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:
5
.changeset/forty-tools-joke.md
Normal file
5
.changeset/forty-tools-joke.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Do not move selection outside inline node when composition starts
|
@@ -1192,27 +1192,10 @@ export const Editable = (props: EditableProps) => {
|
|||||||
setIsComposing(true)
|
setIsComposing(true)
|
||||||
|
|
||||||
const { selection } = editor
|
const { selection } = editor
|
||||||
if (selection) {
|
if (selection && Range.isExpanded(selection)) {
|
||||||
if (Range.isExpanded(selection)) {
|
|
||||||
Editor.deleteFragment(editor)
|
Editor.deleteFragment(editor)
|
||||||
return
|
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]
|
[attributes.onCompositionStart, editor]
|
||||||
|
Reference in New Issue
Block a user