mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-16 20:24:01 +02:00
Directly paste ClipboardEvents in Safari (#5362)
* Directly paste ClipboardEvents in Safari * Add changeset
This commit is contained in:
5
.changeset/lovely-papayas-hug.md
Normal file
5
.changeset/lovely-papayas-hug.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix an issue where pastes in Safari wouldn't include application/x-slate-fragment data
|
@@ -1619,9 +1619,13 @@ export const Editable = (props: EditableProps) => {
|
|||||||
// fall back to React's `onPaste` here instead.
|
// fall back to React's `onPaste` here instead.
|
||||||
// COMPAT: Firefox, Chrome and Safari don't emit `beforeinput` events
|
// COMPAT: Firefox, Chrome and Safari don't emit `beforeinput` events
|
||||||
// when "paste without formatting" is used, so fallback. (2020/02/20)
|
// when "paste without formatting" is used, so fallback. (2020/02/20)
|
||||||
|
// COMPAT: Safari InputEvents generated by pasting won't include
|
||||||
|
// application/x-slate-fragment items, so use the
|
||||||
|
// ClipboardEvent here. (2023/03/15)
|
||||||
if (
|
if (
|
||||||
!HAS_BEFORE_INPUT_SUPPORT ||
|
!HAS_BEFORE_INPUT_SUPPORT ||
|
||||||
isPlainTextOnlyPaste(event.nativeEvent)
|
isPlainTextOnlyPaste(event.nativeEvent) ||
|
||||||
|
IS_SAFARI
|
||||||
) {
|
) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
ReactEditor.insertData(editor, event.clipboardData)
|
ReactEditor.insertData(editor, event.clipboardData)
|
||||||
|
Reference in New Issue
Block a user