mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-24 09:13:24 +01:00
* fix DOM selection can not be updated when use composition input on Safari #3196 * Update editable.tsx * Create dry-deers-applaud.md Co-authored-by: Ian Storm Taylor <ian@ianstormtaylor.com>
This commit is contained in:
parent
6799dfd228
commit
bf83f333e6
5
.changeset/dry-deers-applaud.md
Normal file
5
.changeset/dry-deers-applaud.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'slate-react': patch
|
||||
---
|
||||
|
||||
Fixed selection updating with IME inputs in browsers that support `beforeinput`.
|
@ -372,6 +372,15 @@ export const Editable = (props: EditableProps) => {
|
||||
case 'insertFromYank':
|
||||
case 'insertReplacementText':
|
||||
case 'insertText': {
|
||||
if (type === 'insertFromComposition') {
|
||||
// COMPAT: in Safari, `compositionend` is dispatched after the
|
||||
// `beforeinput` for "insertFromComposition". But if we wait for it
|
||||
// then we will abort because we're still composing and the selection
|
||||
// won't be updated properly.
|
||||
// https://www.w3.org/TR/input-events-2/
|
||||
state.isComposing = false
|
||||
}
|
||||
|
||||
const window = ReactEditor.getWindow(editor)
|
||||
if (data instanceof window.DataTransfer) {
|
||||
ReactEditor.insertData(editor, data as DataTransfer)
|
||||
|
Loading…
x
Reference in New Issue
Block a user