mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-07-31 20:40:19 +02:00
Fix toSlatePoint in void nodes with nested editors if children are rendered as the last child (#5054)
This commit is contained in:
5
.changeset/five-snails-travel.md
Normal file
5
.changeset/five-snails-travel.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix toSlatePoint in void nodes with nested editors if children are rendered as the last child
|
@@ -553,8 +553,16 @@ export const ReactEditor = {
|
|||||||
}
|
}
|
||||||
} else if (voidNode) {
|
} else if (voidNode) {
|
||||||
// For void nodes, the element with the offset key will be a cousin, not an
|
// For void nodes, the element with the offset key will be a cousin, not an
|
||||||
// ancestor, so find it by going down from the nearest void parent.
|
// ancestor, so find it by going down from the nearest void parent and taking the
|
||||||
leafNode = voidNode.querySelector('[data-slate-leaf]')!
|
// first one that isn't inside a nested editor.
|
||||||
|
const leafNodes = voidNode.querySelectorAll('[data-slate-leaf]')
|
||||||
|
for (let index = 0; index < leafNodes.length; index++) {
|
||||||
|
const current = leafNodes[index]
|
||||||
|
if (ReactEditor.hasDOMNode(editor, current)) {
|
||||||
|
leafNode = current
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// COMPAT: In read-only editors the leaf is not rendered.
|
// COMPAT: In read-only editors the leaf is not rendered.
|
||||||
if (!leafNode) {
|
if (!leafNode) {
|
||||||
|
Reference in New Issue
Block a user