@excalidraw/math 0.18.0-c65b684e9 → 0.18.0-d1f3982

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 (88) hide show
  1. package/dist/dev/index.js +58 -61
  2. package/dist/dev/index.js.map +3 -3
  3. package/dist/prod/index.js +1 -1
  4. package/dist/types/common/src/constants.d.ts +18 -15
  5. package/dist/types/common/src/editorInterface.d.ts +34 -0
  6. package/dist/types/common/src/index.d.ts +1 -0
  7. package/dist/types/common/src/utils.d.ts +2 -1
  8. package/dist/types/element/src/Scene.d.ts +6 -2
  9. package/dist/types/element/src/bounds.d.ts +1 -1
  10. package/dist/types/element/src/delta.d.ts +6 -4
  11. package/dist/types/element/src/index.d.ts +1 -0
  12. package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
  13. package/dist/types/element/src/renderElement.d.ts +4 -1
  14. package/dist/types/element/src/resizeTest.d.ts +5 -4
  15. package/dist/types/element/src/store.d.ts +6 -1
  16. package/dist/types/element/src/textElement.d.ts +1 -1
  17. package/dist/types/element/src/transformHandles.d.ts +5 -4
  18. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +21 -9
  19. package/dist/types/excalidraw/actions/actionBoundText.d.ts +14 -6
  20. package/dist/types/excalidraw/actions/actionCanvas.d.ts +94 -54
  21. package/dist/types/excalidraw/actions/actionClipboard.d.ts +42 -18
  22. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +7 -3
  23. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +22 -10
  24. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +1 -1
  25. package/dist/types/excalidraw/actions/actionElementLink.d.ts +7 -3
  26. package/dist/types/excalidraw/actions/actionElementLock.d.ts +14 -6
  27. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +7 -3
  28. package/dist/types/excalidraw/actions/actionExport.d.ts +63 -27
  29. package/dist/types/excalidraw/actions/actionFinalize.d.ts +14 -6
  30. package/dist/types/excalidraw/actions/actionFrame.d.ts +28 -12
  31. package/dist/types/excalidraw/actions/actionGroup.d.ts +14 -6
  32. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +8 -4
  33. package/dist/types/excalidraw/actions/actionLink.d.ts +5 -1
  34. package/dist/types/excalidraw/actions/actionMenu.d.ts +7 -369
  35. package/dist/types/excalidraw/actions/actionNavigate.d.ts +14 -6
  36. package/dist/types/excalidraw/actions/actionProperties.d.ts +122 -53
  37. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +7 -3
  38. package/dist/types/excalidraw/actions/actionStyles.d.ts +7 -3
  39. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +7 -3
  40. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +7 -3
  41. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +7 -3
  42. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +7 -3
  43. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +7 -3
  44. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +7 -3
  45. package/dist/types/excalidraw/actions/index.d.ts +2 -2
  46. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  47. package/dist/types/excalidraw/appState.d.ts +5 -1
  48. package/dist/types/excalidraw/clipboard.d.ts +64 -1
  49. package/dist/types/excalidraw/components/Actions.d.ts +17 -3
  50. package/dist/types/excalidraw/components/App.d.ts +28 -23
  51. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
  52. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -1
  53. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -1
  54. package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
  55. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +1 -1
  56. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
  57. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -1
  58. package/dist/types/excalidraw/components/HintViewer.d.ts +4 -3
  59. package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -1
  60. package/dist/types/excalidraw/components/LayerUI.d.ts +2 -1
  61. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
  62. package/dist/types/excalidraw/components/MobileMenu.d.ts +3 -5
  63. package/dist/types/excalidraw/components/MobileToolBar.d.ts +11 -0
  64. package/dist/types/excalidraw/components/Popover.d.ts +2 -1
  65. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
  66. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -2
  67. package/dist/types/excalidraw/components/TextField.d.ts +1 -0
  68. package/dist/types/excalidraw/components/ToolPopover.d.ts +25 -0
  69. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +3 -2
  70. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +4 -2
  71. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +2 -1
  72. package/dist/types/excalidraw/components/icons.d.ts +5 -0
  73. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +13 -1
  74. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +0 -3
  75. package/dist/types/excalidraw/components/shapes.d.ts +129 -1
  76. package/dist/types/excalidraw/data/blob.d.ts +3 -7
  77. package/dist/types/excalidraw/data/reconcile.d.ts +1 -0
  78. package/dist/types/excalidraw/data/restore.d.ts +6 -1
  79. package/dist/types/excalidraw/data/types.d.ts +4 -1
  80. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  81. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
  82. package/dist/types/excalidraw/index.d.ts +3 -4
  83. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
  84. package/dist/types/excalidraw/scene/types.d.ts +3 -3
  85. package/dist/types/excalidraw/shortcut.d.ts +1 -0
  86. package/dist/types/excalidraw/types.d.ts +23 -17
  87. package/dist/types/math/src/segment.d.ts +1 -0
  88. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES } from "@excalidraw/common";
1
+ import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface } from "@excalidraw/common";
2
2
  import type { SuggestedBinding } from "@excalidraw/element";
3
3
  import type { LinearElementEditor } from "@excalidraw/element";
4
4
  import type { MaybeTransformHandleType } from "@excalidraw/element";
@@ -155,8 +155,10 @@ export type ObservedElementsAppState = {
155
155
  editingGroupId: AppState["editingGroupId"];
156
156
  selectedElementIds: AppState["selectedElementIds"];
157
157
  selectedGroupIds: AppState["selectedGroupIds"];
158
- selectedLinearElementId: LinearElementEditor["elementId"] | null;
159
- selectedLinearElementIsEditing: boolean | null;
158
+ selectedLinearElement: {
159
+ elementId: LinearElementEditor["elementId"];
160
+ isEditing: boolean;
161
+ } | null;
160
162
  croppingElementId: AppState["croppingElementId"];
161
163
  lockedMultiSelections: AppState["lockedMultiSelections"];
162
164
  activeLockedId: AppState["activeLockedId"];
@@ -219,6 +221,10 @@ export interface AppState {
219
221
  locked: boolean;
220
222
  fromSelection: boolean;
221
223
  } & ActiveTool;
224
+ preferredSelectionTool: {
225
+ type: "selection" | "lasso";
226
+ initialized: boolean;
227
+ };
222
228
  penMode: boolean;
223
229
  penDetected: boolean;
224
230
  exportBackground: boolean;
@@ -249,8 +255,8 @@ export interface AppState {
249
255
  isResizing: boolean;
250
256
  isRotating: boolean;
251
257
  zoom: Zoom;
252
- openMenu: "canvas" | "shape" | null;
253
- openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | null;
258
+ openMenu: "canvas" | null;
259
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
254
260
  openSidebar: {
255
261
  name: SidebarName;
256
262
  tab?: SidebarTabName;
@@ -439,6 +445,7 @@ export interface ExcalidrawProps {
439
445
  onDuplicate?: (nextElements: readonly ExcalidrawElement[],
440
446
  /** excludes the duplicated elements */
441
447
  prevElements: readonly ExcalidrawElement[]) => ExcalidrawElement[] | void;
448
+ renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
442
449
  renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
443
450
  langCode?: Language["code"];
444
451
  viewModeEnabled?: boolean;
@@ -496,6 +503,12 @@ export type UIOptions = Partial<{
496
503
  tools: {
497
504
  image: boolean;
498
505
  };
506
+ /**
507
+ * Optionally control the editor form factor and desktop UI mode from the host app.
508
+ * If not provided, we will take care of it internally.
509
+ */
510
+ formFactor?: EditorInterface["formFactor"];
511
+ desktopUIMode?: EditorInterface["desktopUIMode"];
499
512
  /** @deprecated does nothing. Will be removed in 0.15 */
500
513
  welcomeScreen?: boolean;
501
514
  }>;
@@ -526,7 +539,7 @@ export type AppClassProperties = {
526
539
  mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
527
540
  }>;
528
541
  files: BinaryFiles;
529
- device: App["device"];
542
+ editorInterface: App["editorInterface"];
530
543
  scene: App["scene"];
531
544
  syncActionResult: App["syncActionResult"];
532
545
  fonts: App["fonts"];
@@ -555,6 +568,7 @@ export type AppClassProperties = {
555
568
  excalidrawContainerValue: App["excalidrawContainerValue"];
556
569
  onPointerUpEmitter: App["onPointerUpEmitter"];
557
570
  updateEditorAtom: App["updateEditorAtom"];
571
+ onPointerDownEmitter: App["onPointerDownEmitter"];
558
572
  };
559
573
  export type PointerDownState = Readonly<{
560
574
  origin: Readonly<{
@@ -602,6 +616,7 @@ export type PointerDownState = Readonly<{
602
616
  x: number;
603
617
  y: number;
604
618
  };
619
+ blockDragging: boolean;
605
620
  };
606
621
  eventListeners: {
607
622
  onMove: null | ReturnType<typeof throttleRAF>;
@@ -616,6 +631,7 @@ export type PointerDownState = Readonly<{
616
631
  export type UnsubscribeCallback = () => void;
617
632
  export interface ExcalidrawImperativeAPI {
618
633
  updateScene: InstanceType<typeof App>["updateScene"];
634
+ applyDeltas: InstanceType<typeof App>["applyDeltas"];
619
635
  mutateElement: InstanceType<typeof App>["mutateElement"];
620
636
  updateLibrary: InstanceType<typeof Library>["updateLibrary"];
621
637
  resetScene: InstanceType<typeof App>["resetScene"];
@@ -638,6 +654,7 @@ export interface ExcalidrawImperativeAPI {
638
654
  setCursor: InstanceType<typeof App>["setCursor"];
639
655
  resetCursor: InstanceType<typeof App>["resetCursor"];
640
656
  toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
657
+ getEditorInterface: () => EditorInterface;
641
658
  /**
642
659
  * Disables rendering of frames (including element clipping), but currently
643
660
  * the frames are still interactive in edit mode. As such, this API should be
@@ -651,17 +668,6 @@ export interface ExcalidrawImperativeAPI {
651
668
  onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
652
669
  onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
653
670
  }
654
- export type Device = Readonly<{
655
- viewport: {
656
- isMobile: boolean;
657
- isLandscape: boolean;
658
- };
659
- editor: {
660
- isMobile: boolean;
661
- canFitSidebar: boolean;
662
- };
663
- isTouchScreen: boolean;
664
- }>;
665
671
  export type FrameNameBounds = {
666
672
  x: number;
667
673
  y: number;
@@ -37,3 +37,4 @@ export declare const distanceToLineSegment: <Point extends GlobalPoint | LocalPo
37
37
  * @returns
38
38
  */
39
39
  export declare function lineSegmentIntersectionPoints<Point extends GlobalPoint | LocalPoint>(l: LineSegment<Point>, s: LineSegment<Point>, threshold?: number): Point | null;
40
+ export declare function lineSegmentsDistance<Point extends GlobalPoint | LocalPoint>(s1: LineSegment<Point>, s2: LineSegment<Point>): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excalidraw/math",
3
- "version": "0.18.0-c65b684e9",
3
+ "version": "0.18.0-d1f3982",
4
4
  "type": "module",
5
5
  "types": "./dist/types/math/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -61,6 +61,6 @@
61
61
  "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
62
62
  },
63
63
  "dependencies": {
64
- "@excalidraw/common": "0.18.0-c65b684e9"
64
+ "@excalidraw/common": "0.18.0-d1f3982"
65
65
  }
66
66
  }