1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-31 10:51:44 +02:00

fix(react-editor): text node spacer can be non-existant if editor is in readonly mode

This commit is contained in:
msc117
2020-09-28 12:47:07 -07:00
parent 60b56651b2
commit 8f6e20418a

View File

@@ -435,9 +435,13 @@ export const ReactEditor = {
// ancestor, so find it by going down from the nearest void parent.
leafNode = voidNode.querySelector('[data-slate-leaf]')!
textNode = leafNode.closest('[data-slate-node="text"]')!
domNode = leafNode
offset = domNode.textContent!.length
if (!leafNode) {
offset = 1
} else {
textNode = leafNode.closest('[data-slate-node="text"]')!
domNode = leafNode
offset = domNode.textContent!.length
}
}
// COMPAT: If the parent node is a Slate zero-width space, editor is