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

Do not move selection outside inline node when composition starts (#5541)

This commit is contained in:
Joe Anderson
2024-02-07 11:50:25 +00:00
committed by GitHub
parent cd93871ae6
commit c2ae1eda91
2 changed files with 8 additions and 20 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-react': patch
---
Do not move selection outside inline node when composition starts

View File

@@ -1192,27 +1192,10 @@ export const Editable = (props: EditableProps) => {
setIsComposing(true)
const { selection } = editor
if (selection) {
if (Range.isExpanded(selection)) {
if (selection && Range.isExpanded(selection)) {
Editor.deleteFragment(editor)
return
}
const inline = Editor.above(editor, {
match: n =>
Element.isElement(n) && Editor.isInline(editor, n),
mode: 'highest',
})
if (inline) {
const [, inlinePath] = inline
if (Editor.isEnd(editor, selection.anchor, inlinePath)) {
const point = Editor.after(editor, inlinePath)!
Transforms.setSelection(editor, {
anchor: point,
focus: point,
})
}
}
}
}
},
[attributes.onCompositionStart, editor]