@excalidraw/common 0.18.0-508de2f3a → 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 +327 -46
- package/dist/dev/index.js.map +3 -3
- package/dist/prod/index.js +3 -3
- package/dist/types/common/src/constants.d.ts +20 -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/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 +4 -5
- package/dist/types/element/src/index.d.ts +1 -3
- package/dist/types/element/src/linearElementEditor.d.ts +15 -18
- package/dist/types/element/src/mutateElement.d.ts +0 -1
- 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 +5 -0
- 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 -13
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +25 -11
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +153 -262
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +46 -773
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +12 -5
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +42 -23
- 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 -6
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +23 -9
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +12 -5
- package/dist/types/excalidraw/actions/actionExport.d.ts +68 -943
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +10 -393
- package/dist/types/excalidraw/actions/actionFlip.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionFrame.d.ts +50 -24
- package/dist/types/excalidraw/actions/actionGroup.d.ts +24 -10
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +22 -19
- package/dist/types/excalidraw/actions/actionLink.d.ts +9 -2
- package/dist/types/excalidraw/actions/actionMenu.d.ts +10 -371
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +21 -359
- package/dist/types/excalidraw/actions/actionProperties.d.ts +87 -2403
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +12 -5
- package/dist/types/excalidraw/actions/actionStyles.d.ts +13 -6
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +11 -4
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +11 -4
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +10 -5
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +11 -4
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +11 -4
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +12 -5
- 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 +21 -4
- package/dist/types/excalidraw/components/App.d.ts +36 -27
- 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/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/restore.d.ts +3 -3
- 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 +2 -3
- 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/scene/types.d.ts +15 -3
- package/dist/types/excalidraw/shortcut.d.ts +1 -0
- package/dist/types/excalidraw/types.d.ts +32 -21
- 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,15 +640,6 @@ 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;
|
|
@@ -731,10 +721,13 @@ var ENV = {
|
|
|
731
721
|
PRODUCTION: "production"
|
|
732
722
|
};
|
|
733
723
|
var CLASSES = {
|
|
724
|
+
SIDEBAR: "sidebar",
|
|
734
725
|
SHAPE_ACTIONS_MENU: "App-menu__left",
|
|
735
726
|
ZOOM_ACTIONS: "zoom-actions",
|
|
736
727
|
SEARCH_MENU_INPUT_WRAPPER: "layer-ui__search-inputWrapper",
|
|
737
|
-
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"
|
|
738
731
|
};
|
|
739
732
|
var CJK_HAND_DRAWN_FALLBACK_FONT = "Xiaolai";
|
|
740
733
|
var WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
|
|
@@ -829,13 +822,19 @@ var IMAGE_MIME_TYPES = {
|
|
|
829
822
|
avif: "image/avif",
|
|
830
823
|
jfif: "image/jfif"
|
|
831
824
|
};
|
|
832
|
-
var
|
|
825
|
+
var STRING_MIME_TYPES = {
|
|
833
826
|
text: "text/plain",
|
|
834
827
|
html: "text/html",
|
|
835
828
|
json: "application/json",
|
|
836
829
|
// excalidraw data
|
|
837
830
|
excalidraw: "application/vnd.excalidraw+json",
|
|
831
|
+
// LEGACY: fully-qualified library JSON data
|
|
838
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,
|
|
839
838
|
// image-encoded excalidraw data
|
|
840
839
|
"excalidraw.svg": "image/svg+xml",
|
|
841
840
|
"excalidraw.png": "image/png",
|
|
@@ -894,10 +893,6 @@ var DEFAULT_UI_OPTIONS = {
|
|
|
894
893
|
image: true
|
|
895
894
|
}
|
|
896
895
|
};
|
|
897
|
-
var MQ_MAX_WIDTH_PORTRAIT = 730;
|
|
898
|
-
var MQ_MAX_WIDTH_LANDSCAPE = 1e3;
|
|
899
|
-
var MQ_MAX_HEIGHT_LANDSCAPE = 500;
|
|
900
|
-
var MQ_RIGHT_SIDEBAR_MIN_WIDTH = 1229;
|
|
901
896
|
var MAX_DECIMALS_FOR_SVG_EXPORT = 2;
|
|
902
897
|
var EXPORT_SCALES = [1, 2, 3];
|
|
903
898
|
var DEFAULT_EXPORT_PADDING = 10;
|
|
@@ -1017,6 +1012,11 @@ var UserIdleState = /* @__PURE__ */ ((UserIdleState2) => {
|
|
|
1017
1012
|
return UserIdleState2;
|
|
1018
1013
|
})(UserIdleState || {});
|
|
1019
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
|
+
};
|
|
1020
1020
|
|
|
1021
1021
|
// src/font-metadata.ts
|
|
1022
1022
|
init_define_import_meta_env();
|
|
@@ -1172,6 +1172,133 @@ var Queue = class {
|
|
|
1172
1172
|
|
|
1173
1173
|
// src/keys.ts
|
|
1174
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
|
|
1175
1302
|
var CODES = {
|
|
1176
1303
|
EQUAL: "Equal",
|
|
1177
1304
|
MINUS: "Minus",
|
|
@@ -1417,7 +1544,7 @@ var isInteractive = (target) => {
|
|
|
1417
1544
|
return isInputLike(target) || target instanceof Element && !!target.closest("label, button");
|
|
1418
1545
|
};
|
|
1419
1546
|
var isWritableElement = (target) => target instanceof HTMLElement && target.dataset.type === "wysiwyg" || target instanceof HTMLBRElement || // newline in wysiwyg
|
|
1420
|
-
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");
|
|
1421
1548
|
var getFontFamilyString = ({
|
|
1422
1549
|
fontFamily
|
|
1423
1550
|
}) => {
|
|
@@ -1434,6 +1561,9 @@ var getFontString = ({
|
|
|
1434
1561
|
}) => {
|
|
1435
1562
|
return `${fontSize}px ${getFontFamilyString({ fontFamily })}`;
|
|
1436
1563
|
};
|
|
1564
|
+
var nextAnimationFrame = async (cb) => {
|
|
1565
|
+
requestAnimationFrame(() => requestAnimationFrame(cb));
|
|
1566
|
+
};
|
|
1437
1567
|
var debounce = (fn, timeout) => {
|
|
1438
1568
|
let handle = 0;
|
|
1439
1569
|
let lastArgs = null;
|
|
@@ -1598,6 +1728,9 @@ var removeSelection = () => {
|
|
|
1598
1728
|
}
|
|
1599
1729
|
};
|
|
1600
1730
|
var distance = (x, y) => Math.abs(x - y);
|
|
1731
|
+
var isSelectionLikeTool = (type) => {
|
|
1732
|
+
return type === "selection" || type === "lasso";
|
|
1733
|
+
};
|
|
1601
1734
|
var updateActiveTool = (appState, data) => {
|
|
1602
1735
|
if (data.type === "custom") {
|
|
1603
1736
|
return {
|
|
@@ -1619,13 +1752,6 @@ var updateActiveTool = (appState, data) => {
|
|
|
1619
1752
|
var isFullScreen = () => document.fullscreenElement?.nodeName === "HTML";
|
|
1620
1753
|
var allowFullScreen = () => document.documentElement.requestFullscreen();
|
|
1621
1754
|
var exitFullScreen = () => document.exitFullscreen();
|
|
1622
|
-
var getShortcutKey = (shortcut) => {
|
|
1623
|
-
shortcut = shortcut.replace(/\bAlt\b/i, "Alt").replace(/\bShift\b/i, "Shift").replace(/\b(Enter|Return)\b/i, "Enter");
|
|
1624
|
-
if (isDarwin) {
|
|
1625
|
-
return shortcut.replace(/\bCtrlOrCmd\b/gi, "Cmd").replace(/\bAlt\b/i, "Option");
|
|
1626
|
-
}
|
|
1627
|
-
return shortcut.replace(/\bCtrlOrCmd\b/gi, "Ctrl");
|
|
1628
|
-
};
|
|
1629
1755
|
var viewportCoordsToSceneCoords = ({ clientX, clientY }, {
|
|
1630
1756
|
zoom,
|
|
1631
1757
|
offsetLeft,
|
|
@@ -1704,7 +1830,6 @@ var isTransparent = (color) => {
|
|
|
1704
1830
|
const isRRGGBBTransparent = color.length === 9 && color.substr(7, 2) === "00";
|
|
1705
1831
|
return isRGBTransparent || isRRGGBBTransparent || color === COLOR_PALETTE.transparent;
|
|
1706
1832
|
};
|
|
1707
|
-
var isBindingFallthroughEnabled = (el) => el.fillStyle !== "solid" || isTransparent(el.backgroundColor);
|
|
1708
1833
|
var resolvablePromise = () => {
|
|
1709
1834
|
let resolve;
|
|
1710
1835
|
let reject;
|
|
@@ -2067,6 +2192,38 @@ var reduceToCommonValue = (collection, getValue) => {
|
|
|
2067
2192
|
}
|
|
2068
2193
|
return commonValue;
|
|
2069
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
|
+
};
|
|
2070
2227
|
|
|
2071
2228
|
// src/random.ts
|
|
2072
2229
|
var random = new Random(Date.now());
|
|
@@ -2140,6 +2297,107 @@ var Emitter = class {
|
|
|
2140
2297
|
this.subscribers = [];
|
|
2141
2298
|
}
|
|
2142
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
|
+
};
|
|
2143
2401
|
export {
|
|
2144
2402
|
ACTIVE_THRESHOLD,
|
|
2145
2403
|
ALLOWED_PASTE_MIME_TYPES,
|
|
@@ -2147,6 +2405,7 @@ export {
|
|
|
2147
2405
|
ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO,
|
|
2148
2406
|
ARROW_LABEL_WIDTH_FRACTION,
|
|
2149
2407
|
ARROW_TYPE,
|
|
2408
|
+
BIND_MODE_TIMEOUT,
|
|
2150
2409
|
BOUND_TEXT_PADDING,
|
|
2151
2410
|
BinaryHeap,
|
|
2152
2411
|
CANVAS_ONLY_ACTIONS,
|
|
@@ -2189,6 +2448,7 @@ export {
|
|
|
2189
2448
|
DEFAULT_UI_OPTIONS,
|
|
2190
2449
|
DEFAULT_VERSION,
|
|
2191
2450
|
DEFAULT_VERTICAL_ALIGN,
|
|
2451
|
+
DOUBLE_TAP_POSITION_THRESHOLD,
|
|
2192
2452
|
DRAGGING_THRESHOLD,
|
|
2193
2453
|
EDITOR_LS_KEYS,
|
|
2194
2454
|
ELEMENTS_PALETTE_SHADE_INDEXES,
|
|
@@ -2230,10 +2490,14 @@ export {
|
|
|
2230
2490
|
MIN_FONT_SIZE,
|
|
2231
2491
|
MIN_WIDTH_OR_HEIGHT,
|
|
2232
2492
|
MIN_ZOOM,
|
|
2493
|
+
MOBILE_ACTION_BUTTON_BG,
|
|
2233
2494
|
MONOSPACE_GENERIC_FONT,
|
|
2234
2495
|
MQ_MAX_HEIGHT_LANDSCAPE,
|
|
2496
|
+
MQ_MAX_MOBILE,
|
|
2497
|
+
MQ_MAX_TABLET,
|
|
2235
2498
|
MQ_MAX_WIDTH_LANDSCAPE,
|
|
2236
|
-
|
|
2499
|
+
MQ_MIN_TABLET,
|
|
2500
|
+
MQ_MIN_WIDTH_DESKTOP,
|
|
2237
2501
|
MQ_RIGHT_SIDEBAR_MIN_WIDTH,
|
|
2238
2502
|
ORIG_ID,
|
|
2239
2503
|
POINTER_BUTTON,
|
|
@@ -2247,6 +2511,7 @@ export {
|
|
|
2247
2511
|
SHIFT_LOCKING_ANGLE,
|
|
2248
2512
|
SIDE_RESIZING_THRESHOLD,
|
|
2249
2513
|
STATS_PANELS,
|
|
2514
|
+
STRING_MIME_TYPES,
|
|
2250
2515
|
STROKE_WIDTH,
|
|
2251
2516
|
SVG_DOCUMENT_PREAMBLE,
|
|
2252
2517
|
SVG_NS,
|
|
@@ -2281,7 +2546,16 @@ export {
|
|
|
2281
2546
|
chunk,
|
|
2282
2547
|
cloneJSON,
|
|
2283
2548
|
composeEventHandlers,
|
|
2549
|
+
createUserAgentDescriptor,
|
|
2284
2550
|
debounce,
|
|
2551
|
+
debugClear,
|
|
2552
|
+
debugCloseFrame,
|
|
2553
|
+
debugDrawBounds,
|
|
2554
|
+
debugDrawCubicBezier,
|
|
2555
|
+
debugDrawLine,
|
|
2556
|
+
debugDrawPoint,
|
|
2557
|
+
debugDrawPoints,
|
|
2558
|
+
deriveStylesPanelMode,
|
|
2285
2559
|
distance,
|
|
2286
2560
|
easeOut,
|
|
2287
2561
|
easeToValuesRAF,
|
|
@@ -2293,16 +2567,17 @@ export {
|
|
|
2293
2567
|
getAllColorsSpecificShade,
|
|
2294
2568
|
getDateTime,
|
|
2295
2569
|
getExportSource,
|
|
2570
|
+
getFeatureFlag,
|
|
2296
2571
|
getFontFamilyFallbacks,
|
|
2297
2572
|
getFontFamilyString,
|
|
2298
2573
|
getFontString,
|
|
2574
|
+
getFormFactor,
|
|
2299
2575
|
getFrame,
|
|
2300
2576
|
getGenericFontFamilyFallback,
|
|
2301
2577
|
getGlobalCSSVariable,
|
|
2302
2578
|
getGridPoint,
|
|
2303
2579
|
getLineHeight,
|
|
2304
2580
|
getNearestScrollableContainer,
|
|
2305
|
-
getShortcutKey,
|
|
2306
2581
|
getSizeFromPoints,
|
|
2307
2582
|
getSpecificColorShades,
|
|
2308
2583
|
getSvgPathFromStroke,
|
|
@@ -2313,7 +2588,6 @@ export {
|
|
|
2313
2588
|
isAndroid,
|
|
2314
2589
|
isAnyTrue,
|
|
2315
2590
|
isArrowKey,
|
|
2316
|
-
isBindingFallthroughEnabled,
|
|
2317
2591
|
isBrave,
|
|
2318
2592
|
isChrome,
|
|
2319
2593
|
isDarwin,
|
|
@@ -2326,6 +2600,7 @@ export {
|
|
|
2326
2600
|
isLatinChar,
|
|
2327
2601
|
isLocalLink,
|
|
2328
2602
|
isMemberOf,
|
|
2603
|
+
isMobileBreakpoint,
|
|
2329
2604
|
isPrimitive,
|
|
2330
2605
|
isProdEnv,
|
|
2331
2606
|
isPromiseLike,
|
|
@@ -2333,18 +2608,22 @@ export {
|
|
|
2333
2608
|
isReadonlyArray,
|
|
2334
2609
|
isRunningInIframe,
|
|
2335
2610
|
isSafari,
|
|
2611
|
+
isSelectionLikeTool,
|
|
2336
2612
|
isServerEnv,
|
|
2337
2613
|
isShallowEqual,
|
|
2614
|
+
isTabletBreakpoint,
|
|
2338
2615
|
isTestEnv,
|
|
2339
2616
|
isToolIcon,
|
|
2340
2617
|
isTransparent,
|
|
2341
2618
|
isWindows,
|
|
2342
2619
|
isWritableElement,
|
|
2620
|
+
loadDesktopUIModePreference,
|
|
2343
2621
|
mapFind,
|
|
2344
2622
|
matchKey,
|
|
2345
2623
|
memoize,
|
|
2346
2624
|
muteFSAbortError,
|
|
2347
2625
|
nFormatter,
|
|
2626
|
+
nextAnimationFrame,
|
|
2348
2627
|
normalizeEOL,
|
|
2349
2628
|
normalizeLink,
|
|
2350
2629
|
preventUnload,
|
|
@@ -2362,6 +2641,8 @@ export {
|
|
|
2362
2641
|
sceneCoordsToViewportCoords,
|
|
2363
2642
|
selectNode,
|
|
2364
2643
|
setDateTimeForTests,
|
|
2644
|
+
setDesktopUIMode,
|
|
2645
|
+
setFeatureFlag,
|
|
2365
2646
|
shouldMaintainAspectRatio,
|
|
2366
2647
|
shouldResizeFromCenter,
|
|
2367
2648
|
shouldRotateWithDiscreteAngle,
|