Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ianstormtaylor/slate
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: slate@0.101.5
Choose a base ref
...
head repository: ianstormtaylor/slate
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: slate@0.102.0
Choose a head ref
  • 7 commits
  • 82 files changed
  • 7 contributors

Commits on Jan 11, 2024

  1. Bump follow-redirects from 1.15.3 to 1.15.4 (#5589)

    Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.3 to 1.15.4.
    - [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
    - [Commits](follow-redirects/follow-redirects@v1.15.3...v1.15.4)
    
    ---
    updated-dependencies:
    - dependency-name: follow-redirects
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jan 11, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8f2ad02 View commit details

Commits on Jan 24, 2024

  1. Fix useFocused not updated when calling ReactEditor.focus (#5593)

    12joan authored Jan 24, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    54594d0 View commit details
  2. Version Packages (#5595)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    github-actions[bot] and github-actions[bot] authored Jan 24, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    f5253cd View commit details

Commits on Jan 28, 2024

  1. Fix relative url to normalizing-11.md (#5596)

    sunsheeppoplar authored Jan 28, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    cd93871 View commit details

Commits on Feb 7, 2024

  1. Do not move selection outside inline node when composition starts (#5541

    )
    12joan authored Feb 7, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c2ae1ed View commit details
  2. Transform.insertNodes & Transform.insertFragment performance optimize (

    …#5543)
    
    * feat: insertNodes & insertFragment performance optimize
    
    * chore: change set
    
    * feat: add unit test
    
    ---------
    
    Co-authored-by: mainhanu@outlook.com <xingchi.mxc@alibaba-inc.com>
    mainhanu and mainhanu@outlook.com authored Feb 7, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    3aaf3b5 View commit details
  3. Version Packages (#5602)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    github-actions[bot] and github-actions[bot] authored Feb 7, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b04b7e0 View commit details
Showing with 413 additions and 209 deletions.
  1. +1 −1 docs/api/nodes/editor.md
  2. +1 −1 packages/slate-history/package.json
  3. +1 −1 packages/slate-hyperscript/package.json
  4. +12 −0 packages/slate-react/CHANGELOG.md
  5. +2 −2 packages/slate-react/package.json
  6. +3 −20 packages/slate-react/src/components/editable.tsx
  7. +3 −1 packages/slate-react/src/plugin/react-editor.ts
  8. +6 −0 packages/slate/CHANGELOG.md
  9. +1 −1 packages/slate/package.json
  10. +9 −34 packages/slate/src/core/apply.ts
  11. +24 −0 packages/slate/src/core/batch-dirty-paths.ts
  12. +50 −0 packages/slate/src/core/update-dirty-paths.ts
  13. +1 −0 packages/slate/src/interfaces/transforms/node.ts
  14. +1 −0 packages/slate/src/interfaces/transforms/text.ts
  15. +63 −6 packages/slate/src/transforms-node/insert-nodes.ts
  16. +4 −1 packages/slate/src/transforms-text/insert-fragment.ts
  17. +35 −1 packages/slate/test/index.js
  18. +3 −2 packages/slate/test/transforms/insertFragment/of-blocks/block-empty.tsx
  19. +3 −2 packages/slate/test/transforms/insertFragment/of-blocks/block-end.tsx
  20. +2 −2 packages/slate/test/transforms/insertFragment/of-blocks/block-hanging.tsx
  21. +3 −2 packages/slate/test/transforms/insertFragment/of-blocks/block-middle.tsx
  22. +3 −2 packages/slate/test/transforms/insertFragment/of-blocks/block-nested.tsx
  23. +3 −2 packages/slate/test/transforms/insertFragment/of-blocks/block-start.tsx
  24. +3 −2 packages/slate/test/transforms/insertFragment/of-blocks/with-inline.tsx
  25. +3 −2 packages/slate/test/transforms/insertFragment/of-inlines/block-empty.tsx
  26. +3 −2 packages/slate/test/transforms/insertFragment/of-inlines/block-end.tsx
  27. +3 −2 packages/slate/test/transforms/insertFragment/of-inlines/block-middle.tsx
  28. +3 −2 packages/slate/test/transforms/insertFragment/of-inlines/block-start.tsx
  29. +3 −2 packages/slate/test/transforms/insertFragment/of-inlines/inline-empty.tsx
  30. +3 −2 packages/slate/test/transforms/insertFragment/of-inlines/inline-middle.tsx
  31. +3 −2 packages/slate/test/transforms/insertFragment/of-inlines/with-multiple.tsx
  32. +3 −2 packages/slate/test/transforms/insertFragment/of-inlines/with-text.tsx
  33. +3 −2 packages/slate/test/transforms/insertFragment/of-lists/merge-lists.tsx
  34. +3 −2 packages/slate/test/transforms/insertFragment/of-mixed/block-empty.tsx
  35. +3 −2 packages/slate/test/transforms/insertFragment/of-mixed/block-empty2.tsx
  36. +3 −2 packages/slate/test/transforms/insertFragment/of-mixed/block-empty3.tsx
  37. +3 −2 packages/slate/test/transforms/insertFragment/of-mixed/block-end.tsx
  38. +3 −2 packages/slate/test/transforms/insertFragment/of-mixed/block-end2.tsx
  39. +3 −2 packages/slate/test/transforms/insertFragment/of-mixed/block-middle.tsx
  40. +3 −2 packages/slate/test/transforms/insertFragment/of-mixed/block-start.tsx
  41. +3 −2 packages/slate/test/transforms/insertFragment/of-mixed/block-start2.tsx
  42. +3 −2 packages/slate/test/transforms/insertFragment/of-tables/merge-cells-with-nested-blocks.tsx
  43. +3 −2 packages/slate/test/transforms/insertFragment/of-tables/merge-into-empty-cells.tsx
  44. +3 −2 packages/slate/test/transforms/insertFragment/of-tables/merge-into-full-cells.tsx
  45. +2 −2 packages/slate/test/transforms/insertFragment/of-texts/block-across.tsx
  46. +2 −2 packages/slate/test/transforms/insertFragment/of-texts/block-empty.tsx
  47. +2 −2 packages/slate/test/transforms/insertFragment/of-texts/block-end.tsx
  48. +2 −2 packages/slate/test/transforms/insertFragment/of-texts/block-middle.tsx
  49. +2 −2 packages/slate/test/transforms/insertFragment/of-texts/block-start.tsx
  50. +2 −2 packages/slate/test/transforms/insertFragment/of-texts/inline-empty.tsx
  51. +2 −2 packages/slate/test/transforms/insertFragment/of-texts/inline-middle.tsx
  52. +3 −2 packages/slate/test/transforms/insertFragment/of-texts/with-multiple.tsx
  53. +2 −2 packages/slate/test/transforms/insertFragment/voids-false/block.tsx
  54. +2 −2 packages/slate/test/transforms/insertFragment/voids-false/inline.tsx
  55. +2 −1 packages/slate/test/transforms/insertFragment/voids-true/block.tsx
  56. +2 −1 packages/slate/test/transforms/insertFragment/voids-true/inline.tsx
  57. +3 −2 packages/slate/test/transforms/insertNodes/block/block-empty.tsx
  58. +3 −2 packages/slate/test/transforms/insertNodes/block/block-middle.tsx
  59. +3 −2 packages/slate/test/transforms/insertNodes/block/block-void.tsx
  60. +3 −2 packages/slate/test/transforms/insertNodes/block/inline-void.tsx
  61. +3 −2 packages/slate/test/transforms/insertNodes/inline/block-empty.tsx
  62. +3 −2 packages/slate/test/transforms/insertNodes/inline/block-end.tsx
  63. +3 −2 packages/slate/test/transforms/insertNodes/inline/block-middle.tsx
  64. +3 −2 packages/slate/test/transforms/insertNodes/inline/block-start.tsx
  65. +3 −2 packages/slate/test/transforms/insertNodes/inline/block-void.tsx
  66. +3 −2 packages/slate/test/transforms/insertNodes/inline/inline-middle.tsx
  67. +2 −2 packages/slate/test/transforms/insertNodes/path/block.tsx
  68. +2 −2 packages/slate/test/transforms/insertNodes/path/inline.tsx
  69. +11 −7 packages/slate/test/transforms/insertNodes/path/multiple-inline-not-end.tsx
  70. +11 −7 packages/slate/test/transforms/insertNodes/path/multiple-inline.tsx
  71. +2 −1 packages/slate/test/transforms/insertNodes/path/multiple.tsx
  72. +5 −2 packages/slate/test/transforms/insertNodes/path/text.tsx
  73. +2 −2 packages/slate/test/transforms/insertNodes/select-true/block.tsx
  74. +2 −2 packages/slate/test/transforms/insertNodes/selection/none-empty.tsx
  75. +2 −2 packages/slate/test/transforms/insertNodes/selection/none-end.tsx
  76. +2 −2 packages/slate/test/transforms/insertNodes/void/at-path.tsx
  77. +3 −2 packages/slate/test/transforms/insertNodes/void/block-nested.tsx
  78. +3 −2 packages/slate/test/transforms/insertNodes/void/block.tsx
  79. +3 −2 packages/slate/test/transforms/insertNodes/void/inline.tsx
  80. +2 −1 packages/slate/test/transforms/insertNodes/voids-true/block.tsx
  81. +2 −1 packages/slate/test/transforms/insertNodes/voids-true/inline.tsx
  82. +7 −7 yarn.lock
2 changes: 1 addition & 1 deletion docs/api/nodes/editor.md
Original file line number Diff line number Diff line change
@@ -346,7 +346,7 @@ Options: `{force?: boolean; operation?: Operation}`
#### `Editor.withoutNormalizing(editor: Editor, fn: () => void) => void`

Call a function, deferring normalization until after it completes.
See [Normalization - Implications for Other Code](./11-normalizing.md#implications-for-other-code);
See [Normalization - Implications for Other Code](../../concepts/11-normalizing.md#implications-for-other-code);

### Ref Methods

2 changes: 1 addition & 1 deletion packages/slate-history/package.json
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
"devDependencies": {
"@babel/runtime": "^7.23.2",
"lodash": "^4.17.21",
"slate": "^0.101.1",
"slate": "^0.102.0",
"slate-hyperscript": "^0.100.0",
"source-map-loader": "^4.0.1"
},
2 changes: 1 addition & 1 deletion packages/slate-hyperscript/package.json
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
},
"devDependencies": {
"@babel/runtime": "^7.23.2",
"slate": "^0.101.1",
"slate": "^0.102.0",
"source-map-loader": "^4.0.1"
},
"peerDependencies": {
12 changes: 12 additions & 0 deletions packages/slate-react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# slate-react

## 0.102.0

### Patch Changes

- [#5541](https://github.com/ianstormtaylor/slate/pull/5541) [`c2ae1eda`](https://github.com/ianstormtaylor/slate/commit/c2ae1eda91d0aae1cd63bd46af759c542c292a8a) Thanks [@12joan](https://github.com/12joan)! - Do not move selection outside inline node when composition starts

## 0.101.6

### Patch Changes

- [#5593](https://github.com/ianstormtaylor/slate/pull/5593) [`54594d0f`](https://github.com/ianstormtaylor/slate/commit/54594d0f81627166d72c97256203c4b5642a82ff) Thanks [@12joan](https://github.com/12joan)! - Fix: Calling `ReactEditor.focus` doesn't update `useFocused` when running in @testing-library/react

## 0.101.5

### Patch Changes
4 changes: 2 additions & 2 deletions packages/slate-react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "slate-react",
"description": "Tools for building completely customizable richtext editors with React.",
"version": "0.101.5",
"version": "0.102.0",
"license": "MIT",
"repository": "git://github.com/ianstormtaylor/slate.git",
"main": "dist/index.js",
@@ -34,7 +34,7 @@
"@types/resize-observer-browser": "^0.1.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"slate": "^0.101.5",
"slate": "^0.102.0",
"slate-hyperscript": "^0.100.0",
"source-map-loader": "^4.0.1"
},
23 changes: 3 additions & 20 deletions packages/slate-react/src/components/editable.tsx
Original file line number Diff line number Diff line change
@@ -1192,26 +1192,9 @@ export const Editable = (props: EditableProps) => {
setIsComposing(true)

const { selection } = editor
if (selection) {
if (Range.isExpanded(selection)) {
Editor.deleteFragment(editor)
return
}
const inline = Editor.above(editor, {
match: n =>
Element.isElement(n) && Editor.isInline(editor, n),
mode: 'highest',
})
if (inline) {
const [, inlinePath] = inline
if (Editor.isEnd(editor, selection.anchor, inlinePath)) {
const point = Editor.after(editor, inlinePath)!
Transforms.setSelection(editor, {
anchor: point,
focus: point,
})
}
}
if (selection && Range.isExpanded(selection)) {
Editor.deleteFragment(editor)
return
}
}
},
4 changes: 3 additions & 1 deletion packages/slate-react/src/plugin/react-editor.ts
Original file line number Diff line number Diff line change
@@ -447,8 +447,10 @@ export const ReactEditor: ReactEditorInterface = {
Transforms.select(editor, Editor.start(editor, []))
editor.onChange()
}
el.focus({ preventScroll: true })
// IS_FOCUSED should be set before calling el.focus() to ensure that
// FocusedContext is updated to the correct value
IS_FOCUSED.set(editor, true)
el.focus({ preventScroll: true })
}
},

6 changes: 6 additions & 0 deletions packages/slate/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# slate

## 0.102.0

### Minor Changes

- [#5543](https://github.com/ianstormtaylor/slate/pull/5543) [`3aaf3b51`](https://github.com/ianstormtaylor/slate/commit/3aaf3b517c2020c198bffe0f3aa8156746914408) Thanks [@mainhanu](https://github.com/mainhanu)! - Transform.insertNodes & Transform.insertFragment performance optimize

## 0.101.5

### Patch Changes
2 changes: 1 addition & 1 deletion packages/slate/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "slate",
"description": "A completely customizable framework for building rich text editors.",
"version": "0.101.5",
"version": "0.102.0",
"license": "MIT",
"repository": "git://github.com/ianstormtaylor/slate.git",
"main": "dist/index.js",
43 changes: 9 additions & 34 deletions packages/slate/src/core/apply.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { PathRef } from '../interfaces/path-ref'
import { PointRef } from '../interfaces/point-ref'
import { RangeRef } from '../interfaces/range-ref'
import { DIRTY_PATH_KEYS, DIRTY_PATHS, FLUSHING } from '../utils/weak-maps'
import { FLUSHING } from '../utils/weak-maps'
import { Path } from '../interfaces/path'
import { Transforms } from '../interfaces/transforms'
import { WithEditorFirstArg } from '../utils/types'
import { Editor } from '../interfaces/editor'
import { isBatchingDirtyPaths } from './batch-dirty-paths'
import { updateDirtyPaths } from './update-dirty-paths'

export const apply: WithEditorFirstArg<Editor['apply']> = (editor, op) => {
for (const ref of Editor.pathRefs(editor)) {
@@ -20,41 +22,14 @@ export const apply: WithEditorFirstArg<Editor['apply']> = (editor, op) => {
RangeRef.transform(ref, op)
}

const oldDirtyPaths = DIRTY_PATHS.get(editor) || []
const oldDirtyPathKeys = DIRTY_PATH_KEYS.get(editor) || new Set()
let dirtyPaths: Path[]
let dirtyPathKeys: Set<string>

const add = (path: Path | null) => {
if (path) {
const key = path.join(',')

if (!dirtyPathKeys.has(key)) {
dirtyPathKeys.add(key)
dirtyPaths.push(path)
}
}
}

if (Path.operationCanTransformPath(op)) {
dirtyPaths = []
dirtyPathKeys = new Set()
for (const path of oldDirtyPaths) {
const newPath = Path.transform(path, op)
add(newPath)
}
} else {
dirtyPaths = oldDirtyPaths
dirtyPathKeys = oldDirtyPathKeys
}

const newDirtyPaths = editor.getDirtyPaths(op)
for (const path of newDirtyPaths) {
add(path)
// update dirty paths
if (!isBatchingDirtyPaths(editor)) {
const transform = Path.operationCanTransformPath(op)
? (p: Path) => Path.transform(p, op)
: undefined
updateDirtyPaths(editor, editor.getDirtyPaths(op), transform)
}

DIRTY_PATHS.set(editor, dirtyPaths)
DIRTY_PATH_KEYS.set(editor, dirtyPathKeys)
Transforms.transform(editor, op)
editor.operations.push(op)
Editor.normalize(editor, {
24 changes: 24 additions & 0 deletions packages/slate/src/core/batch-dirty-paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// perf

import { Editor } from '../interfaces/editor'

const BATCHING_DIRTY_PATHS: WeakMap<Editor, boolean> = new WeakMap()

export const isBatchingDirtyPaths = (editor: Editor) => {
return BATCHING_DIRTY_PATHS.get(editor) || false
}

export const batchDirtyPaths = (
editor: Editor,
fn: () => void,
update: () => void
) => {
const value = BATCHING_DIRTY_PATHS.get(editor) || false
BATCHING_DIRTY_PATHS.set(editor, true)
try {
fn()
update()
} finally {
BATCHING_DIRTY_PATHS.set(editor, value)
}
}
50 changes: 50 additions & 0 deletions packages/slate/src/core/update-dirty-paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { DIRTY_PATH_KEYS, DIRTY_PATHS } from '../utils/weak-maps'
import { Path } from '../interfaces/path'
import { Editor } from '../interfaces/editor'

/**
* update editor dirty paths
*
* @param newDirtyPaths: Path[]; new dirty paths
* @param transform: (p: Path) => Path | null; how to transform existing dirty paths
*/
export function updateDirtyPaths(
editor: Editor,
newDirtyPaths: Path[],
transform?: (p: Path) => Path | null
) {
const oldDirtyPaths = DIRTY_PATHS.get(editor) || []
const oldDirtyPathKeys = DIRTY_PATH_KEYS.get(editor) || new Set()
let dirtyPaths: Path[]
let dirtyPathKeys: Set<string>

const add = (path: Path | null) => {
if (path) {
const key = path.join(',')

if (!dirtyPathKeys.has(key)) {
dirtyPathKeys.add(key)
dirtyPaths.push(path)
}
}
}

if (transform) {
dirtyPaths = []
dirtyPathKeys = new Set()
for (const path of oldDirtyPaths) {
const newPath = transform(path)
add(newPath)
}
} else {
dirtyPaths = oldDirtyPaths
dirtyPathKeys = oldDirtyPathKeys
}

for (const path of newDirtyPaths) {
add(path)
}

DIRTY_PATHS.set(editor, dirtyPaths)
DIRTY_PATH_KEYS.set(editor, dirtyPathKeys)
}
1 change: 1 addition & 0 deletions packages/slate/src/interfaces/transforms/node.ts
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ export interface NodeInsertNodesOptions<T extends Node> {
hanging?: boolean
select?: boolean
voids?: boolean
batchDirty?: boolean
}

export interface NodeTransforms {
1 change: 1 addition & 0 deletions packages/slate/src/interfaces/transforms/text.ts
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ export interface TextInsertFragmentOptions {
at?: Location
hanging?: boolean
voids?: boolean
batchDirty?: boolean
}

export interface TextInsertTextOptions {
69 changes: 63 additions & 6 deletions packages/slate/src/transforms-node/insert-nodes.ts
Original file line number Diff line number Diff line change
@@ -8,14 +8,22 @@ import { Text } from '../interfaces/text'
import { Element } from '../interfaces/element'
import { Path } from '../interfaces/path'
import { getDefaultInsertLocation } from '../utils'
import { batchDirtyPaths } from '../core/batch-dirty-paths'
import { BaseInsertNodeOperation } from '../interfaces'
import { updateDirtyPaths } from '../core/update-dirty-paths'

export const insertNodes: NodeTransforms['insertNodes'] = (
editor,
nodes,
options = {}
) => {
Editor.withoutNormalizing(editor, () => {
const { hanging = false, voids = false, mode = 'lowest' } = options
const {
hanging = false,
voids = false,
mode = 'lowest',
batchDirty = true,
} = options
let { at, match, select } = options

if (Node.isNode(nodes)) {
@@ -91,12 +99,61 @@ export const insertNodes: NodeTransforms['insertNodes'] = (
return
}

for (const node of nodes) {
const path = parentPath.concat(index)
index++
editor.apply({ type: 'insert_node', path, node })
at = Path.next(at)
if (batchDirty) {
// PERF: batch update dirty paths
// batched ops used to transform existing dirty paths
const batchedOps: BaseInsertNodeOperation[] = []
const newDirtyPaths: Path[] = Path.levels(parentPath)
batchDirtyPaths(
editor,
() => {
for (const node of nodes as Node[]) {
const path = parentPath.concat(index)
index++

const op: BaseInsertNodeOperation = {
type: 'insert_node',
path,
node,
}
editor.apply(op)
at = Path.next(at as Path)

batchedOps.push(op)
if (!Text.isText) {
newDirtyPaths.push(path)
} else {
newDirtyPaths.push(
...Array.from(Node.nodes(node), ([, p]) => path.concat(p))
)
}
}
},
() => {
updateDirtyPaths(editor, newDirtyPaths, p => {
let newPath: Path | null = p
for (const op of batchedOps) {
if (Path.operationCanTransformPath(op)) {
newPath = Path.transform(newPath, op)
if (!newPath) {
return null
}
}
}
return newPath
})
}
)
} else {
for (const node of nodes as Node[]) {
const path = parentPath.concat(index)
index++

editor.apply({ type: 'insert_node', path, node })
at = Path.next(at as Path)
}
}

at = Path.previous(at)

if (select) {
5 changes: 4 additions & 1 deletion packages/slate/src/transforms-text/insert-fragment.ts
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ export const insertFragment: TextTransforms['insertFragment'] = (
) => {
Editor.withoutNormalizing(editor, () => {
const { hanging = false, voids = false } = options
let { at = getDefaultInsertLocation(editor) } = options
let { at = getDefaultInsertLocation(editor), batchDirty = true } = options

if (!fragment.length) {
return
@@ -187,6 +187,7 @@ export const insertFragment: TextTransforms['insertFragment'] = (
match: n => Text.isText(n) || Editor.isInline(editor, n),
mode: 'highest',
voids,
batchDirty,
})

if (isBlockEmpty && !starts.length && middles.length && !ends.length) {
@@ -198,13 +199,15 @@ export const insertFragment: TextTransforms['insertFragment'] = (
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
mode: 'lowest',
voids,
batchDirty,
})

Transforms.insertNodes(editor, ends, {
at: endRef.current!,
match: n => Text.isText(n) || Editor.isInline(editor, n),
mode: 'highest',
voids,
batchDirty,
})

if (!options.at) {
36 changes: 35 additions & 1 deletion packages/slate/test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'assert'
import { cloneDeep } from 'lodash'
import { fixtures } from '../../../support/fixtures'
import { Editor } from 'slate'
import { Editor, createEditor } from 'slate'
import { createHyperscript } from 'slate-hyperscript'

describe('slate', () => {
@@ -45,6 +46,31 @@ describe('slate', () => {
const result = test(input)
assert.deepEqual(result, output)
})
// make sure with or without batchDirty, the normalize result is the same
const testBatchDirty = ({ module }) => {
const { input, run } = module

const input2 = createEditor()
input2.children = cloneDeep(input.children)
input2.selection = cloneDeep(input.selection)

const dirties1 = []
const dirties2 = []

const editor1 = withBatchTest(withTest(input), dirties1)
const editor2 = withBatchTest(withTest(input2), dirties2)

run(editor1, { batchDirty: true })
run(editor2, { batchDirty: false })

assert.equal(dirties1.join(' '), dirties2.join(' '))
}
fixtures(__dirname, 'transforms/insertNodes', ({ module }) => {
testBatchDirty({ module })
})
fixtures(__dirname, 'transforms/insertFragment', ({ module }) => {
testBatchDirty({ module })
})
})
const withTest = editor => {
const { isInline, isVoid, isElementReadOnly, isSelectable } = editor
@@ -62,6 +88,14 @@ const withTest = editor => {
}
return editor
}
const withBatchTest = (editor, dirties) => {
const { normalizeNode } = editor
editor.normalizeNode = ([node, path]) => {
dirties.push(JSON.stringify(path))
normalizeNode([node, path])
}
return editor
}
export const jsx = createHyperscript({
elements: {
block: {},
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
@@ -11,7 +11,8 @@ export const run = editor => {
</block>
<block>two</block>
<block>three</block>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<block>one</block>
<block>two</block>
<block>three</block>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ const fragment = (
<block>two</block>
</fragment>
)
export const run = editor => {
Transforms.insertFragment(editor, fragment)
export const run = (editor, options = {}) => {
Transforms.insertFragment(editor, fragment, options)
}
export const input = (
<editor>
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<block>one</block>
<block>two</block>
<block>three</block>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<block>one</block>
<block>two</block>
<block>three</block>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<block>one</block>
<block>two</block>
<block>three</block>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
@@ -15,7 +15,8 @@ export const run = editor => {
<block>
seven<inline>eight</inline>nine
</block>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<inline>fragment</inline>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<inline>fragment</inline>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<inline>fragment</inline>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<inline>fragment</inline>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<inline>fragment</inline>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<inline>fragment</inline>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<inline>one</inline>
<inline>two</inline>
<inline>three</inline>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
one
<inline>two</inline>
three
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,13 +2,14 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<block>
<block>3</block>
<block>4</block>
</block>
</block>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<text>one</text>
<block>two</block>
<text>three</text>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,13 +2,14 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<block>two</block>
<text>three</text>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,13 +2,14 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<text>one</text>
<block>two</block>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<text>one</text>
<block>two</block>
<text>three</text>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,13 +2,14 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<text>one</text>
<block>two</block>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<text>one</text>
<block>two</block>
<text>three</text>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<text>one</text>
<block>two</block>
<text>three</text>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,13 +2,14 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<block>one</block>
<text>two</text>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<block>
@@ -16,7 +16,8 @@ export const run = editor => {
</block>
</block>
</block>
</block>
</block>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<block>
@@ -12,7 +12,8 @@ export const run = editor => {
<block>2</block>
</block>
</block>
</block>
</block>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<block>
@@ -12,7 +12,8 @@ export const run = editor => {
<block>New 2</block>
</block>
</block>
</block>
</block>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>)
export const run = (editor, options = {}) => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>, options)
}
export const input = (
<editor>
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>)
export const run = (editor, options = {}) => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>, options)
}
export const input = (
<editor>
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>)
export const run = (editor, options = {}) => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>, options)
}
export const input = (
<editor>
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>)
export const run = (editor, options = {}) => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>, options)
}
export const input = (
<editor>
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>)
export const run = (editor, options = {}) => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>, options)
}
export const input = (
<editor>
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>)
export const run = (editor, options = {}) => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>, options)
}
export const input = (
<editor>
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>)
export const run = (editor, options = {}) => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>, options)
}
export const input = (
<editor>
Original file line number Diff line number Diff line change
@@ -2,13 +2,14 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(
editor,
<fragment>
<text>one</text>
<text>two</text>
</fragment>
</fragment>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>)
export const run = (editor, options = {}) => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>, options)
}
export const input = (
<editor>
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>)
export const run = (editor, options = {}) => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>, options)
}
export const input = (
<editor>
Original file line number Diff line number Diff line change
@@ -2,9 +2,10 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>, {
voids: true,
...options,
})
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,9 +2,10 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertFragment(editor, <fragment>fragment</fragment>, {
voids: true,
...options,
})
}
export const input = (
Original file line number Diff line number Diff line change
@@ -10,12 +10,13 @@ export const input = (
<block>not empty</block>
</editor>
)
export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<block>
<text />
</block>
</block>,
options
)
}
export const output = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<block>
<text />
</block>
</block>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<block>
<text />
</block>
</block>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<block>
<text />
</block>
</block>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -9,12 +9,13 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<inline void>
<text />
</inline>
</inline>,
options
)
}
export const output = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<inline void>
<text />
</inline>
</inline>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<inline void>
<text />
</inline>
</inline>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<inline void>
<text />
</inline>
</inline>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<inline void>
<text />
</inline>
</inline>,
options
)
}
export const input = (
Original file line number Diff line number Diff line change
@@ -2,12 +2,13 @@
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<inline void>
<text />
</inline>
</inline>,
options
)
}
export const input = (
4 changes: 2 additions & 2 deletions packages/slate/test/transforms/insertNodes/path/block.tsx
Original file line number Diff line number Diff line change
@@ -10,13 +10,13 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<block>
<text />
</block>,
{ at: [0] }
{ at: [0], ...options }
)
}
export const output = (
4 changes: 2 additions & 2 deletions packages/slate/test/transforms/insertNodes/path/inline.tsx
Original file line number Diff line number Diff line change
@@ -10,13 +10,13 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<inline>
<text />
</inline>,
{ at: [0, 0] }
{ at: [0, 0], ...options }
)
}
export const output = (
Original file line number Diff line number Diff line change
@@ -11,13 +11,17 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
Transforms.insertNodes(editor, [
<inline>
<text />
</inline>,
<text>world</text>,
])
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
[
<inline>
<text />
</inline>,
<text>world</text>,
],
options
)
}
export const output = (
<editor>
Original file line number Diff line number Diff line change
@@ -10,13 +10,17 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
Transforms.insertNodes(editor, [
<inline>
<text />
</inline>,
<text>world</text>,
])
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
[
<inline>
<text />
</inline>,
<text>world</text>,
],
options
)
}
export const output = (
<editor>
3 changes: 2 additions & 1 deletion packages/slate/test/transforms/insertNodes/path/multiple.tsx
Original file line number Diff line number Diff line change
@@ -10,9 +10,10 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(editor, [<block>two</block>, <block>three</block>], {
at: [0],
...options,
})
}
export const output = (
7 changes: 5 additions & 2 deletions packages/slate/test/transforms/insertNodes/path/text.tsx
Original file line number Diff line number Diff line change
@@ -10,8 +10,11 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
Transforms.insertNodes(editor, <text>another</text>, { at: [0, 0] })
export const run = (editor, options = {}) => {
Transforms.insertNodes(editor, <text>another</text>, {
at: [0, 0],
...options,
})
}
export const output = (
<editor>
Original file line number Diff line number Diff line change
@@ -10,13 +10,13 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<block>
<text />
</block>,
{ at: [0], select: true }
{ at: [0], select: true, ...options }
)
}
export const output = (
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@ import { Transforms } from 'slate'
import { jsx } from '../../..'

export const input = <editor />
export const run = editor => {
Transforms.insertNodes(editor, <block>one</block>)
export const run = (editor, options = {}) => {
Transforms.insertNodes(editor, <block>one</block>, options)
}
export const output = (
<editor>
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ export const input = (
<block>one</block>
</editor>
)
export const run = editor => {
Transforms.insertNodes(editor, <block>two</block>)
export const run = (editor, options = {}) => {
Transforms.insertNodes(editor, <block>two</block>, options)
}
export const output = (
<editor>
4 changes: 2 additions & 2 deletions packages/slate/test/transforms/insertNodes/void/at-path.tsx
Original file line number Diff line number Diff line change
@@ -10,13 +10,13 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<block void>
<text>two</text>
</block>,
{ at: [1], select: true }
{ at: [1], select: true, ...options }
)
}
export const output = (
Original file line number Diff line number Diff line change
@@ -10,14 +10,15 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<block void>
<block>
<text>two</text>
</block>
</block>
</block>,
options
)
}
export const output = (
5 changes: 3 additions & 2 deletions packages/slate/test/transforms/insertNodes/void/block.tsx
Original file line number Diff line number Diff line change
@@ -10,12 +10,13 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<block void>
<text>two</text>
</block>
</block>,
options
)
}
export const output = (
5 changes: 3 additions & 2 deletions packages/slate/test/transforms/insertNodes/void/inline.tsx
Original file line number Diff line number Diff line change
@@ -14,12 +14,13 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(
editor,
<inline void>
<text>four</text>
</inline>
</inline>,
options
)
}
export const output = (
Original file line number Diff line number Diff line change
@@ -10,10 +10,11 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(editor, <text>two</text>, {
at: [0, 1],
voids: true,
options,
})
}
export const output = (
Original file line number Diff line number Diff line change
@@ -14,10 +14,11 @@ export const input = (
</block>
</editor>
)
export const run = editor => {
export const run = (editor, options = {}) => {
Transforms.insertNodes(editor, <text>four</text>, {
at: [0, 1, 1],
voids: true,
options,
})
}
export const output = (
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -6997,12 +6997,12 @@ __metadata:
linkType: hard

"follow-redirects@npm:^1.15.0":
version: 1.15.3
resolution: "follow-redirects@npm:1.15.3"
version: 1.15.4
resolution: "follow-redirects@npm:1.15.4"
peerDependenciesMeta:
debug:
optional: true
checksum: 60d98693f4976892f8c654b16ef6d1803887a951898857ab0cdc009570b1c06314ad499505b7a040ac5b98144939f8597766e5e6a6859c0945d157b473aa6f5f
checksum: 2e8f5f259a6b02dfa8dc199e08431848a7c3beed32eb4c19945966164a52c89f07b86c3afcc32ebe4279cf0a960520e45a63013d6350309c5ec90133c5d9351a
languageName: node
linkType: hard

@@ -13265,7 +13265,7 @@ __metadata:
"@babel/runtime": "npm:^7.23.2"
is-plain-object: "npm:^5.0.0"
lodash: "npm:^4.17.21"
slate: "npm:^0.101.1"
slate: "npm:^0.102.0"
slate-hyperscript: "npm:^0.100.0"
source-map-loader: "npm:^4.0.1"
peerDependencies:
@@ -13279,7 +13279,7 @@ __metadata:
dependencies:
"@babel/runtime": "npm:^7.23.2"
is-plain-object: "npm:^5.0.0"
slate: "npm:^0.101.1"
slate: "npm:^0.102.0"
source-map-loader: "npm:^4.0.1"
peerDependencies:
slate: ">=0.65.3"
@@ -13390,7 +13390,7 @@ __metadata:
react: "npm:^18.2.0"
react-dom: "npm:^18.2.0"
scroll-into-view-if-needed: "npm:^3.1.0"
slate: "npm:^0.101.5"
slate: "npm:^0.102.0"
slate-hyperscript: "npm:^0.100.0"
source-map-loader: "npm:^4.0.1"
tiny-invariant: "npm:1.3.1"
@@ -13401,7 +13401,7 @@ __metadata:
languageName: unknown
linkType: soft

"slate@npm:^0.101.1, slate@npm:^0.101.5, slate@workspace:*, slate@workspace:packages/slate":
"slate@npm:^0.102.0, slate@workspace:*, slate@workspace:packages/slate":
version: 0.0.0-use.local
resolution: "slate@workspace:packages/slate"
dependencies: