@myoc/excalidraw 0.19.508 → 0.19.509

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/dev/{chunk-TW3GG6X2.js → chunk-6GFAONMV.js} +2 -2
  3. package/dist/dev/{chunk-55P7U5EB.js → chunk-XO7KL57K.js} +2 -1
  4. package/dist/dev/{chunk-55P7U5EB.js.map → chunk-XO7KL57K.js.map} +2 -2
  5. package/dist/dev/{chunk-4FUVQKPQ.js → chunk-Y644LIRZ.js} +3 -3
  6. package/dist/dev/data/{image-BLMJ34ZZ.js → image-BK4K75ZK.js} +3 -3
  7. package/dist/dev/index.css +5 -0
  8. package/dist/dev/index.css.map +2 -2
  9. package/dist/dev/index.js +112 -10
  10. package/dist/dev/index.js.map +3 -3
  11. package/dist/dev/locales/{en-MHJYLCUG.js → en-YKPA7MQG.js} +2 -2
  12. package/dist/dev/subset-shared.chunk.js +1 -1
  13. package/dist/dev/subset-worker.chunk.js +1 -1
  14. package/dist/prod/{chunk-GYDQTBSQ.js → chunk-QTEN3SXT.js} +1 -1
  15. package/dist/prod/{chunk-QIZKYIJ7.js → chunk-SC7IWESZ.js} +2 -2
  16. package/dist/prod/{chunk-5HKPV526.js → chunk-WBVFIETZ.js} +2 -2
  17. package/dist/prod/data/image-AN67VCG3.js +1 -0
  18. package/dist/prod/index.css +1 -1
  19. package/dist/prod/index.js +17 -17
  20. package/dist/prod/locales/{en-YKHOUQAO.js → en-NJXWY54O.js} +1 -1
  21. package/dist/prod/subset-shared.chunk.js +1 -1
  22. package/dist/prod/subset-worker.chunk.js +1 -1
  23. package/dist/types/excalidraw/components/App.d.ts +2 -0
  24. package/dist/types/excalidraw/components/Dialog.d.ts +1 -0
  25. package/dist/types/excalidraw/components/Modal.d.ts +1 -0
  26. package/package.json +4 -4
  27. package/dist/prod/data/image-S4O4TFPQ.js +0 -1
  28. /package/dist/dev/{chunk-TW3GG6X2.js.map → chunk-6GFAONMV.js.map} +0 -0
  29. /package/dist/dev/{chunk-4FUVQKPQ.js.map → chunk-Y644LIRZ.js.map} +0 -0
  30. /package/dist/dev/data/{image-BLMJ34ZZ.js.map → image-BK4K75ZK.js.map} +0 -0
  31. /package/dist/dev/locales/{en-MHJYLCUG.js.map → en-YKPA7MQG.js.map} +0 -0
package/dist/dev/index.js CHANGED
@@ -63,13 +63,13 @@ import {
63
63
  serializeAsJSON,
64
64
  serializeLibraryAsJSON,
65
65
  strokeRectWithRotation_simple
66
- } from "./chunk-4FUVQKPQ.js";
66
+ } from "./chunk-Y644LIRZ.js";
67
67
  import {
68
68
  define_import_meta_env_default
69
- } from "./chunk-TW3GG6X2.js";
69
+ } from "./chunk-6GFAONMV.js";
70
70
  import {
71
71
  en_default
72
- } from "./chunk-55P7U5EB.js";
72
+ } from "./chunk-XO7KL57K.js";
73
73
  import {
74
74
  percentages_default
75
75
  } from "./chunk-URPEKBQ3.js";
@@ -197,7 +197,8 @@ import {
197
197
  loadDesktopUIModePreference,
198
198
  setDesktopUIMode,
199
199
  isSelectionLikeTool,
200
- oneOf
200
+ oneOf,
201
+ matchKey as matchKey3
201
202
  } from "@excalidraw/common";
202
203
  import {
203
204
  getObservedAppState,
@@ -398,7 +399,7 @@ var globImport_locales_json = __glob({
398
399
  "./locales/de-CH.json": () => import("./locales/de-CH-GCXOD4LK.js"),
399
400
  "./locales/de-DE.json": () => import("./locales/de-DE-CGDBECYD.js"),
400
401
  "./locales/el-GR.json": () => import("./locales/el-GR-G5QZC24A.js"),
401
- "./locales/en.json": () => import("./locales/en-MHJYLCUG.js"),
402
+ "./locales/en.json": () => import("./locales/en-YKPA7MQG.js"),
402
403
  "./locales/es-ES.json": () => import("./locales/es-ES-UMEOH76W.js"),
403
404
  "./locales/eu-ES.json": () => import("./locales/eu-ES-IWRZXJC5.js"),
404
405
  "./locales/fa-IR.json": () => import("./locales/fa-IR-QOYVIIJA.js"),
@@ -9625,7 +9626,7 @@ var exportCanvas = async (type, elements, appState, files, {
9625
9626
  let blob = canvasToBlob(tempCanvas);
9626
9627
  if (appState.exportEmbedScene) {
9627
9628
  blob = blob.then(
9628
- (blob2) => import("./data/image-BLMJ34ZZ.js").then(
9629
+ (blob2) => import("./data/image-BK4K75ZK.js").then(
9629
9630
  ({ encodePngMetadata: encodePngMetadata2 }) => encodePngMetadata2({
9630
9631
  blob: blob2,
9631
9632
  metadata: serializeAsJSON(elements, appState, files, "local")
@@ -16753,7 +16754,10 @@ import { jsx as jsx75, jsxs as jsxs40 } from "react/jsx-runtime";
16753
16754
  var Modal = (props) => {
16754
16755
  const { closeOnClickOutside = true } = props;
16755
16756
  const modalRoot = useCreatePortalContainer({
16756
- className: "excalidraw-modal-container"
16757
+ className: clsx32(
16758
+ "excalidraw-modal-container",
16759
+ props.portalContainerClassName
16760
+ )
16757
16761
  });
16758
16762
  const animationsDisabledRef = useRef21(
16759
16763
  document.body.classList.contains("excalidraw-animations-disabled")
@@ -16871,6 +16875,7 @@ var Dialog = (props) => {
16871
16875
  maxWidth: getDialogSize(props.size),
16872
16876
  onCloseRequest: onClose,
16873
16877
  closeOnClickOutside: props.closeOnClickOutside,
16878
+ portalContainerClassName: props.portalContainerClassName,
16874
16879
  children: /* @__PURE__ */ jsxs41(Island, { ref: setIslandNode, children: [
16875
16880
  props.title && /* @__PURE__ */ jsxs41("h2", { id: `${id}-dialog-title`, className: "Dialog__title", children: [
16876
16881
  /* @__PURE__ */ jsx76("span", { className: "Dialog__titleContent", children: props.title }),
@@ -30630,6 +30635,13 @@ function BasicHelpDialog() {
30630
30635
  caption: t("helpDialog.view"),
30631
30636
  children: [
30632
30637
  /* @__PURE__ */ jsx132(Shortcut, { label: t("helpDialog.smartZoom"), shortcuts: [KEYS50.F] }),
30638
+ /* @__PURE__ */ jsx132(
30639
+ Shortcut,
30640
+ {
30641
+ label: t("helpDialog.dragToZoom"),
30642
+ shortcuts: [`${KEYS50.Z}+${t("helpDialog.drag")}`]
30643
+ }
30644
+ ),
30633
30645
  /* @__PURE__ */ jsx132(
30634
30646
  Shortcut,
30635
30647
  {
@@ -30802,6 +30814,7 @@ var HelpDialog = ({ onClose }) => {
30802
30814
  title: t("helpDialog.title"),
30803
30815
  className: "HelpDialog",
30804
30816
  titleButton: showAllButton,
30817
+ portalContainerClassName: "HelpDialog__modalContainer",
30805
30818
  children: isShowAll ? /* @__PURE__ */ jsxs71(Section3, { title: t("helpDialog.shortcuts"), children: [
30806
30819
  /* @__PURE__ */ jsxs71(
30807
30820
  ShortcutIsland2,
@@ -30945,6 +30958,13 @@ var HelpDialog = ({ onClose }) => {
30945
30958
  shortcuts: [KEYS51.F]
30946
30959
  }
30947
30960
  ),
30961
+ /* @__PURE__ */ jsx133(
30962
+ Shortcut2,
30963
+ {
30964
+ label: t("helpDialog.dragToZoom"),
30965
+ shortcuts: [`${KEYS51.Z}+${t("helpDialog.drag")}`]
30966
+ }
30967
+ ),
30948
30968
  /* @__PURE__ */ jsx133(
30949
30969
  Shortcut2,
30950
30970
  {
@@ -32289,6 +32309,14 @@ var LayerUI = ({
32289
32309
  penDetected: appState.penDetected
32290
32310
  }
32291
32311
  ),
32312
+ /* @__PURE__ */ jsx140(
32313
+ HandButton,
32314
+ {
32315
+ checked: isHandToolActive(appState),
32316
+ onChange: onHandToolToggle,
32317
+ title: t("toolBar.hand")
32318
+ }
32319
+ ),
32292
32320
  /* @__PURE__ */ jsx140(
32293
32321
  ShapesSwitcher,
32294
32322
  {
@@ -34922,7 +34950,9 @@ var didTapTwice = false;
34922
34950
  var tappedTwiceTimer = 0;
34923
34951
  var firstTapPosition = null;
34924
34952
  var isHoldingSpace = false;
34953
+ var isHoldingZoomKey = false;
34925
34954
  var isPanning = false;
34955
+ var isZoomingByDragging = false;
34926
34956
  var isDraggingScrollBar = false;
34927
34957
  var currentScrollBars = { horizontal: null, vertical: null };
34928
34958
  var touchTimeout = 0;
@@ -34933,6 +34963,7 @@ var IS_PLAIN_PASTE = false;
34933
34963
  var IS_PLAIN_PASTE_TIMER = 0;
34934
34964
  var PLAIN_PASTE_TOAST_SHOWN = false;
34935
34965
  var lastPointerUp = null;
34966
+ var ZOOM_DRAG_CURSOR = "zoom-in";
34936
34967
  var gesture = {
34937
34968
  pointers: /* @__PURE__ */ new Map(),
34938
34969
  lastCenter: null,
@@ -35488,6 +35519,9 @@ var App = class _App extends React44.Component {
35488
35519
  // Lifecycle
35489
35520
  __publicField(this, "onBlur", withBatchedUpdates(() => {
35490
35521
  isHoldingSpace = false;
35522
+ isHoldingZoomKey = false;
35523
+ isZoomingByDragging = false;
35524
+ this.restoreCursorAfterZoomKey();
35491
35525
  this.setState({
35492
35526
  isBindingEnabled: this.state.bindingPreference === "enabled"
35493
35527
  });
@@ -36511,6 +36545,12 @@ var App = class _App extends React44.Component {
36511
36545
  if (this.actionManager.handleKeyDown(event)) {
36512
36546
  return;
36513
36547
  }
36548
+ if (!event.altKey && !event.shiftKey && !event.ctrlKey && !event.metaKey && matchKey3(event, KEYS52.Z)) {
36549
+ isHoldingZoomKey = true;
36550
+ setCursor(this.interactiveCanvas, ZOOM_DRAG_CURSOR);
36551
+ event.preventDefault();
36552
+ return;
36553
+ }
36514
36554
  const shouldPreventToolSwitching = this.props.viewModeEnabled === true;
36515
36555
  if (!shouldPreventToolSwitching && this.state.viewModeEnabled && event.key === KEYS52.ESCAPE) {
36516
36556
  this.setActiveTool({ type: "selection" });
@@ -36711,6 +36751,10 @@ var App = class _App extends React44.Component {
36711
36751
  }
36712
36752
  isHoldingSpace = false;
36713
36753
  }
36754
+ if (matchKey3(event, KEYS52.Z)) {
36755
+ isHoldingZoomKey = false;
36756
+ this.restoreCursorAfterZoomKey();
36757
+ }
36714
36758
  if (event.key === KEYS52.ALT) {
36715
36759
  maybeHandleArrowPointlikeDrag({ app: this, event });
36716
36760
  }
@@ -37535,7 +37579,7 @@ var App = class _App extends React44.Component {
37535
37579
  } else {
37536
37580
  gesture.lastCenter = gesture.initialDistance = gesture.initialScale = null;
37537
37581
  }
37538
- if (isHoldingSpace || isPanning || isDraggingScrollBar || isHandToolActive(this.state)) {
37582
+ if (isHoldingSpace || isHoldingZoomKey || isPanning || isZoomingByDragging || isDraggingScrollBar || isHandToolActive(this.state)) {
37539
37583
  return;
37540
37584
  }
37541
37585
  const isPointerOverScrollBars = isOverScrollBars(
@@ -38069,11 +38113,11 @@ var App = class _App extends React44.Component {
38069
38113
  isTouchScreen: true
38070
38114
  });
38071
38115
  }
38072
- if (isPanning) {
38116
+ if (isPanning || isZoomingByDragging) {
38073
38117
  return;
38074
38118
  }
38075
38119
  this.lastPointerDownEvent = event;
38076
- if (this.handleCanvasPanUsingWheelOrSpaceDrag(event)) {
38120
+ if (this.handleCanvasZoomUsingZDrag(event) || this.handleCanvasPanUsingWheelOrSpaceDrag(event)) {
38077
38121
  return;
38078
38122
  }
38079
38123
  this.setState({
@@ -38363,6 +38407,64 @@ var App = class _App extends React44.Component {
38363
38407
  lastPointerUp?.();
38364
38408
  this.missingPointerEventCleanupEmitter.trigger(event).clear();
38365
38409
  });
38410
+ __publicField(this, "handleCanvasZoomUsingZDrag", (event) => {
38411
+ if (!(isHoldingZoomKey && gesture.pointers.size <= 1 && event.button === POINTER_BUTTON2.MAIN && event.pointerType === "mouse")) {
38412
+ return false;
38413
+ }
38414
+ isZoomingByDragging = true;
38415
+ this.focusContainer();
38416
+ event.preventDefault();
38417
+ const anchorClientX = event.clientX;
38418
+ const anchorClientY = event.clientY;
38419
+ const startClientX = event.clientX;
38420
+ const startZoom = this.state.zoom.value;
38421
+ const PIXELS_PER_ZOOM_DOUBLING = 200;
38422
+ const onPointerMove = withBatchedUpdatesThrottled((event2) => {
38423
+ const nextZoom = getNormalizedZoom(
38424
+ startZoom * 2 ** ((event2.clientX - startClientX) / PIXELS_PER_ZOOM_DOUBLING)
38425
+ );
38426
+ this.translateCanvas((state) => ({
38427
+ ...getStateForZoom(
38428
+ {
38429
+ viewportX: anchorClientX,
38430
+ viewportY: anchorClientY,
38431
+ nextZoom
38432
+ },
38433
+ state
38434
+ ),
38435
+ shouldCacheIgnoreZoom: true
38436
+ }));
38437
+ this.resetShouldCacheIgnoreZoomDebounced();
38438
+ });
38439
+ const teardown = withBatchedUpdates(
38440
+ lastPointerUp = () => {
38441
+ lastPointerUp = null;
38442
+ isZoomingByDragging = false;
38443
+ if (!isHoldingZoomKey) {
38444
+ this.restoreCursorAfterZoomKey();
38445
+ }
38446
+ window.removeEventListener(EVENT13.POINTER_MOVE, onPointerMove);
38447
+ window.removeEventListener(EVENT13.POINTER_UP, teardown);
38448
+ window.removeEventListener(EVENT13.BLUR, teardown);
38449
+ onPointerMove.flush();
38450
+ }
38451
+ );
38452
+ window.addEventListener(EVENT13.BLUR, teardown);
38453
+ window.addEventListener(EVENT13.POINTER_MOVE, onPointerMove, {
38454
+ passive: true
38455
+ });
38456
+ window.addEventListener(EVENT13.POINTER_UP, teardown);
38457
+ return true;
38458
+ });
38459
+ __publicField(this, "restoreCursorAfterZoomKey", () => {
38460
+ if (this.state.viewModeEnabled && this.state.activeTool.type !== "laser") {
38461
+ setCursor(this.interactiveCanvas, CURSOR_TYPE4.GRAB);
38462
+ } else if (isSelectionLikeTool(this.state.activeTool.type)) {
38463
+ resetCursor(this.interactiveCanvas);
38464
+ } else {
38465
+ setCursorForShape(this.interactiveCanvas, this.state);
38466
+ }
38467
+ });
38366
38468
  // Returns whether the event is a panning
38367
38469
  __publicField(this, "handleCanvasPanUsingWheelOrSpaceDrag", (event) => {
38368
38470
  if (!(gesture.pointers.size <= 1 && (event.button === POINTER_BUTTON2.WHEEL || event.button === POINTER_BUTTON2.MAIN && isHoldingSpace || isHandToolActive(this.state) || this.state.viewModeEnabled && this.state.activeTool.type !== "laser"))) {