mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: Add onPaste prop to customise clipboard paste event (#3420)
* Add Awaited type util * Expose onPasteFromClipboard props * Add `event` as second param for advanced usages * Add support for async flows * Extract ClipboardData type * Rename `onPasteFromClipboard` to `onPaste` * Remove unused type helper * Add `onPaste` documentation * tweak docs * fix Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
This commit is contained in:
parent
89472c14ed
commit
d91950bd03
6 changed files with 39 additions and 8 deletions
|
@ -14,6 +14,13 @@ type ElementsClipboard = {
|
|||
elements: ExcalidrawElement[];
|
||||
};
|
||||
|
||||
export interface ClipboardData {
|
||||
spreadsheet?: Spreadsheet;
|
||||
elements?: readonly ExcalidrawElement[];
|
||||
text?: string;
|
||||
errorMessage?: string;
|
||||
}
|
||||
|
||||
let CLIPBOARD = "";
|
||||
let PREFER_APP_CLIPBOARD = false;
|
||||
|
||||
|
@ -110,12 +117,7 @@ const getSystemClipboard = async (
|
|||
*/
|
||||
export const parseClipboard = async (
|
||||
event: ClipboardEvent | null,
|
||||
): Promise<{
|
||||
spreadsheet?: Spreadsheet;
|
||||
elements?: readonly ExcalidrawElement[];
|
||||
text?: string;
|
||||
errorMessage?: string;
|
||||
}> => {
|
||||
): Promise<ClipboardData> => {
|
||||
const systemClipboard = await getSystemClipboard(event);
|
||||
|
||||
// if system clipboard empty, couldn't be resolved, or contains previously
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue