mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-01-17 13:38:37 +01:00
Fix toSlatePoint in void nodes with nested editors if children are rendered as the last child (#5054)
This commit is contained in:
parent
f13cd6b918
commit
1cc0797f53
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) {
|
||||
// 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.
|
||||
leafNode = voidNode.querySelector('[data-slate-leaf]')!
|
||||
// ancestor, so find it by going down from the nearest void parent and taking the
|
||||
// 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.
|
||||
if (!leafNode) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user