@myoc/excalidraw 0.19.526 → 0.19.528

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
@@ -44,6 +44,7 @@ import {
44
44
  isImageFileHandle,
45
45
  isImageFileHandleType,
46
46
  isPointHittingLink,
47
+ isPointHittingLinkIcon,
47
48
  isSomeElementSelected,
48
49
  isSupportedImageFile,
49
50
  isSupportedImageFileType,
@@ -61,10 +62,10 @@ import {
61
62
  serializeAsJSON,
62
63
  strokeRectWithRotation_simple,
63
64
  zoomToFitBounds
64
- } from "./chunk-UKYYHFTM.js";
65
+ } from "./chunk-NY5S5VQK.js";
65
66
  import {
66
67
  define_import_meta_env_default
67
- } from "./chunk-WQAS3ONQ.js";
68
+ } from "./chunk-6FFT5HLH.js";
68
69
  import {
69
70
  en_default
70
71
  } from "./chunk-SKCAT7JG.js";
@@ -317,7 +318,7 @@ import {
317
318
  getDragOffsetXY,
318
319
  Scene as Scene2,
319
320
  Store,
320
- CaptureUpdateAction as CaptureUpdateAction40,
321
+ CaptureUpdateAction as CaptureUpdateAction39,
321
322
  hitElementBoundingBox as hitElementBoundingBox2,
322
323
  isLineElement as isLineElement9,
323
324
  isSimpleArrow,
@@ -10935,7 +10936,7 @@ var exportCanvas = async (type, elements, appState, files, {
10935
10936
  let blob = canvasToBlob(tempCanvas);
10936
10937
  if (appState.exportEmbedScene) {
10937
10938
  blob = blob.then(
10938
- (blob2) => import("./data/image-ILRWTLER.js").then(
10939
+ (blob2) => import("./data/image-V7WKCORB.js").then(
10939
10940
  ({ encodePngMetadata: encodePngMetadata2 }) => encodePngMetadata2({
10940
10941
  blob: blob2,
10941
10942
  metadata: serializeAsJSON(elements, appState, files, "local")
@@ -16295,94 +16296,6 @@ var actionToggleCropEditor = register({
16295
16296
  }
16296
16297
  });
16297
16298
 
16298
- // actions/actionElementLink.ts
16299
- import {
16300
- canCreateLinkFromElements,
16301
- defaultGetElementLinkFromSelection,
16302
- getLinkIdAndTypeFromSelection
16303
- } from "@excalidraw/element";
16304
- import { CaptureUpdateAction as CaptureUpdateAction32 } from "@excalidraw/element";
16305
- var actionCopyElementLink = register({
16306
- name: "copyElementLink",
16307
- label: "labels.copyElementLink",
16308
- icon: copyIcon,
16309
- trackEvent: { category: "element" },
16310
- perform: async (elements, appState, _, app) => {
16311
- const selectedElements = getSelectedElements(elements, appState);
16312
- try {
16313
- if (window.location) {
16314
- const idAndType = getLinkIdAndTypeFromSelection(
16315
- selectedElements,
16316
- appState
16317
- );
16318
- if (idAndType) {
16319
- await copyTextToSystemClipboard(
16320
- app.props.generateLinkForSelection ? app.props.generateLinkForSelection(idAndType.id, idAndType.type) : defaultGetElementLinkFromSelection(
16321
- idAndType.id,
16322
- idAndType.type
16323
- )
16324
- );
16325
- return {
16326
- appState: {
16327
- toast: {
16328
- message: t("toast.elementLinkCopied"),
16329
- closable: true
16330
- }
16331
- },
16332
- captureUpdate: CaptureUpdateAction32.EVENTUALLY
16333
- };
16334
- }
16335
- return {
16336
- appState,
16337
- elements,
16338
- app,
16339
- captureUpdate: CaptureUpdateAction32.EVENTUALLY
16340
- };
16341
- }
16342
- } catch (error) {
16343
- console.error(error);
16344
- }
16345
- return {
16346
- appState,
16347
- elements,
16348
- app,
16349
- captureUpdate: CaptureUpdateAction32.EVENTUALLY
16350
- };
16351
- },
16352
- predicate: (elements, appState) => canCreateLinkFromElements(getSelectedElements(elements, appState))
16353
- });
16354
- var actionLinkToElement = register({
16355
- name: "linkToElement",
16356
- label: "labels.linkToElement",
16357
- icon: elementLinkIcon,
16358
- perform: (elements, appState, _, app) => {
16359
- const selectedElements = getSelectedElements(elements, appState);
16360
- if (selectedElements.length !== 1 || !canCreateLinkFromElements(selectedElements)) {
16361
- return {
16362
- elements,
16363
- appState,
16364
- app,
16365
- captureUpdate: CaptureUpdateAction32.EVENTUALLY
16366
- };
16367
- }
16368
- return {
16369
- appState: {
16370
- ...appState,
16371
- openDialog: {
16372
- name: "elementLinkSelector",
16373
- sourceElementId: getSelectedElements(elements, appState)[0].id
16374
- }
16375
- },
16376
- captureUpdate: CaptureUpdateAction32.IMMEDIATELY
16377
- };
16378
- },
16379
- predicate: (elements, appState, appProps, app) => {
16380
- const selectedElements = getSelectedElements(elements, appState);
16381
- return appState.openDialog?.name !== "elementLinkSelector" && selectedElements.length === 1 && canCreateLinkFromElements(selectedElements);
16382
- },
16383
- trackEvent: false
16384
- });
16385
-
16386
16299
  // actions/actionFrame.ts
16387
16300
  import { getNonDeletedElements as getNonDeletedElements14 } from "@excalidraw/element";
16388
16301
  import { mutateElement as mutateElement4 } from "@excalidraw/element";
@@ -16395,7 +16308,7 @@ import {
16395
16308
  import { getFrameChildren as getFrameChildren3 } from "@excalidraw/element";
16396
16309
  import { getElementsInGroup as getElementsInGroup6 } from "@excalidraw/element";
16397
16310
  import { getCommonBounds as getCommonBounds3 } from "@excalidraw/element";
16398
- import { CaptureUpdateAction as CaptureUpdateAction33 } from "@excalidraw/element";
16311
+ import { CaptureUpdateAction as CaptureUpdateAction32 } from "@excalidraw/element";
16399
16312
  var isSingleFrameSelected = (appState, app) => {
16400
16313
  const selectedElements = app.scene.getSelectedElements(appState);
16401
16314
  return selectedElements.length === 1 && isFrameLikeElement9(selectedElements[0]);
@@ -16420,13 +16333,13 @@ var actionSelectAllElementsInFrame = register({
16420
16333
  return acc;
16421
16334
  }, {})
16422
16335
  },
16423
- captureUpdate: CaptureUpdateAction33.IMMEDIATELY
16336
+ captureUpdate: CaptureUpdateAction32.IMMEDIATELY
16424
16337
  };
16425
16338
  }
16426
16339
  return {
16427
16340
  elements,
16428
16341
  appState,
16429
- captureUpdate: CaptureUpdateAction33.EVENTUALLY
16342
+ captureUpdate: CaptureUpdateAction32.EVENTUALLY
16430
16343
  };
16431
16344
  },
16432
16345
  predicate: (elements, appState, _, app) => isSingleFrameSelected(appState, app)
@@ -16446,13 +16359,13 @@ var actionRemoveAllElementsFromFrame = register({
16446
16359
  [selectedElement.id]: true
16447
16360
  }
16448
16361
  },
16449
- captureUpdate: CaptureUpdateAction33.IMMEDIATELY
16362
+ captureUpdate: CaptureUpdateAction32.IMMEDIATELY
16450
16363
  };
16451
16364
  }
16452
16365
  return {
16453
16366
  elements,
16454
16367
  appState,
16455
- captureUpdate: CaptureUpdateAction33.EVENTUALLY
16368
+ captureUpdate: CaptureUpdateAction32.EVENTUALLY
16456
16369
  };
16457
16370
  },
16458
16371
  predicate: (elements, appState, _, app) => isSingleFrameSelected(appState, app)
@@ -16472,7 +16385,7 @@ var actionupdateFrameRendering = register({
16472
16385
  enabled: !appState.frameRendering.enabled
16473
16386
  }
16474
16387
  },
16475
- captureUpdate: CaptureUpdateAction33.EVENTUALLY
16388
+ captureUpdate: CaptureUpdateAction32.EVENTUALLY
16476
16389
  };
16477
16390
  },
16478
16391
  checked: (appState) => appState.frameRendering.enabled
@@ -16518,7 +16431,7 @@ var actionWrapSelectionInFrame = register({
16518
16431
  appState: {
16519
16432
  selectedElementIds: { [frame.id]: true }
16520
16433
  },
16521
- captureUpdate: CaptureUpdateAction33.IMMEDIATELY
16434
+ captureUpdate: CaptureUpdateAction32.IMMEDIATELY
16522
16435
  };
16523
16436
  }
16524
16437
  });
@@ -16530,13 +16443,13 @@ import {
16530
16443
  arrayToMap as arrayToMap28,
16531
16444
  MOBILE_ACTION_BUTTON_BG as MOBILE_ACTION_BUTTON_BG4
16532
16445
  } from "@excalidraw/common";
16533
- import { CaptureUpdateAction as CaptureUpdateAction35 } from "@excalidraw/element";
16446
+ import { CaptureUpdateAction as CaptureUpdateAction34 } from "@excalidraw/element";
16534
16447
  import { orderByFractionalIndex as orderByFractionalIndex2 } from "@excalidraw/element";
16535
16448
 
16536
16449
  // history.ts
16537
16450
  import { Emitter as Emitter2 } from "@excalidraw/common";
16538
16451
  import {
16539
- CaptureUpdateAction as CaptureUpdateAction34,
16452
+ CaptureUpdateAction as CaptureUpdateAction33,
16540
16453
  StoreChange,
16541
16454
  StoreDelta
16542
16455
  } from "@excalidraw/element";
@@ -16650,7 +16563,7 @@ var History = class _History {
16650
16563
  if (historyDelta === null) {
16651
16564
  return;
16652
16565
  }
16653
- const action = CaptureUpdateAction34.IMMEDIATELY;
16566
+ const action = CaptureUpdateAction33.IMMEDIATELY;
16654
16567
  let prevSnapshot = this.store.snapshot;
16655
16568
  let nextElements = elements;
16656
16569
  let nextAppState = appState;
@@ -16734,7 +16647,7 @@ var executeHistoryAction = (app, appState, updater) => {
16734
16647
  !app.drawShape.hasPendingGesture()) {
16735
16648
  const result = updater();
16736
16649
  if (!result) {
16737
- return { captureUpdate: CaptureUpdateAction35.EVENTUALLY };
16650
+ return { captureUpdate: CaptureUpdateAction34.EVENTUALLY };
16738
16651
  }
16739
16652
  const [nextElementsMap, nextAppState] = result;
16740
16653
  const nextElements = orderByFractionalIndex2(
@@ -16743,10 +16656,10 @@ var executeHistoryAction = (app, appState, updater) => {
16743
16656
  return {
16744
16657
  appState: nextAppState,
16745
16658
  elements: nextElements,
16746
- captureUpdate: CaptureUpdateAction35.NEVER
16659
+ captureUpdate: CaptureUpdateAction34.NEVER
16747
16660
  };
16748
16661
  }
16749
- return { captureUpdate: CaptureUpdateAction35.EVENTUALLY };
16662
+ return { captureUpdate: CaptureUpdateAction34.EVENTUALLY };
16750
16663
  };
16751
16664
  var createUndoAction = (history) => ({
16752
16665
  name: "undo",
@@ -16836,7 +16749,7 @@ import {
16836
16749
  } from "@excalidraw/element";
16837
16750
  import { measureText as measureText3 } from "@excalidraw/element";
16838
16751
  import { isTextElement as isTextElement7 } from "@excalidraw/element";
16839
- import { CaptureUpdateAction as CaptureUpdateAction36 } from "@excalidraw/element";
16752
+ import { CaptureUpdateAction as CaptureUpdateAction35 } from "@excalidraw/element";
16840
16753
  var actionTextAutoResize = register({
16841
16754
  name: "autoResize",
16842
16755
  label: "labels.autoResize",
@@ -16879,7 +16792,7 @@ var actionTextAutoResize = register({
16879
16792
  elements: elements.map(
16880
16793
  (element) => element.id === resized.id ? resized : element
16881
16794
  ),
16882
- captureUpdate: CaptureUpdateAction36.IMMEDIATELY
16795
+ captureUpdate: CaptureUpdateAction35.IMMEDIATELY
16883
16796
  };
16884
16797
  }
16885
16798
  });
@@ -16887,7 +16800,7 @@ var actionTextAutoResize = register({
16887
16800
  // actions/actionToggleViewMode.tsx
16888
16801
  import { CODES as CODES9, KEYS as KEYS36 } from "@excalidraw/common";
16889
16802
  import clsx23 from "clsx";
16890
- import { CaptureUpdateAction as CaptureUpdateAction37 } from "@excalidraw/element";
16803
+ import { CaptureUpdateAction as CaptureUpdateAction36 } from "@excalidraw/element";
16891
16804
  import { jsx as jsx58 } from "react/jsx-runtime";
16892
16805
  var actionToggleViewMode = register({
16893
16806
  name: "viewMode",
@@ -16907,7 +16820,7 @@ var actionToggleViewMode = register({
16907
16820
  ...appState,
16908
16821
  viewModeEnabled: !this.checked(appState)
16909
16822
  },
16910
- captureUpdate: CaptureUpdateAction37.EVENTUALLY
16823
+ captureUpdate: CaptureUpdateAction36.EVENTUALLY
16911
16824
  };
16912
16825
  },
16913
16826
  checked: (appState) => appState.viewModeEnabled,
@@ -24373,7 +24286,7 @@ var AppDrawShape = class {
24373
24286
  import { isArrowKey as isArrowKey2, KEYS as KEYS39 } from "@excalidraw/common";
24374
24287
  import {
24375
24288
  makeNextSelectedElementIds as makeNextSelectedElementIds3,
24376
- CaptureUpdateAction as CaptureUpdateAction38,
24289
+ CaptureUpdateAction as CaptureUpdateAction37,
24377
24290
  FlowChartCreator,
24378
24291
  FlowChartNavigator,
24379
24292
  getSelectedElements as getSelectedElements6,
@@ -24497,7 +24410,7 @@ var AppFlowchart = class _AppFlowchart {
24497
24410
  }
24498
24411
  captureUpdate() {
24499
24412
  this.app.syncActionResult({
24500
- captureUpdate: CaptureUpdateAction38.IMMEDIATELY
24413
+ captureUpdate: CaptureUpdateAction37.IMMEDIATELY
24501
24414
  });
24502
24415
  }
24503
24416
  static getLinkDirectionFromKey(key) {
@@ -28842,7 +28755,7 @@ import clsx43 from "clsx";
28842
28755
  import { useEffect as useEffect28, useRef as useRef22, useState as useState24 } from "react";
28843
28756
  import { EVENT as EVENT7, KEYS as KEYS45, cloneJSON as cloneJSON3 } from "@excalidraw/common";
28844
28757
  import { deepCopyElement as deepCopyElement4 } from "@excalidraw/element";
28845
- import { CaptureUpdateAction as CaptureUpdateAction39 } from "@excalidraw/element";
28758
+ import { CaptureUpdateAction as CaptureUpdateAction38 } from "@excalidraw/element";
28846
28759
 
28847
28760
  // components/Stats/utils.ts
28848
28761
  import { pointFrom as pointFrom40, pointRotateRads as pointRotateRads22 } from "@excalidraw/math";
@@ -29053,7 +28966,7 @@ var StatsDragInput = ({
29053
28966
  setAppState
29054
28967
  });
29055
28968
  app.syncActionResult({
29056
- captureUpdate: CaptureUpdateAction39.IMMEDIATELY
28969
+ captureUpdate: CaptureUpdateAction38.IMMEDIATELY
29057
28970
  });
29058
28971
  }
29059
28972
  };
@@ -29161,7 +29074,7 @@ var StatsDragInput = ({
29161
29074
  false
29162
29075
  );
29163
29076
  app.syncActionResult({
29164
- captureUpdate: CaptureUpdateAction39.IMMEDIATELY
29077
+ captureUpdate: CaptureUpdateAction38.IMMEDIATELY
29165
29078
  });
29166
29079
  dragFinishedCallback?.({
29167
29080
  app,
@@ -31064,8 +30977,8 @@ var StatsInner = memo2(
31064
30977
  import { useCallback as useCallback10, useEffect as useEffect30, useState as useState27 } from "react";
31065
30978
  import { normalizeLink as normalizeLink3, KEYS as KEYS46 } from "@excalidraw/common";
31066
30979
  import {
31067
- defaultGetElementLinkFromSelection as defaultGetElementLinkFromSelection2,
31068
- getLinkIdAndTypeFromSelection as getLinkIdAndTypeFromSelection2
30980
+ defaultGetElementLinkFromSelection,
30981
+ getLinkIdAndTypeFromSelection
31069
30982
  } from "@excalidraw/element";
31070
30983
 
31071
30984
  // components/DialogActionButton.tsx
@@ -31222,7 +31135,7 @@ var ElementLinkDialog = ({
31222
31135
  onClose,
31223
31136
  appState,
31224
31137
  scene,
31225
- generateLinkForSelection = defaultGetElementLinkFromSelection2
31138
+ generateLinkForSelection = defaultGetElementLinkFromSelection
31226
31139
  }) => {
31227
31140
  const elementsMap = scene.getNonDeletedElementsMap();
31228
31141
  const originalLink = elementsMap.get(sourceElementId)?.link ?? null;
@@ -31232,7 +31145,7 @@ var ElementLinkDialog = ({
31232
31145
  const selectedElements = getSelectedElements(elementsMap, appState);
31233
31146
  let nextLink2 = originalLink;
31234
31147
  if (selectedElements.length > 0 && generateLinkForSelection) {
31235
- const idAndType = getLinkIdAndTypeFromSelection2(
31148
+ const idAndType = getLinkIdAndTypeFromSelection(
31236
31149
  selectedElements,
31237
31150
  appState
31238
31151
  );
@@ -36080,12 +35993,12 @@ var App = class _App extends React40.Component {
36080
35993
  if (shouldUpdateStrokeColor) {
36081
35994
  this.syncActionResult({
36082
35995
  appState: { ...this.state, currentItemStrokeColor: color },
36083
- captureUpdate: CaptureUpdateAction40.IMMEDIATELY
35996
+ captureUpdate: CaptureUpdateAction39.IMMEDIATELY
36084
35997
  });
36085
35998
  } else {
36086
35999
  this.syncActionResult({
36087
36000
  appState: { ...this.state, currentItemBackgroundColor: color },
36088
- captureUpdate: CaptureUpdateAction40.IMMEDIATELY
36001
+ captureUpdate: CaptureUpdateAction39.IMMEDIATELY
36089
36002
  });
36090
36003
  }
36091
36004
  } else {
@@ -36098,7 +36011,7 @@ var App = class _App extends React40.Component {
36098
36011
  }
36099
36012
  return el;
36100
36013
  }),
36101
- captureUpdate: CaptureUpdateAction40.IMMEDIATELY
36014
+ captureUpdate: CaptureUpdateAction39.IMMEDIATELY
36102
36015
  });
36103
36016
  }
36104
36017
  },
@@ -36516,7 +36429,7 @@ var App = class _App extends React40.Component {
36516
36429
  elements: restoredElements,
36517
36430
  appState: restoredAppState,
36518
36431
  files: initialData?.files,
36519
- captureUpdate: CaptureUpdateAction40.NEVER
36432
+ captureUpdate: CaptureUpdateAction39.NEVER
36520
36433
  });
36521
36434
  this.clearImageShapeCache();
36522
36435
  this.fonts.loadSceneFonts().then((fontFaces) => {
@@ -37117,11 +37030,9 @@ var App = class _App extends React40.Component {
37117
37030
  });
37118
37031
  __publicField(this, "setDownloadError", (fileId, error) => {
37119
37032
  this.updateImageStatus(fileId, (previous) => {
37120
- const uploadProgress = error === null && previous?.uploadProgress?.state === "error" ? null : previous?.uploadProgress;
37121
37033
  return {
37122
37034
  ...previous,
37123
- downloadError: error === true ? {} : error || null,
37124
- uploadProgress
37035
+ downloadError: error === true ? {} : error || null
37125
37036
  };
37126
37037
  });
37127
37038
  });
@@ -38316,7 +38227,31 @@ var App = class _App extends React40.Component {
38316
38227
  }
38317
38228
  }
38318
38229
  });
38230
+ __publicField(this, "getElementLinkAtPositionForContextMenu", (scenePointer, hitElementMightBeLocked) => {
38231
+ const linkElement = this.getElementLinkAtPosition(
38232
+ scenePointer,
38233
+ hitElementMightBeLocked
38234
+ );
38235
+ if (linkElement) {
38236
+ return linkElement;
38237
+ }
38238
+ const elementsMap = this.scene.getNonDeletedElementsMap();
38239
+ for (const element of this.scene.getNonDeletedElements().slice().reverse()) {
38240
+ if (element.link && !element.locked && isPointHittingLinkIcon(
38241
+ element,
38242
+ elementsMap,
38243
+ this.state,
38244
+ pointFrom44(scenePointer.x, scenePointer.y)
38245
+ )) {
38246
+ return element;
38247
+ }
38248
+ }
38249
+ });
38319
38250
  __publicField(this, "handleElementLinkClick", (event) => {
38251
+ const isActivationButton = (button) => button === POINTER_BUTTON2.MAIN || button === POINTER_BUTTON2.TOUCH;
38252
+ if (!isActivationButton(this.lastPointerDownEvent.button) || !isActivationButton(this.lastPointerUpEvent.button)) {
38253
+ return;
38254
+ }
38320
38255
  const draggedDistance = pointDistance11(
38321
38256
  pointFrom44(
38322
38257
  this.lastPointerDownEvent.clientX,
@@ -38355,28 +38290,32 @@ var App = class _App extends React40.Component {
38355
38290
  );
38356
38291
  if (lastPointerDownHittingLinkIcon && lastPointerUpHittingLinkIcon) {
38357
38292
  hideHyperlinkToolip();
38358
- let url = this.hitLinkElement.link;
38359
- if (url) {
38360
- url = normalizeLink4(url);
38361
- let customEvent;
38362
- if (this.props.onLinkOpen) {
38363
- customEvent = wrapEvent2(EVENT11.EXCALIDRAW_LINK, event.nativeEvent);
38364
- this.props.onLinkOpen(
38365
- {
38366
- ...this.hitLinkElement,
38367
- link: url
38368
- },
38369
- customEvent
38370
- );
38371
- }
38372
- if (!customEvent?.defaultPrevented) {
38373
- const target = isLocalLink2(url) ? "_self" : "_blank";
38374
- const newWindow = window.open(void 0, target);
38375
- if (newWindow) {
38376
- newWindow.opener = null;
38377
- newWindow.location = url;
38378
- }
38379
- }
38293
+ this.openElementLink(this.hitLinkElement, event);
38294
+ }
38295
+ });
38296
+ __publicField(this, "openElementLink", (element, event) => {
38297
+ let url = element.link;
38298
+ if (!url) {
38299
+ return;
38300
+ }
38301
+ url = normalizeLink4(url);
38302
+ let customEvent;
38303
+ if (this.props.onLinkOpen && event) {
38304
+ customEvent = wrapEvent2(EVENT11.EXCALIDRAW_LINK, event.nativeEvent);
38305
+ this.props.onLinkOpen(
38306
+ {
38307
+ ...element,
38308
+ link: url
38309
+ },
38310
+ customEvent
38311
+ );
38312
+ }
38313
+ if (!customEvent?.defaultPrevented) {
38314
+ const target = isLocalLink2(url) ? "_self" : "_blank";
38315
+ const newWindow = window.open(void 0, target);
38316
+ if (newWindow) {
38317
+ newWindow.opener = null;
38318
+ newWindow.location = url;
38380
38319
  }
38381
38320
  }
38382
38321
  });
@@ -39096,7 +39035,7 @@ var App = class _App extends React40.Component {
39096
39035
  this.state
39097
39036
  )
39098
39037
  },
39099
- captureUpdate: this.state.openDialog?.name === "elementLinkSelector" ? CaptureUpdateAction40.EVENTUALLY : CaptureUpdateAction40.NEVER
39038
+ captureUpdate: this.state.openDialog?.name === "elementLinkSelector" ? CaptureUpdateAction39.EVENTUALLY : CaptureUpdateAction39.NEVER
39100
39039
  });
39101
39040
  return;
39102
39041
  }
@@ -40633,7 +40572,7 @@ var App = class _App extends React40.Component {
40633
40572
  });
40634
40573
  }
40635
40574
  if (erroredFiles.size || updatedFiles.size) {
40636
- this.store.scheduleAction(CaptureUpdateAction40.NEVER);
40575
+ this.store.scheduleAction(CaptureUpdateAction39.NEVER);
40637
40576
  this.scene.replaceAllElements(
40638
40577
  this.scene.getElementsIncludingDeleted().map((element) => {
40639
40578
  if (isInitializedImageElement3(element)) {
@@ -40753,7 +40692,7 @@ var App = class _App extends React40.Component {
40753
40692
  )
40754
40693
  },
40755
40694
  elements: nextElements,
40756
- captureUpdate: CaptureUpdateAction40.IMMEDIATELY
40695
+ captureUpdate: CaptureUpdateAction39.IMMEDIATELY
40757
40696
  });
40758
40697
  this.setState({}, () => {
40759
40698
  this.actionManager.executeAction(actionFinalize);
@@ -40787,7 +40726,7 @@ var App = class _App extends React40.Component {
40787
40726
  isLoading: false
40788
40727
  },
40789
40728
  replaceFiles: true,
40790
- captureUpdate: CaptureUpdateAction40.IMMEDIATELY
40729
+ captureUpdate: CaptureUpdateAction39.IMMEDIATELY
40791
40730
  });
40792
40731
  return;
40793
40732
  } catch (error) {
@@ -40860,7 +40799,7 @@ var App = class _App extends React40.Component {
40860
40799
  {
40861
40800
  syncInvalidIndices3(elements.concat(ret.elements));
40862
40801
  this.store.scheduleMicroAction({
40863
- action: CaptureUpdateAction40.NEVER,
40802
+ action: CaptureUpdateAction39.NEVER,
40864
40803
  elements,
40865
40804
  appState: void 0
40866
40805
  });
@@ -40873,7 +40812,7 @@ var App = class _App extends React40.Component {
40873
40812
  isLoading: false
40874
40813
  },
40875
40814
  replaceFiles: true,
40876
- captureUpdate: CaptureUpdateAction40.IMMEDIATELY
40815
+ captureUpdate: CaptureUpdateAction39.IMMEDIATELY
40877
40816
  });
40878
40817
  }
40879
40818
  } catch (error) {
@@ -40895,12 +40834,15 @@ var App = class _App extends React40.Component {
40895
40834
  preferSelected: true,
40896
40835
  includeLockedElements: true
40897
40836
  });
40837
+ const linkElement = this.isLinksEnabled() ? this.getElementLinkAtPositionForContextMenu({ x, y }, element) : void 0;
40898
40838
  const selectedElements = this.scene.getSelectedElements(this.state);
40899
40839
  const isHittingCommonBoundBox = this.isHittingCommonBoundingBoxOfSelectedElements(
40900
40840
  { x, y },
40901
40841
  selectedElements
40902
40842
  );
40903
- const type = element || isHittingCommonBoundBox ? "element" : "canvas";
40843
+ const selectedLinkedElement = isHittingCommonBoundBox && selectedElements.length === 1 && selectedElements[0].link ? selectedElements[0] : void 0;
40844
+ const contextMenuElement = element ?? linkElement ?? selectedLinkedElement;
40845
+ const type = contextMenuElement || isHittingCommonBoundBox ? "element" : "canvas";
40904
40846
  const container = this.excalidrawContainerRef.current;
40905
40847
  const { top: offsetTop, left: offsetLeft } = container.getBoundingClientRect();
40906
40848
  const left = event.clientX - offsetLeft;
@@ -40908,19 +40850,19 @@ var App = class _App extends React40.Component {
40908
40850
  trackEvent("contextMenu", "openContextMenu", type);
40909
40851
  this.setState(
40910
40852
  {
40911
- ...element && !this.state.selectedElementIds[element.id] ? {
40853
+ ...contextMenuElement && !this.state.selectedElementIds[contextMenuElement.id] ? {
40912
40854
  ...this.state,
40913
40855
  ...selectGroupsForSelectedElements7(
40914
40856
  {
40915
40857
  editingGroupId: this.state.editingGroupId,
40916
- selectedElementIds: { [element.id]: true }
40858
+ selectedElementIds: { [contextMenuElement.id]: true }
40917
40859
  },
40918
40860
  this.scene.getNonDeletedElements(),
40919
40861
  this.state,
40920
40862
  this
40921
40863
  ),
40922
- selectedLinearElement: isLinearElement11(element) ? new LinearElementEditor12(
40923
- element,
40864
+ selectedLinearElement: isLinearElement11(contextMenuElement) ? new LinearElementEditor12(
40865
+ contextMenuElement,
40924
40866
  this.scene.getNonDeletedElementsMap()
40925
40867
  ) : null
40926
40868
  } : this.state,
@@ -40931,7 +40873,7 @@ var App = class _App extends React40.Component {
40931
40873
  contextMenu: {
40932
40874
  top,
40933
40875
  left,
40934
- items: this.getContextMenuItems(type, element)
40876
+ items: this.getContextMenuItems(type, contextMenuElement)
40935
40877
  }
40936
40878
  });
40937
40879
  }
@@ -41201,8 +41143,36 @@ var App = class _App extends React40.Component {
41201
41143
  }
41202
41144
  return [];
41203
41145
  });
41146
+ __publicField(this, "getElementLinkContextMenuItems", (hitElement) => {
41147
+ if (!hitElement?.link) {
41148
+ return [];
41149
+ }
41150
+ const link = normalizeLink4(hitElement.link);
41151
+ const isObjectLink = isElementLink3(link);
41152
+ return [
41153
+ {
41154
+ key: "goToLink",
41155
+ label: isObjectLink ? t("labels.link.goToElement") : "Go to link",
41156
+ onSelect: () => this.openElementLink(hitElement)
41157
+ },
41158
+ !isObjectLink && {
41159
+ key: "copyLink",
41160
+ label: t("buttons.copyLink"),
41161
+ onSelect: async () => {
41162
+ await copyTextToSystemClipboard(link);
41163
+ this.setState({
41164
+ toast: {
41165
+ message: t("toast.elementLinkCopied"),
41166
+ closable: true
41167
+ }
41168
+ });
41169
+ }
41170
+ }
41171
+ ];
41172
+ });
41204
41173
  __publicField(this, "getContextMenuItems", (type, hitElement) => {
41205
41174
  const imageContextMenuItems = this.getImageContextMenuItems(hitElement);
41175
+ const elementLinkContextMenuItems = this.getElementLinkContextMenuItems(hitElement);
41206
41176
  if (type === "canvas") {
41207
41177
  if (this.state.viewModeEnabled) {
41208
41178
  return [
@@ -41228,6 +41198,8 @@ var App = class _App extends React40.Component {
41228
41198
  }
41229
41199
  if (this.state.viewModeEnabled) {
41230
41200
  return [
41201
+ ...elementLinkContextMenuItems,
41202
+ elementLinkContextMenuItems.length > 0 && CONTEXT_MENU_SEPARATOR,
41231
41203
  actionSmartZoom,
41232
41204
  actionCopy,
41233
41205
  imageContextMenuItems.length > 0 && CONTEXT_MENU_SEPARATOR,
@@ -41272,7 +41244,8 @@ var App = class _App extends React40.Component {
41272
41244
  actionToggleLinearEditor,
41273
41245
  CONTEXT_MENU_SEPARATOR,
41274
41246
  actionLink,
41275
- actionCopyElementLink,
41247
+ elementLinkContextMenuItems.length > 0 && CONTEXT_MENU_SEPARATOR,
41248
+ ...elementLinkContextMenuItems,
41276
41249
  CONTEXT_MENU_SEPARATOR,
41277
41250
  actionDuplicateSelection,
41278
41251
  actionToggleElementLock,
@@ -44598,7 +44571,7 @@ var App = class _App extends React40.Component {
44598
44571
  appState: {
44599
44572
  newElement: null
44600
44573
  },
44601
- captureUpdate: CaptureUpdateAction40.NEVER
44574
+ captureUpdate: CaptureUpdateAction39.NEVER
44602
44575
  });
44603
44576
  return;
44604
44577
  }
@@ -44729,7 +44702,7 @@ var App = class _App extends React40.Component {
44729
44702
  if (resizingElement && isInvisiblySmallElement4(resizingElement)) {
44730
44703
  this.updateScene({
44731
44704
  elements: this.scene.getElementsIncludingDeleted().filter((el) => el.id !== resizingElement.id),
44732
- captureUpdate: CaptureUpdateAction40.NEVER
44705
+ captureUpdate: CaptureUpdateAction39.NEVER
44733
44706
  });
44734
44707
  }
44735
44708
  if (pointerDownState.resize.isResizing) {
@@ -45598,7 +45571,7 @@ import {
45598
45571
  newElementWith as newElementWith11,
45599
45572
  bumpVersion as bumpVersion4
45600
45573
  } from "@excalidraw/element";
45601
- import { CaptureUpdateAction as CaptureUpdateAction41 } from "@excalidraw/element";
45574
+ import { CaptureUpdateAction as CaptureUpdateAction40 } from "@excalidraw/element";
45602
45575
  import {
45603
45576
  getCommonBounds as getCommonBounds14,
45604
45577
  getVisibleSceneBounds as getVisibleSceneBounds2,
@@ -45854,7 +45827,7 @@ function useExcalidrawStateValue(selector) {
45854
45827
  }
45855
45828
  export {
45856
45829
  Button,
45857
- CaptureUpdateAction41 as CaptureUpdateAction,
45830
+ CaptureUpdateAction40 as CaptureUpdateAction,
45858
45831
  DEFAULT_LASER_COLOR2 as DEFAULT_LASER_COLOR,
45859
45832
  DEFAULT_OVERSCROLL,
45860
45833
  DefaultSidebar,