@excalidraw/common 0.18.0-4e471c107 → 0.18.0-51ad895
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/index.js +329 -46
- package/dist/dev/index.js.map +3 -3
- package/dist/prod/index.js +3 -3
- package/dist/types/common/src/constants.d.ts +21 -15
- package/dist/types/common/src/editorInterface.d.ts +34 -0
- package/dist/types/common/src/index.d.ts +2 -0
- package/dist/types/common/src/utils.d.ts +9 -3
- package/dist/types/common/src/visualdebug.d.ts +41 -0
- package/dist/types/element/src/Scene.d.ts +6 -2
- package/dist/types/element/src/align.d.ts +2 -1
- package/dist/types/element/src/binding.d.ts +55 -43
- package/dist/types/element/src/bounds.d.ts +1 -1
- package/dist/types/element/src/collision.d.ts +6 -2
- package/dist/types/element/src/delta.d.ts +16 -4
- package/dist/types/element/src/distribute.d.ts +2 -1
- package/dist/types/element/src/groups.d.ts +1 -0
- package/dist/types/element/src/index.d.ts +1 -3
- package/dist/types/element/src/linearElementEditor.d.ts +17 -19
- package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
- package/dist/types/element/src/renderElement.d.ts +5 -2
- package/dist/types/element/src/resizeTest.d.ts +5 -4
- package/dist/types/element/src/store.d.ts +6 -1
- package/dist/types/element/src/textElement.d.ts +1 -1
- package/dist/types/element/src/transformHandles.d.ts +5 -4
- package/dist/types/element/src/typeChecks.d.ts +2 -3
- package/dist/types/element/src/types.d.ts +7 -11
- package/dist/types/element/src/utils.d.ts +2 -1
- package/dist/types/element/src/zindex.d.ts +7 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +34 -16
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +25 -13
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +153 -275
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +45 -777
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +12 -6
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +45 -29
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +11 -7
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +23 -11
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +12 -6
- package/dist/types/excalidraw/actions/actionExport.d.ts +68 -952
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +10 -394
- package/dist/types/excalidraw/actions/actionFlip.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionFrame.d.ts +50 -28
- package/dist/types/excalidraw/actions/actionGroup.d.ts +24 -12
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +47 -14
- package/dist/types/excalidraw/actions/actionLink.d.ts +9 -3
- package/dist/types/excalidraw/actions/actionMenu.d.ts +10 -374
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +21 -361
- package/dist/types/excalidraw/actions/actionProperties.d.ts +87 -2418
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +12 -6
- package/dist/types/excalidraw/actions/actionStyles.d.ts +13 -7
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +11 -5
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +11 -5
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +10 -6
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +11 -5
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +11 -5
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +12 -6
- package/dist/types/excalidraw/actions/actionZindex.d.ts +2 -2
- package/dist/types/excalidraw/actions/index.d.ts +2 -2
- package/dist/types/excalidraw/actions/manager.d.ts +1 -1
- package/dist/types/excalidraw/actions/register.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +4 -4
- package/dist/types/excalidraw/appState.d.ts +9 -4
- package/dist/types/excalidraw/clipboard.d.ts +64 -1
- package/dist/types/excalidraw/components/Actions.d.ts +20 -7
- package/dist/types/excalidraw/components/App.d.ts +35 -25
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -1
- package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
- package/dist/types/excalidraw/components/CommandPalette/types.d.ts +1 -2
- package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
- package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +1 -1
- package/dist/types/excalidraw/components/FilledButton.d.ts +1 -1
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -1
- package/dist/types/excalidraw/components/HintViewer.d.ts +4 -3
- package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -1
- package/dist/types/excalidraw/components/LayerUI.d.ts +2 -1
- package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
- package/dist/types/excalidraw/components/MobileMenu.d.ts +3 -5
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +11 -0
- package/dist/types/excalidraw/components/Popover.d.ts +2 -1
- package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
- package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -2
- package/dist/types/excalidraw/components/TextField.d.ts +1 -0
- package/dist/types/excalidraw/components/ToolPopover.d.ts +25 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +6 -3
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +4 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +2 -1
- package/dist/types/excalidraw/components/icons.d.ts +10 -0
- package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +13 -1
- package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +0 -3
- package/dist/types/excalidraw/components/shapes.d.ts +129 -1
- package/dist/types/excalidraw/data/blob.d.ts +3 -7
- package/dist/types/excalidraw/data/reconcile.d.ts +1 -0
- package/dist/types/excalidraw/data/restore.d.ts +7 -2
- package/dist/types/excalidraw/data/types.d.ts +4 -1
- package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +3 -1
- package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
- package/dist/types/excalidraw/index.d.ts +4 -4
- package/dist/types/excalidraw/renderer/animation.d.ts +12 -0
- package/dist/types/excalidraw/renderer/helpers.d.ts +2 -6
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +5 -13
- package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
- package/dist/types/excalidraw/scene/types.d.ts +15 -3
- package/dist/types/excalidraw/shortcut.d.ts +1 -0
- package/dist/types/excalidraw/types.d.ts +37 -24
- package/dist/types/math/src/segment.d.ts +1 -0
- package/package.json +1 -1
package/dist/dev/index.js
CHANGED
|
@@ -281,49 +281,48 @@ var BinaryHeap = class {
|
|
|
281
281
|
content = [];
|
|
282
282
|
sinkDown(idx) {
|
|
283
283
|
const node = this.content[idx];
|
|
284
|
+
const nodeScore = this.scoreFunction(node);
|
|
284
285
|
while (idx > 0) {
|
|
285
286
|
const parentN = (idx + 1 >> 1) - 1;
|
|
286
287
|
const parent = this.content[parentN];
|
|
287
|
-
if (
|
|
288
|
-
this.content[parentN] = node;
|
|
288
|
+
if (nodeScore < this.scoreFunction(parent)) {
|
|
289
289
|
this.content[idx] = parent;
|
|
290
290
|
idx = parentN;
|
|
291
291
|
} else {
|
|
292
292
|
break;
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
+
this.content[idx] = node;
|
|
295
296
|
}
|
|
296
297
|
bubbleUp(idx) {
|
|
297
298
|
const length = this.content.length;
|
|
298
299
|
const node = this.content[idx];
|
|
299
300
|
const score = this.scoreFunction(node);
|
|
300
301
|
while (true) {
|
|
301
|
-
const
|
|
302
|
-
const
|
|
303
|
-
let
|
|
304
|
-
let
|
|
302
|
+
const child1N = (idx + 1 << 1) - 1;
|
|
303
|
+
const child2N = child1N + 1;
|
|
304
|
+
let smallestIdx = idx;
|
|
305
|
+
let smallestScore = score;
|
|
305
306
|
if (child1N < length) {
|
|
306
|
-
const
|
|
307
|
-
child1Score
|
|
308
|
-
|
|
309
|
-
|
|
307
|
+
const child1Score = this.scoreFunction(this.content[child1N]);
|
|
308
|
+
if (child1Score < smallestScore) {
|
|
309
|
+
smallestIdx = child1N;
|
|
310
|
+
smallestScore = child1Score;
|
|
310
311
|
}
|
|
311
312
|
}
|
|
312
313
|
if (child2N < length) {
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
swap = child2N;
|
|
314
|
+
const child2Score = this.scoreFunction(this.content[child2N]);
|
|
315
|
+
if (child2Score < smallestScore) {
|
|
316
|
+
smallestIdx = child2N;
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
|
-
if (
|
|
320
|
-
this.content[idx] = this.content[swap];
|
|
321
|
-
this.content[swap] = node;
|
|
322
|
-
idx = swap;
|
|
323
|
-
} else {
|
|
319
|
+
if (smallestIdx === idx) {
|
|
324
320
|
break;
|
|
325
321
|
}
|
|
322
|
+
this.content[idx] = this.content[smallestIdx];
|
|
323
|
+
idx = smallestIdx;
|
|
326
324
|
}
|
|
325
|
+
this.content[idx] = node;
|
|
327
326
|
}
|
|
328
327
|
push(node) {
|
|
329
328
|
this.content.push(node);
|
|
@@ -641,19 +640,11 @@ var rgbToHex = (r, g, b) => `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(
|
|
|
641
640
|
|
|
642
641
|
// src/constants.ts
|
|
643
642
|
init_define_import_meta_env();
|
|
644
|
-
var isDarwin = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
645
|
-
var isWindows = /^Win/.test(navigator.platform);
|
|
646
|
-
var isAndroid = /\b(android)\b/i.test(navigator.userAgent);
|
|
647
|
-
var isFirefox = typeof window !== "undefined" && "netscape" in window && navigator.userAgent.indexOf("rv:") > 1 && navigator.userAgent.indexOf("Gecko") > 1;
|
|
648
|
-
var isChrome = navigator.userAgent.indexOf("Chrome") !== -1;
|
|
649
|
-
var isSafari = !isChrome && navigator.userAgent.indexOf("Safari") !== -1;
|
|
650
|
-
var isIOS = /iPad|iPhone/.test(navigator.platform) || // iPadOS 13+
|
|
651
|
-
navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
|
652
|
-
var isBrave = () => navigator.brave?.isBrave?.name === "isBrave";
|
|
653
643
|
var supportsResizeObserver = typeof window !== "undefined" && "ResizeObserver" in window;
|
|
654
644
|
var APP_NAME = "Excalidraw";
|
|
655
645
|
var TEXT_AUTOWRAP_THRESHOLD = 36;
|
|
656
646
|
var DRAGGING_THRESHOLD = 10;
|
|
647
|
+
var MINIMUM_ARROW_SIZE = 20;
|
|
657
648
|
var LINE_CONFIRM_THRESHOLD = 8;
|
|
658
649
|
var ELEMENT_SHIFT_TRANSLATE_AMOUNT = 5;
|
|
659
650
|
var ELEMENT_TRANSLATE_AMOUNT = 1;
|
|
@@ -730,10 +721,13 @@ var ENV = {
|
|
|
730
721
|
PRODUCTION: "production"
|
|
731
722
|
};
|
|
732
723
|
var CLASSES = {
|
|
724
|
+
SIDEBAR: "sidebar",
|
|
733
725
|
SHAPE_ACTIONS_MENU: "App-menu__left",
|
|
734
726
|
ZOOM_ACTIONS: "zoom-actions",
|
|
735
727
|
SEARCH_MENU_INPUT_WRAPPER: "layer-ui__search-inputWrapper",
|
|
736
|
-
CONVERT_ELEMENT_TYPE_POPUP: "ConvertElementTypePopup"
|
|
728
|
+
CONVERT_ELEMENT_TYPE_POPUP: "ConvertElementTypePopup",
|
|
729
|
+
SHAPE_ACTIONS_THEME_SCOPE: "shape-actions-theme-scope",
|
|
730
|
+
FRAME_NAME: "frame-name"
|
|
737
731
|
};
|
|
738
732
|
var CJK_HAND_DRAWN_FALLBACK_FONT = "Xiaolai";
|
|
739
733
|
var WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
|
|
@@ -828,13 +822,19 @@ var IMAGE_MIME_TYPES = {
|
|
|
828
822
|
avif: "image/avif",
|
|
829
823
|
jfif: "image/jfif"
|
|
830
824
|
};
|
|
831
|
-
var
|
|
825
|
+
var STRING_MIME_TYPES = {
|
|
832
826
|
text: "text/plain",
|
|
833
827
|
html: "text/html",
|
|
834
828
|
json: "application/json",
|
|
835
829
|
// excalidraw data
|
|
836
830
|
excalidraw: "application/vnd.excalidraw+json",
|
|
831
|
+
// LEGACY: fully-qualified library JSON data
|
|
837
832
|
excalidrawlib: "application/vnd.excalidrawlib+json",
|
|
833
|
+
// list of excalidraw library item ids
|
|
834
|
+
excalidrawlibIds: "application/vnd.excalidrawlib.ids+json"
|
|
835
|
+
};
|
|
836
|
+
var MIME_TYPES = {
|
|
837
|
+
...STRING_MIME_TYPES,
|
|
838
838
|
// image-encoded excalidraw data
|
|
839
839
|
"excalidraw.svg": "image/svg+xml",
|
|
840
840
|
"excalidraw.png": "image/png",
|
|
@@ -893,10 +893,6 @@ var DEFAULT_UI_OPTIONS = {
|
|
|
893
893
|
image: true
|
|
894
894
|
}
|
|
895
895
|
};
|
|
896
|
-
var MQ_MAX_WIDTH_PORTRAIT = 730;
|
|
897
|
-
var MQ_MAX_WIDTH_LANDSCAPE = 1e3;
|
|
898
|
-
var MQ_MAX_HEIGHT_LANDSCAPE = 500;
|
|
899
|
-
var MQ_RIGHT_SIDEBAR_MIN_WIDTH = 1229;
|
|
900
896
|
var MAX_DECIMALS_FOR_SVG_EXPORT = 2;
|
|
901
897
|
var EXPORT_SCALES = [1, 2, 3];
|
|
902
898
|
var DEFAULT_EXPORT_PADDING = 10;
|
|
@@ -1016,6 +1012,11 @@ var UserIdleState = /* @__PURE__ */ ((UserIdleState2) => {
|
|
|
1016
1012
|
return UserIdleState2;
|
|
1017
1013
|
})(UserIdleState || {});
|
|
1018
1014
|
var LINE_POLYGON_POINT_MERGE_DISTANCE = 20;
|
|
1015
|
+
var DOUBLE_TAP_POSITION_THRESHOLD = 35;
|
|
1016
|
+
var BIND_MODE_TIMEOUT = 700;
|
|
1017
|
+
var MOBILE_ACTION_BUTTON_BG = {
|
|
1018
|
+
background: "var(--mobile-action-button-bg)"
|
|
1019
|
+
};
|
|
1019
1020
|
|
|
1020
1021
|
// src/font-metadata.ts
|
|
1021
1022
|
init_define_import_meta_env();
|
|
@@ -1171,6 +1172,133 @@ var Queue = class {
|
|
|
1171
1172
|
|
|
1172
1173
|
// src/keys.ts
|
|
1173
1174
|
init_define_import_meta_env();
|
|
1175
|
+
|
|
1176
|
+
// src/editorInterface.ts
|
|
1177
|
+
init_define_import_meta_env();
|
|
1178
|
+
var DESKTOP_UI_MODE_STORAGE_KEY = "excalidraw.desktopUIMode";
|
|
1179
|
+
var MQ_MAX_MOBILE = 599;
|
|
1180
|
+
var MQ_MAX_WIDTH_LANDSCAPE = 1e3;
|
|
1181
|
+
var MQ_MAX_HEIGHT_LANDSCAPE = 500;
|
|
1182
|
+
var MQ_MIN_TABLET = MQ_MAX_MOBILE + 1;
|
|
1183
|
+
var MQ_MAX_TABLET = 1400;
|
|
1184
|
+
var MQ_MIN_WIDTH_DESKTOP = 1440;
|
|
1185
|
+
var MQ_RIGHT_SIDEBAR_MIN_WIDTH = 1229;
|
|
1186
|
+
var isDarwin = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
1187
|
+
var isWindows = /^Win/.test(navigator.platform);
|
|
1188
|
+
var isAndroid = /\b(android)\b/i.test(navigator.userAgent);
|
|
1189
|
+
var isFirefox = typeof window !== "undefined" && "netscape" in window && navigator.userAgent.indexOf("rv:") > 1 && navigator.userAgent.indexOf("Gecko") > 1;
|
|
1190
|
+
var isChrome = navigator.userAgent.indexOf("Chrome") !== -1;
|
|
1191
|
+
var isSafari = !isChrome && navigator.userAgent.indexOf("Safari") !== -1;
|
|
1192
|
+
var isIOS = /iPad|iPhone/i.test(navigator.platform) || // iPadOS 13+
|
|
1193
|
+
navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
|
1194
|
+
var isBrave = () => navigator.brave?.isBrave?.name === "isBrave";
|
|
1195
|
+
var isMobileBreakpoint = (width, height) => {
|
|
1196
|
+
return width <= MQ_MAX_MOBILE || height < MQ_MAX_HEIGHT_LANDSCAPE && width < MQ_MAX_WIDTH_LANDSCAPE;
|
|
1197
|
+
};
|
|
1198
|
+
var isTabletBreakpoint = (editorWidth, editorHeight) => {
|
|
1199
|
+
const minSide = Math.min(editorWidth, editorHeight);
|
|
1200
|
+
const maxSide = Math.max(editorWidth, editorHeight);
|
|
1201
|
+
return minSide >= MQ_MIN_TABLET && maxSide <= MQ_MAX_TABLET;
|
|
1202
|
+
};
|
|
1203
|
+
var isMobileOrTablet = () => {
|
|
1204
|
+
const ua = navigator.userAgent || "";
|
|
1205
|
+
const platform = navigator.platform || "";
|
|
1206
|
+
const uaData = navigator.userAgentData;
|
|
1207
|
+
if (uaData) {
|
|
1208
|
+
const plat = (uaData.platform || "").toLowerCase();
|
|
1209
|
+
const isDesktopOS = plat === "windows" || plat === "macos" || plat === "linux" || plat === "chrome os";
|
|
1210
|
+
if (uaData.mobile === true) {
|
|
1211
|
+
return true;
|
|
1212
|
+
}
|
|
1213
|
+
if (uaData.mobile === false && plat === "android") {
|
|
1214
|
+
const looksTouchTablet = matchMedia?.("(hover: none)").matches && matchMedia?.("(pointer: coarse)").matches;
|
|
1215
|
+
return looksTouchTablet;
|
|
1216
|
+
}
|
|
1217
|
+
if (isDesktopOS) {
|
|
1218
|
+
return false;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
if (isIOS) {
|
|
1222
|
+
return true;
|
|
1223
|
+
}
|
|
1224
|
+
if (isAndroid) {
|
|
1225
|
+
const isAndroidPhone = /Mobile/i.test(ua);
|
|
1226
|
+
const isAndroidTablet = !isAndroidPhone;
|
|
1227
|
+
if (isAndroidPhone || isAndroidTablet) {
|
|
1228
|
+
const looksTouchTablet = matchMedia?.("(hover: none)").matches && matchMedia?.("(pointer: coarse)").matches;
|
|
1229
|
+
return looksTouchTablet;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
const looksDesktopPlatform = /Win|Linux|CrOS|Mac/.test(platform) || /Windows NT|X11|CrOS|Macintosh/.test(ua);
|
|
1233
|
+
if (looksDesktopPlatform) {
|
|
1234
|
+
return false;
|
|
1235
|
+
}
|
|
1236
|
+
return false;
|
|
1237
|
+
};
|
|
1238
|
+
var getFormFactor = (editorWidth, editorHeight) => {
|
|
1239
|
+
if (isMobileBreakpoint(editorWidth, editorHeight)) {
|
|
1240
|
+
return "phone";
|
|
1241
|
+
}
|
|
1242
|
+
if (isTabletBreakpoint(editorWidth, editorHeight)) {
|
|
1243
|
+
return "tablet";
|
|
1244
|
+
}
|
|
1245
|
+
return "desktop";
|
|
1246
|
+
};
|
|
1247
|
+
var deriveStylesPanelMode = (editorInterface) => {
|
|
1248
|
+
if (editorInterface.formFactor === "phone") {
|
|
1249
|
+
return "mobile";
|
|
1250
|
+
}
|
|
1251
|
+
if (editorInterface.formFactor === "tablet") {
|
|
1252
|
+
return "compact";
|
|
1253
|
+
}
|
|
1254
|
+
return editorInterface.desktopUIMode;
|
|
1255
|
+
};
|
|
1256
|
+
var createUserAgentDescriptor = (userAgentString) => {
|
|
1257
|
+
const normalizedUA = userAgentString ?? "";
|
|
1258
|
+
let platform = "unknown";
|
|
1259
|
+
if (isIOS) {
|
|
1260
|
+
platform = "ios";
|
|
1261
|
+
} else if (isAndroid) {
|
|
1262
|
+
platform = "android";
|
|
1263
|
+
} else if (normalizedUA) {
|
|
1264
|
+
platform = "other";
|
|
1265
|
+
}
|
|
1266
|
+
return {
|
|
1267
|
+
isMobileDevice: isMobileOrTablet(),
|
|
1268
|
+
platform
|
|
1269
|
+
};
|
|
1270
|
+
};
|
|
1271
|
+
var loadDesktopUIModePreference = () => {
|
|
1272
|
+
if (typeof window === "undefined") {
|
|
1273
|
+
return null;
|
|
1274
|
+
}
|
|
1275
|
+
try {
|
|
1276
|
+
const stored = window.localStorage.getItem(DESKTOP_UI_MODE_STORAGE_KEY);
|
|
1277
|
+
if (stored === "compact" || stored === "full") {
|
|
1278
|
+
return stored;
|
|
1279
|
+
}
|
|
1280
|
+
} catch (error) {
|
|
1281
|
+
}
|
|
1282
|
+
return null;
|
|
1283
|
+
};
|
|
1284
|
+
var persistDesktopUIMode = (mode) => {
|
|
1285
|
+
if (typeof window === "undefined") {
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
try {
|
|
1289
|
+
window.localStorage.setItem(DESKTOP_UI_MODE_STORAGE_KEY, mode);
|
|
1290
|
+
} catch (error) {
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1293
|
+
var setDesktopUIMode = (mode) => {
|
|
1294
|
+
if (mode !== "compact" && mode !== "full") {
|
|
1295
|
+
return;
|
|
1296
|
+
}
|
|
1297
|
+
persistDesktopUIMode(mode);
|
|
1298
|
+
return mode;
|
|
1299
|
+
};
|
|
1300
|
+
|
|
1301
|
+
// src/keys.ts
|
|
1174
1302
|
var CODES = {
|
|
1175
1303
|
EQUAL: "Equal",
|
|
1176
1304
|
MINUS: "Minus",
|
|
@@ -1416,7 +1544,7 @@ var isInteractive = (target) => {
|
|
|
1416
1544
|
return isInputLike(target) || target instanceof Element && !!target.closest("label, button");
|
|
1417
1545
|
};
|
|
1418
1546
|
var isWritableElement = (target) => target instanceof HTMLElement && target.dataset.type === "wysiwyg" || target instanceof HTMLBRElement || // newline in wysiwyg
|
|
1419
|
-
target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && (target.type === "text" || target.type === "number" || target.type === "password");
|
|
1547
|
+
target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && (target.type === "text" || target.type === "number" || target.type === "password" || target.type === "search");
|
|
1420
1548
|
var getFontFamilyString = ({
|
|
1421
1549
|
fontFamily
|
|
1422
1550
|
}) => {
|
|
@@ -1433,6 +1561,9 @@ var getFontString = ({
|
|
|
1433
1561
|
}) => {
|
|
1434
1562
|
return `${fontSize}px ${getFontFamilyString({ fontFamily })}`;
|
|
1435
1563
|
};
|
|
1564
|
+
var nextAnimationFrame = async (cb) => {
|
|
1565
|
+
requestAnimationFrame(() => requestAnimationFrame(cb));
|
|
1566
|
+
};
|
|
1436
1567
|
var debounce = (fn, timeout) => {
|
|
1437
1568
|
let handle = 0;
|
|
1438
1569
|
let lastArgs = null;
|
|
@@ -1597,6 +1728,9 @@ var removeSelection = () => {
|
|
|
1597
1728
|
}
|
|
1598
1729
|
};
|
|
1599
1730
|
var distance = (x, y) => Math.abs(x - y);
|
|
1731
|
+
var isSelectionLikeTool = (type) => {
|
|
1732
|
+
return type === "selection" || type === "lasso";
|
|
1733
|
+
};
|
|
1600
1734
|
var updateActiveTool = (appState, data) => {
|
|
1601
1735
|
if (data.type === "custom") {
|
|
1602
1736
|
return {
|
|
@@ -1618,13 +1752,6 @@ var updateActiveTool = (appState, data) => {
|
|
|
1618
1752
|
var isFullScreen = () => document.fullscreenElement?.nodeName === "HTML";
|
|
1619
1753
|
var allowFullScreen = () => document.documentElement.requestFullscreen();
|
|
1620
1754
|
var exitFullScreen = () => document.exitFullscreen();
|
|
1621
|
-
var getShortcutKey = (shortcut) => {
|
|
1622
|
-
shortcut = shortcut.replace(/\bAlt\b/i, "Alt").replace(/\bShift\b/i, "Shift").replace(/\b(Enter|Return)\b/i, "Enter");
|
|
1623
|
-
if (isDarwin) {
|
|
1624
|
-
return shortcut.replace(/\bCtrlOrCmd\b/gi, "Cmd").replace(/\bAlt\b/i, "Option");
|
|
1625
|
-
}
|
|
1626
|
-
return shortcut.replace(/\bCtrlOrCmd\b/gi, "Ctrl");
|
|
1627
|
-
};
|
|
1628
1755
|
var viewportCoordsToSceneCoords = ({ clientX, clientY }, {
|
|
1629
1756
|
zoom,
|
|
1630
1757
|
offsetLeft,
|
|
@@ -1703,7 +1830,6 @@ var isTransparent = (color) => {
|
|
|
1703
1830
|
const isRRGGBBTransparent = color.length === 9 && color.substr(7, 2) === "00";
|
|
1704
1831
|
return isRGBTransparent || isRRGGBBTransparent || color === COLOR_PALETTE.transparent;
|
|
1705
1832
|
};
|
|
1706
|
-
var isBindingFallthroughEnabled = (el) => el.fillStyle !== "solid" || isTransparent(el.backgroundColor);
|
|
1707
1833
|
var resolvablePromise = () => {
|
|
1708
1834
|
let resolve;
|
|
1709
1835
|
let reject;
|
|
@@ -2066,6 +2192,38 @@ var reduceToCommonValue = (collection, getValue) => {
|
|
|
2066
2192
|
}
|
|
2067
2193
|
return commonValue;
|
|
2068
2194
|
};
|
|
2195
|
+
var FEATURE_FLAGS_STORAGE_KEY = "excalidraw-feature-flags";
|
|
2196
|
+
var DEFAULT_FEATURE_FLAGS = {
|
|
2197
|
+
COMPLEX_BINDINGS: false
|
|
2198
|
+
};
|
|
2199
|
+
var featureFlags = null;
|
|
2200
|
+
var getFeatureFlag = (flag) => {
|
|
2201
|
+
if (!featureFlags) {
|
|
2202
|
+
try {
|
|
2203
|
+
const serializedFlags = localStorage.getItem(FEATURE_FLAGS_STORAGE_KEY);
|
|
2204
|
+
if (serializedFlags) {
|
|
2205
|
+
const flags = JSON.parse(serializedFlags);
|
|
2206
|
+
featureFlags = flags ?? DEFAULT_FEATURE_FLAGS;
|
|
2207
|
+
}
|
|
2208
|
+
} catch {
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
return (featureFlags || DEFAULT_FEATURE_FLAGS)[flag];
|
|
2212
|
+
};
|
|
2213
|
+
var setFeatureFlag = (flag, value) => {
|
|
2214
|
+
try {
|
|
2215
|
+
featureFlags = {
|
|
2216
|
+
...featureFlags || DEFAULT_FEATURE_FLAGS,
|
|
2217
|
+
[flag]: value
|
|
2218
|
+
};
|
|
2219
|
+
localStorage.setItem(
|
|
2220
|
+
FEATURE_FLAGS_STORAGE_KEY,
|
|
2221
|
+
JSON.stringify(featureFlags)
|
|
2222
|
+
);
|
|
2223
|
+
} catch (e) {
|
|
2224
|
+
console.error("unable to set feature flag", e);
|
|
2225
|
+
}
|
|
2226
|
+
};
|
|
2069
2227
|
|
|
2070
2228
|
// src/random.ts
|
|
2071
2229
|
var random = new Random(Date.now());
|
|
@@ -2139,6 +2297,107 @@ var Emitter = class {
|
|
|
2139
2297
|
this.subscribers = [];
|
|
2140
2298
|
}
|
|
2141
2299
|
};
|
|
2300
|
+
|
|
2301
|
+
// src/visualdebug.ts
|
|
2302
|
+
init_define_import_meta_env();
|
|
2303
|
+
import {
|
|
2304
|
+
isLineSegment,
|
|
2305
|
+
lineSegment,
|
|
2306
|
+
pointFrom
|
|
2307
|
+
} from "@excalidraw/math";
|
|
2308
|
+
import { isBounds } from "@excalidraw/element";
|
|
2309
|
+
var debugDrawCubicBezier = (c, opts) => {
|
|
2310
|
+
addToCurrentFrame({
|
|
2311
|
+
color: opts?.color ?? "purple",
|
|
2312
|
+
permanent: !!opts?.permanent,
|
|
2313
|
+
data: c
|
|
2314
|
+
});
|
|
2315
|
+
};
|
|
2316
|
+
var debugDrawLine = (segment, opts) => {
|
|
2317
|
+
const segments = isLineSegment(segment) ? [segment] : segment;
|
|
2318
|
+
segments.forEach(
|
|
2319
|
+
(data) => addToCurrentFrame({
|
|
2320
|
+
color: opts?.color ?? "red",
|
|
2321
|
+
data,
|
|
2322
|
+
permanent: !!opts?.permanent
|
|
2323
|
+
})
|
|
2324
|
+
);
|
|
2325
|
+
};
|
|
2326
|
+
var debugDrawPoint = (p, opts) => {
|
|
2327
|
+
const xOffset = opts?.fuzzy ? Math.random() * 3 : 0;
|
|
2328
|
+
const yOffset = opts?.fuzzy ? Math.random() * 3 : 0;
|
|
2329
|
+
debugDrawLine(
|
|
2330
|
+
lineSegment(
|
|
2331
|
+
pointFrom(p[0] + xOffset - 10, p[1] + yOffset - 10),
|
|
2332
|
+
pointFrom(p[0] + xOffset + 10, p[1] + yOffset + 10)
|
|
2333
|
+
),
|
|
2334
|
+
{
|
|
2335
|
+
color: opts?.color ?? "cyan",
|
|
2336
|
+
permanent: opts?.permanent
|
|
2337
|
+
}
|
|
2338
|
+
);
|
|
2339
|
+
debugDrawLine(
|
|
2340
|
+
lineSegment(
|
|
2341
|
+
pointFrom(p[0] + xOffset - 10, p[1] + yOffset + 10),
|
|
2342
|
+
pointFrom(p[0] + xOffset + 10, p[1] + yOffset - 10)
|
|
2343
|
+
),
|
|
2344
|
+
{
|
|
2345
|
+
color: opts?.color ?? "cyan",
|
|
2346
|
+
permanent: opts?.permanent
|
|
2347
|
+
}
|
|
2348
|
+
);
|
|
2349
|
+
};
|
|
2350
|
+
var debugDrawBounds = (box, opts) => {
|
|
2351
|
+
(isBounds(box) ? [box] : box).forEach(
|
|
2352
|
+
(bbox) => debugDrawLine(
|
|
2353
|
+
[
|
|
2354
|
+
lineSegment(
|
|
2355
|
+
pointFrom(bbox[0], bbox[1]),
|
|
2356
|
+
pointFrom(bbox[2], bbox[1])
|
|
2357
|
+
),
|
|
2358
|
+
lineSegment(
|
|
2359
|
+
pointFrom(bbox[2], bbox[1]),
|
|
2360
|
+
pointFrom(bbox[2], bbox[3])
|
|
2361
|
+
),
|
|
2362
|
+
lineSegment(
|
|
2363
|
+
pointFrom(bbox[2], bbox[3]),
|
|
2364
|
+
pointFrom(bbox[0], bbox[3])
|
|
2365
|
+
),
|
|
2366
|
+
lineSegment(
|
|
2367
|
+
pointFrom(bbox[0], bbox[3]),
|
|
2368
|
+
pointFrom(bbox[0], bbox[1])
|
|
2369
|
+
)
|
|
2370
|
+
],
|
|
2371
|
+
{
|
|
2372
|
+
color: opts?.color ?? "green",
|
|
2373
|
+
permanent: !!opts?.permanent
|
|
2374
|
+
}
|
|
2375
|
+
)
|
|
2376
|
+
);
|
|
2377
|
+
};
|
|
2378
|
+
var debugDrawPoints = ({
|
|
2379
|
+
x,
|
|
2380
|
+
y,
|
|
2381
|
+
points
|
|
2382
|
+
}, options) => {
|
|
2383
|
+
points.forEach(
|
|
2384
|
+
(p) => debugDrawPoint(pointFrom(x + p[0], y + p[1]), options)
|
|
2385
|
+
);
|
|
2386
|
+
};
|
|
2387
|
+
var debugCloseFrame = () => {
|
|
2388
|
+
window.visualDebug?.data.push([]);
|
|
2389
|
+
};
|
|
2390
|
+
var debugClear = () => {
|
|
2391
|
+
if (window.visualDebug?.data) {
|
|
2392
|
+
window.visualDebug.data = [];
|
|
2393
|
+
}
|
|
2394
|
+
};
|
|
2395
|
+
var addToCurrentFrame = (element) => {
|
|
2396
|
+
if (window.visualDebug?.data && window.visualDebug.data.length === 0) {
|
|
2397
|
+
window.visualDebug.data[0] = [];
|
|
2398
|
+
}
|
|
2399
|
+
window.visualDebug?.data && window.visualDebug.data[window.visualDebug.data.length - 1].push(element);
|
|
2400
|
+
};
|
|
2142
2401
|
export {
|
|
2143
2402
|
ACTIVE_THRESHOLD,
|
|
2144
2403
|
ALLOWED_PASTE_MIME_TYPES,
|
|
@@ -2146,6 +2405,7 @@ export {
|
|
|
2146
2405
|
ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO,
|
|
2147
2406
|
ARROW_LABEL_WIDTH_FRACTION,
|
|
2148
2407
|
ARROW_TYPE,
|
|
2408
|
+
BIND_MODE_TIMEOUT,
|
|
2149
2409
|
BOUND_TEXT_PADDING,
|
|
2150
2410
|
BinaryHeap,
|
|
2151
2411
|
CANVAS_ONLY_ACTIONS,
|
|
@@ -2188,6 +2448,7 @@ export {
|
|
|
2188
2448
|
DEFAULT_UI_OPTIONS,
|
|
2189
2449
|
DEFAULT_VERSION,
|
|
2190
2450
|
DEFAULT_VERTICAL_ALIGN,
|
|
2451
|
+
DOUBLE_TAP_POSITION_THRESHOLD,
|
|
2191
2452
|
DRAGGING_THRESHOLD,
|
|
2192
2453
|
EDITOR_LS_KEYS,
|
|
2193
2454
|
ELEMENTS_PALETTE_SHADE_INDEXES,
|
|
@@ -2225,13 +2486,18 @@ export {
|
|
|
2225
2486
|
MAX_DECIMALS_FOR_SVG_EXPORT,
|
|
2226
2487
|
MAX_ZOOM,
|
|
2227
2488
|
MIME_TYPES,
|
|
2489
|
+
MINIMUM_ARROW_SIZE,
|
|
2228
2490
|
MIN_FONT_SIZE,
|
|
2229
2491
|
MIN_WIDTH_OR_HEIGHT,
|
|
2230
2492
|
MIN_ZOOM,
|
|
2493
|
+
MOBILE_ACTION_BUTTON_BG,
|
|
2231
2494
|
MONOSPACE_GENERIC_FONT,
|
|
2232
2495
|
MQ_MAX_HEIGHT_LANDSCAPE,
|
|
2496
|
+
MQ_MAX_MOBILE,
|
|
2497
|
+
MQ_MAX_TABLET,
|
|
2233
2498
|
MQ_MAX_WIDTH_LANDSCAPE,
|
|
2234
|
-
|
|
2499
|
+
MQ_MIN_TABLET,
|
|
2500
|
+
MQ_MIN_WIDTH_DESKTOP,
|
|
2235
2501
|
MQ_RIGHT_SIDEBAR_MIN_WIDTH,
|
|
2236
2502
|
ORIG_ID,
|
|
2237
2503
|
POINTER_BUTTON,
|
|
@@ -2245,6 +2511,7 @@ export {
|
|
|
2245
2511
|
SHIFT_LOCKING_ANGLE,
|
|
2246
2512
|
SIDE_RESIZING_THRESHOLD,
|
|
2247
2513
|
STATS_PANELS,
|
|
2514
|
+
STRING_MIME_TYPES,
|
|
2248
2515
|
STROKE_WIDTH,
|
|
2249
2516
|
SVG_DOCUMENT_PREAMBLE,
|
|
2250
2517
|
SVG_NS,
|
|
@@ -2279,7 +2546,16 @@ export {
|
|
|
2279
2546
|
chunk,
|
|
2280
2547
|
cloneJSON,
|
|
2281
2548
|
composeEventHandlers,
|
|
2549
|
+
createUserAgentDescriptor,
|
|
2282
2550
|
debounce,
|
|
2551
|
+
debugClear,
|
|
2552
|
+
debugCloseFrame,
|
|
2553
|
+
debugDrawBounds,
|
|
2554
|
+
debugDrawCubicBezier,
|
|
2555
|
+
debugDrawLine,
|
|
2556
|
+
debugDrawPoint,
|
|
2557
|
+
debugDrawPoints,
|
|
2558
|
+
deriveStylesPanelMode,
|
|
2283
2559
|
distance,
|
|
2284
2560
|
easeOut,
|
|
2285
2561
|
easeToValuesRAF,
|
|
@@ -2291,16 +2567,17 @@ export {
|
|
|
2291
2567
|
getAllColorsSpecificShade,
|
|
2292
2568
|
getDateTime,
|
|
2293
2569
|
getExportSource,
|
|
2570
|
+
getFeatureFlag,
|
|
2294
2571
|
getFontFamilyFallbacks,
|
|
2295
2572
|
getFontFamilyString,
|
|
2296
2573
|
getFontString,
|
|
2574
|
+
getFormFactor,
|
|
2297
2575
|
getFrame,
|
|
2298
2576
|
getGenericFontFamilyFallback,
|
|
2299
2577
|
getGlobalCSSVariable,
|
|
2300
2578
|
getGridPoint,
|
|
2301
2579
|
getLineHeight,
|
|
2302
2580
|
getNearestScrollableContainer,
|
|
2303
|
-
getShortcutKey,
|
|
2304
2581
|
getSizeFromPoints,
|
|
2305
2582
|
getSpecificColorShades,
|
|
2306
2583
|
getSvgPathFromStroke,
|
|
@@ -2311,7 +2588,6 @@ export {
|
|
|
2311
2588
|
isAndroid,
|
|
2312
2589
|
isAnyTrue,
|
|
2313
2590
|
isArrowKey,
|
|
2314
|
-
isBindingFallthroughEnabled,
|
|
2315
2591
|
isBrave,
|
|
2316
2592
|
isChrome,
|
|
2317
2593
|
isDarwin,
|
|
@@ -2324,6 +2600,7 @@ export {
|
|
|
2324
2600
|
isLatinChar,
|
|
2325
2601
|
isLocalLink,
|
|
2326
2602
|
isMemberOf,
|
|
2603
|
+
isMobileBreakpoint,
|
|
2327
2604
|
isPrimitive,
|
|
2328
2605
|
isProdEnv,
|
|
2329
2606
|
isPromiseLike,
|
|
@@ -2331,18 +2608,22 @@ export {
|
|
|
2331
2608
|
isReadonlyArray,
|
|
2332
2609
|
isRunningInIframe,
|
|
2333
2610
|
isSafari,
|
|
2611
|
+
isSelectionLikeTool,
|
|
2334
2612
|
isServerEnv,
|
|
2335
2613
|
isShallowEqual,
|
|
2614
|
+
isTabletBreakpoint,
|
|
2336
2615
|
isTestEnv,
|
|
2337
2616
|
isToolIcon,
|
|
2338
2617
|
isTransparent,
|
|
2339
2618
|
isWindows,
|
|
2340
2619
|
isWritableElement,
|
|
2620
|
+
loadDesktopUIModePreference,
|
|
2341
2621
|
mapFind,
|
|
2342
2622
|
matchKey,
|
|
2343
2623
|
memoize,
|
|
2344
2624
|
muteFSAbortError,
|
|
2345
2625
|
nFormatter,
|
|
2626
|
+
nextAnimationFrame,
|
|
2346
2627
|
normalizeEOL,
|
|
2347
2628
|
normalizeLink,
|
|
2348
2629
|
preventUnload,
|
|
@@ -2360,6 +2641,8 @@ export {
|
|
|
2360
2641
|
sceneCoordsToViewportCoords,
|
|
2361
2642
|
selectNode,
|
|
2362
2643
|
setDateTimeForTests,
|
|
2644
|
+
setDesktopUIMode,
|
|
2645
|
+
setFeatureFlag,
|
|
2363
2646
|
shouldMaintainAspectRatio,
|
|
2364
2647
|
shouldResizeFromCenter,
|
|
2365
2648
|
shouldRotateWithDiscreteAngle,
|