feat: Added Copy/Paste from Google Docs (#7136)

Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
Lakshya Satpal
2023-10-19 15:44:23 +05:30
committed by GitHub
parent dde3dac931
commit 63650f82d1
9 changed files with 232 additions and 77 deletions
+5 -6
View File
@@ -208,10 +208,8 @@ export const assertSelectedElements = (
expect(selectedElementIds).toEqual(expect.arrayContaining(ids));
};
export const createPasteEvent = (
text:
| string
| /* getData function */ ((type: string) => string | Promise<string>),
export const createPasteEvent = <T extends "text/plain" | "text/html">(
items: Record<T, string>,
files?: File[],
) => {
return Object.assign(
@@ -222,11 +220,12 @@ export const createPasteEvent = (
}),
{
clipboardData: {
getData: typeof text === "string" ? () => text : text,
getData: (type: string) =>
(items as Record<string, string>)[type] || "",
files: files || [],
},
},
);
) as any as ClipboardEvent;
};
export const toggleMenu = (container: HTMLElement) => {