mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-13 10:44:02 +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++) {
|
for (let i = 0; i < node.children.length; i++, n++) {
|
||||||
const currentNode = Node.get(editor, path)
|
const currentNode = Node.get(editor, path)
|
||||||
if (Text.isText(currentNode)) continue
|
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 prev = currentNode.children[n - 1] as Descendant
|
||||||
const isLast = i === node.children.length - 1
|
const isLast = i === node.children.length - 1
|
||||||
const isInlineOrText =
|
const isInlineOrText =
|
||||||
|
@@ -6,6 +6,8 @@ export const input = (
|
|||||||
<block>
|
<block>
|
||||||
<block>one</block>
|
<block>one</block>
|
||||||
<inline>two</inline>
|
<inline>two</inline>
|
||||||
|
<block>three</block>
|
||||||
|
<inline>four</inline>
|
||||||
</block>
|
</block>
|
||||||
</editor>
|
</editor>
|
||||||
)
|
)
|
||||||
@@ -13,6 +15,7 @@ export const output = (
|
|||||||
<editor>
|
<editor>
|
||||||
<block>
|
<block>
|
||||||
<block>one</block>
|
<block>one</block>
|
||||||
|
<block>three</block>
|
||||||
</block>
|
</block>
|
||||||
</editor>
|
</editor>
|
||||||
)
|
)
|
||||||
|
@@ -5,10 +5,13 @@ export const input = (
|
|||||||
<editor>
|
<editor>
|
||||||
<inline>one</inline>
|
<inline>one</inline>
|
||||||
<block>two</block>
|
<block>two</block>
|
||||||
|
<inline>three</inline>
|
||||||
|
<block>four</block>
|
||||||
</editor>
|
</editor>
|
||||||
)
|
)
|
||||||
export const output = (
|
export const output = (
|
||||||
<editor>
|
<editor>
|
||||||
<block>two</block>
|
<block>two</block>
|
||||||
|
<block>four</block>
|
||||||
</editor>
|
</editor>
|
||||||
)
|
)
|
||||||
|
@@ -5,10 +5,13 @@ export const input = (
|
|||||||
<editor>
|
<editor>
|
||||||
<text>one</text>
|
<text>one</text>
|
||||||
<block>two</block>
|
<block>two</block>
|
||||||
|
<text>three</text>
|
||||||
|
<block>four</block>
|
||||||
</editor>
|
</editor>
|
||||||
)
|
)
|
||||||
export const output = (
|
export const output = (
|
||||||
<editor>
|
<editor>
|
||||||
<block>two</block>
|
<block>two</block>
|
||||||
|
<block>four</block>
|
||||||
</editor>
|
</editor>
|
||||||
)
|
)
|
||||||
|
@@ -8,6 +8,8 @@ export const input = (
|
|||||||
<inline>
|
<inline>
|
||||||
<block>one</block>
|
<block>one</block>
|
||||||
<text>two</text>
|
<text>two</text>
|
||||||
|
<block>three</block>
|
||||||
|
<text>four</text>
|
||||||
</inline>
|
</inline>
|
||||||
<text />
|
<text />
|
||||||
</block>
|
</block>
|
||||||
@@ -18,7 +20,7 @@ export const output = (
|
|||||||
<block>
|
<block>
|
||||||
<text />
|
<text />
|
||||||
<inline>
|
<inline>
|
||||||
<text>two</text>
|
<text>twofour</text>
|
||||||
</inline>
|
</inline>
|
||||||
<text />
|
<text />
|
||||||
</block>
|
</block>
|
||||||
|
Reference in New Issue
Block a user