mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-21 22:45:18 +02:00
fix: weak guard on DataTransfer to not rely on current window (#4654)
This commit is contained in:
5
.changeset/beige-hotels-vanish.md
Normal file
5
.changeset/beige-hotels-vanish.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
weak guard on DataTransfer to not rely on current window
|
@@ -429,9 +429,11 @@ export const Editable = (props: EditableProps) => {
|
|||||||
state.isComposing = false
|
state.isComposing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const window = ReactEditor.getWindow(editor)
|
// use a weak comparison instead of 'instanceof' to allow
|
||||||
if (data instanceof window.DataTransfer) {
|
// programmatic access of paste events coming from external windows
|
||||||
ReactEditor.insertData(editor, data as DataTransfer)
|
// like cypress where cy.window does not work realibly
|
||||||
|
if (data?.constructor.name === 'DataTransfer') {
|
||||||
|
ReactEditor.insertData(editor, data)
|
||||||
} else if (typeof data === 'string') {
|
} else if (typeof data === 'string') {
|
||||||
// Only insertText operations use the native functionality, for now.
|
// Only insertText operations use the native functionality, for now.
|
||||||
// Potentially expand to single character deletes, as well.
|
// Potentially expand to single character deletes, as well.
|
||||||
|
Reference in New Issue
Block a user