mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-22 06:53:25 +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)
|
||||
|
||||
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]
|
||||
|
Reference in New Issue
Block a user