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

fix: caret jump to the start of composition string (#5443)

* fix:  caret jump to the start of composition str

* chore: add changeset

* chore: edit changeset

---------

Co-authored-by: huangyuning <huangyuning@vv.cn>
This commit is contained in:
Old_dream
2023-06-13 06:20:22 +08:00
committed by GitHub
parent 5eb589dbbb
commit eb7f598707
2 changed files with 8 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-react': patch
---
fix wrong caret position during composition.

View File

@@ -366,7 +366,9 @@ export const Editable = (props: EditableProps) => {
selection && ReactEditor.toDOMRange(editor, selection)
if (newDomRange) {
if (Range.isBackward(selection!)) {
if (ReactEditor.isComposing(editor)) {
domSelection.collapseToEnd()
} else if (Range.isBackward(selection!)) {
domSelection.setBaseAndExtent(
newDomRange.endContainer,
newDomRange.endOffset,