@nous-excalidraw/excalidraw 0.18.3 → 0.18.4-beta.2

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.
@@ -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: "@nous-excalidraw/excalidraw", PKG_VERSION: "0.18.2-beta.1", 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: "@nous-excalidraw/excalidraw", PKG_VERSION: "0.18.4-beta.1", DEV: true };
3
3
 
4
4
  export {
5
5
  define_import_meta_env_default
6
6
  };
7
- //# sourceMappingURL=chunk-GDIPPJNS.js.map
7
+ //# sourceMappingURL=chunk-2C5KXBJQ.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  define_import_meta_env_default
3
- } from "./chunk-GDIPPJNS.js";
3
+ } from "./chunk-2C5KXBJQ.js";
4
4
  import {
5
5
  __publicField
6
6
  } from "./chunk-XDFCUUT6.js";
@@ -5085,7 +5085,7 @@ var parseFileContents = async (blob) => {
5085
5085
  let contents;
5086
5086
  if (blob.type === MIME_TYPES6.png) {
5087
5087
  try {
5088
- return await (await import("./data/image-X4CDE7NB.js")).decodePngMetadata(blob);
5088
+ return await (await import("./data/image-JEK4DDYJ.js")).decodePngMetadata(blob);
5089
5089
  } catch (error) {
5090
5090
  if (error.message === "INVALID") {
5091
5091
  throw new ImageSceneDataError(
@@ -5519,4 +5519,4 @@ export {
5519
5519
  createFile,
5520
5520
  normalizeFile
5521
5521
  };
5522
- //# sourceMappingURL=chunk-4Q2BPT5H.js.map
5522
+ //# sourceMappingURL=chunk-SAWRJ2AG.js.map
@@ -1,4 +1,4 @@
1
- import "../../chunk-GDIPPJNS.js";
1
+ import "../../chunk-2C5KXBJQ.js";
2
2
  import "../../chunk-XDFCUUT6.js";
3
3
 
4
4
  // components/TTDDialog/CodeMirrorEditor.tsx
@@ -256,4 +256,4 @@ var CodeMirrorEditor_default = CodeMirrorEditor;
256
256
  export {
257
257
  CodeMirrorEditor_default as default
258
258
  };
259
- //# sourceMappingURL=CodeMirrorEditor-R36AGSC4.js.map
259
+ //# sourceMappingURL=CodeMirrorEditor-I72JGFZW.js.map
@@ -2,12 +2,12 @@ import {
2
2
  decodePngMetadata,
3
3
  encodePngMetadata,
4
4
  getTEXtChunk
5
- } from "../chunk-4Q2BPT5H.js";
6
- import "../chunk-GDIPPJNS.js";
5
+ } from "../chunk-SAWRJ2AG.js";
6
+ import "../chunk-2C5KXBJQ.js";
7
7
  import "../chunk-XDFCUUT6.js";
8
8
  export {
9
9
  decodePngMetadata,
10
10
  encodePngMetadata,
11
11
  getTEXtChunk
12
12
  };
13
- //# sourceMappingURL=image-X4CDE7NB.js.map
13
+ //# sourceMappingURL=image-JEK4DDYJ.js.map
package/dist/dev/index.js CHANGED
@@ -65,10 +65,10 @@ import {
65
65
  serializeAsJSON,
66
66
  serializeLibraryAsJSON,
67
67
  strokeRectWithRotation_simple
68
- } from "./chunk-4Q2BPT5H.js";
68
+ } from "./chunk-SAWRJ2AG.js";
69
69
  import {
70
70
  define_import_meta_env_default
71
- } from "./chunk-GDIPPJNS.js";
71
+ } from "./chunk-2C5KXBJQ.js";
72
72
  import {
73
73
  en_default
74
74
  } from "./chunk-4JOINNOK.js";
@@ -142,7 +142,8 @@ import {
142
142
  TOUCH_CTX_MENU_TIMEOUT,
143
143
  VERTICAL_ALIGN as VERTICAL_ALIGN5,
144
144
  YOUTUBE_STATES,
145
- ZOOM_STEP as ZOOM_STEP2,
145
+ getInteractiveZoomStep as getInteractiveZoomStep2,
146
+ INITIAL_CANVAS_ZOOM,
146
147
  POINTER_EVENTS,
147
148
  TOOL_TYPE as TOOL_TYPE3,
148
149
  supportsResizeObserver as supportsResizeObserver2,
@@ -7878,6 +7879,8 @@ import {
7878
7879
  MIN_ZOOM,
7879
7880
  THEME as THEME5,
7880
7881
  ZOOM_STEP,
7882
+ getInteractiveZoomStep,
7883
+ getDisplayedZoomValue,
7881
7884
  updateActiveTool as updateActiveTool2,
7882
7885
  CODES as CODES2,
7883
7886
  KEYS as KEYS12
@@ -8140,6 +8143,7 @@ var actionZoomIn = register({
8140
8143
  icon: ZoomInIcon,
8141
8144
  trackEvent: { category: "canvas" },
8142
8145
  perform: (_elements, appState, _, app) => {
8146
+ const displayedZoomValue = getDisplayedZoomValue(appState.zoom.value);
8143
8147
  return {
8144
8148
  appState: {
8145
8149
  ...appState,
@@ -8147,7 +8151,9 @@ var actionZoomIn = register({
8147
8151
  {
8148
8152
  viewportX: appState.width / 2 + appState.offsetLeft,
8149
8153
  viewportY: appState.height / 2 + appState.offsetTop,
8150
- nextZoom: getNormalizedZoom(appState.zoom.value + ZOOM_STEP)
8154
+ nextZoom: getNormalizedZoom(
8155
+ displayedZoomValue + getInteractiveZoomStep(appState.zoom.value, "in")
8156
+ )
8151
8157
  },
8152
8158
  appState
8153
8159
  ),
@@ -8179,6 +8185,7 @@ var actionZoomOut = register({
8179
8185
  viewMode: true,
8180
8186
  trackEvent: { category: "canvas" },
8181
8187
  perform: (_elements, appState, _, app) => {
8188
+ const displayedZoomValue = getDisplayedZoomValue(appState.zoom.value);
8182
8189
  return {
8183
8190
  appState: {
8184
8191
  ...appState,
@@ -8186,7 +8193,9 @@ var actionZoomOut = register({
8186
8193
  {
8187
8194
  viewportX: appState.width / 2 + appState.offsetLeft,
8188
8195
  viewportY: appState.height / 2 + appState.offsetTop,
8189
- nextZoom: getNormalizedZoom(appState.zoom.value - ZOOM_STEP)
8196
+ nextZoom: getNormalizedZoom(
8197
+ displayedZoomValue - getInteractiveZoomStep(appState.zoom.value, "out")
8198
+ )
8190
8199
  },
8191
8200
  appState
8192
8201
  ),
@@ -9630,7 +9639,7 @@ var exportCanvas = async (type, elements, appState, files, {
9630
9639
  let blob = canvasToBlob(tempCanvas);
9631
9640
  if (appState.exportEmbedScene) {
9632
9641
  blob = blob.then(
9633
- (blob2) => import("./data/image-X4CDE7NB.js").then(
9642
+ (blob2) => import("./data/image-JEK4DDYJ.js").then(
9634
9643
  ({ encodePngMetadata: encodePngMetadata2 }) => encodePngMetadata2({
9635
9644
  blob: blob2,
9636
9645
  metadata: serializeAsJSON(elements, appState, files, "local")
@@ -17924,11 +17933,20 @@ var ShapesSwitcher = ({
17924
17933
  var ZoomActions = ({
17925
17934
  renderAction,
17926
17935
  zoom
17927
- }) => /* @__PURE__ */ jsx76(Stack_default.Col, { gap: 1, className: CLASSES5.ZOOM_ACTIONS, children: /* @__PURE__ */ jsxs43(Stack_default.Row, { align: "center", children: [
17928
- renderAction("zoomOut"),
17929
- renderAction("resetZoom"),
17930
- renderAction("zoomIn")
17931
- ] }) });
17936
+ }) => /* @__PURE__ */ jsx76(
17937
+ "div",
17938
+ {
17939
+ className: CLASSES5.ZOOM_ACTIONS,
17940
+ onPointerDown: (event) => event.stopPropagation(),
17941
+ onClick: (event) => event.stopPropagation(),
17942
+ onDoubleClick: (event) => event.stopPropagation(),
17943
+ children: /* @__PURE__ */ jsx76(Stack_default.Col, { gap: 1, children: /* @__PURE__ */ jsxs43(Stack_default.Row, { align: "center", children: [
17944
+ renderAction("zoomOut"),
17945
+ renderAction("resetZoom"),
17946
+ renderAction("zoomIn")
17947
+ ] }) })
17948
+ }
17949
+ );
17932
17950
  var UndoRedoActions = ({
17933
17951
  renderAction,
17934
17952
  className
@@ -28481,7 +28499,7 @@ var TTDDialogInput = ({
28481
28499
  setShowSpinner(true);
28482
28500
  }
28483
28501
  }, SPINNER_DELAY_MS);
28484
- import("./components/TTDDialog/CodeMirrorEditor-R36AGSC4.js").then((mod) => {
28502
+ import("./components/TTDDialog/CodeMirrorEditor-I72JGFZW.js").then((mod) => {
28485
28503
  if (!cancelled) {
28486
28504
  setEditorState({ type: "ready", component: mod.default });
28487
28505
  }
@@ -38128,6 +38146,37 @@ var App = class _App extends React46.Component {
38128
38146
  })
38129
38147
  };
38130
38148
  }
38149
+ const initialZoomValue = getNormalizedZoom(INITIAL_CANVAS_ZOOM);
38150
+ const nonDeletedRestoredElements = restoredElements.filter(
38151
+ (element) => !element.isDeleted
38152
+ );
38153
+ if (nonDeletedRestoredElements.length) {
38154
+ const { appState: fittedAppState } = zoomToFit({
38155
+ targetElements: nonDeletedRestoredElements,
38156
+ appState: {
38157
+ ...restoredAppState,
38158
+ width: this.state.width,
38159
+ height: this.state.height,
38160
+ offsetTop: this.state.offsetTop,
38161
+ offsetLeft: this.state.offsetLeft,
38162
+ zoom: { value: initialZoomValue }
38163
+ },
38164
+ fitToViewport: false,
38165
+ maxZoom: initialZoomValue,
38166
+ canvasOffsets: this.getEditorUIOffsets()
38167
+ });
38168
+ restoredAppState = {
38169
+ ...restoredAppState,
38170
+ scrollX: fittedAppState.scrollX,
38171
+ scrollY: fittedAppState.scrollY,
38172
+ zoom: fittedAppState.zoom
38173
+ };
38174
+ } else {
38175
+ restoredAppState = {
38176
+ ...restoredAppState,
38177
+ zoom: { value: initialZoomValue }
38178
+ };
38179
+ }
38131
38180
  this.resetStore();
38132
38181
  this.resetHistory();
38133
38182
  this.syncActionResult({
@@ -39679,6 +39728,21 @@ var App = class _App extends React46.Component {
39679
39728
  event,
39680
39729
  this.state
39681
39730
  );
39731
+ const hitElement = this.getElementAtPosition(sceneX, sceneY);
39732
+ if (hitElement && (isImageElement9(hitElement) || isFrameLikeElement15(hitElement) || isEmbeddableElement4(hitElement))) {
39733
+ this.scrollToContent(hitElement, {
39734
+ animate: true,
39735
+ duration: 500,
39736
+ fitToViewport: true,
39737
+ viewportZoomFactor: 0.6,
39738
+ minZoom: this.state.zoom.value + getInteractiveZoomStep2(this.state.zoom.value, "in"),
39739
+ canvasOffsets: this.getEditorUIOffsets()
39740
+ });
39741
+ return;
39742
+ }
39743
+ if (hitElement) {
39744
+ return;
39745
+ }
39682
39746
  if (selectedElements.length === 1 && isLinearElement12(selectedElements[0])) {
39683
39747
  const selectedLinearElement = selectedElements[0];
39684
39748
  if ((event[KEYS55.CTRL_OR_CMD] && isSimpleArrow(selectedLinearElement) || isLineElement8(selectedLinearElement)) && (!this.state.selectedLinearElement?.isEditing || this.state.selectedLinearElement.elementId !== selectedLinearElement.id)) {
@@ -39739,25 +39803,11 @@ var App = class _App extends React46.Component {
39739
39803
  return;
39740
39804
  }
39741
39805
  }
39742
- if (selectedElements.length === 1 && isImageElement9(selectedElements[0])) {
39743
- this.startImageCropping(selectedElements[0]);
39744
- return;
39745
- }
39746
- if (selectedElements.length === 1 && isFrameLikeElement15(selectedElements[0])) {
39747
- this.scrollToContent(selectedElements[0], {
39748
- animate: true,
39749
- duration: 500,
39750
- viewportZoomFactor: 0.6,
39751
- fitToViewport: true,
39752
- canvasOffsets: this.getEditorUIOffsets()
39753
- });
39754
- return;
39755
- }
39756
39806
  resetCursor(this.interactiveCanvas);
39757
39807
  const selectedGroupIds = getSelectedGroupIds4(this.state);
39758
39808
  if (selectedGroupIds.length > 0) {
39759
- const hitElement = this.getElementAtPosition(sceneX, sceneY);
39760
- const selectedGroupId = hitElement && getSelectedGroupIdForElement(hitElement, this.state.selectedGroupIds);
39809
+ const hitElement2 = this.getElementAtPosition(sceneX, sceneY);
39810
+ const selectedGroupId = hitElement2 && getSelectedGroupIdForElement(hitElement2, this.state.selectedGroupIds);
39761
39811
  if (selectedGroupId) {
39762
39812
  this.store.scheduleCapture();
39763
39813
  this.setState((prevState) => ({
@@ -39765,7 +39815,7 @@ var App = class _App extends React46.Component {
39765
39815
  ...selectGroupsForSelectedElements7(
39766
39816
  {
39767
39817
  editingGroupId: selectedGroupId,
39768
- selectedElementIds: { [hitElement.id]: true }
39818
+ selectedElementIds: { [hitElement2.id]: true }
39769
39819
  },
39770
39820
  this.scene.getNonDeletedElements(),
39771
39821
  prevState,
@@ -39777,10 +39827,10 @@ var App = class _App extends React46.Component {
39777
39827
  }
39778
39828
  resetCursor(this.interactiveCanvas);
39779
39829
  if (!event[KEYS55.CTRL_OR_CMD] && !this.state.viewModeEnabled) {
39780
- const hitElement = this.getElementAtPosition(sceneX, sceneY);
39781
- if (isIframeLikeElement2(hitElement)) {
39830
+ const hitElement2 = this.getElementAtPosition(sceneX, sceneY);
39831
+ if (isIframeLikeElement2(hitElement2)) {
39782
39832
  this.setState({
39783
- activeEmbeddable: { element: hitElement, state: "active" }
39833
+ activeEmbeddable: { element: hitElement2, state: "active" }
39784
39834
  });
39785
39835
  return;
39786
39836
  }
@@ -42510,7 +42560,10 @@ var App = class _App extends React46.Component {
42510
42560
  const { deltaX, deltaY } = event;
42511
42561
  if (event.metaKey || event.ctrlKey) {
42512
42562
  const sign = Math.sign(deltaY);
42513
- const MAX_STEP = ZOOM_STEP2 * 100;
42563
+ const MAX_STEP = getInteractiveZoomStep2(
42564
+ this.state.zoom.value,
42565
+ sign > 0 ? "out" : "in"
42566
+ ) * 100;
42514
42567
  const absDelta = Math.abs(deltaY);
42515
42568
  let delta = deltaY;
42516
42569
  if (absDelta > MAX_STEP) {