diff --git a/packages/slate/src/interfaces/editor/transforms/node.ts b/packages/slate/src/interfaces/editor/transforms/node.ts index c322e6957..55f97bb91 100644 --- a/packages/slate/src/interfaces/editor/transforms/node.ts +++ b/packages/slate/src/interfaces/editor/transforms/node.ts @@ -23,14 +23,14 @@ export const NodeTransforms = { at?: Location match?: NodeMatch hanging?: boolean + select?: boolean voids?: boolean } = {} ) { Editor.withoutNormalizing(editor, () => { const { selection } = editor const { hanging = false, voids = false } = options - let { at, match } = options - let select = false + let { at, match, select } = options if (Node.isNode(nodes)) { nodes = [nodes] @@ -57,6 +57,10 @@ export const NodeTransforms = { select = true } + if (select == null) { + select = false + } + if (Range.isRange(at)) { if (!hanging) { at = Editor.unhangRange(editor, at) diff --git a/packages/slate/test/transforms/insertNodes/select-true/block.js b/packages/slate/test/transforms/insertNodes/select-true/block.js new file mode 100644 index 000000000..f4e0e490a --- /dev/null +++ b/packages/slate/test/transforms/insertNodes/select-true/block.js @@ -0,0 +1,34 @@ +/** @jsx jsx */ + +import { Editor } from 'slate' +import { jsx } from '../../..' + +export const input = ( + + + + one + + +) + +export const run = editor => { + Editor.insertNodes( + editor, + + + , + { at: [0], select: true } + ) +} + +export const output = ( + + + + + + one + + +)