1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-01 04:50:27 +02:00

Merge branch 'master' of github.com:ianstormtaylor/slate

This commit is contained in:
Ian Storm Taylor
2019-12-06 12:09:00 -05:00

View File

@@ -197,6 +197,13 @@ export const ReactEditor = {
const el = ReactEditor.toDOMNode(editor, node) const el = ReactEditor.toDOMNode(editor, node)
let domPoint: DOMPoint | undefined let domPoint: DOMPoint | undefined
// If we're inside a void node, force the offset to 0, otherwise the zero
// width spacing character will result in an incorrect offset of 1
const [match] = Editor.nodes(editor, { at: point, match: 'void' })
if (match) {
point = { path: point.path, offset: 0 }
}
// For each leaf, we need to isolate its content, which means filtering // For each leaf, we need to isolate its content, which means filtering
// to its direct text and zero-width spans. (We have to filter out any // to its direct text and zero-width spans. (We have to filter out any
// other siblings that may have been rendered alongside them.) // other siblings that may have been rendered alongside them.)