1
0
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:
void
2023-04-18 14:00:33 +02:00
committed by GitHub
parent 832e75f47a
commit bc945eb12c
6 changed files with 18 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
'slate': patch
---
Correct core normalization that could cause wrong nodes to be removed

View File

@@ -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 =

View File

@@ -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>
)

View File

@@ -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>
)

View File

@@ -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>
)

View File

@@ -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>