@zsviczian/excalidraw 0.16.1-obsidian-2 → 0.16.1-obsidian-4

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 (50) hide show
  1. package/dist/excalidraw.development.js +92 -26
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/package.json +1 -1
  4. package/types/actions/actionAddToLibrary.d.ts +9 -27
  5. package/types/actions/actionAlign.d.ts +8 -8
  6. package/types/actions/actionBoundText.d.ts +6 -18
  7. package/types/actions/actionCanvas.d.ts +206 -125
  8. package/types/actions/actionClipboard.d.ts +19 -49
  9. package/types/actions/actionDeleteSelected.d.ts +11 -29
  10. package/types/actions/actionDistribute.d.ts +4 -4
  11. package/types/actions/actionDuplicateSelection.d.ts +2 -2
  12. package/types/actions/actionElementLock.d.ts +8 -20
  13. package/types/actions/actionExport.d.ts +35 -89
  14. package/types/actions/actionFinalize.d.ts +8 -20
  15. package/types/actions/actionFlip.d.ts +4 -4
  16. package/types/actions/actionFrame.d.ts +11 -29
  17. package/types/actions/actionGroup.d.ts +10 -22
  18. package/types/actions/actionLinearEditor.d.ts +3 -9
  19. package/types/actions/actionMenu.d.ts +13 -31
  20. package/types/actions/actionProperties.d.ts +43 -121
  21. package/types/actions/actionSelectAll.d.ts +5 -11
  22. package/types/actions/actionStyles.d.ts +7 -13
  23. package/types/actions/actionToggleGridMode.d.ts +5 -11
  24. package/types/actions/actionToggleObjectsSnapMode.d.ts +5 -11
  25. package/types/actions/actionToggleStats.d.ts +5 -11
  26. package/types/actions/actionToggleViewMode.d.ts +5 -11
  27. package/types/actions/actionToggleZenMode.d.ts +5 -11
  28. package/types/actions/actionZindex.d.ts +8 -8
  29. package/types/actions/shortcuts.d.ts +1 -1
  30. package/types/actions/types.d.ts +1 -1
  31. package/types/appState.d.ts +7 -10
  32. package/types/components/Actions.d.ts +3 -4
  33. package/types/components/App.d.ts +7 -6
  34. package/types/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  35. package/types/components/LaserTool/LaserPathManager.d.ts +28 -0
  36. package/types/components/LaserTool/LaserPointerButton.d.ts +10 -0
  37. package/types/components/LaserTool/LaserTool.d.ts +7 -0
  38. package/types/components/LayerUI.d.ts +2 -1
  39. package/types/components/dropdownMenu/DropdownMenu.d.ts +6 -3
  40. package/types/components/dropdownMenu/DropdownMenuItem.d.ts +2 -1
  41. package/types/components/dropdownMenu/DropdownMenuItemCustom.d.ts +2 -1
  42. package/types/components/dropdownMenu/DropdownMenuItemLink.d.ts +2 -1
  43. package/types/components/dropdownMenu/common.d.ts +1 -1
  44. package/types/components/icons.d.ts +2 -0
  45. package/types/components/main-menu/MainMenu.d.ts +6 -3
  46. package/types/element/Hyperlink.d.ts +5 -11
  47. package/types/element/embeddable.d.ts +3 -9
  48. package/types/element/linearElementEditor.d.ts +3 -9
  49. package/types/types.d.ts +15 -17
  50. package/types/utils.d.ts +3 -4
@@ -11,10 +11,10 @@ export declare const actionSendBackward: {
11
11
  };
12
12
  contextItemLabel: string;
13
13
  keyPriority: number;
14
- keyTest: (event: KeyboardEvent | React.KeyboardEvent<Element>) => boolean;
14
+ keyTest: (event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean;
15
15
  PanelComponent: ({ updateData, appState }: import("./types").PanelComponentProps) => import("react/jsx-runtime").JSX.Element;
16
16
  } & {
17
- keyTest?: ((event: KeyboardEvent | React.KeyboardEvent<Element>) => boolean) | undefined;
17
+ keyTest?: ((event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean) | undefined;
18
18
  };
19
19
  export declare const actionBringForward: {
20
20
  name: "bringForward";
@@ -28,10 +28,10 @@ export declare const actionBringForward: {
28
28
  };
29
29
  contextItemLabel: string;
30
30
  keyPriority: number;
31
- keyTest: (event: KeyboardEvent | React.KeyboardEvent<Element>) => boolean;
31
+ keyTest: (event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean;
32
32
  PanelComponent: ({ updateData, appState }: import("./types").PanelComponentProps) => import("react/jsx-runtime").JSX.Element;
33
33
  } & {
34
- keyTest?: ((event: KeyboardEvent | React.KeyboardEvent<Element>) => boolean) | undefined;
34
+ keyTest?: ((event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean) | undefined;
35
35
  };
36
36
  export declare const actionSendToBack: {
37
37
  name: "sendToBack";
@@ -44,10 +44,10 @@ export declare const actionSendToBack: {
44
44
  commitToHistory: true;
45
45
  };
46
46
  contextItemLabel: string;
47
- keyTest: (event: KeyboardEvent | React.KeyboardEvent<Element>) => boolean;
47
+ keyTest: (event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean;
48
48
  PanelComponent: ({ updateData, appState }: import("./types").PanelComponentProps) => import("react/jsx-runtime").JSX.Element;
49
49
  } & {
50
- keyTest?: ((event: KeyboardEvent | React.KeyboardEvent<Element>) => boolean) | undefined;
50
+ keyTest?: ((event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean) | undefined;
51
51
  };
52
52
  export declare const actionBringToFront: {
53
53
  name: "bringToFront";
@@ -60,8 +60,8 @@ export declare const actionBringToFront: {
60
60
  commitToHistory: true;
61
61
  };
62
62
  contextItemLabel: string;
63
- keyTest: (event: KeyboardEvent | React.KeyboardEvent<Element>) => boolean;
63
+ keyTest: (event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean;
64
64
  PanelComponent: ({ updateData, appState }: import("./types").PanelComponentProps) => import("react/jsx-runtime").JSX.Element;
65
65
  } & {
66
- keyTest?: ((event: KeyboardEvent | React.KeyboardEvent<Element>) => boolean) | undefined;
66
+ keyTest?: ((event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean) | undefined;
67
67
  };
@@ -1,4 +1,4 @@
1
1
  import { SubtypeOf } from "../utility-types";
2
2
  import { ActionName } from "./types";
3
- export type ShortcutName = SubtypeOf<ActionName, "toggleTheme" | "loadScene" | "clearCanvas" | "cut" | "copy" | "paste" | "copyStyles" | "pasteStyles" | "selectAll" | "deleteSelectedElements" | "duplicateSelection" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyAsPng" | "copyAsSvg" | "group" | "ungroup" | "gridMode" | "zenMode" | "objectsSnapMode" | "stats" | "addToLibrary" | "viewMode" | "flipHorizontal" | "flipVertical" | "hyperlink" | "toggleElementLock"> | "saveScene" | "imageExport";
3
+ export type ShortcutName = SubtypeOf<ActionName, "toggleTheme" | "loadScene" | "clearCanvas" | "cut" | "copy" | "paste" | "copyStyles" | "pasteStyles" | "selectAll" | "deleteSelectedElements" | "duplicateSelection" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyAsPng" | "copyAsSvg" | "group" | "ungroup" | "gridMode" | "zenMode" | "objectsSnapMode" | "stats" | "addToLibrary" | "viewMode" | "flipHorizontal" | "flipVertical" | "hyperlink" | "toggleElementLock" | "toggleLaserPointerTool"> | "saveScene" | "imageExport";
4
4
  export declare const getShortcutFromShortcutName: (name: ShortcutName) => string;
@@ -15,7 +15,7 @@ export type ActionResult = {
15
15
  type ActionFn = (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, formData: any, app: AppClassProperties) => ActionResult | Promise<ActionResult>;
16
16
  export type UpdaterFn = (res: ActionResult) => void;
17
17
  export type ActionFilterFn = (action: Action) => void;
18
- export type ActionName = "copy" | "cut" | "paste" | "copyAsPng" | "copyAsSvg" | "copyText" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyStyles" | "selectAll" | "pasteStyles" | "gridMode" | "zenMode" | "objectsSnapMode" | "stats" | "changeStrokeColor" | "changeBackgroundColor" | "changeFillStyle" | "changeStrokeWidth" | "changeStrokeShape" | "changeSloppiness" | "changeStrokeStyle" | "changeArrowhead" | "changeOpacity" | "changeFontSize" | "toggleCanvasMenu" | "toggleEditMenu" | "undo" | "redo" | "finalize" | "changeProjectName" | "changeExportBackground" | "changeExportEmbedScene" | "changeExportScale" | "saveToActiveFile" | "saveFileToDisk" | "loadScene" | "duplicateSelection" | "deleteSelectedElements" | "changeViewBackgroundColor" | "clearCanvas" | "zoomIn" | "zoomOut" | "resetZoom" | "zoomToFit" | "zoomToFitSelection" | "zoomToFitSelectionInViewport" | "changeFontFamily" | "changeTextAlign" | "changeVerticalAlign" | "toggleFullScreen" | "toggleShortcuts" | "group" | "ungroup" | "goToCollaborator" | "addToLibrary" | "changeRoundness" | "alignTop" | "alignBottom" | "alignLeft" | "alignRight" | "alignVerticallyCentered" | "alignHorizontallyCentered" | "distributeHorizontally" | "distributeVertically" | "flipHorizontal" | "flipVertical" | "viewMode" | "exportWithDarkMode" | "toggleTheme" | "increaseFontSize" | "decreaseFontSize" | "unbindText" | "hyperlink" | "bindText" | "unlockAllElements" | "toggleElementLock" | "toggleLinearEditor" | "toggleEraserTool" | "toggleHandTool" | "selectAllElementsInFrame" | "removeAllElementsFromFrame" | "updateFrameRendering" | "setFrameAsActiveTool" | "setEmbeddableAsActiveTool" | "createContainerFromText" | "wrapTextInContainer";
18
+ export type ActionName = "copy" | "cut" | "paste" | "copyAsPng" | "copyAsSvg" | "copyText" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyStyles" | "selectAll" | "pasteStyles" | "gridMode" | "zenMode" | "objectsSnapMode" | "stats" | "changeStrokeColor" | "changeBackgroundColor" | "changeFillStyle" | "changeStrokeWidth" | "changeStrokeShape" | "changeSloppiness" | "changeStrokeStyle" | "changeArrowhead" | "changeOpacity" | "changeFontSize" | "toggleCanvasMenu" | "toggleEditMenu" | "undo" | "redo" | "finalize" | "changeProjectName" | "changeExportBackground" | "changeExportEmbedScene" | "changeExportScale" | "saveToActiveFile" | "saveFileToDisk" | "loadScene" | "duplicateSelection" | "deleteSelectedElements" | "changeViewBackgroundColor" | "clearCanvas" | "zoomIn" | "zoomOut" | "resetZoom" | "zoomToFit" | "zoomToFitSelection" | "zoomToFitSelectionInViewport" | "changeFontFamily" | "changeTextAlign" | "changeVerticalAlign" | "toggleFullScreen" | "toggleShortcuts" | "group" | "ungroup" | "goToCollaborator" | "addToLibrary" | "changeRoundness" | "alignTop" | "alignBottom" | "alignLeft" | "alignRight" | "alignVerticallyCentered" | "alignHorizontallyCentered" | "distributeHorizontally" | "distributeVertically" | "flipHorizontal" | "flipVertical" | "viewMode" | "exportWithDarkMode" | "toggleTheme" | "increaseFontSize" | "decreaseFontSize" | "unbindText" | "hyperlink" | "bindText" | "unlockAllElements" | "toggleElementLock" | "toggleLinearEditor" | "toggleEraserTool" | "toggleHandTool" | "selectAllElementsInFrame" | "removeAllElementsFromFrame" | "updateFrameRendering" | "setFrameAsActiveTool" | "setEmbeddableAsActiveTool" | "createContainerFromText" | "wrapTextInContainer" | "toggleLaserPointerTool";
19
19
  export type PanelComponentProps = {
20
20
  elements: readonly ExcalidrawElement[];
21
21
  appState: AppState;
@@ -1,18 +1,11 @@
1
1
  import { AppState, NormalizedZoomValue } from "./types";
2
2
  export declare const getDefaultAppState: () => Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
3
3
  export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>) => {
4
- theme?: import("./element/types").Theme | undefined;
5
- name?: string | undefined;
6
4
  activeTool?: ({
7
- lastActiveTool: import("./types").LastActiveTool;
5
+ lastActiveTool: import("./types").ActiveTool | null;
8
6
  locked: boolean;
9
- } & ({
10
- type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand" | "mermaid";
11
- customType: null;
12
- } | {
13
- type: "custom";
14
- customType: string;
15
- })) | undefined;
7
+ } & import("./types").ActiveTool) | undefined;
8
+ name?: string | undefined;
16
9
  penMode?: boolean | undefined;
17
10
  showWelcomeScreen?: boolean | undefined;
18
11
  penDetected?: boolean | undefined;
@@ -56,6 +49,7 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
56
49
  } | undefined;
57
50
  shouldCacheIgnoreZoom?: boolean | undefined;
58
51
  zenModeEnabled?: boolean | undefined;
52
+ theme?: import("./element/types").Theme | undefined;
59
53
  gridSize?: number | null | undefined;
60
54
  selectedGroupIds?: {
61
55
  [groupId: string]: boolean;
@@ -80,3 +74,6 @@ export declare const isEraserActive: ({ activeTool, }: {
80
74
  export declare const isHandToolActive: ({ activeTool, }: {
81
75
  activeTool: AppState["activeTool"];
82
76
  }) => boolean;
77
+ export declare const isLaserPointerActive: ({ activeTool, }: {
78
+ activeTool: AppState["activeTool"];
79
+ }) => boolean;
@@ -1,21 +1,20 @@
1
- import React from "react";
2
1
  import { ActionManager } from "../actions/manager";
3
2
  import { ExcalidrawElement, PointerType } from "../element/types";
4
- import { UIAppState, Zoom } from "../types";
3
+ import { AppClassProperties, UIAppState, Zoom } from "../types";
5
4
  import "./Actions.scss";
6
5
  export declare const SelectedShapeActions: ({ appState, elements, renderAction, }: {
7
6
  appState: UIAppState;
8
7
  elements: readonly ExcalidrawElement[];
9
8
  renderAction: ActionManager["renderAction"];
10
9
  }) => import("react/jsx-runtime").JSX.Element;
11
- export declare const ShapesSwitcher: ({ interactiveCanvas, activeTool, setAppState, onImageAction, appState, }: {
10
+ export declare const ShapesSwitcher: ({ interactiveCanvas, activeTool, onImageAction, appState, app, }: {
12
11
  interactiveCanvas: HTMLCanvasElement | null;
13
12
  activeTool: UIAppState["activeTool"];
14
- setAppState: React.Component<any, UIAppState>["setState"];
15
13
  onImageAction: (data: {
16
14
  pointerType: PointerType | null;
17
15
  }) => void;
18
16
  appState: UIAppState;
17
+ app: AppClassProperties;
19
18
  }) => import("react/jsx-runtime").JSX.Element;
20
19
  export declare const ZoomActions: ({ renderAction, zoom, trayMode, }: {
21
20
  renderAction: ActionManager["renderAction"];
@@ -6,10 +6,10 @@ import { LinearElementEditor } from "../element/linearElementEditor";
6
6
  import { ExcalidrawElement, ExcalidrawLinearElement, NonDeletedExcalidrawElement } from "../element/types";
7
7
  import History from "../history";
8
8
  import Scene from "../scene/Scene";
9
- import { SHAPES } from "../shapes";
10
- import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, Device, FrameNameBoundsCache, SidebarName, SidebarTabName } from "../types";
9
+ import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, Device, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType } from "../types";
11
10
  import { FileSystemHandle } from "../data/filesystem";
12
11
  import { Renderer } from "../scene/Renderer";
12
+ import { LaserPathManager } from "./LaserTool/LaserPathManager";
13
13
  export declare let showFourthFont: boolean;
14
14
  export declare const ExcalidrawContainerContext: React.Context<{
15
15
  container: HTMLDivElement | null;
@@ -56,13 +56,14 @@ declare class App extends React.Component<AppProps, AppState> {
56
56
  imageCache: AppClassProperties["imageCache"];
57
57
  private iFrameRefs;
58
58
  hitLinkElement?: NonDeletedExcalidrawElement;
59
- lastPointerDown: React.PointerEvent<HTMLElement> | null;
60
- lastPointerUp: React.PointerEvent<HTMLElement> | PointerEvent | null;
59
+ lastPointerDownEvent: React.PointerEvent<HTMLElement> | null;
60
+ lastPointerUpEvent: React.PointerEvent<HTMLElement> | PointerEvent | null;
61
61
  lastViewportPosition: {
62
62
  x: number;
63
63
  y: number;
64
64
  };
65
65
  allowMobileMode: boolean;
66
+ laserPathManager: LaserPathManager;
66
67
  constructor(props: AppProps);
67
68
  private onWindowMessage;
68
69
  private updateEmbeddableRef;
@@ -129,7 +130,7 @@ declare class App extends React.Component<AppProps, AppState> {
129
130
  outline: boolean;
130
131
  clip: boolean;
131
132
  }> | ((prevState: AppState["frameRendering"]) => Partial<AppState["frameRendering"]>)) => void;
132
- togglePenMode: () => void;
133
+ togglePenMode: (force?: boolean) => void;
133
134
  onHandToolToggle: () => void;
134
135
  /**
135
136
  * Zooms on canvas viewport center
@@ -192,7 +193,7 @@ declare class App extends React.Component<AppProps, AppState> {
192
193
  private onWheel;
193
194
  private onKeyUp;
194
195
  setActiveTool: (tool: {
195
- type: (typeof SHAPES)[number]["value"] | "eraser" | "hand" | "frame" | "embeddable" | "mermaid";
196
+ type: ToolType;
196
197
  } | {
197
198
  type: "custom";
198
199
  customType: string;
@@ -17,5 +17,5 @@ export type ActiveColorPickerSectionAtomType = "custom" | "baseColors" | "shades
17
17
  export declare const activeColorPickerSectionAtom: import("jotai").PrimitiveAtom<ActiveColorPickerSectionAtomType> & {
18
18
  init: ActiveColorPickerSectionAtomType;
19
19
  };
20
- export declare const getContrastYIQ: (bgHex: string, isCustomColor: boolean) => "black" | "white";
20
+ export declare const getContrastYIQ: (bgHex: string, isCustomColor: boolean) => "white" | "black";
21
21
  export type ColorPickerType = "canvasBackground" | "elementBackground" | "elementStroke";
@@ -0,0 +1,28 @@
1
+ import { LaserPointer } from "@excalidraw/laser-pointer";
2
+ import App from "../App";
3
+ declare global {
4
+ interface Window {
5
+ LPM: LaserPathManager;
6
+ }
7
+ }
8
+ export declare class LaserPathManager {
9
+ private app;
10
+ private ownState;
11
+ private collaboratorsState;
12
+ private rafId;
13
+ private isDrawing;
14
+ private container;
15
+ constructor(app: App);
16
+ destroy(): void;
17
+ startPath(x: number, y: number): void;
18
+ addPointToPath(x: number, y: number): void;
19
+ endPath(): void;
20
+ private updatePath;
21
+ private isRunning;
22
+ start(svg?: SVGSVGElement): void;
23
+ stop(): void;
24
+ loop(): void;
25
+ draw(path: LaserPointer): string;
26
+ updateCollabolatorsState(): void;
27
+ update(): void;
28
+ }
@@ -0,0 +1,10 @@
1
+ import "../ToolIcon.scss";
2
+ type LaserPointerIconProps = {
3
+ title?: string;
4
+ name?: string;
5
+ checked: boolean;
6
+ onChange?(): void;
7
+ isMobile?: boolean;
8
+ };
9
+ export declare const LaserPointerButton: (props: LaserPointerIconProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,7 @@
1
+ import { LaserPathManager } from "./LaserPathManager";
2
+ import "./LaserToolOverlay.scss";
3
+ type LaserToolOverlayProps = {
4
+ manager: LaserPathManager;
5
+ };
6
+ export declare const LaserToolOverlay: ({ manager }: LaserToolOverlayProps) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -28,6 +28,7 @@ interface LayerUIProps {
28
28
  renderWelcomeScreen: boolean;
29
29
  children?: React.ReactNode;
30
30
  app: AppClassProperties;
31
+ isCollaborating: boolean;
31
32
  }
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) => import("react/jsx-runtime").JSX.Element>;
33
+ declare const _default: React.MemoExoticComponent<({ actionManager, appState, files, setAppState, elements, canvas, interactiveCanvas, onLockToggle, onHandToolToggle, onPenModeToggle, showExitZenModeBtn, renderTopRightUI, renderCustomStats, UIOptions, onImageAction, onExportImage, renderWelcomeScreen, children, app, isCollaborating, }: LayerUIProps) => import("react/jsx-runtime").JSX.Element>;
33
34
  export default _default;
@@ -25,29 +25,32 @@ declare const DropdownMenu: {
25
25
  displayName: string;
26
26
  };
27
27
  Item: {
28
- ({ icon, onSelect, children, shortcut, className, ...rest }: {
28
+ ({ icon, onSelect, children, shortcut, className, selected, ...rest }: {
29
29
  icon?: JSX.Element | undefined;
30
30
  onSelect: (event: Event) => void;
31
31
  children: React.ReactNode;
32
32
  shortcut?: string | undefined;
33
+ selected?: boolean | undefined;
33
34
  className?: string | undefined;
34
35
  } & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onSelect">): import("react/jsx-runtime").JSX.Element;
35
36
  displayName: string;
36
37
  };
37
38
  ItemLink: {
38
- ({ icon, shortcut, href, children, onSelect, className, ...rest }: {
39
+ ({ icon, shortcut, href, children, onSelect, className, selected, ...rest }: {
39
40
  href: string;
40
41
  icon?: JSX.Element | undefined;
41
42
  children: React.ReactNode;
42
43
  shortcut?: string | undefined;
43
44
  className?: string | undefined;
45
+ selected?: boolean | undefined;
44
46
  onSelect?: ((event: Event) => void) | undefined;
45
47
  } & React.AnchorHTMLAttributes<HTMLAnchorElement>): import("react/jsx-runtime").JSX.Element;
46
48
  displayName: string;
47
49
  };
48
- ItemCustom: ({ children, className, ...rest }: {
50
+ ItemCustom: ({ children, className, selected, ...rest }: {
49
51
  children: React.ReactNode;
50
52
  className?: string | undefined;
53
+ selected?: boolean | undefined;
51
54
  } & React.HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
52
55
  Group: {
53
56
  ({ children, className, style, title, }: {
@@ -1,10 +1,11 @@
1
1
  import React from "react";
2
2
  declare const DropdownMenuItem: {
3
- ({ icon, onSelect, children, shortcut, className, ...rest }: {
3
+ ({ icon, onSelect, children, shortcut, className, selected, ...rest }: {
4
4
  icon?: JSX.Element | undefined;
5
5
  onSelect: (event: Event) => void;
6
6
  children: React.ReactNode;
7
7
  shortcut?: string | undefined;
8
+ selected?: boolean | undefined;
8
9
  className?: string | undefined;
9
10
  } & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onSelect">): import("react/jsx-runtime").JSX.Element;
10
11
  displayName: string;
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
- declare const DropdownMenuItemCustom: ({ children, className, ...rest }: {
2
+ declare const DropdownMenuItemCustom: ({ children, className, selected, ...rest }: {
3
3
  children: React.ReactNode;
4
4
  className?: string | undefined;
5
+ selected?: boolean | undefined;
5
6
  } & React.HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
6
7
  export default DropdownMenuItemCustom;
@@ -1,11 +1,12 @@
1
1
  import React from "react";
2
2
  declare const DropdownMenuItemLink: {
3
- ({ icon, shortcut, href, children, onSelect, className, ...rest }: {
3
+ ({ icon, shortcut, href, children, onSelect, className, selected, ...rest }: {
4
4
  href: string;
5
5
  icon?: JSX.Element | undefined;
6
6
  children: React.ReactNode;
7
7
  shortcut?: string | undefined;
8
8
  className?: string | undefined;
9
+ selected?: boolean | undefined;
9
10
  onSelect?: ((event: Event) => void) | undefined;
10
11
  } & React.AnchorHTMLAttributes<HTMLAnchorElement>): import("react/jsx-runtime").JSX.Element;
11
12
  displayName: string;
@@ -2,5 +2,5 @@ import React from "react";
2
2
  export declare const DropdownMenuContentPropsContext: React.Context<{
3
3
  onSelect?: ((event: Event) => void) | undefined;
4
4
  }>;
5
- export declare const getDropdownMenuItemClassName: (className?: string) => string;
5
+ export declare const getDropdownMenuItemClassName: (className?: string, selected?: boolean) => string;
6
6
  export declare const useHandleDropdownMenuItemClick: (origOnClick: React.MouseEventHandler<HTMLAnchorElement | HTMLButtonElement> | undefined, onSelect: ((event: Event) => void) | undefined) => (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement, MouseEvent>) => void;
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { Theme } from "../element/types";
3
+ export declare const iconFillColor: (theme: Theme) => string;
3
4
  type Opts = {
4
5
  width?: number;
5
6
  height?: number;
@@ -153,4 +154,5 @@ export declare const extraToolsIcon: import("react/jsx-runtime").JSX.Element;
153
154
  export declare const frameToolIcon: import("react/jsx-runtime").JSX.Element;
154
155
  export declare const mermaidLogoIcon: import("react/jsx-runtime").JSX.Element;
155
156
  export declare const ArrowRightIcon: import("react/jsx-runtime").JSX.Element;
157
+ export declare const laserPointerToolIcon: import("react/jsx-runtime").JSX.Element;
156
158
  export {};
@@ -19,29 +19,32 @@ declare const MainMenu: React.FC<{
19
19
  displayName: string;
20
20
  };
21
21
  Item: {
22
- ({ icon, onSelect, children, shortcut, className, ...rest }: {
22
+ ({ icon, onSelect, children, shortcut, className, selected, ...rest }: {
23
23
  icon?: JSX.Element | undefined;
24
24
  onSelect: (event: Event) => void;
25
25
  children: React.ReactNode;
26
26
  shortcut?: string | undefined;
27
+ selected?: boolean | undefined;
27
28
  className?: string | undefined;
28
29
  } & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onSelect">): import("react/jsx-runtime").JSX.Element;
29
30
  displayName: string;
30
31
  };
31
32
  ItemLink: {
32
- ({ icon, shortcut, href, children, onSelect, className, ...rest }: {
33
+ ({ icon, shortcut, href, children, onSelect, className, selected, ...rest }: {
33
34
  href: string;
34
35
  icon?: JSX.Element | undefined;
35
36
  children: React.ReactNode;
36
37
  shortcut?: string | undefined;
37
38
  className?: string | undefined;
39
+ selected?: boolean | undefined;
38
40
  onSelect?: ((event: Event) => void) | undefined;
39
41
  } & React.AnchorHTMLAttributes<HTMLAnchorElement>): import("react/jsx-runtime").JSX.Element;
40
42
  displayName: string;
41
43
  };
42
- ItemCustom: ({ children, className, ...rest }: {
44
+ ItemCustom: ({ children, className, selected, ...rest }: {
43
45
  children: React.ReactNode;
44
46
  className?: string | undefined;
47
+ selected?: boolean | undefined;
45
48
  } & React.HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
46
49
  Group: {
47
50
  ({ children, className, style, title, }: {
@@ -51,15 +51,9 @@ export declare const actionLink: {
51
51
  editingElement: NonDeletedExcalidrawElement | null;
52
52
  editingLinearElement: import("./linearElementEditor").LinearElementEditor | null;
53
53
  activeTool: {
54
- lastActiveTool: import("../types").LastActiveTool;
54
+ lastActiveTool: import("../types").ActiveTool | null;
55
55
  locked: boolean;
56
- } & ({
57
- type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand" | "mermaid";
58
- customType: null;
59
- } | {
60
- type: "custom";
61
- customType: string;
62
- });
56
+ } & import("../types").ActiveTool;
63
57
  penMode: boolean;
64
58
  penDetected: boolean;
65
59
  exportBackground: boolean;
@@ -162,7 +156,7 @@ export declare const actionLink: {
162
156
  dynamicStyle: string;
163
157
  invertBindingBehaviour: boolean;
164
158
  selectedLinearElement: import("./linearElementEditor").LinearElementEditor | null;
165
- snapLines: import("../snapping").SnapLine[];
159
+ snapLines: readonly import("../snapping").SnapLine[];
166
160
  originSnapOffset: {
167
161
  x: number;
168
162
  y: number;
@@ -175,12 +169,12 @@ export declare const actionLink: {
175
169
  category: "hyperlink";
176
170
  action: string;
177
171
  };
178
- keyTest: (event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean;
172
+ keyTest: (event: import("react").KeyboardEvent<Element> | KeyboardEvent) => boolean;
179
173
  contextItemLabel: (elements: readonly import("./types").ExcalidrawElement[], appState: Readonly<AppState>) => "labels.link.editEmbed" | "labels.link.edit" | "labels.link.createEmbed" | "labels.link.create";
180
174
  predicate: (elements: readonly import("./types").ExcalidrawElement[], appState: AppState) => boolean;
181
175
  PanelComponent: ({ elements, appState, updateData }: import("../actions/types").PanelComponentProps) => import("react/jsx-runtime").JSX.Element;
182
176
  } & {
183
- keyTest?: ((event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean) | undefined;
177
+ keyTest?: ((event: import("react").KeyboardEvent<Element> | KeyboardEvent) => boolean) | undefined;
184
178
  };
185
179
  export declare const getContextMenuLabel: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => "labels.link.editEmbed" | "labels.link.edit" | "labels.link.createEmbed" | "labels.link.create";
186
180
  export declare const getLinkHandleFromCoords: ([x1, y1, x2, y2]: Bounds, angle: number, appState: Pick<UIAppState, "zoom">) => [x: number, y: number, width: number, height: number];
@@ -25,15 +25,9 @@ export declare const actionSetEmbeddableAsActiveTool: {
25
25
  elements: readonly ExcalidrawElement[];
26
26
  appState: {
27
27
  activeTool: {
28
- lastActiveTool: import("../types").LastActiveTool;
28
+ lastActiveTool: import("../types").ActiveTool | null;
29
29
  locked: boolean;
30
- } & ({
31
- type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand" | "mermaid";
32
- customType: null;
33
- } | {
34
- type: "custom";
35
- customType: string;
36
- });
30
+ } & import("../types").ActiveTool;
37
31
  contextMenu: {
38
32
  items: import("../components/ContextMenu").ContextMenuItems;
39
33
  top: number;
@@ -168,7 +162,7 @@ export declare const actionSetEmbeddableAsActiveTool: {
168
162
  dynamicStyle: string;
169
163
  invertBindingBehaviour: boolean;
170
164
  selectedLinearElement: import("./linearElementEditor").LinearElementEditor | null;
171
- snapLines: import("../snapping").SnapLine[];
165
+ snapLines: readonly import("../snapping").SnapLine[];
172
166
  originSnapOffset: {
173
167
  x: number;
174
168
  y: number;
@@ -152,15 +152,9 @@ export declare class LinearElementEditor {
152
152
  elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
153
153
  editingElement: import("./types").NonDeletedExcalidrawElement | null;
154
154
  activeTool: {
155
- lastActiveTool: import("../types").LastActiveTool;
155
+ lastActiveTool: import("../types").ActiveTool | null;
156
156
  locked: boolean;
157
- } & ({
158
- type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand" | "mermaid";
159
- customType: null;
160
- } | {
161
- type: "custom";
162
- customType: string;
163
- });
157
+ } & import("../types").ActiveTool;
164
158
  penMode: boolean;
165
159
  penDetected: boolean;
166
160
  exportBackground: boolean;
@@ -265,7 +259,7 @@ export declare class LinearElementEditor {
265
259
  dynamicStyle: string;
266
260
  invertBindingBehaviour: boolean;
267
261
  selectedLinearElement: LinearElementEditor | null;
268
- snapLines: import("../snapping").SnapLine[];
262
+ snapLines: readonly import("../snapping").SnapLine[];
269
263
  originSnapOffset: {
270
264
  x: number;
271
265
  y: number;
package/types/types.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
2
  import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawFrameElement, ExcalidrawEmbeddableElement } from "./element/types";
3
- import { SHAPES } from "./shapes";
4
3
  import { Point as RoughPoint } from "roughjs/bin/geometry";
5
4
  import { LinearElementEditor } from "./element/linearElementEditor";
6
5
  import { SuggestedBinding } from "./element/binding";
@@ -21,10 +20,7 @@ import { Merge, ForwardRef, ValueOf } from "./utility-types";
21
20
  import { ColorPaletteCustom } from "./colors";
22
21
  export type Point = Readonly<RoughPoint>;
23
22
  export type Collaborator = {
24
- pointer?: {
25
- x: number;
26
- y: number;
27
- };
23
+ pointer?: CollaboratorPointer;
28
24
  button?: "up" | "down";
29
25
  selectedElementIds?: AppState["selectedElementIds"];
30
26
  username?: string | null;
@@ -36,6 +32,11 @@ export type Collaborator = {
36
32
  avatarUrl?: string;
37
33
  id?: string;
38
34
  };
35
+ export type CollaboratorPointer = {
36
+ x: number;
37
+ y: number;
38
+ tool: "pointer" | "laser";
39
+ };
39
40
  export type DataURL = string & {
40
41
  _brand: "DataURL";
41
42
  };
@@ -58,13 +59,14 @@ export type BinaryFileData = {
58
59
  };
59
60
  export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
60
61
  export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
61
- export type LastActiveTool = {
62
- type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame" | "embeddable" | "mermaid";
62
+ export type ToolType = "selection" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "embeddable" | "laser" | "mermaid";
63
+ export type ActiveTool = {
64
+ type: ToolType;
63
65
  customType: null;
64
66
  } | {
65
67
  type: "custom";
66
68
  customType: string;
67
- } | null;
69
+ };
68
70
  export type SidebarName = string;
69
71
  export type SidebarTabName = string;
70
72
  type _CommonCanvasAppState = {
@@ -146,15 +148,9 @@ export type AppState = {
146
148
  * indicates a previous tool we should revert back to if we deselect the
147
149
  * currently active tool. At the moment applies to `eraser` and `hand` tool.
148
150
  */
149
- lastActiveTool: LastActiveTool;
151
+ lastActiveTool: ActiveTool | null;
150
152
  locked: boolean;
151
- } & ({
152
- type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame" | "embeddable" | "mermaid";
153
- customType: null;
154
- } | {
155
- type: "custom";
156
- customType: string;
157
- });
153
+ } & ActiveTool;
158
154
  penMode: boolean;
159
155
  penDetected: boolean;
160
156
  exportBackground: boolean;
@@ -268,7 +264,7 @@ export type AppState = {
268
264
  dynamicStyle: string;
269
265
  invertBindingBehaviour: boolean;
270
266
  selectedLinearElement: LinearElementEditor | null;
271
- snapLines: SnapLine[];
267
+ snapLines: readonly SnapLine[];
272
268
  originSnapOffset: {
273
269
  x: number;
274
270
  y: number;
@@ -332,6 +328,7 @@ export interface ExcalidrawProps {
332
328
  pointer: {
333
329
  x: number;
334
330
  y: number;
331
+ tool: "pointer" | "laser";
335
332
  };
336
333
  button: "down" | "up";
337
334
  pointersMap: Gesture["pointers"];
@@ -439,6 +436,7 @@ export type AppClassProperties = {
439
436
  addFiles: App["addFiles"];
440
437
  setSelection: App["setSelection"];
441
438
  addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
439
+ togglePenMode: App["togglePenMode"];
442
440
  setActiveTool: App["setActiveTool"];
443
441
  };
444
442
  export type PointerDownState = Readonly<{
package/types/utils.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { EVENT } from "./constants";
2
2
  import { FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./element/types";
3
- import { AppState, LastActiveTool, Zoom } from "./types";
4
- import { SHAPES } from "./shapes";
3
+ import { ActiveTool, AppState, ToolType, Zoom } from "./types";
5
4
  export declare const setDateTimeForTests: (dateTime: string) => void;
6
5
  export declare const getDateTime: () => string;
7
6
  export declare const capitalizeString: (str: string) => string;
@@ -81,12 +80,12 @@ export declare const selectNode: (node: Element) => void;
81
80
  export declare const removeSelection: () => void;
82
81
  export declare const distance: (x: number, y: number) => number;
83
82
  export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">, data: ({
84
- type: (typeof SHAPES)[number]["value"] | "eraser" | "hand" | "frame" | "embeddable" | "mermaid";
83
+ type: ToolType;
85
84
  } | {
86
85
  type: "custom";
87
86
  customType: string;
88
87
  }) & {
89
- lastActiveToolBeforeEraser?: LastActiveTool;
88
+ lastActiveToolBeforeEraser?: ActiveTool | null;
90
89
  }) => AppState["activeTool"];
91
90
  export declare const resetCursor: (interactiveCanvas: HTMLCanvasElement | null) => void;
92
91
  export declare const setCursor: (interactiveCanvas: HTMLCanvasElement | null, cursor: string) => void;