1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-12 10:14:02 +02:00

Allow setFragmentData without clipboardData object (#4333)

* allow setFragmentData to be used without a copy/paste or DnD data structure

* Add changeset

* return data for use outside of setFragmentData call
This commit is contained in:
Dylan Schiemann
2021-08-06 07:43:42 -07:00
committed by GitHub
parent f0721ac42a
commit e0776c5c92
2 changed files with 7 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-react': patch
---
Allow setFragmentData to work without copy/paste or DnD data structure

View File

@@ -96,7 +96,7 @@ export const withReact = <T extends Editor>(editor: T) => {
}
}
e.setFragmentData = (data: DataTransfer) => {
e.setFragmentData = (data: Pick<DataTransfer, 'getData' | 'setData'>) => {
const { selection } = e
if (!selection) {
@@ -179,6 +179,7 @@ export const withReact = <T extends Editor>(editor: T) => {
data.setData('text/html', div.innerHTML)
data.setData('text/plain', getPlainText(div))
document.body.removeChild(div)
return data
}
e.insertData = (data: DataTransfer) => {