mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-11-20 20:55:06 +01:00
feat: [cont.] support inserting multiple images (#9875)
* feat: support inserting multiple images * Initial * handleAppOnDrop, onImageToolbarButtonClick, pasteFromClipboard * Initial get history working * insertMultipleImages -> insertImages * Bug fixes, improvements * Remove redundant branch * Refactor addElementsFromMixedContentPaste * History, drag & drop bug fixes * Update snapshots * Remove redundant try-catch * Refactor pasteFromClipboard * Plain paste check in mermaid paste * Move comment * processClipboardData -> insertClipboardContent * Redundant variable * Redundant variable * Refactor insertImages * createImagePlaceholder -> newImagePlaceholder * Get rid of unneeded NEVER schedule, filter out failed images * Trigger CI * Position placeholders before initializing * Don't mutate scene with positionElementsOnGrid, captureUpdate: CaptureUpdateAction.IMMEDIATELY * Comment * Move positionOnGrid out of file * Rename file * Get rid of generic * Initial tests * More asserts, test paste * Test image tool * De-duplicate * Stricter assert, move rest of logic outside of waitFor * Modify history tests * De-duplicate update snapshots * Trigger CI * Fix package build * Make setupImageTest more explicit * Re-introduce generic to use latest placeholder versions * newElementWith instead of mutateElement to delete failed placeholder * Insert failed images separately with CaptureUpdateAction.NEVER * Refactor * Don't re-order elements * WIP * Get rid of 'never' for failed * refactor type check * align max file size constant * make grid padding scale to zoom --------- Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
arrayToMap,
|
||||
isMemberOf,
|
||||
isPromiseLike,
|
||||
EVENT,
|
||||
} from "@excalidraw/common";
|
||||
|
||||
import { mutateElement } from "@excalidraw/element";
|
||||
@@ -92,7 +93,7 @@ export const createPasteEvent = ({
|
||||
console.warn("createPasteEvent: no types or files provided");
|
||||
}
|
||||
|
||||
const event = new ClipboardEvent("paste", {
|
||||
const event = new ClipboardEvent(EVENT.PASTE, {
|
||||
clipboardData: new DataTransfer(),
|
||||
});
|
||||
|
||||
@@ -519,3 +520,14 @@ const copyTextViaExecCommand = (text: string | null) => {
|
||||
|
||||
return success;
|
||||
};
|
||||
|
||||
export const isClipboardEvent = (
|
||||
event: React.SyntheticEvent | Event,
|
||||
): event is ClipboardEvent => {
|
||||
/** not using instanceof ClipboardEvent due to tests (jsdom) */
|
||||
return (
|
||||
event.type === EVENT.PASTE ||
|
||||
event.type === EVENT.COPY ||
|
||||
event.type === EVENT.CUT
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user