@excalidraw/common 0.18.0-7b8a5f54c → 0.18.0-7f66e1f
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 +286 -44
- package/dist/dev/index.js.map +3 -3
- package/dist/prod/index.js +3 -3
- package/dist/types/common/src/constants.d.ts +18 -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 +2 -1
- package/dist/types/common/src/visualdebug.d.ts +41 -0
- package/dist/types/element/src/bounds.d.ts +1 -1
- package/dist/types/element/src/delta.d.ts +4 -4
- package/dist/types/element/src/index.d.ts +1 -0
- package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
- package/dist/types/element/src/renderElement.d.ts +4 -1
- package/dist/types/element/src/resizeTest.d.ts +5 -4
- package/dist/types/element/src/store.d.ts +3 -2
- package/dist/types/element/src/textElement.d.ts +1 -1
- package/dist/types/element/src/transformHandles.d.ts +5 -4
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +21 -9
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +14 -6
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +94 -41
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +42 -18
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +22 -10
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +14 -6
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionExport.d.ts +63 -27
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +14 -6
- package/dist/types/excalidraw/actions/actionFrame.d.ts +28 -12
- package/dist/types/excalidraw/actions/actionGroup.d.ts +14 -6
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +8 -4
- package/dist/types/excalidraw/actions/actionLink.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +7 -369
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +14 -6
- package/dist/types/excalidraw/actions/actionProperties.d.ts +122 -53
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionStyles.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +8 -4
- package/dist/types/excalidraw/actions/index.d.ts +2 -2
- package/dist/types/excalidraw/actions/types.d.ts +1 -1
- package/dist/types/excalidraw/appState.d.ts +5 -1
- 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 +28 -24
- 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/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/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/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/interactiveScene.d.ts +5 -13
- package/dist/types/excalidraw/scene/types.d.ts +11 -3
- package/dist/types/excalidraw/shortcut.d.ts +1 -0
- package/dist/types/excalidraw/types.d.ts +18 -15
- 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,12 @@ 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"
|
|
738
730
|
};
|
|
739
731
|
var CJK_HAND_DRAWN_FALLBACK_FONT = "Xiaolai";
|
|
740
732
|
var WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
|
|
@@ -829,13 +821,19 @@ var IMAGE_MIME_TYPES = {
|
|
|
829
821
|
avif: "image/avif",
|
|
830
822
|
jfif: "image/jfif"
|
|
831
823
|
};
|
|
832
|
-
var
|
|
824
|
+
var STRING_MIME_TYPES = {
|
|
833
825
|
text: "text/plain",
|
|
834
826
|
html: "text/html",
|
|
835
827
|
json: "application/json",
|
|
836
828
|
// excalidraw data
|
|
837
829
|
excalidraw: "application/vnd.excalidraw+json",
|
|
830
|
+
// LEGACY: fully-qualified library JSON data
|
|
838
831
|
excalidrawlib: "application/vnd.excalidrawlib+json",
|
|
832
|
+
// list of excalidraw library item ids
|
|
833
|
+
excalidrawlibIds: "application/vnd.excalidrawlib.ids+json"
|
|
834
|
+
};
|
|
835
|
+
var MIME_TYPES = {
|
|
836
|
+
...STRING_MIME_TYPES,
|
|
839
837
|
// image-encoded excalidraw data
|
|
840
838
|
"excalidraw.svg": "image/svg+xml",
|
|
841
839
|
"excalidraw.png": "image/png",
|
|
@@ -894,10 +892,6 @@ var DEFAULT_UI_OPTIONS = {
|
|
|
894
892
|
image: true
|
|
895
893
|
}
|
|
896
894
|
};
|
|
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
895
|
var MAX_DECIMALS_FOR_SVG_EXPORT = 2;
|
|
902
896
|
var EXPORT_SCALES = [1, 2, 3];
|
|
903
897
|
var DEFAULT_EXPORT_PADDING = 10;
|
|
@@ -1017,6 +1011,10 @@ var UserIdleState = /* @__PURE__ */ ((UserIdleState2) => {
|
|
|
1017
1011
|
return UserIdleState2;
|
|
1018
1012
|
})(UserIdleState || {});
|
|
1019
1013
|
var LINE_POLYGON_POINT_MERGE_DISTANCE = 20;
|
|
1014
|
+
var DOUBLE_TAP_POSITION_THRESHOLD = 35;
|
|
1015
|
+
var MOBILE_ACTION_BUTTON_BG = {
|
|
1016
|
+
background: "var(--mobile-action-button-bg)"
|
|
1017
|
+
};
|
|
1020
1018
|
|
|
1021
1019
|
// src/font-metadata.ts
|
|
1022
1020
|
init_define_import_meta_env();
|
|
@@ -1172,6 +1170,133 @@ var Queue = class {
|
|
|
1172
1170
|
|
|
1173
1171
|
// src/keys.ts
|
|
1174
1172
|
init_define_import_meta_env();
|
|
1173
|
+
|
|
1174
|
+
// src/editorInterface.ts
|
|
1175
|
+
init_define_import_meta_env();
|
|
1176
|
+
var DESKTOP_UI_MODE_STORAGE_KEY = "excalidraw.desktopUIMode";
|
|
1177
|
+
var MQ_MAX_MOBILE = 599;
|
|
1178
|
+
var MQ_MAX_WIDTH_LANDSCAPE = 1e3;
|
|
1179
|
+
var MQ_MAX_HEIGHT_LANDSCAPE = 500;
|
|
1180
|
+
var MQ_MIN_TABLET = MQ_MAX_MOBILE + 1;
|
|
1181
|
+
var MQ_MAX_TABLET = 1400;
|
|
1182
|
+
var MQ_MIN_WIDTH_DESKTOP = 1440;
|
|
1183
|
+
var MQ_RIGHT_SIDEBAR_MIN_WIDTH = 1229;
|
|
1184
|
+
var isDarwin = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
1185
|
+
var isWindows = /^Win/.test(navigator.platform);
|
|
1186
|
+
var isAndroid = /\b(android)\b/i.test(navigator.userAgent);
|
|
1187
|
+
var isFirefox = typeof window !== "undefined" && "netscape" in window && navigator.userAgent.indexOf("rv:") > 1 && navigator.userAgent.indexOf("Gecko") > 1;
|
|
1188
|
+
var isChrome = navigator.userAgent.indexOf("Chrome") !== -1;
|
|
1189
|
+
var isSafari = !isChrome && navigator.userAgent.indexOf("Safari") !== -1;
|
|
1190
|
+
var isIOS = /iPad|iPhone/i.test(navigator.platform) || // iPadOS 13+
|
|
1191
|
+
navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
|
1192
|
+
var isBrave = () => navigator.brave?.isBrave?.name === "isBrave";
|
|
1193
|
+
var isMobileBreakpoint = (width, height) => {
|
|
1194
|
+
return width <= MQ_MAX_MOBILE || height < MQ_MAX_HEIGHT_LANDSCAPE && width < MQ_MAX_WIDTH_LANDSCAPE;
|
|
1195
|
+
};
|
|
1196
|
+
var isTabletBreakpoint = (editorWidth, editorHeight) => {
|
|
1197
|
+
const minSide = Math.min(editorWidth, editorHeight);
|
|
1198
|
+
const maxSide = Math.max(editorWidth, editorHeight);
|
|
1199
|
+
return minSide >= MQ_MIN_TABLET && maxSide <= MQ_MAX_TABLET;
|
|
1200
|
+
};
|
|
1201
|
+
var isMobileOrTablet = () => {
|
|
1202
|
+
const ua = navigator.userAgent || "";
|
|
1203
|
+
const platform = navigator.platform || "";
|
|
1204
|
+
const uaData = navigator.userAgentData;
|
|
1205
|
+
if (uaData) {
|
|
1206
|
+
const plat = (uaData.platform || "").toLowerCase();
|
|
1207
|
+
const isDesktopOS = plat === "windows" || plat === "macos" || plat === "linux" || plat === "chrome os";
|
|
1208
|
+
if (uaData.mobile === true) {
|
|
1209
|
+
return true;
|
|
1210
|
+
}
|
|
1211
|
+
if (uaData.mobile === false && plat === "android") {
|
|
1212
|
+
const looksTouchTablet = matchMedia?.("(hover: none)").matches && matchMedia?.("(pointer: coarse)").matches;
|
|
1213
|
+
return looksTouchTablet;
|
|
1214
|
+
}
|
|
1215
|
+
if (isDesktopOS) {
|
|
1216
|
+
return false;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
if (isIOS) {
|
|
1220
|
+
return true;
|
|
1221
|
+
}
|
|
1222
|
+
if (isAndroid) {
|
|
1223
|
+
const isAndroidPhone = /Mobile/i.test(ua);
|
|
1224
|
+
const isAndroidTablet = !isAndroidPhone;
|
|
1225
|
+
if (isAndroidPhone || isAndroidTablet) {
|
|
1226
|
+
const looksTouchTablet = matchMedia?.("(hover: none)").matches && matchMedia?.("(pointer: coarse)").matches;
|
|
1227
|
+
return looksTouchTablet;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
const looksDesktopPlatform = /Win|Linux|CrOS|Mac/.test(platform) || /Windows NT|X11|CrOS|Macintosh/.test(ua);
|
|
1231
|
+
if (looksDesktopPlatform) {
|
|
1232
|
+
return false;
|
|
1233
|
+
}
|
|
1234
|
+
return false;
|
|
1235
|
+
};
|
|
1236
|
+
var getFormFactor = (editorWidth, editorHeight) => {
|
|
1237
|
+
if (isMobileBreakpoint(editorWidth, editorHeight)) {
|
|
1238
|
+
return "phone";
|
|
1239
|
+
}
|
|
1240
|
+
if (isTabletBreakpoint(editorWidth, editorHeight)) {
|
|
1241
|
+
return "tablet";
|
|
1242
|
+
}
|
|
1243
|
+
return "desktop";
|
|
1244
|
+
};
|
|
1245
|
+
var deriveStylesPanelMode = (editorInterface) => {
|
|
1246
|
+
if (editorInterface.formFactor === "phone") {
|
|
1247
|
+
return "mobile";
|
|
1248
|
+
}
|
|
1249
|
+
if (editorInterface.formFactor === "tablet") {
|
|
1250
|
+
return "compact";
|
|
1251
|
+
}
|
|
1252
|
+
return editorInterface.desktopUIMode;
|
|
1253
|
+
};
|
|
1254
|
+
var createUserAgentDescriptor = (userAgentString) => {
|
|
1255
|
+
const normalizedUA = userAgentString ?? "";
|
|
1256
|
+
let platform = "unknown";
|
|
1257
|
+
if (isIOS) {
|
|
1258
|
+
platform = "ios";
|
|
1259
|
+
} else if (isAndroid) {
|
|
1260
|
+
platform = "android";
|
|
1261
|
+
} else if (normalizedUA) {
|
|
1262
|
+
platform = "other";
|
|
1263
|
+
}
|
|
1264
|
+
return {
|
|
1265
|
+
isMobileDevice: isMobileOrTablet(),
|
|
1266
|
+
platform
|
|
1267
|
+
};
|
|
1268
|
+
};
|
|
1269
|
+
var loadDesktopUIModePreference = () => {
|
|
1270
|
+
if (typeof window === "undefined") {
|
|
1271
|
+
return null;
|
|
1272
|
+
}
|
|
1273
|
+
try {
|
|
1274
|
+
const stored = window.localStorage.getItem(DESKTOP_UI_MODE_STORAGE_KEY);
|
|
1275
|
+
if (stored === "compact" || stored === "full") {
|
|
1276
|
+
return stored;
|
|
1277
|
+
}
|
|
1278
|
+
} catch (error) {
|
|
1279
|
+
}
|
|
1280
|
+
return null;
|
|
1281
|
+
};
|
|
1282
|
+
var persistDesktopUIMode = (mode) => {
|
|
1283
|
+
if (typeof window === "undefined") {
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
try {
|
|
1287
|
+
window.localStorage.setItem(DESKTOP_UI_MODE_STORAGE_KEY, mode);
|
|
1288
|
+
} catch (error) {
|
|
1289
|
+
}
|
|
1290
|
+
};
|
|
1291
|
+
var setDesktopUIMode = (mode) => {
|
|
1292
|
+
if (mode !== "compact" && mode !== "full") {
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
persistDesktopUIMode(mode);
|
|
1296
|
+
return mode;
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
// src/keys.ts
|
|
1175
1300
|
var CODES = {
|
|
1176
1301
|
EQUAL: "Equal",
|
|
1177
1302
|
MINUS: "Minus",
|
|
@@ -1417,7 +1542,7 @@ var isInteractive = (target) => {
|
|
|
1417
1542
|
return isInputLike(target) || target instanceof Element && !!target.closest("label, button");
|
|
1418
1543
|
};
|
|
1419
1544
|
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");
|
|
1545
|
+
target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && (target.type === "text" || target.type === "number" || target.type === "password" || target.type === "search");
|
|
1421
1546
|
var getFontFamilyString = ({
|
|
1422
1547
|
fontFamily
|
|
1423
1548
|
}) => {
|
|
@@ -1434,6 +1559,9 @@ var getFontString = ({
|
|
|
1434
1559
|
}) => {
|
|
1435
1560
|
return `${fontSize}px ${getFontFamilyString({ fontFamily })}`;
|
|
1436
1561
|
};
|
|
1562
|
+
var nextAnimationFrame = async (cb) => {
|
|
1563
|
+
requestAnimationFrame(() => requestAnimationFrame(cb));
|
|
1564
|
+
};
|
|
1437
1565
|
var debounce = (fn, timeout) => {
|
|
1438
1566
|
let handle = 0;
|
|
1439
1567
|
let lastArgs = null;
|
|
@@ -1619,13 +1747,6 @@ var updateActiveTool = (appState, data) => {
|
|
|
1619
1747
|
var isFullScreen = () => document.fullscreenElement?.nodeName === "HTML";
|
|
1620
1748
|
var allowFullScreen = () => document.documentElement.requestFullscreen();
|
|
1621
1749
|
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
1750
|
var viewportCoordsToSceneCoords = ({ clientX, clientY }, {
|
|
1630
1751
|
zoom,
|
|
1631
1752
|
offsetLeft,
|
|
@@ -2140,6 +2261,107 @@ var Emitter = class {
|
|
|
2140
2261
|
this.subscribers = [];
|
|
2141
2262
|
}
|
|
2142
2263
|
};
|
|
2264
|
+
|
|
2265
|
+
// src/visualdebug.ts
|
|
2266
|
+
init_define_import_meta_env();
|
|
2267
|
+
import {
|
|
2268
|
+
isLineSegment,
|
|
2269
|
+
lineSegment,
|
|
2270
|
+
pointFrom
|
|
2271
|
+
} from "@excalidraw/math";
|
|
2272
|
+
import { isBounds } from "@excalidraw/element";
|
|
2273
|
+
var debugDrawCubicBezier = (c, opts) => {
|
|
2274
|
+
addToCurrentFrame({
|
|
2275
|
+
color: opts?.color ?? "purple",
|
|
2276
|
+
permanent: !!opts?.permanent,
|
|
2277
|
+
data: c
|
|
2278
|
+
});
|
|
2279
|
+
};
|
|
2280
|
+
var debugDrawLine = (segment, opts) => {
|
|
2281
|
+
const segments = isLineSegment(segment) ? [segment] : segment;
|
|
2282
|
+
segments.forEach(
|
|
2283
|
+
(data) => addToCurrentFrame({
|
|
2284
|
+
color: opts?.color ?? "red",
|
|
2285
|
+
data,
|
|
2286
|
+
permanent: !!opts?.permanent
|
|
2287
|
+
})
|
|
2288
|
+
);
|
|
2289
|
+
};
|
|
2290
|
+
var debugDrawPoint = (p, opts) => {
|
|
2291
|
+
const xOffset = opts?.fuzzy ? Math.random() * 3 : 0;
|
|
2292
|
+
const yOffset = opts?.fuzzy ? Math.random() * 3 : 0;
|
|
2293
|
+
debugDrawLine(
|
|
2294
|
+
lineSegment(
|
|
2295
|
+
pointFrom(p[0] + xOffset - 10, p[1] + yOffset - 10),
|
|
2296
|
+
pointFrom(p[0] + xOffset + 10, p[1] + yOffset + 10)
|
|
2297
|
+
),
|
|
2298
|
+
{
|
|
2299
|
+
color: opts?.color ?? "cyan",
|
|
2300
|
+
permanent: opts?.permanent
|
|
2301
|
+
}
|
|
2302
|
+
);
|
|
2303
|
+
debugDrawLine(
|
|
2304
|
+
lineSegment(
|
|
2305
|
+
pointFrom(p[0] + xOffset - 10, p[1] + yOffset + 10),
|
|
2306
|
+
pointFrom(p[0] + xOffset + 10, p[1] + yOffset - 10)
|
|
2307
|
+
),
|
|
2308
|
+
{
|
|
2309
|
+
color: opts?.color ?? "cyan",
|
|
2310
|
+
permanent: opts?.permanent
|
|
2311
|
+
}
|
|
2312
|
+
);
|
|
2313
|
+
};
|
|
2314
|
+
var debugDrawBounds = (box, opts) => {
|
|
2315
|
+
(isBounds(box) ? [box] : box).forEach(
|
|
2316
|
+
(bbox) => debugDrawLine(
|
|
2317
|
+
[
|
|
2318
|
+
lineSegment(
|
|
2319
|
+
pointFrom(bbox[0], bbox[1]),
|
|
2320
|
+
pointFrom(bbox[2], bbox[1])
|
|
2321
|
+
),
|
|
2322
|
+
lineSegment(
|
|
2323
|
+
pointFrom(bbox[2], bbox[1]),
|
|
2324
|
+
pointFrom(bbox[2], bbox[3])
|
|
2325
|
+
),
|
|
2326
|
+
lineSegment(
|
|
2327
|
+
pointFrom(bbox[2], bbox[3]),
|
|
2328
|
+
pointFrom(bbox[0], bbox[3])
|
|
2329
|
+
),
|
|
2330
|
+
lineSegment(
|
|
2331
|
+
pointFrom(bbox[0], bbox[3]),
|
|
2332
|
+
pointFrom(bbox[0], bbox[1])
|
|
2333
|
+
)
|
|
2334
|
+
],
|
|
2335
|
+
{
|
|
2336
|
+
color: opts?.color ?? "green",
|
|
2337
|
+
permanent: !!opts?.permanent
|
|
2338
|
+
}
|
|
2339
|
+
)
|
|
2340
|
+
);
|
|
2341
|
+
};
|
|
2342
|
+
var debugDrawPoints = ({
|
|
2343
|
+
x,
|
|
2344
|
+
y,
|
|
2345
|
+
points
|
|
2346
|
+
}, options) => {
|
|
2347
|
+
points.forEach(
|
|
2348
|
+
(p) => debugDrawPoint(pointFrom(x + p[0], y + p[1]), options)
|
|
2349
|
+
);
|
|
2350
|
+
};
|
|
2351
|
+
var debugCloseFrame = () => {
|
|
2352
|
+
window.visualDebug?.data.push([]);
|
|
2353
|
+
};
|
|
2354
|
+
var debugClear = () => {
|
|
2355
|
+
if (window.visualDebug?.data) {
|
|
2356
|
+
window.visualDebug.data = [];
|
|
2357
|
+
}
|
|
2358
|
+
};
|
|
2359
|
+
var addToCurrentFrame = (element) => {
|
|
2360
|
+
if (window.visualDebug?.data && window.visualDebug.data.length === 0) {
|
|
2361
|
+
window.visualDebug.data[0] = [];
|
|
2362
|
+
}
|
|
2363
|
+
window.visualDebug?.data && window.visualDebug.data[window.visualDebug.data.length - 1].push(element);
|
|
2364
|
+
};
|
|
2143
2365
|
export {
|
|
2144
2366
|
ACTIVE_THRESHOLD,
|
|
2145
2367
|
ALLOWED_PASTE_MIME_TYPES,
|
|
@@ -2189,6 +2411,7 @@ export {
|
|
|
2189
2411
|
DEFAULT_UI_OPTIONS,
|
|
2190
2412
|
DEFAULT_VERSION,
|
|
2191
2413
|
DEFAULT_VERTICAL_ALIGN,
|
|
2414
|
+
DOUBLE_TAP_POSITION_THRESHOLD,
|
|
2192
2415
|
DRAGGING_THRESHOLD,
|
|
2193
2416
|
EDITOR_LS_KEYS,
|
|
2194
2417
|
ELEMENTS_PALETTE_SHADE_INDEXES,
|
|
@@ -2230,10 +2453,14 @@ export {
|
|
|
2230
2453
|
MIN_FONT_SIZE,
|
|
2231
2454
|
MIN_WIDTH_OR_HEIGHT,
|
|
2232
2455
|
MIN_ZOOM,
|
|
2456
|
+
MOBILE_ACTION_BUTTON_BG,
|
|
2233
2457
|
MONOSPACE_GENERIC_FONT,
|
|
2234
2458
|
MQ_MAX_HEIGHT_LANDSCAPE,
|
|
2459
|
+
MQ_MAX_MOBILE,
|
|
2460
|
+
MQ_MAX_TABLET,
|
|
2235
2461
|
MQ_MAX_WIDTH_LANDSCAPE,
|
|
2236
|
-
|
|
2462
|
+
MQ_MIN_TABLET,
|
|
2463
|
+
MQ_MIN_WIDTH_DESKTOP,
|
|
2237
2464
|
MQ_RIGHT_SIDEBAR_MIN_WIDTH,
|
|
2238
2465
|
ORIG_ID,
|
|
2239
2466
|
POINTER_BUTTON,
|
|
@@ -2247,6 +2474,7 @@ export {
|
|
|
2247
2474
|
SHIFT_LOCKING_ANGLE,
|
|
2248
2475
|
SIDE_RESIZING_THRESHOLD,
|
|
2249
2476
|
STATS_PANELS,
|
|
2477
|
+
STRING_MIME_TYPES,
|
|
2250
2478
|
STROKE_WIDTH,
|
|
2251
2479
|
SVG_DOCUMENT_PREAMBLE,
|
|
2252
2480
|
SVG_NS,
|
|
@@ -2281,7 +2509,16 @@ export {
|
|
|
2281
2509
|
chunk,
|
|
2282
2510
|
cloneJSON,
|
|
2283
2511
|
composeEventHandlers,
|
|
2512
|
+
createUserAgentDescriptor,
|
|
2284
2513
|
debounce,
|
|
2514
|
+
debugClear,
|
|
2515
|
+
debugCloseFrame,
|
|
2516
|
+
debugDrawBounds,
|
|
2517
|
+
debugDrawCubicBezier,
|
|
2518
|
+
debugDrawLine,
|
|
2519
|
+
debugDrawPoint,
|
|
2520
|
+
debugDrawPoints,
|
|
2521
|
+
deriveStylesPanelMode,
|
|
2285
2522
|
distance,
|
|
2286
2523
|
easeOut,
|
|
2287
2524
|
easeToValuesRAF,
|
|
@@ -2296,13 +2533,13 @@ export {
|
|
|
2296
2533
|
getFontFamilyFallbacks,
|
|
2297
2534
|
getFontFamilyString,
|
|
2298
2535
|
getFontString,
|
|
2536
|
+
getFormFactor,
|
|
2299
2537
|
getFrame,
|
|
2300
2538
|
getGenericFontFamilyFallback,
|
|
2301
2539
|
getGlobalCSSVariable,
|
|
2302
2540
|
getGridPoint,
|
|
2303
2541
|
getLineHeight,
|
|
2304
2542
|
getNearestScrollableContainer,
|
|
2305
|
-
getShortcutKey,
|
|
2306
2543
|
getSizeFromPoints,
|
|
2307
2544
|
getSpecificColorShades,
|
|
2308
2545
|
getSvgPathFromStroke,
|
|
@@ -2326,6 +2563,7 @@ export {
|
|
|
2326
2563
|
isLatinChar,
|
|
2327
2564
|
isLocalLink,
|
|
2328
2565
|
isMemberOf,
|
|
2566
|
+
isMobileBreakpoint,
|
|
2329
2567
|
isPrimitive,
|
|
2330
2568
|
isProdEnv,
|
|
2331
2569
|
isPromiseLike,
|
|
@@ -2335,16 +2573,19 @@ export {
|
|
|
2335
2573
|
isSafari,
|
|
2336
2574
|
isServerEnv,
|
|
2337
2575
|
isShallowEqual,
|
|
2576
|
+
isTabletBreakpoint,
|
|
2338
2577
|
isTestEnv,
|
|
2339
2578
|
isToolIcon,
|
|
2340
2579
|
isTransparent,
|
|
2341
2580
|
isWindows,
|
|
2342
2581
|
isWritableElement,
|
|
2582
|
+
loadDesktopUIModePreference,
|
|
2343
2583
|
mapFind,
|
|
2344
2584
|
matchKey,
|
|
2345
2585
|
memoize,
|
|
2346
2586
|
muteFSAbortError,
|
|
2347
2587
|
nFormatter,
|
|
2588
|
+
nextAnimationFrame,
|
|
2348
2589
|
normalizeEOL,
|
|
2349
2590
|
normalizeLink,
|
|
2350
2591
|
preventUnload,
|
|
@@ -2362,6 +2603,7 @@ export {
|
|
|
2362
2603
|
sceneCoordsToViewportCoords,
|
|
2363
2604
|
selectNode,
|
|
2364
2605
|
setDateTimeForTests,
|
|
2606
|
+
setDesktopUIMode,
|
|
2365
2607
|
shouldMaintainAspectRatio,
|
|
2366
2608
|
shouldResizeFromCenter,
|
|
2367
2609
|
shouldRotateWithDiscreteAngle,
|