mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-24 09:13:24 +01:00
* Fix IME input bug (#3292) * Changed delete_fragment according to #3351
This commit is contained in:
parent
f3fb40cce0
commit
3cc9effdd1
@ -646,13 +646,27 @@ export const Editable = (props: EditableProps) => {
|
|||||||
},
|
},
|
||||||
[attributes.onCompositionEnd]
|
[attributes.onCompositionEnd]
|
||||||
)}
|
)}
|
||||||
|
onCompositionUpdate={useCallback(
|
||||||
|
(event: React.CompositionEvent<HTMLDivElement>) => {
|
||||||
|
if (
|
||||||
|
hasEditableTarget(editor, event.target) &&
|
||||||
|
!isEventHandled(event, attributes.onCompositionUpdate)
|
||||||
|
) {
|
||||||
|
state.isComposing = true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[attributes.onCompositionUpdate]
|
||||||
|
)}
|
||||||
onCompositionStart={useCallback(
|
onCompositionStart={useCallback(
|
||||||
(event: React.CompositionEvent<HTMLDivElement>) => {
|
(event: React.CompositionEvent<HTMLDivElement>) => {
|
||||||
if (
|
if (
|
||||||
hasEditableTarget(editor, event.target) &&
|
hasEditableTarget(editor, event.target) &&
|
||||||
!isEventHandled(event, attributes.onCompositionStart)
|
!isEventHandled(event, attributes.onCompositionStart)
|
||||||
) {
|
) {
|
||||||
state.isComposing = true
|
const { selection } = editor
|
||||||
|
if (selection && Range.isExpanded(selection)) {
|
||||||
|
Editor.deleteFragment(editor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[attributes.onCompositionStart]
|
[attributes.onCompositionStart]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user