1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-07-31 20:40:19 +02:00

Directly paste ClipboardEvents in Safari (#5362)

* Directly paste ClipboardEvents in Safari

* Add changeset
This commit is contained in:
Jason Cheatham
2023-03-16 09:00:41 -04:00
committed by GitHub
parent e587880964
commit 4399935690
2 changed files with 10 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-react': patch
---
Fix an issue where pastes in Safari wouldn't include application/x-slate-fragment data

View File

@@ -1619,9 +1619,13 @@ export const Editable = (props: EditableProps) => {
// fall back to React's `onPaste` here instead.
// COMPAT: Firefox, Chrome and Safari don't emit `beforeinput` events
// 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 (
!HAS_BEFORE_INPUT_SUPPORT ||
isPlainTextOnlyPaste(event.nativeEvent)
isPlainTextOnlyPaste(event.nativeEvent) ||
IS_SAFARI
) {
event.preventDefault()
ReactEditor.insertData(editor, event.clipboardData)