@zsviczian/excalidraw 0.15.2-obsidian-1 → 0.15.2-obsidian-3

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 (127) hide show
  1. package/dist/excalidraw.development.js +1438 -364
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/package.json +2 -2
  4. package/types/actions/actionAddToLibrary.d.ts +48 -24
  5. package/types/actions/actionBoundText.d.ts +32 -16
  6. package/types/actions/actionCanvas.d.ts +160 -80
  7. package/types/actions/actionClipboard.d.ts +80 -40
  8. package/types/actions/actionDeleteSelected.d.ts +48 -24
  9. package/types/actions/actionElementLock.d.ts +287 -0
  10. package/types/actions/actionExport.d.ts +145 -73
  11. package/types/actions/actionFinalize.d.ts +32 -16
  12. package/types/actions/actionFlip.d.ts +2 -4
  13. package/types/actions/actionHistory.d.ts +1 -1
  14. package/types/actions/actionLinearEditor.d.ts +16 -8
  15. package/types/actions/actionMenu.d.ts +48 -24
  16. package/types/actions/actionProperties.d.ts +210 -106
  17. package/types/actions/actionStyles.d.ts +16 -8
  18. package/types/actions/actionToggleGridMode.d.ts +16 -8
  19. package/types/actions/actionToggleLock.d.ts +5 -2
  20. package/types/actions/actionToggleStats.d.ts +16 -8
  21. package/types/actions/actionToggleViewMode.d.ts +16 -8
  22. package/types/actions/actionToggleZenMode.d.ts +16 -8
  23. package/types/actions/index.d.ts +1 -1
  24. package/types/actions/manager.d.ts +1 -1
  25. package/types/actions/shortcuts.d.ts +1 -1
  26. package/types/actions/types.d.ts +7 -7
  27. package/types/appState.d.ts +5 -2
  28. package/types/charts.d.ts +2 -2
  29. package/types/clients.d.ts +4 -1
  30. package/types/clipboard.d.ts +2 -2
  31. package/types/colors.d.ts +59 -5
  32. package/types/components/Actions.d.ts +5 -5
  33. package/types/components/App.d.ts +13 -3
  34. package/types/components/Avatar.d.ts +1 -1
  35. package/types/components/Button.d.ts +3 -1
  36. package/types/components/ColorPicker/ColorInput.d.ts +7 -0
  37. package/types/components/ColorPicker/ColorPicker.d.ts +18 -0
  38. package/types/components/ColorPicker/CustomColorList.d.ts +8 -0
  39. package/types/components/ColorPicker/HotkeyLabel.d.ts +8 -0
  40. package/types/components/ColorPicker/Picker.d.ts +16 -0
  41. package/types/components/ColorPicker/PickerColorList.d.ts +10 -0
  42. package/types/components/ColorPicker/PickerHeading.d.ts +5 -0
  43. package/types/components/ColorPicker/ShadeList.d.ts +8 -0
  44. package/types/components/ColorPicker/TopPicks.d.ts +9 -0
  45. package/types/components/ColorPicker/colorPickerUtils.d.ts +41 -0
  46. package/types/components/ColorPicker/keyboardNavHandlers.d.ts +16 -0
  47. package/types/components/ContextMenu.d.ts +3 -3
  48. package/types/components/DefaultSidebar.d.ts +30 -0
  49. package/types/components/Dialog.d.ts +2 -2
  50. package/types/components/FilledButton.d.ts +16 -0
  51. package/types/components/FixedSideContainer.d.ts +1 -1
  52. package/types/components/HandButton.d.ts +1 -1
  53. package/types/components/HelpButton.d.ts +1 -1
  54. package/types/components/HintViewer.d.ts +2 -2
  55. package/types/components/ImageExportDialog.d.ts +8 -13
  56. package/types/components/Island.d.ts +1 -1
  57. package/types/components/JSONExportDialog.d.ts +4 -4
  58. package/types/components/LayerUI.d.ts +4 -10
  59. package/types/components/LibraryMenu.d.ts +33 -14
  60. package/types/components/LibraryMenuBrowseButton.d.ts +2 -2
  61. package/types/components/LibraryMenuControlButtons.d.ts +9 -0
  62. package/types/components/LibraryMenuHeaderContent.d.ts +11 -28
  63. package/types/components/LibraryMenuItems.d.ts +6 -7
  64. package/types/components/LibraryMenuSection.d.ts +22 -0
  65. package/types/components/LibraryUnit.d.ts +7 -3
  66. package/types/components/LockButton.d.ts +1 -1
  67. package/types/components/MobileMenu.d.ts +4 -4
  68. package/types/components/PasteChartDialog.d.ts +4 -5
  69. package/types/components/PenModeButton.d.ts +1 -1
  70. package/types/components/Popover.d.ts +1 -1
  71. package/types/components/ProjectName.d.ts +2 -1
  72. package/types/components/PublishLibrary.d.ts +2 -2
  73. package/types/components/RadioGroup.d.ts +12 -0
  74. package/types/components/Sidebar/Sidebar.d.ts +68 -45
  75. package/types/components/Sidebar/SidebarHeader.d.ts +6 -19
  76. package/types/components/Sidebar/SidebarTab.d.ts +9 -0
  77. package/types/components/Sidebar/SidebarTabTrigger.d.ts +10 -0
  78. package/types/components/Sidebar/SidebarTabTriggers.d.ts +7 -0
  79. package/types/components/Sidebar/SidebarTabs.d.ts +7 -0
  80. package/types/components/Sidebar/SidebarTrigger.d.ts +6 -0
  81. package/types/components/Sidebar/common.d.ts +24 -7
  82. package/types/components/Spinner.d.ts +2 -1
  83. package/types/components/Stack.d.ts +4 -3
  84. package/types/components/Stats.d.ts +3 -3
  85. package/types/components/Switch.d.ts +9 -0
  86. package/types/components/ToolButton.d.ts +3 -3
  87. package/types/components/Tooltip.d.ts +1 -1
  88. package/types/components/Trans.d.ts +8 -0
  89. package/types/components/footer/Footer.d.ts +2 -2
  90. package/types/components/icons.d.ts +7 -1
  91. package/types/constants.d.ts +10 -0
  92. package/types/context/tunnels.d.ts +18 -0
  93. package/types/context/ui-appState.d.ts +4 -0
  94. package/types/data/encode.d.ts +1 -1
  95. package/types/data/filesystem.d.ts +1 -1
  96. package/types/data/library.d.ts +2 -0
  97. package/types/data/restore.d.ts +2 -2
  98. package/types/data/types.d.ts +3 -5
  99. package/types/element/Hyperlink.d.ts +18 -10
  100. package/types/element/binding.d.ts +2 -2
  101. package/types/element/bounds.d.ts +1 -1
  102. package/types/element/linearElementEditor.d.ts +16 -8
  103. package/types/element/mutateElement.d.ts +1 -1
  104. package/types/element/newElement.d.ts +7 -2
  105. package/types/element/resizeElements.d.ts +1 -0
  106. package/types/element/showSelectedShapeActions.d.ts +2 -2
  107. package/types/element/textElement.d.ts +2 -2
  108. package/types/element/transformHandles.d.ts +5 -5
  109. package/types/element/types.d.ts +35 -35
  110. package/types/errors.d.ts +1 -1
  111. package/types/ga.d.ts +5 -5
  112. package/types/hooks/useLibraryItemSvg.d.ts +31 -0
  113. package/types/hooks/useOutsideClick.d.ts +1 -1
  114. package/types/hooks/useScrollPosition.d.ts +2 -0
  115. package/types/hooks/useTransition.d.ts +2 -0
  116. package/types/i18n.d.ts +2 -2
  117. package/types/keys.d.ts +1 -1
  118. package/types/packages/excalidraw/index.d.ts +3 -2
  119. package/types/packages/utils.d.ts +3 -3
  120. package/types/renderer/easingFunctions.d.ts +1 -1
  121. package/types/renderer/renderElement.d.ts +2 -2
  122. package/types/scene/Scene.d.ts +4 -4
  123. package/types/scene/selection.d.ts +4 -4
  124. package/types/scene/types.d.ts +4 -4
  125. package/types/types.d.ts +65 -46
  126. package/types/utility-types.d.ts +13 -13
  127. package/types/utils.d.ts +5 -5
@@ -66,10 +66,13 @@ export declare const actionToggleStats: {
66
66
  value: import("../types").NormalizedZoomValue;
67
67
  }>;
68
68
  openMenu: "canvas" | "shape" | null;
69
- openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
70
- openSidebar: "library" | "customSidebar" | null;
69
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
70
+ openSidebar: {
71
+ name: string;
72
+ tab?: string | undefined;
73
+ } | null;
71
74
  openDialog: "imageExport" | "help" | "jsonExport" | null;
72
- isSidebarDocked: boolean;
75
+ defaultSidebarDockedPreference: boolean;
73
76
  lastPointerDownWith: import("../element/types").PointerType;
74
77
  selectedElementIds: {
75
78
  [id: string]: boolean;
@@ -110,11 +113,16 @@ export declare const actionToggleStats: {
110
113
  showHyperlinkPopup: false | "info" | "editor";
111
114
  linkOpacity: number;
112
115
  trayModeEnabled: boolean;
113
- colorPalette: {
114
- canvasBackground?: string[] | undefined;
115
- elementBackground?: string[] | undefined;
116
- elementStroke?: string[] | undefined;
117
- };
116
+ colorPalette?: {
117
+ canvasBackground: import("../colors").ColorPaletteCustom;
118
+ elementBackground: import("../colors").ColorPaletteCustom;
119
+ elementStroke: import("../colors").ColorPaletteCustom;
120
+ topPicks: {
121
+ canvasBackground: [string, string, string, string, string];
122
+ elementStroke: [string, string, string, string, string];
123
+ elementBackground: [string, string, string, string, string];
124
+ };
125
+ } | undefined;
118
126
  allowWheelZoom?: boolean | undefined;
119
127
  allowPinchZoom?: boolean | undefined;
120
128
  pinnedScripts?: string[] | undefined;
@@ -67,10 +67,13 @@ export declare const actionToggleViewMode: {
67
67
  value: import("../types").NormalizedZoomValue;
68
68
  }>;
69
69
  openMenu: "canvas" | "shape" | null;
70
- openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
71
- openSidebar: "library" | "customSidebar" | null;
70
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
71
+ openSidebar: {
72
+ name: string;
73
+ tab?: string | undefined;
74
+ } | null;
72
75
  openDialog: "imageExport" | "help" | "jsonExport" | null;
73
- isSidebarDocked: boolean;
76
+ defaultSidebarDockedPreference: boolean;
74
77
  lastPointerDownWith: import("../element/types").PointerType;
75
78
  selectedElementIds: {
76
79
  [id: string]: boolean;
@@ -111,11 +114,16 @@ export declare const actionToggleViewMode: {
111
114
  showHyperlinkPopup: false | "info" | "editor";
112
115
  linkOpacity: number;
113
116
  trayModeEnabled: boolean;
114
- colorPalette: {
115
- canvasBackground?: string[] | undefined;
116
- elementBackground?: string[] | undefined;
117
- elementStroke?: string[] | undefined;
118
- };
117
+ colorPalette?: {
118
+ canvasBackground: import("../colors").ColorPaletteCustom;
119
+ elementBackground: import("../colors").ColorPaletteCustom;
120
+ elementStroke: import("../colors").ColorPaletteCustom;
121
+ topPicks: {
122
+ canvasBackground: [string, string, string, string, string];
123
+ elementStroke: [string, string, string, string, string];
124
+ elementBackground: [string, string, string, string, string];
125
+ };
126
+ } | undefined;
119
127
  allowWheelZoom?: boolean | undefined;
120
128
  allowPinchZoom?: boolean | undefined;
121
129
  pinnedScripts?: string[] | undefined;
@@ -67,10 +67,13 @@ export declare const actionToggleZenMode: {
67
67
  value: import("../types").NormalizedZoomValue;
68
68
  }>;
69
69
  openMenu: "canvas" | "shape" | null;
70
- openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
71
- openSidebar: "library" | "customSidebar" | null;
70
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
71
+ openSidebar: {
72
+ name: string;
73
+ tab?: string | undefined;
74
+ } | null;
72
75
  openDialog: "imageExport" | "help" | "jsonExport" | null;
73
- isSidebarDocked: boolean;
76
+ defaultSidebarDockedPreference: boolean;
74
77
  lastPointerDownWith: import("../element/types").PointerType;
75
78
  selectedElementIds: {
76
79
  [id: string]: boolean;
@@ -111,11 +114,16 @@ export declare const actionToggleZenMode: {
111
114
  showHyperlinkPopup: false | "info" | "editor";
112
115
  linkOpacity: number;
113
116
  trayModeEnabled: boolean;
114
- colorPalette: {
115
- canvasBackground?: string[] | undefined;
116
- elementBackground?: string[] | undefined;
117
- elementStroke?: string[] | undefined;
118
- };
117
+ colorPalette?: {
118
+ canvasBackground: import("../colors").ColorPaletteCustom;
119
+ elementBackground: import("../colors").ColorPaletteCustom;
120
+ elementStroke: import("../colors").ColorPaletteCustom;
121
+ topPicks: {
122
+ canvasBackground: [string, string, string, string, string];
123
+ elementStroke: [string, string, string, string, string];
124
+ elementBackground: [string, string, string, string, string];
125
+ };
126
+ } | undefined;
119
127
  allowWheelZoom?: boolean | undefined;
120
128
  allowPinchZoom?: boolean | undefined;
121
129
  pinnedScripts?: string[] | undefined;
@@ -20,5 +20,5 @@ export { actionToggleZenMode } from "./actionToggleZenMode";
20
20
  export { actionToggleStats } from "./actionToggleStats";
21
21
  export { actionUnbindText, actionBindText } from "./actionBoundText";
22
22
  export { actionLink } from "../element/Hyperlink";
23
- export { actionToggleLock } from "./actionToggleLock";
23
+ export { actionToggleElementLock } from "./actionElementLock";
24
24
  export { actionToggleLinearEditor } from "./actionLinearEditor";
@@ -12,7 +12,7 @@ export declare class ActionManager {
12
12
  registerAction(action: Action): void;
13
13
  registerAll(actions: readonly Action[]): void;
14
14
  handleKeyDown(event: React.KeyboardEvent | KeyboardEvent): boolean;
15
- executeAction(action: Action, source?: ActionSource): void;
15
+ executeAction(action: Action, source?: ActionSource, value?: any): void;
16
16
  /**
17
17
  * @param data additional data sent to the PanelComponent
18
18
  */
@@ -1,4 +1,4 @@
1
1
  import { SubtypeOf } from "../utility-types";
2
2
  import { ActionName } from "./types";
3
- export declare 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" | "stats" | "addToLibrary" | "viewMode" | "flipHorizontal" | "flipVertical" | "hyperlink" | "toggleLock"> | "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" | "stats" | "addToLibrary" | "viewMode" | "flipHorizontal" | "flipVertical" | "hyperlink" | "toggleElementLock"> | "saveScene" | "imageExport";
4
4
  export declare const getShortcutFromShortcutName: (name: ShortcutName) => string;
@@ -2,9 +2,9 @@ import React from "react";
2
2
  import { ExcalidrawElement } from "../element/types";
3
3
  import { AppClassProperties, AppState, ExcalidrawProps, BinaryFiles } from "../types";
4
4
  import { MarkOptional } from "../utility-types";
5
- export declare type ActionSource = "ui" | "keyboard" | "contextMenu" | "api";
5
+ export type ActionSource = "ui" | "keyboard" | "contextMenu" | "api";
6
6
  /** if false, the action should be prevented */
7
- export declare type ActionResult = {
7
+ export type ActionResult = {
8
8
  elements?: readonly ExcalidrawElement[] | null;
9
9
  appState?: MarkOptional<AppState, "offsetTop" | "offsetLeft" | "width" | "height"> | null;
10
10
  files?: BinaryFiles | null;
@@ -12,11 +12,11 @@ export declare type ActionResult = {
12
12
  syncHistory?: boolean;
13
13
  replaceFiles?: boolean;
14
14
  } | false;
15
- declare type ActionFn = (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, formData: any, app: AppClassProperties) => ActionResult | Promise<ActionResult>;
16
- export declare type UpdaterFn = (res: ActionResult) => void;
17
- export declare type ActionFilterFn = (action: Action) => void;
18
- export declare type ActionName = "copy" | "cut" | "paste" | "copyAsPng" | "copyAsSvg" | "copyText" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyStyles" | "selectAll" | "pasteStyles" | "gridMode" | "zenMode" | "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" | "zoomToSelection" | "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" | "toggleLock" | "toggleLinearEditor" | "toggleEraserTool" | "toggleHandTool" | "wrapTextInContainer";
19
- export declare type PanelComponentProps = {
15
+ type ActionFn = (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, formData: any, app: AppClassProperties) => ActionResult | Promise<ActionResult>;
16
+ export type UpdaterFn = (res: ActionResult) => void;
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" | "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" | "zoomToSelection" | "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" | "wrapTextInContainer";
19
+ export type PanelComponentProps = {
20
20
  elements: readonly ExcalidrawElement[];
21
21
  appState: AppState;
22
22
  updateData: (formData?: any) => void;
@@ -42,8 +42,11 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
42
42
  value: NormalizedZoomValue;
43
43
  }> | undefined;
44
44
  openMenu?: "canvas" | "shape" | null | undefined;
45
- openSidebar?: "library" | "customSidebar" | null | undefined;
46
- isSidebarDocked?: boolean | undefined;
45
+ openSidebar?: {
46
+ name: string;
47
+ tab?: string | undefined;
48
+ } | null | undefined;
49
+ defaultSidebarDockedPreference?: boolean | undefined;
47
50
  lastPointerDownWith?: import("./element/types").PointerType | undefined;
48
51
  selectedElementIds?: {
49
52
  [id: string]: boolean;
package/types/charts.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NonDeletedExcalidrawElement } from "./element/types";
2
- export declare type ChartElements = readonly NonDeletedExcalidrawElement[];
2
+ export type ChartElements = readonly NonDeletedExcalidrawElement[];
3
3
  export interface Spreadsheet {
4
4
  title: string | null;
5
5
  labels: string[] | null;
@@ -7,7 +7,7 @@ export interface Spreadsheet {
7
7
  }
8
8
  export declare const NOT_SPREADSHEET = "NOT_SPREADSHEET";
9
9
  export declare const VALID_SPREADSHEET = "VALID_SPREADSHEET";
10
- declare type ParseSpreadsheetResult = {
10
+ type ParseSpreadsheetResult = {
11
11
  type: typeof NOT_SPREADSHEET;
12
12
  reason: string;
13
13
  } | {
@@ -3,4 +3,7 @@ export declare const getClientColors: (clientId: string, appState: AppState) =>
3
3
  background: string;
4
4
  stroke: string;
5
5
  };
6
- export declare const getClientInitials: (userName?: string | null) => string;
6
+ /**
7
+ * returns first char, capitalized
8
+ */
9
+ export declare const getNameInitial: (name?: string | null) => string;
@@ -1,5 +1,5 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement } from "./element/types";
2
- import { AppState, BinaryFiles } from "./types";
2
+ import { BinaryFiles } from "./types";
3
3
  import { Spreadsheet } from "./charts";
4
4
  export interface ClipboardData {
5
5
  spreadsheet?: Spreadsheet;
@@ -11,7 +11,7 @@ export interface ClipboardData {
11
11
  export declare const probablySupportsClipboardReadText: boolean;
12
12
  export declare const probablySupportsClipboardWriteText: boolean;
13
13
  export declare const probablySupportsClipboardBlob: boolean;
14
- export declare const copyToClipboard: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles | null) => Promise<void>;
14
+ export declare const copyToClipboard: (elements: readonly NonDeletedExcalidrawElement[], files: BinaryFiles | null) => Promise<string | undefined>;
15
15
  /**
16
16
  * Retrieves content from system clipboard (either from ClipboardEvent or
17
17
  * via async clipboard API if supported)
package/types/colors.d.ts CHANGED
@@ -1,6 +1,60 @@
1
- declare const _default: {
2
- canvasBackground: string[];
3
- elementBackground: string[];
4
- elementStroke: string[];
1
+ import oc from "open-color";
2
+ import { Merge } from "./utility-types";
3
+ export type ColorPickerColor = Exclude<keyof oc, "indigo" | "lime"> | "transparent" | "bronze";
4
+ export type ColorTuple = readonly [string, string, string, string, string];
5
+ export type ColorPalette = Merge<Record<ColorPickerColor, ColorTuple>, {
6
+ black: string;
7
+ white: string;
8
+ transparent: string;
9
+ }>;
10
+ export type ColorPaletteCustom = {
11
+ [key: string]: ColorTuple | string;
5
12
  };
6
- export default _default;
13
+ export type ColorShadesIndexes = [number, number, number, number, number];
14
+ export declare const MAX_CUSTOM_COLORS_USED_IN_CANVAS = 5;
15
+ export declare const COLORS_PER_ROW = 5;
16
+ export declare const DEFAULT_CHART_COLOR_INDEX = 4;
17
+ export declare const DEFAULT_ELEMENT_STROKE_COLOR_INDEX = 4;
18
+ export declare const DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX = 1;
19
+ export declare const ELEMENTS_PALETTE_SHADE_INDEXES: readonly [0, 2, 4, 6, 8];
20
+ export declare const CANVAS_PALETTE_SHADE_INDEXES: readonly [0, 1, 2, 3, 4];
21
+ export declare const getSpecificColorShades: (color: Exclude<ColorPickerColor, "transparent" | "white" | "black" | "bronze">, indexArr: readonly [number, number, number, number, number]) => ColorTuple;
22
+ export declare const COLOR_PALETTE: ColorPalette;
23
+ export declare const DEFAULT_ELEMENT_STROKE_PICKS: ColorTuple;
24
+ export declare const DEFAULT_ELEMENT_BACKGROUND_PICKS: ColorTuple;
25
+ export declare const DEFAULT_CANVAS_BACKGROUND_PICKS: ColorTuple;
26
+ export declare const DEFAULT_ELEMENT_STROKE_COLOR_PALETTE: {
27
+ readonly red: ColorTuple;
28
+ readonly pink: ColorTuple;
29
+ readonly grape: ColorTuple;
30
+ readonly violet: ColorTuple;
31
+ readonly blue: ColorTuple;
32
+ readonly cyan: ColorTuple;
33
+ readonly teal: ColorTuple;
34
+ readonly green: ColorTuple;
35
+ readonly yellow: ColorTuple;
36
+ readonly orange: ColorTuple;
37
+ readonly transparent: string;
38
+ readonly white: string;
39
+ readonly gray: ColorTuple;
40
+ readonly black: string;
41
+ readonly bronze: ColorTuple;
42
+ };
43
+ export declare const DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE: {
44
+ readonly red: ColorTuple;
45
+ readonly pink: ColorTuple;
46
+ readonly grape: ColorTuple;
47
+ readonly violet: ColorTuple;
48
+ readonly blue: ColorTuple;
49
+ readonly cyan: ColorTuple;
50
+ readonly teal: ColorTuple;
51
+ readonly green: ColorTuple;
52
+ readonly yellow: ColorTuple;
53
+ readonly orange: ColorTuple;
54
+ readonly transparent: string;
55
+ readonly white: string;
56
+ readonly gray: ColorTuple;
57
+ readonly black: string;
58
+ readonly bronze: ColorTuple;
59
+ };
60
+ export declare const getAllColorsSpecificShade: (index: 0 | 1 | 2 | 3 | 4) => readonly [string, string, string, string, string, string, string, string, string, string];
@@ -1,21 +1,21 @@
1
1
  import React from "react";
2
2
  import { ActionManager } from "../actions/manager";
3
3
  import { ExcalidrawElement, PointerType } from "../element/types";
4
- import { AppState, Zoom } from "../types";
4
+ import { UIAppState, Zoom } from "../types";
5
5
  import "./Actions.scss";
6
6
  export declare const SelectedShapeActions: ({ appState, elements, renderAction, }: {
7
- appState: AppState;
7
+ appState: UIAppState;
8
8
  elements: readonly ExcalidrawElement[];
9
9
  renderAction: ActionManager["renderAction"];
10
10
  }) => JSX.Element;
11
11
  export declare const ShapesSwitcher: ({ canvas, activeTool, setAppState, onImageAction, appState, }: {
12
12
  canvas: HTMLCanvasElement | null;
13
- activeTool: AppState["activeTool"];
14
- setAppState: React.Component<any, AppState>["setState"];
13
+ activeTool: UIAppState["activeTool"];
14
+ setAppState: React.Component<any, UIAppState>["setState"];
15
15
  onImageAction: (data: {
16
16
  pointerType: PointerType | null;
17
17
  }) => void;
18
- appState: AppState;
18
+ appState: UIAppState;
19
19
  }) => JSX.Element;
20
20
  export declare const ZoomActions: ({ renderAction, zoom, trayMode, }: {
21
21
  renderAction: ActionManager["renderAction"];
@@ -1,12 +1,13 @@
1
1
  import React from "react";
2
2
  import { RoughCanvas } from "roughjs/bin/canvas";
3
3
  import { ActionManager } from "../actions/manager";
4
+ import { EXPORT_IMAGE_TYPES } from "../constants";
4
5
  import { RestoredDataState } from "../data/restore";
5
6
  import { LinearElementEditor } from "../element/linearElementEditor";
6
7
  import { ExcalidrawElement, ExcalidrawLinearElement, NonDeletedExcalidrawElement } from "../element/types";
7
8
  import History from "../history";
8
9
  import Scene from "../scene/Scene";
9
- import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, Device } from "../types";
10
+ import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, Device, SidebarName, SidebarTabName } from "../types";
10
11
  import { FileSystemHandle } from "../data/filesystem";
11
12
  import { ImportedDataState } from "../data/types";
12
13
  export declare let showFourthFont: boolean;
@@ -14,11 +15,14 @@ export declare const ExcalidrawContainerContext: React.Context<{
14
15
  container: HTMLDivElement | null;
15
16
  id: string | null;
16
17
  }>;
18
+ export declare const useApp: () => AppClassProperties;
19
+ export declare const useAppProps: () => AppProps;
17
20
  export declare const useDevice: () => Readonly<{
18
21
  isSmScreen: boolean;
19
22
  isMobile: boolean;
20
23
  isTouchScreen: boolean;
21
24
  canDeviceFitSidebar: boolean;
25
+ isLandscape: boolean;
22
26
  }>;
23
27
  export declare const useExcalidrawContainer: () => {
24
28
  container: HTMLDivElement | null;
@@ -43,7 +47,7 @@ declare class App extends React.Component<AppProps, AppState> {
43
47
  private nearestScrollableContainer;
44
48
  library: AppClassProperties["library"];
45
49
  libraryItemsFromStorage: LibraryItems | undefined;
46
- private id;
50
+ id: string;
47
51
  private history;
48
52
  private excalidrawContainerValue;
49
53
  files: BinaryFiles;
@@ -62,6 +66,8 @@ declare class App extends React.Component<AppProps, AppState> {
62
66
  focusContainer: AppClassProperties["focusContainer"];
63
67
  getSceneElementsIncludingDeleted: () => readonly ExcalidrawElement[];
64
68
  getSceneElements: () => readonly NonDeletedExcalidrawElement[];
69
+ onInsertElements: (elements: readonly ExcalidrawElement[]) => void;
70
+ onExportImage: (type: keyof typeof EXPORT_IMAGE_TYPES, elements: readonly NonDeletedExcalidrawElement[]) => Promise<void>;
65
71
  private syncActionResult;
66
72
  private onBlur;
67
73
  private onUnload;
@@ -138,7 +144,11 @@ declare class App extends React.Component<AppProps, AppState> {
138
144
  /**
139
145
  * @returns whether the menu was toggled on or off
140
146
  */
141
- toggleMenu: (type: "library" | "customSidebar", force?: boolean) => boolean;
147
+ toggleSidebar: ({ name, tab, force, }: {
148
+ name: SidebarName;
149
+ tab?: string | undefined;
150
+ force?: boolean | undefined;
151
+ }) => boolean;
142
152
  private updateCurrentCursorPosition;
143
153
  private onKeyDown;
144
154
  private onWheel;
@@ -1,6 +1,6 @@
1
1
  import "./Avatar.scss";
2
2
  import React from "react";
3
- declare type AvatarProps = {
3
+ type AvatarProps = {
4
4
  onClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
5
5
  color: string;
6
6
  border: string;
@@ -3,6 +3,8 @@ import "./Button.scss";
3
3
  interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
4
4
  type?: "button" | "submit" | "reset";
5
5
  onSelect: () => any;
6
+ /** whether button is in active state */
7
+ selected?: boolean;
6
8
  children: React.ReactNode;
7
9
  className?: string;
8
10
  }
@@ -11,5 +13,5 @@ interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
11
13
  * Style can be customised using `className` or `style` prop.
12
14
  * Accepts all props that a regular `button` element accepts.
13
15
  */
14
- export declare const Button: ({ type, onSelect, children, className, ...rest }: ButtonProps) => JSX.Element;
16
+ export declare const Button: ({ type, onSelect, selected, children, className, ...rest }: ButtonProps) => JSX.Element;
15
17
  export {};
@@ -0,0 +1,7 @@
1
+ interface ColorInputProps {
2
+ color: string | null;
3
+ onChange: (color: string) => void;
4
+ label: string;
5
+ }
6
+ export declare const ColorInput: ({ color, onChange, label }: ColorInputProps) => JSX.Element;
7
+ export {};
@@ -0,0 +1,18 @@
1
+ import { ExcalidrawElement } from "../../element/types";
2
+ import { AppState } from "../../types";
3
+ import { ColorPickerType } from "./colorPickerUtils";
4
+ import { ColorTuple, ColorPaletteCustom } from "../../colors";
5
+ import "./ColorPicker.scss";
6
+ export declare const getColor: (color: string) => string | null;
7
+ export interface ColorPickerProps {
8
+ type: ColorPickerType;
9
+ color: string | null;
10
+ onChange: (color: string) => void;
11
+ label: string;
12
+ elements: readonly ExcalidrawElement[];
13
+ appState: AppState;
14
+ palette?: ColorPaletteCustom | null;
15
+ topPicks?: ColorTuple;
16
+ updateData: (formData?: any) => void;
17
+ }
18
+ export declare const ColorPicker: ({ type, color, onChange, label, elements, palette, topPicks, updateData, appState, }: ColorPickerProps) => JSX.Element;
@@ -0,0 +1,8 @@
1
+ interface CustomColorListProps {
2
+ colors: string[];
3
+ color: string | null;
4
+ onChange: (color: string) => void;
5
+ label: string;
6
+ }
7
+ export declare const CustomColorList: ({ colors, color, onChange, label, }: CustomColorListProps) => JSX.Element;
8
+ export {};
@@ -0,0 +1,8 @@
1
+ interface HotkeyLabelProps {
2
+ color: string;
3
+ keyLabel: string | number;
4
+ isCustomColor?: boolean;
5
+ isShade?: boolean;
6
+ }
7
+ declare const HotkeyLabel: ({ color, keyLabel, isCustomColor, isShade, }: HotkeyLabelProps) => JSX.Element;
8
+ export default HotkeyLabel;
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import { ExcalidrawElement } from "../../element/types";
3
+ import { ColorPickerType } from "./colorPickerUtils";
4
+ import { ColorPaletteCustom } from "../../colors";
5
+ interface PickerProps {
6
+ color: string | null;
7
+ onChange: (color: string) => void;
8
+ label: string;
9
+ type: ColorPickerType;
10
+ elements: readonly ExcalidrawElement[];
11
+ palette: ColorPaletteCustom;
12
+ updateData: (formData?: any) => void;
13
+ children?: React.ReactNode;
14
+ }
15
+ export declare const Picker: ({ color, onChange, label, type, elements, palette, updateData, children, }: PickerProps) => JSX.Element;
16
+ export {};
@@ -0,0 +1,10 @@
1
+ import { ColorPaletteCustom } from "../../colors";
2
+ interface PickerColorListProps {
3
+ palette: ColorPaletteCustom;
4
+ color: string | null;
5
+ onChange: (color: string) => void;
6
+ label: string;
7
+ activeShade: number;
8
+ }
9
+ declare const PickerColorList: ({ palette, color, onChange, label, activeShade, }: PickerColorListProps) => JSX.Element;
10
+ export default PickerColorList;
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from "react";
2
+ declare const PickerHeading: ({ children }: {
3
+ children: ReactNode;
4
+ }) => JSX.Element;
5
+ export default PickerHeading;
@@ -0,0 +1,8 @@
1
+ import { ColorPaletteCustom } from "../../colors";
2
+ interface ShadeListProps {
3
+ hex: string | null;
4
+ onChange: (color: string) => void;
5
+ palette: ColorPaletteCustom;
6
+ }
7
+ export declare const ShadeList: ({ hex, onChange, palette }: ShadeListProps) => JSX.Element;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ColorPickerType } from "./colorPickerUtils";
2
+ interface TopPicksProps {
3
+ onChange: (color: string) => void;
4
+ type: ColorPickerType;
5
+ activeColor: string | null;
6
+ topPicks?: readonly string[];
7
+ }
8
+ export declare const TopPicks: ({ onChange, type, activeColor, topPicks, }: TopPicksProps) => JSX.Element | null;
9
+ export {};
@@ -0,0 +1,41 @@
1
+ import { ExcalidrawElement } from "../../element/types";
2
+ import { ColorPickerColor, ColorPaletteCustom } from "../../colors";
3
+ export declare const getColorNameAndShadeFromHex: ({ palette, hex, }: {
4
+ palette: ColorPaletteCustom;
5
+ hex: string;
6
+ }) => {
7
+ colorName: ColorPickerColor;
8
+ shade: number | null;
9
+ } | null;
10
+ export declare const colorPickerHotkeyBindings: string[];
11
+ export declare const isCustomColor: ({ color, palette, }: {
12
+ color: string | null;
13
+ palette: ColorPaletteCustom;
14
+ }) => boolean;
15
+ export declare const getMostUsedCustomColors: (elements: readonly ExcalidrawElement[], type: "elementBackground" | "elementStroke", palette: ColorPaletteCustom) => string[];
16
+ export type ActiveColorPickerSectionAtomType = "custom" | "baseColors" | "shades" | "hex" | null;
17
+ export declare const activeColorPickerSectionAtom: import("jotai").Atom<ActiveColorPickerSectionAtomType> & {
18
+ write: (get: {
19
+ <Value>(atom: import("jotai").Atom<Value | Promise<Value>>): Value;
20
+ <Value_1>(atom: import("jotai").Atom<Promise<Value_1>>): Value_1;
21
+ <Value_2>(atom: import("jotai").Atom<Value_2>): Value_2 extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : Value_2;
22
+ } & {
23
+ <Value_3>(atom: import("jotai").Atom<Value_3 | Promise<Value_3>>, options: {
24
+ unstable_promise: true;
25
+ }): Value_3 | Promise<Value_3>;
26
+ <Value_4>(atom: import("jotai").Atom<Promise<Value_4>>, options: {
27
+ unstable_promise: true;
28
+ }): Value_4 | Promise<Value_4>;
29
+ <Value_5>(atom: import("jotai").Atom<Value_5>, options: {
30
+ unstable_promise: true;
31
+ }): (Value_5 extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : Value_5) | Promise<Value_5 extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : Value_5>;
32
+ }, set: {
33
+ <Value_6, Result extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_6, undefined, Result>): Result;
34
+ <Value_7, Update, Result_1 extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_7, Update, Result_1>, update: Update): Result_1;
35
+ }, update: ActiveColorPickerSectionAtomType | ((prev: ActiveColorPickerSectionAtomType) => ActiveColorPickerSectionAtomType)) => void;
36
+ onMount?: (<S extends (update: ActiveColorPickerSectionAtomType | ((prev: ActiveColorPickerSectionAtomType) => ActiveColorPickerSectionAtomType)) => void>(setAtom: S) => void | (() => void)) | undefined;
37
+ } & {
38
+ init: ActiveColorPickerSectionAtomType;
39
+ };
40
+ export declare const getContrastYIQ: (bgHex: string, isCustomColor: boolean) => "white" | "black";
41
+ export type ColorPickerType = "canvasBackground" | "elementBackground" | "elementStroke";
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import { ColorPaletteCustom } from "../../colors";
3
+ import { ActiveColorPickerSectionAtomType } from "./colorPickerUtils";
4
+ interface ColorPickerKeyNavHandlerProps {
5
+ e: React.KeyboardEvent;
6
+ activeColorPickerSection: ActiveColorPickerSectionAtomType;
7
+ palette: ColorPaletteCustom;
8
+ hex: string | null;
9
+ onChange: (color: string) => void;
10
+ customColors: string[];
11
+ setActiveColorPickerSection: (update: React.SetStateAction<ActiveColorPickerSectionAtomType>) => void;
12
+ updateData: (formData?: any) => void;
13
+ activeShade: number;
14
+ }
15
+ export declare const colorPickerKeyNavHandler: ({ e, activeColorPickerSection, palette, hex, onChange, customColors, setActiveColorPickerSection, updateData, activeShade, }: ColorPickerKeyNavHandlerProps) => void;
16
+ export {};
@@ -2,9 +2,9 @@ import "./ContextMenu.scss";
2
2
  import { Action } from "../actions/types";
3
3
  import { ActionManager } from "../actions/manager";
4
4
  import React from "react";
5
- export declare type ContextMenuItem = typeof CONTEXT_MENU_SEPARATOR | Action;
6
- export declare type ContextMenuItems = (ContextMenuItem | false | null | undefined)[];
7
- declare type ContextMenuProps = {
5
+ export type ContextMenuItem = typeof CONTEXT_MENU_SEPARATOR | Action;
6
+ export type ContextMenuItems = (ContextMenuItem | false | null | undefined)[];
7
+ type ContextMenuProps = {
8
8
  actionManager: ActionManager;
9
9
  items: ContextMenuItems;
10
10
  top: number;
@@ -0,0 +1,30 @@
1
+ /// <reference types="react" />
2
+ import { MarkOptional } from "../utility-types";
3
+ import { SidebarProps, SidebarTriggerProps } from "./Sidebar/common";
4
+ export declare const DefaultSidebar: import("react").FC<Omit<MarkOptional<Omit<{
5
+ name: string;
6
+ children: import("react").ReactNode;
7
+ onStateChange?: ((state: {
8
+ name: string;
9
+ tab?: string | undefined;
10
+ } | null) => void) | undefined;
11
+ onDock?: ((docked: boolean) => void) | undefined;
12
+ docked?: boolean | undefined;
13
+ className?: string | undefined;
14
+ __fallback?: boolean | undefined;
15
+ }, "name">, "children">, "onDock"> & {
16
+ /** pass `false` to disable docking */
17
+ onDock?: SidebarProps["onDock"] | false;
18
+ } & {
19
+ __fallback?: boolean | undefined;
20
+ }> & {
21
+ Trigger: import("react").FC<Omit<SidebarTriggerProps, "name"> & import("react").HTMLAttributes<HTMLDivElement> & {
22
+ __fallback?: boolean | undefined;
23
+ }>;
24
+ TabTriggers: {
25
+ ({ children, ...rest }: {
26
+ children: React.ReactNode;
27
+ } & import("react").HTMLAttributes<HTMLDivElement>): JSX.Element;
28
+ displayName: string;
29
+ };
30
+ };