Skip to content

Commit

Permalink
feat(core): allow setFragmentData without clipboardData object
Browse files Browse the repository at this point in the history
  • Loading branch information
pubuzhixing8 committed Feb 11, 2022
1 parent dd32550 commit 52ba73e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/odd-garlics-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"slate-angular": patch
---

Allow setFragmentData to work without copy/paste or DnD data structure
3 changes: 2 additions & 1 deletion packages/src/plugins/with-angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const withAngular = <T extends Editor>(editor: T, clipboardFormatKey = 'x
onChange();
};

e.setFragmentData = (data: DataTransfer) => {
e.setFragmentData = (data: Pick<DataTransfer, 'getData' | 'setData'>) => {
const { selection } = e;

if (!selection) {
Expand Down Expand Up @@ -178,6 +178,7 @@ export const withAngular = <T extends Editor>(editor: T, clipboardFormatKey = 'x
data.setData('text/html', div.innerHTML);
data.setData('text/plain', getPlainText(div));
contents.ownerDocument.body.removeChild(div);
return data;
};

e.deleteCutData = () => {
Expand Down

0 comments on commit 52ba73e

Please sign in to comment.