@dwelle/excalidraw 0.5.0-2aec728 → 0.5.0-2dbdd6f
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/{chunk-M4JV7MPJ.js → chunk-EWKWI3K7.js} +12 -4
- package/dist/dev/chunk-EWKWI3K7.js.map +7 -0
- package/dist/dev/{chunk-K532CM3P.js → chunk-JBODKHIT.js} +420 -153
- package/dist/dev/chunk-JBODKHIT.js.map +7 -0
- package/dist/dev/{chunk-M2XQF7GS.js → chunk-NYLL7DNJ.js} +2 -2
- package/dist/dev/components/TTDDialog/CodeMirrorEditor-PY5ZVWKQ.js +259 -0
- package/dist/dev/components/TTDDialog/CodeMirrorEditor-PY5ZVWKQ.js.map +7 -0
- package/dist/dev/data/{image-2KXEDCIH.js → image-WSL7K3G4.js} +3 -3
- package/dist/dev/index.css +99 -22
- package/dist/dev/index.css.map +2 -2
- package/dist/dev/index.js +1469 -408
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-RZ6RNZOE.js → en-A3UOWEYW.js} +2 -2
- package/dist/dev/subset-shared.chunk.js +1 -1
- package/dist/dev/subset-worker.chunk.js +1 -1
- package/dist/prod/chunk-33L4EPXN.js +34 -0
- package/dist/prod/{chunk-GYMRTBHM.js → chunk-DF5Y7EC7.js} +5 -5
- package/dist/prod/{chunk-V7CARC7D.js → chunk-ZV7TQH6J.js} +1 -1
- package/dist/prod/components/TTDDialog/CodeMirrorEditor-M5ZUJBXD.js +1 -0
- package/dist/prod/data/image-57VVPCM3.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +32 -24
- package/dist/prod/locales/{en-XBJ4S4YK.js → en-QI57FMQH.js} +1 -1
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/element/src/arrowheads.d.ts +3 -0
- package/dist/types/element/src/bounds.d.ts +1 -1
- package/dist/types/element/src/index.d.ts +1 -0
- package/dist/types/element/src/linearElementEditor.d.ts +2 -2
- package/dist/types/element/src/selection.d.ts +5 -1
- package/dist/types/element/src/shape.d.ts +1 -1
- package/dist/types/element/src/textElement.d.ts +1 -1
- package/dist/types/element/src/textWrapping.d.ts +26 -0
- package/dist/types/element/src/types.d.ts +4 -1
- package/dist/types/element/src/utils.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +10 -10
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionExport.d.ts +5 -4
- package/dist/types/excalidraw/actions/actionFrame.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionGroup.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionLink.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionProperties.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionStyles.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +1 -1
- package/dist/types/excalidraw/components/App.d.ts +11 -0
- package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
- package/dist/types/excalidraw/components/Range.d.ts +10 -4
- package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +4 -1
- package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
- package/dist/types/excalidraw/components/icons.d.ts +17 -8
- package/dist/types/excalidraw/data/blob.d.ts +2 -2
- package/dist/types/excalidraw/data/json.d.ts +1 -1
- package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
- package/dist/types/excalidraw/types.d.ts +3 -2
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +5 -1
- package/dist/types/math/src/point.d.ts +1 -1
- package/package.json +7 -2
- package/dist/dev/chunk-K532CM3P.js.map +0 -7
- package/dist/dev/chunk-M4JV7MPJ.js.map +0 -7
- package/dist/prod/chunk-FARSR7T2.js +0 -33
- package/dist/prod/data/image-P4TPEGR7.js +0 -1
- /package/dist/dev/{chunk-M2XQF7GS.js.map → chunk-NYLL7DNJ.js.map} +0 -0
- /package/dist/dev/data/{image-2KXEDCIH.js.map → image-WSL7K3G4.js.map} +0 -0
- /package/dist/dev/locales/{en-RZ6RNZOE.js.map → en-A3UOWEYW.js.map} +0 -0
package/dist/dev/index.js
CHANGED
|
@@ -183,9 +183,11 @@ import {
|
|
|
183
183
|
frameAndChildrenSelectedTogether,
|
|
184
184
|
frameClip,
|
|
185
185
|
generateIdFromFile,
|
|
186
|
+
getActiveTextElement,
|
|
186
187
|
getAllColorsSpecificShade,
|
|
187
188
|
getApproxMinLineHeight,
|
|
188
189
|
getApproxMinLineWidth,
|
|
190
|
+
getArrowheadForPicker,
|
|
189
191
|
getBoundTextElement,
|
|
190
192
|
getBoundTextElementId,
|
|
191
193
|
getBoundTextMaxHeight,
|
|
@@ -238,6 +240,7 @@ import {
|
|
|
238
240
|
getInitializedImageElements,
|
|
239
241
|
getLineHeight,
|
|
240
242
|
getLineHeightInPx,
|
|
243
|
+
getLineWidth,
|
|
241
244
|
getLinearElementSubType,
|
|
242
245
|
getLinkDirectionFromKey,
|
|
243
246
|
getLinkHandleFromCoords,
|
|
@@ -276,6 +279,7 @@ import {
|
|
|
276
279
|
getUncroppedWidthAndHeight,
|
|
277
280
|
getVisibleAndNonSelectedElements,
|
|
278
281
|
getVisibleSceneBounds,
|
|
282
|
+
getWrappedTextLines,
|
|
279
283
|
groupByFrameLikes,
|
|
280
284
|
handleBindTextResize,
|
|
281
285
|
handleFocusPointDrag,
|
|
@@ -352,6 +356,7 @@ import {
|
|
|
352
356
|
isPointInElement,
|
|
353
357
|
isProdEnv,
|
|
354
358
|
isPromiseLike,
|
|
359
|
+
isRTL,
|
|
355
360
|
isSafari,
|
|
356
361
|
isSelectedViaGroup,
|
|
357
362
|
isSelectionLikeTool,
|
|
@@ -504,13 +509,13 @@ import {
|
|
|
504
509
|
viewportCoordsToSceneCoords,
|
|
505
510
|
wrapEvent,
|
|
506
511
|
wrapText
|
|
507
|
-
} from "./chunk-
|
|
512
|
+
} from "./chunk-JBODKHIT.js";
|
|
508
513
|
import {
|
|
509
514
|
define_import_meta_env_default
|
|
510
|
-
} from "./chunk-
|
|
515
|
+
} from "./chunk-NYLL7DNJ.js";
|
|
511
516
|
import {
|
|
512
517
|
en_default
|
|
513
|
-
} from "./chunk-
|
|
518
|
+
} from "./chunk-EWKWI3K7.js";
|
|
514
519
|
import {
|
|
515
520
|
percentages_default
|
|
516
521
|
} from "./chunk-URPEKBQ3.js";
|
|
@@ -627,7 +632,7 @@ var globImport_locales_json = __glob({
|
|
|
627
632
|
"./locales/de-CH.json": () => import("./locales/de-CH-GCXOD4LK.js"),
|
|
628
633
|
"./locales/de-DE.json": () => import("./locales/de-DE-CGDBECYD.js"),
|
|
629
634
|
"./locales/el-GR.json": () => import("./locales/el-GR-G5QZC24A.js"),
|
|
630
|
-
"./locales/en.json": () => import("./locales/en-
|
|
635
|
+
"./locales/en.json": () => import("./locales/en-A3UOWEYW.js"),
|
|
631
636
|
"./locales/es-ES.json": () => import("./locales/es-ES-UMEOH76W.js"),
|
|
632
637
|
"./locales/eu-ES.json": () => import("./locales/eu-ES-IWRZXJC5.js"),
|
|
633
638
|
"./locales/fa-IR.json": () => import("./locales/fa-IR-QOYVIIJA.js"),
|
|
@@ -812,11 +817,14 @@ __export(icons_exports, {
|
|
|
812
817
|
ArrowRightIcon: () => ArrowRightIcon,
|
|
813
818
|
ArrowheadArrowIcon: () => ArrowheadArrowIcon,
|
|
814
819
|
ArrowheadBarIcon: () => ArrowheadBarIcon,
|
|
820
|
+
ArrowheadCardinalityExactlyOneIcon: () => ArrowheadCardinalityExactlyOneIcon,
|
|
821
|
+
ArrowheadCardinalityManyIcon: () => ArrowheadCardinalityManyIcon,
|
|
822
|
+
ArrowheadCardinalityOneIcon: () => ArrowheadCardinalityOneIcon,
|
|
823
|
+
ArrowheadCardinalityOneOrManyIcon: () => ArrowheadCardinalityOneOrManyIcon,
|
|
824
|
+
ArrowheadCardinalityZeroOrManyIcon: () => ArrowheadCardinalityZeroOrManyIcon,
|
|
825
|
+
ArrowheadCardinalityZeroOrOneIcon: () => ArrowheadCardinalityZeroOrOneIcon,
|
|
815
826
|
ArrowheadCircleIcon: () => ArrowheadCircleIcon,
|
|
816
827
|
ArrowheadCircleOutlineIcon: () => ArrowheadCircleOutlineIcon,
|
|
817
|
-
ArrowheadCrowfootIcon: () => ArrowheadCrowfootIcon,
|
|
818
|
-
ArrowheadCrowfootOneIcon: () => ArrowheadCrowfootOneIcon,
|
|
819
|
-
ArrowheadCrowfootOneOrManyIcon: () => ArrowheadCrowfootOneOrManyIcon,
|
|
820
828
|
ArrowheadDiamondIcon: () => ArrowheadDiamondIcon,
|
|
821
829
|
ArrowheadDiamondOutlineIcon: () => ArrowheadDiamondOutlineIcon,
|
|
822
830
|
ArrowheadNoneIcon: () => ArrowheadNoneIcon,
|
|
@@ -1049,6 +1057,10 @@ var modifiedTablerIconProps = {
|
|
|
1049
1057
|
strokeLinecap: "round",
|
|
1050
1058
|
strokeLinejoin: "round"
|
|
1051
1059
|
};
|
|
1060
|
+
var arrowheadPreviewIconProps = {
|
|
1061
|
+
width: 40,
|
|
1062
|
+
height: 20
|
|
1063
|
+
};
|
|
1052
1064
|
var HomeIcon = createIcon(
|
|
1053
1065
|
/* @__PURE__ */ jsxs("g", { strokeWidth: 1.5, children: [
|
|
1054
1066
|
/* @__PURE__ */ jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
@@ -2242,39 +2254,39 @@ var ArrowheadNoneIcon = React.memo(
|
|
|
2242
2254
|
/* @__PURE__ */ jsxs(
|
|
2243
2255
|
"g",
|
|
2244
2256
|
{
|
|
2245
|
-
transform: flip ? "translate(
|
|
2257
|
+
transform: flip ? "translate(40, 0) scale(-1, 1)" : "",
|
|
2246
2258
|
stroke: "currentColor",
|
|
2247
2259
|
opacity: 0.3,
|
|
2248
2260
|
strokeWidth: 2,
|
|
2261
|
+
fill: "none",
|
|
2262
|
+
strokeLinecap: "round",
|
|
2249
2263
|
children: [
|
|
2250
|
-
/* @__PURE__ */ jsx("path", { d: "
|
|
2251
|
-
/* @__PURE__ */ jsx("path", { d: "
|
|
2252
|
-
/* @__PURE__ */ jsx("path", { d: "M21 15l-6 -6" })
|
|
2264
|
+
/* @__PURE__ */ jsx("path", { d: "M7,11 H19" }),
|
|
2265
|
+
/* @__PURE__ */ jsx("path", { d: "M25,6 L33,16 M33,6 L25,16" })
|
|
2253
2266
|
]
|
|
2254
2267
|
}
|
|
2255
2268
|
),
|
|
2256
|
-
|
|
2269
|
+
arrowheadPreviewIconProps
|
|
2257
2270
|
)
|
|
2258
2271
|
);
|
|
2259
2272
|
var ArrowheadArrowIcon = React.memo(
|
|
2260
2273
|
({ flip = false }) => createIcon(
|
|
2261
|
-
/* @__PURE__ */
|
|
2274
|
+
/* @__PURE__ */ jsx(
|
|
2262
2275
|
"g",
|
|
2263
2276
|
{
|
|
2264
2277
|
transform: flip ? "translate(40, 0) scale(-1, 1)" : "",
|
|
2265
2278
|
stroke: "currentColor",
|
|
2266
2279
|
strokeWidth: 2,
|
|
2267
2280
|
fill: "none",
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
]
|
|
2281
|
+
strokeLinecap: "round",
|
|
2282
|
+
strokeLinejoin: "round",
|
|
2283
|
+
children: /* @__PURE__ */ jsx("path", { d: "M7,11 H33 M23,5 L33,11 L23,17" })
|
|
2272
2284
|
}
|
|
2273
2285
|
),
|
|
2274
|
-
|
|
2286
|
+
arrowheadPreviewIconProps
|
|
2275
2287
|
)
|
|
2276
2288
|
);
|
|
2277
|
-
var
|
|
2289
|
+
var ArrowheadTriangleIcon = React.memo(
|
|
2278
2290
|
({ flip = false }) => createIcon(
|
|
2279
2291
|
/* @__PURE__ */ jsxs(
|
|
2280
2292
|
"g",
|
|
@@ -2282,16 +2294,17 @@ var ArrowheadCircleIcon = React.memo(
|
|
|
2282
2294
|
stroke: "currentColor",
|
|
2283
2295
|
fill: "currentColor",
|
|
2284
2296
|
transform: flip ? "translate(40, 0) scale(-1, 1)" : "",
|
|
2297
|
+
strokeLinejoin: "round",
|
|
2285
2298
|
children: [
|
|
2286
|
-
/* @__PURE__ */ jsx("path", { d: "
|
|
2287
|
-
/* @__PURE__ */ jsx("
|
|
2299
|
+
/* @__PURE__ */ jsx("path", { d: "M7,11 H23", strokeWidth: 2, strokeLinecap: "round" }),
|
|
2300
|
+
/* @__PURE__ */ jsx("path", { d: "M23,5 L35,11 L23,17 Z" })
|
|
2288
2301
|
]
|
|
2289
2302
|
}
|
|
2290
2303
|
),
|
|
2291
|
-
|
|
2304
|
+
arrowheadPreviewIconProps
|
|
2292
2305
|
)
|
|
2293
2306
|
);
|
|
2294
|
-
var
|
|
2307
|
+
var ArrowheadTriangleOutlineIcon = React.memo(
|
|
2295
2308
|
({ flip = false }) => createIcon(
|
|
2296
2309
|
/* @__PURE__ */ jsxs(
|
|
2297
2310
|
"g",
|
|
@@ -2300,30 +2313,18 @@ var ArrowheadCircleOutlineIcon = React.memo(
|
|
|
2300
2313
|
fill: "none",
|
|
2301
2314
|
transform: flip ? "translate(40, 0) scale(-1, 1)" : "",
|
|
2302
2315
|
strokeWidth: 2,
|
|
2316
|
+
strokeLinejoin: "round",
|
|
2317
|
+
strokeLinecap: "round",
|
|
2303
2318
|
children: [
|
|
2304
|
-
/* @__PURE__ */ jsx("path", { d: "
|
|
2305
|
-
/* @__PURE__ */ jsx("
|
|
2319
|
+
/* @__PURE__ */ jsx("path", { d: "M7,11 H23" }),
|
|
2320
|
+
/* @__PURE__ */ jsx("path", { d: "M23,5 L35,11 L23,17 Z" })
|
|
2306
2321
|
]
|
|
2307
2322
|
}
|
|
2308
2323
|
),
|
|
2309
|
-
|
|
2324
|
+
arrowheadPreviewIconProps
|
|
2310
2325
|
)
|
|
2311
2326
|
);
|
|
2312
|
-
var
|
|
2313
|
-
({ flip = false }) => createIcon(
|
|
2314
|
-
/* @__PURE__ */ jsx("g", { transform: flip ? "translate(40, 0) scale(-1, 1)" : "", children: /* @__PURE__ */ jsx(
|
|
2315
|
-
"path",
|
|
2316
|
-
{
|
|
2317
|
-
d: "M34 10H5.99996M34 10L34 5M34 10L34 15",
|
|
2318
|
-
stroke: "currentColor",
|
|
2319
|
-
strokeWidth: 2,
|
|
2320
|
-
fill: "none"
|
|
2321
|
-
}
|
|
2322
|
-
) }),
|
|
2323
|
-
{ width: 40, height: 20 }
|
|
2324
|
-
)
|
|
2325
|
-
);
|
|
2326
|
-
var ArrowheadTriangleIcon = React.memo(
|
|
2327
|
+
var ArrowheadCircleIcon = React.memo(
|
|
2327
2328
|
({ flip = false }) => createIcon(
|
|
2328
2329
|
/* @__PURE__ */ jsxs(
|
|
2329
2330
|
"g",
|
|
@@ -2332,15 +2333,15 @@ var ArrowheadTriangleIcon = React.memo(
|
|
|
2332
2333
|
fill: "currentColor",
|
|
2333
2334
|
transform: flip ? "translate(40, 0) scale(-1, 1)" : "",
|
|
2334
2335
|
children: [
|
|
2335
|
-
/* @__PURE__ */ jsx("path", { d: "
|
|
2336
|
-
/* @__PURE__ */ jsx("
|
|
2336
|
+
/* @__PURE__ */ jsx("path", { d: "M7,11 H25", strokeWidth: 2, strokeLinecap: "round" }),
|
|
2337
|
+
/* @__PURE__ */ jsx("circle", { cx: "29", cy: "11", r: "4" })
|
|
2337
2338
|
]
|
|
2338
2339
|
}
|
|
2339
2340
|
),
|
|
2340
|
-
|
|
2341
|
+
arrowheadPreviewIconProps
|
|
2341
2342
|
)
|
|
2342
2343
|
);
|
|
2343
|
-
var
|
|
2344
|
+
var ArrowheadCircleOutlineIcon = React.memo(
|
|
2344
2345
|
({ flip = false }) => createIcon(
|
|
2345
2346
|
/* @__PURE__ */ jsxs(
|
|
2346
2347
|
"g",
|
|
@@ -2349,14 +2350,13 @@ var ArrowheadTriangleOutlineIcon = React.memo(
|
|
|
2349
2350
|
fill: "none",
|
|
2350
2351
|
transform: flip ? "translate(40, 0) scale(-1, 1)" : "",
|
|
2351
2352
|
strokeWidth: 2,
|
|
2352
|
-
strokeLinejoin: "round",
|
|
2353
2353
|
children: [
|
|
2354
|
-
/* @__PURE__ */ jsx("path", { d: "
|
|
2355
|
-
/* @__PURE__ */ jsx("
|
|
2354
|
+
/* @__PURE__ */ jsx("path", { d: "M7,11 H25", strokeLinecap: "round" }),
|
|
2355
|
+
/* @__PURE__ */ jsx("circle", { cx: "29", cy: "11", r: "4" })
|
|
2356
2356
|
]
|
|
2357
2357
|
}
|
|
2358
2358
|
),
|
|
2359
|
-
|
|
2359
|
+
arrowheadPreviewIconProps
|
|
2360
2360
|
)
|
|
2361
2361
|
);
|
|
2362
2362
|
var ArrowheadDiamondIcon = React.memo(
|
|
@@ -2368,14 +2368,13 @@ var ArrowheadDiamondIcon = React.memo(
|
|
|
2368
2368
|
fill: "currentColor",
|
|
2369
2369
|
transform: flip ? "translate(40, 0) scale(-1, 1)" : "",
|
|
2370
2370
|
strokeLinejoin: "round",
|
|
2371
|
-
strokeWidth: 2,
|
|
2372
2371
|
children: [
|
|
2373
|
-
/* @__PURE__ */ jsx("path", { d: "
|
|
2374
|
-
/* @__PURE__ */ jsx("path", { d: "
|
|
2372
|
+
/* @__PURE__ */ jsx("path", { d: "M7,11 H21", strokeWidth: 2, strokeLinecap: "round" }),
|
|
2373
|
+
/* @__PURE__ */ jsx("path", { d: "M21,11 L28,5 L35,11 L28,17 Z" })
|
|
2375
2374
|
]
|
|
2376
2375
|
}
|
|
2377
2376
|
),
|
|
2378
|
-
|
|
2377
|
+
arrowheadPreviewIconProps
|
|
2379
2378
|
)
|
|
2380
2379
|
);
|
|
2381
2380
|
var ArrowheadDiamondOutlineIcon = React.memo(
|
|
@@ -2388,16 +2387,33 @@ var ArrowheadDiamondOutlineIcon = React.memo(
|
|
|
2388
2387
|
transform: flip ? "translate(40, 0) scale(-1, 1)" : "",
|
|
2389
2388
|
strokeLinejoin: "round",
|
|
2390
2389
|
strokeWidth: 2,
|
|
2390
|
+
strokeLinecap: "round",
|
|
2391
2391
|
children: [
|
|
2392
|
-
/* @__PURE__ */ jsx("path", { d: "
|
|
2393
|
-
/* @__PURE__ */ jsx("path", { d: "
|
|
2392
|
+
/* @__PURE__ */ jsx("path", { d: "M7,11 H21" }),
|
|
2393
|
+
/* @__PURE__ */ jsx("path", { d: "M21,11 L28,5 L35,11 L28,17 Z" })
|
|
2394
2394
|
]
|
|
2395
2395
|
}
|
|
2396
2396
|
),
|
|
2397
|
-
|
|
2397
|
+
arrowheadPreviewIconProps
|
|
2398
2398
|
)
|
|
2399
2399
|
);
|
|
2400
|
-
var
|
|
2400
|
+
var ArrowheadBarIcon = React.memo(
|
|
2401
|
+
({ flip = false }) => createIcon(
|
|
2402
|
+
/* @__PURE__ */ jsx(
|
|
2403
|
+
"g",
|
|
2404
|
+
{
|
|
2405
|
+
transform: flip ? "translate(40, 0) scale(-1, 1)" : "",
|
|
2406
|
+
stroke: "currentColor",
|
|
2407
|
+
strokeWidth: 2,
|
|
2408
|
+
fill: "none",
|
|
2409
|
+
strokeLinecap: "round",
|
|
2410
|
+
children: /* @__PURE__ */ jsx("path", { d: "M11,11 H31 M31,5 V17" })
|
|
2411
|
+
}
|
|
2412
|
+
),
|
|
2413
|
+
arrowheadPreviewIconProps
|
|
2414
|
+
)
|
|
2415
|
+
);
|
|
2416
|
+
var ArrowheadCardinalityOneIcon = React.memo(
|
|
2401
2417
|
({ flip = false }) => createIcon(
|
|
2402
2418
|
/* @__PURE__ */ jsx(
|
|
2403
2419
|
"g",
|
|
@@ -2407,13 +2423,13 @@ var ArrowheadCrowfootIcon = React.memo(
|
|
|
2407
2423
|
transform: flip ? "" : "translate(40, 0) scale(-1, 1)",
|
|
2408
2424
|
strokeLinejoin: "round",
|
|
2409
2425
|
strokeWidth: 2,
|
|
2410
|
-
children: /* @__PURE__ */ jsx("path", { d: "
|
|
2426
|
+
children: /* @__PURE__ */ jsx("path", { d: "M35,11 H7 M15,5 V17" })
|
|
2411
2427
|
}
|
|
2412
2428
|
),
|
|
2413
|
-
|
|
2429
|
+
arrowheadPreviewIconProps
|
|
2414
2430
|
)
|
|
2415
2431
|
);
|
|
2416
|
-
var
|
|
2432
|
+
var ArrowheadCardinalityManyIcon = React.memo(
|
|
2417
2433
|
({ flip = false }) => createIcon(
|
|
2418
2434
|
/* @__PURE__ */ jsx(
|
|
2419
2435
|
"g",
|
|
@@ -2423,13 +2439,13 @@ var ArrowheadCrowfootOneIcon = React.memo(
|
|
|
2423
2439
|
transform: flip ? "" : "translate(40, 0) scale(-1, 1)",
|
|
2424
2440
|
strokeLinejoin: "round",
|
|
2425
2441
|
strokeWidth: 2,
|
|
2426
|
-
children: /* @__PURE__ */ jsx("path", { d: "
|
|
2442
|
+
children: /* @__PURE__ */ jsx("path", { d: "M35,11 H7 M15,11 L7,5 M15,11 L7,17" })
|
|
2427
2443
|
}
|
|
2428
2444
|
),
|
|
2429
|
-
|
|
2445
|
+
arrowheadPreviewIconProps
|
|
2430
2446
|
)
|
|
2431
2447
|
);
|
|
2432
|
-
var
|
|
2448
|
+
var ArrowheadCardinalityOneOrManyIcon = React.memo(
|
|
2433
2449
|
({ flip = false }) => createIcon(
|
|
2434
2450
|
/* @__PURE__ */ jsx(
|
|
2435
2451
|
"g",
|
|
@@ -2439,10 +2455,64 @@ var ArrowheadCrowfootOneOrManyIcon = React.memo(
|
|
|
2439
2455
|
transform: flip ? "" : "translate(40, 0) scale(-1, 1)",
|
|
2440
2456
|
strokeLinejoin: "round",
|
|
2441
2457
|
strokeWidth: 2,
|
|
2442
|
-
children: /* @__PURE__ */ jsx("path", { d: "
|
|
2458
|
+
children: /* @__PURE__ */ jsx("path", { d: "M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17" })
|
|
2459
|
+
}
|
|
2460
|
+
),
|
|
2461
|
+
arrowheadPreviewIconProps
|
|
2462
|
+
)
|
|
2463
|
+
);
|
|
2464
|
+
var ArrowheadCardinalityExactlyOneIcon = React.memo(
|
|
2465
|
+
({ flip = false }) => createIcon(
|
|
2466
|
+
/* @__PURE__ */ jsx(
|
|
2467
|
+
"g",
|
|
2468
|
+
{
|
|
2469
|
+
stroke: "currentColor",
|
|
2470
|
+
fill: "none",
|
|
2471
|
+
transform: flip ? "" : "translate(40, 0) scale(-1, 1)",
|
|
2472
|
+
strokeLinejoin: "round",
|
|
2473
|
+
strokeWidth: 2,
|
|
2474
|
+
children: /* @__PURE__ */ jsx("path", { d: "M35,11 H7 M15,5 V17 M7,5 V17" })
|
|
2475
|
+
}
|
|
2476
|
+
),
|
|
2477
|
+
arrowheadPreviewIconProps
|
|
2478
|
+
)
|
|
2479
|
+
);
|
|
2480
|
+
var ArrowheadCardinalityZeroOrOneIcon = React.memo(
|
|
2481
|
+
({ flip = false }) => createIcon(
|
|
2482
|
+
/* @__PURE__ */ jsxs(
|
|
2483
|
+
"g",
|
|
2484
|
+
{
|
|
2485
|
+
stroke: "currentColor",
|
|
2486
|
+
fill: "none",
|
|
2487
|
+
transform: flip ? "" : "translate(40, 0) scale(-1, 1)",
|
|
2488
|
+
strokeLinejoin: "round",
|
|
2489
|
+
strokeWidth: 2,
|
|
2490
|
+
children: [
|
|
2491
|
+
/* @__PURE__ */ jsx("path", { d: "M35,11 H19 M11,11 H7 M7,5 V17" }),
|
|
2492
|
+
/* @__PURE__ */ jsx("circle", { cx: "15", cy: "11", r: "4" })
|
|
2493
|
+
]
|
|
2443
2494
|
}
|
|
2444
2495
|
),
|
|
2445
|
-
|
|
2496
|
+
arrowheadPreviewIconProps
|
|
2497
|
+
)
|
|
2498
|
+
);
|
|
2499
|
+
var ArrowheadCardinalityZeroOrManyIcon = React.memo(
|
|
2500
|
+
({ flip = false }) => createIcon(
|
|
2501
|
+
/* @__PURE__ */ jsxs(
|
|
2502
|
+
"g",
|
|
2503
|
+
{
|
|
2504
|
+
stroke: "currentColor",
|
|
2505
|
+
fill: "none",
|
|
2506
|
+
transform: flip ? "" : "translate(40, 0) scale(-1, 1)",
|
|
2507
|
+
strokeLinejoin: "round",
|
|
2508
|
+
strokeWidth: 2,
|
|
2509
|
+
children: [
|
|
2510
|
+
/* @__PURE__ */ jsx("path", { d: "M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17" }),
|
|
2511
|
+
/* @__PURE__ */ jsx("circle", { cx: "23", cy: "11", r: "4" })
|
|
2512
|
+
]
|
|
2513
|
+
}
|
|
2514
|
+
),
|
|
2515
|
+
arrowheadPreviewIconProps
|
|
2446
2516
|
)
|
|
2447
2517
|
);
|
|
2448
2518
|
var FontSizeSmallIcon = createIcon(
|
|
@@ -3997,7 +4067,7 @@ var actionDuplicateSelection = register({
|
|
|
3997
4067
|
});
|
|
3998
4068
|
|
|
3999
4069
|
// actions/actionProperties.tsx
|
|
4000
|
-
import { useEffect as useEffect13, useMemo as
|
|
4070
|
+
import { useEffect as useEffect13, useMemo as useMemo4, useRef as useRef10, useState as useState7 } from "react";
|
|
4001
4071
|
|
|
4002
4072
|
// analytics.ts
|
|
4003
4073
|
var ALLOWED_CATEGORIES_TO_TRACK = /* @__PURE__ */ new Set(["command_palette", "export"]);
|
|
@@ -6201,7 +6271,7 @@ var FontPicker = React11.memo(
|
|
|
6201
6271
|
// components/IconPicker.tsx
|
|
6202
6272
|
import { Popover as Popover5 } from "radix-ui";
|
|
6203
6273
|
import clsx16 from "clsx";
|
|
6204
|
-
import React12, { useEffect as useEffect11 } from "react";
|
|
6274
|
+
import React12, { useEffect as useEffect11, useMemo as useMemo3 } from "react";
|
|
6205
6275
|
|
|
6206
6276
|
// components/InlineIcon.tsx
|
|
6207
6277
|
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
@@ -6264,50 +6334,108 @@ var Collapsible_default = Collapsible;
|
|
|
6264
6334
|
// components/IconPicker.tsx
|
|
6265
6335
|
import { jsx as jsx32, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
6266
6336
|
var moreOptionsAtom = atom(false);
|
|
6337
|
+
var PICKER_COLUMNS = 4;
|
|
6338
|
+
var DEFAULT_SECTION_NAME = "default";
|
|
6339
|
+
var flattenOptions = (sections) => sections.flatMap((section) => section.options);
|
|
6340
|
+
var findOption = (sections, predicate) => {
|
|
6341
|
+
for (const section of sections) {
|
|
6342
|
+
const option = section.options.find(predicate);
|
|
6343
|
+
if (option) {
|
|
6344
|
+
return option;
|
|
6345
|
+
}
|
|
6346
|
+
}
|
|
6347
|
+
return null;
|
|
6348
|
+
};
|
|
6349
|
+
var hasOption = (sections, predicate) => sections.some((section) => section.options.some(predicate));
|
|
6350
|
+
var getNavigationRows = (sections) => sections.flatMap(
|
|
6351
|
+
(section) => Array.from(
|
|
6352
|
+
{ length: Math.ceil(section.options.length / PICKER_COLUMNS) },
|
|
6353
|
+
(_, index) => section.options.slice(
|
|
6354
|
+
index * PICKER_COLUMNS,
|
|
6355
|
+
index * PICKER_COLUMNS + PICKER_COLUMNS
|
|
6356
|
+
)
|
|
6357
|
+
)
|
|
6358
|
+
);
|
|
6267
6359
|
function Picker2({
|
|
6268
|
-
|
|
6360
|
+
visibleSections,
|
|
6361
|
+
hiddenSections = [],
|
|
6269
6362
|
value,
|
|
6270
6363
|
label,
|
|
6271
6364
|
onChange,
|
|
6272
|
-
onClose
|
|
6273
|
-
numberOfOptionsToAlwaysShow = options.length
|
|
6365
|
+
onClose
|
|
6274
6366
|
}) {
|
|
6275
|
-
const editorInterface = useEditorInterface();
|
|
6276
6367
|
const { container } = useExcalidrawContainer();
|
|
6368
|
+
const [showMoreOptions, setShowMoreOptions] = useAtom(moreOptionsAtom);
|
|
6369
|
+
const allSections = [...visibleSections, ...hiddenSections];
|
|
6370
|
+
const allOptions = flattenOptions(allSections);
|
|
6371
|
+
const navigationRows = getNavigationRows([
|
|
6372
|
+
...visibleSections,
|
|
6373
|
+
...showMoreOptions ? hiddenSections : []
|
|
6374
|
+
]);
|
|
6277
6375
|
const handleKeyDown = (event) => {
|
|
6278
|
-
const pressedOption =
|
|
6376
|
+
const pressedOption = allOptions.find(
|
|
6279
6377
|
(option) => option.keyBinding === event.key.toLowerCase()
|
|
6280
6378
|
);
|
|
6281
6379
|
if (!(event.metaKey || event.altKey || event.ctrlKey) && pressedOption) {
|
|
6282
6380
|
onChange(pressedOption.value);
|
|
6283
6381
|
event.preventDefault();
|
|
6284
6382
|
} else if (event.key === KEYS.TAB) {
|
|
6285
|
-
const index =
|
|
6286
|
-
const nextIndex = event.shiftKey ? (
|
|
6287
|
-
onChange(
|
|
6383
|
+
const index = allOptions.findIndex((option) => option.value === value);
|
|
6384
|
+
const nextIndex = event.shiftKey ? (allOptions.length + index - 1) % allOptions.length : (index + 1) % allOptions.length;
|
|
6385
|
+
onChange(allOptions[nextIndex].value);
|
|
6288
6386
|
} else if (isArrowKey(event.key)) {
|
|
6289
|
-
const
|
|
6290
|
-
const index =
|
|
6387
|
+
const isRTL2 = getLanguage().rtl;
|
|
6388
|
+
const index = allOptions.findIndex((option) => option.value === value);
|
|
6291
6389
|
if (index !== -1) {
|
|
6292
|
-
const length =
|
|
6390
|
+
const length = allOptions.length;
|
|
6293
6391
|
let nextIndex = index;
|
|
6294
6392
|
switch (event.key) {
|
|
6295
|
-
case (
|
|
6393
|
+
case (isRTL2 ? KEYS.ARROW_LEFT : KEYS.ARROW_RIGHT):
|
|
6296
6394
|
nextIndex = (index + 1) % length;
|
|
6297
6395
|
break;
|
|
6298
|
-
case (
|
|
6396
|
+
case (isRTL2 ? KEYS.ARROW_RIGHT : KEYS.ARROW_LEFT):
|
|
6299
6397
|
nextIndex = (length + index - 1) % length;
|
|
6300
6398
|
break;
|
|
6301
6399
|
case KEYS.ARROW_DOWN: {
|
|
6302
|
-
|
|
6400
|
+
const currentRowIndex = navigationRows.findIndex(
|
|
6401
|
+
(row) => row.some((option) => option.value === value)
|
|
6402
|
+
);
|
|
6403
|
+
const currentRow = navigationRows[currentRowIndex];
|
|
6404
|
+
if (currentRowIndex !== -1 && currentRow) {
|
|
6405
|
+
const column = currentRow.findIndex(
|
|
6406
|
+
(option) => option.value === value
|
|
6407
|
+
);
|
|
6408
|
+
const nextRow = navigationRows[(currentRowIndex + 1) % navigationRows.length];
|
|
6409
|
+
const nextOption = nextRow[Math.min(column, nextRow.length - 1)] ?? allOptions[index];
|
|
6410
|
+
onChange(nextOption.value);
|
|
6411
|
+
event.preventDefault();
|
|
6412
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
6413
|
+
event.stopPropagation();
|
|
6414
|
+
return;
|
|
6415
|
+
}
|
|
6303
6416
|
break;
|
|
6304
6417
|
}
|
|
6305
6418
|
case KEYS.ARROW_UP: {
|
|
6306
|
-
|
|
6419
|
+
const currentRowIndex = navigationRows.findIndex(
|
|
6420
|
+
(row) => row.some((option) => option.value === value)
|
|
6421
|
+
);
|
|
6422
|
+
const currentRow = navigationRows[currentRowIndex];
|
|
6423
|
+
if (currentRowIndex !== -1 && currentRow) {
|
|
6424
|
+
const column = currentRow.findIndex(
|
|
6425
|
+
(option) => option.value === value
|
|
6426
|
+
);
|
|
6427
|
+
const previousRow = navigationRows[(navigationRows.length + currentRowIndex - 1) % navigationRows.length];
|
|
6428
|
+
const previousOption = previousRow[Math.min(column, previousRow.length - 1)] ?? allOptions[index];
|
|
6429
|
+
onChange(previousOption.value);
|
|
6430
|
+
event.preventDefault();
|
|
6431
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
6432
|
+
event.stopPropagation();
|
|
6433
|
+
return;
|
|
6434
|
+
}
|
|
6307
6435
|
break;
|
|
6308
6436
|
}
|
|
6309
6437
|
}
|
|
6310
|
-
onChange(
|
|
6438
|
+
onChange(allOptions[nextIndex].value);
|
|
6311
6439
|
}
|
|
6312
6440
|
event.preventDefault();
|
|
6313
6441
|
} else if (event.key === KEYS.ESCAPE || event.key === KEYS.ENTER) {
|
|
@@ -6317,32 +6445,23 @@ function Picker2({
|
|
|
6317
6445
|
event.nativeEvent.stopImmediatePropagation();
|
|
6318
6446
|
event.stopPropagation();
|
|
6319
6447
|
};
|
|
6320
|
-
const [showMoreOptions, setShowMoreOptions] = useAtom(moreOptionsAtom);
|
|
6321
|
-
const alwaysVisibleOptions = React12.useMemo(
|
|
6322
|
-
() => options.slice(0, numberOfOptionsToAlwaysShow),
|
|
6323
|
-
[options, numberOfOptionsToAlwaysShow]
|
|
6324
|
-
);
|
|
6325
|
-
const moreOptions = React12.useMemo(
|
|
6326
|
-
() => options.slice(numberOfOptionsToAlwaysShow),
|
|
6327
|
-
[options, numberOfOptionsToAlwaysShow]
|
|
6328
|
-
);
|
|
6329
6448
|
useEffect11(() => {
|
|
6330
|
-
if (
|
|
6449
|
+
if (hasOption(hiddenSections, (option) => option.value === value)) {
|
|
6331
6450
|
setShowMoreOptions(true);
|
|
6332
6451
|
}
|
|
6333
|
-
}, [value,
|
|
6334
|
-
const renderOptions = (
|
|
6335
|
-
return /* @__PURE__ */ jsx32("div", { className: "picker-content", children:
|
|
6452
|
+
}, [value, hiddenSections, setShowMoreOptions]);
|
|
6453
|
+
const renderOptions = (options) => {
|
|
6454
|
+
return /* @__PURE__ */ jsx32("div", { className: "picker-content", children: options.map((option) => /* @__PURE__ */ jsxs18(
|
|
6336
6455
|
"button",
|
|
6337
6456
|
{
|
|
6338
6457
|
type: "button",
|
|
6339
6458
|
className: clsx16("picker-option", {
|
|
6340
6459
|
active: value === option.value
|
|
6341
6460
|
}),
|
|
6342
|
-
onClick: (
|
|
6461
|
+
onClick: () => {
|
|
6343
6462
|
onChange(option.value);
|
|
6344
6463
|
},
|
|
6345
|
-
title: `${option.text}
|
|
6464
|
+
title: option.keyBinding ? `${option.text} \u2014 ${option.keyBinding.toUpperCase()}` : option.text,
|
|
6346
6465
|
"aria-label": option.text || "none",
|
|
6347
6466
|
"aria-keyshortcuts": option.keyBinding || void 0,
|
|
6348
6467
|
ref: (ref) => {
|
|
@@ -6360,77 +6479,78 @@ function Picker2({
|
|
|
6360
6479
|
option.text
|
|
6361
6480
|
)) });
|
|
6362
6481
|
};
|
|
6363
|
-
const
|
|
6482
|
+
const renderSections = (sections) => sections.map(
|
|
6483
|
+
(section, index) => section.name === DEFAULT_SECTION_NAME ? /* @__PURE__ */ jsx32(React12.Fragment, { children: renderOptions(section.options) }, `${section.name}-${index}`) : /* @__PURE__ */ jsxs18("div", { className: "picker-section", children: [
|
|
6484
|
+
/* @__PURE__ */ jsx32("div", { className: "picker-section-label", children: section.name }),
|
|
6485
|
+
renderOptions(section.options)
|
|
6486
|
+
] }, `${section.name}-${index}`)
|
|
6487
|
+
);
|
|
6364
6488
|
return /* @__PURE__ */ jsx32(
|
|
6365
6489
|
Popover5.Content,
|
|
6366
6490
|
{
|
|
6367
|
-
|
|
6491
|
+
className: "picker",
|
|
6492
|
+
role: "dialog",
|
|
6493
|
+
"aria-modal": "true",
|
|
6494
|
+
"aria-label": label,
|
|
6495
|
+
side: "bottom",
|
|
6368
6496
|
align: "start",
|
|
6369
|
-
sideOffset:
|
|
6497
|
+
sideOffset: 12,
|
|
6498
|
+
alignOffset: 12,
|
|
6370
6499
|
style: { zIndex: "var(--zIndex-ui-styles-popup)" },
|
|
6371
6500
|
onKeyDown: handleKeyDown,
|
|
6372
6501
|
collisionBoundary: container ?? void 0,
|
|
6373
|
-
children: /* @__PURE__ */ jsxs18(
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
setShowMoreOptions((value2) => !value2);
|
|
6389
|
-
},
|
|
6390
|
-
className: "picker-collapsible",
|
|
6391
|
-
children: renderOptions(moreOptions)
|
|
6392
|
-
}
|
|
6393
|
-
)
|
|
6394
|
-
]
|
|
6395
|
-
}
|
|
6396
|
-
)
|
|
6502
|
+
children: /* @__PURE__ */ jsxs18("div", { className: "picker-sections", children: [
|
|
6503
|
+
renderSections(visibleSections),
|
|
6504
|
+
hiddenSections.length > 0 && /* @__PURE__ */ jsx32(
|
|
6505
|
+
Collapsible_default,
|
|
6506
|
+
{
|
|
6507
|
+
label: t("labels.more_options"),
|
|
6508
|
+
open: showMoreOptions,
|
|
6509
|
+
openTrigger: () => {
|
|
6510
|
+
setShowMoreOptions((value2) => !value2);
|
|
6511
|
+
},
|
|
6512
|
+
className: "picker-collapsible",
|
|
6513
|
+
children: /* @__PURE__ */ jsx32("div", { className: "picker-sections", children: renderSections(hiddenSections) })
|
|
6514
|
+
}
|
|
6515
|
+
)
|
|
6516
|
+
] })
|
|
6397
6517
|
}
|
|
6398
6518
|
);
|
|
6399
6519
|
}
|
|
6400
6520
|
function IconPicker({
|
|
6401
6521
|
value,
|
|
6402
6522
|
label,
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
numberOfOptionsToAlwaysShow
|
|
6523
|
+
visibleSections,
|
|
6524
|
+
hiddenSections,
|
|
6525
|
+
onChange
|
|
6407
6526
|
}) {
|
|
6408
6527
|
const [isActive, setActive] = React12.useState(false);
|
|
6409
|
-
const
|
|
6528
|
+
const selectedOption = useMemo3(
|
|
6529
|
+
() => findOption(visibleSections, (option) => option.value === value) ?? findOption(hiddenSections ?? [], (option) => option.value === value),
|
|
6530
|
+
[visibleSections, hiddenSections, value]
|
|
6531
|
+
);
|
|
6410
6532
|
return /* @__PURE__ */ jsx32("div", { children: /* @__PURE__ */ jsxs18(Popover5.Root, { open: isActive, onOpenChange: (open) => setActive(open), children: [
|
|
6411
6533
|
/* @__PURE__ */ jsx32(
|
|
6412
6534
|
Popover5.Trigger,
|
|
6413
6535
|
{
|
|
6414
|
-
name: group,
|
|
6415
6536
|
type: "button",
|
|
6416
6537
|
"aria-label": label,
|
|
6417
6538
|
onClick: () => setActive(!isActive),
|
|
6418
|
-
ref: rPickerButton,
|
|
6419
6539
|
className: isActive ? "active" : "",
|
|
6420
|
-
children:
|
|
6540
|
+
children: selectedOption?.icon
|
|
6421
6541
|
}
|
|
6422
6542
|
),
|
|
6423
6543
|
isActive && /* @__PURE__ */ jsx32(
|
|
6424
6544
|
Picker2,
|
|
6425
6545
|
{
|
|
6426
|
-
|
|
6546
|
+
visibleSections,
|
|
6547
|
+
hiddenSections,
|
|
6427
6548
|
value,
|
|
6428
6549
|
label,
|
|
6429
6550
|
onChange,
|
|
6430
6551
|
onClose: () => {
|
|
6431
6552
|
setActive(false);
|
|
6432
|
-
}
|
|
6433
|
-
numberOfOptionsToAlwaysShow
|
|
6553
|
+
}
|
|
6434
6554
|
}
|
|
6435
6555
|
)
|
|
6436
6556
|
] }) });
|
|
@@ -6439,57 +6559,59 @@ function IconPicker({
|
|
|
6439
6559
|
// components/Range.tsx
|
|
6440
6560
|
import React13, { useEffect as useEffect12 } from "react";
|
|
6441
6561
|
import { jsx as jsx33, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
6442
|
-
var Range = ({
|
|
6562
|
+
var Range = ({
|
|
6563
|
+
label,
|
|
6564
|
+
value,
|
|
6565
|
+
onChange,
|
|
6566
|
+
min = 0,
|
|
6567
|
+
max = 100,
|
|
6568
|
+
step = 10,
|
|
6569
|
+
minLabel = min,
|
|
6570
|
+
hasCommonValue = true,
|
|
6571
|
+
testId
|
|
6572
|
+
}) => {
|
|
6443
6573
|
const rangeRef = React13.useRef(null);
|
|
6444
6574
|
const valueRef = React13.useRef(null);
|
|
6445
|
-
const selectedElements = app.scene.getSelectedElements(app.state);
|
|
6446
|
-
let hasCommonOpacity = true;
|
|
6447
|
-
const firstElement = selectedElements.at(0);
|
|
6448
|
-
const leastCommonOpacity = selectedElements.reduce((acc, element) => {
|
|
6449
|
-
if (acc != null && acc !== element.opacity) {
|
|
6450
|
-
hasCommonOpacity = false;
|
|
6451
|
-
}
|
|
6452
|
-
if (acc == null || acc > element.opacity) {
|
|
6453
|
-
return element.opacity;
|
|
6454
|
-
}
|
|
6455
|
-
return acc;
|
|
6456
|
-
}, firstElement?.opacity ?? null);
|
|
6457
|
-
const value = leastCommonOpacity ?? app.state.currentItemOpacity;
|
|
6458
6575
|
useEffect12(() => {
|
|
6459
6576
|
if (rangeRef.current && valueRef.current) {
|
|
6460
6577
|
const rangeElement = rangeRef.current;
|
|
6461
6578
|
const valueElement = valueRef.current;
|
|
6462
6579
|
const inputWidth = rangeElement.offsetWidth;
|
|
6463
|
-
const thumbWidth =
|
|
6464
|
-
|
|
6580
|
+
const thumbWidth = parseFloat(
|
|
6581
|
+
getComputedStyle(rangeElement).getPropertyValue(
|
|
6582
|
+
"--slider-thumb-size"
|
|
6583
|
+
)
|
|
6584
|
+
) || 16;
|
|
6585
|
+
const progress = (value - min) / (max - min || 1) * 100;
|
|
6586
|
+
const position = progress / 100 * (inputWidth - thumbWidth) + thumbWidth / 2;
|
|
6465
6587
|
valueElement.style.left = `${position}px`;
|
|
6466
|
-
rangeElement.style.background = `linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${
|
|
6588
|
+
rangeElement.style.background = `linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${progress}%, var(--button-bg) ${progress}%, var(--button-bg) 100%)`;
|
|
6467
6589
|
}
|
|
6468
|
-
}, [value]);
|
|
6590
|
+
}, [max, min, value]);
|
|
6469
6591
|
return /* @__PURE__ */ jsxs19("label", { className: "control-label", children: [
|
|
6470
|
-
|
|
6592
|
+
label,
|
|
6471
6593
|
/* @__PURE__ */ jsxs19("div", { className: "range-wrapper", children: [
|
|
6472
6594
|
/* @__PURE__ */ jsx33(
|
|
6473
6595
|
"input",
|
|
6474
6596
|
{
|
|
6475
6597
|
style: {
|
|
6476
|
-
["--color-slider-track"]:
|
|
6598
|
+
["--color-slider-track"]: hasCommonValue ? void 0 : "var(--button-bg)"
|
|
6477
6599
|
},
|
|
6478
6600
|
ref: rangeRef,
|
|
6479
6601
|
type: "range",
|
|
6480
|
-
min
|
|
6481
|
-
max
|
|
6482
|
-
step
|
|
6602
|
+
min,
|
|
6603
|
+
max,
|
|
6604
|
+
step,
|
|
6483
6605
|
onChange: (event) => {
|
|
6484
|
-
|
|
6606
|
+
onChange(+event.target.value);
|
|
6485
6607
|
},
|
|
6486
6608
|
value,
|
|
6487
6609
|
className: "range-input",
|
|
6488
6610
|
"data-testid": testId
|
|
6489
6611
|
}
|
|
6490
6612
|
),
|
|
6491
|
-
/* @__PURE__ */ jsx33("div", { className: "value-bubble", ref: valueRef, children: value !==
|
|
6492
|
-
/* @__PURE__ */ jsx33("div", { className: "zero-label", children:
|
|
6613
|
+
/* @__PURE__ */ jsx33("div", { className: "value-bubble", ref: valueRef, children: value !== min ? value : null }),
|
|
6614
|
+
/* @__PURE__ */ jsx33("div", { className: "zero-label", children: minLabel })
|
|
6493
6615
|
] })
|
|
6494
6616
|
] });
|
|
6495
6617
|
};
|
|
@@ -6518,7 +6640,7 @@ var changeProperty = (elements, appState, callback, includeBoundText = false) =>
|
|
|
6518
6640
|
return element;
|
|
6519
6641
|
});
|
|
6520
6642
|
};
|
|
6521
|
-
var getFormValue = function(elements, app, getAttribute,
|
|
6643
|
+
var getFormValue = function(elements, app, getAttribute, elementPredicate, defaultValue) {
|
|
6522
6644
|
const editingTextElement = app.state.editingTextElement;
|
|
6523
6645
|
const nonDeletedElements = getNonDeletedElements(elements);
|
|
6524
6646
|
let ret = null;
|
|
@@ -6529,7 +6651,7 @@ var getFormValue = function(elements, app, getAttribute, isRelevantElement, defa
|
|
|
6529
6651
|
const hasSelection = isSomeElementSelected(nonDeletedElements, app.state);
|
|
6530
6652
|
if (hasSelection) {
|
|
6531
6653
|
const selectedElements = app.scene.getSelectedElements(app.state);
|
|
6532
|
-
const targetElements =
|
|
6654
|
+
const targetElements = elementPredicate === true ? selectedElements : selectedElements.filter((el) => elementPredicate(el));
|
|
6533
6655
|
ret = reduceToCommonValue(targetElements, getAttribute) ?? (typeof defaultValue === "function" ? defaultValue(true) : defaultValue);
|
|
6534
6656
|
} else {
|
|
6535
6657
|
ret = typeof defaultValue === "function" ? defaultValue(false) : defaultValue;
|
|
@@ -6967,7 +7089,28 @@ var actionChangeOpacity = register({
|
|
|
6967
7089
|
captureUpdate: CaptureUpdateAction.IMMEDIATELY
|
|
6968
7090
|
};
|
|
6969
7091
|
},
|
|
6970
|
-
PanelComponent: ({ app, updateData }) =>
|
|
7092
|
+
PanelComponent: ({ elements, appState, app, updateData }) => {
|
|
7093
|
+
const opacity = getFormValue(
|
|
7094
|
+
elements,
|
|
7095
|
+
app,
|
|
7096
|
+
(element) => element.opacity,
|
|
7097
|
+
true,
|
|
7098
|
+
(hasSelection) => hasSelection ? null : appState.currentItemOpacity
|
|
7099
|
+
);
|
|
7100
|
+
return /* @__PURE__ */ jsx34(
|
|
7101
|
+
Range,
|
|
7102
|
+
{
|
|
7103
|
+
label: t("labels.opacity"),
|
|
7104
|
+
value: opacity ?? appState.currentItemOpacity,
|
|
7105
|
+
hasCommonValue: opacity !== null,
|
|
7106
|
+
onChange: updateData,
|
|
7107
|
+
min: 0,
|
|
7108
|
+
max: 100,
|
|
7109
|
+
step: 10,
|
|
7110
|
+
testId: "opacity"
|
|
7111
|
+
}
|
|
7112
|
+
);
|
|
7113
|
+
}
|
|
6971
7114
|
});
|
|
6972
7115
|
var actionChangeFontSize = register(
|
|
6973
7116
|
{
|
|
@@ -7239,7 +7382,7 @@ var actionChangeFontFamily = register({
|
|
|
7239
7382
|
const [batchedData, setBatchedData] = useState7({});
|
|
7240
7383
|
const isUnmounted = useRef10(true);
|
|
7241
7384
|
const { stylesPanelMode, isCompact } = getStylesPanelInfo(app);
|
|
7242
|
-
const selectedFontFamily =
|
|
7385
|
+
const selectedFontFamily = useMemo4(() => {
|
|
7243
7386
|
const getFontFamily = (elementsArray, elementsMap) => getFormValue(
|
|
7244
7387
|
elementsArray,
|
|
7245
7388
|
app,
|
|
@@ -7626,80 +7769,117 @@ var actionChangeRoundness = register({
|
|
|
7626
7769
|
}
|
|
7627
7770
|
});
|
|
7628
7771
|
var getArrowheadOptions = (flip) => {
|
|
7629
|
-
return
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7772
|
+
return {
|
|
7773
|
+
visibleSections: [
|
|
7774
|
+
{
|
|
7775
|
+
name: "default",
|
|
7776
|
+
options: [
|
|
7777
|
+
{
|
|
7778
|
+
value: null,
|
|
7779
|
+
text: t("labels.arrowhead_none"),
|
|
7780
|
+
keyBinding: "q",
|
|
7781
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadNoneIcon, { flip })
|
|
7782
|
+
},
|
|
7783
|
+
{
|
|
7784
|
+
value: "arrow",
|
|
7785
|
+
text: t("labels.arrowhead_arrow"),
|
|
7786
|
+
keyBinding: "w",
|
|
7787
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadArrowIcon, { flip })
|
|
7788
|
+
},
|
|
7789
|
+
{
|
|
7790
|
+
value: "triangle",
|
|
7791
|
+
text: t("labels.arrowhead_triangle"),
|
|
7792
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadTriangleIcon, { flip }),
|
|
7793
|
+
keyBinding: "e"
|
|
7794
|
+
},
|
|
7795
|
+
{
|
|
7796
|
+
value: "triangle_outline",
|
|
7797
|
+
text: t("labels.arrowhead_triangle_outline"),
|
|
7798
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadTriangleOutlineIcon, { flip }),
|
|
7799
|
+
keyBinding: "r"
|
|
7800
|
+
}
|
|
7801
|
+
]
|
|
7802
|
+
}
|
|
7803
|
+
],
|
|
7804
|
+
hiddenSections: [
|
|
7805
|
+
{
|
|
7806
|
+
name: "default",
|
|
7807
|
+
options: [
|
|
7808
|
+
{
|
|
7809
|
+
value: "circle",
|
|
7810
|
+
text: t("labels.arrowhead_circle"),
|
|
7811
|
+
keyBinding: "a",
|
|
7812
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadCircleIcon, { flip })
|
|
7813
|
+
},
|
|
7814
|
+
{
|
|
7815
|
+
value: "circle_outline",
|
|
7816
|
+
text: t("labels.arrowhead_circle_outline"),
|
|
7817
|
+
keyBinding: "s",
|
|
7818
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadCircleOutlineIcon, { flip })
|
|
7819
|
+
},
|
|
7820
|
+
{
|
|
7821
|
+
value: "diamond",
|
|
7822
|
+
text: t("labels.arrowhead_diamond"),
|
|
7823
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadDiamondIcon, { flip }),
|
|
7824
|
+
keyBinding: "d"
|
|
7825
|
+
},
|
|
7826
|
+
{
|
|
7827
|
+
value: "diamond_outline",
|
|
7828
|
+
text: t("labels.arrowhead_diamond_outline"),
|
|
7829
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadDiamondOutlineIcon, { flip }),
|
|
7830
|
+
keyBinding: "f"
|
|
7831
|
+
},
|
|
7832
|
+
{
|
|
7833
|
+
value: "bar",
|
|
7834
|
+
text: t("labels.arrowhead_bar"),
|
|
7835
|
+
keyBinding: "z",
|
|
7836
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadBarIcon, { flip })
|
|
7837
|
+
}
|
|
7838
|
+
]
|
|
7839
|
+
},
|
|
7840
|
+
{
|
|
7841
|
+
name: t("labels.cardinality"),
|
|
7842
|
+
options: [
|
|
7843
|
+
{
|
|
7844
|
+
value: "cardinality_one",
|
|
7845
|
+
text: t("labels.arrowhead_cardinality_one"),
|
|
7846
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadCardinalityOneIcon, { flip }),
|
|
7847
|
+
keyBinding: "x"
|
|
7848
|
+
},
|
|
7849
|
+
{
|
|
7850
|
+
value: "cardinality_many",
|
|
7851
|
+
text: t("labels.arrowhead_cardinality_many"),
|
|
7852
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadCardinalityManyIcon, { flip }),
|
|
7853
|
+
keyBinding: "c"
|
|
7854
|
+
},
|
|
7855
|
+
{
|
|
7856
|
+
value: "cardinality_one_or_many",
|
|
7857
|
+
text: t("labels.arrowhead_cardinality_one_or_many"),
|
|
7858
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadCardinalityOneOrManyIcon, { flip }),
|
|
7859
|
+
keyBinding: "v"
|
|
7860
|
+
},
|
|
7861
|
+
{
|
|
7862
|
+
value: "cardinality_exactly_one",
|
|
7863
|
+
text: t("labels.arrowhead_cardinality_exactly_one"),
|
|
7864
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadCardinalityExactlyOneIcon, { flip }),
|
|
7865
|
+
keyBinding: null
|
|
7866
|
+
},
|
|
7867
|
+
{
|
|
7868
|
+
value: "cardinality_zero_or_one",
|
|
7869
|
+
text: t("labels.arrowhead_cardinality_zero_or_one"),
|
|
7870
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadCardinalityZeroOrOneIcon, { flip }),
|
|
7871
|
+
keyBinding: null
|
|
7872
|
+
},
|
|
7873
|
+
{
|
|
7874
|
+
value: "cardinality_zero_or_many",
|
|
7875
|
+
text: t("labels.arrowhead_cardinality_zero_or_many"),
|
|
7876
|
+
icon: /* @__PURE__ */ jsx34(ArrowheadCardinalityZeroOrManyIcon, { flip }),
|
|
7877
|
+
keyBinding: null
|
|
7878
|
+
}
|
|
7879
|
+
]
|
|
7880
|
+
}
|
|
7881
|
+
]
|
|
7882
|
+
};
|
|
7703
7883
|
};
|
|
7704
7884
|
var actionChangeArrowhead = register({
|
|
7705
7885
|
name: "changeArrowhead",
|
|
@@ -7733,41 +7913,48 @@ var actionChangeArrowhead = register({
|
|
|
7733
7913
|
};
|
|
7734
7914
|
},
|
|
7735
7915
|
PanelComponent: ({ elements, appState, updateData, app }) => {
|
|
7736
|
-
const
|
|
7916
|
+
const isRTL2 = getLanguage().rtl;
|
|
7917
|
+
const startArrowheadOptions = useMemo4(
|
|
7918
|
+
() => getArrowheadOptions(!isRTL2),
|
|
7919
|
+
[isRTL2]
|
|
7920
|
+
);
|
|
7921
|
+
const endArrowheadOptions = useMemo4(
|
|
7922
|
+
() => getArrowheadOptions(!!isRTL2),
|
|
7923
|
+
[isRTL2]
|
|
7924
|
+
);
|
|
7737
7925
|
return /* @__PURE__ */ jsxs20("fieldset", { children: [
|
|
7738
7926
|
/* @__PURE__ */ jsx34("legend", { children: t("labels.arrowheads") }),
|
|
7739
7927
|
/* @__PURE__ */ jsxs20("div", { className: "iconSelectList buttonList", children: [
|
|
7740
7928
|
/* @__PURE__ */ jsx34(
|
|
7741
7929
|
IconPicker,
|
|
7742
7930
|
{
|
|
7931
|
+
visibleSections: startArrowheadOptions.visibleSections,
|
|
7932
|
+
hiddenSections: startArrowheadOptions.hiddenSections,
|
|
7743
7933
|
label: "arrowhead_start",
|
|
7744
|
-
options: getArrowheadOptions(!isRTL),
|
|
7745
7934
|
value: getFormValue(
|
|
7746
7935
|
elements,
|
|
7747
7936
|
app,
|
|
7748
|
-
(element) => isLinearElement(element) && canHaveArrowheads(element.type) ? element.startArrowhead : appState.currentItemStartArrowhead,
|
|
7937
|
+
(element) => isLinearElement(element) && canHaveArrowheads(element.type) ? getArrowheadForPicker(element.startArrowhead) : appState.currentItemStartArrowhead,
|
|
7749
7938
|
true,
|
|
7750
7939
|
(hasSelection) => hasSelection ? null : appState.currentItemStartArrowhead
|
|
7751
7940
|
),
|
|
7752
|
-
onChange: (value) => updateData({ position: "start", type: value })
|
|
7753
|
-
numberOfOptionsToAlwaysShow: 4
|
|
7941
|
+
onChange: (value) => updateData({ position: "start", type: value })
|
|
7754
7942
|
}
|
|
7755
7943
|
),
|
|
7756
7944
|
/* @__PURE__ */ jsx34(
|
|
7757
7945
|
IconPicker,
|
|
7758
7946
|
{
|
|
7947
|
+
visibleSections: endArrowheadOptions.visibleSections,
|
|
7948
|
+
hiddenSections: endArrowheadOptions.hiddenSections,
|
|
7759
7949
|
label: "arrowhead_end",
|
|
7760
|
-
group: "arrowheads",
|
|
7761
|
-
options: getArrowheadOptions(!!isRTL),
|
|
7762
7950
|
value: getFormValue(
|
|
7763
7951
|
elements,
|
|
7764
7952
|
app,
|
|
7765
|
-
(element) => isLinearElement(element) && canHaveArrowheads(element.type) ? element.endArrowhead : appState.currentItemEndArrowhead,
|
|
7953
|
+
(element) => isLinearElement(element) && canHaveArrowheads(element.type) ? getArrowheadForPicker(element.endArrowhead) : appState.currentItemEndArrowhead,
|
|
7766
7954
|
true,
|
|
7767
7955
|
(hasSelection) => hasSelection ? null : appState.currentItemEndArrowhead
|
|
7768
7956
|
),
|
|
7769
|
-
onChange: (value) => updateData({ position: "end", type: value })
|
|
7770
|
-
numberOfOptionsToAlwaysShow: 4
|
|
7957
|
+
onChange: (value) => updateData({ position: "end", type: value })
|
|
7771
7958
|
}
|
|
7772
7959
|
)
|
|
7773
7960
|
] })
|
|
@@ -9655,13 +9842,13 @@ var copyTextViaExecCommand = (text) => {
|
|
|
9655
9842
|
if (!text) {
|
|
9656
9843
|
text = " ";
|
|
9657
9844
|
}
|
|
9658
|
-
const
|
|
9845
|
+
const isRTL2 = document.documentElement.getAttribute("dir") === "rtl";
|
|
9659
9846
|
const textarea = document.createElement("textarea");
|
|
9660
9847
|
textarea.style.border = "0";
|
|
9661
9848
|
textarea.style.padding = "0";
|
|
9662
9849
|
textarea.style.margin = "0";
|
|
9663
9850
|
textarea.style.position = "absolute";
|
|
9664
|
-
textarea.style[
|
|
9851
|
+
textarea.style[isRTL2 ? "right" : "left"] = "-9999px";
|
|
9665
9852
|
const yPosition = window.pageYOffset || document.documentElement.scrollTop;
|
|
9666
9853
|
textarea.style.top = `${yPosition}px`;
|
|
9667
9854
|
textarea.style.fontSize = "12pt";
|
|
@@ -9784,7 +9971,7 @@ var exportAsImage = async ({
|
|
|
9784
9971
|
let blob = canvasToBlob(tempCanvas);
|
|
9785
9972
|
if (data.appState.exportEmbedScene) {
|
|
9786
9973
|
blob = blob.then(
|
|
9787
|
-
(blob2) => import("./data/image-
|
|
9974
|
+
(blob2) => import("./data/image-WSL7K3G4.js").then(
|
|
9788
9975
|
({ encodePngMetadata: encodePngMetadata2 }) => encodePngMetadata2({
|
|
9789
9976
|
blob: blob2,
|
|
9790
9977
|
metadata: serializeAsJSON(
|
|
@@ -10036,7 +10223,7 @@ var actionSaveFileToDisk = register({
|
|
|
10036
10223
|
...appState,
|
|
10037
10224
|
openDialog: null,
|
|
10038
10225
|
fileHandle,
|
|
10039
|
-
toast: { message: t("toast.fileSaved") }
|
|
10226
|
+
toast: { message: t("toast.fileSaved"), duration: 3e3 }
|
|
10040
10227
|
}
|
|
10041
10228
|
};
|
|
10042
10229
|
} catch (error) {
|
|
@@ -10102,7 +10289,8 @@ var actionExportWithDarkMode = register({
|
|
|
10102
10289
|
name: "exportWithDarkMode",
|
|
10103
10290
|
label: "imageExportDialog.label.darkMode",
|
|
10104
10291
|
trackEvent: { category: "export", action: "toggleTheme" },
|
|
10105
|
-
perform: (_elements, appState, value) => {
|
|
10292
|
+
perform: (_elements, appState, value, app) => {
|
|
10293
|
+
app.setSessionExportThemeOverride(value ? THEME.DARK : THEME.LIGHT);
|
|
10106
10294
|
return {
|
|
10107
10295
|
appState: { ...appState, exportWithDarkMode: value },
|
|
10108
10296
|
captureUpdate: CaptureUpdateAction.EVENTUALLY
|
|
@@ -12466,10 +12654,10 @@ var actionUnlockAllElements = register({
|
|
|
12466
12654
|
// components/CommandPalette/CommandPalette.tsx
|
|
12467
12655
|
import clsx36 from "clsx";
|
|
12468
12656
|
import fuzzy from "fuzzy";
|
|
12469
|
-
import { useEffect as useEffect27, useRef as useRef23, useMemo as
|
|
12657
|
+
import { useEffect as useEffect27, useRef as useRef23, useMemo as useMemo8, useState as useState25 } from "react";
|
|
12470
12658
|
|
|
12471
12659
|
// components/ConvertElementTypePopup.tsx
|
|
12472
|
-
import { useEffect as useEffect16, useMemo as
|
|
12660
|
+
import { useEffect as useEffect16, useMemo as useMemo5, useRef as useRef12, useState as useState11 } from "react";
|
|
12473
12661
|
import { jsx as jsx49 } from "react/jsx-runtime";
|
|
12474
12662
|
var GAP_HORIZONTAL = 8;
|
|
12475
12663
|
var GAP_VERTICAL = 10;
|
|
@@ -12520,10 +12708,10 @@ var Panel = ({
|
|
|
12520
12708
|
elements
|
|
12521
12709
|
}) => {
|
|
12522
12710
|
const conversionType = getConversionTypeFromElements(elements);
|
|
12523
|
-
const genericElements =
|
|
12711
|
+
const genericElements = useMemo5(() => {
|
|
12524
12712
|
return conversionType === "generic" ? filterGenericConvetibleElements(elements) : [];
|
|
12525
12713
|
}, [conversionType, elements]);
|
|
12526
|
-
const linearElements =
|
|
12714
|
+
const linearElements = useMemo5(() => {
|
|
12527
12715
|
return conversionType === "linear" ? filterLinearConvertibleElements(elements) : [];
|
|
12528
12716
|
}, [conversionType, elements]);
|
|
12529
12717
|
const sameType = conversionType === "generic" ? genericElements.every(
|
|
@@ -13427,7 +13615,7 @@ var useCallbackRefState = () => {
|
|
|
13427
13615
|
import {
|
|
13428
13616
|
useState as useState21,
|
|
13429
13617
|
useCallback as useCallback13,
|
|
13430
|
-
useMemo as
|
|
13618
|
+
useMemo as useMemo7,
|
|
13431
13619
|
useEffect as useEffect24,
|
|
13432
13620
|
memo as memo3,
|
|
13433
13621
|
useRef as useRef19
|
|
@@ -14233,7 +14421,7 @@ var LibraryMenuControlButtons = ({
|
|
|
14233
14421
|
import {
|
|
14234
14422
|
useCallback as useCallback12,
|
|
14235
14423
|
useEffect as useEffect23,
|
|
14236
|
-
useMemo as
|
|
14424
|
+
useMemo as useMemo6,
|
|
14237
14425
|
useRef as useRef18,
|
|
14238
14426
|
useState as useState20
|
|
14239
14427
|
} from "react";
|
|
@@ -15855,7 +16043,7 @@ function LibraryMenuItems({
|
|
|
15855
16043
|
const [searchInputValue, setSearchInputValue] = useState20("");
|
|
15856
16044
|
const IS_LIBRARY_EMPTY = !libraryItems.length && !pendingElements.length;
|
|
15857
16045
|
const IS_SEARCHING = !IS_LIBRARY_EMPTY && !!searchInputValue.trim();
|
|
15858
|
-
const filteredItems =
|
|
16046
|
+
const filteredItems = useMemo6(() => {
|
|
15859
16047
|
const searchQuery = deburr(searchInputValue.trim().toLowerCase());
|
|
15860
16048
|
if (!searchQuery) {
|
|
15861
16049
|
return [];
|
|
@@ -15865,11 +16053,11 @@ function LibraryMenuItems({
|
|
|
15865
16053
|
return itemName.trim() && deburr(itemName.toLowerCase()).includes(searchQuery);
|
|
15866
16054
|
});
|
|
15867
16055
|
}, [libraryItems, searchInputValue]);
|
|
15868
|
-
const unpublishedItems =
|
|
16056
|
+
const unpublishedItems = useMemo6(
|
|
15869
16057
|
() => libraryItems.filter((item) => item.status !== "published"),
|
|
15870
16058
|
[libraryItems]
|
|
15871
16059
|
);
|
|
15872
|
-
const publishedItems =
|
|
16060
|
+
const publishedItems = useMemo6(
|
|
15873
16061
|
() => libraryItems.filter((item) => item.status === "published"),
|
|
15874
16062
|
[libraryItems]
|
|
15875
16063
|
);
|
|
@@ -16204,7 +16392,7 @@ var LibraryMenuContent = memo3(
|
|
|
16204
16392
|
},
|
|
16205
16393
|
[onAddToLibrary, library, setAppState, libraryItemsData.libraryItems]
|
|
16206
16394
|
);
|
|
16207
|
-
const libraryItems =
|
|
16395
|
+
const libraryItems = useMemo7(
|
|
16208
16396
|
() => libraryItemsData.libraryItems,
|
|
16209
16397
|
[libraryItemsData]
|
|
16210
16398
|
);
|
|
@@ -16307,7 +16495,7 @@ var LibraryMenu = memo3(() => {
|
|
|
16307
16495
|
const appState = useUIAppState();
|
|
16308
16496
|
const setAppState = useExcalidrawSetAppState();
|
|
16309
16497
|
const [selectedItems, setSelectedItems] = useState21([]);
|
|
16310
|
-
const memoizedLibrary =
|
|
16498
|
+
const memoizedLibrary = useMemo7(() => app.library, [app.library]);
|
|
16311
16499
|
const pendingElements = usePendingElementsMemo(appState, app);
|
|
16312
16500
|
useEffect24(() => {
|
|
16313
16501
|
return addEventListener(
|
|
@@ -16811,7 +16999,7 @@ var SelectedShapeActions = ({
|
|
|
16811
16999
|
appState.editingTextElement || appState.newElement
|
|
16812
17000
|
);
|
|
16813
17001
|
const editorInterface = useEditorInterface();
|
|
16814
|
-
const
|
|
17002
|
+
const isRTL2 = document.documentElement.getAttribute("dir") === "rtl";
|
|
16815
17003
|
const showFillIcons = hasBackground(appState.activeTool.type) && !isTransparent(appState.currentItemBackgroundColor) || targetElements.some(
|
|
16816
17004
|
(element) => hasBackground(element.type) && !isTransparent(element.backgroundColor)
|
|
16817
17005
|
);
|
|
@@ -16851,7 +17039,7 @@ var SelectedShapeActions = ({
|
|
|
16851
17039
|
showAlignActions && !isSingleElementBoundContainer && /* @__PURE__ */ jsxs42("fieldset", { children: [
|
|
16852
17040
|
/* @__PURE__ */ jsx75("legend", { children: t("labels.align") }),
|
|
16853
17041
|
/* @__PURE__ */ jsxs42("div", { className: "buttonList", children: [
|
|
16854
|
-
|
|
17042
|
+
isRTL2 ? /* @__PURE__ */ jsxs42(Fragment10, { children: [
|
|
16855
17043
|
renderAction("alignRight"),
|
|
16856
17044
|
renderAction("alignHorizontallyCentered"),
|
|
16857
17045
|
renderAction("alignLeft")
|
|
@@ -17142,7 +17330,7 @@ var CombinedExtraActions = ({
|
|
|
17142
17330
|
if (targetElements.length === 2 && (hasBoundTextElement(targetElements[0]) || hasBoundTextElement(targetElements[1]))) {
|
|
17143
17331
|
isSingleElementBoundContainer = true;
|
|
17144
17332
|
}
|
|
17145
|
-
const
|
|
17333
|
+
const isRTL2 = document.documentElement.getAttribute("dir") === "rtl";
|
|
17146
17334
|
const isOpen = appState.openPopup === "compactOtherProperties";
|
|
17147
17335
|
if (isEditingTextOrNewElement || targetElements.length === 0) {
|
|
17148
17336
|
return null;
|
|
@@ -17202,7 +17390,7 @@ var CombinedExtraActions = ({
|
|
|
17202
17390
|
showAlignActions && !isSingleElementBoundContainer && /* @__PURE__ */ jsxs42("fieldset", { children: [
|
|
17203
17391
|
/* @__PURE__ */ jsx75("legend", { children: t("labels.align") }),
|
|
17204
17392
|
/* @__PURE__ */ jsxs42("div", { className: "buttonList", children: [
|
|
17205
|
-
|
|
17393
|
+
isRTL2 ? /* @__PURE__ */ jsxs42(Fragment10, { children: [
|
|
17206
17394
|
renderAction("alignRight"),
|
|
17207
17395
|
renderAction("alignHorizontallyCentered"),
|
|
17208
17396
|
renderAction("alignLeft")
|
|
@@ -17855,7 +18043,7 @@ function CommandPaletteInner({
|
|
|
17855
18043
|
appProps
|
|
17856
18044
|
});
|
|
17857
18045
|
const [libraryItemsData] = useAtom(libraryItemsAtom);
|
|
17858
|
-
const libraryCommands =
|
|
18046
|
+
const libraryCommands = useMemo8(() => {
|
|
17859
18047
|
return libraryItemsData.libraryItems?.filter(
|
|
17860
18048
|
(libraryItem) => !!libraryItem.name
|
|
17861
18049
|
).map((libraryItem) => ({
|
|
@@ -19214,16 +19402,17 @@ var actionTextAutoResize = register({
|
|
|
19214
19402
|
label: "labels.autoResize",
|
|
19215
19403
|
icon: null,
|
|
19216
19404
|
trackEvent: { category: "element" },
|
|
19217
|
-
predicate: (elements, appState, _
|
|
19405
|
+
predicate: (elements, appState, _) => {
|
|
19218
19406
|
const selectedElements = getSelectedElements(elements, appState);
|
|
19219
19407
|
return selectedElements.length === 1 && isTextElement(selectedElements[0]) && !selectedElements[0].autoResize;
|
|
19220
19408
|
},
|
|
19221
|
-
perform: (elements, appState,
|
|
19409
|
+
perform: (elements, appState, targetElement) => {
|
|
19222
19410
|
const selectedElements = getSelectedElements(elements, appState);
|
|
19411
|
+
const targetTextElement = isExcalidrawElement(targetElement) && isTextElement(targetElement) ? targetElement : selectedElements[0];
|
|
19223
19412
|
return {
|
|
19224
19413
|
appState,
|
|
19225
19414
|
elements: elements.map((element) => {
|
|
19226
|
-
if (element.id ===
|
|
19415
|
+
if (element.id === targetTextElement?.id && isTextElement(element)) {
|
|
19227
19416
|
const metrics = measureText(
|
|
19228
19417
|
element.originalText,
|
|
19229
19418
|
getFontString(element),
|
|
@@ -20785,6 +20974,58 @@ var isRenderThrottlingEnabled = (() => {
|
|
|
20785
20974
|
};
|
|
20786
20975
|
})();
|
|
20787
20976
|
|
|
20977
|
+
// textAutoResizeHandle.ts
|
|
20978
|
+
var TEXT_AUTO_RESIZE_HANDLE_GAP = 12;
|
|
20979
|
+
var TEXT_AUTO_RESIZE_HANDLE_LENGTH = 16;
|
|
20980
|
+
var TEXT_AUTO_RESIZE_HANDLE_HITBOX_WIDTH = 10;
|
|
20981
|
+
var TEXT_AUTO_RESIZE_HANDLE_HITBOX_HEIGHT = TEXT_AUTO_RESIZE_HANDLE_LENGTH + 2;
|
|
20982
|
+
var MAX_HANDLE_HEIGHT_RATIO = 0.8;
|
|
20983
|
+
var getTextBoxPadding = (zoomValue) => DEFAULT_TRANSFORM_HANDLE_SPACING * 2 / zoomValue;
|
|
20984
|
+
var getTextAutoResizeHandle = (textElement, zoomValue, formFactor) => {
|
|
20985
|
+
if (formFactor !== "desktop" || TEXT_AUTO_RESIZE_HANDLE_LENGTH > textElement.height * zoomValue * MAX_HANDLE_HEIGHT_RATIO) {
|
|
20986
|
+
return null;
|
|
20987
|
+
}
|
|
20988
|
+
const padding = getTextBoxPadding(zoomValue);
|
|
20989
|
+
const gap = TEXT_AUTO_RESIZE_HANDLE_GAP / zoomValue;
|
|
20990
|
+
const length = TEXT_AUTO_RESIZE_HANDLE_LENGTH / zoomValue;
|
|
20991
|
+
const center = pointFrom(
|
|
20992
|
+
textElement.x + textElement.width / 2,
|
|
20993
|
+
textElement.y + textElement.height / 2
|
|
20994
|
+
);
|
|
20995
|
+
const handleCenter = pointRotateRads(
|
|
20996
|
+
pointFrom(center[0] + textElement.width / 2 + padding + gap, center[1]),
|
|
20997
|
+
center,
|
|
20998
|
+
textElement.angle
|
|
20999
|
+
);
|
|
21000
|
+
return {
|
|
21001
|
+
center: handleCenter,
|
|
21002
|
+
start: pointRotateRads(
|
|
21003
|
+
pointFrom(handleCenter[0], handleCenter[1] - length / 2),
|
|
21004
|
+
handleCenter,
|
|
21005
|
+
textElement.angle
|
|
21006
|
+
),
|
|
21007
|
+
end: pointRotateRads(
|
|
21008
|
+
pointFrom(handleCenter[0], handleCenter[1] + length / 2),
|
|
21009
|
+
handleCenter,
|
|
21010
|
+
textElement.angle
|
|
21011
|
+
),
|
|
21012
|
+
hitboxWidth: TEXT_AUTO_RESIZE_HANDLE_HITBOX_WIDTH / zoomValue,
|
|
21013
|
+
hitboxHeight: TEXT_AUTO_RESIZE_HANDLE_HITBOX_HEIGHT / zoomValue
|
|
21014
|
+
};
|
|
21015
|
+
};
|
|
21016
|
+
var isPointHittingTextAutoResizeHandle = (point, textElement, zoomValue, formFactor) => {
|
|
21017
|
+
const handle = getTextAutoResizeHandle(textElement, zoomValue, formFactor);
|
|
21018
|
+
if (!handle) {
|
|
21019
|
+
return false;
|
|
21020
|
+
}
|
|
21021
|
+
const unrotatedPoint = pointRotateRads(
|
|
21022
|
+
pointFrom(point.x, point.y),
|
|
21023
|
+
handle.center,
|
|
21024
|
+
-textElement.angle
|
|
21025
|
+
);
|
|
21026
|
+
return Math.abs(unrotatedPoint[0] - handle.center[0]) <= handle.hitboxWidth / 2 && Math.abs(unrotatedPoint[1] - handle.center[1]) <= handle.hitboxHeight / 2;
|
|
21027
|
+
};
|
|
21028
|
+
|
|
20788
21029
|
// wysiwyg/textWysiwyg.tsx
|
|
20789
21030
|
var getTransform = (width, height, angle, appState, maxWidth, maxHeight) => {
|
|
20790
21031
|
const { zoom } = appState;
|
|
@@ -20799,6 +21040,82 @@ var getTransform = (width, height, angle, appState, maxWidth, maxHeight) => {
|
|
|
20799
21040
|
}
|
|
20800
21041
|
return `translate(${translateX}px, ${translateY}px) scale(${zoom.value}) rotate(${degree}deg)`;
|
|
20801
21042
|
};
|
|
21043
|
+
var getLineDirection = (text, offset) => {
|
|
21044
|
+
const hardLineStart = text.lastIndexOf("\n", Math.max(0, offset - 1)) + 1;
|
|
21045
|
+
const hardLineEnd = text.indexOf("\n", offset);
|
|
21046
|
+
const hardLineText = text.slice(
|
|
21047
|
+
hardLineStart,
|
|
21048
|
+
hardLineEnd === -1 ? text.length : hardLineEnd
|
|
21049
|
+
);
|
|
21050
|
+
return isRTL(hardLineText) ? "rtl" : "ltr";
|
|
21051
|
+
};
|
|
21052
|
+
var getCaretBoundaryOffsets = (text) => {
|
|
21053
|
+
const offsets = [0];
|
|
21054
|
+
let offset = 0;
|
|
21055
|
+
for (const char of Array.from(text)) {
|
|
21056
|
+
offset += char.length;
|
|
21057
|
+
offsets.push(offset);
|
|
21058
|
+
}
|
|
21059
|
+
return offsets;
|
|
21060
|
+
};
|
|
21061
|
+
var getLineCaretOffsetFromNativeLayout = ({
|
|
21062
|
+
text,
|
|
21063
|
+
font,
|
|
21064
|
+
lineHeightPx,
|
|
21065
|
+
direction,
|
|
21066
|
+
targetX
|
|
21067
|
+
}) => {
|
|
21068
|
+
if (!text || !document.body || typeof document.createRange !== "function") {
|
|
21069
|
+
return null;
|
|
21070
|
+
}
|
|
21071
|
+
const offsets = getCaretBoundaryOffsets(text);
|
|
21072
|
+
const mirror = document.createElement("div");
|
|
21073
|
+
const textNode = document.createTextNode(text);
|
|
21074
|
+
const range = document.createRange();
|
|
21075
|
+
const positions = [];
|
|
21076
|
+
mirror.dir = direction;
|
|
21077
|
+
Object.assign(mirror.style, {
|
|
21078
|
+
position: "fixed",
|
|
21079
|
+
top: "0",
|
|
21080
|
+
left: "0",
|
|
21081
|
+
margin: 0,
|
|
21082
|
+
padding: 0,
|
|
21083
|
+
border: 0,
|
|
21084
|
+
opacity: "0",
|
|
21085
|
+
pointerEvents: "none",
|
|
21086
|
+
whiteSpace: "pre",
|
|
21087
|
+
font,
|
|
21088
|
+
lineHeight: `${lineHeightPx}px`
|
|
21089
|
+
});
|
|
21090
|
+
mirror.append(textNode);
|
|
21091
|
+
document.body.append(mirror);
|
|
21092
|
+
try {
|
|
21093
|
+
for (const offset of offsets) {
|
|
21094
|
+
range.setStart(textNode, offset);
|
|
21095
|
+
range.setEnd(textNode, offset);
|
|
21096
|
+
const caretRect = range.getBoundingClientRect();
|
|
21097
|
+
if (!Number.isFinite(caretRect.left)) {
|
|
21098
|
+
return null;
|
|
21099
|
+
}
|
|
21100
|
+
positions.push(caretRect.left);
|
|
21101
|
+
}
|
|
21102
|
+
} catch {
|
|
21103
|
+
return null;
|
|
21104
|
+
} finally {
|
|
21105
|
+
mirror.remove();
|
|
21106
|
+
}
|
|
21107
|
+
const leftEdge = Math.min(...positions);
|
|
21108
|
+
let closestOffset = offsets[0];
|
|
21109
|
+
let closestDistance = Infinity;
|
|
21110
|
+
for (let index = 0; index < offsets.length; index++) {
|
|
21111
|
+
const distance2 = Math.abs(positions[index] - leftEdge - targetX);
|
|
21112
|
+
if (distance2 < closestDistance) {
|
|
21113
|
+
closestDistance = distance2;
|
|
21114
|
+
closestOffset = offsets[index];
|
|
21115
|
+
}
|
|
21116
|
+
}
|
|
21117
|
+
return closestOffset;
|
|
21118
|
+
};
|
|
20802
21119
|
var textWysiwyg = ({
|
|
20803
21120
|
id,
|
|
20804
21121
|
onChange,
|
|
@@ -20808,8 +21125,10 @@ var textWysiwyg = ({
|
|
|
20808
21125
|
canvas,
|
|
20809
21126
|
excalidrawContainer,
|
|
20810
21127
|
app,
|
|
20811
|
-
autoSelect = true
|
|
21128
|
+
autoSelect = true,
|
|
21129
|
+
initialCaretSceneCoords = null
|
|
20812
21130
|
}) => {
|
|
21131
|
+
let currentTextLayout = null;
|
|
20813
21132
|
const textPropertiesUpdated = (updatedTextElement, editable2) => {
|
|
20814
21133
|
if (!editable2.style.fontFamily || !editable2.style.fontSize) {
|
|
20815
21134
|
return false;
|
|
@@ -20916,6 +21235,7 @@ var textWysiwyg = ({
|
|
|
20916
21235
|
}
|
|
20917
21236
|
height *= 1.05;
|
|
20918
21237
|
const font = getFontString(updatedTextElement);
|
|
21238
|
+
const angle = getTextElementAngle(updatedTextElement, container);
|
|
20919
21239
|
const editorMaxHeight = (appState.height - viewportY) / appState.zoom.value;
|
|
20920
21240
|
Object.assign(editable.style, {
|
|
20921
21241
|
font,
|
|
@@ -20928,7 +21248,7 @@ var textWysiwyg = ({
|
|
|
20928
21248
|
transform: getTransform(
|
|
20929
21249
|
width,
|
|
20930
21250
|
height,
|
|
20931
|
-
|
|
21251
|
+
angle,
|
|
20932
21252
|
appState,
|
|
20933
21253
|
maxWidth,
|
|
20934
21254
|
editorMaxHeight
|
|
@@ -20939,6 +21259,19 @@ var textWysiwyg = ({
|
|
|
20939
21259
|
opacity: updatedTextElement.opacity / 100,
|
|
20940
21260
|
maxHeight: `${editorMaxHeight}px`
|
|
20941
21261
|
});
|
|
21262
|
+
currentTextLayout = {
|
|
21263
|
+
angle,
|
|
21264
|
+
font,
|
|
21265
|
+
height: updatedTextElement.height,
|
|
21266
|
+
lineHeightPx: getLineHeightInPx(
|
|
21267
|
+
updatedTextElement.fontSize,
|
|
21268
|
+
updatedTextElement.lineHeight
|
|
21269
|
+
),
|
|
21270
|
+
textAlign,
|
|
21271
|
+
width: updatedTextElement.width,
|
|
21272
|
+
x: coordX,
|
|
21273
|
+
y: coordY
|
|
21274
|
+
};
|
|
20942
21275
|
editable.scrollTop = 0;
|
|
20943
21276
|
if (isTestEnv()) {
|
|
20944
21277
|
editable.style.fontFamily = getFontFamilyString(updatedTextElement);
|
|
@@ -20980,6 +21313,58 @@ var textWysiwyg = ({
|
|
|
20980
21313
|
});
|
|
20981
21314
|
editable.value = element.originalText;
|
|
20982
21315
|
updateWysiwygStyle();
|
|
21316
|
+
const getCaretIndexFromInitialSceneCoords = () => {
|
|
21317
|
+
if (!initialCaretSceneCoords || !currentTextLayout) {
|
|
21318
|
+
return null;
|
|
21319
|
+
}
|
|
21320
|
+
const layout = currentTextLayout;
|
|
21321
|
+
const center = pointFrom(
|
|
21322
|
+
layout.x + layout.width / 2,
|
|
21323
|
+
layout.y + layout.height / 2
|
|
21324
|
+
);
|
|
21325
|
+
const [unrotatedX, unrotatedY] = pointRotateRads(
|
|
21326
|
+
pointFrom(initialCaretSceneCoords.x, initialCaretSceneCoords.y),
|
|
21327
|
+
center,
|
|
21328
|
+
-layout.angle
|
|
21329
|
+
);
|
|
21330
|
+
const localX = unrotatedX - layout.x;
|
|
21331
|
+
const localY = unrotatedY - layout.y;
|
|
21332
|
+
const lines = getWrappedTextLines(
|
|
21333
|
+
editable.value,
|
|
21334
|
+
layout.font,
|
|
21335
|
+
whiteSpace === "pre-wrap" ? layout.width : Infinity
|
|
21336
|
+
);
|
|
21337
|
+
const lineIndex = Math.max(
|
|
21338
|
+
0,
|
|
21339
|
+
Math.min(lines.length - 1, Math.floor(localY / layout.lineHeightPx))
|
|
21340
|
+
);
|
|
21341
|
+
const line = lines[lineIndex];
|
|
21342
|
+
const direction = getLineDirection(editable.value, line.start);
|
|
21343
|
+
const lineWidth = getLineWidth(line.text, layout.font);
|
|
21344
|
+
const lineStartX = layout.textAlign === "center" ? (layout.width - lineWidth) / 2 : layout.textAlign === "right" ? layout.width - lineWidth : 0;
|
|
21345
|
+
const relativeX = localX - lineStartX;
|
|
21346
|
+
if (!line.text) {
|
|
21347
|
+
return line.start;
|
|
21348
|
+
}
|
|
21349
|
+
const lineCaretOffset = getLineCaretOffsetFromNativeLayout({
|
|
21350
|
+
text: line.text,
|
|
21351
|
+
font: layout.font,
|
|
21352
|
+
lineHeightPx: layout.lineHeightPx,
|
|
21353
|
+
direction,
|
|
21354
|
+
targetX: relativeX
|
|
21355
|
+
});
|
|
21356
|
+
return line.start + (lineCaretOffset || 0);
|
|
21357
|
+
};
|
|
21358
|
+
let pendingInitialSelection = (() => {
|
|
21359
|
+
const caretIndex = getCaretIndexFromInitialSceneCoords();
|
|
21360
|
+
if (caretIndex === null) {
|
|
21361
|
+
return null;
|
|
21362
|
+
}
|
|
21363
|
+
return {
|
|
21364
|
+
start: caretIndex,
|
|
21365
|
+
end: caretIndex
|
|
21366
|
+
};
|
|
21367
|
+
})();
|
|
20983
21368
|
if (onChange) {
|
|
20984
21369
|
editable.onpaste = async (event) => {
|
|
20985
21370
|
const mimeTypes = parseDataTransferEventMimeTypes(event);
|
|
@@ -21236,6 +21621,13 @@ var textWysiwyg = ({
|
|
|
21236
21621
|
}
|
|
21237
21622
|
editable.onblur = handleSubmit;
|
|
21238
21623
|
editable.focus();
|
|
21624
|
+
if (pendingInitialSelection) {
|
|
21625
|
+
editable.setSelectionRange(
|
|
21626
|
+
pendingInitialSelection.start,
|
|
21627
|
+
pendingInitialSelection.end
|
|
21628
|
+
);
|
|
21629
|
+
pendingInitialSelection = null;
|
|
21630
|
+
}
|
|
21239
21631
|
});
|
|
21240
21632
|
};
|
|
21241
21633
|
const temporarilyDisableSubmit = () => {
|
|
@@ -21285,7 +21677,7 @@ var textWysiwyg = ({
|
|
|
21285
21677
|
updateWysiwygStyle();
|
|
21286
21678
|
});
|
|
21287
21679
|
let isDestroyed = false;
|
|
21288
|
-
if (autoSelect) {
|
|
21680
|
+
if (autoSelect && !pendingInitialSelection) {
|
|
21289
21681
|
editable.select();
|
|
21290
21682
|
}
|
|
21291
21683
|
bindBlurEvent();
|
|
@@ -21327,7 +21719,7 @@ var getScrollBars = (elements, viewportWidth, viewportHeight, appState) => {
|
|
|
21327
21719
|
left: parseInt(getGlobalCSSVariable("sal")) || 0,
|
|
21328
21720
|
right: parseInt(getGlobalCSSVariable("sar")) || 0
|
|
21329
21721
|
};
|
|
21330
|
-
const
|
|
21722
|
+
const isRTL2 = getLanguage().rtl;
|
|
21331
21723
|
const viewportMinX = -appState.scrollX + safeArea.left;
|
|
21332
21724
|
const viewportMinY = -appState.scrollY + safeArea.top;
|
|
21333
21725
|
const viewportMaxX = viewportMinX + viewportWidthWithZoom - safeArea.right;
|
|
@@ -21355,7 +21747,7 @@ var getScrollBars = (elements, viewportWidth, viewportHeight, appState) => {
|
|
|
21355
21747
|
deltaMultiplier: horizontalDeltaMultiplier
|
|
21356
21748
|
},
|
|
21357
21749
|
vertical: viewportMinY === sceneMinY && viewportMaxY === sceneMaxY ? null : {
|
|
21358
|
-
x:
|
|
21750
|
+
x: isRTL2 ? Math.max(safeArea.left, SCROLLBAR_MARGIN) : viewportWidth - SCROLLBAR_WIDTH - Math.max(safeArea.right, SCROLLBAR_MARGIN),
|
|
21359
21751
|
y: Math.max(safeArea.top, SCROLLBAR_MARGIN) + SCROLLBAR_WIDTH + (viewportMinY - sceneMinY) / extendedSceneHeight * viewportHeight,
|
|
21360
21752
|
width: SCROLLBAR_WIDTH,
|
|
21361
21753
|
height: scrollbarHeight,
|
|
@@ -23566,16 +23958,14 @@ var MobileToolBar = ({
|
|
|
23566
23958
|
children: t("toolBar.mermaidToExcalidraw")
|
|
23567
23959
|
}
|
|
23568
23960
|
),
|
|
23569
|
-
app.props.aiEnabled !== false && app.plugins.diagramToCode && /* @__PURE__ */ jsx90(Fragment11, { children: /* @__PURE__ */
|
|
23961
|
+
app.props.aiEnabled !== false && app.plugins.diagramToCode && /* @__PURE__ */ jsx90(Fragment11, { children: /* @__PURE__ */ jsx90(
|
|
23570
23962
|
DropdownMenu_default.Item,
|
|
23571
23963
|
{
|
|
23572
23964
|
onSelect: () => app.onMagicframeToolSelect(),
|
|
23573
23965
|
icon: MagicIcon,
|
|
23574
23966
|
"data-testid": "toolbar-magicframe",
|
|
23575
|
-
children:
|
|
23576
|
-
|
|
23577
|
-
/* @__PURE__ */ jsx90(DropdownMenu_default.Item.Badge, { children: "AI" })
|
|
23578
|
-
]
|
|
23967
|
+
badge: /* @__PURE__ */ jsx90(DropdownMenu_default.Item.Badge, { children: "AI" }),
|
|
23968
|
+
children: t("toolBar.magicframe")
|
|
23579
23969
|
}
|
|
23580
23970
|
) })
|
|
23581
23971
|
]
|
|
@@ -25113,7 +25503,6 @@ var PreferencesToggleMidpointSnappingItem = () => {
|
|
|
25113
25503
|
DropdownMenuItemCheckbox_default,
|
|
25114
25504
|
{
|
|
25115
25505
|
checked: appState.isMidpointSnappingEnabled,
|
|
25116
|
-
disabled: appState.bindingPreference === "disabled",
|
|
25117
25506
|
onSelect: (event) => {
|
|
25118
25507
|
actionManager.executeAction(actionToggleMidpointSnapping);
|
|
25119
25508
|
event.preventDefault();
|
|
@@ -25485,7 +25874,7 @@ import clsx54 from "clsx";
|
|
|
25485
25874
|
// components/SearchMenu.tsx
|
|
25486
25875
|
import clsx53 from "clsx";
|
|
25487
25876
|
import debounce2 from "lodash.debounce";
|
|
25488
|
-
import { Fragment as Fragment17, memo as memo4, useEffect as useEffect33, useMemo as
|
|
25877
|
+
import { Fragment as Fragment17, memo as memo4, useEffect as useEffect33, useMemo as useMemo9, useRef as useRef28, useState as useState32 } from "react";
|
|
25489
25878
|
import { Fragment as Fragment18, jsx as jsx114, jsxs as jsxs66 } from "react/jsx-runtime";
|
|
25490
25879
|
var searchQueryAtom = atom("");
|
|
25491
25880
|
var searchItemInFocusAtom = atom(null);
|
|
@@ -25808,11 +26197,11 @@ var ListItem = (props) => {
|
|
|
25808
26197
|
);
|
|
25809
26198
|
};
|
|
25810
26199
|
var MatchListBase = (props) => {
|
|
25811
|
-
const frameNameMatches =
|
|
26200
|
+
const frameNameMatches = useMemo9(
|
|
25812
26201
|
() => props.matches.items.filter((match) => isFrameLikeElement(match.element)),
|
|
25813
26202
|
[props.matches]
|
|
25814
26203
|
);
|
|
25815
|
-
const textMatches =
|
|
26204
|
+
const textMatches = useMemo9(
|
|
25816
26205
|
() => props.matches.items.filter((match) => isTextElement(match.element)),
|
|
25817
26206
|
[props.matches]
|
|
25818
26207
|
);
|
|
@@ -26153,24 +26542,57 @@ var DefaultSidebar = Object.assign(
|
|
|
26153
26542
|
);
|
|
26154
26543
|
|
|
26155
26544
|
// components/TTDDialog/TTDDialog.tsx
|
|
26156
|
-
import { useEffect as useEffect40, useState as
|
|
26545
|
+
import { useEffect as useEffect40, useState as useState37 } from "react";
|
|
26157
26546
|
|
|
26158
26547
|
// components/TTDDialog/MermaidToExcalidraw.tsx
|
|
26159
|
-
import { useState as
|
|
26548
|
+
import { useState as useState34, useRef as useRef30, useEffect as useEffect35, useDeferredValue } from "react";
|
|
26160
26549
|
|
|
26161
26550
|
// components/TTDDialog/TTDDialogInput.tsx
|
|
26162
|
-
import { useEffect as useEffect34, useRef as useRef29 } from "react";
|
|
26551
|
+
import { useEffect as useEffect34, useRef as useRef29, useState as useState33 } from "react";
|
|
26163
26552
|
import { jsx as jsx116 } from "react/jsx-runtime";
|
|
26553
|
+
var SPINNER_DELAY_MS = 300;
|
|
26164
26554
|
var TTDDialogInput = ({
|
|
26165
26555
|
input,
|
|
26166
26556
|
placeholder,
|
|
26167
26557
|
onChange,
|
|
26168
|
-
onKeyboardSubmit
|
|
26558
|
+
onKeyboardSubmit,
|
|
26559
|
+
errorLine
|
|
26169
26560
|
}) => {
|
|
26170
26561
|
const ref = useRef29(null);
|
|
26171
26562
|
const callbackRef = useRef29(onKeyboardSubmit);
|
|
26172
26563
|
callbackRef.current = onKeyboardSubmit;
|
|
26564
|
+
const [editorState, setEditorState] = useState33({
|
|
26565
|
+
type: "loading"
|
|
26566
|
+
});
|
|
26567
|
+
const [showSpinner, setShowSpinner] = useState33(false);
|
|
26568
|
+
const { theme } = useUIAppState();
|
|
26569
|
+
useEffect34(() => {
|
|
26570
|
+
let cancelled = false;
|
|
26571
|
+
const spinnerTimer = setTimeout(() => {
|
|
26572
|
+
if (!cancelled) {
|
|
26573
|
+
setShowSpinner(true);
|
|
26574
|
+
}
|
|
26575
|
+
}, SPINNER_DELAY_MS);
|
|
26576
|
+
import("./components/TTDDialog/CodeMirrorEditor-PY5ZVWKQ.js").then((mod) => {
|
|
26577
|
+
if (!cancelled) {
|
|
26578
|
+
setEditorState({ type: "ready", component: mod.default });
|
|
26579
|
+
}
|
|
26580
|
+
}).catch(() => {
|
|
26581
|
+
if (!cancelled) {
|
|
26582
|
+
setEditorState({ type: "fallback" });
|
|
26583
|
+
}
|
|
26584
|
+
}).finally(() => {
|
|
26585
|
+
clearTimeout(spinnerTimer);
|
|
26586
|
+
});
|
|
26587
|
+
return () => {
|
|
26588
|
+
cancelled = true;
|
|
26589
|
+
clearTimeout(spinnerTimer);
|
|
26590
|
+
};
|
|
26591
|
+
}, []);
|
|
26173
26592
|
useEffect34(() => {
|
|
26593
|
+
if (editorState.type !== "fallback") {
|
|
26594
|
+
return;
|
|
26595
|
+
}
|
|
26174
26596
|
if (!callbackRef.current) {
|
|
26175
26597
|
return;
|
|
26176
26598
|
}
|
|
@@ -26188,28 +26610,151 @@ var TTDDialogInput = ({
|
|
|
26188
26610
|
textarea.removeEventListener("keydown" /* KEYDOWN */, handleKeyDown);
|
|
26189
26611
|
};
|
|
26190
26612
|
}
|
|
26191
|
-
}, []);
|
|
26192
|
-
|
|
26193
|
-
|
|
26194
|
-
|
|
26195
|
-
|
|
26196
|
-
|
|
26197
|
-
|
|
26198
|
-
|
|
26199
|
-
|
|
26200
|
-
|
|
26201
|
-
|
|
26613
|
+
}, [editorState.type]);
|
|
26614
|
+
if (editorState.type === "ready") {
|
|
26615
|
+
const CodeMirrorEditor = editorState.component;
|
|
26616
|
+
return /* @__PURE__ */ jsx116(
|
|
26617
|
+
CodeMirrorEditor,
|
|
26618
|
+
{
|
|
26619
|
+
value: input,
|
|
26620
|
+
onChange,
|
|
26621
|
+
onKeyboardSubmit,
|
|
26622
|
+
placeholder,
|
|
26623
|
+
theme,
|
|
26624
|
+
errorLine
|
|
26625
|
+
}
|
|
26626
|
+
);
|
|
26627
|
+
}
|
|
26628
|
+
if (editorState.type === "fallback") {
|
|
26629
|
+
return /* @__PURE__ */ jsx116(
|
|
26630
|
+
"textarea",
|
|
26631
|
+
{
|
|
26632
|
+
className: "ttd-dialog-input",
|
|
26633
|
+
onChange: (e) => onChange(e.target.value),
|
|
26634
|
+
value: input,
|
|
26635
|
+
placeholder,
|
|
26636
|
+
ref
|
|
26637
|
+
}
|
|
26638
|
+
);
|
|
26639
|
+
}
|
|
26640
|
+
if (showSpinner) {
|
|
26641
|
+
return /* @__PURE__ */ jsx116("div", { className: "ttd-dialog-input ttd-dialog-input--loading", children: /* @__PURE__ */ jsx116(Spinner_default, {}) });
|
|
26642
|
+
}
|
|
26643
|
+
return null;
|
|
26202
26644
|
};
|
|
26203
26645
|
|
|
26204
26646
|
// components/TTDDialog/TTDDialogOutput.tsx
|
|
26205
26647
|
import clsx55 from "clsx";
|
|
26648
|
+
|
|
26649
|
+
// components/TTDDialog/utils/mermaidError.ts
|
|
26650
|
+
var MERMAID_SYNTAX_ERROR_LINE = /(?:Parse|Lexical) error on line (\d+)[.:]/i;
|
|
26651
|
+
var MERMAID_INACTIVE_PARTICIPANT_ERROR = /Trying to inactivate an inactive participant \((.+)\)/i;
|
|
26652
|
+
var MERMAID_CARET_LINE = /^\s*-+\^\s*$/;
|
|
26653
|
+
var isMermaidParseSyntaxError = (message) => MERMAID_SYNTAX_ERROR_LINE.test(message);
|
|
26654
|
+
var isMermaidAutoFixableError = (message) => isMermaidParseSyntaxError(message) || MERMAID_INACTIVE_PARTICIPANT_ERROR.test(message);
|
|
26655
|
+
var isMermaidCaretLine = (line) => MERMAID_CARET_LINE.test(line);
|
|
26656
|
+
var getMermaidInactiveParticipant = (message) => {
|
|
26657
|
+
const match = message.match(MERMAID_INACTIVE_PARTICIPANT_ERROR);
|
|
26658
|
+
if (!match?.[1]) {
|
|
26659
|
+
return null;
|
|
26660
|
+
}
|
|
26661
|
+
return match[1].trim();
|
|
26662
|
+
};
|
|
26663
|
+
var escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
26664
|
+
var getInactiveParticipantLineNumber = (message, sourceText) => {
|
|
26665
|
+
const participant = getMermaidInactiveParticipant(message);
|
|
26666
|
+
if (!participant) {
|
|
26667
|
+
return null;
|
|
26668
|
+
}
|
|
26669
|
+
const deactivatePattern = new RegExp(
|
|
26670
|
+
`^\\s*deactivate\\s+${escapeRegExp(participant)}(?:\\s+%%.*)?\\s*$`
|
|
26671
|
+
);
|
|
26672
|
+
const lines = sourceText.split(/\r?\n/);
|
|
26673
|
+
for (let index = lines.length - 1; index >= 0; index--) {
|
|
26674
|
+
if (deactivatePattern.test(lines[index])) {
|
|
26675
|
+
return index + 1;
|
|
26676
|
+
}
|
|
26677
|
+
}
|
|
26678
|
+
return null;
|
|
26679
|
+
};
|
|
26680
|
+
var getMermaidErrorLineNumber = (message, sourceText) => {
|
|
26681
|
+
const match = message.match(MERMAID_SYNTAX_ERROR_LINE);
|
|
26682
|
+
if (!match) {
|
|
26683
|
+
if (!sourceText) {
|
|
26684
|
+
return null;
|
|
26685
|
+
}
|
|
26686
|
+
return getInactiveParticipantLineNumber(message, sourceText);
|
|
26687
|
+
}
|
|
26688
|
+
return Number.parseInt(match[1], 10);
|
|
26689
|
+
};
|
|
26690
|
+
var countMatches = (text, re) => (text.match(re) || []).length;
|
|
26691
|
+
var getMermaidSyntaxErrorGuidance = (message, sourceText) => {
|
|
26692
|
+
if (!isMermaidParseSyntaxError(message)) {
|
|
26693
|
+
return null;
|
|
26694
|
+
}
|
|
26695
|
+
const errorLine = getMermaidErrorLineNumber(message, sourceText);
|
|
26696
|
+
const summary = errorLine ? `Syntax error near line ${errorLine}.` : "Syntax error in Mermaid diagram.";
|
|
26697
|
+
const likelyCauses = [];
|
|
26698
|
+
if (sourceText) {
|
|
26699
|
+
const openBrackets = countMatches(sourceText, /\[/g);
|
|
26700
|
+
const closeBrackets = countMatches(sourceText, /\]/g);
|
|
26701
|
+
if (openBrackets !== closeBrackets) {
|
|
26702
|
+
likelyCauses.push("Unbalanced square brackets in a node label.");
|
|
26703
|
+
}
|
|
26704
|
+
const openParens = countMatches(sourceText, /\(/g);
|
|
26705
|
+
const closeParens = countMatches(sourceText, /\)/g);
|
|
26706
|
+
if (openParens !== closeParens) {
|
|
26707
|
+
likelyCauses.push("Unbalanced parentheses in a node shape.");
|
|
26708
|
+
}
|
|
26709
|
+
const openBraces = countMatches(sourceText, /\{/g);
|
|
26710
|
+
const closeBraces = countMatches(sourceText, /\}/g);
|
|
26711
|
+
if (openBraces !== closeBraces) {
|
|
26712
|
+
likelyCauses.push("Unbalanced braces in a decision node.");
|
|
26713
|
+
}
|
|
26714
|
+
const subgraphCount = countMatches(sourceText, /^\s*subgraph\b/gm);
|
|
26715
|
+
const endCount = countMatches(sourceText, /^\s*end\s*$/gm);
|
|
26716
|
+
if (subgraphCount > endCount) {
|
|
26717
|
+
likelyCauses.push("A block is missing an `end` statement.");
|
|
26718
|
+
}
|
|
26719
|
+
}
|
|
26720
|
+
if (/got 'NODE_STRING'/.test(message) || /got 'PS'/.test(message)) {
|
|
26721
|
+
likelyCauses.push(
|
|
26722
|
+
"An extra character/token may appear after a node or label definition."
|
|
26723
|
+
);
|
|
26724
|
+
}
|
|
26725
|
+
if (likelyCauses.length === 0) {
|
|
26726
|
+
likelyCauses.push(
|
|
26727
|
+
"A node or edge line is malformed (missing/extra delimiters)."
|
|
26728
|
+
);
|
|
26729
|
+
likelyCauses.push("A block (`subgraph`, `class`, etc.) may be incomplete.");
|
|
26730
|
+
}
|
|
26731
|
+
return {
|
|
26732
|
+
summary,
|
|
26733
|
+
likelyCauses: [...new Set(likelyCauses)]
|
|
26734
|
+
};
|
|
26735
|
+
};
|
|
26736
|
+
var formatMermaidParseErrorMessage = (message) => {
|
|
26737
|
+
if (!isMermaidParseSyntaxError(message)) {
|
|
26738
|
+
return message;
|
|
26739
|
+
}
|
|
26740
|
+
return message.replace(/\n\s*Expecting[\s\S]*$/, "").trimEnd();
|
|
26741
|
+
};
|
|
26742
|
+
|
|
26743
|
+
// components/TTDDialog/TTDDialogOutput.tsx
|
|
26206
26744
|
import { jsx as jsx117, jsxs as jsxs68 } from "react/jsx-runtime";
|
|
26207
26745
|
var TTDDialogOutput = ({
|
|
26208
26746
|
error,
|
|
26209
26747
|
canvasRef,
|
|
26210
26748
|
loaded,
|
|
26211
|
-
hideErrorDetails
|
|
26749
|
+
hideErrorDetails,
|
|
26750
|
+
sourceText,
|
|
26751
|
+
autoFixAvailable,
|
|
26752
|
+
onApplyAutoFix
|
|
26212
26753
|
}) => {
|
|
26754
|
+
const errorMessage = error ? hideErrorDetails ? t("chat.errors.mermaidParseError") : formatMermaidParseErrorMessage(error.message) : null;
|
|
26755
|
+
const syntaxGuidance = error && !hideErrorDetails ? getMermaidSyntaxErrorGuidance(error.message, sourceText) : null;
|
|
26756
|
+
const showAutoFixButton = !!autoFixAvailable && !!onApplyAutoFix && !hideErrorDetails;
|
|
26757
|
+
const errorMessageLines = errorMessage?.split(/\r?\n/) ?? [];
|
|
26213
26758
|
return /* @__PURE__ */ jsxs68(
|
|
26214
26759
|
"div",
|
|
26215
26760
|
{
|
|
@@ -26222,8 +26767,30 @@ var TTDDialogOutput = ({
|
|
|
26222
26767
|
className: "ttd-dialog-output-error",
|
|
26223
26768
|
children: /* @__PURE__ */ jsxs68("div", { className: "ttd-dialog-output-error-content", children: [
|
|
26224
26769
|
/* @__PURE__ */ jsx117("div", { className: "ttd-dialog-output-error-icon", children: alertTriangleIcon }),
|
|
26225
|
-
/* @__PURE__ */
|
|
26226
|
-
|
|
26770
|
+
syntaxGuidance && /* @__PURE__ */ jsxs68("div", { className: "ttd-dialog-output-error-summary", children: [
|
|
26771
|
+
/* @__PURE__ */ jsx117("div", { className: "ttd-dialog-output-error-summary__headline", children: syntaxGuidance.summary }),
|
|
26772
|
+
/* @__PURE__ */ jsx117("div", { className: "ttd-dialog-output-error-summary__label", children: "Likely causes:" }),
|
|
26773
|
+
/* @__PURE__ */ jsx117("ul", { className: "ttd-dialog-output-error-summary__causes", children: syntaxGuidance.likelyCauses.map((cause) => /* @__PURE__ */ jsx117("li", { children: cause }, cause)) })
|
|
26774
|
+
] }),
|
|
26775
|
+
/* @__PURE__ */ jsx117("div", { className: "ttd-dialog-output-error-message", children: errorMessageLines.map((line, index) => /* @__PURE__ */ jsxs68(
|
|
26776
|
+
"span",
|
|
26777
|
+
{
|
|
26778
|
+
className: isMermaidCaretLine(line) ? "ttd-dialog-output-error-message__caret" : void 0,
|
|
26779
|
+
children: [
|
|
26780
|
+
line,
|
|
26781
|
+
index < errorMessageLines.length - 1 ? "\n" : ""
|
|
26782
|
+
]
|
|
26783
|
+
},
|
|
26784
|
+
`error-line-${index}`
|
|
26785
|
+
)) }),
|
|
26786
|
+
!hideErrorDetails && /* @__PURE__ */ jsx117("div", { className: "ttd-dialog-output-error-autofix-slot", children: showAutoFixButton ? /* @__PURE__ */ jsx117(
|
|
26787
|
+
Button,
|
|
26788
|
+
{
|
|
26789
|
+
className: "ttd-dialog-panel-button ttd-dialog-output-error-autofix",
|
|
26790
|
+
onSelect: onApplyAutoFix,
|
|
26791
|
+
children: t("mermaid.autoFixAvailable")
|
|
26792
|
+
}
|
|
26793
|
+
) : null })
|
|
26227
26794
|
] })
|
|
26228
26795
|
},
|
|
26229
26796
|
"error"
|
|
@@ -26346,6 +26913,134 @@ var TTDDialogSubmitShortcut = () => {
|
|
|
26346
26913
|
] });
|
|
26347
26914
|
};
|
|
26348
26915
|
|
|
26916
|
+
// components/TTDDialog/utils/mermaidAutoFix.ts
|
|
26917
|
+
var getErrorLineIndex = (message, sourceText) => {
|
|
26918
|
+
const lineNumber = getMermaidErrorLineNumber(message, sourceText);
|
|
26919
|
+
if (lineNumber == null) {
|
|
26920
|
+
return null;
|
|
26921
|
+
}
|
|
26922
|
+
return lineNumber - 1;
|
|
26923
|
+
};
|
|
26924
|
+
var replaceLineAt = (lines, index, transform) => {
|
|
26925
|
+
if (index < 0 || index >= lines.length) {
|
|
26926
|
+
return null;
|
|
26927
|
+
}
|
|
26928
|
+
const nextLine = transform(lines[index]);
|
|
26929
|
+
if (nextLine === lines[index]) {
|
|
26930
|
+
return null;
|
|
26931
|
+
}
|
|
26932
|
+
const nextLines = [...lines];
|
|
26933
|
+
nextLines[index] = nextLine;
|
|
26934
|
+
return nextLines.join("\n");
|
|
26935
|
+
};
|
|
26936
|
+
var stripTrailingTokenAfterShape = (line) => {
|
|
26937
|
+
const alphaTailMatch = line.match(
|
|
26938
|
+
/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([A-Za-z]+)\s*$/
|
|
26939
|
+
);
|
|
26940
|
+
if (alphaTailMatch) {
|
|
26941
|
+
return alphaTailMatch[1];
|
|
26942
|
+
}
|
|
26943
|
+
const punctuationTailMatch = line.match(
|
|
26944
|
+
/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([,;:])\s*$/
|
|
26945
|
+
);
|
|
26946
|
+
if (punctuationTailMatch) {
|
|
26947
|
+
return punctuationTailMatch[1];
|
|
26948
|
+
}
|
|
26949
|
+
return line;
|
|
26950
|
+
};
|
|
26951
|
+
var removeExtraArrowheadAfterEdgeLabel = (line) => {
|
|
26952
|
+
return line.replace(/(\|[^|\n]+\|)\s*>\s*(?=[A-Za-z0-9_("[{'`])/g, "$1 ");
|
|
26953
|
+
};
|
|
26954
|
+
var escapeRegExp2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
26955
|
+
var removeLastDeactivateForParticipant = (sourceText, participant) => {
|
|
26956
|
+
const pattern = new RegExp(
|
|
26957
|
+
`^\\s*deactivate\\s+${escapeRegExp2(participant)}(?:\\s+%%.*)?\\s*$`
|
|
26958
|
+
);
|
|
26959
|
+
const lines = sourceText.split(/\r?\n/);
|
|
26960
|
+
for (let index = lines.length - 1; index >= 0; index--) {
|
|
26961
|
+
if (pattern.test(lines[index])) {
|
|
26962
|
+
return lines.filter((_, lineIndex) => lineIndex !== index).join("\n");
|
|
26963
|
+
}
|
|
26964
|
+
}
|
|
26965
|
+
return null;
|
|
26966
|
+
};
|
|
26967
|
+
var removeAllDeactivateForParticipant = (sourceText, participant) => {
|
|
26968
|
+
const pattern = new RegExp(
|
|
26969
|
+
`^\\s*deactivate\\s+${escapeRegExp2(participant)}(?:\\s+%%.*)?\\s*$`
|
|
26970
|
+
);
|
|
26971
|
+
const lines = sourceText.split(/\r?\n/);
|
|
26972
|
+
let removedAny = false;
|
|
26973
|
+
const remainingLines = lines.filter((line) => {
|
|
26974
|
+
if (!pattern.test(line)) {
|
|
26975
|
+
return true;
|
|
26976
|
+
}
|
|
26977
|
+
removedAny = true;
|
|
26978
|
+
return false;
|
|
26979
|
+
});
|
|
26980
|
+
return removedAny ? remainingLines.join("\n") : null;
|
|
26981
|
+
};
|
|
26982
|
+
var appendMissingEnds = (sourceText) => {
|
|
26983
|
+
const subgraphCount = (sourceText.match(/^\s*subgraph\b/gm) || []).length;
|
|
26984
|
+
const endCount = (sourceText.match(/^\s*end\s*$/gm) || []).length;
|
|
26985
|
+
const missingCount = subgraphCount - endCount;
|
|
26986
|
+
if (missingCount <= 0) {
|
|
26987
|
+
return null;
|
|
26988
|
+
}
|
|
26989
|
+
const endings = Array.from({ length: missingCount }, () => "end").join("\n");
|
|
26990
|
+
return `${sourceText.trimEnd()}
|
|
26991
|
+
${endings}`;
|
|
26992
|
+
};
|
|
26993
|
+
var normalizeSmartQuotes = (sourceText) => sourceText.replace(/[“”]/g, '"').replace(/[‘’]/g, "'");
|
|
26994
|
+
var getMermaidAutoFixCandidates = (sourceText, errorMessage) => {
|
|
26995
|
+
if (!isMermaidAutoFixableError(errorMessage) || !sourceText.trim()) {
|
|
26996
|
+
return [];
|
|
26997
|
+
}
|
|
26998
|
+
const candidates = [];
|
|
26999
|
+
const seen = /* @__PURE__ */ new Set();
|
|
27000
|
+
const addCandidate = (candidate) => {
|
|
27001
|
+
if (!candidate || candidate === sourceText || seen.has(candidate)) {
|
|
27002
|
+
return;
|
|
27003
|
+
}
|
|
27004
|
+
seen.add(candidate);
|
|
27005
|
+
candidates.push(candidate);
|
|
27006
|
+
};
|
|
27007
|
+
const inactiveParticipant = getMermaidInactiveParticipant(errorMessage);
|
|
27008
|
+
if (inactiveParticipant) {
|
|
27009
|
+
addCandidate(
|
|
27010
|
+
removeLastDeactivateForParticipant(sourceText, inactiveParticipant)
|
|
27011
|
+
);
|
|
27012
|
+
addCandidate(
|
|
27013
|
+
removeAllDeactivateForParticipant(sourceText, inactiveParticipant)
|
|
27014
|
+
);
|
|
27015
|
+
}
|
|
27016
|
+
if (isMermaidParseSyntaxError(errorMessage)) {
|
|
27017
|
+
const lines = sourceText.split(/\r?\n/);
|
|
27018
|
+
const errorLineIndex = getErrorLineIndex(errorMessage, sourceText);
|
|
27019
|
+
const lineIndexesToTry = errorLineIndex == null ? [] : [errorLineIndex, errorLineIndex - 1, errorLineIndex + 1];
|
|
27020
|
+
for (const lineIndex of lineIndexesToTry) {
|
|
27021
|
+
addCandidate(
|
|
27022
|
+
replaceLineAt(
|
|
27023
|
+
lines,
|
|
27024
|
+
lineIndex,
|
|
27025
|
+
(line) => stripTrailingTokenAfterShape(line)
|
|
27026
|
+
)
|
|
27027
|
+
);
|
|
27028
|
+
addCandidate(
|
|
27029
|
+
replaceLineAt(
|
|
27030
|
+
lines,
|
|
27031
|
+
lineIndex,
|
|
27032
|
+
(line) => removeExtraArrowheadAfterEdgeLabel(line)
|
|
27033
|
+
)
|
|
27034
|
+
);
|
|
27035
|
+
}
|
|
27036
|
+
addCandidate(removeExtraArrowheadAfterEdgeLabel(sourceText));
|
|
27037
|
+
addCandidate(appendMissingEnds(sourceText));
|
|
27038
|
+
const normalizedQuotes = normalizeSmartQuotes(sourceText);
|
|
27039
|
+
addCandidate(normalizedQuotes === sourceText ? null : normalizedQuotes);
|
|
27040
|
+
}
|
|
27041
|
+
return candidates;
|
|
27042
|
+
};
|
|
27043
|
+
|
|
26349
27044
|
// components/TTDDialog/common.ts
|
|
26350
27045
|
var resetPreview = ({
|
|
26351
27046
|
canvasRef,
|
|
@@ -26384,17 +27079,21 @@ var convertMermaidToExcalidraw = async ({
|
|
|
26384
27079
|
try {
|
|
26385
27080
|
const api = await mermaidToExcalidrawLib.api;
|
|
26386
27081
|
try {
|
|
27082
|
+
ret = await api.parseMermaidToExcalidraw(mermaidDefinition);
|
|
27083
|
+
} catch (err) {
|
|
27084
|
+
const originalParseError = err;
|
|
27085
|
+
if (!mermaidDefinition.includes('"')) {
|
|
27086
|
+
return { success: false, error: originalParseError };
|
|
27087
|
+
}
|
|
26387
27088
|
try {
|
|
26388
|
-
ret = await api.parseMermaidToExcalidraw(mermaidDefinition);
|
|
26389
|
-
} catch (err) {
|
|
26390
27089
|
ret = await api.parseMermaidToExcalidraw(
|
|
26391
27090
|
mermaidDefinition.replace(/"/g, "'")
|
|
26392
27091
|
);
|
|
27092
|
+
} catch {
|
|
27093
|
+
return { success: false, error: originalParseError };
|
|
26393
27094
|
}
|
|
26394
|
-
} catch (err) {
|
|
26395
|
-
return { success: false, error: err };
|
|
26396
27095
|
}
|
|
26397
|
-
const { elements, files } = ret;
|
|
27096
|
+
const { elements, files = {} } = ret;
|
|
26398
27097
|
setError(null);
|
|
26399
27098
|
data.current = {
|
|
26400
27099
|
elements: convertToExcalidrawElements(elements, {
|
|
@@ -26456,15 +27155,37 @@ var insertToEditor = ({
|
|
|
26456
27155
|
import { Fragment as Fragment20, jsx as jsx121, jsxs as jsxs71 } from "react/jsx-runtime";
|
|
26457
27156
|
var MERMAID_EXAMPLE = "flowchart TD\n A[Christmas] -->|Get money| B(Go shopping)\n B --> C{Let me think}\n C -->|One| D[Laptop]\n C -->|Two| E[iPhone]\n C -->|Three| F[Car]";
|
|
26458
27157
|
var debouncedSaveMermaidDefinition = debounce(saveMermaidDataToStorage, 300);
|
|
27158
|
+
var AUTO_FIX_DEBOUNCE_MS = 500;
|
|
27159
|
+
var AUTO_FIX_MAX_DEPTH = 4;
|
|
27160
|
+
var AUTO_FIX_MAX_CANDIDATES = 30;
|
|
27161
|
+
var getErrorMessage = (error) => {
|
|
27162
|
+
if (error instanceof Error) {
|
|
27163
|
+
return error.message;
|
|
27164
|
+
}
|
|
27165
|
+
if (typeof error === "string") {
|
|
27166
|
+
return error;
|
|
27167
|
+
}
|
|
27168
|
+
if (error && typeof error === "object" && "message" in error && typeof error.message === "string") {
|
|
27169
|
+
return error.message;
|
|
27170
|
+
}
|
|
27171
|
+
return "";
|
|
27172
|
+
};
|
|
26459
27173
|
var MermaidToExcalidraw = ({
|
|
26460
27174
|
mermaidToExcalidrawLib,
|
|
26461
27175
|
isActive
|
|
26462
27176
|
}) => {
|
|
26463
|
-
const [text, setText] =
|
|
27177
|
+
const [text, setText] = useState34(
|
|
26464
27178
|
() => EditorLocalStorage.get(EDITOR_LS_KEYS.MERMAID_TO_EXCALIDRAW) || MERMAID_EXAMPLE
|
|
26465
27179
|
);
|
|
26466
|
-
const deferredText = useDeferredValue(text
|
|
26467
|
-
const [error, setError] =
|
|
27180
|
+
const deferredText = useDeferredValue(text);
|
|
27181
|
+
const [error, setError] = useState34(null);
|
|
27182
|
+
const [autoFixCandidate, setAutoFixCandidate] = useState34(null);
|
|
27183
|
+
const errorLine = (() => {
|
|
27184
|
+
if (!error?.message) {
|
|
27185
|
+
return null;
|
|
27186
|
+
}
|
|
27187
|
+
return getMermaidErrorLineNumber(error.message, deferredText);
|
|
27188
|
+
})();
|
|
26468
27189
|
const canvasRef = useRef30(null);
|
|
26469
27190
|
const data = useRef30({ elements: [], files: null });
|
|
26470
27191
|
const app = useApp();
|
|
@@ -26472,7 +27193,7 @@ var MermaidToExcalidraw = ({
|
|
|
26472
27193
|
useEffect35(() => {
|
|
26473
27194
|
const doRender = async () => {
|
|
26474
27195
|
try {
|
|
26475
|
-
if (!deferredText) {
|
|
27196
|
+
if (!deferredText.trim()) {
|
|
26476
27197
|
resetPreview({ canvasRef, setError });
|
|
26477
27198
|
return;
|
|
26478
27199
|
}
|
|
@@ -26505,6 +27226,75 @@ var MermaidToExcalidraw = ({
|
|
|
26505
27226
|
},
|
|
26506
27227
|
[]
|
|
26507
27228
|
);
|
|
27229
|
+
useEffect35(() => {
|
|
27230
|
+
const errorMessage = error?.message ?? "";
|
|
27231
|
+
const sourceText = deferredText;
|
|
27232
|
+
const shouldTryAutoFix = isActive && isMermaidAutoFixableError(errorMessage) && !!sourceText.trim() && mermaidToExcalidrawLib.loaded;
|
|
27233
|
+
if (!shouldTryAutoFix) {
|
|
27234
|
+
setAutoFixCandidate(null);
|
|
27235
|
+
return;
|
|
27236
|
+
}
|
|
27237
|
+
const candidates = getMermaidAutoFixCandidates(sourceText, errorMessage);
|
|
27238
|
+
if (!candidates.length) {
|
|
27239
|
+
setAutoFixCandidate(null);
|
|
27240
|
+
return;
|
|
27241
|
+
}
|
|
27242
|
+
let cancelled = false;
|
|
27243
|
+
const timer = setTimeout(async () => {
|
|
27244
|
+
try {
|
|
27245
|
+
const api = await mermaidToExcalidrawLib.api;
|
|
27246
|
+
const seen = /* @__PURE__ */ new Set([sourceText]);
|
|
27247
|
+
const queue = candidates.map((candidate) => ({
|
|
27248
|
+
text: candidate,
|
|
27249
|
+
depth: 1
|
|
27250
|
+
}));
|
|
27251
|
+
let triedCandidates = 0;
|
|
27252
|
+
while (queue.length > 0 && triedCandidates < AUTO_FIX_MAX_CANDIDATES) {
|
|
27253
|
+
const current = queue.shift();
|
|
27254
|
+
if (!current || seen.has(current.text)) {
|
|
27255
|
+
continue;
|
|
27256
|
+
}
|
|
27257
|
+
seen.add(current.text);
|
|
27258
|
+
triedCandidates += 1;
|
|
27259
|
+
try {
|
|
27260
|
+
await api.parseMermaidToExcalidraw(current.text);
|
|
27261
|
+
if (!cancelled) {
|
|
27262
|
+
setAutoFixCandidate(current.text);
|
|
27263
|
+
}
|
|
27264
|
+
return;
|
|
27265
|
+
} catch (candidateError) {
|
|
27266
|
+
if (current.depth >= AUTO_FIX_MAX_DEPTH) {
|
|
27267
|
+
continue;
|
|
27268
|
+
}
|
|
27269
|
+
const nextErrorMessage = getErrorMessage(candidateError);
|
|
27270
|
+
if (!nextErrorMessage) {
|
|
27271
|
+
continue;
|
|
27272
|
+
}
|
|
27273
|
+
const nextCandidates = getMermaidAutoFixCandidates(
|
|
27274
|
+
current.text,
|
|
27275
|
+
nextErrorMessage
|
|
27276
|
+
);
|
|
27277
|
+
for (const nextCandidate of nextCandidates) {
|
|
27278
|
+
if (!seen.has(nextCandidate)) {
|
|
27279
|
+
queue.push({
|
|
27280
|
+
text: nextCandidate,
|
|
27281
|
+
depth: current.depth + 1
|
|
27282
|
+
});
|
|
27283
|
+
}
|
|
27284
|
+
}
|
|
27285
|
+
}
|
|
27286
|
+
}
|
|
27287
|
+
} catch {
|
|
27288
|
+
}
|
|
27289
|
+
if (!cancelled) {
|
|
27290
|
+
setAutoFixCandidate(null);
|
|
27291
|
+
}
|
|
27292
|
+
}, AUTO_FIX_DEBOUNCE_MS);
|
|
27293
|
+
return () => {
|
|
27294
|
+
cancelled = true;
|
|
27295
|
+
clearTimeout(timer);
|
|
27296
|
+
};
|
|
27297
|
+
}, [deferredText, error?.message, isActive, mermaidToExcalidrawLib]);
|
|
26508
27298
|
const onInsertToEditor = () => {
|
|
26509
27299
|
insertToEditor({
|
|
26510
27300
|
app,
|
|
@@ -26513,14 +27303,53 @@ var MermaidToExcalidraw = ({
|
|
|
26513
27303
|
shouldSaveMermaidDataToStorage: true
|
|
26514
27304
|
});
|
|
26515
27305
|
};
|
|
27306
|
+
const onApplyAutoFix = () => {
|
|
27307
|
+
if (!autoFixCandidate) {
|
|
27308
|
+
return;
|
|
27309
|
+
}
|
|
27310
|
+
setText(autoFixCandidate);
|
|
27311
|
+
};
|
|
26516
27312
|
return /* @__PURE__ */ jsxs71(Fragment20, { children: [
|
|
26517
27313
|
/* @__PURE__ */ jsx121("div", { className: "ttd-dialog-desc", children: /* @__PURE__ */ jsx121(
|
|
26518
27314
|
Trans_default,
|
|
26519
27315
|
{
|
|
26520
27316
|
i18nKey: "mermaid.description",
|
|
26521
|
-
flowchartLink: (el) => /* @__PURE__ */ jsx121(
|
|
26522
|
-
|
|
26523
|
-
|
|
27317
|
+
flowchartLink: (el) => /* @__PURE__ */ jsx121(
|
|
27318
|
+
"a",
|
|
27319
|
+
{
|
|
27320
|
+
href: "https://mermaid.js.org/syntax/flowchart.html",
|
|
27321
|
+
target: "_blank",
|
|
27322
|
+
rel: "noreferrer",
|
|
27323
|
+
children: el
|
|
27324
|
+
}
|
|
27325
|
+
),
|
|
27326
|
+
sequenceLink: (el) => /* @__PURE__ */ jsx121(
|
|
27327
|
+
"a",
|
|
27328
|
+
{
|
|
27329
|
+
href: "https://mermaid.js.org/syntax/sequenceDiagram.html",
|
|
27330
|
+
target: "_blank",
|
|
27331
|
+
rel: "noreferrer",
|
|
27332
|
+
children: el
|
|
27333
|
+
}
|
|
27334
|
+
),
|
|
27335
|
+
classLink: (el) => /* @__PURE__ */ jsx121(
|
|
27336
|
+
"a",
|
|
27337
|
+
{
|
|
27338
|
+
href: "https://mermaid.js.org/syntax/classDiagram.html",
|
|
27339
|
+
target: "_blank",
|
|
27340
|
+
rel: "noreferrer",
|
|
27341
|
+
children: el
|
|
27342
|
+
}
|
|
27343
|
+
),
|
|
27344
|
+
erdLink: (el) => /* @__PURE__ */ jsx121(
|
|
27345
|
+
"a",
|
|
27346
|
+
{
|
|
27347
|
+
href: "https://mermaid.js.org/syntax/entityRelationshipDiagram.html",
|
|
27348
|
+
target: "_blank",
|
|
27349
|
+
rel: "noreferrer",
|
|
27350
|
+
children: el
|
|
27351
|
+
}
|
|
27352
|
+
)
|
|
26524
27353
|
}
|
|
26525
27354
|
) }),
|
|
26526
27355
|
/* @__PURE__ */ jsxs71(TTDDialogPanels, { children: [
|
|
@@ -26529,7 +27358,8 @@ var MermaidToExcalidraw = ({
|
|
|
26529
27358
|
{
|
|
26530
27359
|
input: text,
|
|
26531
27360
|
placeholder: t("mermaid.inputPlaceholder"),
|
|
26532
|
-
onChange: (
|
|
27361
|
+
onChange: (value) => setText(value),
|
|
27362
|
+
errorLine,
|
|
26533
27363
|
onKeyboardSubmit: () => {
|
|
26534
27364
|
onInsertToEditor();
|
|
26535
27365
|
}
|
|
@@ -26554,7 +27384,10 @@ var MermaidToExcalidraw = ({
|
|
|
26554
27384
|
{
|
|
26555
27385
|
canvasRef,
|
|
26556
27386
|
loaded: mermaidToExcalidrawLib.loaded,
|
|
26557
|
-
error
|
|
27387
|
+
error,
|
|
27388
|
+
sourceText: text,
|
|
27389
|
+
autoFixAvailable: !!autoFixCandidate,
|
|
27390
|
+
onApplyAutoFix
|
|
26558
27391
|
}
|
|
26559
27392
|
)
|
|
26560
27393
|
}
|
|
@@ -26582,7 +27415,7 @@ var TTDWelcomeMessage = () => {
|
|
|
26582
27415
|
|
|
26583
27416
|
// components/TTDDialog/Chat/ChatMessage.tsx
|
|
26584
27417
|
import clsx57 from "clsx";
|
|
26585
|
-
import { useState as
|
|
27418
|
+
import { useState as useState35, useEffect as useEffect36 } from "react";
|
|
26586
27419
|
import { Fragment as Fragment21, jsx as jsx123, jsxs as jsxs73 } from "react/jsx-runtime";
|
|
26587
27420
|
var ChatMessage = ({
|
|
26588
27421
|
message,
|
|
@@ -26596,7 +27429,7 @@ var ChatMessage = ({
|
|
|
26596
27429
|
renderWarning,
|
|
26597
27430
|
allowFixingParseError
|
|
26598
27431
|
}) => {
|
|
26599
|
-
const [canRetry, setCanRetry] =
|
|
27432
|
+
const [canRetry, setCanRetry] = useState35(false);
|
|
26600
27433
|
useEffect36(() => {
|
|
26601
27434
|
if (!message.error || !isLastMessage) {
|
|
26602
27435
|
return;
|
|
@@ -27122,7 +27955,7 @@ var useTTDChatStorage = ({
|
|
|
27122
27955
|
};
|
|
27123
27956
|
|
|
27124
27957
|
// components/TTDDialog/hooks/useMermaidRenderer.ts
|
|
27125
|
-
import { useCallback as useCallback16, useEffect as useEffect39, useMemo as
|
|
27958
|
+
import { useCallback as useCallback16, useEffect as useEffect39, useMemo as useMemo10, useRef as useRef33 } from "react";
|
|
27126
27959
|
|
|
27127
27960
|
// components/TTDDialog/utils/mermaidValidation.ts
|
|
27128
27961
|
var isValidMermaidSyntax = (content) => {
|
|
@@ -27171,7 +28004,7 @@ var useMermaidRenderer = ({
|
|
|
27171
28004
|
const [, setError] = useAtom(errorAtom);
|
|
27172
28005
|
const [showPreview, setShowPreview] = useAtom(showPreviewAtom);
|
|
27173
28006
|
const isRenderingRef = useRef33(false);
|
|
27174
|
-
const lastAssistantMessage =
|
|
28007
|
+
const lastAssistantMessage = useMemo10(
|
|
27175
28008
|
() => getLastAssistantMessage(chatHistory),
|
|
27176
28009
|
[chatHistory]
|
|
27177
28010
|
);
|
|
@@ -27217,7 +28050,7 @@ var useMermaidRenderer = ({
|
|
|
27217
28050
|
},
|
|
27218
28051
|
[canvasRef, mermaidToExcalidrawLib, setError, theme]
|
|
27219
28052
|
);
|
|
27220
|
-
const throttledRenderMermaid =
|
|
28053
|
+
const throttledRenderMermaid = useMemo10(() => {
|
|
27221
28054
|
const fn = async (content) => {
|
|
27222
28055
|
const now = Date.now();
|
|
27223
28056
|
const timeSinceLastRender = now - lastRenderTimeRef.current;
|
|
@@ -27474,13 +28307,13 @@ var useTextGeneration = ({
|
|
|
27474
28307
|
};
|
|
27475
28308
|
|
|
27476
28309
|
// components/TTDDialog/hooks/useChatManagement.ts
|
|
27477
|
-
import { useCallback as useCallback17, useState as
|
|
28310
|
+
import { useCallback as useCallback17, useState as useState36 } from "react";
|
|
27478
28311
|
var useChatManagement = ({
|
|
27479
28312
|
persistenceAdapter
|
|
27480
28313
|
}) => {
|
|
27481
28314
|
const setError = useSetAtom(errorAtom);
|
|
27482
28315
|
const [chatHistory, setChatHistory] = useAtom(chatHistoryAtom);
|
|
27483
|
-
const [isMenuOpen, setIsMenuOpen] =
|
|
28316
|
+
const [isMenuOpen, setIsMenuOpen] = useState36(false);
|
|
27484
28317
|
const { restoreChat, deleteChat, createNewChatId } = useTTDChatStorage({
|
|
27485
28318
|
persistenceAdapter
|
|
27486
28319
|
});
|
|
@@ -28052,7 +28885,7 @@ var TTDDialogBase = withInternalFallback(
|
|
|
28052
28885
|
...rest
|
|
28053
28886
|
}) => {
|
|
28054
28887
|
const app = useApp();
|
|
28055
|
-
const [mermaidToExcalidrawLib, setMermaidToExcalidrawLib] =
|
|
28888
|
+
const [mermaidToExcalidrawLib, setMermaidToExcalidrawLib] = useState37({
|
|
28056
28889
|
loaded: false,
|
|
28057
28890
|
api: import("@excalidraw/mermaid-to-excalidraw")
|
|
28058
28891
|
});
|
|
@@ -28108,11 +28941,11 @@ var TTDDialogBase = withInternalFallback(
|
|
|
28108
28941
|
// components/Stats/index.tsx
|
|
28109
28942
|
import clsx60 from "clsx";
|
|
28110
28943
|
import throttle2 from "lodash.throttle";
|
|
28111
|
-
import { useEffect as useEffect42, useMemo as
|
|
28944
|
+
import { useEffect as useEffect42, useMemo as useMemo13, useState as useState39, memo as memo5 } from "react";
|
|
28112
28945
|
|
|
28113
28946
|
// components/Stats/DragInput.tsx
|
|
28114
28947
|
import clsx59 from "clsx";
|
|
28115
|
-
import { useEffect as useEffect41, useRef as useRef37, useState as
|
|
28948
|
+
import { useEffect as useEffect41, useRef as useRef37, useState as useState38 } from "react";
|
|
28116
28949
|
|
|
28117
28950
|
// components/Stats/utils.ts
|
|
28118
28951
|
var SMALLEST_DELTA = 0.01;
|
|
@@ -28262,7 +29095,7 @@ var StatsDragInput = ({
|
|
|
28262
29095
|
const setAppState = useExcalidrawSetAppState();
|
|
28263
29096
|
const inputRef = useRef37(null);
|
|
28264
29097
|
const labelRef = useRef37(null);
|
|
28265
|
-
const [inputValue, setInputValue] =
|
|
29098
|
+
const [inputValue, setInputValue] = useState38(value.toString());
|
|
28266
29099
|
const stateRef = useRef37(null);
|
|
28267
29100
|
if (!stateRef.current) {
|
|
28268
29101
|
stateRef.current = {
|
|
@@ -29020,7 +29853,7 @@ var MultiAngle = ({
|
|
|
29020
29853
|
var MultiAngle_default = MultiAngle;
|
|
29021
29854
|
|
|
29022
29855
|
// components/Stats/MultiDimension.tsx
|
|
29023
|
-
import { useMemo as
|
|
29856
|
+
import { useMemo as useMemo11 } from "react";
|
|
29024
29857
|
import { jsx as jsx140 } from "react/jsx-runtime";
|
|
29025
29858
|
var STEP_SIZE7 = 10;
|
|
29026
29859
|
var getResizedUpdates = (anchorX, anchorY, scale, origElement) => {
|
|
@@ -29324,7 +30157,7 @@ var MultiDimension = ({
|
|
|
29324
30157
|
scene,
|
|
29325
30158
|
appState
|
|
29326
30159
|
}) => {
|
|
29327
|
-
const sizes =
|
|
30160
|
+
const sizes = useMemo11(
|
|
29328
30161
|
() => atomicUnits.map((atomicUnit) => {
|
|
29329
30162
|
const elementsInUnit = getElementsInAtomicUnit(atomicUnit, elementsMap);
|
|
29330
30163
|
if (elementsInUnit.length > 1) {
|
|
@@ -29468,7 +30301,7 @@ var MultiFontSize = ({
|
|
|
29468
30301
|
var MultiFontSize_default = MultiFontSize;
|
|
29469
30302
|
|
|
29470
30303
|
// components/Stats/MultiPosition.tsx
|
|
29471
|
-
import { useMemo as
|
|
30304
|
+
import { useMemo as useMemo12 } from "react";
|
|
29472
30305
|
import { jsx as jsx142 } from "react/jsx-runtime";
|
|
29473
30306
|
var moveElements = (property, changeInTopX, changeInTopY, originalElements, originalElementsMap, scene, appState) => {
|
|
29474
30307
|
for (let i = 0; i < originalElements.length; i++) {
|
|
@@ -29616,7 +30449,7 @@ var MultiPosition = ({
|
|
|
29616
30449
|
scene,
|
|
29617
30450
|
appState
|
|
29618
30451
|
}) => {
|
|
29619
|
-
const positions =
|
|
30452
|
+
const positions = useMemo12(
|
|
29620
30453
|
() => atomicUnits.map((atomicUnit) => {
|
|
29621
30454
|
const elementsInUnit = Object.keys(atomicUnit).map((id) => elementsMap.get(id)).filter((el2) => el2 !== void 0);
|
|
29622
30455
|
if (elementsInUnit.length > 1) {
|
|
@@ -29870,11 +30703,11 @@ var StatsInner = memo5(
|
|
|
29870
30703
|
const multipleElements = selectedElements.length > 1 ? selectedElements : null;
|
|
29871
30704
|
const cropMode = appState.croppingElementId && isImageElement(singleElement);
|
|
29872
30705
|
const unCroppedDimension = cropMode ? getUncroppedWidthAndHeight(singleElement) : null;
|
|
29873
|
-
const [sceneDimension, setSceneDimension] =
|
|
30706
|
+
const [sceneDimension, setSceneDimension] = useState39({
|
|
29874
30707
|
width: 0,
|
|
29875
30708
|
height: 0
|
|
29876
30709
|
});
|
|
29877
|
-
const throttledSetSceneDimension =
|
|
30710
|
+
const throttledSetSceneDimension = useMemo13(
|
|
29878
30711
|
() => throttle2((elements2) => {
|
|
29879
30712
|
const boundingBox = getCommonBounds(elements2);
|
|
29880
30713
|
setSceneDimension({
|
|
@@ -29891,10 +30724,10 @@ var StatsInner = memo5(
|
|
|
29891
30724
|
() => () => throttledSetSceneDimension.cancel(),
|
|
29892
30725
|
[throttledSetSceneDimension]
|
|
29893
30726
|
);
|
|
29894
|
-
const atomicUnits =
|
|
30727
|
+
const atomicUnits = useMemo13(() => {
|
|
29895
30728
|
return getAtomicUnits(selectedElements, appState);
|
|
29896
30729
|
}, [selectedElements, appState]);
|
|
29897
|
-
const _frameAndChildrenSelectedTogether =
|
|
30730
|
+
const _frameAndChildrenSelectedTogether = useMemo13(() => {
|
|
29898
30731
|
return frameAndChildrenSelectedTogether(selectedElements);
|
|
29899
30732
|
}, [selectedElements]);
|
|
29900
30733
|
return /* @__PURE__ */ jsx144("div", { className: "exc-stats", children: /* @__PURE__ */ jsxs80(Island, { padding: 3, children: [
|
|
@@ -30127,7 +30960,7 @@ var StatsInner = memo5(
|
|
|
30127
30960
|
);
|
|
30128
30961
|
|
|
30129
30962
|
// components/ElementLinkDialog.tsx
|
|
30130
|
-
import { useCallback as useCallback18, useEffect as useEffect43, useState as
|
|
30963
|
+
import { useCallback as useCallback18, useEffect as useEffect43, useState as useState40 } from "react";
|
|
30131
30964
|
import { jsx as jsx145, jsxs as jsxs81 } from "react/jsx-runtime";
|
|
30132
30965
|
var ElementLinkDialog = ({
|
|
30133
30966
|
sourceElementId,
|
|
@@ -30138,8 +30971,8 @@ var ElementLinkDialog = ({
|
|
|
30138
30971
|
}) => {
|
|
30139
30972
|
const elementsMap = scene.getNonDeletedElementsMap();
|
|
30140
30973
|
const originalLink = elementsMap.get(sourceElementId)?.link ?? null;
|
|
30141
|
-
const [nextLink, setNextLink] =
|
|
30142
|
-
const [linkEdited, setLinkEdited] =
|
|
30974
|
+
const [nextLink, setNextLink] = useState40(originalLink);
|
|
30975
|
+
const [linkEdited, setLinkEdited] = useState40(false);
|
|
30143
30976
|
useEffect43(() => {
|
|
30144
30977
|
const selectedElements = getSelectedElements(elementsMap, appState);
|
|
30145
30978
|
let nextLink2 = originalLink;
|
|
@@ -30259,13 +31092,13 @@ var ElementLinkDialog = ({
|
|
|
30259
31092
|
var ElementLinkDialog_default = ElementLinkDialog;
|
|
30260
31093
|
|
|
30261
31094
|
// components/ErrorDialog.tsx
|
|
30262
|
-
import React39, { useState as
|
|
31095
|
+
import React39, { useState as useState41 } from "react";
|
|
30263
31096
|
import { Fragment as Fragment24, jsx as jsx146 } from "react/jsx-runtime";
|
|
30264
31097
|
var ErrorDialog = ({
|
|
30265
31098
|
children,
|
|
30266
31099
|
onClose
|
|
30267
31100
|
}) => {
|
|
30268
|
-
const [modalIsShown, setModalIsShown] =
|
|
31101
|
+
const [modalIsShown, setModalIsShown] = useState41(!!children);
|
|
30269
31102
|
const { container: excalidrawContainer } = useExcalidrawContainer();
|
|
30270
31103
|
const handleClose = React39.useCallback(() => {
|
|
30271
31104
|
setModalIsShown(false);
|
|
@@ -31162,13 +31995,13 @@ var HintViewer = ({
|
|
|
31162
31995
|
};
|
|
31163
31996
|
|
|
31164
31997
|
// components/ImageExportDialog.tsx
|
|
31165
|
-
import { useEffect as useEffect44, useRef as useRef39, useState as
|
|
31998
|
+
import { useEffect as useEffect44, useRef as useRef39, useState as useState43 } from "react";
|
|
31166
31999
|
|
|
31167
32000
|
// hooks/useCopiedIndicator.ts
|
|
31168
|
-
import { useCallback as useCallback19, useRef as useRef38, useState as
|
|
32001
|
+
import { useCallback as useCallback19, useRef as useRef38, useState as useState42 } from "react";
|
|
31169
32002
|
var TIMEOUT = 2e3;
|
|
31170
32003
|
var useCopyStatus = () => {
|
|
31171
|
-
const [copyStatus, setCopyStatus] =
|
|
32004
|
+
const [copyStatus, setCopyStatus] = useState42(null);
|
|
31172
32005
|
const timeoutRef = useRef38(0);
|
|
31173
32006
|
const onCopy = () => {
|
|
31174
32007
|
clearTimeout(timeoutRef.current);
|
|
@@ -31235,33 +32068,32 @@ var ImageExportModal = ({
|
|
|
31235
32068
|
files,
|
|
31236
32069
|
actionManager,
|
|
31237
32070
|
onExportImage,
|
|
31238
|
-
name
|
|
32071
|
+
name,
|
|
32072
|
+
exportWithDarkMode
|
|
31239
32073
|
}) => {
|
|
31240
32074
|
const hasSelection = isSomeElementSelected(
|
|
31241
32075
|
elementsSnapshot,
|
|
31242
32076
|
appStateSnapshot
|
|
31243
32077
|
);
|
|
31244
|
-
const [projectName, setProjectName] =
|
|
31245
|
-
const [exportSelectionOnly, setExportSelectionOnly] =
|
|
31246
|
-
const [exportWithBackground, setExportWithBackground] =
|
|
32078
|
+
const [projectName, setProjectName] = useState43(name);
|
|
32079
|
+
const [exportSelectionOnly, setExportSelectionOnly] = useState43(hasSelection);
|
|
32080
|
+
const [exportWithBackground, setExportWithBackground] = useState43(
|
|
31247
32081
|
appStateSnapshot.exportBackground
|
|
31248
32082
|
);
|
|
31249
|
-
const [
|
|
31250
|
-
appStateSnapshot.exportWithDarkMode
|
|
31251
|
-
);
|
|
31252
|
-
const [embedScene, setEmbedScene] = useState42(
|
|
32083
|
+
const [embedScene, setEmbedScene] = useState43(
|
|
31253
32084
|
appStateSnapshot.exportEmbedScene
|
|
31254
32085
|
);
|
|
31255
|
-
const [exportScale, setExportScale] =
|
|
32086
|
+
const [exportScale, setExportScale] = useState43(appStateSnapshot.exportScale);
|
|
31256
32087
|
const previewRef = useRef39(null);
|
|
31257
|
-
const
|
|
32088
|
+
const previewRenderRequestIdRef = useRef39(0);
|
|
32089
|
+
const [renderError, setRenderError] = useState43(null);
|
|
31258
32090
|
const { onCopy, copyStatus, resetCopyStatus } = useCopyStatus();
|
|
31259
32091
|
useEffect44(() => {
|
|
31260
32092
|
resetCopyStatus();
|
|
31261
32093
|
}, [
|
|
31262
32094
|
projectName,
|
|
31263
32095
|
exportWithBackground,
|
|
31264
|
-
|
|
32096
|
+
exportWithDarkMode,
|
|
31265
32097
|
exportScale,
|
|
31266
32098
|
embedScene,
|
|
31267
32099
|
resetCopyStatus
|
|
@@ -31281,6 +32113,10 @@ var ImageExportModal = ({
|
|
|
31281
32113
|
if (!maxWidth) {
|
|
31282
32114
|
return;
|
|
31283
32115
|
}
|
|
32116
|
+
const requestId = ++previewRenderRequestIdRef.current;
|
|
32117
|
+
const isStaleRequest = () => {
|
|
32118
|
+
return requestId !== previewRenderRequestIdRef.current;
|
|
32119
|
+
};
|
|
31284
32120
|
exportToCanvas2({
|
|
31285
32121
|
data: {
|
|
31286
32122
|
elements: exportedElements,
|
|
@@ -31292,27 +32128,40 @@ var ImageExportModal = ({
|
|
|
31292
32128
|
files
|
|
31293
32129
|
},
|
|
31294
32130
|
config: {
|
|
31295
|
-
canvasBackgroundColor:
|
|
32131
|
+
canvasBackgroundColor: exportWithBackground ? appStateSnapshot.viewBackgroundColor : false,
|
|
31296
32132
|
padding: DEFAULT_EXPORT_PADDING,
|
|
31297
|
-
theme:
|
|
32133
|
+
theme: exportWithDarkMode ? "dark" : "light",
|
|
31298
32134
|
scale: exportScale,
|
|
31299
32135
|
maxWidthOrHeight: Math.max(maxWidth, maxHeight),
|
|
31300
32136
|
exportingFrame
|
|
31301
32137
|
}
|
|
31302
|
-
}).then((canvas) => {
|
|
31303
|
-
|
|
31304
|
-
|
|
31305
|
-
|
|
31306
|
-
|
|
31307
|
-
|
|
32138
|
+
}).then(async (canvas) => {
|
|
32139
|
+
if (isStaleRequest()) {
|
|
32140
|
+
return;
|
|
32141
|
+
}
|
|
32142
|
+
try {
|
|
32143
|
+
await canvasToBlob(canvas);
|
|
32144
|
+
} catch (error) {
|
|
32145
|
+
if (error.name === "CANVAS_POSSIBLY_TOO_BIG") {
|
|
31308
32146
|
throw new Error(t("canvasError.canvasTooBig"));
|
|
31309
32147
|
}
|
|
31310
|
-
throw
|
|
31311
|
-
}
|
|
32148
|
+
throw error;
|
|
32149
|
+
}
|
|
32150
|
+
if (isStaleRequest()) {
|
|
32151
|
+
return;
|
|
32152
|
+
}
|
|
32153
|
+
setRenderError(null);
|
|
32154
|
+
previewNode.replaceChildren(canvas);
|
|
31312
32155
|
}).catch((error) => {
|
|
32156
|
+
if (isStaleRequest()) {
|
|
32157
|
+
return;
|
|
32158
|
+
}
|
|
31313
32159
|
console.error(error);
|
|
31314
32160
|
setRenderError(error);
|
|
31315
32161
|
});
|
|
32162
|
+
return () => {
|
|
32163
|
+
previewRenderRequestIdRef.current += 1;
|
|
32164
|
+
};
|
|
31316
32165
|
}, [
|
|
31317
32166
|
appStateSnapshot,
|
|
31318
32167
|
files,
|
|
@@ -31320,7 +32169,7 @@ var ImageExportModal = ({
|
|
|
31320
32169
|
exportingFrame,
|
|
31321
32170
|
projectName,
|
|
31322
32171
|
exportWithBackground,
|
|
31323
|
-
|
|
32172
|
+
exportWithDarkMode,
|
|
31324
32173
|
exportScale,
|
|
31325
32174
|
embedScene
|
|
31326
32175
|
]);
|
|
@@ -31396,9 +32245,8 @@ var ImageExportModal = ({
|
|
|
31396
32245
|
Switch,
|
|
31397
32246
|
{
|
|
31398
32247
|
name: "exportDarkModeSwitch",
|
|
31399
|
-
checked:
|
|
32248
|
+
checked: exportWithDarkMode,
|
|
31400
32249
|
onChange: (checked) => {
|
|
31401
|
-
setExportDarkMode(checked);
|
|
31402
32250
|
actionManager.executeAction(
|
|
31403
32251
|
actionExportWithDarkMode,
|
|
31404
32252
|
"ui",
|
|
@@ -31533,7 +32381,7 @@ var ImageExportDialog = ({
|
|
|
31533
32381
|
onCloseRequest,
|
|
31534
32382
|
name
|
|
31535
32383
|
}) => {
|
|
31536
|
-
const [{ appStateSnapshot, elementsSnapshot }] =
|
|
32384
|
+
const [{ appStateSnapshot, elementsSnapshot }] = useState43(() => {
|
|
31537
32385
|
return {
|
|
31538
32386
|
appStateSnapshot: cloneJSON(appState),
|
|
31539
32387
|
elementsSnapshot: cloneJSON(elements)
|
|
@@ -31547,7 +32395,8 @@ var ImageExportDialog = ({
|
|
|
31547
32395
|
files,
|
|
31548
32396
|
actionManager,
|
|
31549
32397
|
onExportImage,
|
|
31550
|
-
name
|
|
32398
|
+
name,
|
|
32399
|
+
exportWithDarkMode: appState.exportWithDarkMode
|
|
31551
32400
|
}
|
|
31552
32401
|
) });
|
|
31553
32402
|
};
|
|
@@ -33224,7 +34073,8 @@ var renderLinearPointHandles = (context, appState, element, elementsMap) => {
|
|
|
33224
34073
|
points[idx + 1],
|
|
33225
34074
|
points[idx],
|
|
33226
34075
|
idx,
|
|
33227
|
-
appState.zoom
|
|
34076
|
+
appState.zoom,
|
|
34077
|
+
elementsMap
|
|
33228
34078
|
)) {
|
|
33229
34079
|
renderSingleLinearPoint(
|
|
33230
34080
|
context,
|
|
@@ -33465,20 +34315,48 @@ var renderCropHandles = (context, renderConfig, appState, croppingElement, eleme
|
|
|
33465
34315
|
};
|
|
33466
34316
|
var renderTextBox = (text, context, appState, selectionColor) => {
|
|
33467
34317
|
context.save();
|
|
33468
|
-
const padding =
|
|
34318
|
+
const padding = getTextBoxPadding(appState.zoom.value);
|
|
33469
34319
|
const width = text.width + padding * 2;
|
|
33470
34320
|
const height = text.height + padding * 2;
|
|
33471
|
-
const cx = text.x + width / 2;
|
|
33472
|
-
const cy = text.y + height / 2;
|
|
33473
|
-
const shiftX = -(width / 2 + padding);
|
|
33474
|
-
const shiftY = -(height / 2 + padding);
|
|
34321
|
+
const cx = text.x + text.width / 2;
|
|
34322
|
+
const cy = text.y + text.height / 2;
|
|
34323
|
+
const shiftX = -(text.width / 2 + padding);
|
|
34324
|
+
const shiftY = -(text.height / 2 + padding);
|
|
33475
34325
|
context.translate(cx + appState.scrollX, cy + appState.scrollY);
|
|
33476
34326
|
context.rotate(text.angle);
|
|
33477
34327
|
context.lineWidth = 1 / appState.zoom.value;
|
|
33478
34328
|
context.strokeStyle = selectionColor;
|
|
34329
|
+
context.globalAlpha = 0.5;
|
|
34330
|
+
context.setLineDash([6 / appState.zoom.value, 4 / appState.zoom.value]);
|
|
33479
34331
|
context.strokeRect(shiftX, shiftY, width, height);
|
|
33480
34332
|
context.restore();
|
|
33481
34333
|
};
|
|
34334
|
+
var renderResetAutoResizeHandle = (text, context, appState, selectionColor, formFactor) => {
|
|
34335
|
+
const autoResizeHandle = getTextAutoResizeHandle(
|
|
34336
|
+
text,
|
|
34337
|
+
appState.zoom.value,
|
|
34338
|
+
formFactor
|
|
34339
|
+
);
|
|
34340
|
+
if (!autoResizeHandle) {
|
|
34341
|
+
return;
|
|
34342
|
+
}
|
|
34343
|
+
context.save();
|
|
34344
|
+
context.globalAlpha = 0.5;
|
|
34345
|
+
context.lineWidth = 1.5 / appState.zoom.value;
|
|
34346
|
+
context.lineCap = "round";
|
|
34347
|
+
context.strokeStyle = selectionColor;
|
|
34348
|
+
context.beginPath();
|
|
34349
|
+
context.moveTo(
|
|
34350
|
+
autoResizeHandle.start[0] + appState.scrollX,
|
|
34351
|
+
autoResizeHandle.start[1] + appState.scrollY
|
|
34352
|
+
);
|
|
34353
|
+
context.lineTo(
|
|
34354
|
+
autoResizeHandle.end[0] + appState.scrollX,
|
|
34355
|
+
autoResizeHandle.end[1] + appState.scrollY
|
|
34356
|
+
);
|
|
34357
|
+
context.stroke();
|
|
34358
|
+
context.restore();
|
|
34359
|
+
};
|
|
33482
34360
|
var _renderInteractiveScene = ({
|
|
33483
34361
|
app,
|
|
33484
34362
|
canvas,
|
|
@@ -33537,7 +34415,17 @@ var _renderInteractiveScene = ({
|
|
|
33537
34415
|
console.error(error);
|
|
33538
34416
|
}
|
|
33539
34417
|
}
|
|
33540
|
-
|
|
34418
|
+
const activeTextElement = getActiveTextElement(selectedElements, appState);
|
|
34419
|
+
if (activeTextElement && !activeTextElement.autoResize) {
|
|
34420
|
+
renderResetAutoResizeHandle(
|
|
34421
|
+
activeTextElement,
|
|
34422
|
+
context,
|
|
34423
|
+
appState,
|
|
34424
|
+
renderConfig.selectionColor,
|
|
34425
|
+
editorInterface.formFactor
|
|
34426
|
+
);
|
|
34427
|
+
}
|
|
34428
|
+
if (appState.editingTextElement) {
|
|
33541
34429
|
const textElement = allElementsMap.get(appState.editingTextElement.id);
|
|
33542
34430
|
if (textElement && !textElement.autoResize) {
|
|
33543
34431
|
renderTextBox(
|
|
@@ -33982,6 +34870,7 @@ var InteractiveCanvas = (props) => {
|
|
|
33982
34870
|
height: props.appState.height * props.scale,
|
|
33983
34871
|
ref: props.handleCanvasRef,
|
|
33984
34872
|
onContextMenu: props.onContextMenu,
|
|
34873
|
+
onClick: props.onClick,
|
|
33985
34874
|
onPointerMove: props.onPointerMove,
|
|
33986
34875
|
onPointerUp: props.onPointerUp,
|
|
33987
34876
|
onPointerCancel: props.onPointerCancel,
|
|
@@ -34409,6 +35298,7 @@ var gesture = {
|
|
|
34409
35298
|
initialDistance: null,
|
|
34410
35299
|
initialScale: null
|
|
34411
35300
|
};
|
|
35301
|
+
var SESSION_EXPORT_THEME_OVERRIDE = void 0;
|
|
34412
35302
|
var App = class _App extends React46.Component {
|
|
34413
35303
|
constructor(props) {
|
|
34414
35304
|
super(props);
|
|
@@ -34456,9 +35346,15 @@ var App = class _App extends React46.Component {
|
|
|
34456
35346
|
__publicField(this, "hitLinkElement");
|
|
34457
35347
|
__publicField(this, "lastPointerDownEvent", null);
|
|
34458
35348
|
__publicField(this, "lastPointerUpEvent", null);
|
|
35349
|
+
// TODO this is a hack and we should ideally unify touch and pointer events
|
|
35350
|
+
// and implement our own double click handling end-to-end (currently we're
|
|
35351
|
+
// using a mix of native browser for click events and manual for touch -
|
|
35352
|
+
// and browser doubleClick sucks to begin with)
|
|
35353
|
+
__publicField(this, "lastPointerUpIsDoubleClick", false);
|
|
34459
35354
|
__publicField(this, "lastPointerMoveEvent", null);
|
|
34460
35355
|
/** current frame pointer cords */
|
|
34461
35356
|
__publicField(this, "lastPointerMoveCoords", null);
|
|
35357
|
+
__publicField(this, "lastCompletedCanvasClicks", []);
|
|
34462
35358
|
/** previous frame pointer coords */
|
|
34463
35359
|
__publicField(this, "previousPointerMoveCoords", null);
|
|
34464
35360
|
__publicField(this, "lastViewportPosition", { x: 0, y: 0 });
|
|
@@ -34486,6 +35382,20 @@ var App = class _App extends React46.Component {
|
|
|
34486
35382
|
__publicField(this, "getEffectiveGridSize", () => {
|
|
34487
35383
|
return isGridModeEnabled(this) ? this.state.gridSize : null;
|
|
34488
35384
|
});
|
|
35385
|
+
__publicField(this, "getTextCreationGridPoint", (x, y) => {
|
|
35386
|
+
const effectiveGridSize = this.getEffectiveGridSize();
|
|
35387
|
+
if (effectiveGridSize === null) {
|
|
35388
|
+
return null;
|
|
35389
|
+
}
|
|
35390
|
+
const getTextCreationGridCoordinate = (coordinate) => {
|
|
35391
|
+
const topLeftGridPoint = Math.floor(coordinate / effectiveGridSize) * effectiveGridSize;
|
|
35392
|
+
return topLeftGridPoint;
|
|
35393
|
+
};
|
|
35394
|
+
return {
|
|
35395
|
+
x: getTextCreationGridCoordinate(x),
|
|
35396
|
+
y: getTextCreationGridCoordinate(y)
|
|
35397
|
+
};
|
|
35398
|
+
});
|
|
34489
35399
|
__publicField(this, "handleIframeLikeElementHover", ({
|
|
34490
35400
|
hitElement,
|
|
34491
35401
|
scenePointer,
|
|
@@ -34507,6 +35417,9 @@ var App = class _App extends React46.Component {
|
|
|
34507
35417
|
}
|
|
34508
35418
|
return false;
|
|
34509
35419
|
});
|
|
35420
|
+
__publicField(this, "isDoubleClick", (lastPointerEvent, currentPointerEvent) => {
|
|
35421
|
+
return lastPointerEvent != null && currentPointerEvent.timeStamp - lastPointerEvent.timeStamp <= TAP_TWICE_TIMEOUT;
|
|
35422
|
+
});
|
|
34510
35423
|
__publicField(this, "updateEmbedValidationStatus", (element, status) => {
|
|
34511
35424
|
this.embedsValidationStatus.set(element.id, status);
|
|
34512
35425
|
ShapeCache.delete(element);
|
|
@@ -35223,7 +36136,12 @@ var App = class _App extends React46.Component {
|
|
|
35223
36136
|
this.deselectElements();
|
|
35224
36137
|
this.handleCanvasDoubleClick({
|
|
35225
36138
|
clientX: touch.clientX,
|
|
35226
|
-
clientY: touch.clientY
|
|
36139
|
+
clientY: touch.clientY,
|
|
36140
|
+
type: "touch",
|
|
36141
|
+
altKey: false,
|
|
36142
|
+
ctrlKey: false,
|
|
36143
|
+
metaKey: false,
|
|
36144
|
+
shiftKey: false
|
|
35227
36145
|
});
|
|
35228
36146
|
}
|
|
35229
36147
|
didTapTwice = false;
|
|
@@ -36514,12 +37432,46 @@ var App = class _App extends React46.Component {
|
|
|
36514
37432
|
}
|
|
36515
37433
|
gesture.initialScale = null;
|
|
36516
37434
|
}));
|
|
37435
|
+
__publicField(this, "isHittingTextAutoResizeHandle", (selectedElements, point) => {
|
|
37436
|
+
const activeTextElement = getActiveTextElement(
|
|
37437
|
+
selectedElements,
|
|
37438
|
+
this.state
|
|
37439
|
+
);
|
|
37440
|
+
if (activeTextElement && !activeTextElement.isDeleted && !activeTextElement.autoResize && isPointHittingTextAutoResizeHandle(
|
|
37441
|
+
point,
|
|
37442
|
+
activeTextElement,
|
|
37443
|
+
this.state.zoom.value,
|
|
37444
|
+
this.editorInterface.formFactor
|
|
37445
|
+
)) {
|
|
37446
|
+
return true;
|
|
37447
|
+
}
|
|
37448
|
+
return false;
|
|
37449
|
+
});
|
|
37450
|
+
__publicField(this, "handleTextAutoResizeHandlePointerDown", (selectedElements, point) => {
|
|
37451
|
+
const activeTextElement = getActiveTextElement(
|
|
37452
|
+
selectedElements,
|
|
37453
|
+
this.state
|
|
37454
|
+
);
|
|
37455
|
+
if (!activeTextElement || !this.isHittingTextAutoResizeHandle(selectedElements, point)) {
|
|
37456
|
+
return false;
|
|
37457
|
+
}
|
|
37458
|
+
this.actionManager.executeAction(
|
|
37459
|
+
actionTextAutoResize,
|
|
37460
|
+
"ui",
|
|
37461
|
+
// we need to pass down the element since it may already be deselected
|
|
37462
|
+
// due to the pointerdown
|
|
37463
|
+
activeTextElement
|
|
37464
|
+
);
|
|
37465
|
+
this.resetCursor();
|
|
37466
|
+
return true;
|
|
37467
|
+
});
|
|
36517
37468
|
__publicField(this, "startTextEditing", ({
|
|
36518
37469
|
sceneX,
|
|
36519
37470
|
sceneY,
|
|
36520
37471
|
insertAtParentCenter = true,
|
|
36521
37472
|
container,
|
|
36522
|
-
autoEdit = true
|
|
37473
|
+
autoEdit = true,
|
|
37474
|
+
initialCaretSceneCoords
|
|
36523
37475
|
}) => {
|
|
36524
37476
|
let shouldBindToContainer = false;
|
|
36525
37477
|
let parentCenterPosition = insertAtParentCenter && this.getTextWysiwygSnappedToCenterPosition(
|
|
@@ -36537,22 +37489,7 @@ var App = class _App extends React46.Component {
|
|
|
36537
37489
|
shouldBindToContainer = true;
|
|
36538
37490
|
}
|
|
36539
37491
|
}
|
|
36540
|
-
|
|
36541
|
-
const selectedElements = this.scene.getSelectedElements(this.state);
|
|
36542
|
-
if (selectedElements.length === 1) {
|
|
36543
|
-
if (isTextElement(selectedElements[0])) {
|
|
36544
|
-
existingTextElement = selectedElements[0];
|
|
36545
|
-
} else if (container) {
|
|
36546
|
-
existingTextElement = getBoundTextElement(
|
|
36547
|
-
selectedElements[0],
|
|
36548
|
-
this.scene.getNonDeletedElementsMap()
|
|
36549
|
-
);
|
|
36550
|
-
} else {
|
|
36551
|
-
existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);
|
|
36552
|
-
}
|
|
36553
|
-
} else {
|
|
36554
|
-
existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);
|
|
36555
|
-
}
|
|
37492
|
+
const existingTextElement = this.getSelectedTextElement(container) || this.getTextElementAtPosition(sceneX, sceneY);
|
|
36556
37493
|
const fontFamily = existingTextElement?.fontFamily || this.state.currentItemFontFamily;
|
|
36557
37494
|
const lineHeight = existingTextElement?.lineHeight || getLineHeight(fontFamily);
|
|
36558
37495
|
const fontSize = this.state.currentItemFontSize;
|
|
@@ -36587,9 +37524,23 @@ var App = class _App extends React46.Component {
|
|
|
36587
37524
|
x: sceneX,
|
|
36588
37525
|
y: sceneY
|
|
36589
37526
|
});
|
|
37527
|
+
const textCreationGridPoint = this.getTextCreationGridPoint(sceneX, sceneY);
|
|
37528
|
+
const newTextElementPosition = parentCenterPosition ? {
|
|
37529
|
+
x: parentCenterPosition.elementCenterX,
|
|
37530
|
+
y: parentCenterPosition.elementCenterY
|
|
37531
|
+
} : !existingTextElement ? {
|
|
37532
|
+
x: textCreationGridPoint?.x ?? sceneX,
|
|
37533
|
+
y: textCreationGridPoint === null ? (
|
|
37534
|
+
// Free text starts from a point cursor, so center the first line box on it.
|
|
37535
|
+
sceneY - getLineHeightInPx(fontSize, lineHeight) / 2
|
|
37536
|
+
) : textCreationGridPoint.y
|
|
37537
|
+
} : {
|
|
37538
|
+
x: sceneX,
|
|
37539
|
+
y: sceneY
|
|
37540
|
+
};
|
|
36590
37541
|
const element = existingTextElement || newTextElement({
|
|
36591
|
-
x:
|
|
36592
|
-
y:
|
|
37542
|
+
x: newTextElementPosition.x,
|
|
37543
|
+
y: newTextElementPosition.y,
|
|
36593
37544
|
strokeColor: this.state.currentItemStrokeColor,
|
|
36594
37545
|
backgroundColor: this.state.currentItemBackgroundColor,
|
|
36595
37546
|
fillStyle: this.state.currentItemFillStyle,
|
|
@@ -36627,7 +37578,8 @@ var App = class _App extends React46.Component {
|
|
|
36627
37578
|
}
|
|
36628
37579
|
if (autoEdit || existingTextElement || container) {
|
|
36629
37580
|
this.handleTextWysiwyg(element, {
|
|
36630
|
-
isExistingElement: !!existingTextElement
|
|
37581
|
+
isExistingElement: !!existingTextElement,
|
|
37582
|
+
initialCaretSceneCoords: existingTextElement ? initialCaretSceneCoords : null
|
|
36631
37583
|
});
|
|
36632
37584
|
} else {
|
|
36633
37585
|
this.setState({
|
|
@@ -36650,7 +37602,26 @@ var App = class _App extends React46.Component {
|
|
|
36650
37602
|
});
|
|
36651
37603
|
}
|
|
36652
37604
|
});
|
|
37605
|
+
__publicField(this, "shouldHandleBrowserCanvasDoubleClick", (type) => {
|
|
37606
|
+
if (type === "touch") {
|
|
37607
|
+
return true;
|
|
37608
|
+
}
|
|
37609
|
+
if (this.lastCompletedCanvasClicks.length === 0) {
|
|
37610
|
+
return true;
|
|
37611
|
+
}
|
|
37612
|
+
if (this.lastCompletedCanvasClicks.length < 2) {
|
|
37613
|
+
return false;
|
|
37614
|
+
}
|
|
37615
|
+
const [firstClick, secondClick] = this.lastCompletedCanvasClicks;
|
|
37616
|
+
return pointDistance(
|
|
37617
|
+
pointFrom(firstClick.x, firstClick.y),
|
|
37618
|
+
pointFrom(secondClick.x, secondClick.y)
|
|
37619
|
+
) <= DOUBLE_TAP_POSITION_THRESHOLD;
|
|
37620
|
+
});
|
|
36653
37621
|
__publicField(this, "handleCanvasDoubleClick", (event) => {
|
|
37622
|
+
if (this.state.editingTextElement || !this.shouldHandleBrowserCanvasDoubleClick(event.type)) {
|
|
37623
|
+
return;
|
|
37624
|
+
}
|
|
36654
37625
|
if (this.state.multiElement) {
|
|
36655
37626
|
return;
|
|
36656
37627
|
}
|
|
@@ -36787,6 +37758,19 @@ var App = class _App extends React46.Component {
|
|
|
36787
37758
|
}
|
|
36788
37759
|
}
|
|
36789
37760
|
});
|
|
37761
|
+
__publicField(this, "handleCanvasClick", (event) => {
|
|
37762
|
+
if (event.button !== POINTER_BUTTON.MAIN) {
|
|
37763
|
+
this.lastCompletedCanvasClicks = [];
|
|
37764
|
+
return;
|
|
37765
|
+
}
|
|
37766
|
+
this.lastCompletedCanvasClicks = [
|
|
37767
|
+
...this.lastCompletedCanvasClicks.slice(-1),
|
|
37768
|
+
{
|
|
37769
|
+
x: event.clientX,
|
|
37770
|
+
y: event.clientY
|
|
37771
|
+
}
|
|
37772
|
+
];
|
|
37773
|
+
});
|
|
36790
37774
|
__publicField(this, "getElementLinkAtPosition", (scenePointer, hitElementMightBeLocked) => {
|
|
36791
37775
|
if (hitElementMightBeLocked && hitElementMightBeLocked.locked) {
|
|
36792
37776
|
return void 0;
|
|
@@ -37227,6 +38211,10 @@ var App = class _App extends React46.Component {
|
|
|
37227
38211
|
}
|
|
37228
38212
|
const elements = this.scene.getNonDeletedElements();
|
|
37229
38213
|
const selectedElements = this.scene.getSelectedElements(this.state);
|
|
38214
|
+
if (this.isHittingTextAutoResizeHandle(selectedElements, scenePointer)) {
|
|
38215
|
+
setCursor(this.interactiveCanvas, CURSOR_TYPE.POINTER);
|
|
38216
|
+
return;
|
|
38217
|
+
}
|
|
37230
38218
|
if (selectedElements.length === 1 && !isOverScrollBar && !this.state.selectedLinearElement?.isEditing) {
|
|
37231
38219
|
if (this.state.selectedLinearElement) {
|
|
37232
38220
|
this.handleHoverSelectedLinearElement(
|
|
@@ -37329,7 +38317,8 @@ var App = class _App extends React46.Component {
|
|
|
37329
38317
|
setCursor(this.interactiveCanvas, CURSOR_TYPE.AUTO);
|
|
37330
38318
|
} else if (
|
|
37331
38319
|
// if using cmd/ctrl, we're not dragging
|
|
37332
|
-
!event[KEYS.CTRL_OR_CMD]
|
|
38320
|
+
!event[KEYS.CTRL_OR_CMD] && // editing text -> don't show move cursor when hovering over its bbox
|
|
38321
|
+
hitElement?.id !== this.state.editingTextElement?.id
|
|
37333
38322
|
) {
|
|
37334
38323
|
if ((hitElement || this.isHittingCommonBoundingBoxOfSelectedElements(
|
|
37335
38324
|
scenePointer,
|
|
@@ -37390,6 +38379,7 @@ var App = class _App extends React46.Component {
|
|
|
37390
38379
|
invalidateContextMenu = true;
|
|
37391
38380
|
});
|
|
37392
38381
|
__publicField(this, "handleCanvasPointerDown", (event) => {
|
|
38382
|
+
const selectedElements = this.scene.getSelectedElements(this.state);
|
|
37393
38383
|
if (!event.ctrlKey) {
|
|
37394
38384
|
const preferenceEnabled = this.state.bindingPreference === "enabled";
|
|
37395
38385
|
if (this.state.isBindingEnabled !== preferenceEnabled) {
|
|
@@ -37538,6 +38528,12 @@ var App = class _App extends React46.Component {
|
|
|
37538
38528
|
this.setState({
|
|
37539
38529
|
selectedElementsAreBeingDragged: false
|
|
37540
38530
|
});
|
|
38531
|
+
if (this.props.interactive !== false && this.handleTextAutoResizeHandlePointerDown(
|
|
38532
|
+
selectedElements,
|
|
38533
|
+
pointerDownState.origin
|
|
38534
|
+
)) {
|
|
38535
|
+
return;
|
|
38536
|
+
}
|
|
37541
38537
|
if (this.props.interactive !== false && this.handleDraggingScrollBar(event, pointerDownState)) {
|
|
37542
38538
|
return;
|
|
37543
38539
|
}
|
|
@@ -37686,6 +38682,10 @@ var App = class _App extends React46.Component {
|
|
|
37686
38682
|
this.resetDelayedBindMode();
|
|
37687
38683
|
}
|
|
37688
38684
|
this.removePointer(event);
|
|
38685
|
+
this.lastPointerUpIsDoubleClick = this.isDoubleClick(
|
|
38686
|
+
this.lastPointerUpEvent,
|
|
38687
|
+
event
|
|
38688
|
+
);
|
|
37689
38689
|
this.lastPointerUpEvent = event;
|
|
37690
38690
|
if (!event.ctrlKey) {
|
|
37691
38691
|
const preferenceEnabled = this.state.bindingPreference === "enabled";
|
|
@@ -38145,7 +39145,8 @@ var App = class _App extends React46.Component {
|
|
|
38145
39145
|
sceneY,
|
|
38146
39146
|
insertAtParentCenter: !event.altKey,
|
|
38147
39147
|
container,
|
|
38148
|
-
autoEdit: false
|
|
39148
|
+
autoEdit: false,
|
|
39149
|
+
initialCaretSceneCoords: { x: sceneX, y: sceneY }
|
|
38149
39150
|
});
|
|
38150
39151
|
resetCursor(this.interactiveCanvas);
|
|
38151
39152
|
if (!this.state.activeTool.locked) {
|
|
@@ -39652,6 +40653,7 @@ var App = class _App extends React46.Component {
|
|
|
39652
40653
|
this.state = {
|
|
39653
40654
|
...defaultAppState,
|
|
39654
40655
|
theme,
|
|
40656
|
+
exportWithDarkMode: theme === THEME.DARK,
|
|
39655
40657
|
isLoading: true,
|
|
39656
40658
|
...this.getCanvasOffsets(),
|
|
39657
40659
|
viewModeEnabled,
|
|
@@ -39735,6 +40737,9 @@ var App = class _App extends React46.Component {
|
|
|
39735
40737
|
this.actionManager.registerAction(createUndoAction(this.history));
|
|
39736
40738
|
this.actionManager.registerAction(createRedoAction(this.history));
|
|
39737
40739
|
}
|
|
40740
|
+
setSessionExportThemeOverride(theme) {
|
|
40741
|
+
SESSION_EXPORT_THEME_OVERRIDE = theme;
|
|
40742
|
+
}
|
|
39738
40743
|
onWindowMessage(event) {
|
|
39739
40744
|
if (event.origin !== "https://player.vimeo.com" && event.origin !== "https://www.youtube.com") {
|
|
39740
40745
|
return;
|
|
@@ -40623,7 +41628,8 @@ var App = class _App extends React46.Component {
|
|
|
40623
41628
|
onPointerCancel: this.removePointer,
|
|
40624
41629
|
onTouchMove: this.handleTouchMove,
|
|
40625
41630
|
onPointerDown: this.handleCanvasPointerDown,
|
|
40626
|
-
onDoubleClick: this.handleCanvasDoubleClick
|
|
41631
|
+
onDoubleClick: this.handleCanvasDoubleClick,
|
|
41632
|
+
onClick: this.handleCanvasClick
|
|
40627
41633
|
}
|
|
40628
41634
|
),
|
|
40629
41635
|
this.state.userToFollow && /* @__PURE__ */ jsx162(
|
|
@@ -40986,6 +41992,10 @@ var App = class _App extends React46.Component {
|
|
|
40986
41992
|
this.updateEmbeddables();
|
|
40987
41993
|
const elements = this.scene.getElementsIncludingDeleted();
|
|
40988
41994
|
const elementsMap = this.scene.getElementsMapIncludingDeleted();
|
|
41995
|
+
const shouldExportWithDarkMode = (SESSION_EXPORT_THEME_OVERRIDE ?? this.state.theme) === THEME.DARK;
|
|
41996
|
+
if (this.state.exportWithDarkMode !== shouldExportWithDarkMode) {
|
|
41997
|
+
this.setState({ exportWithDarkMode: shouldExportWithDarkMode });
|
|
41998
|
+
}
|
|
40989
41999
|
if (!this.state.showWelcomeScreen && !elements.length) {
|
|
40990
42000
|
this.setState({ showWelcomeScreen: true });
|
|
40991
42001
|
}
|
|
@@ -41175,7 +42185,7 @@ var App = class _App extends React46.Component {
|
|
|
41175
42185
|
if (!isPlainPaste && isMaybeMermaidDefinition(data.text)) {
|
|
41176
42186
|
const api = await import("@excalidraw/mermaid-to-excalidraw");
|
|
41177
42187
|
try {
|
|
41178
|
-
const { elements: skeletonElements, files } = await api.parseMermaidToExcalidraw(data.text);
|
|
42188
|
+
const { elements: skeletonElements, files = {} } = await api.parseMermaidToExcalidraw(data.text);
|
|
41179
42189
|
const elements = convertToExcalidrawElements(skeletonElements, {
|
|
41180
42190
|
regenerateIds: true
|
|
41181
42191
|
});
|
|
@@ -41354,7 +42364,8 @@ var App = class _App extends React46.Component {
|
|
|
41354
42364
|
}
|
|
41355
42365
|
}
|
|
41356
42366
|
handleTextWysiwyg(element, {
|
|
41357
|
-
isExistingElement = false
|
|
42367
|
+
isExistingElement = false,
|
|
42368
|
+
initialCaretSceneCoords = null
|
|
41358
42369
|
}) {
|
|
41359
42370
|
const elementsMap = this.scene.getElementsMapIncludingDeleted();
|
|
41360
42371
|
const updateElement = (nextOriginalText, isDeleted) => {
|
|
@@ -41439,6 +42450,7 @@ var App = class _App extends React46.Component {
|
|
|
41439
42450
|
element,
|
|
41440
42451
|
excalidrawContainer: this.excalidrawContainerRef.current,
|
|
41441
42452
|
app: this,
|
|
42453
|
+
initialCaretSceneCoords,
|
|
41442
42454
|
// when text is selected, it's hard (at least on iOS) to re-position the
|
|
41443
42455
|
// caret (i.e. deselect). There's not much use for always selecting
|
|
41444
42456
|
// the text on edit anyway (and users can select-all from contextmenu
|
|
@@ -41456,6 +42468,45 @@ var App = class _App extends React46.Component {
|
|
|
41456
42468
|
activeEmbeddable: null
|
|
41457
42469
|
});
|
|
41458
42470
|
}
|
|
42471
|
+
getSelectedTextElement(container) {
|
|
42472
|
+
const selectedElements = this.scene.getSelectedElements(this.state);
|
|
42473
|
+
if (selectedElements.length !== 1) {
|
|
42474
|
+
return null;
|
|
42475
|
+
}
|
|
42476
|
+
const selectedElement = selectedElements[0];
|
|
42477
|
+
if (isTextElement(selectedElement)) {
|
|
42478
|
+
return selectedElement;
|
|
42479
|
+
}
|
|
42480
|
+
if (!container) {
|
|
42481
|
+
return null;
|
|
42482
|
+
}
|
|
42483
|
+
return getBoundTextElement(
|
|
42484
|
+
selectedElement,
|
|
42485
|
+
this.scene.getNonDeletedElementsMap()
|
|
42486
|
+
);
|
|
42487
|
+
}
|
|
42488
|
+
getSelectedTextEditingContainerAtPosition(hitElement, sceneCoords) {
|
|
42489
|
+
const selectedElements = this.scene.getSelectedElements(this.state);
|
|
42490
|
+
if (selectedElements.length !== 1 || !hitElement || hitElement.id !== selectedElements[0].id) {
|
|
42491
|
+
return null;
|
|
42492
|
+
}
|
|
42493
|
+
const selectedElement = selectedElements[0];
|
|
42494
|
+
if (isTextElement(selectedElement)) {
|
|
42495
|
+
return null;
|
|
42496
|
+
}
|
|
42497
|
+
if (!isValidTextContainer(selectedElement)) {
|
|
42498
|
+
return void 0;
|
|
42499
|
+
}
|
|
42500
|
+
const textElement = this.getSelectedTextElement(selectedElement);
|
|
42501
|
+
const hitTextElement = this.getTextElementAtPosition(
|
|
42502
|
+
sceneCoords.x,
|
|
42503
|
+
sceneCoords.y
|
|
42504
|
+
);
|
|
42505
|
+
if (!textElement || hitTextElement?.id !== textElement.id) {
|
|
42506
|
+
return void 0;
|
|
42507
|
+
}
|
|
42508
|
+
return selectedElement;
|
|
42509
|
+
}
|
|
41459
42510
|
getTextElementAtPosition(x, y) {
|
|
41460
42511
|
const element = this.getElementAtPosition(x, y, {
|
|
41461
42512
|
includeBoundTextElement: true
|
|
@@ -43153,6 +44204,16 @@ var App = class _App extends React46.Component {
|
|
|
43153
44204
|
setCursor(this.interactiveCanvas, CURSOR_TYPE.AUTO);
|
|
43154
44205
|
return;
|
|
43155
44206
|
}
|
|
44207
|
+
const selectedTextEditingContainer = this.getSelectedTextEditingContainerAtPosition(hitElement, sceneCoords);
|
|
44208
|
+
if (activeTool.type === this.state.preferredSelectionTool.type && !this.state.editingTextElement && !pointerDownState.drag.hasOccurred && !pointerDownState.hit.wasAddedToSelection && !childEvent.shiftKey && !childEvent[KEYS.CTRL_OR_CMD] && !childEvent.altKey && childEvent.pointerType !== "touch" && hitElement && (isTextElement(hitElement) && this.state.selectedElementIds[hitElement.id] && this.scene.getSelectedElements(this.state).length === 1 || selectedTextEditingContainer)) {
|
|
44209
|
+
this.startTextEditing({
|
|
44210
|
+
sceneX: sceneCoords.x,
|
|
44211
|
+
sceneY: sceneCoords.y,
|
|
44212
|
+
container: selectedTextEditingContainer,
|
|
44213
|
+
initialCaretSceneCoords: this.lastPointerUpIsDoubleClick ? void 0 : sceneCoords
|
|
44214
|
+
});
|
|
44215
|
+
return;
|
|
44216
|
+
}
|
|
43156
44217
|
if (!activeTool.locked && activeTool.type !== "freedraw" && newElement2) {
|
|
43157
44218
|
this.setState((prevState) => ({
|
|
43158
44219
|
selectedElementIds: makeNextSelectedElementIds(
|
|
@@ -43288,10 +44349,10 @@ createTestHook();
|
|
|
43288
44349
|
var App_default = App;
|
|
43289
44350
|
|
|
43290
44351
|
// components/InitializeApp.tsx
|
|
43291
|
-
import { useEffect as useEffect50, useState as
|
|
44352
|
+
import { useEffect as useEffect50, useState as useState44 } from "react";
|
|
43292
44353
|
import { jsx as jsx163 } from "react/jsx-runtime";
|
|
43293
44354
|
var InitializeApp = (props) => {
|
|
43294
|
-
const [loading, setLoading] =
|
|
44355
|
+
const [loading, setLoading] = useState44(true);
|
|
43295
44356
|
useEffect50(() => {
|
|
43296
44357
|
const updateLang = async () => {
|
|
43297
44358
|
await setLanguage(currentLang2);
|