mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-12 02:03:59 +02:00
Take previously added/removed nodes into account when fetching child node in core normalization (#5396)
This commit is contained in:
5
.changeset/tall-gorillas-deny.md
Normal file
5
.changeset/tall-gorillas-deny.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'slate': patch
|
||||
---
|
||||
|
||||
Correct core normalization that could cause wrong nodes to be removed
|
@@ -245,7 +245,7 @@ export const createEditor = (): Editor => {
|
||||
for (let i = 0; i < node.children.length; i++, n++) {
|
||||
const currentNode = Node.get(editor, path)
|
||||
if (Text.isText(currentNode)) continue
|
||||
const child = node.children[i] as Descendant
|
||||
const child = currentNode.children[n] as Descendant
|
||||
const prev = currentNode.children[n - 1] as Descendant
|
||||
const isLast = i === node.children.length - 1
|
||||
const isInlineOrText =
|
||||
|
@@ -6,6 +6,8 @@ export const input = (
|
||||
<block>
|
||||
<block>one</block>
|
||||
<inline>two</inline>
|
||||
<block>three</block>
|
||||
<inline>four</inline>
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
@@ -13,6 +15,7 @@ export const output = (
|
||||
<editor>
|
||||
<block>
|
||||
<block>one</block>
|
||||
<block>three</block>
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
@@ -5,10 +5,13 @@ export const input = (
|
||||
<editor>
|
||||
<inline>one</inline>
|
||||
<block>two</block>
|
||||
<inline>three</inline>
|
||||
<block>four</block>
|
||||
</editor>
|
||||
)
|
||||
export const output = (
|
||||
<editor>
|
||||
<block>two</block>
|
||||
<block>four</block>
|
||||
</editor>
|
||||
)
|
||||
|
@@ -5,10 +5,13 @@ export const input = (
|
||||
<editor>
|
||||
<text>one</text>
|
||||
<block>two</block>
|
||||
<text>three</text>
|
||||
<block>four</block>
|
||||
</editor>
|
||||
)
|
||||
export const output = (
|
||||
<editor>
|
||||
<block>two</block>
|
||||
<block>four</block>
|
||||
</editor>
|
||||
)
|
||||
|
@@ -8,6 +8,8 @@ export const input = (
|
||||
<inline>
|
||||
<block>one</block>
|
||||
<text>two</text>
|
||||
<block>three</block>
|
||||
<text>four</text>
|
||||
</inline>
|
||||
<text />
|
||||
</block>
|
||||
@@ -18,7 +20,7 @@ export const output = (
|
||||
<block>
|
||||
<text />
|
||||
<inline>
|
||||
<text>two</text>
|
||||
<text>twofour</text>
|
||||
</inline>
|
||||
<text />
|
||||
</block>
|
||||
|
Reference in New Issue
Block a user