@dwelle/excalidraw 0.5.0-8cb033d → 0.5.0-90f2d4e

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 (141) hide show
  1. package/dist/dev/{chunk-C6WW3IWU.js → chunk-BIYCCCC4.js} +14 -4
  2. package/dist/dev/chunk-BIYCCCC4.js.map +7 -0
  3. package/dist/dev/chunk-QW2KPMGE.js +7 -0
  4. package/dist/dev/chunk-QW2KPMGE.js.map +7 -0
  5. package/dist/dev/{chunk-2LNRWI74.js → chunk-VPDGV5DO.js} +9679 -8756
  6. package/dist/dev/chunk-VPDGV5DO.js.map +7 -0
  7. package/dist/dev/data/{image-7QZI7GM4.js → image-RC4Z3PZK.js} +3 -3
  8. package/dist/dev/index.css +695 -506
  9. package/dist/dev/index.css.map +3 -3
  10. package/dist/dev/index.js +4223 -2821
  11. package/dist/dev/index.js.map +4 -4
  12. package/dist/dev/locales/{en-VFJV7E2V.js → en-XLJO5VTH.js} +2 -2
  13. package/dist/dev/subset-shared.chunk.js +1 -1
  14. package/dist/dev/subset-worker.chunk.js +1 -1
  15. package/dist/prod/chunk-DUG5AXRR.js +33 -0
  16. package/dist/prod/chunk-M2OFWNPH.js +7 -0
  17. package/dist/prod/{chunk-O65DDAOS.js → chunk-SPUFWQ3U.js} +4 -4
  18. package/dist/prod/data/image-W7J67QSB.js +1 -0
  19. package/dist/prod/index.css +1 -1
  20. package/dist/prod/index.js +20 -20
  21. package/dist/prod/locales/{en-UUHXMMMY.js → en-DMU2KFKH.js} +1 -1
  22. package/dist/prod/subset-shared.chunk.js +1 -1
  23. package/dist/prod/subset-worker.chunk.js +1 -1
  24. package/dist/types/common/src/constants.d.ts +38 -6
  25. package/dist/types/common/src/utils.d.ts +6 -5
  26. package/dist/types/element/src/Scene.d.ts +7 -3
  27. package/dist/types/element/src/align.d.ts +2 -1
  28. package/dist/types/element/src/binding.d.ts +10 -7
  29. package/dist/types/element/src/bounds.d.ts +12 -4
  30. package/dist/types/element/src/collision.d.ts +18 -12
  31. package/dist/types/element/src/cropElement.d.ts +1 -1
  32. package/dist/types/element/src/delta.d.ts +41 -9
  33. package/dist/types/element/src/distance.d.ts +2 -2
  34. package/dist/types/element/src/distribute.d.ts +2 -1
  35. package/dist/types/element/src/fractionalIndex.d.ts +8 -2
  36. package/dist/types/element/src/frame.d.ts +2 -2
  37. package/dist/types/element/src/groups.d.ts +1 -0
  38. package/dist/types/element/src/index.d.ts +2 -3
  39. package/dist/types/element/src/linearElementEditor.d.ts +13 -15
  40. package/dist/types/element/src/mutateElement.d.ts +1 -1
  41. package/dist/types/element/src/newElement.d.ts +2 -1
  42. package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
  43. package/dist/types/element/src/renderElement.d.ts +4 -1
  44. package/dist/types/element/src/resizeElements.d.ts +1 -0
  45. package/dist/types/element/src/selection.d.ts +1 -1
  46. package/dist/types/element/src/shape.d.ts +42 -0
  47. package/dist/types/element/src/sizeHelpers.d.ts +2 -1
  48. package/dist/types/element/src/store.d.ts +19 -9
  49. package/dist/types/element/src/textElement.d.ts +1 -1
  50. package/dist/types/element/src/transformHandles.d.ts +4 -4
  51. package/dist/types/element/src/typeChecks.d.ts +15 -1
  52. package/dist/types/element/src/types.d.ts +8 -3
  53. package/dist/types/element/src/utils.d.ts +16 -6
  54. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +15 -18
  55. package/dist/types/excalidraw/actions/actionAlign.d.ts +8 -8
  56. package/dist/types/excalidraw/actions/actionBoundText.d.ts +10 -12
  57. package/dist/types/excalidraw/actions/actionCanvas.d.ts +158 -170
  58. package/dist/types/excalidraw/actions/actionClipboard.d.ts +38 -42
  59. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +5 -6
  60. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +21 -23
  61. package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -4
  62. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
  63. package/dist/types/excalidraw/actions/actionElementLink.d.ts +4 -5
  64. package/dist/types/excalidraw/actions/actionElementLock.d.ts +12 -14
  65. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +5 -6
  66. package/dist/types/excalidraw/actions/actionExport.d.ts +130 -139
  67. package/dist/types/excalidraw/actions/actionFinalize.d.ts +61 -22
  68. package/dist/types/excalidraw/actions/actionFlip.d.ts +4 -4
  69. package/dist/types/excalidraw/actions/actionFrame.d.ts +70 -74
  70. package/dist/types/excalidraw/actions/actionGroup.d.ts +16 -18
  71. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +532 -9
  72. package/dist/types/excalidraw/actions/actionLink.d.ts +6 -7
  73. package/dist/types/excalidraw/actions/actionMenu.d.ts +16 -19
  74. package/dist/types/excalidraw/actions/actionNavigate.d.ts +10 -12
  75. package/dist/types/excalidraw/actions/actionProperties.d.ts +107 -105
  76. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +8 -9
  77. package/dist/types/excalidraw/actions/actionStyles.d.ts +9 -10
  78. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +7 -8
  79. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +7 -8
  80. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +6 -7
  81. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +7 -8
  82. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +7 -8
  83. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +7 -8
  84. package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
  85. package/dist/types/excalidraw/actions/index.d.ts +1 -1
  86. package/dist/types/excalidraw/actions/types.d.ts +2 -1
  87. package/dist/types/excalidraw/appState.d.ts +21 -20
  88. package/dist/types/excalidraw/clipboard.d.ts +64 -1
  89. package/dist/types/excalidraw/components/Actions.d.ts +8 -5
  90. package/dist/types/excalidraw/components/App.d.ts +21 -27
  91. package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
  92. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +2 -1
  93. package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
  94. package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
  95. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
  96. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +2 -1
  97. package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -1
  98. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
  99. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
  100. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +11 -1
  101. package/dist/types/excalidraw/components/TextField.d.ts +1 -0
  102. package/dist/types/excalidraw/components/icons.d.ts +7 -0
  103. package/dist/types/excalidraw/components/shapes.d.ts +129 -1
  104. package/dist/types/excalidraw/data/blob.d.ts +4 -8
  105. package/dist/types/excalidraw/data/reconcile.d.ts +1 -0
  106. package/dist/types/excalidraw/data/restore.d.ts +6 -1
  107. package/dist/types/excalidraw/data/types.d.ts +4 -1
  108. package/dist/types/excalidraw/eraser/index.d.ts +0 -2
  109. package/dist/types/excalidraw/history.d.ts +21 -5
  110. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  111. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
  112. package/dist/types/excalidraw/index.d.ts +2 -1
  113. package/dist/types/excalidraw/lasso/utils.d.ts +2 -1
  114. package/dist/types/excalidraw/renderer/helpers.d.ts +4 -4
  115. package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
  116. package/dist/types/excalidraw/scene/Renderer.d.ts +0 -1
  117. package/dist/types/excalidraw/types.d.ts +12 -9
  118. package/dist/types/math/src/angle.d.ts +2 -0
  119. package/dist/types/math/src/constants.d.ts +3 -0
  120. package/dist/types/math/src/curve.d.ts +32 -0
  121. package/dist/types/math/src/index.d.ts +1 -0
  122. package/dist/types/math/src/point.d.ts +1 -1
  123. package/dist/types/math/src/rectangle.d.ts +2 -0
  124. package/dist/types/math/src/segment.d.ts +1 -0
  125. package/dist/types/math/src/vector.d.ts +4 -2
  126. package/history.ts +107 -44
  127. package/package.json +9 -9
  128. package/dist/dev/chunk-2LNRWI74.js.map +0 -7
  129. package/dist/dev/chunk-C6WW3IWU.js.map +0 -7
  130. package/dist/dev/chunk-NR24AOHB.js +0 -7
  131. package/dist/dev/chunk-NR24AOHB.js.map +0 -7
  132. package/dist/prod/chunk-JUZ2P6ZK.js +0 -33
  133. package/dist/prod/chunk-ZSOIT5RG.js +0 -7
  134. package/dist/prod/data/image-RPTD4VCP.js +0 -1
  135. package/dist/types/element/src/Shape.d.ts +0 -17
  136. package/dist/types/element/src/ShapeCache.d.ts +0 -25
  137. package/dist/types/element/src/shapes.d.ts +0 -23
  138. package/dist/types/excalidraw/visualdebug.d.ts +0 -41
  139. package/dist/types/utils/src/collision.d.ts +0 -8
  140. /package/dist/dev/data/{image-7QZI7GM4.js.map → image-RC4Z3PZK.js.map} +0 -0
  141. /package/dist/dev/locales/{en-VFJV7E2V.js.map → en-XLJO5VTH.js.map} +0 -0
@@ -2,11 +2,11 @@ import { IMAGE_MIME_TYPES, MIME_TYPES } from "@excalidraw/common";
2
2
  import type { ValueOf } from "@excalidraw/common/utility-types";
3
3
  import type { ExcalidrawElement, FileId } from "@excalidraw/element/types";
4
4
  import type { AppState, DataURL, LibraryItem } from "../types";
5
- import type { FileSystemHandle } from "./filesystem";
5
+ import type { FileSystemHandle } from "browser-fs-access";
6
6
  import type { ImportedLibraryData } from "./types";
7
7
  export declare const getMimeType: (blob: Blob | string) => string;
8
8
  export declare const getFileHandleType: (handle: FileSystemHandle | null) => string | null;
9
- export declare const isImageFileHandleType: (type: string | null) => type is "svg" | "png";
9
+ export declare const isImageFileHandleType: (type: string | null) => type is "png" | "svg";
10
10
  export declare const isImageFileHandle: (handle: FileSystemHandle | null) => boolean;
11
11
  export declare const isSupportedImageFileType: (type: string | null | undefined) => boolean;
12
12
  export declare const isSupportedImageFile: (blob: Blob | null | undefined) => blob is Blob & {
@@ -40,12 +40,8 @@ export declare const SVGStringToFile: (SVGString: string, filename?: string) =>
40
40
  type: typeof MIME_TYPES.svg;
41
41
  };
42
42
  export declare const ImageURLToFile: (imageUrl: string, filename?: string) => Promise<File | undefined>;
43
- export declare const getFileFromEvent: (event: React.DragEvent<HTMLDivElement>) => Promise<{
44
- file: File | null;
45
- fileHandle: FileSystemHandle | null;
46
- }>;
47
- export declare const getFileHandle: (event: React.DragEvent<HTMLDivElement>) => Promise<FileSystemHandle | null>;
48
- export declare const createFile: (blob: File | Blob | ArrayBuffer, mimeType: ValueOf<typeof MIME_TYPES>, name: string | undefined) => File;
43
+ export declare const getFileHandle: (event: DragEvent | React.DragEvent | DataTransferItem) => Promise<FileSystemHandle | null>;
44
+ export declare const createFile: (blob: File | Blob | ArrayBuffer, mimeType: string, name: string | undefined) => File;
49
45
  /** attempts to detect correct mimeType if none is set, or if an image
50
46
  * has an incorrect extension.
51
47
  * Note: doesn't handle missing .excalidraw/.excalidrawlib extension */
@@ -3,4 +3,5 @@ import type { MakeBrand } from "@excalidraw/common/utility-types";
3
3
  import type { AppState } from "../types";
4
4
  export type ReconciledExcalidrawElement = OrderedExcalidrawElement & MakeBrand<"ReconciledElement">;
5
5
  export type RemoteExcalidrawElement = OrderedExcalidrawElement & MakeBrand<"RemoteExcalidrawElement">;
6
+ export declare const shouldDiscardRemoteElement: (localAppState: AppState, local: OrderedExcalidrawElement | undefined, remote: RemoteExcalidrawElement) => boolean;
6
7
  export declare const reconcileElements: (localElements: readonly OrderedExcalidrawElement[], remoteElements: readonly RemoteExcalidrawElement[], localAppState: AppState) => ReconciledExcalidrawElement[];
@@ -1,4 +1,4 @@
1
- import type { ExcalidrawElement, OrderedExcalidrawElement } from "@excalidraw/element/types";
1
+ import type { ExcalidrawArrowElement, ExcalidrawElement, ExcalidrawLinearElement, ExcalidrawSelectionElement, ExcalidrawTextElement, OrderedExcalidrawElement } from "@excalidraw/element/types";
2
2
  import type { AppState, BinaryFiles, LibraryItem } from "../types";
3
3
  import type { ImportedDataState } from "./types";
4
4
  type RestoredAppState = Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
@@ -8,14 +8,19 @@ export type RestoredDataState = {
8
8
  appState: RestoredAppState;
9
9
  files: BinaryFiles;
10
10
  };
11
+ export declare const restoreElement: (element: Exclude<ExcalidrawElement, ExcalidrawSelectionElement>, opts?: {
12
+ deleteInvisibleElements?: boolean;
13
+ }) => ExcalidrawLinearElement | import("@excalidraw/element/types").ExcalidrawRectangleElement | import("@excalidraw/element/types").ExcalidrawDiamondElement | import("@excalidraw/element/types").ExcalidrawEllipseElement | import("@excalidraw/element/types").ExcalidrawEmbeddableElement | import("@excalidraw/element/types").ExcalidrawIframeElement | import("@excalidraw/element/types").ExcalidrawImageElement | import("@excalidraw/element/types").ExcalidrawFrameElement | import("@excalidraw/element/types").ExcalidrawMagicFrameElement | ExcalidrawTextElement | import("@excalidraw/element/types").ExcalidrawFreeDrawElement | ExcalidrawArrowElement | null;
11
14
  export declare const restoreElements: (elements: ImportedDataState["elements"], localElements: readonly ExcalidrawElement[] | null | undefined, opts?: {
12
15
  refreshDimensions?: boolean;
13
16
  repairBindings?: boolean;
17
+ deleteInvisibleElements?: boolean;
14
18
  } | undefined) => OrderedExcalidrawElement[];
15
19
  export declare const restoreAppState: (appState: ImportedDataState["appState"], localAppState: Partial<AppState> | null | undefined) => RestoredAppState;
16
20
  export declare const restore: (data: Pick<ImportedDataState, "appState" | "elements" | "files"> | null, localAppState: Partial<AppState> | null | undefined, localElements: readonly ExcalidrawElement[] | null | undefined, elementsConfig?: {
17
21
  refreshDimensions?: boolean;
18
22
  repairBindings?: boolean;
23
+ deleteInvisibleElements?: boolean;
19
24
  }) => RestoredDataState;
20
25
  export declare const restoreLibraryItems: (libraryItems: ImportedDataState["libraryItems"], defaultStatus: LibraryItem["status"]) => LibraryItem[];
21
26
  export {};
@@ -1,7 +1,7 @@
1
1
  import type { VERSIONS } from "@excalidraw/common";
2
2
  import type { ExcalidrawElement } from "@excalidraw/element/types";
3
3
  import type { cleanAppStateForExport } from "../appState";
4
- import type { AppState, BinaryFiles, LibraryItems, LibraryItems_anyVersion } from "../types";
4
+ import type { AppState, BinaryFiles, LibraryItem, LibraryItems, LibraryItems_anyVersion } from "../types";
5
5
  export interface ExportedDataState {
6
6
  type: string;
7
7
  version: number;
@@ -43,3 +43,6 @@ export interface ImportedLibraryData extends Partial<ExportedLibraryData> {
43
43
  /** @deprecated v1 */
44
44
  library?: LibraryItems;
45
45
  }
46
+ export type ExcalidrawLibraryIds = {
47
+ itemIds: LibraryItem["id"][];
48
+ };
@@ -4,8 +4,6 @@ import type App from "../components/App";
4
4
  export declare class EraserTrail extends AnimatedTrail {
5
5
  private elementsToErase;
6
6
  private groupsToErase;
7
- private segmentsCache;
8
- private geometricShapesCache;
9
7
  constructor(animationFrameHandler: AnimationFrameHandler, app: App);
10
8
  startPath(x: number, y: number): void;
11
9
  addPointToPath(x: number, y: number, restore?: boolean): string[];
@@ -1,8 +1,25 @@
1
1
  import { Emitter } from "@excalidraw/common";
2
- import { StoreDelta, type Store } from "@excalidraw/element";
2
+ import { StoreDelta } from "@excalidraw/element";
3
+ import type { StoreSnapshot, Store } from "@excalidraw/element";
3
4
  import type { SceneElementsMap } from "@excalidraw/element/types";
4
5
  import type { AppState } from "./types";
5
- declare class HistoryEntry extends StoreDelta {
6
+ export declare class HistoryDelta extends StoreDelta {
7
+ /**
8
+ * Apply the delta to the passed elements and appState, does not modify the snapshot.
9
+ */
10
+ applyTo(elements: SceneElementsMap, appState: AppState, snapshot: StoreSnapshot): [SceneElementsMap, AppState, boolean];
11
+ /**
12
+ * Overriding once to avoid type casting everywhere.
13
+ */
14
+ static calculate(prevSnapshot: StoreSnapshot, nextSnapshot: StoreSnapshot): HistoryDelta;
15
+ /**
16
+ * Overriding once to avoid type casting everywhere.
17
+ */
18
+ static inverse(delta: StoreDelta): HistoryDelta;
19
+ /**
20
+ * Overriding once to avoid type casting everywhere.
21
+ */
22
+ static applyLatestChanges(delta: StoreDelta, prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): HistoryDelta;
6
23
  }
7
24
  export declare class HistoryChangedEvent {
8
25
  readonly isUndoStackEmpty: boolean;
@@ -12,8 +29,8 @@ export declare class HistoryChangedEvent {
12
29
  export declare class History {
13
30
  private readonly store;
14
31
  readonly onHistoryChangedEmitter: Emitter<[HistoryChangedEvent]>;
15
- readonly undoStack: HistoryEntry[];
16
- readonly redoStack: HistoryEntry[];
32
+ readonly undoStack: HistoryDelta[];
33
+ readonly redoStack: HistoryDelta[];
17
34
  get isUndoStackEmpty(): boolean;
18
35
  get isRedoStackEmpty(): boolean;
19
36
  constructor(store: Store);
@@ -29,4 +46,3 @@ export declare class History {
29
46
  private static pop;
30
47
  private static push;
31
48
  }
32
- export {};
@@ -3,7 +3,7 @@ export type SvgCache = Map<LibraryItem["id"], SVGSVGElement>;
3
3
  export declare const libraryItemSvgsCache: import("jotai/vanilla/atom").PrimitiveAtom<SvgCache> & {
4
4
  init: SvgCache;
5
5
  };
6
- export declare const useLibraryItemSvg: (id: LibraryItem["id"] | null, elements: LibraryItem["elements"] | undefined, svgCache: SvgCache) => SVGSVGElement | undefined;
6
+ export declare const useLibraryItemSvg: (id: LibraryItem["id"] | null, elements: LibraryItem["elements"] | undefined, svgCache: SvgCache, ref: React.RefObject<HTMLDivElement | null>) => SVGSVGElement | undefined;
7
7
  export declare const useLibraryCache: () => {
8
8
  clearLibraryCache: () => void;
9
9
  deleteItemsFromLibraryCache: (items: LibraryItem["id"][]) => void;
@@ -0,0 +1,14 @@
1
+ export type CaretPosition = {
2
+ start: number;
3
+ end: number;
4
+ };
5
+ export declare const saveCaretPosition: () => CaretPosition | null;
6
+ export declare const restoreCaretPosition: (position: CaretPosition | null) => void;
7
+ export declare const withCaretPositionPreservation: (callback: () => void, isCompactMode: boolean, isEditingText: boolean, onPreventClose?: () => void) => void;
8
+ export declare const useTextEditorFocus: () => {
9
+ saveCaretPosition: () => void;
10
+ restoreCaretPosition: () => void;
11
+ clearSavedPosition: () => void;
12
+ hasSavedPosition: boolean;
13
+ };
14
+ export declare const temporarilyDisableTextEditorBlur: (duration?: number) => void;
@@ -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 { exportToBlob, exportToSvg, exportToClipboard, } from "@excalidraw/utils/export";
18
18
  export { serializeAsJSON, serializeLibraryAsJSON } from "./data/json";
@@ -29,6 +29,7 @@ export { Sidebar } from "./components/Sidebar/Sidebar";
29
29
  export { Button } from "./components/Button";
30
30
  export { Footer };
31
31
  export { MainMenu };
32
+ export { Ellipsify } from "./components/Ellipsify";
32
33
  export { useDevice } from "./components/App";
33
34
  export { WelcomeScreen };
34
35
  export { LiveCollaborationTrigger };
@@ -1,8 +1,9 @@
1
1
  import type { ElementsSegmentsMap, GlobalPoint } from "@excalidraw/math/types";
2
- import type { ExcalidrawElement } from "@excalidraw/element/types";
2
+ import type { ElementsMap, ExcalidrawElement } from "@excalidraw/element/types";
3
3
  export declare const getLassoSelectedElementIds: (input: {
4
4
  lassoPath: GlobalPoint[];
5
5
  elements: readonly ExcalidrawElement[];
6
+ elementsMap: ElementsMap;
6
7
  elementsSegments: ElementsSegmentsMap;
7
8
  intersectedElements: Set<ExcalidrawElement["id"]>;
8
9
  enclosedElements: Set<ExcalidrawElement["id"]>;
@@ -1,7 +1,7 @@
1
- import type { ExcalidrawDiamondElement, ExcalidrawRectanguloidElement } from "@excalidraw/element/types";
1
+ import type { ElementsMap, ExcalidrawDiamondElement, ExcalidrawRectanguloidElement } from "@excalidraw/element/types";
2
2
  import type { StaticCanvasRenderConfig } from "../scene/types";
3
3
  import type { AppState } from "../types";
4
- export declare const fillCircle: (context: CanvasRenderingContext2D, cx: number, cy: number, radius: number, stroke?: boolean) => void;
4
+ export declare const fillCircle: (context: CanvasRenderingContext2D, cx: number, cy: number, radius: number, stroke: boolean, fill?: boolean) => void;
5
5
  export declare const getNormalizedCanvasDimensions: (canvas: HTMLCanvasElement, scale: number) => [number, number];
6
6
  export declare const bootstrapCanvas: ({ canvas, scale, normalizedWidth, normalizedHeight, theme, isExporting, canvasBackgroundColor, }: {
7
7
  canvas: HTMLCanvasElement;
@@ -12,7 +12,7 @@ export declare const bootstrapCanvas: ({ canvas, scale, normalizedWidth, normali
12
12
  isExporting?: boolean | undefined;
13
13
  canvasBackgroundColor?: string | null | undefined;
14
14
  }) => CanvasRenderingContext2D;
15
- export declare const drawHighlightForRectWithRotation: (context: CanvasRenderingContext2D, element: ExcalidrawRectanguloidElement, padding: number) => void;
15
+ export declare const drawHighlightForRectWithRotation: (context: CanvasRenderingContext2D, element: ExcalidrawRectanguloidElement, elementsMap: ElementsMap, padding: number) => void;
16
16
  export declare const strokeEllipseWithRotation: (context: CanvasRenderingContext2D, width: number, height: number, cx: number, cy: number, angle: number) => void;
17
17
  export declare const strokeRectWithRotation: (context: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, cx: number, cy: number, angle: number, fill?: boolean, radius?: number) => void;
18
- export declare const drawHighlightForDiamondWithRotation: (context: CanvasRenderingContext2D, padding: number, element: ExcalidrawDiamondElement) => void;
18
+ export declare const drawHighlightForDiamondWithRotation: (context: CanvasRenderingContext2D, padding: number, element: ExcalidrawDiamondElement, elementsMap: ElementsMap) => void;
@@ -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;
@@ -16,7 +16,6 @@ export declare class Renderer {
16
16
  /** note: first render of newElement will always bust the cache
17
17
  * (we'd have to prefilter elements outside of this function) */
18
18
  newElementId: ExcalidrawElement["id"] | undefined;
19
- pendingImageElementId: AppState["pendingImageElementId"];
20
19
  sceneNonce: ReturnType<InstanceType<typeof Scene>["getSceneNonce"]>;
21
20
  }) => {
22
21
  elementsMap: Map<string, NonDeletedExcalidrawElement> & import("@excalidraw/common/utility-types").MakeBrand<"NonDeletedElementsMap"> & import("@excalidraw/common/utility-types").MakeBrand<"RenderableElementsMap">;
@@ -2,7 +2,7 @@ import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES } from "@
2
2
  import type { SuggestedBinding } from "@excalidraw/element";
3
3
  import type { LinearElementEditor } from "@excalidraw/element";
4
4
  import type { MaybeTransformHandleType } from "@excalidraw/element";
5
- import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement } from "@excalidraw/element/types";
5
+ import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement } from "@excalidraw/element/types";
6
6
  import type { Merge, MaybePromise, ValueOf, MakeBrand } from "@excalidraw/common/utility-types";
7
7
  import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
8
8
  import type { Action } from "./actions/types";
@@ -113,7 +113,6 @@ type _CommonCanvasAppState = {
113
113
  offsetLeft: AppState["offsetLeft"];
114
114
  offsetTop: AppState["offsetTop"];
115
115
  theme: AppState["theme"];
116
- pendingImageElementId: AppState["pendingImageElementId"];
117
116
  };
118
117
  export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
119
118
  shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
@@ -128,7 +127,6 @@ export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
128
127
  }>;
129
128
  export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
130
129
  activeEmbeddable: AppState["activeEmbeddable"];
131
- editingLinearElement: AppState["editingLinearElement"];
132
130
  selectionElement: AppState["selectionElement"];
133
131
  selectedGroupIds: AppState["selectedGroupIds"];
134
132
  selectedLinearElement: AppState["selectedLinearElement"];
@@ -155,8 +153,10 @@ export type ObservedElementsAppState = {
155
153
  editingGroupId: AppState["editingGroupId"];
156
154
  selectedElementIds: AppState["selectedElementIds"];
157
155
  selectedGroupIds: AppState["selectedGroupIds"];
158
- editingLinearElementId: LinearElementEditor["elementId"] | null;
159
- selectedLinearElementId: LinearElementEditor["elementId"] | null;
156
+ selectedLinearElement: {
157
+ elementId: LinearElementEditor["elementId"];
158
+ isEditing: boolean;
159
+ } | null;
160
160
  croppingElementId: AppState["croppingElementId"];
161
161
  lockedMultiSelections: AppState["lockedMultiSelections"];
162
162
  activeLockedId: AppState["activeLockedId"];
@@ -210,7 +210,6 @@ export interface AppState {
210
210
  * set when a new text is created or when an existing text is being edited
211
211
  */
212
212
  editingTextElement: NonDeletedExcalidrawElement | null;
213
- editingLinearElement: LinearElementEditor | null;
214
213
  activeTool: {
215
214
  /**
216
215
  * indicates a previous tool we should revert back to if we deselect the
@@ -251,7 +250,7 @@ export interface AppState {
251
250
  isRotating: boolean;
252
251
  zoom: Zoom;
253
252
  openMenu: "canvas" | "shape" | null;
254
- openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | null;
253
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
255
254
  openSidebar: {
256
255
  name: SidebarName;
257
256
  tab?: SidebarTabName;
@@ -325,8 +324,6 @@ export interface AppState {
325
324
  shown: true;
326
325
  data: Spreadsheet;
327
326
  };
328
- /** imageElement waiting to be placed on canvas */
329
- pendingImageElementId: ExcalidrawImageElement["id"] | null;
330
327
  showHyperlinkPopup: false | "info" | "editor";
331
328
  selectedLinearElement: LinearElementEditor | null;
332
329
  snapLines: readonly SnapLine[];
@@ -352,6 +349,8 @@ export interface AppState {
352
349
  lockedMultiSelections: {
353
350
  [groupId: string]: true;
354
351
  };
352
+ /** properties sidebar mode - determines whether to show compact or complete sidebar */
353
+ stylesPanelMode: "compact" | "full";
355
354
  }
356
355
  export type SearchMatch = {
357
356
  id: string;
@@ -574,6 +573,7 @@ export type AppClassProperties = {
574
573
  excalidrawContainerValue: App["excalidrawContainerValue"];
575
574
  onPointerUpEmitter: App["onPointerUpEmitter"];
576
575
  updateEditorAtom: App["updateEditorAtom"];
576
+ defaultSelectionTool: "selection" | "lasso";
577
577
  };
578
578
  export type PointerDownState = Readonly<{
579
579
  origin: Readonly<{
@@ -621,6 +621,7 @@ export type PointerDownState = Readonly<{
621
621
  x: number;
622
622
  y: number;
623
623
  };
624
+ blockDragging: boolean;
624
625
  };
625
626
  eventListeners: {
626
627
  onMove: null | ReturnType<typeof throttleRAF>;
@@ -635,10 +636,12 @@ export type PointerDownState = Readonly<{
635
636
  export type UnsubscribeCallback = () => void;
636
637
  export interface ExcalidrawImperativeAPI {
637
638
  updateScene: InstanceType<typeof App>["updateScene"];
639
+ applyDeltas: InstanceType<typeof App>["applyDeltas"];
638
640
  mutateElement: InstanceType<typeof App>["mutateElement"];
639
641
  updateLibrary: InstanceType<typeof Library>["updateLibrary"];
640
642
  resetScene: InstanceType<typeof App>["resetScene"];
641
643
  getSceneElementsIncludingDeleted: InstanceType<typeof App>["getSceneElementsIncludingDeleted"];
644
+ getSceneElementsMapIncludingDeleted: InstanceType<typeof App>["getSceneElementsMapIncludingDeleted"];
642
645
  history: {
643
646
  clear: InstanceType<typeof App>["resetHistory"];
644
647
  };
@@ -15,3 +15,5 @@ export declare function radiansToDegrees(degrees: Radians): Degrees;
15
15
  * @returns TRUE if the provided angle is a right angle
16
16
  */
17
17
  export declare function isRightAngleRads(rads: Radians): boolean;
18
+ export declare function radiansBetweenAngles(a: Radians, min: Radians, max: Radians): boolean;
19
+ export declare function radiansDifference(a: Radians, b: Radians): Radians;
@@ -0,0 +1,3 @@
1
+ export declare const PRECISION = 0.0001;
2
+ export declare const LegendreGaussN24TValues: number[];
3
+ export declare const LegendreGaussN24CValues: number[];
@@ -40,3 +40,35 @@ export declare function curvePointDistance<Point extends GlobalPoint | LocalPoin
40
40
  */
41
41
  export declare function isCurve<P extends GlobalPoint | LocalPoint>(v: unknown): v is Curve<P>;
42
42
  export declare function curveTangent<Point extends GlobalPoint | LocalPoint>([p0, p1, p2, p3]: Curve<Point>, t: number): import("./types").Vector;
43
+ export declare function curveCatmullRomQuadraticApproxPoints(points: GlobalPoint[], tension?: number): [GlobalPoint, GlobalPoint][] | undefined;
44
+ export declare function curveCatmullRomCubicApproxPoints<Point extends GlobalPoint | LocalPoint>(points: Point[], tension?: number): Curve<Point>[] | undefined;
45
+ export declare function curveOffsetPoints([p0, p1, p2, p3]: Curve<GlobalPoint>, offset: number, steps?: number): GlobalPoint[];
46
+ export declare function offsetPointsForQuadraticBezier(p0: GlobalPoint, p1: GlobalPoint, p2: GlobalPoint, offsetDist: number, steps?: number): GlobalPoint[];
47
+ /**
48
+ * Implementation based on Legendre-Gauss quadrature for more accurate arc
49
+ * length calculation.
50
+ *
51
+ * Reference: https://pomax.github.io/bezierinfo/#arclength
52
+ *
53
+ * @param c The curve to calculate the length of
54
+ * @returns The approximated length of the curve
55
+ */
56
+ export declare function curveLength<P extends GlobalPoint | LocalPoint>(c: Curve<P>): number;
57
+ /**
58
+ * Calculates the curve length from t=0 to t=parameter using the same
59
+ * Legendre-Gauss quadrature method used in curveLength
60
+ *
61
+ * @param c The curve to calculate the partial length for
62
+ * @param t The parameter value (0 to 1) to calculate length up to
63
+ * @returns The length of the curve from beginning to parameter t
64
+ */
65
+ export declare function curveLengthAtParameter<P extends GlobalPoint | LocalPoint>(c: Curve<P>, t: number): number;
66
+ /**
67
+ * Calculates the point at a specific percentage of a curve's total length
68
+ * using binary search for improved efficiency and accuracy.
69
+ *
70
+ * @param c The curve to calculate point on
71
+ * @param percent A value between 0 and 1 representing the percentage of the curve's length
72
+ * @returns The point at the specified percentage of curve length
73
+ */
74
+ export declare function curvePointAtLength<P extends GlobalPoint | LocalPoint>(c: Curve<P>, percent: number): P;
@@ -1,5 +1,6 @@
1
1
  export * from "./angle";
2
2
  export * from "./curve";
3
+ export * from "./ellipse";
3
4
  export * from "./line";
4
5
  export * from "./point";
5
6
  export * from "./polygon";
@@ -43,7 +43,7 @@ export declare function isPoint(p: unknown): p is LocalPoint | GlobalPoint;
43
43
  * @param b Point The second point to compare
44
44
  * @returns TRUE if the points are sufficiently close to each other
45
45
  */
46
- export declare function pointsEqual<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point): boolean;
46
+ export declare function pointsEqual<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point, tolerance?: number): boolean;
47
47
  /**
48
48
  * Rotate a point by [angle] radians.
49
49
  *
@@ -1,3 +1,5 @@
1
1
  import type { GlobalPoint, LineSegment, LocalPoint, Rectangle } from "./types";
2
2
  export declare function rectangle<P extends GlobalPoint | LocalPoint>(topLeft: P, bottomRight: P): Rectangle<P>;
3
+ export declare function rectangleFromNumberSequence<Point extends LocalPoint | GlobalPoint>(minX: number, minY: number, maxX: number, maxY: number): Rectangle<Point>;
3
4
  export declare function rectangleIntersectLineSegment<Point extends LocalPoint | GlobalPoint>(r: Rectangle<Point>, l: LineSegment<Point>): Point[];
5
+ export declare function rectangleIntersectRectangle<Point extends LocalPoint | GlobalPoint>(rectangle1: Rectangle<Point>, rectangle2: Rectangle<Point>): boolean;
@@ -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;
@@ -12,9 +12,11 @@ export declare function vector(x: number, y: number, originX?: number, originY?:
12
12
  *
13
13
  * @param p The point to turn into a vector
14
14
  * @param origin The origin point in a given coordiante system
15
- * @returns The created vector from the point and the origin
15
+ * @param threshold The threshold to consider the vector as 'undefined'
16
+ * @param defaultValue The default value to return if the vector is 'undefined'
17
+ * @returns The created vector from the point and the origin or default
16
18
  */
17
- export declare function vectorFromPoint<Point extends GlobalPoint | LocalPoint>(p: Point, origin?: Point): Vector;
19
+ export declare function vectorFromPoint<Point extends GlobalPoint | LocalPoint>(p: Point, origin?: Point, threshold?: number, defaultValue?: Vector): Vector;
18
20
  /**
19
21
  * Cross product is a binary operation on two vectors in 2D space.
20
22
  * It results in a vector that is perpendicular to both vectors.