@myoc/excalidraw 0.19.527 → 0.19.529
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 +109 -0
- package/dist/dev/{chunk-N6LESYN7.js → chunk-7GX2B2N5.js} +64 -51
- package/dist/dev/{chunk-N6LESYN7.js.map → chunk-7GX2B2N5.js.map} +2 -2
- package/dist/dev/{chunk-YNR3T55S.js → chunk-H5L4PT3U.js} +2 -2
- package/dist/dev/data/{image-D6KDEKKI.js → image-GYAOLTNI.js} +3 -3
- package/dist/dev/index.js +280 -224
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/subset-shared.chunk.js +1 -1
- package/dist/dev/subset-worker.chunk.js +1 -1
- package/dist/prod/{chunk-FIMIHFNX.js → chunk-5HMH2742.js} +1 -1
- package/dist/prod/{chunk-K3ZT7LUU.js → chunk-CYZQPYCY.js} +3 -3
- package/dist/prod/data/image-O2O5EGGU.js +1 -0
- package/dist/prod/index.js +13 -13
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +0 -27
- package/dist/types/excalidraw/actions/types.d.ts +1 -1
- package/dist/types/excalidraw/components/App.d.ts +5 -0
- package/dist/types/excalidraw/types.d.ts +18 -0
- package/package.json +4 -4
- package/dist/prod/data/image-GHQKUZQU.js +0 -1
- /package/dist/dev/{chunk-YNR3T55S.js.map → chunk-H5L4PT3U.js.map} +0 -0
- /package/dist/dev/data/{image-D6KDEKKI.js.map → image-GYAOLTNI.js.map} +0 -0
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-
|
|
65
|
+
} from "./chunk-7GX2B2N5.js";
|
|
65
66
|
import {
|
|
66
67
|
define_import_meta_env_default
|
|
67
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-H5L4PT3U.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
|
|
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-
|
|
10939
|
+
(blob2) => import("./data/image-GYAOLTNI.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
|
|
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:
|
|
16336
|
+
captureUpdate: CaptureUpdateAction32.IMMEDIATELY
|
|
16424
16337
|
};
|
|
16425
16338
|
}
|
|
16426
16339
|
return {
|
|
16427
16340
|
elements,
|
|
16428
16341
|
appState,
|
|
16429
|
-
captureUpdate:
|
|
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:
|
|
16362
|
+
captureUpdate: CaptureUpdateAction32.IMMEDIATELY
|
|
16450
16363
|
};
|
|
16451
16364
|
}
|
|
16452
16365
|
return {
|
|
16453
16366
|
elements,
|
|
16454
16367
|
appState,
|
|
16455
|
-
captureUpdate:
|
|
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:
|
|
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:
|
|
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
|
|
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
|
|
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 =
|
|
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:
|
|
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:
|
|
16659
|
+
captureUpdate: CaptureUpdateAction34.NEVER
|
|
16747
16660
|
};
|
|
16748
16661
|
}
|
|
16749
|
-
return { captureUpdate:
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
16823
|
+
captureUpdate: CaptureUpdateAction36.EVENTUALLY
|
|
16911
16824
|
};
|
|
16912
16825
|
},
|
|
16913
16826
|
checked: (appState) => appState.viewModeEnabled,
|
|
@@ -16919,12 +16832,13 @@ var actionToggleViewMode = register({
|
|
|
16919
16832
|
if (appState.viewModeOnly || appProps.viewModeOnly) {
|
|
16920
16833
|
return null;
|
|
16921
16834
|
}
|
|
16835
|
+
const label = appState.viewModeEnabled ? "Edit mode" : t("labels.viewMode");
|
|
16922
16836
|
return /* @__PURE__ */ jsx58(
|
|
16923
16837
|
IconButton,
|
|
16924
16838
|
{
|
|
16925
16839
|
type: "button",
|
|
16926
|
-
icon: eyeIcon,
|
|
16927
|
-
"aria-label":
|
|
16840
|
+
icon: appState.viewModeEnabled ? pencilIcon : eyeIcon,
|
|
16841
|
+
"aria-label": label,
|
|
16928
16842
|
onClick: () => updateData(null),
|
|
16929
16843
|
size: data?.size || "medium",
|
|
16930
16844
|
"data-testid": "button-view-mode",
|
|
@@ -24373,7 +24287,7 @@ var AppDrawShape = class {
|
|
|
24373
24287
|
import { isArrowKey as isArrowKey2, KEYS as KEYS39 } from "@excalidraw/common";
|
|
24374
24288
|
import {
|
|
24375
24289
|
makeNextSelectedElementIds as makeNextSelectedElementIds3,
|
|
24376
|
-
CaptureUpdateAction as
|
|
24290
|
+
CaptureUpdateAction as CaptureUpdateAction37,
|
|
24377
24291
|
FlowChartCreator,
|
|
24378
24292
|
FlowChartNavigator,
|
|
24379
24293
|
getSelectedElements as getSelectedElements6,
|
|
@@ -24497,7 +24411,7 @@ var AppFlowchart = class _AppFlowchart {
|
|
|
24497
24411
|
}
|
|
24498
24412
|
captureUpdate() {
|
|
24499
24413
|
this.app.syncActionResult({
|
|
24500
|
-
captureUpdate:
|
|
24414
|
+
captureUpdate: CaptureUpdateAction37.IMMEDIATELY
|
|
24501
24415
|
});
|
|
24502
24416
|
}
|
|
24503
24417
|
static getLinkDirectionFromKey(key) {
|
|
@@ -26325,17 +26239,6 @@ var ExitZenModeButton = ({
|
|
|
26325
26239
|
children: t("buttons.exitZenMode")
|
|
26326
26240
|
}
|
|
26327
26241
|
);
|
|
26328
|
-
var ExitViewModeButton = ({
|
|
26329
|
-
actionManager
|
|
26330
|
-
}) => /* @__PURE__ */ jsx66(
|
|
26331
|
-
"button",
|
|
26332
|
-
{
|
|
26333
|
-
type: "button",
|
|
26334
|
-
className: "disable-view-mode",
|
|
26335
|
-
onClick: () => actionManager.executeAction(actionToggleViewMode),
|
|
26336
|
-
children: pencilIcon
|
|
26337
|
-
}
|
|
26338
|
-
);
|
|
26339
26242
|
|
|
26340
26243
|
// components/LoadingMessage.tsx
|
|
26341
26244
|
import clsx29 from "clsx";
|
|
@@ -27125,22 +27028,19 @@ var MobileMenu = ({
|
|
|
27125
27028
|
if (appState.openDialog?.name === "elementLinkSelector") {
|
|
27126
27029
|
return null;
|
|
27127
27030
|
}
|
|
27128
|
-
const topRightUI = /* @__PURE__ */
|
|
27129
|
-
|
|
27130
|
-
|
|
27131
|
-
|
|
27132
|
-
|
|
27133
|
-
|
|
27134
|
-
|
|
27135
|
-
|
|
27136
|
-
|
|
27137
|
-
|
|
27138
|
-
|
|
27139
|
-
|
|
27140
|
-
|
|
27141
|
-
] })),
|
|
27142
|
-
defaultUIEnabled && appState.viewModeEnabled && app.isInteractionEnabled() && /* @__PURE__ */ jsx80(ExitViewModeButton, { actionManager })
|
|
27143
|
-
] });
|
|
27031
|
+
const topRightUI = /* @__PURE__ */ jsx80("div", { className: "excalidraw-ui-top-right", children: renderTopRightUI?.(true, appState) ?? (!appState.viewModeEnabled && /* @__PURE__ */ jsxs39(Fragment11, { children: [
|
|
27032
|
+
defaultUIEnabled && /* @__PURE__ */ jsx80(
|
|
27033
|
+
PenModeButton,
|
|
27034
|
+
{
|
|
27035
|
+
checked: appState.penMode,
|
|
27036
|
+
onChange: () => onPenModeToggle(null),
|
|
27037
|
+
title: t("toolBar.penMode"),
|
|
27038
|
+
isMobile: true,
|
|
27039
|
+
penDetected: appState.penDetected
|
|
27040
|
+
}
|
|
27041
|
+
),
|
|
27042
|
+
/* @__PURE__ */ jsx80(DefaultSidebarTriggerTunnel.Out, {})
|
|
27043
|
+
] })) });
|
|
27144
27044
|
const topLeftUI = /* @__PURE__ */ jsxs39("div", { className: "excalidraw-ui-top-left", children: [
|
|
27145
27045
|
renderTopLeftUI?.(true, appState),
|
|
27146
27046
|
/* @__PURE__ */ jsx80(MainMenuTunnel.Out, {})
|
|
@@ -27903,7 +27803,13 @@ var Footer = ({
|
|
|
27903
27803
|
}
|
|
27904
27804
|
),
|
|
27905
27805
|
children: /* @__PURE__ */ jsx87(Stack_default.Col, { gap: 2, children: /* @__PURE__ */ jsxs45(Section, { heading: "canvasActions", children: [
|
|
27906
|
-
!appState.viewModeOnly && /* @__PURE__ */ jsx87(
|
|
27806
|
+
!appState.viewModeOnly && /* @__PURE__ */ jsx87(
|
|
27807
|
+
Tooltip,
|
|
27808
|
+
{
|
|
27809
|
+
label: appState.viewModeEnabled ? "Edit mode" : t("labels.viewMode"),
|
|
27810
|
+
children: /* @__PURE__ */ jsx87("div", { className: clsx39("view-mode-button"), children: actionManager.renderAction("viewMode") })
|
|
27811
|
+
}
|
|
27812
|
+
),
|
|
27907
27813
|
/* @__PURE__ */ jsx87(Tooltip, { label: t("buttons.smartZoom"), children: /* @__PURE__ */ jsx87("div", { className: clsx39("smart-zoom-button"), children: actionManager.renderAction("smartZoom") }) }),
|
|
27908
27814
|
zoomUIEnabled && app.isNavigationEnabled() && /* @__PURE__ */ jsx87(ZoomActions, { renderAction: actionManager.renderAction }),
|
|
27909
27815
|
defaultUIEnabled && !appState.viewModeEnabled && /* @__PURE__ */ jsx87(
|
|
@@ -28842,7 +28748,7 @@ import clsx43 from "clsx";
|
|
|
28842
28748
|
import { useEffect as useEffect28, useRef as useRef22, useState as useState24 } from "react";
|
|
28843
28749
|
import { EVENT as EVENT7, KEYS as KEYS45, cloneJSON as cloneJSON3 } from "@excalidraw/common";
|
|
28844
28750
|
import { deepCopyElement as deepCopyElement4 } from "@excalidraw/element";
|
|
28845
|
-
import { CaptureUpdateAction as
|
|
28751
|
+
import { CaptureUpdateAction as CaptureUpdateAction38 } from "@excalidraw/element";
|
|
28846
28752
|
|
|
28847
28753
|
// components/Stats/utils.ts
|
|
28848
28754
|
import { pointFrom as pointFrom40, pointRotateRads as pointRotateRads22 } from "@excalidraw/math";
|
|
@@ -29053,7 +28959,7 @@ var StatsDragInput = ({
|
|
|
29053
28959
|
setAppState
|
|
29054
28960
|
});
|
|
29055
28961
|
app.syncActionResult({
|
|
29056
|
-
captureUpdate:
|
|
28962
|
+
captureUpdate: CaptureUpdateAction38.IMMEDIATELY
|
|
29057
28963
|
});
|
|
29058
28964
|
}
|
|
29059
28965
|
};
|
|
@@ -29161,7 +29067,7 @@ var StatsDragInput = ({
|
|
|
29161
29067
|
false
|
|
29162
29068
|
);
|
|
29163
29069
|
app.syncActionResult({
|
|
29164
|
-
captureUpdate:
|
|
29070
|
+
captureUpdate: CaptureUpdateAction38.IMMEDIATELY
|
|
29165
29071
|
});
|
|
29166
29072
|
dragFinishedCallback?.({
|
|
29167
29073
|
app,
|
|
@@ -31064,8 +30970,8 @@ var StatsInner = memo2(
|
|
|
31064
30970
|
import { useCallback as useCallback10, useEffect as useEffect30, useState as useState27 } from "react";
|
|
31065
30971
|
import { normalizeLink as normalizeLink3, KEYS as KEYS46 } from "@excalidraw/common";
|
|
31066
30972
|
import {
|
|
31067
|
-
defaultGetElementLinkFromSelection
|
|
31068
|
-
getLinkIdAndTypeFromSelection
|
|
30973
|
+
defaultGetElementLinkFromSelection,
|
|
30974
|
+
getLinkIdAndTypeFromSelection
|
|
31069
30975
|
} from "@excalidraw/element";
|
|
31070
30976
|
|
|
31071
30977
|
// components/DialogActionButton.tsx
|
|
@@ -31222,7 +31128,7 @@ var ElementLinkDialog = ({
|
|
|
31222
31128
|
onClose,
|
|
31223
31129
|
appState,
|
|
31224
31130
|
scene,
|
|
31225
|
-
generateLinkForSelection =
|
|
31131
|
+
generateLinkForSelection = defaultGetElementLinkFromSelection
|
|
31226
31132
|
}) => {
|
|
31227
31133
|
const elementsMap = scene.getNonDeletedElementsMap();
|
|
31228
31134
|
const originalLink = elementsMap.get(sourceElementId)?.link ?? null;
|
|
@@ -31232,7 +31138,7 @@ var ElementLinkDialog = ({
|
|
|
31232
31138
|
const selectedElements = getSelectedElements(elementsMap, appState);
|
|
31233
31139
|
let nextLink2 = originalLink;
|
|
31234
31140
|
if (selectedElements.length > 0 && generateLinkForSelection) {
|
|
31235
|
-
const idAndType =
|
|
31141
|
+
const idAndType = getLinkIdAndTypeFromSelection(
|
|
31236
31142
|
selectedElements,
|
|
31237
31143
|
appState
|
|
31238
31144
|
);
|
|
@@ -33505,10 +33411,14 @@ var DefaultSidebar = Object.assign(
|
|
|
33505
33411
|
children,
|
|
33506
33412
|
className,
|
|
33507
33413
|
docked,
|
|
33414
|
+
onDock,
|
|
33508
33415
|
...rest
|
|
33509
33416
|
}) => {
|
|
33510
33417
|
const appState = useUIAppState();
|
|
33418
|
+
const setAppState = useExcalidrawSetAppState();
|
|
33511
33419
|
const isSearchSidebar = appState.openSidebar?.tab === CANVAS_SEARCH_TAB2;
|
|
33420
|
+
const isDocked = isSearchSidebar ? false : docked ?? appState.defaultSidebarDockedPreference;
|
|
33421
|
+
const canDock = !isSearchSidebar && docked == null && onDock !== false;
|
|
33512
33422
|
return /* @__PURE__ */ createElement2(
|
|
33513
33423
|
Sidebar,
|
|
33514
33424
|
{
|
|
@@ -33520,8 +33430,13 @@ var DefaultSidebar = Object.assign(
|
|
|
33520
33430
|
{ "default-sidebar--search-only": isSearchSidebar },
|
|
33521
33431
|
className
|
|
33522
33432
|
),
|
|
33523
|
-
docked:
|
|
33524
|
-
onDock:
|
|
33433
|
+
docked: isDocked,
|
|
33434
|
+
onDock: canDock ? (nextDocked) => {
|
|
33435
|
+
setAppState({
|
|
33436
|
+
defaultSidebarDockedPreference: nextDocked
|
|
33437
|
+
});
|
|
33438
|
+
onDock?.(nextDocked);
|
|
33439
|
+
} : void 0
|
|
33525
33440
|
},
|
|
33526
33441
|
/* @__PURE__ */ jsxs64(Sidebar.Tabs, { children: [
|
|
33527
33442
|
!isSearchSidebar && /* @__PURE__ */ jsx124(Sidebar.Header, {}),
|
|
@@ -34389,7 +34304,8 @@ var LayerUI = ({
|
|
|
34389
34304
|
const renderCanvasActions = () => /* @__PURE__ */ jsxs67("div", { style: { position: "relative" }, children: [
|
|
34390
34305
|
/* @__PURE__ */ jsxs67("div", { className: "excalidraw-ui-top-left", children: [
|
|
34391
34306
|
renderTopLeftUI?.(false, appState),
|
|
34392
|
-
/* @__PURE__ */ jsx131(tunnels.MainMenuTunnel.Out, {})
|
|
34307
|
+
/* @__PURE__ */ jsx131(tunnels.MainMenuTunnel.Out, {}),
|
|
34308
|
+
/* @__PURE__ */ jsx131(tunnels.DefaultSidebarTriggerTunnel.Out, {})
|
|
34393
34309
|
] }),
|
|
34394
34310
|
renderWelcomeScreen && /* @__PURE__ */ jsx131(tunnels.WelcomeScreenMenuHintTunnel.Out, {})
|
|
34395
34311
|
] });
|
|
@@ -34729,9 +34645,9 @@ var LayerUI = ({
|
|
|
34729
34645
|
] })
|
|
34730
34646
|
]
|
|
34731
34647
|
}
|
|
34732
|
-
)
|
|
34733
|
-
|
|
34734
|
-
|
|
34648
|
+
)
|
|
34649
|
+
] }),
|
|
34650
|
+
renderSidebars()
|
|
34735
34651
|
] });
|
|
34736
34652
|
return /* @__PURE__ */ jsx131(UIAppStateContext.Provider, { value: appState, children: /* @__PURE__ */ jsx131(TunnelsJotaiProvider, { children: /* @__PURE__ */ jsx131(TunnelsContext.Provider, { value: tunnels, children: layerUIJSX }) }) });
|
|
34737
34653
|
};
|
|
@@ -36080,12 +35996,12 @@ var App = class _App extends React40.Component {
|
|
|
36080
35996
|
if (shouldUpdateStrokeColor) {
|
|
36081
35997
|
this.syncActionResult({
|
|
36082
35998
|
appState: { ...this.state, currentItemStrokeColor: color },
|
|
36083
|
-
captureUpdate:
|
|
35999
|
+
captureUpdate: CaptureUpdateAction39.IMMEDIATELY
|
|
36084
36000
|
});
|
|
36085
36001
|
} else {
|
|
36086
36002
|
this.syncActionResult({
|
|
36087
36003
|
appState: { ...this.state, currentItemBackgroundColor: color },
|
|
36088
|
-
captureUpdate:
|
|
36004
|
+
captureUpdate: CaptureUpdateAction39.IMMEDIATELY
|
|
36089
36005
|
});
|
|
36090
36006
|
}
|
|
36091
36007
|
} else {
|
|
@@ -36098,7 +36014,7 @@ var App = class _App extends React40.Component {
|
|
|
36098
36014
|
}
|
|
36099
36015
|
return el;
|
|
36100
36016
|
}),
|
|
36101
|
-
captureUpdate:
|
|
36017
|
+
captureUpdate: CaptureUpdateAction39.IMMEDIATELY
|
|
36102
36018
|
});
|
|
36103
36019
|
}
|
|
36104
36020
|
},
|
|
@@ -36516,7 +36432,7 @@ var App = class _App extends React40.Component {
|
|
|
36516
36432
|
elements: restoredElements,
|
|
36517
36433
|
appState: restoredAppState,
|
|
36518
36434
|
files: initialData?.files,
|
|
36519
|
-
captureUpdate:
|
|
36435
|
+
captureUpdate: CaptureUpdateAction39.NEVER
|
|
36520
36436
|
});
|
|
36521
36437
|
this.clearImageShapeCache();
|
|
36522
36438
|
this.fonts.loadSceneFonts().then((fontFaces) => {
|
|
@@ -36731,6 +36647,20 @@ var App = class _App extends React40.Component {
|
|
|
36731
36647
|
const dataTransferList = await parseDataTransferEvent(event);
|
|
36732
36648
|
const filesList = dataTransferList.getFiles();
|
|
36733
36649
|
const data = await parseClipboard(dataTransferList, isPlainPaste);
|
|
36650
|
+
if (this.state.viewModeEnabled) {
|
|
36651
|
+
if (!this.containsImagePaste(data, filesList, isPlainPaste)) {
|
|
36652
|
+
return;
|
|
36653
|
+
}
|
|
36654
|
+
if (!this.shouldInsertImageInViewMode({
|
|
36655
|
+
source: "paste",
|
|
36656
|
+
files: filesList.map((file2) => file2.file),
|
|
36657
|
+
data,
|
|
36658
|
+
event
|
|
36659
|
+
})) {
|
|
36660
|
+
event?.preventDefault();
|
|
36661
|
+
return;
|
|
36662
|
+
}
|
|
36663
|
+
}
|
|
36734
36664
|
if (this.props.onPaste) {
|
|
36735
36665
|
try {
|
|
36736
36666
|
if (await this.props.onPaste(data, event) === false) {
|
|
@@ -38314,7 +38244,31 @@ var App = class _App extends React40.Component {
|
|
|
38314
38244
|
}
|
|
38315
38245
|
}
|
|
38316
38246
|
});
|
|
38247
|
+
__publicField(this, "getElementLinkAtPositionForContextMenu", (scenePointer, hitElementMightBeLocked) => {
|
|
38248
|
+
const linkElement = this.getElementLinkAtPosition(
|
|
38249
|
+
scenePointer,
|
|
38250
|
+
hitElementMightBeLocked
|
|
38251
|
+
);
|
|
38252
|
+
if (linkElement) {
|
|
38253
|
+
return linkElement;
|
|
38254
|
+
}
|
|
38255
|
+
const elementsMap = this.scene.getNonDeletedElementsMap();
|
|
38256
|
+
for (const element of this.scene.getNonDeletedElements().slice().reverse()) {
|
|
38257
|
+
if (element.link && !element.locked && isPointHittingLinkIcon(
|
|
38258
|
+
element,
|
|
38259
|
+
elementsMap,
|
|
38260
|
+
this.state,
|
|
38261
|
+
pointFrom44(scenePointer.x, scenePointer.y)
|
|
38262
|
+
)) {
|
|
38263
|
+
return element;
|
|
38264
|
+
}
|
|
38265
|
+
}
|
|
38266
|
+
});
|
|
38317
38267
|
__publicField(this, "handleElementLinkClick", (event) => {
|
|
38268
|
+
const isActivationButton = (button) => button === POINTER_BUTTON2.MAIN || button === POINTER_BUTTON2.TOUCH;
|
|
38269
|
+
if (!isActivationButton(this.lastPointerDownEvent.button) || !isActivationButton(this.lastPointerUpEvent.button)) {
|
|
38270
|
+
return;
|
|
38271
|
+
}
|
|
38318
38272
|
const draggedDistance = pointDistance11(
|
|
38319
38273
|
pointFrom44(
|
|
38320
38274
|
this.lastPointerDownEvent.clientX,
|
|
@@ -38353,28 +38307,32 @@ var App = class _App extends React40.Component {
|
|
|
38353
38307
|
);
|
|
38354
38308
|
if (lastPointerDownHittingLinkIcon && lastPointerUpHittingLinkIcon) {
|
|
38355
38309
|
hideHyperlinkToolip();
|
|
38356
|
-
|
|
38357
|
-
|
|
38358
|
-
|
|
38359
|
-
|
|
38360
|
-
|
|
38361
|
-
|
|
38362
|
-
|
|
38363
|
-
|
|
38364
|
-
|
|
38365
|
-
|
|
38366
|
-
|
|
38367
|
-
|
|
38368
|
-
|
|
38369
|
-
|
|
38370
|
-
|
|
38371
|
-
|
|
38372
|
-
|
|
38373
|
-
|
|
38374
|
-
|
|
38375
|
-
|
|
38376
|
-
|
|
38377
|
-
|
|
38310
|
+
this.openElementLink(this.hitLinkElement, event);
|
|
38311
|
+
}
|
|
38312
|
+
});
|
|
38313
|
+
__publicField(this, "openElementLink", (element, event) => {
|
|
38314
|
+
let url = element.link;
|
|
38315
|
+
if (!url) {
|
|
38316
|
+
return;
|
|
38317
|
+
}
|
|
38318
|
+
url = normalizeLink4(url);
|
|
38319
|
+
let customEvent;
|
|
38320
|
+
if (this.props.onLinkOpen && event) {
|
|
38321
|
+
customEvent = wrapEvent2(EVENT11.EXCALIDRAW_LINK, event.nativeEvent);
|
|
38322
|
+
this.props.onLinkOpen(
|
|
38323
|
+
{
|
|
38324
|
+
...element,
|
|
38325
|
+
link: url
|
|
38326
|
+
},
|
|
38327
|
+
customEvent
|
|
38328
|
+
);
|
|
38329
|
+
}
|
|
38330
|
+
if (!customEvent?.defaultPrevented) {
|
|
38331
|
+
const target = isLocalLink2(url) ? "_self" : "_blank";
|
|
38332
|
+
const newWindow = window.open(void 0, target);
|
|
38333
|
+
if (newWindow) {
|
|
38334
|
+
newWindow.opener = null;
|
|
38335
|
+
newWindow.location = url;
|
|
38378
38336
|
}
|
|
38379
38337
|
}
|
|
38380
38338
|
});
|
|
@@ -39094,7 +39052,7 @@ var App = class _App extends React40.Component {
|
|
|
39094
39052
|
this.state
|
|
39095
39053
|
)
|
|
39096
39054
|
},
|
|
39097
|
-
captureUpdate: this.state.openDialog?.name === "elementLinkSelector" ?
|
|
39055
|
+
captureUpdate: this.state.openDialog?.name === "elementLinkSelector" ? CaptureUpdateAction39.EVENTUALLY : CaptureUpdateAction39.NEVER
|
|
39098
39056
|
});
|
|
39099
39057
|
return;
|
|
39100
39058
|
}
|
|
@@ -40432,9 +40390,8 @@ var App = class _App extends React40.Component {
|
|
|
40432
40390
|
if (!isSupportedImageFile(imageFile)) {
|
|
40433
40391
|
throw new Error(t("errors.unsupportedFileType"));
|
|
40434
40392
|
}
|
|
40435
|
-
const mimeType = imageFile.type;
|
|
40436
40393
|
this.cursor.set("wait");
|
|
40437
|
-
if (
|
|
40394
|
+
if (imageFile.type === MIME_TYPES9.svg) {
|
|
40438
40395
|
try {
|
|
40439
40396
|
imageFile = SVGStringToFile(
|
|
40440
40397
|
normalizeSVG(await imageFile.text()),
|
|
@@ -40444,7 +40401,18 @@ var App = class _App extends React40.Component {
|
|
|
40444
40401
|
console.warn(error);
|
|
40445
40402
|
throw new Error(t("errors.svgImageInsertError"));
|
|
40446
40403
|
}
|
|
40404
|
+
} else {
|
|
40405
|
+
const { maxWidthOrHeight } = this.props.imageOptions;
|
|
40406
|
+
try {
|
|
40407
|
+
imageFile = await (this.props.compressImageFile ?? resizeImageFile)(
|
|
40408
|
+
imageFile,
|
|
40409
|
+
{ maxWidthOrHeight }
|
|
40410
|
+
);
|
|
40411
|
+
} catch (error) {
|
|
40412
|
+
console.error("Error trying to resize image file on insertion", error);
|
|
40413
|
+
}
|
|
40447
40414
|
}
|
|
40415
|
+
const mimeType = imageFile.type;
|
|
40448
40416
|
const fileId = await (this.props.generateIdForFile?.(
|
|
40449
40417
|
imageFile
|
|
40450
40418
|
) || generateIdFromFile(imageFile));
|
|
@@ -40456,15 +40424,7 @@ var App = class _App extends React40.Component {
|
|
|
40456
40424
|
}
|
|
40457
40425
|
const existingFileData = this.files[fileId];
|
|
40458
40426
|
if (!existingFileData?.dataURL) {
|
|
40459
|
-
const {
|
|
40460
|
-
try {
|
|
40461
|
-
imageFile = await (this.props.compressImageFile ?? resizeImageFile)(
|
|
40462
|
-
imageFile,
|
|
40463
|
-
{ maxWidthOrHeight }
|
|
40464
|
-
);
|
|
40465
|
-
} catch (error) {
|
|
40466
|
-
console.error("Error trying to resize image file on insertion", error);
|
|
40467
|
-
}
|
|
40427
|
+
const { maxFileSizeBytes } = this.props.imageOptions;
|
|
40468
40428
|
if (imageFile.size > maxFileSizeBytes) {
|
|
40469
40429
|
throw new Error(
|
|
40470
40430
|
t("errors.fileTooBig", {
|
|
@@ -40631,7 +40591,7 @@ var App = class _App extends React40.Component {
|
|
|
40631
40591
|
});
|
|
40632
40592
|
}
|
|
40633
40593
|
if (erroredFiles.size || updatedFiles.size) {
|
|
40634
|
-
this.store.scheduleAction(
|
|
40594
|
+
this.store.scheduleAction(CaptureUpdateAction39.NEVER);
|
|
40635
40595
|
this.scene.replaceAllElements(
|
|
40636
40596
|
this.scene.getElementsIncludingDeleted().map((element) => {
|
|
40637
40597
|
if (isInitializedImageElement3(element)) {
|
|
@@ -40751,7 +40711,7 @@ var App = class _App extends React40.Component {
|
|
|
40751
40711
|
)
|
|
40752
40712
|
},
|
|
40753
40713
|
elements: nextElements,
|
|
40754
|
-
captureUpdate:
|
|
40714
|
+
captureUpdate: CaptureUpdateAction39.IMMEDIATELY
|
|
40755
40715
|
});
|
|
40756
40716
|
this.setState({}, () => {
|
|
40757
40717
|
this.actionManager.executeAction(actionFinalize);
|
|
@@ -40768,6 +40728,29 @@ var App = class _App extends React40.Component {
|
|
|
40768
40728
|
const dragDataSnapshot = captureDragEventData(event);
|
|
40769
40729
|
const dataTransferList = await parseDataTransferEvent(event);
|
|
40770
40730
|
const fileItems = dataTransferList.getFiles();
|
|
40731
|
+
const imageFiles = fileItems.map((data) => data.file).filter((file2) => isSupportedImageFile(file2));
|
|
40732
|
+
if (this.state.viewModeEnabled) {
|
|
40733
|
+
if (imageFiles.length === 0 || !this.isToolSupported("image")) {
|
|
40734
|
+
return;
|
|
40735
|
+
}
|
|
40736
|
+
if (!this.shouldInsertImageInViewMode({
|
|
40737
|
+
source: "drop",
|
|
40738
|
+
files: imageFiles,
|
|
40739
|
+
event
|
|
40740
|
+
})) {
|
|
40741
|
+
return;
|
|
40742
|
+
}
|
|
40743
|
+
return this.insertImages(
|
|
40744
|
+
imageFiles,
|
|
40745
|
+
sceneX,
|
|
40746
|
+
sceneY,
|
|
40747
|
+
parseDragImageMetadata(
|
|
40748
|
+
dataTransferList,
|
|
40749
|
+
imageFiles.length,
|
|
40750
|
+
dragDataSnapshot
|
|
40751
|
+
)
|
|
40752
|
+
);
|
|
40753
|
+
}
|
|
40771
40754
|
if (fileItems.length === 1) {
|
|
40772
40755
|
const { file: file2, fileHandle } = fileItems[0];
|
|
40773
40756
|
if (file2 && (file2.type === MIME_TYPES9.png || file2.type === MIME_TYPES9.svg)) {
|
|
@@ -40785,7 +40768,7 @@ var App = class _App extends React40.Component {
|
|
|
40785
40768
|
isLoading: false
|
|
40786
40769
|
},
|
|
40787
40770
|
replaceFiles: true,
|
|
40788
|
-
captureUpdate:
|
|
40771
|
+
captureUpdate: CaptureUpdateAction39.IMMEDIATELY
|
|
40789
40772
|
});
|
|
40790
40773
|
return;
|
|
40791
40774
|
} catch (error) {
|
|
@@ -40795,7 +40778,6 @@ var App = class _App extends React40.Component {
|
|
|
40795
40778
|
}
|
|
40796
40779
|
}
|
|
40797
40780
|
}
|
|
40798
|
-
const imageFiles = fileItems.map((data) => data.file).filter((file2) => isSupportedImageFile(file2));
|
|
40799
40781
|
if (imageFiles.length > 0 && this.isToolSupported("image")) {
|
|
40800
40782
|
return this.insertImages(
|
|
40801
40783
|
imageFiles,
|
|
@@ -40858,7 +40840,7 @@ var App = class _App extends React40.Component {
|
|
|
40858
40840
|
{
|
|
40859
40841
|
syncInvalidIndices3(elements.concat(ret.elements));
|
|
40860
40842
|
this.store.scheduleMicroAction({
|
|
40861
|
-
action:
|
|
40843
|
+
action: CaptureUpdateAction39.NEVER,
|
|
40862
40844
|
elements,
|
|
40863
40845
|
appState: void 0
|
|
40864
40846
|
});
|
|
@@ -40871,7 +40853,7 @@ var App = class _App extends React40.Component {
|
|
|
40871
40853
|
isLoading: false
|
|
40872
40854
|
},
|
|
40873
40855
|
replaceFiles: true,
|
|
40874
|
-
captureUpdate:
|
|
40856
|
+
captureUpdate: CaptureUpdateAction39.IMMEDIATELY
|
|
40875
40857
|
});
|
|
40876
40858
|
}
|
|
40877
40859
|
} catch (error) {
|
|
@@ -40893,12 +40875,15 @@ var App = class _App extends React40.Component {
|
|
|
40893
40875
|
preferSelected: true,
|
|
40894
40876
|
includeLockedElements: true
|
|
40895
40877
|
});
|
|
40878
|
+
const linkElement = this.isLinksEnabled() ? this.getElementLinkAtPositionForContextMenu({ x, y }, element) : void 0;
|
|
40896
40879
|
const selectedElements = this.scene.getSelectedElements(this.state);
|
|
40897
40880
|
const isHittingCommonBoundBox = this.isHittingCommonBoundingBoxOfSelectedElements(
|
|
40898
40881
|
{ x, y },
|
|
40899
40882
|
selectedElements
|
|
40900
40883
|
);
|
|
40901
|
-
const
|
|
40884
|
+
const selectedLinkedElement = isHittingCommonBoundBox && selectedElements.length === 1 && selectedElements[0].link ? selectedElements[0] : void 0;
|
|
40885
|
+
const contextMenuElement = element ?? linkElement ?? selectedLinkedElement;
|
|
40886
|
+
const type = contextMenuElement || isHittingCommonBoundBox ? "element" : "canvas";
|
|
40902
40887
|
const container = this.excalidrawContainerRef.current;
|
|
40903
40888
|
const { top: offsetTop, left: offsetLeft } = container.getBoundingClientRect();
|
|
40904
40889
|
const left = event.clientX - offsetLeft;
|
|
@@ -40906,19 +40891,19 @@ var App = class _App extends React40.Component {
|
|
|
40906
40891
|
trackEvent("contextMenu", "openContextMenu", type);
|
|
40907
40892
|
this.setState(
|
|
40908
40893
|
{
|
|
40909
|
-
...
|
|
40894
|
+
...contextMenuElement && !this.state.selectedElementIds[contextMenuElement.id] ? {
|
|
40910
40895
|
...this.state,
|
|
40911
40896
|
...selectGroupsForSelectedElements7(
|
|
40912
40897
|
{
|
|
40913
40898
|
editingGroupId: this.state.editingGroupId,
|
|
40914
|
-
selectedElementIds: { [
|
|
40899
|
+
selectedElementIds: { [contextMenuElement.id]: true }
|
|
40915
40900
|
},
|
|
40916
40901
|
this.scene.getNonDeletedElements(),
|
|
40917
40902
|
this.state,
|
|
40918
40903
|
this
|
|
40919
40904
|
),
|
|
40920
|
-
selectedLinearElement: isLinearElement11(
|
|
40921
|
-
|
|
40905
|
+
selectedLinearElement: isLinearElement11(contextMenuElement) ? new LinearElementEditor12(
|
|
40906
|
+
contextMenuElement,
|
|
40922
40907
|
this.scene.getNonDeletedElementsMap()
|
|
40923
40908
|
) : null
|
|
40924
40909
|
} : this.state,
|
|
@@ -40929,7 +40914,7 @@ var App = class _App extends React40.Component {
|
|
|
40929
40914
|
contextMenu: {
|
|
40930
40915
|
top,
|
|
40931
40916
|
left,
|
|
40932
|
-
items: this.getContextMenuItems(type,
|
|
40917
|
+
items: this.getContextMenuItems(type, contextMenuElement)
|
|
40933
40918
|
}
|
|
40934
40919
|
});
|
|
40935
40920
|
}
|
|
@@ -41199,8 +41184,36 @@ var App = class _App extends React40.Component {
|
|
|
41199
41184
|
}
|
|
41200
41185
|
return [];
|
|
41201
41186
|
});
|
|
41187
|
+
__publicField(this, "getElementLinkContextMenuItems", (hitElement) => {
|
|
41188
|
+
if (!hitElement?.link) {
|
|
41189
|
+
return [];
|
|
41190
|
+
}
|
|
41191
|
+
const link = normalizeLink4(hitElement.link);
|
|
41192
|
+
const isObjectLink = isElementLink3(link);
|
|
41193
|
+
return [
|
|
41194
|
+
{
|
|
41195
|
+
key: "goToLink",
|
|
41196
|
+
label: isObjectLink ? t("labels.link.goToElement") : "Go to link",
|
|
41197
|
+
onSelect: () => this.openElementLink(hitElement)
|
|
41198
|
+
},
|
|
41199
|
+
!isObjectLink && {
|
|
41200
|
+
key: "copyLink",
|
|
41201
|
+
label: t("buttons.copyLink"),
|
|
41202
|
+
onSelect: async () => {
|
|
41203
|
+
await copyTextToSystemClipboard(link);
|
|
41204
|
+
this.setState({
|
|
41205
|
+
toast: {
|
|
41206
|
+
message: t("toast.elementLinkCopied"),
|
|
41207
|
+
closable: true
|
|
41208
|
+
}
|
|
41209
|
+
});
|
|
41210
|
+
}
|
|
41211
|
+
}
|
|
41212
|
+
];
|
|
41213
|
+
});
|
|
41202
41214
|
__publicField(this, "getContextMenuItems", (type, hitElement) => {
|
|
41203
41215
|
const imageContextMenuItems = this.getImageContextMenuItems(hitElement);
|
|
41216
|
+
const elementLinkContextMenuItems = this.getElementLinkContextMenuItems(hitElement);
|
|
41204
41217
|
if (type === "canvas") {
|
|
41205
41218
|
if (this.state.viewModeEnabled) {
|
|
41206
41219
|
return [
|
|
@@ -41226,6 +41239,8 @@ var App = class _App extends React40.Component {
|
|
|
41226
41239
|
}
|
|
41227
41240
|
if (this.state.viewModeEnabled) {
|
|
41228
41241
|
return [
|
|
41242
|
+
...elementLinkContextMenuItems,
|
|
41243
|
+
elementLinkContextMenuItems.length > 0 && CONTEXT_MENU_SEPARATOR,
|
|
41229
41244
|
actionSmartZoom,
|
|
41230
41245
|
actionCopy,
|
|
41231
41246
|
imageContextMenuItems.length > 0 && CONTEXT_MENU_SEPARATOR,
|
|
@@ -41270,7 +41285,8 @@ var App = class _App extends React40.Component {
|
|
|
41270
41285
|
actionToggleLinearEditor,
|
|
41271
41286
|
CONTEXT_MENU_SEPARATOR,
|
|
41272
41287
|
actionLink,
|
|
41273
|
-
|
|
41288
|
+
elementLinkContextMenuItems.length > 0 && CONTEXT_MENU_SEPARATOR,
|
|
41289
|
+
...elementLinkContextMenuItems,
|
|
41274
41290
|
CONTEXT_MENU_SEPARATOR,
|
|
41275
41291
|
actionDuplicateSelection,
|
|
41276
41292
|
actionToggleElementLock,
|
|
@@ -42669,6 +42685,21 @@ var App = class _App extends React40.Component {
|
|
|
42669
42685
|
EVENT11.GESTURE_END,
|
|
42670
42686
|
this.onGestureEnd,
|
|
42671
42687
|
false
|
|
42688
|
+
),
|
|
42689
|
+
addEventListener2(document, EVENT11.PASTE, this.pasteFromClipboard, {
|
|
42690
|
+
passive: false
|
|
42691
|
+
}),
|
|
42692
|
+
addEventListener2(
|
|
42693
|
+
this.excalidrawContainerRef.current,
|
|
42694
|
+
EVENT11.DRAG_OVER,
|
|
42695
|
+
this.disableEvent,
|
|
42696
|
+
false
|
|
42697
|
+
),
|
|
42698
|
+
addEventListener2(
|
|
42699
|
+
this.excalidrawContainerRef.current,
|
|
42700
|
+
EVENT11.DROP,
|
|
42701
|
+
this.disableEvent,
|
|
42702
|
+
false
|
|
42672
42703
|
)
|
|
42673
42704
|
);
|
|
42674
42705
|
if (this.state.viewModeEnabled) {
|
|
@@ -42681,9 +42712,6 @@ var App = class _App extends React40.Component {
|
|
|
42681
42712
|
this.onFullscreenChange,
|
|
42682
42713
|
{ passive: false }
|
|
42683
42714
|
),
|
|
42684
|
-
addEventListener2(document, EVENT11.PASTE, this.pasteFromClipboard, {
|
|
42685
|
-
passive: false
|
|
42686
|
-
}),
|
|
42687
42715
|
addEventListener2(document, EVENT11.CUT, this.onCut, { passive: false }),
|
|
42688
42716
|
addEventListener2(window, EVENT11.RESIZE, this.onResize, false),
|
|
42689
42717
|
addEventListener2(window, EVENT11.UNLOAD, this.onUnload, false),
|
|
@@ -42693,18 +42721,6 @@ var App = class _App extends React40.Component {
|
|
|
42693
42721
|
EVENT11.WHEEL,
|
|
42694
42722
|
this.handleWheel,
|
|
42695
42723
|
{ passive: false }
|
|
42696
|
-
),
|
|
42697
|
-
addEventListener2(
|
|
42698
|
-
this.excalidrawContainerRef.current,
|
|
42699
|
-
EVENT11.DRAG_OVER,
|
|
42700
|
-
this.disableEvent,
|
|
42701
|
-
false
|
|
42702
|
-
),
|
|
42703
|
-
addEventListener2(
|
|
42704
|
-
this.excalidrawContainerRef.current,
|
|
42705
|
-
EVENT11.DROP,
|
|
42706
|
-
this.disableEvent,
|
|
42707
|
-
false
|
|
42708
42724
|
)
|
|
42709
42725
|
);
|
|
42710
42726
|
if (this.props.detectScroll) {
|
|
@@ -42927,6 +42943,42 @@ var App = class _App extends React40.Component {
|
|
|
42927
42943
|
}
|
|
42928
42944
|
this.addTextFromPaste(data.text, isPlainPaste);
|
|
42929
42945
|
}
|
|
42946
|
+
containsImagePaste(data, dataTransferFiles, isPlainPaste) {
|
|
42947
|
+
if (dataTransferFiles.some((data2) => isSupportedImageFile(data2.file))) {
|
|
42948
|
+
return true;
|
|
42949
|
+
}
|
|
42950
|
+
if (!isPlainPaste && data.mixedContent?.some((node) => node.type === "imageUrl")) {
|
|
42951
|
+
return true;
|
|
42952
|
+
}
|
|
42953
|
+
if (isPlainPaste || !data.text) {
|
|
42954
|
+
return false;
|
|
42955
|
+
}
|
|
42956
|
+
const trimmedText = data.text.trim();
|
|
42957
|
+
return trimmedText.startsWith("<svg") && trimmedText.endsWith("</svg>");
|
|
42958
|
+
}
|
|
42959
|
+
shouldInsertImageInViewMode({
|
|
42960
|
+
source,
|
|
42961
|
+
files,
|
|
42962
|
+
data,
|
|
42963
|
+
event
|
|
42964
|
+
}) {
|
|
42965
|
+
if (!this.state.viewModeEnabled) {
|
|
42966
|
+
return true;
|
|
42967
|
+
}
|
|
42968
|
+
if (this.state.viewModeOnly || this.props.viewModeImageInsertBehavior === "reject") {
|
|
42969
|
+
this.props.onViewModeImageInsertRejected?.({
|
|
42970
|
+
source,
|
|
42971
|
+
files,
|
|
42972
|
+
data,
|
|
42973
|
+
event
|
|
42974
|
+
});
|
|
42975
|
+
return false;
|
|
42976
|
+
}
|
|
42977
|
+
flushSync2(() => {
|
|
42978
|
+
this.setState({ viewModeEnabled: false });
|
|
42979
|
+
});
|
|
42980
|
+
return true;
|
|
42981
|
+
}
|
|
42930
42982
|
// TODO rewrite this to paste both text & images at the same time if
|
|
42931
42983
|
// pasted data contains both
|
|
42932
42984
|
async addElementsFromMixedContentPaste(mixedContent, {
|
|
@@ -44596,7 +44648,7 @@ var App = class _App extends React40.Component {
|
|
|
44596
44648
|
appState: {
|
|
44597
44649
|
newElement: null
|
|
44598
44650
|
},
|
|
44599
|
-
captureUpdate:
|
|
44651
|
+
captureUpdate: CaptureUpdateAction39.NEVER
|
|
44600
44652
|
});
|
|
44601
44653
|
return;
|
|
44602
44654
|
}
|
|
@@ -44727,7 +44779,7 @@ var App = class _App extends React40.Component {
|
|
|
44727
44779
|
if (resizingElement && isInvisiblySmallElement4(resizingElement)) {
|
|
44728
44780
|
this.updateScene({
|
|
44729
44781
|
elements: this.scene.getElementsIncludingDeleted().filter((el) => el.id !== resizingElement.id),
|
|
44730
|
-
captureUpdate:
|
|
44782
|
+
captureUpdate: CaptureUpdateAction39.NEVER
|
|
44731
44783
|
});
|
|
44732
44784
|
}
|
|
44733
44785
|
if (pointerDownState.resize.isResizing) {
|
|
@@ -45596,7 +45648,7 @@ import {
|
|
|
45596
45648
|
newElementWith as newElementWith11,
|
|
45597
45649
|
bumpVersion as bumpVersion4
|
|
45598
45650
|
} from "@excalidraw/element";
|
|
45599
|
-
import { CaptureUpdateAction as
|
|
45651
|
+
import { CaptureUpdateAction as CaptureUpdateAction40 } from "@excalidraw/element";
|
|
45600
45652
|
import {
|
|
45601
45653
|
getCommonBounds as getCommonBounds14,
|
|
45602
45654
|
getVisibleSceneBounds as getVisibleSceneBounds2,
|
|
@@ -45644,6 +45696,8 @@ var ExcalidrawBase = (props) => {
|
|
|
45644
45696
|
editorPreferences,
|
|
45645
45697
|
onEditorPreferencesChange,
|
|
45646
45698
|
onPaste,
|
|
45699
|
+
viewModeImageInsertBehavior,
|
|
45700
|
+
onViewModeImageInsertRejected,
|
|
45647
45701
|
detectScroll = true,
|
|
45648
45702
|
handleKeyboardGlobally = false,
|
|
45649
45703
|
autoFocus = false,
|
|
@@ -45757,6 +45811,8 @@ var ExcalidrawBase = (props) => {
|
|
|
45757
45811
|
onEditorPreferencesChange,
|
|
45758
45812
|
UIOptions,
|
|
45759
45813
|
onPaste,
|
|
45814
|
+
viewModeImageInsertBehavior,
|
|
45815
|
+
onViewModeImageInsertRejected,
|
|
45760
45816
|
detectScroll,
|
|
45761
45817
|
handleKeyboardGlobally,
|
|
45762
45818
|
autoFocus,
|
|
@@ -45852,7 +45908,7 @@ function useExcalidrawStateValue(selector) {
|
|
|
45852
45908
|
}
|
|
45853
45909
|
export {
|
|
45854
45910
|
Button,
|
|
45855
|
-
|
|
45911
|
+
CaptureUpdateAction40 as CaptureUpdateAction,
|
|
45856
45912
|
DEFAULT_LASER_COLOR2 as DEFAULT_LASER_COLOR,
|
|
45857
45913
|
DEFAULT_OVERSCROLL,
|
|
45858
45914
|
DefaultSidebar,
|