@myoc/excalidraw 0.19.544 → 0.19.546

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dev/index.js CHANGED
@@ -65,10 +65,10 @@ import {
65
65
  serializeAsJSON,
66
66
  strokeRectWithRotation_simple,
67
67
  zoomToFitBounds
68
- } from "./chunk-DPY7NUSG.js";
68
+ } from "./chunk-XE3CQOUC.js";
69
69
  import {
70
70
  define_import_meta_env_default
71
- } from "./chunk-AKYL2SH7.js";
71
+ } from "./chunk-GEFQQ6MF.js";
72
72
  import {
73
73
  en_default
74
74
  } from "./chunk-35XUJXYN.js";
@@ -10437,11 +10437,36 @@ var serializeAsClipboardJSON = ({
10437
10437
  };
10438
10438
  return JSON.stringify(contents);
10439
10439
  };
10440
+ var convertImageFileToPNG = async (file2) => {
10441
+ const bitmap = await createImageBitmap(file2);
10442
+ try {
10443
+ const canvas = document.createElement("canvas");
10444
+ canvas.width = bitmap.width;
10445
+ canvas.height = bitmap.height;
10446
+ const context = canvas.getContext("2d");
10447
+ if (!context) {
10448
+ throw new Error("Could not create a canvas context for clipboard image");
10449
+ }
10450
+ context.drawImage(bitmap, 0, 0);
10451
+ return await new Promise((resolve, reject) => {
10452
+ canvas.toBlob((blob) => {
10453
+ if (blob) {
10454
+ resolve(blob);
10455
+ } else {
10456
+ reject(new Error("Could not encode clipboard image as PNG"));
10457
+ }
10458
+ }, MIME_TYPES2.png);
10459
+ });
10460
+ } finally {
10461
+ bitmap.close();
10462
+ }
10463
+ };
10440
10464
  var copyToClipboard = async (elements, files, clipboardEvent) => {
10441
10465
  const json = serializeAsClipboardJSON({ elements, files });
10442
10466
  const imageFile = elements.length === 1 && isInitializedImageElement(elements[0]) ? files?.[elements[0].fileId] : null;
10443
10467
  const clipboardFile = imageFile && isSupportedImageFileType(imageFile.mimeType) && imageFile.dataURL ? dataURLToFile(imageFile.dataURL, imageFile.fileName) : null;
10444
10468
  if (clipboardFile) {
10469
+ const clipboardImagePNG = clipboardFile.type === MIME_TYPES2.png ? clipboardFile : convertImageFileToPNG(clipboardFile);
10445
10470
  if (supportsClipboardBlob()) {
10446
10471
  try {
10447
10472
  await navigator.clipboard.write([
@@ -10449,7 +10474,7 @@ var copyToClipboard = async (elements, files, clipboardEvent) => {
10449
10474
  [WEB_EXCALIDRAW_CLIPBOARD_MIME_TYPE]: new Blob([json], {
10450
10475
  type: MIME_TYPES2.excalidrawClipboard
10451
10476
  }),
10452
- [clipboardFile.type]: clipboardFile
10477
+ [MIME_TYPES2.png]: clipboardImagePNG
10453
10478
  })
10454
10479
  ]);
10455
10480
  return;
@@ -10459,7 +10484,12 @@ var copyToClipboard = async (elements, files, clipboardEvent) => {
10459
10484
  }
10460
10485
  if (clipboardEvent?.clipboardData?.items) {
10461
10486
  try {
10462
- clipboardEvent.clipboardData.items.add(clipboardFile);
10487
+ const clipboardImageFile = clipboardFile.type === MIME_TYPES2.png ? clipboardFile : new File(
10488
+ [await clipboardImagePNG],
10489
+ `${clipboardFile.name.replace(/\.[^/.]+$/, "") || "image"}.png`,
10490
+ { type: MIME_TYPES2.png }
10491
+ );
10492
+ clipboardEvent.clipboardData.items.add(clipboardImageFile);
10463
10493
  await copyTextToSystemClipboard(
10464
10494
  { [MIME_TYPES2.excalidrawClipboard]: json },
10465
10495
  clipboardEvent
@@ -11014,7 +11044,7 @@ var exportCanvas = async (type, elements, appState, files, {
11014
11044
  let blob = canvasToBlob(tempCanvas);
11015
11045
  if (appState.exportEmbedScene) {
11016
11046
  blob = blob.then(
11017
- (blob2) => import("./data/image-AIHWJUYD.js").then(
11047
+ (blob2) => import("./data/image-K27274LO.js").then(
11018
11048
  ({ encodePngMetadata: encodePngMetadata2 }) => encodePngMetadata2({
11019
11049
  blob: blob2,
11020
11050
  metadata: serializeAsJSON(elements, appState, files, "local")
@@ -12933,8 +12963,9 @@ var actionCopy = register({
12933
12963
  captureUpdate: CaptureUpdateAction20.EVENTUALLY
12934
12964
  };
12935
12965
  },
12936
- // don't supply a shortcut since we handle this conditionally via onCopy event
12937
- keyTest: void 0
12966
+ // MyOC: Handle keyboard copy at keydown so async ClipboardItem writes use
12967
+ // the keyboard gesture instead of relying on the native copy-event fallback.
12968
+ keyTest: (event) => event[KEYS25.CTRL_OR_CMD] && event.key === KEYS25.C
12938
12969
  });
12939
12970
  var actionPaste = register({
12940
12971
  name: "paste",
@@ -15250,7 +15281,12 @@ import { arrayToMap as arrayToMap23, findIndex, findLastIndex as findLastIndex2
15250
15281
  import { isFiniteNumber } from "@excalidraw/math";
15251
15282
 
15252
15283
  // ../element/src/gif.ts
15253
- import { decode, decodeFrames } from "modern-gif";
15284
+ import { decodeAnimated } from "@discourse/gif";
15285
+ var GIF_WORKER_FILENAME = "gif.worker.js";
15286
+ var gifWorkerUrl = new URL(
15287
+ GIF_WORKER_FILENAME,
15288
+ import.meta.url
15289
+ ).toString();
15254
15290
 
15255
15291
  // ../element/src/image.ts
15256
15292
  import {
@@ -31768,21 +31804,34 @@ var GifPlaybackControls = ({
31768
31804
  app.ensureGifPlaybackLoop();
31769
31805
  }
31770
31806
  };
31771
- const deferredGifBadges = app.scene.getNonDeletedElements().filter(
31772
- (element) => isInitializedImageElement4(element) && !liveAppState.selectedElementIds[element.id] && files[element.fileId]?.mimeType === MIME_TYPES10.gif && app.imageCache.get(element.fileId)?.gifDecodeStatus === "deferred"
31773
- ).map((element) => {
31807
+ const deferredGifControls = app.scene.getNonDeletedElements().flatMap((element) => {
31808
+ if (!isInitializedImageElement4(element) || files[element.fileId]?.mimeType !== MIME_TYPES10.gif || app.imageCache.get(element.fileId)?.gifDecodeStatus !== "deferred") {
31809
+ return [];
31810
+ }
31774
31811
  const position = getGifControlPosition(element, liveAppState);
31775
- return /* @__PURE__ */ jsx113(
31776
- "span",
31777
- {
31778
- className: "gif-playback-controls gif-playback-controls__deferred-badge",
31779
- role: "img",
31780
- "aria-label": "GIF paused",
31781
- style: position,
31782
- children: CirclePauseIcon
31783
- },
31784
- element.id
31785
- );
31812
+ return [
31813
+ /* @__PURE__ */ jsx113(
31814
+ "div",
31815
+ {
31816
+ className: "gif-playback-controls gif-playback-controls--deferred",
31817
+ style: position,
31818
+ onPointerDown: (event) => event.stopPropagation(),
31819
+ children: /* @__PURE__ */ jsx113(
31820
+ "button",
31821
+ {
31822
+ type: "button",
31823
+ className: "gif-playback-controls__load-large",
31824
+ title: "Load Large GIF",
31825
+ onClick: () => {
31826
+ app.loadDeferredGif(element.fileId);
31827
+ },
31828
+ children: "Load Large GIF"
31829
+ }
31830
+ )
31831
+ },
31832
+ element.id
31833
+ )
31834
+ ];
31786
31835
  });
31787
31836
  const selectedElements = app.scene.getSelectedElements(liveAppState);
31788
31837
  const selectedElementControls = () => {
@@ -31813,29 +31862,6 @@ var GifPlaybackControls = ({
31813
31862
  leftTop.y - liveAppState.offsetTop + 16
31814
31863
  )
31815
31864
  );
31816
- if (cacheEntry?.gifDecodeStatus === "deferred") {
31817
- const position = getGifControlPosition(selectedElement, liveAppState);
31818
- return /* @__PURE__ */ jsx113(
31819
- "div",
31820
- {
31821
- className: "gif-playback-controls gif-playback-controls--deferred",
31822
- style: position,
31823
- onPointerDown: (event) => event.stopPropagation(),
31824
- children: /* @__PURE__ */ jsx113(
31825
- "button",
31826
- {
31827
- type: "button",
31828
- className: "gif-playback-controls__load-large",
31829
- title: "Load Large GIF",
31830
- onClick: () => {
31831
- app.loadDeferredGif(selectedElement.fileId);
31832
- },
31833
- children: "Load Large GIF"
31834
- }
31835
- )
31836
- }
31837
- );
31838
- }
31839
31865
  if (cacheEntry?.gifDecodeStatus === "pending") {
31840
31866
  return null;
31841
31867
  }
@@ -32182,7 +32208,7 @@ var GifPlaybackControls = ({
32182
32208
  );
32183
32209
  };
32184
32210
  return /* @__PURE__ */ jsxs59(Fragment18, { children: [
32185
- deferredGifBadges,
32211
+ deferredGifControls,
32186
32212
  selectedElementControls()
32187
32213
  ] });
32188
32214
  };