1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-24 01:02:31 +01:00

Fix IME input bug (#3292) (#3342)

* Fix IME input bug (#3292)

* Changed delete_fragment according to #3351
This commit is contained in:
Ken Aoki 2021-04-01 05:33:40 +09:00 committed by GitHub
parent f3fb40cce0
commit 3cc9effdd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -646,13 +646,27 @@ export const Editable = (props: EditableProps) => {
},
[attributes.onCompositionEnd]
)}
onCompositionUpdate={useCallback(
(event: React.CompositionEvent<HTMLDivElement>) => {
if (
hasEditableTarget(editor, event.target) &&
!isEventHandled(event, attributes.onCompositionUpdate)
) {
state.isComposing = true
}
},
[attributes.onCompositionUpdate]
)}
onCompositionStart={useCallback(
(event: React.CompositionEvent<HTMLDivElement>) => {
if (
hasEditableTarget(editor, event.target) &&
!isEventHandled(event, attributes.onCompositionStart)
) {
state.isComposing = true
const { selection } = editor
if (selection && Range.isExpanded(selection)) {
Editor.deleteFragment(editor)
}
}
},
[attributes.onCompositionStart]