@excalidraw/excalidraw 0.15.2-6546-3398d86 → 0.15.2-6920-554913c

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 (75) hide show
  1. package/dist/excalidraw-assets/locales/{hi-IN-json-3898c9c1216b44476529.js → hi-IN-json-e22f4ad73126c2971850.js} +1 -1
  2. package/dist/excalidraw-assets/locales/{id-ID-json-43d505d7071a0e359681.js → id-ID-json-0e69caf5d919807ed234.js} +1 -1
  3. package/dist/excalidraw-assets/locales/{kk-KZ-json-f648362328b839e9313f.js → kk-KZ-json-106d2a41c68f69765668.js} +1 -1
  4. package/dist/excalidraw-assets/locales/sv-SE-json-efd822b4ee2770a3b369.js +1 -0
  5. package/dist/excalidraw-assets/locales/uk-UA-json-bbfc556c0ea7b939c13a.js +1 -0
  6. package/dist/excalidraw-assets/vendor-114c868489837257394a.js +2 -0
  7. package/dist/excalidraw-assets/vendor-114c868489837257394a.js.LICENSE.txt +22 -0
  8. package/dist/excalidraw-assets-dev/vendor-d615cecc8dc2cc9eb25f.js +3959 -0
  9. package/dist/excalidraw.development.js +7689 -237
  10. package/dist/excalidraw.production.min.js +1 -1
  11. package/dist/excalidraw.production.min.js.LICENSE.txt +10 -0
  12. package/package.json +1 -1
  13. package/types/actions/actionAddToLibrary.d.ts +3 -3
  14. package/types/actions/actionBoundText.d.ts +2 -2
  15. package/types/actions/actionCanvas.d.ts +11 -11
  16. package/types/actions/actionClipboard.d.ts +5 -5
  17. package/types/actions/actionDeleteSelected.d.ts +3 -3
  18. package/types/actions/actionElementLock.d.ts +2 -2
  19. package/types/actions/actionExport.d.ts +9 -9
  20. package/types/actions/actionFinalize.d.ts +3 -3
  21. package/types/actions/actionFrame.d.ts +3 -3
  22. package/types/actions/actionGroup.d.ts +241 -3
  23. package/types/actions/actionLinearEditor.d.ts +1 -1
  24. package/types/actions/actionMenu.d.ts +3 -3
  25. package/types/actions/actionProperties.d.ts +13 -13
  26. package/types/actions/actionSelectAll.d.ts +121 -1
  27. package/types/actions/actionStyles.d.ts +1 -1
  28. package/types/actions/actionToggleGridMode.d.ts +1 -1
  29. package/types/actions/actionToggleStats.d.ts +1 -1
  30. package/types/actions/actionToggleViewMode.d.ts +1 -1
  31. package/types/actions/actionToggleZenMode.d.ts +1 -1
  32. package/types/appState.d.ts +1 -1
  33. package/types/components/Actions.d.ts +2 -2
  34. package/types/components/App.d.ts +8 -6
  35. package/types/components/JSONExportDialog.d.ts +1 -1
  36. package/types/components/LayerUI.d.ts +3 -2
  37. package/types/components/MermaidToExcalidraw.d.ts +8 -0
  38. package/types/components/MobileMenu.d.ts +2 -2
  39. package/types/components/canvases/InteractiveCanvas.d.ts +26 -0
  40. package/types/components/canvases/StaticCanvas.d.ts +18 -0
  41. package/types/components/canvases/index.d.ts +3 -0
  42. package/types/element/Hyperlink.d.ts +2 -2
  43. package/types/element/embeddable.d.ts +1 -1
  44. package/types/element/linearElementEditor.d.ts +5 -5
  45. package/types/element/sizeHelpers.d.ts +8 -1
  46. package/types/element/textWysiwyg.d.ts +1 -1
  47. package/types/element/transformHandles.d.ts +2 -2
  48. package/types/frame.d.ts +3 -3
  49. package/types/groups.d.ts +10 -11
  50. package/types/packages/excalidraw/webpack.dev.config.d.ts +11 -0
  51. package/types/packages/excalidraw/webpack.prod.config.d.ts +11 -0
  52. package/types/renderer/renderElement.d.ts +9 -21
  53. package/types/renderer/renderScene.d.ts +16 -36
  54. package/types/scene/Renderer.d.ts +25 -0
  55. package/types/scene/Scene.d.ts +2 -0
  56. package/types/scene/Shape.d.ts +12 -0
  57. package/types/scene/ShapeCache.d.ts +20 -0
  58. package/types/scene/scroll.d.ts +1 -1
  59. package/types/scene/scrollbars.d.ts +2 -6
  60. package/types/scene/selection.d.ts +2 -2
  61. package/types/scene/types.d.ts +57 -24
  62. package/types/types.d.ts +48 -5
  63. package/types/utils.d.ts +12 -5
  64. package/dist/excalidraw-assets/locales/sv-SE-json-84a855efd030e37f51ab.js +0 -1
  65. package/dist/excalidraw-assets/locales/uk-UA-json-a48bb2e866a11d396a35.js +0 -1
  66. package/dist/excalidraw-assets/vendor-ef3c5d81a00ef582b871.js +0 -2
  67. package/dist/excalidraw-assets/vendor-ef3c5d81a00ef582b871.js.LICENSE.txt +0 -12
  68. package/dist/excalidraw-assets-dev/vendor-a14cd58fa2db417e42b2.js +0 -98
  69. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{hi-IN-json-3898c9c1216b44476529.d.ts → hi-IN-json-e22f4ad73126c2971850.d.ts} +0 -0
  70. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{id-ID-json-43d505d7071a0e359681.d.ts → id-ID-json-0e69caf5d919807ed234.d.ts} +0 -0
  71. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{kk-KZ-json-f648362328b839e9313f.d.ts → kk-KZ-json-106d2a41c68f69765668.d.ts} +0 -0
  72. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{sv-SE-json-84a855efd030e37f51ab.d.ts → sv-SE-json-efd822b4ee2770a3b369.d.ts} +0 -0
  73. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{uk-UA-json-a48bb2e866a11d396a35.d.ts → uk-UA-json-bbfc556c0ea7b939c13a.d.ts} +0 -0
  74. /package/types/packages/excalidraw/dist/excalidraw-assets/{vendor-ef3c5d81a00ef582b871.d.ts → vendor-114c868489837257394a.d.ts} +0 -0
  75. /package/types/packages/excalidraw/dist/excalidraw-assets-dev/{vendor-a14cd58fa2db417e42b2.d.ts → vendor-d615cecc8dc2cc9eb25f.d.ts} +0 -0
@@ -8,6 +8,7 @@ import History from "../history";
8
8
  import Scene from "../scene/Scene";
9
9
  import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, Device, FrameNameBoundsCache, SidebarName, SidebarTabName } from "../types";
10
10
  import { FileSystemHandle } from "../data/filesystem";
11
+ import { Renderer } from "../scene/Renderer";
11
12
  export declare const ExcalidrawContainerContext: React.Context<{
12
13
  container: HTMLDivElement | null;
13
14
  id: string | null;
@@ -31,7 +32,8 @@ export declare const useExcalidrawSetAppState: () => <K extends keyof AppState>(
31
32
  export declare const useExcalidrawActionManager: () => ActionManager;
32
33
  declare class App extends React.Component<AppProps, AppState> {
33
34
  canvas: AppClassProperties["canvas"];
34
- rc: RoughCanvas | null;
35
+ interactiveCanvas: AppClassProperties["interactiveCanvas"];
36
+ rc: RoughCanvas;
35
37
  unmounted: boolean;
36
38
  actionManager: ActionManager;
37
39
  device: Device;
@@ -39,6 +41,7 @@ declare class App extends React.Component<AppProps, AppState> {
39
41
  private excalidrawContainerRef;
40
42
  static defaultProps: Partial<AppProps>;
41
43
  scene: Scene;
44
+ renderer: Renderer;
42
45
  private fonts;
43
46
  private resizeObserver;
44
47
  private nearestScrollableContainer;
@@ -58,7 +61,6 @@ declare class App extends React.Component<AppProps, AppState> {
58
61
  y: number;
59
62
  };
60
63
  constructor(props: AppProps);
61
- private renderCanvas;
62
64
  private onWindowMessage;
63
65
  private updateEmbeddableRef;
64
66
  private getHTMLIFrameElement;
@@ -94,15 +96,15 @@ declare class App extends React.Component<AppProps, AppState> {
94
96
  private removeEventListeners;
95
97
  private addEventListeners;
96
98
  componentDidUpdate(prevProps: AppProps, prevState: AppState): void;
97
- private renderScene;
99
+ private renderInteractiveSceneCallback;
98
100
  private onScroll;
99
101
  private onCut;
100
102
  private onCopy;
101
103
  private cutAll;
102
104
  private copyAll;
103
105
  private static resetTapTwice;
104
- private onTapStart;
105
- private onTapEnd;
106
+ private onTouchStart;
107
+ private onTouchEnd;
106
108
  pasteFromClipboard: (event: ClipboardEvent | null) => Promise<void>;
107
109
  private addElementsFromPasteOrLibrary;
108
110
  private addTextFromPaste;
@@ -246,7 +248,7 @@ declare class App extends React.Component<AppProps, AppState> {
246
248
  private maybeSuggestBindingsForLinearElementAtCoords;
247
249
  private maybeSuggestBindingForAll;
248
250
  private clearSelection;
249
- private handleCanvasRef;
251
+ private handleInteractiveCanvasRef;
250
252
  private handleAppOnDrop;
251
253
  loadFileToCanvas: (file: File, fileHandle: FileSystemHandle | null) => Promise<void>;
252
254
  private handleCanvasContextMenu;
@@ -10,6 +10,6 @@ export declare const JSONExportDialog: ({ elements, appState, files, actionManag
10
10
  files: BinaryFiles;
11
11
  actionManager: ActionManager;
12
12
  exportOpts: ExportOpts;
13
- canvas: HTMLCanvasElement | null;
13
+ canvas: HTMLCanvasElement;
14
14
  setAppState: React.Component<any, UIAppState>["setState"];
15
15
  }) => JSX.Element;
@@ -9,7 +9,8 @@ interface LayerUIProps {
9
9
  actionManager: ActionManager;
10
10
  appState: UIAppState;
11
11
  files: BinaryFiles;
12
- canvas: HTMLCanvasElement | null;
12
+ canvas: HTMLCanvasElement;
13
+ interactiveCanvas: HTMLCanvasElement | null;
13
14
  setAppState: React.Component<any, AppState>["setState"];
14
15
  elements: readonly NonDeletedExcalidrawElement[];
15
16
  onLockToggle: () => void;
@@ -28,5 +29,5 @@ interface LayerUIProps {
28
29
  children?: React.ReactNode;
29
30
  app: AppClassProperties;
30
31
  }
31
- declare const _default: React.MemoExoticComponent<({ actionManager, appState, files, setAppState, elements, canvas, onLockToggle, onHandToolToggle, onPenModeToggle, showExitZenModeBtn, renderTopRightUI, renderCustomStats, UIOptions, onImageAction, onExportImage, renderWelcomeScreen, children, app, }: LayerUIProps) => JSX.Element>;
32
+ declare const _default: React.MemoExoticComponent<({ actionManager, appState, files, setAppState, elements, canvas, interactiveCanvas, onLockToggle, onHandToolToggle, onPenModeToggle, showExitZenModeBtn, renderTopRightUI, renderCustomStats, UIOptions, onImageAction, onExportImage, renderWelcomeScreen, children, app, }: LayerUIProps) => JSX.Element>;
32
33
  export default _default;
@@ -0,0 +1,8 @@
1
+ import { AppState } from "../types";
2
+ import "./MermaidToExcalidraw.scss";
3
+ import { NonDeletedExcalidrawElement } from "../element/types";
4
+ declare const MermaidToExcalidraw: ({ appState, elements, }: {
5
+ appState: AppState;
6
+ elements: readonly NonDeletedExcalidrawElement[];
7
+ }) => JSX.Element | null;
8
+ export default MermaidToExcalidraw;
@@ -12,7 +12,7 @@ type MobileMenuProps = {
12
12
  onLockToggle: () => void;
13
13
  onHandToolToggle: () => void;
14
14
  onPenModeToggle: () => void;
15
- canvas: HTMLCanvasElement | null;
15
+ interactiveCanvas: HTMLCanvasElement | null;
16
16
  onImageAction: (data: {
17
17
  insertOnCanvasDirectly: boolean;
18
18
  }) => void;
@@ -23,5 +23,5 @@ type MobileMenuProps = {
23
23
  renderWelcomeScreen: boolean;
24
24
  app: AppClassProperties;
25
25
  };
26
- export declare const MobileMenu: ({ appState, elements, actionManager, setAppState, onLockToggle, onHandToolToggle, onPenModeToggle, canvas, onImageAction, renderTopRightUI, renderCustomStats, renderSidebars, device, renderWelcomeScreen, app, }: MobileMenuProps) => JSX.Element;
26
+ export declare const MobileMenu: ({ appState, elements, actionManager, setAppState, onLockToggle, onHandToolToggle, onPenModeToggle, interactiveCanvas, onImageAction, renderTopRightUI, renderCustomStats, renderSidebars, device, renderWelcomeScreen, app, }: MobileMenuProps) => JSX.Element;
27
27
  export {};
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import type { DOMAttributes } from "react";
3
+ import type { InteractiveCanvasAppState } from "../../types";
4
+ import type { RenderInteractiveSceneCallback } from "../../scene/types";
5
+ import type { NonDeletedExcalidrawElement } from "../../element/types";
6
+ type InteractiveCanvasProps = {
7
+ canvas: HTMLCanvasElement | null;
8
+ elements: readonly NonDeletedExcalidrawElement[];
9
+ visibleElements: readonly NonDeletedExcalidrawElement[];
10
+ selectedElements: readonly NonDeletedExcalidrawElement[];
11
+ versionNonce: number | undefined;
12
+ selectionNonce: number | undefined;
13
+ scale: number;
14
+ appState: InteractiveCanvasAppState;
15
+ renderInteractiveSceneCallback: (data: RenderInteractiveSceneCallback) => void;
16
+ handleCanvasRef: (canvas: HTMLCanvasElement | null) => void;
17
+ onContextMenu: Exclude<DOMAttributes<HTMLCanvasElement | HTMLDivElement>["onContextMenu"], undefined>;
18
+ onPointerMove: Exclude<DOMAttributes<HTMLCanvasElement>["onPointerMove"], undefined>;
19
+ onPointerUp: Exclude<DOMAttributes<HTMLCanvasElement>["onPointerUp"], undefined>;
20
+ onPointerCancel: Exclude<DOMAttributes<HTMLCanvasElement>["onPointerCancel"], undefined>;
21
+ onTouchMove: Exclude<DOMAttributes<HTMLCanvasElement>["onTouchMove"], undefined>;
22
+ onPointerDown: Exclude<DOMAttributes<HTMLCanvasElement>["onPointerDown"], undefined>;
23
+ onDoubleClick: Exclude<DOMAttributes<HTMLCanvasElement>["onDoubleClick"], undefined>;
24
+ };
25
+ declare const _default: React.MemoExoticComponent<(props: InteractiveCanvasProps) => JSX.Element>;
26
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import { RoughCanvas } from "roughjs/bin/canvas";
3
+ import type { StaticCanvasAppState } from "../../types";
4
+ import type { StaticCanvasRenderConfig } from "../../scene/types";
5
+ import type { NonDeletedExcalidrawElement } from "../../element/types";
6
+ type StaticCanvasProps = {
7
+ canvas: HTMLCanvasElement;
8
+ rc: RoughCanvas;
9
+ elements: readonly NonDeletedExcalidrawElement[];
10
+ visibleElements: readonly NonDeletedExcalidrawElement[];
11
+ versionNonce: number | undefined;
12
+ selectionNonce: number | undefined;
13
+ scale: number;
14
+ appState: StaticCanvasAppState;
15
+ renderConfig: StaticCanvasRenderConfig;
16
+ };
17
+ declare const _default: React.MemoExoticComponent<(props: StaticCanvasProps) => JSX.Element>;
18
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import InteractiveCanvas from "./InteractiveCanvas";
2
+ import StaticCanvas from "./StaticCanvas";
3
+ export { InteractiveCanvas, StaticCanvas };
@@ -54,7 +54,7 @@ export declare const actionLink: {
54
54
  lastActiveTool: import("../types").LastActiveTool;
55
55
  locked: boolean;
56
56
  } & ({
57
- type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand";
57
+ type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand" | "mermaid";
58
58
  customType: null;
59
59
  } | {
60
60
  type: "custom";
@@ -151,7 +151,7 @@ export declare const actionLink: {
151
151
  keyTest?: ((event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean) | undefined;
152
152
  };
153
153
  export declare const getContextMenuLabel: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => "labels.link.editEmbed" | "labels.link.edit" | "labels.link.createEmbed" | "labels.link.create";
154
- export declare const getLinkHandleFromCoords: ([x1, y1, x2, y2]: Bounds, angle: number, appState: UIAppState) => [x: number, y: number, width: number, height: number];
154
+ export declare const getLinkHandleFromCoords: ([x1, y1, x2, y2]: Bounds, angle: number, appState: Pick<UIAppState, "zoom">) => [x: number, y: number, width: number, height: number];
155
155
  export declare const isPointHittingLinkIcon: (element: NonDeletedExcalidrawElement, appState: AppState, [x, y]: readonly [number, number]) => boolean;
156
156
  export declare const isPointHittingLink: (element: NonDeletedExcalidrawElement, appState: AppState, [x, y]: readonly [number, number], isMobile: boolean) => boolean;
157
157
  export declare const showHyperlinkTooltip: (element: NonDeletedExcalidrawElement, appState: AppState) => void;
@@ -28,7 +28,7 @@ export declare const actionSetEmbeddableAsActiveTool: {
28
28
  lastActiveTool: import("../types").LastActiveTool;
29
29
  locked: boolean;
30
30
  } & ({
31
- type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand";
31
+ type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand" | "mermaid";
32
32
  customType: null;
33
33
  } | {
34
34
  type: "custom";
@@ -1,5 +1,5 @@
1
1
  import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer } from "./types";
2
- import { Point, AppState, PointerCoords } from "../types";
2
+ import { Point, AppState, PointerCoords, InteractiveCanvasAppState } from "../types";
3
3
  import History from "../history";
4
4
  import Scene from "../scene/Scene";
5
5
  declare const editorMidPointsCache: {
@@ -52,8 +52,8 @@ export declare class LinearElementEditor {
52
52
  y: number;
53
53
  }[]) => void, linearElementEditor: LinearElementEditor): boolean;
54
54
  static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState): LinearElementEditor;
55
- static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, appState: AppState) => (typeof editorMidPointsCache)["points"];
56
- static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, appState: AppState) => void;
55
+ static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, appState: InteractiveCanvasAppState) => (typeof editorMidPointsCache)["points"];
56
+ static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, appState: InteractiveCanvasAppState) => void;
57
57
  static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
58
58
  x: number;
59
59
  y: number;
@@ -155,7 +155,7 @@ export declare class LinearElementEditor {
155
155
  lastActiveTool: import("../types").LastActiveTool;
156
156
  locked: boolean;
157
157
  } & ({
158
- type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand";
158
+ type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand" | "mermaid";
159
159
  customType: null;
160
160
  } | {
161
161
  type: "custom";
@@ -179,7 +179,7 @@ export declare class LinearElementEditor {
179
179
  currentItemTextAlign: string;
180
180
  currentItemStartArrowhead: import("./types").Arrowhead | null;
181
181
  currentItemEndArrowhead: import("./types").Arrowhead | null;
182
- currentItemRoundness: import("./types").StrokeRoundness; /** @returns whether point was dragged */
182
+ currentItemRoundness: import("./types").StrokeRoundness;
183
183
  viewBackgroundColor: string;
184
184
  scrollX: number;
185
185
  scrollY: number;
@@ -1,6 +1,13 @@
1
1
  import { ExcalidrawElement } from "./types";
2
- import { AppState } from "../types";
2
+ import { AppState, Zoom } from "../types";
3
3
  export declare const isInvisiblySmallElement: (element: ExcalidrawElement) => boolean;
4
+ export declare const isElementInViewport: (element: ExcalidrawElement, width: number, height: number, viewTransformations: {
5
+ zoom: Zoom;
6
+ offsetLeft: number;
7
+ offsetTop: number;
8
+ scrollX: number;
9
+ scrollY: number;
10
+ }) => boolean;
4
11
  /**
5
12
  * Makes a perfect shape or diagonal/horizontal/vertical line
6
13
  */
@@ -15,7 +15,7 @@ export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords,
15
15
  }) => void;
16
16
  getViewportCoords: (x: number, y: number) => [number, number];
17
17
  element: ExcalidrawTextElement;
18
- canvas: HTMLCanvasElement | null;
18
+ canvas: HTMLCanvasElement;
19
19
  excalidrawContainer: HTMLDivElement | null;
20
20
  app: App;
21
21
  }) => void;
@@ -1,5 +1,5 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
2
- import { AppState, Zoom } from "../types";
2
+ import { InteractiveCanvasAppState, Zoom } from "../types";
3
3
  export type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
4
4
  export type TransformHandleType = TransformHandleDirection | "rotation";
5
5
  export type TransformHandle = [number, number, number, number];
@@ -32,4 +32,4 @@ export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [
32
32
  rotation?: boolean | undefined;
33
33
  }, margin?: number) => TransformHandles;
34
34
  export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoom, pointerType?: PointerType) => TransformHandles;
35
- export declare const shouldShowBoundingBox: (elements: NonDeletedExcalidrawElement[], appState: AppState) => boolean;
35
+ export declare const shouldShowBoundingBox: (elements: readonly NonDeletedExcalidrawElement[], appState: InteractiveCanvasAppState) => boolean;
package/types/frame.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ExcalidrawElement, ExcalidrawFrameElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
2
- import { AppClassProperties, AppState } from "./types";
2
+ import { AppClassProperties, AppState, StaticCanvasAppState } from "./types";
3
3
  import { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
4
4
  export declare const bindElementsToFramesAfterDuplication: (nextElements: ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
5
5
  export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
@@ -36,5 +36,5 @@ export declare const omitGroupsContainingFrames: (allElements: ExcalidrawElement
36
36
  * depending on the appState, return target frame, which is the frame the given element
37
37
  * is going to be added to or remove from
38
38
  */
39
- export declare const getTargetFrame: (element: ExcalidrawElement, appState: AppState) => ExcalidrawFrameElement | null;
40
- export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ExcalidrawElementsIncludingDeleted, appState: AppState) => boolean;
39
+ export declare const getTargetFrame: (element: ExcalidrawElement, appState: StaticCanvasAppState) => ExcalidrawFrameElement | null;
40
+ export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ExcalidrawElementsIncludingDeleted, appState: StaticCanvasAppState) => boolean;
package/types/groups.d.ts CHANGED
@@ -1,19 +1,18 @@
1
1
  import { GroupId, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
2
- import { AppClassProperties, AppState } from "./types";
3
- export declare const selectGroup: (groupId: GroupId, appState: AppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => AppState;
2
+ import { AppClassProperties, AppState, InteractiveCanvasAppState } from "./types";
3
+ export declare const selectGroup: (groupId: GroupId, appState: InteractiveCanvasAppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => Pick<InteractiveCanvasAppState, "selectedGroupIds" | "selectedElementIds" | "editingGroupId">;
4
+ export declare const selectGroupsForSelectedElements: {
5
+ (appState: Pick<AppState, "selectedElementIds" | "editingGroupId">, elements: readonly NonDeletedExcalidrawElement[], prevAppState: InteractiveCanvasAppState, app: AppClassProperties | null): Pick<InteractiveCanvasAppState, "selectedGroupIds" | "editingGroupId" | "selectedElementIds">;
6
+ clearCache(): void;
7
+ };
4
8
  /**
5
9
  * If the element's group is selected, don't render an individual
6
10
  * selection border around it.
7
11
  */
8
- export declare const isSelectedViaGroup: (appState: AppState, element: ExcalidrawElement) => boolean;
9
- export declare const getSelectedGroupForElement: (appState: AppState, element: ExcalidrawElement) => string | undefined;
10
- export declare const getSelectedGroupIds: (appState: AppState) => GroupId[];
11
- /**
12
- * When you select an element, you often want to actually select the whole group it's in, unless
13
- * you're currently editing that group.
14
- */
15
- export declare const selectGroupsForSelectedElements: (appState: AppState, elements: readonly NonDeletedExcalidrawElement[], prevAppState: AppState, app: AppClassProperties | null) => AppState;
16
- export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: AppState) => {
12
+ export declare const isSelectedViaGroup: (appState: InteractiveCanvasAppState, element: ExcalidrawElement) => boolean;
13
+ export declare const getSelectedGroupForElement: (appState: InteractiveCanvasAppState, element: ExcalidrawElement) => string | undefined;
14
+ export declare const getSelectedGroupIds: (appState: InteractiveCanvasAppState) => GroupId[];
15
+ export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: InteractiveCanvasAppState) => {
17
16
  [groupId: string]: boolean;
18
17
  };
19
18
  export declare const editGroupForSelectedElement: (appState: AppState, element: NonDeleted<ExcalidrawElement>) => AppState;
@@ -32,6 +32,15 @@ export namespace module {
32
32
  };
33
33
  };
34
34
  })[];
35
+ resolve?: undefined;
36
+ type?: undefined;
37
+ } | {
38
+ test: RegExp;
39
+ resolve: {
40
+ fullySpecified: boolean;
41
+ };
42
+ exclude?: undefined;
43
+ use?: undefined;
35
44
  type?: undefined;
36
45
  } | {
37
46
  test: RegExp;
@@ -46,12 +55,14 @@ export namespace module {
46
55
  configFile: string;
47
56
  };
48
57
  })[];
58
+ resolve?: undefined;
49
59
  type?: undefined;
50
60
  } | {
51
61
  test: RegExp;
52
62
  type: string;
53
63
  exclude?: undefined;
54
64
  use?: undefined;
65
+ resolve?: undefined;
55
66
  })[];
56
67
  }
57
68
  export namespace optimization {
@@ -31,6 +31,15 @@ export namespace module {
31
31
  };
32
32
  };
33
33
  })[];
34
+ resolve?: undefined;
35
+ type?: undefined;
36
+ } | {
37
+ test: RegExp;
38
+ resolve: {
39
+ fullySpecified: boolean;
40
+ };
41
+ exclude?: undefined;
42
+ use?: undefined;
34
43
  type?: undefined;
35
44
  } | {
36
45
  test: RegExp;
@@ -57,12 +66,14 @@ export namespace module {
57
66
  configFile?: undefined;
58
67
  };
59
68
  })[];
69
+ resolve?: undefined;
60
70
  type?: undefined;
61
71
  } | {
62
72
  test: RegExp;
63
73
  type: string;
64
74
  exclude?: undefined;
65
75
  use?: undefined;
76
+ resolve?: undefined;
66
77
  })[];
67
78
  }
68
79
  export namespace optimization {
@@ -1,37 +1,25 @@
1
1
  import { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement } from "../element/types";
2
- import { RoughCanvas } from "roughjs/bin/canvas";
3
- import { Drawable, Options } from "roughjs/bin/core";
4
- import { RoughSVG } from "roughjs/bin/svg";
5
- import { RenderConfig } from "../scene/types";
6
- import { AppState, BinaryFiles } from "../types";
2
+ import type { RoughCanvas } from "roughjs/bin/canvas";
3
+ import type { RoughSVG } from "roughjs/bin/svg";
4
+ import { StaticCanvasRenderConfig } from "../scene/types";
5
+ import { AppState, StaticCanvasAppState, BinaryFiles, InteractiveCanvasAppState } from "../types";
7
6
  export interface ExcalidrawElementWithCanvas {
8
7
  element: ExcalidrawElement | ExcalidrawTextElement;
9
8
  canvas: HTMLCanvasElement;
10
- theme: RenderConfig["theme"];
9
+ theme: AppState["theme"];
11
10
  scale: number;
12
- zoomValue: RenderConfig["zoom"]["value"];
11
+ zoomValue: AppState["zoom"]["value"];
13
12
  canvasOffsetX: number;
14
13
  canvasOffsetY: number;
15
14
  boundTextElementVersion: number | null;
16
15
  containingFrameOpacity: number;
17
16
  }
18
17
  export declare const DEFAULT_LINK_SIZE = 14;
19
- type ElementShape = Drawable | Drawable[] | null;
20
- type ElementShapes = {
21
- freedraw: Drawable | null;
22
- arrow: Drawable[];
23
- line: Drawable[];
24
- text: null;
25
- image: null;
26
- };
27
- export declare const getShapeForElement: <T extends ExcalidrawElement>(element: T) => T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : Drawable | null | undefined;
28
- export declare const setShapeForElement: <T extends ExcalidrawElement>(element: T, shape: T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable) => WeakMap<ExcalidrawElement, ElementShape>;
29
- export declare const invalidateShapeForElement: (element: ExcalidrawElement) => boolean;
30
- export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
31
- export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: RenderConfig, appState: AppState) => void;
18
+ export declare const elementWithCanvasCache: WeakMap<ExcalidrawElement, ExcalidrawElementWithCanvas>;
19
+ export declare const renderSelectionElement: (element: NonDeletedExcalidrawElement, context: CanvasRenderingContext2D, appState: InteractiveCanvasAppState) => void;
20
+ export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState) => void;
32
21
  export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, exportWithDarkMode?: boolean, exportingFrameId?: string | null, renderEmbeddables?: boolean) => void;
33
22
  export declare const pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
34
23
  export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
35
24
  export declare function getFreeDrawPath2D(element: ExcalidrawFreeDrawElement): Path2D | undefined;
36
25
  export declare function getFreeDrawSvgPath(element: ExcalidrawFreeDrawElement): string;
37
- export {};
@@ -1,47 +1,27 @@
1
- import { RoughCanvas } from "roughjs/bin/canvas";
2
1
  import { RoughSVG } from "roughjs/bin/svg";
3
- import { AppState, BinaryFiles, Zoom } from "../types";
4
- import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
5
- import { RenderConfig } from "../scene/types";
2
+ import { BinaryFiles } from "../types";
3
+ import { NonDeletedExcalidrawElement } from "../element/types";
4
+ import { InteractiveSceneRenderConfig, StaticSceneRenderConfig } from "../scene/types";
6
5
  import "canvas-roundrect-polyfill";
7
6
  export declare const DEFAULT_SPACING = 2;
8
- export declare const _renderScene: ({ elements, appState, scale, rc, canvas, renderConfig, }: {
9
- elements: readonly NonDeletedExcalidrawElement[];
10
- appState: AppState;
11
- scale: number;
12
- rc: RoughCanvas;
13
- canvas: HTMLCanvasElement;
14
- renderConfig: RenderConfig;
15
- }) => {
7
+ /**
8
+ * Interactive scene is the ui-canvas where we render boundinb boxes, selections
9
+ * and other ui stuff.
10
+ */
11
+ export declare const renderInteractiveScene: <U extends ({ canvas, elements, visibleElements, selectedElements, scale, appState, renderConfig, }: InteractiveSceneRenderConfig) => {
16
12
  atLeastOneVisibleElement: boolean;
17
- scrollBars?: undefined;
18
- } | {
19
- atLeastOneVisibleElement: boolean;
20
- scrollBars: import("../scene/types").ScrollBars | undefined;
21
- };
22
- /** renderScene throttled to animation framerate */
23
- export declare const renderScene: <T extends boolean = false>(config: {
24
13
  elements: readonly NonDeletedExcalidrawElement[];
25
- appState: AppState;
26
- scale: number;
27
- rc: RoughCanvas;
28
- canvas: HTMLCanvasElement;
29
- renderConfig: RenderConfig;
30
- callback?: ((data: ReturnType<typeof _renderScene>) => void) | undefined;
31
- }, throttle?: T | undefined) => T extends true ? void : {
32
- atLeastOneVisibleElement: boolean;
33
14
  scrollBars?: undefined;
34
15
  } | {
35
- atLeastOneVisibleElement: boolean;
36
16
  scrollBars: import("../scene/types").ScrollBars | undefined;
37
- };
38
- export declare const isVisibleElement: (element: ExcalidrawElement, canvasWidth: number, canvasHeight: number, viewTransformations: {
39
- zoom: Zoom;
40
- offsetLeft: number;
41
- offsetTop: number;
42
- scrollX: number;
43
- scrollY: number;
44
- }) => boolean;
17
+ atLeastOneVisibleElement: boolean;
18
+ elements: readonly NonDeletedExcalidrawElement[];
19
+ }, T extends boolean = false>(renderConfig: InteractiveSceneRenderConfig, throttle?: T | undefined) => T extends true ? void : ReturnType<U>;
20
+ /**
21
+ * Static scene is the non-ui canvas where we render elements.
22
+ */
23
+ export declare const renderStaticScene: (renderConfig: StaticSceneRenderConfig, throttle?: boolean) => void;
24
+ export declare const cancelRender: () => void;
45
25
  export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, { offsetX, offsetY, exportWithDarkMode, exportingFrameId, renderEmbeddables, }?: {
46
26
  offsetX?: number | undefined;
47
27
  offsetY?: number | undefined;
@@ -0,0 +1,25 @@
1
+ import { NonDeletedExcalidrawElement } from "../element/types";
2
+ import { AppState } from "../types";
3
+ import Scene from "./Scene";
4
+ export declare class Renderer {
5
+ private scene;
6
+ constructor(scene: Scene);
7
+ getRenderableElements: ((opts: {
8
+ zoom: AppState["zoom"];
9
+ offsetLeft: AppState["offsetLeft"];
10
+ offsetTop: AppState["offsetTop"];
11
+ scrollX: AppState["scrollX"];
12
+ scrollY: AppState["scrollY"];
13
+ height: AppState["height"];
14
+ width: AppState["width"];
15
+ editingElement: AppState["editingElement"];
16
+ pendingImageElementId: AppState["pendingImageElementId"];
17
+ versionNonce: ReturnType<InstanceType<typeof Scene>["getVersionNonce"]>;
18
+ }) => {
19
+ canvasElements: NonDeletedExcalidrawElement[];
20
+ visibleElements: readonly NonDeletedExcalidrawElement[];
21
+ }) & {
22
+ clear: () => void;
23
+ };
24
+ destroy(): void;
25
+ }
@@ -18,6 +18,7 @@ declare class Scene {
18
18
  private frames;
19
19
  private elementsMap;
20
20
  private selectedElementsCache;
21
+ private versionNonce;
21
22
  getElementsIncludingDeleted(): readonly ExcalidrawElement[];
22
23
  getNonDeletedElements(): readonly NonDeletedExcalidrawElement[];
23
24
  getFramesIncludingDeleted(): readonly ExcalidrawFrameElement[];
@@ -34,6 +35,7 @@ declare class Scene {
34
35
  }): NonDeleted<ExcalidrawElement>[];
35
36
  getNonDeletedFrames(): readonly NonDeleted<ExcalidrawFrameElement>[];
36
37
  getElement<T extends ExcalidrawElement>(id: T["id"]): T | null;
38
+ getVersionNonce(): number | undefined;
37
39
  getNonDeletedElement(id: ExcalidrawElement["id"]): NonDeleted<ExcalidrawElement> | null;
38
40
  /**
39
41
  * A utility method to help with updating all scene elements, with the added
@@ -0,0 +1,12 @@
1
+ import type { Drawable, Options } from "roughjs/bin/core";
2
+ import type { RoughGenerator } from "roughjs/bin/generator";
3
+ import type { ExcalidrawElement, NonDeletedExcalidrawElement, ExcalidrawSelectionElement } from "../element/types";
4
+ export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
5
+ /**
6
+ * Generates the roughjs shape for given element.
7
+ *
8
+ * Low-level. Use `ShapeCache.generateElementShape` instead.
9
+ *
10
+ * @private
11
+ */
12
+ export declare const _generateElementShape: (element: Exclude<NonDeletedExcalidrawElement, ExcalidrawSelectionElement>, generator: RoughGenerator, isExporting?: boolean) => Drawable | Drawable[] | null;
@@ -0,0 +1,20 @@
1
+ import { Drawable } from "roughjs/bin/core";
2
+ import { ExcalidrawElement } from "../element/types";
3
+ import { ElementShape, ElementShapes } from "./types";
4
+ export declare class ShapeCache {
5
+ private static rg;
6
+ private static cache;
7
+ /**
8
+ * Retrieves shape from cache if available. Use this only if shape
9
+ * is optional and you have a fallback in case it's not cached.
10
+ */
11
+ static get: <T extends ExcalidrawElement>(element: T) => T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined;
12
+ static set: <T extends ExcalidrawElement>(element: T, shape: T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable) => WeakMap<ExcalidrawElement, ElementShape>;
13
+ static delete: (element: ExcalidrawElement) => boolean;
14
+ static destroy: () => void;
15
+ /**
16
+ * Generates & caches shape for element if not already cached, otherwise
17
+ * returns cached shape.
18
+ */
19
+ static generateElementShape: <T extends import("../element/types").ExcalidrawLinearElement | import("../element/types").ExcalidrawRectangleElement | import("../element/types").ExcalidrawDiamondElement | import("../element/types").ExcalidrawEllipseElement | import("../element/types").ExcalidrawEmbeddableElement | import("../element/types").ExcalidrawImageElement | import("../element/types").ExcalidrawFrameElement | import("../element/types").ExcalidrawTextElement | import("../element/types").ExcalidrawFreeDrawElement>(element: T, isExporting?: boolean) => ((T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined) & ({} | null)) | (T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable | null);
20
+ }
@@ -11,7 +11,7 @@ export declare const centerScrollOn: ({ scenePoint, viewportDimensions, zoom, }:
11
11
  scrollX: number;
12
12
  scrollY: number;
13
13
  };
14
- export declare const calculateScrollCenter: (elements: readonly ExcalidrawElement[], appState: AppState, canvas: HTMLCanvasElement | null) => {
14
+ export declare const calculateScrollCenter: (elements: readonly ExcalidrawElement[], appState: AppState) => {
15
15
  scrollX: number;
16
16
  scrollY: number;
17
17
  };
@@ -1,14 +1,10 @@
1
1
  import { ExcalidrawElement } from "../element/types";
2
- import { Zoom } from "../types";
2
+ import { InteractiveCanvasAppState } from "../types";
3
3
  import { ScrollBars } from "./types";
4
4
  export declare const SCROLLBAR_MARGIN = 4;
5
5
  export declare const SCROLLBAR_WIDTH = 6;
6
6
  export declare const SCROLLBAR_COLOR = "rgba(0,0,0,0.3)";
7
- export declare const getScrollBars: (elements: readonly ExcalidrawElement[], viewportWidth: number, viewportHeight: number, { scrollX, scrollY, zoom, }: {
8
- scrollX: number;
9
- scrollY: number;
10
- zoom: Zoom;
11
- }) => ScrollBars;
7
+ export declare const getScrollBars: (elements: readonly ExcalidrawElement[], viewportWidth: number, viewportHeight: number, appState: InteractiveCanvasAppState) => ScrollBars;
12
8
  export declare const isOverScrollBars: (scrollBars: ScrollBars, x: number, y: number) => {
13
9
  isOverEither: boolean;
14
10
  isOverHorizontal: boolean;
@@ -1,5 +1,5 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
2
- import { AppState } from "../types";
2
+ import { AppState, InteractiveCanvasAppState } from "../types";
3
3
  /**
4
4
  * Frames and their containing elements are not to be selected at the same time.
5
5
  * Given an array of selected elements, if there are frames and their containing elements
@@ -17,7 +17,7 @@ export declare const isSomeElementSelected: {
17
17
  * elements. If elements don't share the same value, returns `null`.
18
18
  */
19
19
  export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, getAttribute: (element: ExcalidrawElement) => T) => T | null;
20
- export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, opts?: {
20
+ export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<InteractiveCanvasAppState, "selectedElementIds">, opts?: {
21
21
  includeBoundTextElement?: boolean;
22
22
  includeElementsInFrames?: boolean;
23
23
  }) => ExcalidrawElement[];