Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit eb9ca46

Browse files
committed
fix composition mode
1 parent b56c0f6 commit eb9ca46

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/component/handlers/composition/DraftEditorCompositionHandler.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,21 @@ const DraftEditorCompositionHandler = {
191191
offsetKey,
192192
);
193193

194-
const {start, end} = editorState
194+
const {start} = editorState
195195
.getBlockTree(blockKey)
196196
.getIn([decoratorKey, 'leaves', leafKey]);
197197

198+
const selection = editorState.getSelection();
199+
const selectionStart = selection.getStartOffset();
200+
const selectionEnd = selection.getEndOffset();
201+
202+
composedChars = composedChars.slice(selectionStart - start);
203+
198204
const replacementRange = editorState.getSelection().merge({
199205
anchorKey: blockKey,
200206
focusKey: blockKey,
201-
anchorOffset: start,
202-
focusOffset: end,
207+
anchorOffset: selectionStart,
208+
focusOffset: selectionEnd,
203209
isBackward: false,
204210
});
205211

0 commit comments

Comments
 (0)