@myoc/excalidraw 0.19.512 → 0.19.514

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/CHANGELOG.md CHANGED
@@ -4442,4 +4442,57 @@ First release of `@excalidraw/excalidraw`## Excalidraw Library
4442
4442
  - Incorrect import for color (was moved to common)
4443
4443
 
4444
4444
  ---
4445
+ ## Excalidraw Library
4446
+
4447
+ **_This section lists the updates made to the excalidraw library and will not affect the integration._**
4448
+
4449
+ ### Features
4450
+
4451
+ - Add ability to turn off compression for files that are smaller than a given size
4452
+
4453
+ - Add lock tool to the dropdown and also add the status of the extra tools to be the same icon as the selected tool
4454
+
4455
+ - Add view mode button
4456
+
4457
+ - Add multiple image copy paste or drag and drop
4458
+
4459
+ - Multiple image additions from clipboard
4460
+
4461
+ - Add arrange elements action
4462
+
4463
+ - Add top picks to appProps for both stoke color and background color
4464
+
4465
+ ### Fixes
4466
+
4467
+ - Issues
4468
+
4469
+ - Make mobile mode more myoc looking
4470
+
4471
+ - Add normalise functionality
4472
+
4473
+ - Update with excalidraw
4474
+
4475
+ - Fix imports
4476
+
4477
+ - Fix mutateGroup to use scene.mutateGroup
4478
+
4479
+ - Imports
4480
+
4481
+ - Ensure that fileId is different for compressed vs uncompressed file
4482
+
4483
+ - Remove not working prop for dontResizeLimitMBs
4484
+
4485
+ - Add smartview for mobile
4486
+
4487
+ - Hide the alignment buttons if there is only one group selected (they do nothing if only one group is selected)
4488
+
4489
+ - Use css vars already provided instead of hard coding directly from oc-gray
4490
+
4491
+ - Remove unused variables
4492
+
4493
+ - Pass the new top pick color props properly
4494
+
4495
+ - Incorrect import for color (was moved to common)
4496
+
4497
+ ---
4445
4498
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  define_import_meta_env_default
3
- } from "./chunk-QHLG4OQL.js";
3
+ } from "./chunk-FW62QUKV.js";
4
4
  import {
5
5
  __publicField
6
6
  } from "./chunk-XDFCUUT6.js";
@@ -5101,7 +5101,7 @@ var parseFileContents = async (blob) => {
5101
5101
  let contents;
5102
5102
  if (blob.type === MIME_TYPES6.png) {
5103
5103
  try {
5104
- return await (await import("./data/image-R7FQP7SA.js")).decodePngMetadata(blob);
5104
+ return await (await import("./data/image-WGZL7YPK.js")).decodePngMetadata(blob);
5105
5105
  } catch (error) {
5106
5106
  if (error.message === "INVALID") {
5107
5107
  throw new ImageSceneDataError(
@@ -5462,4 +5462,4 @@ export {
5462
5462
  createFile,
5463
5463
  normalizeFile
5464
5464
  };
5465
- //# sourceMappingURL=chunk-OBLRXIUK.js.map
5465
+ //# sourceMappingURL=chunk-BI6BDZVY.js.map
@@ -1,7 +1,7 @@
1
1
  // <define:import.meta.env>
2
- var define_import_meta_env_default = { MODE: "development", VITE_APP_BACKEND_V2_GET_URL: "https://json-dev.excalidraw.com/api/v2/", VITE_APP_BACKEND_V2_POST_URL: "https://json-dev.excalidraw.com/api/v2/post/", VITE_APP_LIBRARY_URL: "https://libraries.excalidraw.com", VITE_APP_LIBRARY_BACKEND: "https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries", VITE_APP_WS_SERVER_URL: "http://localhost:3002", VITE_APP_PLUS_LP: "https://plus.excalidraw.com", VITE_APP_PLUS_APP: "http://localhost:3000", VITE_APP_AI_BACKEND: "http://localhost:3016", VITE_APP_FIREBASE_CONFIG: '{"apiKey":"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8","authDomain":"excalidraw-oss-dev.firebaseapp.com","projectId":"excalidraw-oss-dev","storageBucket":"excalidraw-oss-dev.appspot.com","messagingSenderId":"664559512677","appId":"1:664559512677:web:a385181f2928d328a7aa8c"}', VITE_APP_DEV_DISABLE_LIVE_RELOAD: "", VITE_APP_ENABLE_TRACKING: "true", FAST_REFRESH: "false", VITE_APP_PORT: "3001", VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX: "", VITE_APP_COLLAPSE_OVERLAY: "true", VITE_APP_ENABLE_ESLINT: "true", VITE_APP_ENABLE_PWA: "false", VITE_APP_PLUS_EXPORT_PUBLIC_KEY: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\nHQIDAQAB", VITE_APP_DISABLE_PREVENT_UNLOAD: "", PKG_NAME: "@myoc/excalidraw", PKG_VERSION: "0.19.511", DEV: true };
2
+ var define_import_meta_env_default = { MODE: "development", VITE_APP_BACKEND_V2_GET_URL: "https://json-dev.excalidraw.com/api/v2/", VITE_APP_BACKEND_V2_POST_URL: "https://json-dev.excalidraw.com/api/v2/post/", VITE_APP_LIBRARY_URL: "https://libraries.excalidraw.com", VITE_APP_LIBRARY_BACKEND: "https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries", VITE_APP_WS_SERVER_URL: "http://localhost:3002", VITE_APP_PLUS_LP: "https://plus.excalidraw.com", VITE_APP_PLUS_APP: "http://localhost:3000", VITE_APP_AI_BACKEND: "http://localhost:3016", VITE_APP_FIREBASE_CONFIG: '{"apiKey":"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8","authDomain":"excalidraw-oss-dev.firebaseapp.com","projectId":"excalidraw-oss-dev","storageBucket":"excalidraw-oss-dev.appspot.com","messagingSenderId":"664559512677","appId":"1:664559512677:web:a385181f2928d328a7aa8c"}', VITE_APP_DEV_DISABLE_LIVE_RELOAD: "", VITE_APP_ENABLE_TRACKING: "true", FAST_REFRESH: "false", VITE_APP_PORT: "3001", VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX: "", VITE_APP_COLLAPSE_OVERLAY: "true", VITE_APP_ENABLE_ESLINT: "true", VITE_APP_ENABLE_PWA: "false", VITE_APP_PLUS_EXPORT_PUBLIC_KEY: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\nHQIDAQAB", VITE_APP_DISABLE_PREVENT_UNLOAD: "", PKG_NAME: "@myoc/excalidraw", PKG_VERSION: "0.19.512", DEV: true };
3
3
 
4
4
  export {
5
5
  define_import_meta_env_default
6
6
  };
7
- //# sourceMappingURL=chunk-QHLG4OQL.js.map
7
+ //# sourceMappingURL=chunk-FW62QUKV.js.map
@@ -2,12 +2,12 @@ import {
2
2
  decodePngMetadata,
3
3
  encodePngMetadata,
4
4
  getTEXtChunk
5
- } from "../chunk-OBLRXIUK.js";
6
- import "../chunk-QHLG4OQL.js";
5
+ } from "../chunk-BI6BDZVY.js";
6
+ import "../chunk-FW62QUKV.js";
7
7
  import "../chunk-XDFCUUT6.js";
8
8
  export {
9
9
  decodePngMetadata,
10
10
  encodePngMetadata,
11
11
  getTEXtChunk
12
12
  };
13
- //# sourceMappingURL=image-R7FQP7SA.js.map
13
+ //# sourceMappingURL=image-WGZL7YPK.js.map
package/dist/dev/index.js CHANGED
@@ -57,10 +57,10 @@ import {
57
57
  saveAsJSON,
58
58
  serializeAsJSON,
59
59
  strokeRectWithRotation_simple
60
- } from "./chunk-OBLRXIUK.js";
60
+ } from "./chunk-BI6BDZVY.js";
61
61
  import {
62
62
  define_import_meta_env_default
63
- } from "./chunk-QHLG4OQL.js";
63
+ } from "./chunk-FW62QUKV.js";
64
64
  import {
65
65
  en_default
66
66
  } from "./chunk-ZGRXNVW4.js";
@@ -9611,7 +9611,7 @@ var exportCanvas = async (type, elements, appState, files, {
9611
9611
  let blob = canvasToBlob(tempCanvas);
9612
9612
  if (appState.exportEmbedScene) {
9613
9613
  blob = blob.then(
9614
- (blob2) => import("./data/image-R7FQP7SA.js").then(
9614
+ (blob2) => import("./data/image-WGZL7YPK.js").then(
9615
9615
  ({ encodePngMetadata: encodePngMetadata2 }) => encodePngMetadata2({
9616
9616
  blob: blob2,
9617
9617
  metadata: serializeAsJSON(elements, appState, files, "local")
@@ -19881,17 +19881,29 @@ var Popover6 = ({
19881
19881
  // components/ContextMenu.tsx
19882
19882
  import { jsx as jsx62, jsxs as jsxs29 } from "react/jsx-runtime";
19883
19883
  var CONTEXT_MENU_SEPARATOR = "separator";
19884
+ var isCustomContextMenuItem = (item) => "onSelect" in item;
19884
19885
  var ContextMenu = React19.memo(
19885
19886
  ({ actionManager, items, top, left, onClose }) => {
19886
19887
  const appState = useExcalidrawAppState();
19887
19888
  const elements = useExcalidrawElements();
19888
19889
  const filteredItems = items.reduce((acc, item) => {
19889
- if (item && (item === CONTEXT_MENU_SEPARATOR || !item.predicate || item.predicate(
19890
+ if (!item) {
19891
+ return acc;
19892
+ }
19893
+ if (item === CONTEXT_MENU_SEPARATOR) {
19894
+ acc.push(item);
19895
+ return acc;
19896
+ }
19897
+ if (isCustomContextMenuItem(item)) {
19898
+ acc.push(item);
19899
+ return acc;
19900
+ }
19901
+ if (!item.predicate || item.predicate(
19890
19902
  elements,
19891
19903
  appState,
19892
19904
  actionManager.app.props,
19893
19905
  actionManager.app
19894
- ))) {
19906
+ )) {
19895
19907
  acc.push(item);
19896
19908
  }
19897
19909
  return acc;
@@ -19922,6 +19934,24 @@ var ContextMenu = React19.memo(
19922
19934
  }
19923
19935
  return /* @__PURE__ */ jsx62("hr", { className: "context-menu-item-separator" }, idx);
19924
19936
  }
19937
+ if (isCustomContextMenuItem(item)) {
19938
+ return /* @__PURE__ */ jsx62(
19939
+ "li",
19940
+ {
19941
+ "data-testid": item.key,
19942
+ onClick: () => {
19943
+ onClose(() => {
19944
+ item.onSelect();
19945
+ });
19946
+ },
19947
+ children: /* @__PURE__ */ jsxs29("button", { type: "button", className: "context-menu-item", children: [
19948
+ /* @__PURE__ */ jsx62("div", { className: "context-menu-item__label", children: item.label }),
19949
+ /* @__PURE__ */ jsx62("kbd", { className: "context-menu-item__shortcut" })
19950
+ ] })
19951
+ },
19952
+ item.key
19953
+ );
19954
+ }
19925
19955
  const actionName = item.name;
19926
19956
  let label = "";
19927
19957
  if (item.label) {
@@ -35625,7 +35655,8 @@ var App = class _App extends React40.Component {
35625
35655
  __publicField(this, "newImagePlaceholder", ({
35626
35656
  sceneX,
35627
35657
  sceneY,
35628
- addToFrameUnderCursor = true
35658
+ addToFrameUnderCursor = true,
35659
+ customData
35629
35660
  }) => {
35630
35661
  const [gridX, gridY] = getGridPoint2(
35631
35662
  sceneX,
@@ -35652,7 +35683,8 @@ var App = class _App extends React40.Component {
35652
35683
  x: gridX - placeholderSize / 2,
35653
35684
  y: gridY - placeholderSize / 2,
35654
35685
  width: placeholderSize,
35655
- height: placeholderSize
35686
+ height: placeholderSize,
35687
+ customData
35656
35688
  });
35657
35689
  });
35658
35690
  __publicField(this, "handleLinearElementOnPointerDown", (event, elementType, pointerDownState) => {
@@ -36046,7 +36078,6 @@ var App = class _App extends React40.Component {
36046
36078
  const fileId = await (this.props.generateIdForFile?.(
36047
36079
  imageFile
36048
36080
  ) || generateIdFromFile(imageFile));
36049
- console.info("Excalidraw File ID:", fileId);
36050
36081
  if (!fileId) {
36051
36082
  console.warn(
36052
36083
  "Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."
@@ -36128,7 +36159,13 @@ var App = class _App extends React40.Component {
36128
36159
  ),
36129
36160
  multiple: true
36130
36161
  });
36131
- this.insertImages(imageFiles, x, y);
36162
+ this.insertImages(
36163
+ imageFiles.map((f) => ({
36164
+ file: f
36165
+ })),
36166
+ x,
36167
+ y
36168
+ );
36132
36169
  } catch (error) {
36133
36170
  if (error.name !== "AbortError") {
36134
36171
  console.error(error);
@@ -36241,7 +36278,9 @@ var App = class _App extends React40.Component {
36241
36278
  __publicField(this, "insertImages", async (imageFiles, sceneX, sceneY) => {
36242
36279
  const gridPadding = 50 / this.state.zoom.value;
36243
36280
  const placeholders = positionElementsOnGrid(
36244
- imageFiles.map(() => this.newImagePlaceholder({ sceneX, sceneY })),
36281
+ imageFiles.map(
36282
+ ({ customData }) => this.newImagePlaceholder({ sceneX, sceneY, customData })
36283
+ ),
36245
36284
  sceneX,
36246
36285
  sceneY,
36247
36286
  gridPadding
@@ -36252,7 +36291,7 @@ var App = class _App extends React40.Component {
36252
36291
  try {
36253
36292
  return await this.initializeImage(
36254
36293
  placeholder,
36255
- await normalizeFile(imageFiles[i])
36294
+ await normalizeFile(imageFiles[i].file)
36256
36295
  );
36257
36296
  } catch (error) {
36258
36297
  this.setState({
@@ -36321,7 +36360,13 @@ var App = class _App extends React40.Component {
36321
36360
  }
36322
36361
  const imageFiles = fileItems.map((data) => data.file).filter((file2) => isSupportedImageFile(file2));
36323
36362
  if (imageFiles.length > 0 && this.isToolSupported("image")) {
36324
- return this.insertImages(imageFiles, sceneX, sceneY);
36363
+ return this.insertImages(
36364
+ imageFiles.map((file2) => ({
36365
+ file: file2
36366
+ })),
36367
+ sceneX,
36368
+ sceneY
36369
+ );
36325
36370
  }
36326
36371
  if (fileItems.length > 0) {
36327
36372
  const { file: file2, fileHandle } = fileItems[0];
@@ -36681,6 +36726,8 @@ var App = class _App extends React40.Component {
36681
36726
  });
36682
36727
  __publicField(this, "getContextMenuItems", (type) => {
36683
36728
  const options = [];
36729
+ const imageContextMenuItems = this.getImageContextMenuItems();
36730
+ const imageContextMenuSection = imageContextMenuItems.length > 0 ? [CONTEXT_MENU_SEPARATOR, ...imageContextMenuItems] : [];
36684
36731
  if (type === "canvas") {
36685
36732
  if (this.state.viewModeEnabled) {
36686
36733
  return [actionToggleGridMode, actionToggleViewMode, actionToggleStats];
@@ -36703,7 +36750,9 @@ var App = class _App extends React40.Component {
36703
36750
  }
36704
36751
  options.push(copyText);
36705
36752
  if (this.state.viewModeEnabled) {
36706
- return [actionCopy, ...options];
36753
+ const viewModeItems = [actionCopy];
36754
+ viewModeItems.push(...imageContextMenuSection, ...options);
36755
+ return viewModeItems;
36707
36756
  }
36708
36757
  const zIndexActions = this.editorInterface.formFactor === "desktop" ? [
36709
36758
  CONTEXT_MENU_SEPARATOR,
@@ -36712,11 +36761,17 @@ var App = class _App extends React40.Component {
36712
36761
  actionSendToBack,
36713
36762
  actionBringToFront
36714
36763
  ] : [];
36715
- return [
36764
+ const elementItems = [
36716
36765
  CONTEXT_MENU_SEPARATOR,
36717
36766
  actionCut,
36718
36767
  actionCopy,
36719
- actionPaste,
36768
+ actionPaste
36769
+ ];
36770
+ elementItems.push(...imageContextMenuSection);
36771
+ if (imageContextMenuItems.length > 0) {
36772
+ elementItems.push(CONTEXT_MENU_SEPARATOR);
36773
+ }
36774
+ elementItems.push(
36720
36775
  CONTEXT_MENU_SEPARATOR,
36721
36776
  actionSelectAllElementsInFrame,
36722
36777
  actionRemoveAllElementsFromFrame,
@@ -36749,6 +36804,21 @@ var App = class _App extends React40.Component {
36749
36804
  actionToggleElementLock,
36750
36805
  CONTEXT_MENU_SEPARATOR,
36751
36806
  actionDeleteSelected
36807
+ );
36808
+ return elementItems;
36809
+ });
36810
+ __publicField(this, "getImageContextMenuItems", () => {
36811
+ if (!this.props.imageContextMenuItems) {
36812
+ return [];
36813
+ }
36814
+ const selectedElements = this.scene.getSelectedElements(this.state);
36815
+ if (selectedElements.length === 0 || !selectedElements.every((element) => isImageElement9(element))) {
36816
+ return [];
36817
+ }
36818
+ return [
36819
+ ...this.props.imageContextMenuItems(
36820
+ selectedElements.map((element) => element.id)
36821
+ )
36752
36822
  ];
36753
36823
  });
36754
36824
  __publicField(this, "handleWheel", withBatchedUpdates(
@@ -38372,7 +38442,13 @@ var App = class _App extends React40.Component {
38372
38442
  }
38373
38443
  if (imageFiles.length > 0) {
38374
38444
  if (this.isToolSupported("image")) {
38375
- await this.insertImages(imageFiles, sceneX, sceneY);
38445
+ await this.insertImages(
38446
+ imageFiles.map((file2) => ({
38447
+ file: file2
38448
+ })),
38449
+ sceneX,
38450
+ sceneY
38451
+ );
38376
38452
  } else {
38377
38453
  this.setState({ errorMessage: t("errors.imageToolNotSupported") });
38378
38454
  }
@@ -38448,7 +38524,13 @@ var App = class _App extends React40.Component {
38448
38524
  })
38449
38525
  );
38450
38526
  const imageFiles = responses.filter((response) => !!response.file).map((response) => response.file);
38451
- await this.insertImages(imageFiles, sceneX, sceneY);
38527
+ await this.insertImages(
38528
+ imageFiles.map((file2) => ({
38529
+ file: file2
38530
+ })),
38531
+ sceneX,
38532
+ sceneY
38533
+ );
38452
38534
  const error = responses.find((response) => !!response.errorMessage);
38453
38535
  if (error && error.errorMessage) {
38454
38536
  this.setState({ errorMessage: error.errorMessage });
@@ -41196,6 +41278,7 @@ var ExcalidrawBase = (props) => {
41196
41278
  onPointerUp,
41197
41279
  onScrollChange,
41198
41280
  onDuplicate,
41281
+ imageContextMenuItems,
41199
41282
  children,
41200
41283
  validateEmbeddable,
41201
41284
  renderEmbeddable,
@@ -41291,6 +41374,7 @@ var ExcalidrawBase = (props) => {
41291
41374
  onPointerUp,
41292
41375
  onScrollChange,
41293
41376
  onDuplicate,
41377
+ imageContextMenuItems,
41294
41378
  validateEmbeddable,
41295
41379
  renderEmbeddable,
41296
41380
  showDeprecatedFonts,