From 31b825825af9a453154e24fd0648bbeec83a657d Mon Sep 17 00:00:00 2001 From: "mainhanu@outlook.com" Date: Tue, 31 Oct 2023 19:32:24 +0800 Subject: [PATCH 1/3] feat: insertNodes & insertFragment performance optimize --- packages/slate/src/core/apply.ts | 43 ++++----------- packages/slate/src/core/batch-dirty-paths.ts | 24 +++++++++ packages/slate/src/core/update-dirty-paths.ts | 50 +++++++++++++++++ .../slate/src/transforms-node/insert-nodes.ts | 54 ++++++++++++++++--- 4 files changed, 131 insertions(+), 40 deletions(-) create mode 100644 packages/slate/src/core/batch-dirty-paths.ts create mode 100644 packages/slate/src/core/update-dirty-paths.ts diff --git a/packages/slate/src/core/apply.ts b/packages/slate/src/core/apply.ts index c08df9572e..78805f1d4d 100644 --- a/packages/slate/src/core/apply.ts +++ b/packages/slate/src/core/apply.ts @@ -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, op) => { for (const ref of Editor.pathRefs(editor)) { @@ -20,41 +22,14 @@ export const apply: WithEditorFirstArg = (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 - - 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, { diff --git a/packages/slate/src/core/batch-dirty-paths.ts b/packages/slate/src/core/batch-dirty-paths.ts new file mode 100644 index 0000000000..bd9eec30ff --- /dev/null +++ b/packages/slate/src/core/batch-dirty-paths.ts @@ -0,0 +1,24 @@ +// perf + +import { Editor } from '../interfaces/editor' + +const BATCHING_DIRTY_PATHS: WeakMap = 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) + } +} diff --git a/packages/slate/src/core/update-dirty-paths.ts b/packages/slate/src/core/update-dirty-paths.ts new file mode 100644 index 0000000000..bd29d92840 --- /dev/null +++ b/packages/slate/src/core/update-dirty-paths.ts @@ -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 + + 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) +} diff --git a/packages/slate/src/transforms-node/insert-nodes.ts b/packages/slate/src/transforms-node/insert-nodes.ts index d5b6e42c61..3854f00028 100644 --- a/packages/slate/src/transforms-node/insert-nodes.ts +++ b/packages/slate/src/transforms-node/insert-nodes.ts @@ -8,6 +8,9 @@ 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, @@ -89,12 +92,51 @@ 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) - } + // 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 + }) + } + ) + at = Path.previous(at) if (select) { From 263d22aa60423c7be2eba808c9c8ac40a9b09944 Mon Sep 17 00:00:00 2001 From: "mainhanu@outlook.com" Date: Tue, 31 Oct 2023 20:47:22 +0800 Subject: [PATCH 2/3] chore: change set --- .changeset/witty-apples-return.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/witty-apples-return.md diff --git a/.changeset/witty-apples-return.md b/.changeset/witty-apples-return.md new file mode 100644 index 0000000000..4fd9c41bc3 --- /dev/null +++ b/.changeset/witty-apples-return.md @@ -0,0 +1,5 @@ +--- +'slate': minor +--- + +Transform.insertNodes & Transform.insertFragment performance optimize From a0d64d0c58b4e33266ebe77b42c172770d9c073d Mon Sep 17 00:00:00 2001 From: "mainhanu@outlook.com" Date: Tue, 7 Nov 2023 09:23:30 +0800 Subject: [PATCH 3/3] feat: add unit test --- .../slate/src/interfaces/transforms/node.ts | 1 + .../slate/src/interfaces/transforms/text.ts | 1 + .../slate/src/transforms-node/insert-nodes.ts | 97 +++++++++++-------- .../src/transforms-text/insert-fragment.ts | 5 +- packages/slate/test/index.js | 36 ++++++- .../insertFragment/of-blocks/block-empty.tsx | 5 +- .../insertFragment/of-blocks/block-end.tsx | 5 +- .../of-blocks/block-hanging.tsx | 4 +- .../insertFragment/of-blocks/block-middle.tsx | 5 +- .../insertFragment/of-blocks/block-nested.tsx | 5 +- .../insertFragment/of-blocks/block-start.tsx | 5 +- .../insertFragment/of-blocks/with-inline.tsx | 5 +- .../insertFragment/of-inlines/block-empty.tsx | 5 +- .../insertFragment/of-inlines/block-end.tsx | 5 +- .../of-inlines/block-middle.tsx | 5 +- .../insertFragment/of-inlines/block-start.tsx | 5 +- .../of-inlines/inline-empty.tsx | 5 +- .../of-inlines/inline-middle.tsx | 5 +- .../of-inlines/with-multiple.tsx | 5 +- .../insertFragment/of-inlines/with-text.tsx | 5 +- .../insertFragment/of-lists/merge-lists.tsx | 5 +- .../insertFragment/of-mixed/block-empty.tsx | 5 +- .../insertFragment/of-mixed/block-empty2.tsx | 5 +- .../insertFragment/of-mixed/block-empty3.tsx | 5 +- .../insertFragment/of-mixed/block-end.tsx | 5 +- .../insertFragment/of-mixed/block-end2.tsx | 5 +- .../insertFragment/of-mixed/block-middle.tsx | 5 +- .../insertFragment/of-mixed/block-start.tsx | 5 +- .../insertFragment/of-mixed/block-start2.tsx | 5 +- .../merge-cells-with-nested-blocks.tsx | 5 +- .../of-tables/merge-into-empty-cells.tsx | 5 +- .../of-tables/merge-into-full-cells.tsx | 5 +- .../insertFragment/of-texts/block-across.tsx | 4 +- .../insertFragment/of-texts/block-empty.tsx | 4 +- .../insertFragment/of-texts/block-end.tsx | 4 +- .../insertFragment/of-texts/block-middle.tsx | 4 +- .../insertFragment/of-texts/block-start.tsx | 4 +- .../insertFragment/of-texts/inline-empty.tsx | 4 +- .../insertFragment/of-texts/inline-middle.tsx | 4 +- .../insertFragment/of-texts/with-multiple.tsx | 5 +- .../insertFragment/voids-false/block.tsx | 4 +- .../insertFragment/voids-false/inline.tsx | 4 +- .../insertFragment/voids-true/block.tsx | 3 +- .../insertFragment/voids-true/inline.tsx | 3 +- .../insertNodes/block/block-empty.tsx | 5 +- .../insertNodes/block/block-middle.tsx | 5 +- .../insertNodes/block/block-void.tsx | 5 +- .../insertNodes/block/inline-void.tsx | 5 +- .../insertNodes/inline/block-empty.tsx | 5 +- .../insertNodes/inline/block-end.tsx | 5 +- .../insertNodes/inline/block-middle.tsx | 5 +- .../insertNodes/inline/block-start.tsx | 5 +- .../insertNodes/inline/block-void.tsx | 5 +- .../insertNodes/inline/inline-middle.tsx | 5 +- .../transforms/insertNodes/path/block.tsx | 4 +- .../transforms/insertNodes/path/inline.tsx | 4 +- .../path/multiple-inline-not-end.tsx | 18 ++-- .../insertNodes/path/multiple-inline.tsx | 18 ++-- .../transforms/insertNodes/path/multiple.tsx | 3 +- .../test/transforms/insertNodes/path/text.tsx | 7 +- .../insertNodes/select-true/block.tsx | 4 +- .../insertNodes/selection/none-empty.tsx | 4 +- .../insertNodes/selection/none-end.tsx | 4 +- .../transforms/insertNodes/void/at-path.tsx | 4 +- .../insertNodes/void/block-nested.tsx | 5 +- .../transforms/insertNodes/void/block.tsx | 5 +- .../transforms/insertNodes/void/inline.tsx | 5 +- .../insertNodes/voids-true/block.tsx | 3 +- .../insertNodes/voids-true/inline.tsx | 3 +- 69 files changed, 286 insertions(+), 176 deletions(-) diff --git a/packages/slate/src/interfaces/transforms/node.ts b/packages/slate/src/interfaces/transforms/node.ts index 4067fb3dd5..33cf35d752 100644 --- a/packages/slate/src/interfaces/transforms/node.ts +++ b/packages/slate/src/interfaces/transforms/node.ts @@ -9,6 +9,7 @@ export interface NodeInsertNodesOptions { hanging?: boolean select?: boolean voids?: boolean + batchDirty?: boolean } export interface NodeTransforms { diff --git a/packages/slate/src/interfaces/transforms/text.ts b/packages/slate/src/interfaces/transforms/text.ts index f177ce2588..20765f45a5 100644 --- a/packages/slate/src/interfaces/transforms/text.ts +++ b/packages/slate/src/interfaces/transforms/text.ts @@ -15,6 +15,7 @@ export interface TextInsertFragmentOptions { at?: Location hanging?: boolean voids?: boolean + batchDirty?: boolean } export interface TextInsertTextOptions { diff --git a/packages/slate/src/transforms-node/insert-nodes.ts b/packages/slate/src/transforms-node/insert-nodes.ts index 3854f00028..3550cb5ee6 100644 --- a/packages/slate/src/transforms-node/insert-nodes.ts +++ b/packages/slate/src/transforms-node/insert-nodes.ts @@ -18,7 +18,12 @@ export const insertNodes: NodeTransforms['insertNodes'] = ( 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)) { @@ -92,50 +97,60 @@ export const insertNodes: NodeTransforms['insertNodes'] = ( return } - // 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)) - ) + 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 + }, + () => { + 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 - }) + 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) diff --git a/packages/slate/src/transforms-text/insert-fragment.ts b/packages/slate/src/transforms-text/insert-fragment.ts index 9430b777ac..78780b2738 100644 --- a/packages/slate/src/transforms-text/insert-fragment.ts +++ b/packages/slate/src/transforms-text/insert-fragment.ts @@ -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,6 +199,7 @@ export const insertFragment: TextTransforms['insertFragment'] = ( match: n => Element.isElement(n) && Editor.isBlock(editor, n), mode: 'lowest', voids, + batchDirty, }) Transforms.insertNodes(editor, ends, { @@ -205,6 +207,7 @@ export const insertFragment: TextTransforms['insertFragment'] = ( match: n => Text.isText(n) || Editor.isInline(editor, n), mode: 'highest', voids, + batchDirty, }) if (!options.at) { diff --git a/packages/slate/test/index.js b/packages/slate/test/index.js index 92cf7181f0..08cdc06e18 100644 --- a/packages/slate/test/index.js +++ b/packages/slate/test/index.js @@ -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: {}, diff --git a/packages/slate/test/transforms/insertFragment/of-blocks/block-empty.tsx b/packages/slate/test/transforms/insertFragment/of-blocks/block-empty.tsx index bbf1e37c48..a35a76052e 100644 --- a/packages/slate/test/transforms/insertFragment/of-blocks/block-empty.tsx +++ b/packages/slate/test/transforms/insertFragment/of-blocks/block-empty.tsx @@ -2,7 +2,7 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, @@ -11,7 +11,8 @@ export const run = editor => { two three - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-blocks/block-end.tsx b/packages/slate/test/transforms/insertFragment/of-blocks/block-end.tsx index a9d002a1c7..bbcc257952 100644 --- a/packages/slate/test/transforms/insertFragment/of-blocks/block-end.tsx +++ b/packages/slate/test/transforms/insertFragment/of-blocks/block-end.tsx @@ -2,14 +2,15 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two three - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-blocks/block-hanging.tsx b/packages/slate/test/transforms/insertFragment/of-blocks/block-hanging.tsx index 4a35025fb3..5562c2ee8b 100644 --- a/packages/slate/test/transforms/insertFragment/of-blocks/block-hanging.tsx +++ b/packages/slate/test/transforms/insertFragment/of-blocks/block-hanging.tsx @@ -8,8 +8,8 @@ const fragment = ( two ) -export const run = editor => { - Transforms.insertFragment(editor, fragment) +export const run = (editor, options = {}) => { + Transforms.insertFragment(editor, fragment, options) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-blocks/block-middle.tsx b/packages/slate/test/transforms/insertFragment/of-blocks/block-middle.tsx index 501698382b..ccc881ce14 100644 --- a/packages/slate/test/transforms/insertFragment/of-blocks/block-middle.tsx +++ b/packages/slate/test/transforms/insertFragment/of-blocks/block-middle.tsx @@ -2,14 +2,15 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two three - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-blocks/block-nested.tsx b/packages/slate/test/transforms/insertFragment/of-blocks/block-nested.tsx index f9baea204e..a75de751b5 100644 --- a/packages/slate/test/transforms/insertFragment/of-blocks/block-nested.tsx +++ b/packages/slate/test/transforms/insertFragment/of-blocks/block-nested.tsx @@ -2,14 +2,15 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two three - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-blocks/block-start.tsx b/packages/slate/test/transforms/insertFragment/of-blocks/block-start.tsx index c496968906..63d1519866 100644 --- a/packages/slate/test/transforms/insertFragment/of-blocks/block-start.tsx +++ b/packages/slate/test/transforms/insertFragment/of-blocks/block-start.tsx @@ -2,14 +2,15 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two three - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-blocks/with-inline.tsx b/packages/slate/test/transforms/insertFragment/of-blocks/with-inline.tsx index 8c7e0ce6c6..2101bf3468 100644 --- a/packages/slate/test/transforms/insertFragment/of-blocks/with-inline.tsx +++ b/packages/slate/test/transforms/insertFragment/of-blocks/with-inline.tsx @@ -2,7 +2,7 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, @@ -15,7 +15,8 @@ export const run = editor => { seveneightnine - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-inlines/block-empty.tsx b/packages/slate/test/transforms/insertFragment/of-inlines/block-empty.tsx index 8d241c4658..f35f4747ba 100644 --- a/packages/slate/test/transforms/insertFragment/of-inlines/block-empty.tsx +++ b/packages/slate/test/transforms/insertFragment/of-inlines/block-empty.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, fragment - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-inlines/block-end.tsx b/packages/slate/test/transforms/insertFragment/of-inlines/block-end.tsx index cbbec2395c..beedf557d9 100644 --- a/packages/slate/test/transforms/insertFragment/of-inlines/block-end.tsx +++ b/packages/slate/test/transforms/insertFragment/of-inlines/block-end.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, fragment - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-inlines/block-middle.tsx b/packages/slate/test/transforms/insertFragment/of-inlines/block-middle.tsx index 5b8343bbd9..8817532028 100644 --- a/packages/slate/test/transforms/insertFragment/of-inlines/block-middle.tsx +++ b/packages/slate/test/transforms/insertFragment/of-inlines/block-middle.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, fragment - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-inlines/block-start.tsx b/packages/slate/test/transforms/insertFragment/of-inlines/block-start.tsx index 75685936c6..d4bab23fb8 100644 --- a/packages/slate/test/transforms/insertFragment/of-inlines/block-start.tsx +++ b/packages/slate/test/transforms/insertFragment/of-inlines/block-start.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, fragment - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-inlines/inline-empty.tsx b/packages/slate/test/transforms/insertFragment/of-inlines/inline-empty.tsx index 0a36de5bba..84493382b7 100644 --- a/packages/slate/test/transforms/insertFragment/of-inlines/inline-empty.tsx +++ b/packages/slate/test/transforms/insertFragment/of-inlines/inline-empty.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, fragment - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-inlines/inline-middle.tsx b/packages/slate/test/transforms/insertFragment/of-inlines/inline-middle.tsx index 1f91b64d56..2354fda2fb 100644 --- a/packages/slate/test/transforms/insertFragment/of-inlines/inline-middle.tsx +++ b/packages/slate/test/transforms/insertFragment/of-inlines/inline-middle.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, fragment - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-inlines/with-multiple.tsx b/packages/slate/test/transforms/insertFragment/of-inlines/with-multiple.tsx index 45cbf2aa7d..cb4f0fa41f 100644 --- a/packages/slate/test/transforms/insertFragment/of-inlines/with-multiple.tsx +++ b/packages/slate/test/transforms/insertFragment/of-inlines/with-multiple.tsx @@ -2,14 +2,15 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two three - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-inlines/with-text.tsx b/packages/slate/test/transforms/insertFragment/of-inlines/with-text.tsx index aa878f7e51..a534688633 100644 --- a/packages/slate/test/transforms/insertFragment/of-inlines/with-text.tsx +++ b/packages/slate/test/transforms/insertFragment/of-inlines/with-text.tsx @@ -2,14 +2,15 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two three - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-lists/merge-lists.tsx b/packages/slate/test/transforms/insertFragment/of-lists/merge-lists.tsx index 99fc644818..e4e7fa1575 100644 --- a/packages/slate/test/transforms/insertFragment/of-lists/merge-lists.tsx +++ b/packages/slate/test/transforms/insertFragment/of-lists/merge-lists.tsx @@ -2,13 +2,14 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, 3 4 - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-mixed/block-empty.tsx b/packages/slate/test/transforms/insertFragment/of-mixed/block-empty.tsx index 06ac456e5a..c6f287c8e4 100644 --- a/packages/slate/test/transforms/insertFragment/of-mixed/block-empty.tsx +++ b/packages/slate/test/transforms/insertFragment/of-mixed/block-empty.tsx @@ -2,14 +2,15 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two three - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-mixed/block-empty2.tsx b/packages/slate/test/transforms/insertFragment/of-mixed/block-empty2.tsx index acd9810424..94664503f4 100644 --- a/packages/slate/test/transforms/insertFragment/of-mixed/block-empty2.tsx +++ b/packages/slate/test/transforms/insertFragment/of-mixed/block-empty2.tsx @@ -2,13 +2,14 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, two three - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-mixed/block-empty3.tsx b/packages/slate/test/transforms/insertFragment/of-mixed/block-empty3.tsx index 5cbf9af385..cf2644d987 100644 --- a/packages/slate/test/transforms/insertFragment/of-mixed/block-empty3.tsx +++ b/packages/slate/test/transforms/insertFragment/of-mixed/block-empty3.tsx @@ -2,13 +2,14 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-mixed/block-end.tsx b/packages/slate/test/transforms/insertFragment/of-mixed/block-end.tsx index 5e71575acc..0598f03512 100644 --- a/packages/slate/test/transforms/insertFragment/of-mixed/block-end.tsx +++ b/packages/slate/test/transforms/insertFragment/of-mixed/block-end.tsx @@ -2,14 +2,15 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two three - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-mixed/block-end2.tsx b/packages/slate/test/transforms/insertFragment/of-mixed/block-end2.tsx index c289cb5c6e..b16a03449d 100644 --- a/packages/slate/test/transforms/insertFragment/of-mixed/block-end2.tsx +++ b/packages/slate/test/transforms/insertFragment/of-mixed/block-end2.tsx @@ -2,13 +2,14 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-mixed/block-middle.tsx b/packages/slate/test/transforms/insertFragment/of-mixed/block-middle.tsx index c6a6892433..3efbb8e348 100644 --- a/packages/slate/test/transforms/insertFragment/of-mixed/block-middle.tsx +++ b/packages/slate/test/transforms/insertFragment/of-mixed/block-middle.tsx @@ -2,14 +2,15 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two three - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-mixed/block-start.tsx b/packages/slate/test/transforms/insertFragment/of-mixed/block-start.tsx index a173aa5b55..a8af128315 100644 --- a/packages/slate/test/transforms/insertFragment/of-mixed/block-start.tsx +++ b/packages/slate/test/transforms/insertFragment/of-mixed/block-start.tsx @@ -2,14 +2,15 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two three - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-mixed/block-start2.tsx b/packages/slate/test/transforms/insertFragment/of-mixed/block-start2.tsx index 209a6f8d8a..fc290d5a04 100644 --- a/packages/slate/test/transforms/insertFragment/of-mixed/block-start2.tsx +++ b/packages/slate/test/transforms/insertFragment/of-mixed/block-start2.tsx @@ -2,13 +2,14 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-tables/merge-cells-with-nested-blocks.tsx b/packages/slate/test/transforms/insertFragment/of-tables/merge-cells-with-nested-blocks.tsx index c5712c413b..4a10b6d93a 100644 --- a/packages/slate/test/transforms/insertFragment/of-tables/merge-cells-with-nested-blocks.tsx +++ b/packages/slate/test/transforms/insertFragment/of-tables/merge-cells-with-nested-blocks.tsx @@ -2,7 +2,7 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, @@ -16,7 +16,8 @@ export const run = editor => { - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-tables/merge-into-empty-cells.tsx b/packages/slate/test/transforms/insertFragment/of-tables/merge-into-empty-cells.tsx index 93f7340727..6227012f6e 100644 --- a/packages/slate/test/transforms/insertFragment/of-tables/merge-into-empty-cells.tsx +++ b/packages/slate/test/transforms/insertFragment/of-tables/merge-into-empty-cells.tsx @@ -2,7 +2,7 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, @@ -12,7 +12,8 @@ export const run = editor => { 2 - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-tables/merge-into-full-cells.tsx b/packages/slate/test/transforms/insertFragment/of-tables/merge-into-full-cells.tsx index 80b39e4d4a..64d94aa8ba 100644 --- a/packages/slate/test/transforms/insertFragment/of-tables/merge-into-full-cells.tsx +++ b/packages/slate/test/transforms/insertFragment/of-tables/merge-into-full-cells.tsx @@ -2,7 +2,7 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, @@ -12,7 +12,8 @@ export const run = editor => { New 2 - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-texts/block-across.tsx b/packages/slate/test/transforms/insertFragment/of-texts/block-across.tsx index 5a41ea4447..0c13e34114 100644 --- a/packages/slate/test/transforms/insertFragment/of-texts/block-across.tsx +++ b/packages/slate/test/transforms/insertFragment/of-texts/block-across.tsx @@ -2,8 +2,8 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { - Transforms.insertFragment(editor, fragment) +export const run = (editor, options = {}) => { + Transforms.insertFragment(editor, fragment, options) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-texts/block-empty.tsx b/packages/slate/test/transforms/insertFragment/of-texts/block-empty.tsx index 3cc511b504..b033725392 100644 --- a/packages/slate/test/transforms/insertFragment/of-texts/block-empty.tsx +++ b/packages/slate/test/transforms/insertFragment/of-texts/block-empty.tsx @@ -2,8 +2,8 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { - Transforms.insertFragment(editor, fragment) +export const run = (editor, options = {}) => { + Transforms.insertFragment(editor, fragment, options) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-texts/block-end.tsx b/packages/slate/test/transforms/insertFragment/of-texts/block-end.tsx index 43c5ec9902..779bfb14bf 100644 --- a/packages/slate/test/transforms/insertFragment/of-texts/block-end.tsx +++ b/packages/slate/test/transforms/insertFragment/of-texts/block-end.tsx @@ -2,8 +2,8 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { - Transforms.insertFragment(editor, fragment) +export const run = (editor, options = {}) => { + Transforms.insertFragment(editor, fragment, options) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-texts/block-middle.tsx b/packages/slate/test/transforms/insertFragment/of-texts/block-middle.tsx index f77de47f0b..6e536288cc 100644 --- a/packages/slate/test/transforms/insertFragment/of-texts/block-middle.tsx +++ b/packages/slate/test/transforms/insertFragment/of-texts/block-middle.tsx @@ -2,8 +2,8 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { - Transforms.insertFragment(editor, fragment) +export const run = (editor, options = {}) => { + Transforms.insertFragment(editor, fragment, options) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-texts/block-start.tsx b/packages/slate/test/transforms/insertFragment/of-texts/block-start.tsx index 2eda9660ba..1538191865 100644 --- a/packages/slate/test/transforms/insertFragment/of-texts/block-start.tsx +++ b/packages/slate/test/transforms/insertFragment/of-texts/block-start.tsx @@ -2,8 +2,8 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { - Transforms.insertFragment(editor, fragment) +export const run = (editor, options = {}) => { + Transforms.insertFragment(editor, fragment, options) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-texts/inline-empty.tsx b/packages/slate/test/transforms/insertFragment/of-texts/inline-empty.tsx index 5af42a2a5d..0137305e03 100644 --- a/packages/slate/test/transforms/insertFragment/of-texts/inline-empty.tsx +++ b/packages/slate/test/transforms/insertFragment/of-texts/inline-empty.tsx @@ -2,8 +2,8 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { - Transforms.insertFragment(editor, fragment) +export const run = (editor, options = {}) => { + Transforms.insertFragment(editor, fragment, options) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-texts/inline-middle.tsx b/packages/slate/test/transforms/insertFragment/of-texts/inline-middle.tsx index b60e69976b..e8b2e239c4 100644 --- a/packages/slate/test/transforms/insertFragment/of-texts/inline-middle.tsx +++ b/packages/slate/test/transforms/insertFragment/of-texts/inline-middle.tsx @@ -2,8 +2,8 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { - Transforms.insertFragment(editor, fragment) +export const run = (editor, options = {}) => { + Transforms.insertFragment(editor, fragment, options) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/of-texts/with-multiple.tsx b/packages/slate/test/transforms/insertFragment/of-texts/with-multiple.tsx index 3da488aab8..cbb38becc6 100644 --- a/packages/slate/test/transforms/insertFragment/of-texts/with-multiple.tsx +++ b/packages/slate/test/transforms/insertFragment/of-texts/with-multiple.tsx @@ -2,13 +2,14 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment( editor, one two - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/voids-false/block.tsx b/packages/slate/test/transforms/insertFragment/voids-false/block.tsx index 1c652d00e3..f3e88a6724 100644 --- a/packages/slate/test/transforms/insertFragment/voids-false/block.tsx +++ b/packages/slate/test/transforms/insertFragment/voids-false/block.tsx @@ -2,8 +2,8 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { - Transforms.insertFragment(editor, fragment) +export const run = (editor, options = {}) => { + Transforms.insertFragment(editor, fragment, options) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/voids-false/inline.tsx b/packages/slate/test/transforms/insertFragment/voids-false/inline.tsx index 6105be9715..dce411c91b 100644 --- a/packages/slate/test/transforms/insertFragment/voids-false/inline.tsx +++ b/packages/slate/test/transforms/insertFragment/voids-false/inline.tsx @@ -2,8 +2,8 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { - Transforms.insertFragment(editor, fragment) +export const run = (editor, options = {}) => { + Transforms.insertFragment(editor, fragment, options) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/voids-true/block.tsx b/packages/slate/test/transforms/insertFragment/voids-true/block.tsx index 32483c0e10..f987d000c6 100644 --- a/packages/slate/test/transforms/insertFragment/voids-true/block.tsx +++ b/packages/slate/test/transforms/insertFragment/voids-true/block.tsx @@ -2,9 +2,10 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment(editor, fragment, { voids: true, + ...options, }) } export const input = ( diff --git a/packages/slate/test/transforms/insertFragment/voids-true/inline.tsx b/packages/slate/test/transforms/insertFragment/voids-true/inline.tsx index d4ab0b495f..9ca3a594ce 100644 --- a/packages/slate/test/transforms/insertFragment/voids-true/inline.tsx +++ b/packages/slate/test/transforms/insertFragment/voids-true/inline.tsx @@ -2,9 +2,10 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertFragment(editor, fragment, { voids: true, + ...options, }) } export const input = ( diff --git a/packages/slate/test/transforms/insertNodes/block/block-empty.tsx b/packages/slate/test/transforms/insertNodes/block/block-empty.tsx index 50961b9780..762c7b2ed1 100644 --- a/packages/slate/test/transforms/insertNodes/block/block-empty.tsx +++ b/packages/slate/test/transforms/insertNodes/block/block-empty.tsx @@ -10,12 +10,13 @@ export const input = ( not empty ) -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, - + , + options ) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/block/block-middle.tsx b/packages/slate/test/transforms/insertNodes/block/block-middle.tsx index db23e4e4b0..ab4c998055 100644 --- a/packages/slate/test/transforms/insertNodes/block/block-middle.tsx +++ b/packages/slate/test/transforms/insertNodes/block/block-middle.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertNodes/block/block-void.tsx b/packages/slate/test/transforms/insertNodes/block/block-void.tsx index 729965e661..d5036db93c 100644 --- a/packages/slate/test/transforms/insertNodes/block/block-void.tsx +++ b/packages/slate/test/transforms/insertNodes/block/block-void.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertNodes/block/inline-void.tsx b/packages/slate/test/transforms/insertNodes/block/inline-void.tsx index 3e56a4f9ee..e7ea9fa0b2 100644 --- a/packages/slate/test/transforms/insertNodes/block/inline-void.tsx +++ b/packages/slate/test/transforms/insertNodes/block/inline-void.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertNodes/inline/block-empty.tsx b/packages/slate/test/transforms/insertNodes/inline/block-empty.tsx index 37e482ea44..2eb8301302 100644 --- a/packages/slate/test/transforms/insertNodes/inline/block-empty.tsx +++ b/packages/slate/test/transforms/insertNodes/inline/block-empty.tsx @@ -9,12 +9,13 @@ export const input = ( ) -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, - + , + options ) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/inline/block-end.tsx b/packages/slate/test/transforms/insertNodes/inline/block-end.tsx index 8fe8314faf..b2c2fad652 100644 --- a/packages/slate/test/transforms/insertNodes/inline/block-end.tsx +++ b/packages/slate/test/transforms/insertNodes/inline/block-end.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertNodes/inline/block-middle.tsx b/packages/slate/test/transforms/insertNodes/inline/block-middle.tsx index debf909f0d..1fb97314ca 100644 --- a/packages/slate/test/transforms/insertNodes/inline/block-middle.tsx +++ b/packages/slate/test/transforms/insertNodes/inline/block-middle.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertNodes/inline/block-start.tsx b/packages/slate/test/transforms/insertNodes/inline/block-start.tsx index 527f1f1307..296f52ab9e 100644 --- a/packages/slate/test/transforms/insertNodes/inline/block-start.tsx +++ b/packages/slate/test/transforms/insertNodes/inline/block-start.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertNodes/inline/block-void.tsx b/packages/slate/test/transforms/insertNodes/inline/block-void.tsx index 7053ff1d32..352a7014e9 100644 --- a/packages/slate/test/transforms/insertNodes/inline/block-void.tsx +++ b/packages/slate/test/transforms/insertNodes/inline/block-void.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertNodes/inline/inline-middle.tsx b/packages/slate/test/transforms/insertNodes/inline/inline-middle.tsx index 2ab529a6cf..251567bc9c 100644 --- a/packages/slate/test/transforms/insertNodes/inline/inline-middle.tsx +++ b/packages/slate/test/transforms/insertNodes/inline/inline-middle.tsx @@ -2,12 +2,13 @@ import { Transforms } from 'slate' import { jsx } from '../../..' -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, - + , + options ) } export const input = ( diff --git a/packages/slate/test/transforms/insertNodes/path/block.tsx b/packages/slate/test/transforms/insertNodes/path/block.tsx index 97b3f4d25f..6bcc038969 100644 --- a/packages/slate/test/transforms/insertNodes/path/block.tsx +++ b/packages/slate/test/transforms/insertNodes/path/block.tsx @@ -10,13 +10,13 @@ export const input = ( ) -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, , - { at: [0] } + { at: [0], ...options } ) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/path/inline.tsx b/packages/slate/test/transforms/insertNodes/path/inline.tsx index 108ec42f21..85365d0067 100644 --- a/packages/slate/test/transforms/insertNodes/path/inline.tsx +++ b/packages/slate/test/transforms/insertNodes/path/inline.tsx @@ -10,13 +10,13 @@ export const input = ( ) -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, , - { at: [0, 0] } + { at: [0, 0], ...options } ) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/path/multiple-inline-not-end.tsx b/packages/slate/test/transforms/insertNodes/path/multiple-inline-not-end.tsx index ccbdb8f305..72f7781feb 100644 --- a/packages/slate/test/transforms/insertNodes/path/multiple-inline-not-end.tsx +++ b/packages/slate/test/transforms/insertNodes/path/multiple-inline-not-end.tsx @@ -11,13 +11,17 @@ export const input = ( ) -export const run = editor => { - Transforms.insertNodes(editor, [ - - - , - world, - ]) +export const run = (editor, options = {}) => { + Transforms.insertNodes( + editor, + [ + + + , + world, + ], + options + ) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/path/multiple-inline.tsx b/packages/slate/test/transforms/insertNodes/path/multiple-inline.tsx index e06d71df59..b8f3b355ae 100644 --- a/packages/slate/test/transforms/insertNodes/path/multiple-inline.tsx +++ b/packages/slate/test/transforms/insertNodes/path/multiple-inline.tsx @@ -10,13 +10,17 @@ export const input = ( ) -export const run = editor => { - Transforms.insertNodes(editor, [ - - - , - world, - ]) +export const run = (editor, options = {}) => { + Transforms.insertNodes( + editor, + [ + + + , + world, + ], + options + ) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/path/multiple.tsx b/packages/slate/test/transforms/insertNodes/path/multiple.tsx index f9ad1737af..11597a8f35 100644 --- a/packages/slate/test/transforms/insertNodes/path/multiple.tsx +++ b/packages/slate/test/transforms/insertNodes/path/multiple.tsx @@ -10,9 +10,10 @@ export const input = ( ) -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes(editor, [two, three], { at: [0], + ...options, }) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/path/text.tsx b/packages/slate/test/transforms/insertNodes/path/text.tsx index 245d336d20..12995ec1e4 100644 --- a/packages/slate/test/transforms/insertNodes/path/text.tsx +++ b/packages/slate/test/transforms/insertNodes/path/text.tsx @@ -10,8 +10,11 @@ export const input = ( ) -export const run = editor => { - Transforms.insertNodes(editor, another, { at: [0, 0] }) +export const run = (editor, options = {}) => { + Transforms.insertNodes(editor, another, { + at: [0, 0], + ...options, + }) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/select-true/block.tsx b/packages/slate/test/transforms/insertNodes/select-true/block.tsx index 116ac0f385..90b9387b5a 100644 --- a/packages/slate/test/transforms/insertNodes/select-true/block.tsx +++ b/packages/slate/test/transforms/insertNodes/select-true/block.tsx @@ -10,13 +10,13 @@ export const input = ( ) -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, , - { at: [0], select: true } + { at: [0], select: true, ...options } ) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/selection/none-empty.tsx b/packages/slate/test/transforms/insertNodes/selection/none-empty.tsx index cbf2403805..766c00db1a 100644 --- a/packages/slate/test/transforms/insertNodes/selection/none-empty.tsx +++ b/packages/slate/test/transforms/insertNodes/selection/none-empty.tsx @@ -3,8 +3,8 @@ import { Transforms } from 'slate' import { jsx } from '../../..' export const input = -export const run = editor => { - Transforms.insertNodes(editor, one) +export const run = (editor, options = {}) => { + Transforms.insertNodes(editor, one, options) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/selection/none-end.tsx b/packages/slate/test/transforms/insertNodes/selection/none-end.tsx index 07a1e1d22c..8f6ce296b8 100644 --- a/packages/slate/test/transforms/insertNodes/selection/none-end.tsx +++ b/packages/slate/test/transforms/insertNodes/selection/none-end.tsx @@ -7,8 +7,8 @@ export const input = ( one ) -export const run = editor => { - Transforms.insertNodes(editor, two) +export const run = (editor, options = {}) => { + Transforms.insertNodes(editor, two, options) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/void/at-path.tsx b/packages/slate/test/transforms/insertNodes/void/at-path.tsx index 4ea7dd992e..674cae8b50 100644 --- a/packages/slate/test/transforms/insertNodes/void/at-path.tsx +++ b/packages/slate/test/transforms/insertNodes/void/at-path.tsx @@ -10,13 +10,13 @@ export const input = ( ) -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, two , - { at: [1], select: true } + { at: [1], select: true, ...options } ) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/void/block-nested.tsx b/packages/slate/test/transforms/insertNodes/void/block-nested.tsx index d5d0b61cda..88b3bb0cdd 100644 --- a/packages/slate/test/transforms/insertNodes/void/block-nested.tsx +++ b/packages/slate/test/transforms/insertNodes/void/block-nested.tsx @@ -10,14 +10,15 @@ export const input = ( ) -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, two - + , + options ) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/void/block.tsx b/packages/slate/test/transforms/insertNodes/void/block.tsx index ae58290340..cd57b0664b 100644 --- a/packages/slate/test/transforms/insertNodes/void/block.tsx +++ b/packages/slate/test/transforms/insertNodes/void/block.tsx @@ -10,12 +10,13 @@ export const input = ( ) -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, two - + , + options ) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/void/inline.tsx b/packages/slate/test/transforms/insertNodes/void/inline.tsx index 5109b186e3..b716660183 100644 --- a/packages/slate/test/transforms/insertNodes/void/inline.tsx +++ b/packages/slate/test/transforms/insertNodes/void/inline.tsx @@ -14,12 +14,13 @@ export const input = ( ) -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes( editor, four - + , + options ) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/voids-true/block.tsx b/packages/slate/test/transforms/insertNodes/voids-true/block.tsx index 36119c290e..2e41be4ec9 100644 --- a/packages/slate/test/transforms/insertNodes/voids-true/block.tsx +++ b/packages/slate/test/transforms/insertNodes/voids-true/block.tsx @@ -10,10 +10,11 @@ export const input = ( ) -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes(editor, two, { at: [0, 1], voids: true, + options, }) } export const output = ( diff --git a/packages/slate/test/transforms/insertNodes/voids-true/inline.tsx b/packages/slate/test/transforms/insertNodes/voids-true/inline.tsx index 078ea6ca70..7792d52a1b 100644 --- a/packages/slate/test/transforms/insertNodes/voids-true/inline.tsx +++ b/packages/slate/test/transforms/insertNodes/voids-true/inline.tsx @@ -14,10 +14,11 @@ export const input = ( ) -export const run = editor => { +export const run = (editor, options = {}) => { Transforms.insertNodes(editor, four, { at: [0, 1, 1], voids: true, + options, }) } export const output = (