mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-19 05:31:56 +02:00
fix cursor not correct when insert multiple nodes using insertNodes (#4482)
* fix cursor not correct when insert multiple nodes using insertNodes * fix lint * add changeset
This commit is contained in:
5
.changeset/neat-flies-eat.md
Normal file
5
.changeset/neat-flies-eat.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix cursor not correct issue after insert multiple nodes with `Transform.insertNodes`
|
@@ -228,7 +228,9 @@ export const NodeTransforms: NodeTransforms = {
|
|||||||
const path = parentPath.concat(index)
|
const path = parentPath.concat(index)
|
||||||
index++
|
index++
|
||||||
editor.apply({ type: 'insert_node', path, node })
|
editor.apply({ type: 'insert_node', path, node })
|
||||||
|
at = Path.next(at)
|
||||||
}
|
}
|
||||||
|
at = Path.previous(at)
|
||||||
|
|
||||||
if (select) {
|
if (select) {
|
||||||
const point = Editor.end(editor, at)
|
const point = Editor.end(editor, at)
|
||||||
|
@@ -0,0 +1,34 @@
|
|||||||
|
/** @jsx jsx */
|
||||||
|
import { Transforms } from 'slate'
|
||||||
|
import { jsx } from '../../..'
|
||||||
|
|
||||||
|
export const input = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
hel
|
||||||
|
<cursor />
|
||||||
|
lo
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
||||||
|
export const run = editor => {
|
||||||
|
Transforms.insertNodes(editor, [
|
||||||
|
<inline>
|
||||||
|
<text />
|
||||||
|
</inline>,
|
||||||
|
<text>world</text>,
|
||||||
|
])
|
||||||
|
}
|
||||||
|
export const output = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
hel
|
||||||
|
<inline>
|
||||||
|
<text />
|
||||||
|
</inline>
|
||||||
|
world
|
||||||
|
<cursor />
|
||||||
|
lo
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
@@ -0,0 +1,32 @@
|
|||||||
|
/** @jsx jsx */
|
||||||
|
import { Transforms } from 'slate'
|
||||||
|
import { jsx } from '../../..'
|
||||||
|
|
||||||
|
export const input = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
hello
|
||||||
|
<cursor />
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
||||||
|
export const run = editor => {
|
||||||
|
Transforms.insertNodes(editor, [
|
||||||
|
<inline>
|
||||||
|
<text />
|
||||||
|
</inline>,
|
||||||
|
<text>world</text>,
|
||||||
|
])
|
||||||
|
}
|
||||||
|
export const output = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
hello
|
||||||
|
<inline>
|
||||||
|
<text />
|
||||||
|
</inline>
|
||||||
|
world
|
||||||
|
<cursor />
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
Reference in New Issue
Block a user