@excalidraw/common 0.18.0-7b8a5f54c → 0.18.0-835eb8d
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 +85 -25
- package/dist/dev/index.js.map +2 -2
- package/dist/prod/index.js +3 -3
- package/dist/types/common/src/constants.d.ts +20 -4
- package/dist/types/common/src/utils.d.ts +3 -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/store.d.ts +3 -2
- package/dist/types/element/src/textElement.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +6 -3
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +29 -15
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +12 -6
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +6 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionExport.d.ts +18 -9
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionFrame.d.ts +8 -4
- package/dist/types/excalidraw/actions/actionGroup.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +3 -2
- package/dist/types/excalidraw/actions/actionLink.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +6 -3
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionProperties.d.ts +48 -24
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionStyles.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +2 -1
- package/dist/types/excalidraw/actions/index.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +1 -1
- package/dist/types/excalidraw/appState.d.ts +1 -0
- package/dist/types/excalidraw/clipboard.d.ts +64 -1
- package/dist/types/excalidraw/components/Actions.d.ts +8 -1
- package/dist/types/excalidraw/components/App.d.ts +11 -9
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +2 -1
- package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +2 -1
- package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -1
- package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
- package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
- package/dist/types/excalidraw/components/TextField.d.ts +1 -0
- package/dist/types/excalidraw/components/icons.d.ts +6 -0
- 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/useTextEditorFocus.d.ts +14 -0
- package/dist/types/excalidraw/types.d.ts +5 -1
- 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);
|
|
@@ -647,9 +646,12 @@ var isAndroid = /\b(android)\b/i.test(navigator.userAgent);
|
|
|
647
646
|
var isFirefox = typeof window !== "undefined" && "netscape" in window && navigator.userAgent.indexOf("rv:") > 1 && navigator.userAgent.indexOf("Gecko") > 1;
|
|
648
647
|
var isChrome = navigator.userAgent.indexOf("Chrome") !== -1;
|
|
649
648
|
var isSafari = !isChrome && navigator.userAgent.indexOf("Safari") !== -1;
|
|
650
|
-
var isIOS = /iPad|iPhone
|
|
649
|
+
var isIOS = /iPad|iPhone/i.test(navigator.platform) || // iPadOS 13+
|
|
651
650
|
navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
|
652
651
|
var isBrave = () => navigator.brave?.isBrave?.name === "isBrave";
|
|
652
|
+
var isMobile = isIOS || /android|webos|ipod|blackberry|iemobile|opera mini/i.test(
|
|
653
|
+
navigator.userAgent
|
|
654
|
+
) || /android|ios|ipod|blackberry|windows phone/i.test(navigator.platform);
|
|
653
655
|
var supportsResizeObserver = typeof window !== "undefined" && "ResizeObserver" in window;
|
|
654
656
|
var APP_NAME = "Excalidraw";
|
|
655
657
|
var TEXT_AUTOWRAP_THRESHOLD = 36;
|
|
@@ -731,10 +733,12 @@ var ENV = {
|
|
|
731
733
|
PRODUCTION: "production"
|
|
732
734
|
};
|
|
733
735
|
var CLASSES = {
|
|
736
|
+
SIDEBAR: "sidebar",
|
|
734
737
|
SHAPE_ACTIONS_MENU: "App-menu__left",
|
|
735
738
|
ZOOM_ACTIONS: "zoom-actions",
|
|
736
739
|
SEARCH_MENU_INPUT_WRAPPER: "layer-ui__search-inputWrapper",
|
|
737
|
-
CONVERT_ELEMENT_TYPE_POPUP: "ConvertElementTypePopup"
|
|
740
|
+
CONVERT_ELEMENT_TYPE_POPUP: "ConvertElementTypePopup",
|
|
741
|
+
SHAPE_ACTIONS_THEME_SCOPE: "shape-actions-theme-scope"
|
|
738
742
|
};
|
|
739
743
|
var CJK_HAND_DRAWN_FALLBACK_FONT = "Xiaolai";
|
|
740
744
|
var WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
|
|
@@ -829,13 +833,19 @@ var IMAGE_MIME_TYPES = {
|
|
|
829
833
|
avif: "image/avif",
|
|
830
834
|
jfif: "image/jfif"
|
|
831
835
|
};
|
|
832
|
-
var
|
|
836
|
+
var STRING_MIME_TYPES = {
|
|
833
837
|
text: "text/plain",
|
|
834
838
|
html: "text/html",
|
|
835
839
|
json: "application/json",
|
|
836
840
|
// excalidraw data
|
|
837
841
|
excalidraw: "application/vnd.excalidraw+json",
|
|
842
|
+
// LEGACY: fully-qualified library JSON data
|
|
838
843
|
excalidrawlib: "application/vnd.excalidrawlib+json",
|
|
844
|
+
// list of excalidraw library item ids
|
|
845
|
+
excalidrawlibIds: "application/vnd.excalidrawlib.ids+json"
|
|
846
|
+
};
|
|
847
|
+
var MIME_TYPES = {
|
|
848
|
+
...STRING_MIME_TYPES,
|
|
839
849
|
// image-encoded excalidraw data
|
|
840
850
|
"excalidraw.svg": "image/svg+xml",
|
|
841
851
|
"excalidraw.png": "image/png",
|
|
@@ -894,9 +904,12 @@ var DEFAULT_UI_OPTIONS = {
|
|
|
894
904
|
image: true
|
|
895
905
|
}
|
|
896
906
|
};
|
|
897
|
-
var
|
|
907
|
+
var MQ_MAX_MOBILE = 599;
|
|
898
908
|
var MQ_MAX_WIDTH_LANDSCAPE = 1e3;
|
|
899
909
|
var MQ_MAX_HEIGHT_LANDSCAPE = 500;
|
|
910
|
+
var MQ_MIN_TABLET = MQ_MAX_MOBILE + 1;
|
|
911
|
+
var MQ_MAX_TABLET = 1400;
|
|
912
|
+
var MQ_MIN_WIDTH_DESKTOP = 1440;
|
|
900
913
|
var MQ_RIGHT_SIDEBAR_MIN_WIDTH = 1229;
|
|
901
914
|
var MAX_DECIMALS_FOR_SVG_EXPORT = 2;
|
|
902
915
|
var EXPORT_SCALES = [1, 2, 3];
|
|
@@ -1017,6 +1030,7 @@ var UserIdleState = /* @__PURE__ */ ((UserIdleState2) => {
|
|
|
1017
1030
|
return UserIdleState2;
|
|
1018
1031
|
})(UserIdleState || {});
|
|
1019
1032
|
var LINE_POLYGON_POINT_MERGE_DISTANCE = 20;
|
|
1033
|
+
var DOUBLE_TAP_POSITION_THRESHOLD = 35;
|
|
1020
1034
|
|
|
1021
1035
|
// src/font-metadata.ts
|
|
1022
1036
|
init_define_import_meta_env();
|
|
@@ -1417,7 +1431,7 @@ var isInteractive = (target) => {
|
|
|
1417
1431
|
return isInputLike(target) || target instanceof Element && !!target.closest("label, button");
|
|
1418
1432
|
};
|
|
1419
1433
|
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");
|
|
1434
|
+
target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && (target.type === "text" || target.type === "number" || target.type === "password" || target.type === "search");
|
|
1421
1435
|
var getFontFamilyString = ({
|
|
1422
1436
|
fontFamily
|
|
1423
1437
|
}) => {
|
|
@@ -1434,6 +1448,9 @@ var getFontString = ({
|
|
|
1434
1448
|
}) => {
|
|
1435
1449
|
return `${fontSize}px ${getFontFamilyString({ fontFamily })}`;
|
|
1436
1450
|
};
|
|
1451
|
+
var nextAnimationFrame = async (cb) => {
|
|
1452
|
+
requestAnimationFrame(() => requestAnimationFrame(cb));
|
|
1453
|
+
};
|
|
1437
1454
|
var debounce = (fn, timeout) => {
|
|
1438
1455
|
let handle = 0;
|
|
1439
1456
|
let lastArgs = null;
|
|
@@ -2067,6 +2084,41 @@ var reduceToCommonValue = (collection, getValue) => {
|
|
|
2067
2084
|
}
|
|
2068
2085
|
return commonValue;
|
|
2069
2086
|
};
|
|
2087
|
+
var isMobileOrTablet = () => {
|
|
2088
|
+
const ua = navigator.userAgent || "";
|
|
2089
|
+
const platform = navigator.platform || "";
|
|
2090
|
+
const uaData = navigator.userAgentData;
|
|
2091
|
+
if (uaData) {
|
|
2092
|
+
const plat = (uaData.platform || "").toLowerCase();
|
|
2093
|
+
const isDesktopOS = plat === "windows" || plat === "macos" || plat === "linux" || plat === "chrome os";
|
|
2094
|
+
if (uaData.mobile === true) {
|
|
2095
|
+
return true;
|
|
2096
|
+
}
|
|
2097
|
+
if (uaData.mobile === false && plat === "android") {
|
|
2098
|
+
const looksTouchTablet = matchMedia?.("(hover: none)").matches && matchMedia?.("(pointer: coarse)").matches;
|
|
2099
|
+
return looksTouchTablet;
|
|
2100
|
+
}
|
|
2101
|
+
if (isDesktopOS) {
|
|
2102
|
+
return false;
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
if (isIOS) {
|
|
2106
|
+
return true;
|
|
2107
|
+
}
|
|
2108
|
+
if (isAndroid) {
|
|
2109
|
+
const isAndroidPhone = /Mobile/i.test(ua);
|
|
2110
|
+
const isAndroidTablet = !isAndroidPhone;
|
|
2111
|
+
if (isAndroidPhone || isAndroidTablet) {
|
|
2112
|
+
const looksTouchTablet = matchMedia?.("(hover: none)").matches && matchMedia?.("(pointer: coarse)").matches;
|
|
2113
|
+
return looksTouchTablet;
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
const looksDesktopPlatform = /Win|Linux|CrOS|Mac/.test(platform) || /Windows NT|X11|CrOS|Macintosh/.test(ua);
|
|
2117
|
+
if (looksDesktopPlatform) {
|
|
2118
|
+
return false;
|
|
2119
|
+
}
|
|
2120
|
+
return false;
|
|
2121
|
+
};
|
|
2070
2122
|
|
|
2071
2123
|
// src/random.ts
|
|
2072
2124
|
var random = new Random(Date.now());
|
|
@@ -2189,6 +2241,7 @@ export {
|
|
|
2189
2241
|
DEFAULT_UI_OPTIONS,
|
|
2190
2242
|
DEFAULT_VERSION,
|
|
2191
2243
|
DEFAULT_VERTICAL_ALIGN,
|
|
2244
|
+
DOUBLE_TAP_POSITION_THRESHOLD,
|
|
2192
2245
|
DRAGGING_THRESHOLD,
|
|
2193
2246
|
EDITOR_LS_KEYS,
|
|
2194
2247
|
ELEMENTS_PALETTE_SHADE_INDEXES,
|
|
@@ -2232,8 +2285,11 @@ export {
|
|
|
2232
2285
|
MIN_ZOOM,
|
|
2233
2286
|
MONOSPACE_GENERIC_FONT,
|
|
2234
2287
|
MQ_MAX_HEIGHT_LANDSCAPE,
|
|
2288
|
+
MQ_MAX_MOBILE,
|
|
2289
|
+
MQ_MAX_TABLET,
|
|
2235
2290
|
MQ_MAX_WIDTH_LANDSCAPE,
|
|
2236
|
-
|
|
2291
|
+
MQ_MIN_TABLET,
|
|
2292
|
+
MQ_MIN_WIDTH_DESKTOP,
|
|
2237
2293
|
MQ_RIGHT_SIDEBAR_MIN_WIDTH,
|
|
2238
2294
|
ORIG_ID,
|
|
2239
2295
|
POINTER_BUTTON,
|
|
@@ -2247,6 +2303,7 @@ export {
|
|
|
2247
2303
|
SHIFT_LOCKING_ANGLE,
|
|
2248
2304
|
SIDE_RESIZING_THRESHOLD,
|
|
2249
2305
|
STATS_PANELS,
|
|
2306
|
+
STRING_MIME_TYPES,
|
|
2250
2307
|
STROKE_WIDTH,
|
|
2251
2308
|
SVG_DOCUMENT_PREAMBLE,
|
|
2252
2309
|
SVG_NS,
|
|
@@ -2326,6 +2383,8 @@ export {
|
|
|
2326
2383
|
isLatinChar,
|
|
2327
2384
|
isLocalLink,
|
|
2328
2385
|
isMemberOf,
|
|
2386
|
+
isMobile,
|
|
2387
|
+
isMobileOrTablet,
|
|
2329
2388
|
isPrimitive,
|
|
2330
2389
|
isProdEnv,
|
|
2331
2390
|
isPromiseLike,
|
|
@@ -2345,6 +2404,7 @@ export {
|
|
|
2345
2404
|
memoize,
|
|
2346
2405
|
muteFSAbortError,
|
|
2347
2406
|
nFormatter,
|
|
2407
|
+
nextAnimationFrame,
|
|
2348
2408
|
normalizeEOL,
|
|
2349
2409
|
normalizeLink,
|
|
2350
2410
|
preventUnload,
|