@excalidraw/element 0.18.0-f0063e113 → 0.18.0-f2600fe

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 (96) hide show
  1. package/dist/dev/index.js +1098 -634
  2. package/dist/dev/index.js.map +4 -4
  3. package/dist/prod/index.js +14 -14
  4. package/dist/types/common/src/constants.d.ts +19 -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/align.d.ts +2 -1
  10. package/dist/types/element/src/bounds.d.ts +1 -1
  11. package/dist/types/element/src/delta.d.ts +16 -4
  12. package/dist/types/element/src/distribute.d.ts +2 -1
  13. package/dist/types/element/src/groups.d.ts +1 -0
  14. package/dist/types/element/src/index.d.ts +1 -0
  15. package/dist/types/element/src/linearElementEditor.d.ts +2 -1
  16. package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
  17. package/dist/types/element/src/renderElement.d.ts +4 -1
  18. package/dist/types/element/src/resizeTest.d.ts +5 -4
  19. package/dist/types/element/src/store.d.ts +8 -2
  20. package/dist/types/element/src/textElement.d.ts +1 -1
  21. package/dist/types/element/src/transformHandles.d.ts +5 -4
  22. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +21 -12
  23. package/dist/types/excalidraw/actions/actionBoundText.d.ts +14 -8
  24. package/dist/types/excalidraw/actions/actionCanvas.d.ts +94 -54
  25. package/dist/types/excalidraw/actions/actionClipboard.d.ts +45 -26
  26. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +7 -4
  27. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +25 -16
  28. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +1 -1
  29. package/dist/types/excalidraw/actions/actionElementLink.d.ts +7 -4
  30. package/dist/types/excalidraw/actions/actionElementLock.d.ts +14 -8
  31. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +7 -4
  32. package/dist/types/excalidraw/actions/actionExport.d.ts +63 -36
  33. package/dist/types/excalidraw/actions/actionFinalize.d.ts +16 -9
  34. package/dist/types/excalidraw/actions/actionFrame.d.ts +28 -16
  35. package/dist/types/excalidraw/actions/actionGroup.d.ts +14 -8
  36. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +41 -7
  37. package/dist/types/excalidraw/actions/actionLink.d.ts +5 -2
  38. package/dist/types/excalidraw/actions/actionMenu.d.ts +7 -372
  39. package/dist/types/excalidraw/actions/actionNavigate.d.ts +14 -8
  40. package/dist/types/excalidraw/actions/actionProperties.d.ts +122 -68
  41. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +7 -4
  42. package/dist/types/excalidraw/actions/actionStyles.d.ts +7 -4
  43. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +7 -4
  44. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +7 -4
  45. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +7 -4
  46. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +7 -4
  47. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +7 -4
  48. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +8 -5
  49. package/dist/types/excalidraw/actions/index.d.ts +2 -2
  50. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  51. package/dist/types/excalidraw/appState.d.ts +5 -1
  52. package/dist/types/excalidraw/clipboard.d.ts +64 -1
  53. package/dist/types/excalidraw/components/Actions.d.ts +20 -7
  54. package/dist/types/excalidraw/components/App.d.ts +29 -23
  55. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
  56. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -1
  57. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -1
  58. package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
  59. package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
  60. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +1 -1
  61. package/dist/types/excalidraw/components/FilledButton.d.ts +1 -1
  62. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
  63. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -1
  64. package/dist/types/excalidraw/components/HintViewer.d.ts +4 -3
  65. package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -1
  66. package/dist/types/excalidraw/components/LayerUI.d.ts +2 -1
  67. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
  68. package/dist/types/excalidraw/components/MobileMenu.d.ts +3 -5
  69. package/dist/types/excalidraw/components/MobileToolBar.d.ts +11 -0
  70. package/dist/types/excalidraw/components/Popover.d.ts +2 -1
  71. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
  72. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -2
  73. package/dist/types/excalidraw/components/TextField.d.ts +1 -0
  74. package/dist/types/excalidraw/components/ToolPopover.d.ts +25 -0
  75. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +3 -2
  76. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +4 -2
  77. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +2 -1
  78. package/dist/types/excalidraw/components/icons.d.ts +10 -0
  79. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +13 -1
  80. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +0 -3
  81. package/dist/types/excalidraw/components/shapes.d.ts +129 -1
  82. package/dist/types/excalidraw/data/blob.d.ts +3 -7
  83. package/dist/types/excalidraw/data/reconcile.d.ts +1 -0
  84. package/dist/types/excalidraw/data/restore.d.ts +6 -1
  85. package/dist/types/excalidraw/data/types.d.ts +4 -1
  86. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  87. package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +3 -1
  88. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
  89. package/dist/types/excalidraw/index.d.ts +4 -4
  90. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
  91. package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
  92. package/dist/types/excalidraw/scene/types.d.ts +3 -3
  93. package/dist/types/excalidraw/shortcut.d.ts +1 -0
  94. package/dist/types/excalidraw/types.d.ts +23 -19
  95. package/dist/types/math/src/segment.d.ts +1 -0
  96. package/package.json +7 -3
@@ -12,7 +12,7 @@ export { getSceneVersion, hashElementsVersion, hashString, getNonDeletedElements
12
12
  export { getTextFromElements } from "@excalidraw/element";
13
13
  export { isInvisiblySmallElement } from "@excalidraw/element";
14
14
  export { defaultLang, useI18n, languages } from "./i18n";
15
- export { restore, restoreAppState, restoreElements, restoreLibraryItems, } from "./data/restore";
15
+ export { restore, restoreAppState, restoreElement, restoreElements, restoreLibraryItems, } from "./data/restore";
16
16
  export { reconcileElements } from "./data/reconcile";
17
17
  export { exportToCanvas, exportToBlob, exportToSvg, exportToClipboard, } from "@excalidraw/utils/export";
18
18
  export { serializeAsJSON, serializeLibraryAsJSON } from "./data/json";
@@ -20,16 +20,16 @@ export { loadFromBlob, loadSceneOrLibraryFromBlob, loadLibraryFromBlob, } from "
20
20
  export { getFreeDrawSvgPath } from "@excalidraw/element";
21
21
  export { mergeLibraryItems, getLibraryItemsHash } from "./data/library";
22
22
  export { isLinearElement } from "@excalidraw/element";
23
- export { FONT_FAMILY, THEME, MIME_TYPES, ROUNDNESS, DEFAULT_LASER_COLOR, UserIdleState, normalizeLink, } from "@excalidraw/common";
23
+ export { FONT_FAMILY, THEME, MIME_TYPES, ROUNDNESS, DEFAULT_LASER_COLOR, UserIdleState, normalizeLink, sceneCoordsToViewportCoords, viewportCoordsToSceneCoords, getFormFactor, } from "@excalidraw/common";
24
24
  export { mutateElement, newElementWith, bumpVersion, } from "@excalidraw/element";
25
25
  export { CaptureUpdateAction } from "@excalidraw/element";
26
26
  export { parseLibraryTokensFromUrl, useHandleLibrary } from "./data/library";
27
- export { sceneCoordsToViewportCoords, viewportCoordsToSceneCoords, } from "@excalidraw/common";
28
27
  export { Sidebar } from "./components/Sidebar/Sidebar";
29
28
  export { Button } from "./components/Button";
30
29
  export { Footer };
31
30
  export { MainMenu };
32
- export { useDevice } from "./components/App";
31
+ export { Ellipsify } from "./components/Ellipsify";
32
+ export { useEditorInterface, useStylesPanelMode } from "./components/App";
33
33
  export { WelcomeScreen };
34
34
  export { LiveCollaborationTrigger };
35
35
  export { Stats } from "./components/Stats";
@@ -9,7 +9,7 @@ export declare const renderInteractiveSceneThrottled: {
9
9
  * Interactive scene is the ui-canvas where we render bounding boxes, selections
10
10
  * and other ui stuff.
11
11
  */
12
- export declare const renderInteractiveScene: <U extends ({ canvas, elementsMap, visibleElements, selectedElements, allElementsMap, scale, appState, renderConfig, device, }: InteractiveSceneRenderConfig) => {
12
+ export declare const renderInteractiveScene: <U extends ({ canvas, elementsMap, visibleElements, selectedElements, allElementsMap, scale, appState, renderConfig, editorInterface, }: InteractiveSceneRenderConfig) => {
13
13
  atLeastOneVisibleElement: boolean;
14
14
  elementsMap: RenderableElementsMap;
15
15
  scrollBars?: undefined;
@@ -1,4 +1,7 @@
1
- import type { StaticSceneRenderConfig } from "../scene/types";
1
+ import type { ExcalidrawFrameLikeElement } from "@excalidraw/element/types";
2
+ import type { StaticCanvasRenderConfig, StaticSceneRenderConfig } from "../scene/types";
3
+ import type { StaticCanvasAppState } from "../types";
4
+ export declare const frameClip: (frame: ExcalidrawFrameLikeElement, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState) => void;
2
5
  /** throttled to animation framerate */
3
6
  export declare const renderStaticSceneThrottled: {
4
7
  (config: StaticSceneRenderConfig): void;
@@ -1,7 +1,7 @@
1
- import type { UserIdleState } from "@excalidraw/common";
1
+ import type { UserIdleState, EditorInterface } from "@excalidraw/common";
2
2
  import type { ExcalidrawElement, NonDeletedElementsMap, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap } from "@excalidraw/element/types";
3
3
  import type { MakeBrand } from "@excalidraw/common/utility-types";
4
- import type { AppClassProperties, AppState, EmbedsValidationStatus, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState, SocketId, Device, PendingExcalidrawElements } from "../types";
4
+ import type { AppClassProperties, AppState, EmbedsValidationStatus, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState, SocketId, PendingExcalidrawElements } from "../types";
5
5
  import type { RoughCanvas } from "roughjs/bin/canvas";
6
6
  import type { Drawable } from "roughjs/bin/core";
7
7
  export type RenderableElementsMap = NonDeletedElementsMap & MakeBrand<"RenderableElementsMap">;
@@ -69,7 +69,7 @@ export type InteractiveSceneRenderConfig = {
69
69
  scale: number;
70
70
  appState: InteractiveCanvasAppState;
71
71
  renderConfig: InteractiveCanvasRenderConfig;
72
- device: Device;
72
+ editorInterface: EditorInterface;
73
73
  callback: (data: RenderInteractiveSceneCallback) => void;
74
74
  };
75
75
  export type NewElementSceneRenderConfig = {
@@ -0,0 +1 @@
1
+ export declare const getShortcutKey: (shortcut: string) => string;
@@ -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";
@@ -129,7 +129,6 @@ export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
129
129
  }>;
130
130
  export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
131
131
  activeEmbeddable: AppState["activeEmbeddable"];
132
- editingLinearElement: AppState["editingLinearElement"];
133
132
  selectionElement: AppState["selectionElement"];
134
133
  selectedGroupIds: AppState["selectedGroupIds"];
135
134
  selectedLinearElement: AppState["selectedLinearElement"];
@@ -156,8 +155,10 @@ export type ObservedElementsAppState = {
156
155
  editingGroupId: AppState["editingGroupId"];
157
156
  selectedElementIds: AppState["selectedElementIds"];
158
157
  selectedGroupIds: AppState["selectedGroupIds"];
159
- editingLinearElementId: LinearElementEditor["elementId"] | null;
160
- selectedLinearElementId: LinearElementEditor["elementId"] | null;
158
+ selectedLinearElement: {
159
+ elementId: LinearElementEditor["elementId"];
160
+ isEditing: boolean;
161
+ } | null;
161
162
  croppingElementId: AppState["croppingElementId"];
162
163
  lockedMultiSelections: AppState["lockedMultiSelections"];
163
164
  activeLockedId: AppState["activeLockedId"];
@@ -211,7 +212,6 @@ export interface AppState {
211
212
  * set when a new text is created or when an existing text is being edited
212
213
  */
213
214
  editingTextElement: NonDeletedExcalidrawElement | null;
214
- editingLinearElement: LinearElementEditor | null;
215
215
  activeTool: {
216
216
  /**
217
217
  * indicates a previous tool we should revert back to if we deselect the
@@ -221,6 +221,10 @@ export interface AppState {
221
221
  locked: boolean;
222
222
  fromSelection: boolean;
223
223
  } & ActiveTool;
224
+ preferredSelectionTool: {
225
+ type: "selection" | "lasso";
226
+ initialized: boolean;
227
+ };
224
228
  penMode: boolean;
225
229
  penDetected: boolean;
226
230
  exportBackground: boolean;
@@ -251,8 +255,8 @@ export interface AppState {
251
255
  isResizing: boolean;
252
256
  isRotating: boolean;
253
257
  zoom: Zoom;
254
- openMenu: "canvas" | "shape" | null;
255
- openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | null;
258
+ openMenu: "canvas" | null;
259
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
256
260
  openSidebar: {
257
261
  name: SidebarName;
258
262
  tab?: SidebarTabName;
@@ -441,6 +445,7 @@ export interface ExcalidrawProps {
441
445
  onDuplicate?: (nextElements: readonly ExcalidrawElement[],
442
446
  /** excludes the duplicated elements */
443
447
  prevElements: readonly ExcalidrawElement[]) => ExcalidrawElement[] | void;
448
+ renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
444
449
  renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
445
450
  langCode?: Language["code"];
446
451
  viewModeEnabled?: boolean;
@@ -498,6 +503,12 @@ export type UIOptions = Partial<{
498
503
  tools: {
499
504
  image: boolean;
500
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"];
501
512
  /** @deprecated does nothing. Will be removed in 0.15 */
502
513
  welcomeScreen?: boolean;
503
514
  }>;
@@ -528,7 +539,7 @@ export type AppClassProperties = {
528
539
  mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
529
540
  }>;
530
541
  files: BinaryFiles;
531
- device: App["device"];
542
+ editorInterface: App["editorInterface"];
532
543
  scene: App["scene"];
533
544
  syncActionResult: App["syncActionResult"];
534
545
  fonts: App["fonts"];
@@ -557,6 +568,7 @@ export type AppClassProperties = {
557
568
  excalidrawContainerValue: App["excalidrawContainerValue"];
558
569
  onPointerUpEmitter: App["onPointerUpEmitter"];
559
570
  updateEditorAtom: App["updateEditorAtom"];
571
+ onPointerDownEmitter: App["onPointerDownEmitter"];
560
572
  };
561
573
  export type PointerDownState = Readonly<{
562
574
  origin: Readonly<{
@@ -604,6 +616,7 @@ export type PointerDownState = Readonly<{
604
616
  x: number;
605
617
  y: number;
606
618
  };
619
+ blockDragging: boolean;
607
620
  };
608
621
  eventListeners: {
609
622
  onMove: null | ReturnType<typeof throttleRAF>;
@@ -618,6 +631,7 @@ export type PointerDownState = Readonly<{
618
631
  export type UnsubscribeCallback = () => void;
619
632
  export interface ExcalidrawImperativeAPI {
620
633
  updateScene: InstanceType<typeof App>["updateScene"];
634
+ applyDeltas: InstanceType<typeof App>["applyDeltas"];
621
635
  mutateElement: InstanceType<typeof App>["mutateElement"];
622
636
  updateLibrary: InstanceType<typeof Library>["updateLibrary"];
623
637
  resetScene: InstanceType<typeof App>["resetScene"];
@@ -640,6 +654,7 @@ export interface ExcalidrawImperativeAPI {
640
654
  setCursor: InstanceType<typeof App>["setCursor"];
641
655
  resetCursor: InstanceType<typeof App>["resetCursor"];
642
656
  toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
657
+ getEditorInterface: () => EditorInterface;
643
658
  /**
644
659
  * Disables rendering of frames (including element clipping), but currently
645
660
  * the frames are still interactive in edit mode. As such, this API should be
@@ -653,17 +668,6 @@ export interface ExcalidrawImperativeAPI {
653
668
  onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
654
669
  onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
655
670
  }
656
- export type Device = Readonly<{
657
- viewport: {
658
- isMobile: boolean;
659
- isLandscape: boolean;
660
- };
661
- editor: {
662
- isMobile: boolean;
663
- canFitSidebar: boolean;
664
- };
665
- isTouchScreen: boolean;
666
- }>;
667
671
  export type FrameNameBounds = {
668
672
  x: number;
669
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/element",
3
- "version": "0.18.0-f0063e113",
3
+ "version": "0.18.0-f2600fe",
4
4
  "type": "module",
5
5
  "types": "./dist/types/element/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -13,7 +13,10 @@
13
13
  "default": "./dist/prod/index.js"
14
14
  },
15
15
  "./*": {
16
- "types": "./dist/types/element/src/*.d.ts"
16
+ "types": "./dist/types/element/src/*.d.ts",
17
+ "development": "./dist/dev/index.js",
18
+ "production": "./dist/prod/index.js",
19
+ "default": "./dist/prod/index.js"
17
20
  }
18
21
  },
19
22
  "files": [
@@ -54,6 +57,7 @@
54
57
  "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
55
58
  },
56
59
  "dependencies": {
57
- "@excalidraw/common": "0.18.0-f0063e113"
60
+ "@excalidraw/common": "0.18.0-f2600fe",
61
+ "@excalidraw/math": "0.18.0-f2600fe"
58
62
  }
59
63
  }