@excalidraw/common 0.18.0-3bdaafe → 0.18.0-4e0441e

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.
Files changed (68) hide show
  1. package/dist/dev/index.js +82 -32
  2. package/dist/dev/index.js.map +2 -2
  3. package/dist/prod/index.js +3 -3
  4. package/dist/types/common/src/constants.d.ts +21 -4
  5. package/dist/types/common/src/utils.d.ts +3 -1
  6. package/dist/types/element/src/renderElement.d.ts +4 -1
  7. package/dist/types/element/src/transformHandles.d.ts +1 -1
  8. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +21 -6
  9. package/dist/types/excalidraw/actions/actionBoundText.d.ts +14 -4
  10. package/dist/types/excalidraw/actions/actionCanvas.d.ts +92 -40
  11. package/dist/types/excalidraw/actions/actionClipboard.d.ts +42 -12
  12. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +7 -2
  13. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +21 -6
  14. package/dist/types/excalidraw/actions/actionElementLink.d.ts +7 -2
  15. package/dist/types/excalidraw/actions/actionElementLock.d.ts +14 -4
  16. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +7 -2
  17. package/dist/types/excalidraw/actions/actionExport.d.ts +63 -18
  18. package/dist/types/excalidraw/actions/actionFinalize.d.ts +14 -4
  19. package/dist/types/excalidraw/actions/actionFrame.d.ts +28 -8
  20. package/dist/types/excalidraw/actions/actionGroup.d.ts +14 -4
  21. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +8 -3
  22. package/dist/types/excalidraw/actions/actionLink.d.ts +6 -1
  23. package/dist/types/excalidraw/actions/actionMenu.d.ts +7 -368
  24. package/dist/types/excalidraw/actions/actionNavigate.d.ts +14 -4
  25. package/dist/types/excalidraw/actions/actionProperties.d.ts +122 -38
  26. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +7 -2
  27. package/dist/types/excalidraw/actions/actionStyles.d.ts +7 -2
  28. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +7 -2
  29. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +7 -2
  30. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +7 -2
  31. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +7 -2
  32. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +7 -2
  33. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +7 -2
  34. package/dist/types/excalidraw/actions/index.d.ts +2 -2
  35. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  36. package/dist/types/excalidraw/appState.d.ts +5 -1
  37. package/dist/types/excalidraw/clipboard.d.ts +63 -1
  38. package/dist/types/excalidraw/components/Actions.d.ts +17 -3
  39. package/dist/types/excalidraw/components/App.d.ts +1 -2
  40. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +1 -0
  41. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
  42. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -1
  43. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -1
  44. package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
  45. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +1 -1
  46. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
  47. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -1
  48. package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -1
  49. package/dist/types/excalidraw/components/LayerUI.d.ts +2 -1
  50. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
  51. package/dist/types/excalidraw/components/MobileMenu.d.ts +3 -5
  52. package/dist/types/excalidraw/components/MobileToolBar.d.ts +11 -0
  53. package/dist/types/excalidraw/components/Popover.d.ts +2 -1
  54. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
  55. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -2
  56. package/dist/types/excalidraw/components/TextField.d.ts +1 -0
  57. package/dist/types/excalidraw/components/ToolPopover.d.ts +25 -0
  58. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +4 -2
  59. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +2 -1
  60. package/dist/types/excalidraw/components/icons.d.ts +5 -0
  61. package/dist/types/excalidraw/data/blob.d.ts +2 -9
  62. package/dist/types/excalidraw/data/types.d.ts +4 -1
  63. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  64. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
  65. package/dist/types/excalidraw/shortcut.d.ts +1 -0
  66. package/dist/types/excalidraw/types.d.ts +10 -3
  67. package/dist/types/math/src/segment.d.ts +1 -0
  68. 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 (this.scoreFunction(node) < this.scoreFunction(parent)) {
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 child2N = idx + 1 << 1;
302
- const child1N = child2N - 1;
303
- let swap = null;
304
- let child1Score = 0;
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 child1 = this.content[child1N];
307
- child1Score = this.scoreFunction(child1);
308
- if (child1Score < score) {
309
- swap = child1N;
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 child2 = this.content[child2N];
314
- const child2Score = this.scoreFunction(child2);
315
- if (child2Score < (swap === null ? score : child1Score)) {
316
- swap = child2N;
314
+ const child2Score = this.scoreFunction(this.content[child2N]);
315
+ if (child2Score < smallestScore) {
316
+ smallestIdx = child2N;
317
317
  }
318
318
  }
319
- if (swap !== null) {
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);
@@ -734,10 +733,12 @@ var ENV = {
734
733
  PRODUCTION: "production"
735
734
  };
736
735
  var CLASSES = {
736
+ SIDEBAR: "sidebar",
737
737
  SHAPE_ACTIONS_MENU: "App-menu__left",
738
738
  ZOOM_ACTIONS: "zoom-actions",
739
739
  SEARCH_MENU_INPUT_WRAPPER: "layer-ui__search-inputWrapper",
740
- CONVERT_ELEMENT_TYPE_POPUP: "ConvertElementTypePopup"
740
+ CONVERT_ELEMENT_TYPE_POPUP: "ConvertElementTypePopup",
741
+ SHAPE_ACTIONS_THEME_SCOPE: "shape-actions-theme-scope"
741
742
  };
742
743
  var CJK_HAND_DRAWN_FALLBACK_FONT = "Xiaolai";
743
744
  var WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
@@ -832,13 +833,19 @@ var IMAGE_MIME_TYPES = {
832
833
  avif: "image/avif",
833
834
  jfif: "image/jfif"
834
835
  };
835
- var MIME_TYPES = {
836
+ var STRING_MIME_TYPES = {
836
837
  text: "text/plain",
837
838
  html: "text/html",
838
839
  json: "application/json",
839
840
  // excalidraw data
840
841
  excalidraw: "application/vnd.excalidraw+json",
842
+ // LEGACY: fully-qualified library JSON data
841
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,
842
849
  // image-encoded excalidraw data
843
850
  "excalidraw.svg": "image/svg+xml",
844
851
  "excalidraw.png": "image/png",
@@ -897,9 +904,12 @@ var DEFAULT_UI_OPTIONS = {
897
904
  image: true
898
905
  }
899
906
  };
900
- var MQ_MAX_WIDTH_PORTRAIT = 730;
907
+ var MQ_MAX_MOBILE = 599;
901
908
  var MQ_MAX_WIDTH_LANDSCAPE = 1e3;
902
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;
903
913
  var MQ_RIGHT_SIDEBAR_MIN_WIDTH = 1229;
904
914
  var MAX_DECIMALS_FOR_SVG_EXPORT = 2;
905
915
  var EXPORT_SCALES = [1, 2, 3];
@@ -1021,6 +1031,9 @@ var UserIdleState = /* @__PURE__ */ ((UserIdleState2) => {
1021
1031
  })(UserIdleState || {});
1022
1032
  var LINE_POLYGON_POINT_MERGE_DISTANCE = 20;
1023
1033
  var DOUBLE_TAP_POSITION_THRESHOLD = 35;
1034
+ var MOBILE_ACTION_BUTTON_BG = {
1035
+ background: "var(--mobile-action-button-bg)"
1036
+ };
1024
1037
 
1025
1038
  // src/font-metadata.ts
1026
1039
  init_define_import_meta_env();
@@ -1421,7 +1434,7 @@ var isInteractive = (target) => {
1421
1434
  return isInputLike(target) || target instanceof Element && !!target.closest("label, button");
1422
1435
  };
1423
1436
  var isWritableElement = (target) => target instanceof HTMLElement && target.dataset.type === "wysiwyg" || target instanceof HTMLBRElement || // newline in wysiwyg
1424
- target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && (target.type === "text" || target.type === "number" || target.type === "password");
1437
+ target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && (target.type === "text" || target.type === "number" || target.type === "password" || target.type === "search");
1425
1438
  var getFontFamilyString = ({
1426
1439
  fontFamily
1427
1440
  }) => {
@@ -1438,6 +1451,9 @@ var getFontString = ({
1438
1451
  }) => {
1439
1452
  return `${fontSize}px ${getFontFamilyString({ fontFamily })}`;
1440
1453
  };
1454
+ var nextAnimationFrame = async (cb) => {
1455
+ requestAnimationFrame(() => requestAnimationFrame(cb));
1456
+ };
1441
1457
  var debounce = (fn, timeout) => {
1442
1458
  let handle = 0;
1443
1459
  let lastArgs = null;
@@ -1623,13 +1639,6 @@ var updateActiveTool = (appState, data) => {
1623
1639
  var isFullScreen = () => document.fullscreenElement?.nodeName === "HTML";
1624
1640
  var allowFullScreen = () => document.documentElement.requestFullscreen();
1625
1641
  var exitFullScreen = () => document.exitFullscreen();
1626
- var getShortcutKey = (shortcut) => {
1627
- shortcut = shortcut.replace(/\bAlt\b/i, "Alt").replace(/\bShift\b/i, "Shift").replace(/\b(Enter|Return)\b/i, "Enter");
1628
- if (isDarwin) {
1629
- return shortcut.replace(/\bCtrlOrCmd\b/gi, "Cmd").replace(/\bAlt\b/i, "Option");
1630
- }
1631
- return shortcut.replace(/\bCtrlOrCmd\b/gi, "Ctrl");
1632
- };
1633
1642
  var viewportCoordsToSceneCoords = ({ clientX, clientY }, {
1634
1643
  zoom,
1635
1644
  offsetLeft,
@@ -2071,6 +2080,41 @@ var reduceToCommonValue = (collection, getValue) => {
2071
2080
  }
2072
2081
  return commonValue;
2073
2082
  };
2083
+ var isMobileOrTablet = () => {
2084
+ const ua = navigator.userAgent || "";
2085
+ const platform = navigator.platform || "";
2086
+ const uaData = navigator.userAgentData;
2087
+ if (uaData) {
2088
+ const plat = (uaData.platform || "").toLowerCase();
2089
+ const isDesktopOS = plat === "windows" || plat === "macos" || plat === "linux" || plat === "chrome os";
2090
+ if (uaData.mobile === true) {
2091
+ return true;
2092
+ }
2093
+ if (uaData.mobile === false && plat === "android") {
2094
+ const looksTouchTablet = matchMedia?.("(hover: none)").matches && matchMedia?.("(pointer: coarse)").matches;
2095
+ return looksTouchTablet;
2096
+ }
2097
+ if (isDesktopOS) {
2098
+ return false;
2099
+ }
2100
+ }
2101
+ if (isIOS) {
2102
+ return true;
2103
+ }
2104
+ if (isAndroid) {
2105
+ const isAndroidPhone = /Mobile/i.test(ua);
2106
+ const isAndroidTablet = !isAndroidPhone;
2107
+ if (isAndroidPhone || isAndroidTablet) {
2108
+ const looksTouchTablet = matchMedia?.("(hover: none)").matches && matchMedia?.("(pointer: coarse)").matches;
2109
+ return looksTouchTablet;
2110
+ }
2111
+ }
2112
+ const looksDesktopPlatform = /Win|Linux|CrOS|Mac/.test(platform) || /Windows NT|X11|CrOS|Macintosh/.test(ua);
2113
+ if (looksDesktopPlatform) {
2114
+ return false;
2115
+ }
2116
+ return false;
2117
+ };
2074
2118
 
2075
2119
  // src/random.ts
2076
2120
  var random = new Random(Date.now());
@@ -2235,10 +2279,14 @@ export {
2235
2279
  MIN_FONT_SIZE,
2236
2280
  MIN_WIDTH_OR_HEIGHT,
2237
2281
  MIN_ZOOM,
2282
+ MOBILE_ACTION_BUTTON_BG,
2238
2283
  MONOSPACE_GENERIC_FONT,
2239
2284
  MQ_MAX_HEIGHT_LANDSCAPE,
2285
+ MQ_MAX_MOBILE,
2286
+ MQ_MAX_TABLET,
2240
2287
  MQ_MAX_WIDTH_LANDSCAPE,
2241
- MQ_MAX_WIDTH_PORTRAIT,
2288
+ MQ_MIN_TABLET,
2289
+ MQ_MIN_WIDTH_DESKTOP,
2242
2290
  MQ_RIGHT_SIDEBAR_MIN_WIDTH,
2243
2291
  ORIG_ID,
2244
2292
  POINTER_BUTTON,
@@ -2252,6 +2300,7 @@ export {
2252
2300
  SHIFT_LOCKING_ANGLE,
2253
2301
  SIDE_RESIZING_THRESHOLD,
2254
2302
  STATS_PANELS,
2303
+ STRING_MIME_TYPES,
2255
2304
  STROKE_WIDTH,
2256
2305
  SVG_DOCUMENT_PREAMBLE,
2257
2306
  SVG_NS,
@@ -2307,7 +2356,6 @@ export {
2307
2356
  getGridPoint,
2308
2357
  getLineHeight,
2309
2358
  getNearestScrollableContainer,
2310
- getShortcutKey,
2311
2359
  getSizeFromPoints,
2312
2360
  getSpecificColorShades,
2313
2361
  getSvgPathFromStroke,
@@ -2332,6 +2380,7 @@ export {
2332
2380
  isLocalLink,
2333
2381
  isMemberOf,
2334
2382
  isMobile,
2383
+ isMobileOrTablet,
2335
2384
  isPrimitive,
2336
2385
  isProdEnv,
2337
2386
  isPromiseLike,
@@ -2351,6 +2400,7 @@ export {
2351
2400
  memoize,
2352
2401
  muteFSAbortError,
2353
2402
  nFormatter,
2403
+ nextAnimationFrame,
2354
2404
  normalizeEOL,
2355
2405
  normalizeLink,
2356
2406
  preventUnload,