Skip to content

Commit c2ae1ed

Browse files
authoredFeb 7, 2024··
Do not move selection outside inline node when composition starts (#5541)
1 parent cd93871 commit c2ae1ed

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed
 

‎.changeset/forty-tools-joke.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'slate-react': patch
3+
---
4+
5+
Do not move selection outside inline node when composition starts

‎packages/slate-react/src/components/editable.tsx

+3-20
Original file line numberDiff line numberDiff line change
@@ -1192,26 +1192,9 @@ export const Editable = (props: EditableProps) => {
11921192
setIsComposing(true)
11931193

11941194
const { selection } = editor
1195-
if (selection) {
1196-
if (Range.isExpanded(selection)) {
1197-
Editor.deleteFragment(editor)
1198-
return
1199-
}
1200-
const inline = Editor.above(editor, {
1201-
match: n =>
1202-
Element.isElement(n) && Editor.isInline(editor, n),
1203-
mode: 'highest',
1204-
})
1205-
if (inline) {
1206-
const [, inlinePath] = inline
1207-
if (Editor.isEnd(editor, selection.anchor, inlinePath)) {
1208-
const point = Editor.after(editor, inlinePath)!
1209-
Transforms.setSelection(editor, {
1210-
anchor: point,
1211-
focus: point,
1212-
})
1213-
}
1214-
}
1195+
if (selection && Range.isExpanded(selection)) {
1196+
Editor.deleteFragment(editor)
1197+
return
12151198
}
12161199
}
12171200
},

0 commit comments

Comments
 (0)
Please sign in to comment.