@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
@@ -1,23 +1,23 @@
1
1
  import { Point } from "../types";
2
2
  import { FONT_FAMILY, ROUNDNESS, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "../constants";
3
3
  import { MarkNonNullable, ValueOf } from "../utility-types";
4
- export declare type ChartType = "bar" | "line";
5
- export declare type FillStyle = "hachure" | "cross-hatch" | "solid" | "zigzag";
6
- export declare type FontFamilyKeys = keyof typeof FONT_FAMILY;
7
- export declare type FontFamilyValues = typeof FONT_FAMILY[FontFamilyKeys];
8
- export declare type Theme = typeof THEME[keyof typeof THEME];
9
- export declare type FontString = string & {
4
+ export type ChartType = "bar" | "line";
5
+ export type FillStyle = "hachure" | "cross-hatch" | "solid" | "zigzag";
6
+ export type FontFamilyKeys = keyof typeof FONT_FAMILY;
7
+ export type FontFamilyValues = typeof FONT_FAMILY[FontFamilyKeys];
8
+ export type Theme = typeof THEME[keyof typeof THEME];
9
+ export type FontString = string & {
10
10
  _brand: "fontString";
11
11
  };
12
- export declare type GroupId = string;
13
- export declare type PointerType = "mouse" | "pen" | "touch";
14
- export declare type StrokeRoundness = "round" | "sharp";
15
- export declare type RoundnessType = ValueOf<typeof ROUNDNESS>;
16
- export declare type StrokeStyle = "solid" | "dashed" | "dotted";
17
- export declare type TextAlign = typeof TEXT_ALIGN[keyof typeof TEXT_ALIGN];
18
- declare type VerticalAlignKeys = keyof typeof VERTICAL_ALIGN;
19
- export declare type VerticalAlign = typeof VERTICAL_ALIGN[VerticalAlignKeys];
20
- declare type _ExcalidrawElementBase = Readonly<{
12
+ export type GroupId = string;
13
+ export type PointerType = "mouse" | "pen" | "touch";
14
+ export type StrokeRoundness = "round" | "sharp";
15
+ export type RoundnessType = ValueOf<typeof ROUNDNESS>;
16
+ export type StrokeStyle = "solid" | "dashed" | "dotted";
17
+ export type TextAlign = typeof TEXT_ALIGN[keyof typeof TEXT_ALIGN];
18
+ type VerticalAlignKeys = keyof typeof VERTICAL_ALIGN;
19
+ export type VerticalAlign = typeof VERTICAL_ALIGN[VerticalAlignKeys];
20
+ type _ExcalidrawElementBase = Readonly<{
21
21
  id: string;
22
22
  x: number;
23
23
  y: number;
@@ -60,19 +60,19 @@ declare type _ExcalidrawElementBase = Readonly<{
60
60
  locked: boolean;
61
61
  customData?: Record<string, any>;
62
62
  }>;
63
- export declare type ExcalidrawSelectionElement = _ExcalidrawElementBase & {
63
+ export type ExcalidrawSelectionElement = _ExcalidrawElementBase & {
64
64
  type: "selection";
65
65
  };
66
- export declare type ExcalidrawRectangleElement = _ExcalidrawElementBase & {
66
+ export type ExcalidrawRectangleElement = _ExcalidrawElementBase & {
67
67
  type: "rectangle";
68
68
  };
69
- export declare type ExcalidrawDiamondElement = _ExcalidrawElementBase & {
69
+ export type ExcalidrawDiamondElement = _ExcalidrawElementBase & {
70
70
  type: "diamond";
71
71
  };
72
- export declare type ExcalidrawEllipseElement = _ExcalidrawElementBase & {
72
+ export type ExcalidrawEllipseElement = _ExcalidrawElementBase & {
73
73
  type: "ellipse";
74
74
  };
75
- export declare type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
75
+ export type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
76
76
  type: "image";
77
77
  fileId: FileId | null;
78
78
  /** whether respective file is persisted */
@@ -80,22 +80,22 @@ export declare type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
80
80
  /** X and Y scale factors <-1, 1>, used for image axis flipping */
81
81
  scale: [number, number];
82
82
  }>;
83
- export declare type InitializedExcalidrawImageElement = MarkNonNullable<ExcalidrawImageElement, "fileId">;
83
+ export type InitializedExcalidrawImageElement = MarkNonNullable<ExcalidrawImageElement, "fileId">;
84
84
  /**
85
85
  * These are elements that don't have any additional properties.
86
86
  */
87
- export declare type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
87
+ export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
88
88
  /**
89
89
  * ExcalidrawElement should be JSON serializable and (eventually) contain
90
90
  * no computed data. The list of all ExcalidrawElements should be shareable
91
91
  * between peers and contain no state local to the peer.
92
92
  */
93
- export declare type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement;
94
- export declare type NonDeleted<TElement extends ExcalidrawElement> = TElement & {
93
+ export type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement;
94
+ export type NonDeleted<TElement extends ExcalidrawElement> = TElement & {
95
95
  isDeleted: boolean;
96
96
  };
97
- export declare type NonDeletedExcalidrawElement = NonDeleted<ExcalidrawElement>;
98
- export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
97
+ export type NonDeletedExcalidrawElement = NonDeleted<ExcalidrawElement>;
98
+ export type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
99
99
  type: "text";
100
100
  fontSize: number;
101
101
  fontFamily: FontFamilyValues;
@@ -114,18 +114,18 @@ export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
114
114
  _brand: "unitlessLineHeight";
115
115
  };
116
116
  }>;
117
- export declare type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement;
118
- export declare type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawImageElement | ExcalidrawArrowElement;
119
- export declare type ExcalidrawTextElementWithContainer = {
117
+ export type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement;
118
+ export type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawImageElement | ExcalidrawArrowElement;
119
+ export type ExcalidrawTextElementWithContainer = {
120
120
  containerId: ExcalidrawTextContainer["id"];
121
121
  } & ExcalidrawTextElement;
122
- export declare type PointBinding = {
122
+ export type PointBinding = {
123
123
  elementId: ExcalidrawBindableElement["id"];
124
124
  focus: number;
125
125
  gap: number;
126
126
  };
127
- export declare type Arrowhead = "arrow" | "bar" | "dot" | "triangle";
128
- export declare type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
127
+ export type Arrowhead = "arrow" | "bar" | "dot" | "triangle";
128
+ export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
129
129
  type: "line" | "arrow";
130
130
  points: readonly Point[];
131
131
  lastCommittedPoint: Point | null;
@@ -134,17 +134,17 @@ export declare type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<
134
134
  startArrowhead: Arrowhead | null;
135
135
  endArrowhead: Arrowhead | null;
136
136
  }>;
137
- export declare type ExcalidrawArrowElement = ExcalidrawLinearElement & Readonly<{
137
+ export type ExcalidrawArrowElement = ExcalidrawLinearElement & Readonly<{
138
138
  type: "arrow";
139
139
  }>;
140
- export declare type ExcalidrawFreeDrawElement = _ExcalidrawElementBase & Readonly<{
140
+ export type ExcalidrawFreeDrawElement = _ExcalidrawElementBase & Readonly<{
141
141
  type: "freedraw";
142
142
  points: readonly Point[];
143
143
  pressures: readonly number[];
144
144
  simulatePressure: boolean;
145
145
  lastCommittedPoint: Point | null;
146
146
  }>;
147
- export declare type FileId = string & {
147
+ export type FileId = string & {
148
148
  _brand: "FileId";
149
149
  };
150
150
  export {};
package/types/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare type CANVAS_ERROR_NAMES = "CANVAS_ERROR" | "CANVAS_POSSIBLY_TOO_BIG";
1
+ type CANVAS_ERROR_NAMES = "CANVAS_ERROR" | "CANVAS_POSSIBLY_TOO_BIG";
2
2
  export declare class CanvasError extends Error {
3
3
  constructor(message?: string, name?: CANVAS_ERROR_NAMES);
4
4
  }
package/types/ga.d.ts CHANGED
@@ -16,15 +16,15 @@
16
16
  * See GAPoint, GALine, GADirection and GATransform modules for common
17
17
  * operations.
18
18
  */
19
- export declare type Point = NVector;
20
- export declare type Direction = NVector;
21
- export declare type Line = NVector;
22
- export declare type Transform = NVector;
19
+ export type Point = NVector;
20
+ export type Direction = NVector;
21
+ export type Line = NVector;
22
+ export type Transform = NVector;
23
23
  export declare const point: (x: number, y: number) => NVector;
24
24
  export declare const origin: () => NVector;
25
25
  export declare const direction: (x: number, y: number) => NVector;
26
26
  export declare const offset: (x: number, y: number) => NVector;
27
- declare type NVector = readonly [
27
+ type NVector = readonly [
28
28
  number,
29
29
  number,
30
30
  number,
@@ -0,0 +1,31 @@
1
+ import { LibraryItem } from "../types";
2
+ export type SvgCache = Map<LibraryItem["id"], SVGSVGElement>;
3
+ export declare const libraryItemSvgsCache: import("jotai").Atom<SvgCache> & {
4
+ write: (get: {
5
+ <Value>(atom: import("jotai").Atom<Value | Promise<Value>>): Value;
6
+ <Value_1>(atom: import("jotai").Atom<Promise<Value_1>>): Value_1;
7
+ <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;
8
+ } & {
9
+ <Value_3>(atom: import("jotai").Atom<Value_3 | Promise<Value_3>>, options: {
10
+ unstable_promise: true;
11
+ }): Value_3 | Promise<Value_3>;
12
+ <Value_4>(atom: import("jotai").Atom<Promise<Value_4>>, options: {
13
+ unstable_promise: true;
14
+ }): Value_4 | Promise<Value_4>;
15
+ <Value_5>(atom: import("jotai").Atom<Value_5>, options: {
16
+ unstable_promise: true;
17
+ }): (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>;
18
+ }, set: {
19
+ <Value_6, Result extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_6, undefined, Result>): Result;
20
+ <Value_7, Update, Result_1 extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_7, Update, Result_1>, update: Update): Result_1;
21
+ }, update: SvgCache | ((prev: SvgCache) => SvgCache)) => void;
22
+ onMount?: (<S extends (update: SvgCache | ((prev: SvgCache) => SvgCache)) => void>(setAtom: S) => void | (() => void)) | undefined;
23
+ } & {
24
+ init: SvgCache;
25
+ };
26
+ export declare const useLibraryItemSvg: (id: LibraryItem["id"] | null, elements: LibraryItem["elements"] | undefined, svgCache: SvgCache) => SVGSVGElement | undefined;
27
+ export declare const useLibraryCache: () => {
28
+ clearLibraryCache: () => void;
29
+ deleteItemsFromLibraryCache: (items: LibraryItem["id"][]) => void;
30
+ svgCache: SvgCache;
31
+ };
@@ -1,2 +1,2 @@
1
1
  /// <reference types="react" />
2
- export declare const useOutsideClickHook: (handler: (event: Event) => void) => import("react").MutableRefObject<null>;
2
+ export declare const useOutsideClick: (handler: (event: Event) => void) => import("react").MutableRefObject<null>;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const useScrollPosition: <T extends HTMLElement>(elementRef: import("react").RefObject<T>) => number;
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const useTransition: typeof React.useTransition;
package/types/i18n.d.ts CHANGED
@@ -12,10 +12,10 @@ export declare const setLanguage: (lang: Language) => Promise<void>;
12
12
  export declare const getLanguage: () => Language;
13
13
  export declare const t: (path: string, replacement?: {
14
14
  [key: string]: string | number;
15
- } | undefined) => string;
15
+ } | null | undefined, fallback?: string) => string;
16
16
  export declare const useI18n: () => {
17
17
  t: (path: string, replacement?: {
18
18
  [key: string]: string | number;
19
- } | undefined) => string;
19
+ } | null | undefined, fallback?: string) => string;
20
20
  langCode: string;
21
21
  };
package/types/keys.d.ts CHANGED
@@ -70,7 +70,7 @@ export declare const KEYS: {
70
70
  readonly 8: "8";
71
71
  readonly 9: "9";
72
72
  };
73
- export declare type Key = keyof typeof KEYS;
73
+ export type Key = keyof typeof KEYS;
74
74
  export declare const isArrowKey: (key: string) => boolean;
75
75
  export declare const shouldResizeFromCenter: (event: MouseEvent | KeyboardEvent) => boolean;
76
76
  export declare const shouldMaintainAspectRatio: (event: MouseEvent | KeyboardEvent) => boolean;
@@ -6,7 +6,7 @@ import Footer from "../../components/footer/FooterCenter";
6
6
  import MainMenu from "../../components/main-menu/MainMenu";
7
7
  import WelcomeScreen from "../../components/welcome-screen/WelcomeScreen";
8
8
  import LiveCollaborationTrigger from "../../components/live-collaboration/LiveCollaborationTrigger";
9
- declare type PublicExcalidrawProps = Omit<ExcalidrawProps, "forwardedRef">;
9
+ type PublicExcalidrawProps = Omit<ExcalidrawProps, "forwardedRef">;
10
10
  export declare const Excalidraw: React.MemoExoticComponent<React.ForwardRefExoticComponent<PublicExcalidrawProps & React.RefAttributes<ExcalidrawAPIRefValue>>>;
11
11
  export { getSceneVersion, isInvisiblySmallElement, getNonDeletedElements, } from "../../element";
12
12
  export { defaultLang, useI18n, languages } from "../../i18n";
@@ -19,7 +19,7 @@ measureText, //zsviczian
19
19
  getDefaultLineHeight, //zsviczian
20
20
  wrapText, //zsviczian
21
21
  getFontString, //zsviczian
22
- getMaxContainerWidth, //zsviczian
22
+ getBoundTextMaxWidth, //zsviczian
23
23
  exportToClipboard, mergeLibraryItems, } from "../../packages/utils";
24
24
  export { isLinearElement } from "../../element/typeChecks";
25
25
  export { FONT_FAMILY, THEME, MIME_TYPES } from "../../constants";
@@ -33,3 +33,4 @@ export { MainMenu };
33
33
  export { useDevice } from "../../components/App";
34
34
  export { WelcomeScreen };
35
35
  export { LiveCollaborationTrigger };
36
+ export { DefaultSidebar } from "../../components/DefaultSidebar";
@@ -2,7 +2,7 @@ import { AppState, BinaryFiles } from "../types";
2
2
  import { ExcalidrawElement, NonDeleted } from "../element/types";
3
3
  import { MIME_TYPES } from "../constants";
4
4
  export { MIME_TYPES };
5
- declare type ExportOpts = {
5
+ type ExportOpts = {
6
6
  elements: readonly NonDeleted<ExcalidrawElement>[];
7
7
  appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
8
8
  files: BinaryFiles | null;
@@ -36,7 +36,7 @@ export { getCommonBoundingBox } from "../element/bounds";
36
36
  export { getMaximumGroups } from "../groups";
37
37
  export { intersectElementWithLine } from "../element/collision";
38
38
  export { determineFocusDistance } from "../element/collision";
39
- export { measureText, wrapText, getDefaultLineHeight } from "../element/textElement";
39
+ export { measureText, wrapText, getDefaultLineHeight, } from "../element/textElement";
40
40
  export { getFontString } from "../utils";
41
- export { getMaxContainerWidth } from "../element/textElement";
41
+ export { getBoundTextMaxWidth } from "../element/textElement";
42
42
  export { mergeLibraryItems } from "../data/library";
@@ -1,4 +1,4 @@
1
- declare type EasingFunction = (progress: number) => number;
1
+ type EasingFunction = (progress: number) => number;
2
2
  interface EasingDictionary {
3
3
  [easing: string]: EasingFunction;
4
4
  }
@@ -15,8 +15,8 @@ export interface ExcalidrawElementWithCanvas {
15
15
  boundTextElementVersion: number | null;
16
16
  }
17
17
  export declare const DEFAULT_LINK_SIZE = 14;
18
- declare type ElementShape = Drawable | Drawable[] | null;
19
- declare type ElementShapes = {
18
+ type ElementShape = Drawable | Drawable[] | null;
19
+ type ElementShapes = {
20
20
  freedraw: Drawable | null;
21
21
  arrow: Drawable[];
22
22
  line: Drawable[];
@@ -1,9 +1,9 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "../element/types";
2
2
  import { LinearElementEditor } from "../element/linearElementEditor";
3
- declare type ElementIdKey = InstanceType<typeof LinearElementEditor>["elementId"];
4
- declare type ElementKey = ExcalidrawElement | ElementIdKey;
5
- declare type SceneStateCallback = () => void;
6
- declare type SceneStateCallbackRemover = () => void;
3
+ type ElementIdKey = InstanceType<typeof LinearElementEditor>["elementId"];
4
+ type ElementKey = ExcalidrawElement | ElementIdKey;
5
+ type SceneStateCallback = () => void;
6
+ type SceneStateCallbackRemover = () => void;
7
7
  declare class Scene {
8
8
  private static sceneMapByElement;
9
9
  private static sceneMapById;
@@ -1,11 +1,11 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
2
2
  import { AppState } from "../types";
3
3
  export declare const getElementsWithinSelection: (elements: readonly NonDeletedExcalidrawElement[], selection: NonDeletedExcalidrawElement) => NonDeletedExcalidrawElement[];
4
- export declare const isSomeElementSelected: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => boolean;
4
+ export declare const isSomeElementSelected: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">) => boolean;
5
5
  /**
6
6
  * Returns common attribute (picked by `getAttribute` callback) of selected
7
7
  * elements. If elements don't share the same value, returns `null`.
8
8
  */
9
- export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: AppState, getAttribute: (element: ExcalidrawElement) => T) => T | null;
10
- export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, includeBoundTextElement?: boolean) => NonDeletedExcalidrawElement[];
11
- export declare const getTargetElements: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => NonDeletedExcalidrawElement[];
9
+ export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, getAttribute: (element: ExcalidrawElement) => T) => T | null;
10
+ export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, includeBoundTextElement?: boolean) => NonDeletedExcalidrawElement[];
11
+ export declare const getTargetElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds" | "editingElement">) => NonDeletedExcalidrawElement[];
@@ -1,6 +1,6 @@
1
1
  import { ExcalidrawTextElement } from "../element/types";
2
2
  import { AppClassProperties, AppState } from "../types";
3
- export declare type RenderConfig = {
3
+ export type RenderConfig = {
4
4
  scrollX: AppState["scrollX"];
5
5
  scrollY: AppState["scrollY"];
6
6
  /** null indicates transparent bg */
@@ -35,15 +35,15 @@ export declare type RenderConfig = {
35
35
  isExporting: boolean;
36
36
  selectionColor?: string;
37
37
  };
38
- export declare type SceneScroll = {
38
+ export type SceneScroll = {
39
39
  scrollX: number;
40
40
  scrollY: number;
41
41
  };
42
42
  export interface Scene {
43
43
  elements: ExcalidrawTextElement[];
44
44
  }
45
- export declare type ExportType = "png" | "clipboard" | "clipboard-svg" | "backend" | "svg";
46
- export declare type ScrollBars = {
45
+ export type ExportType = "png" | "clipboard" | "clipboard-svg" | "backend" | "svg";
46
+ export type ScrollBars = {
47
47
  horizontal: {
48
48
  x: number;
49
49
  y: number;
package/types/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import React from "react";
1
2
  import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, ExcalidrawImageElement, Theme, StrokeRoundness } from "./element/types";
2
3
  import { SHAPES } from "./shapes";
3
4
  import { Point as RoughPoint } from "roughjs/bin/geometry";
@@ -16,9 +17,9 @@ import type { FileSystemHandle } from "./data/filesystem";
16
17
  import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
17
18
  import { ContextMenuItems } from "./components/ContextMenu";
18
19
  import { Merge, ForwardRef, ValueOf } from "./utility-types";
19
- import React from "react";
20
- export declare type Point = Readonly<RoughPoint>;
21
- export declare type Collaborator = {
20
+ import { ColorPaletteCustom } from "./colors";
21
+ export type Point = Readonly<RoughPoint>;
22
+ export type Collaborator = {
22
23
  pointer?: {
23
24
  x: number;
24
25
  y: number;
@@ -34,10 +35,10 @@ export declare type Collaborator = {
34
35
  avatarUrl?: string;
35
36
  id?: string;
36
37
  };
37
- export declare type DataURL = string & {
38
+ export type DataURL = string & {
38
39
  _brand: "DataURL";
39
40
  };
40
- export declare type BinaryFileData = {
41
+ export type BinaryFileData = {
41
42
  mimeType: ValueOf<typeof IMAGE_MIME_TYPES> | typeof MIME_TYPES.binary;
42
43
  id: FileId;
43
44
  dataURL: DataURL;
@@ -54,16 +55,18 @@ export declare type BinaryFileData = {
54
55
  */
55
56
  lastRetrieved?: number;
56
57
  };
57
- export declare type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
58
- export declare type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
59
- export declare type LastActiveTool = {
58
+ export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
59
+ export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
60
+ export type LastActiveTool = {
60
61
  type: typeof SHAPES[number]["value"] | "eraser" | "hand";
61
62
  customType: null;
62
63
  } | {
63
64
  type: "custom";
64
65
  customType: string;
65
66
  } | null;
66
- export declare type AppState = {
67
+ export type SidebarName = string;
68
+ export type SidebarTabName = string;
69
+ export type AppState = {
67
70
  contextMenu: {
68
71
  items: ContextMenuItems;
69
72
  top: number;
@@ -124,10 +127,20 @@ export declare type AppState = {
124
127
  isRotating: boolean;
125
128
  zoom: Zoom;
126
129
  openMenu: "canvas" | "shape" | null;
127
- openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
128
- openSidebar: "library" | "customSidebar" | null;
130
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
131
+ openSidebar: {
132
+ name: SidebarName;
133
+ tab?: SidebarTabName;
134
+ } | null;
129
135
  openDialog: "imageExport" | "help" | "jsonExport" | null;
130
- isSidebarDocked: boolean;
136
+ /**
137
+ * Reflects user preference for whether the default sidebar should be docked.
138
+ *
139
+ * NOTE this is only a user preference and does not reflect the actual docked
140
+ * state of the sidebar, because the host apps can override this through
141
+ * a DefaultSidebar prop, which is not reflected back to the appState.
142
+ */
143
+ defaultSidebarDockedPreference: boolean;
131
144
  lastPointerDownWith: PointerType;
132
145
  selectedElementIds: {
133
146
  [id: string]: boolean;
@@ -173,10 +186,15 @@ export declare type AppState = {
173
186
  showHyperlinkPopup: false | "info" | "editor";
174
187
  linkOpacity: number;
175
188
  trayModeEnabled: boolean;
176
- colorPalette: {
177
- canvasBackground?: string[];
178
- elementBackground?: string[];
179
- elementStroke?: string[];
189
+ colorPalette?: {
190
+ canvasBackground: ColorPaletteCustom;
191
+ elementBackground: ColorPaletteCustom;
192
+ elementStroke: ColorPaletteCustom;
193
+ topPicks: {
194
+ canvasBackground: [string, string, string, string, string];
195
+ elementStroke: [string, string, string, string, string];
196
+ elementBackground: [string, string, string, string, string];
197
+ };
180
198
  };
181
199
  allowWheelZoom?: boolean;
182
200
  allowPinchZoom?: boolean;
@@ -189,17 +207,18 @@ export declare type AppState = {
189
207
  invertBindingBehaviour: boolean;
190
208
  selectedLinearElement: LinearElementEditor | null;
191
209
  };
192
- export declare type NormalizedZoomValue = number & {
210
+ export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
211
+ export type NormalizedZoomValue = number & {
193
212
  _brand: "normalizedZoom";
194
213
  };
195
- export declare type Zoom = Readonly<{
214
+ export type Zoom = Readonly<{
196
215
  value: NormalizedZoomValue;
197
216
  }>;
198
- export declare type PointerCoords = Readonly<{
217
+ export type PointerCoords = Readonly<{
199
218
  x: number;
200
219
  y: number;
201
220
  }>;
202
- export declare type Gesture = {
221
+ export type Gesture = {
203
222
  pointers: Map<number, PointerCoords>;
204
223
  lastCenter: {
205
224
  x: number;
@@ -213,11 +232,11 @@ export declare class GestureEvent extends UIEvent {
213
232
  readonly scale: number;
214
233
  }
215
234
  /** @deprecated legacy: do not use outside of migration paths */
216
- export declare type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[];
235
+ export type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[];
217
236
  /** @deprecated legacy: do not use outside of migration paths */
218
- declare type LibraryItems_v1 = readonly LibraryItem_v1[];
237
+ type LibraryItems_v1 = readonly LibraryItem_v1[];
219
238
  /** v2 library item */
220
- export declare type LibraryItem = {
239
+ export type LibraryItem = {
221
240
  id: string;
222
241
  status: "published" | "unpublished";
223
242
  elements: readonly NonDeleted<ExcalidrawElement>[];
@@ -226,14 +245,14 @@ export declare type LibraryItem = {
226
245
  name?: string;
227
246
  error?: string;
228
247
  };
229
- export declare type LibraryItems = readonly LibraryItem[];
230
- export declare type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
231
- export declare type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
232
- export declare type ExcalidrawAPIRefValue = ExcalidrawImperativeAPI | {
248
+ export type LibraryItems = readonly LibraryItem[];
249
+ export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
250
+ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
251
+ export type ExcalidrawAPIRefValue = ExcalidrawImperativeAPI | {
233
252
  readyPromise?: ResolvablePromise<ExcalidrawImperativeAPI>;
234
253
  ready?: false;
235
254
  };
236
- export declare type ExcalidrawInitialDataState = Merge<ImportedDataState, {
255
+ export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
237
256
  libraryItems?: Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>;
238
257
  }>;
239
258
  export interface ExcalidrawProps {
@@ -251,7 +270,7 @@ export interface ExcalidrawProps {
251
270
  }) => void;
252
271
  onPaste?: (data: ClipboardData, event: ClipboardEvent | null) => Promise<boolean> | boolean;
253
272
  onDrop?: (event: React.DragEvent<HTMLDivElement>) => Promise<boolean> | boolean;
254
- renderTopRightUI?: (isMobile: boolean, appState: AppState) => JSX.Element | null;
273
+ renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
255
274
  langCode?: Language["code"];
256
275
  viewModeEnabled?: boolean;
257
276
  zenModeEnabled?: boolean;
@@ -260,7 +279,7 @@ export interface ExcalidrawProps {
260
279
  initState?: AppState;
261
280
  theme?: Theme;
262
281
  name?: string;
263
- renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => JSX.Element;
282
+ renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
264
283
  UIOptions?: Partial<UIOptions>;
265
284
  detectScroll?: boolean;
266
285
  handleKeyboardGlobally?: boolean;
@@ -277,13 +296,9 @@ export interface ExcalidrawProps {
277
296
  onLinkHover?: (element: NonDeletedExcalidrawElement, event: React.PointerEvent<HTMLCanvasElement>) => void;
278
297
  onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
279
298
  onScrollChange?: (scrollX: number, scrollY: number) => void;
280
- /**
281
- * Render function that renders custom <Sidebar /> component.
282
- */
283
- renderSidebar?: () => JSX.Element | null;
284
299
  children?: React.ReactNode;
285
300
  }
286
- export declare type SceneData = {
301
+ export type SceneData = {
287
302
  elements?: ImportedDataState["elements"];
288
303
  appState?: ImportedDataState["appState"];
289
304
  collaborators?: Map<string, Collaborator>;
@@ -294,12 +309,12 @@ export declare enum UserIdleState {
294
309
  AWAY = "away",
295
310
  IDLE = "idle"
296
311
  }
297
- export declare type ExportOpts = {
312
+ export type ExportOpts = {
298
313
  saveFileToDisk?: boolean;
299
- onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => void;
300
- renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => JSX.Element;
314
+ onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => void;
315
+ renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => JSX.Element;
301
316
  };
302
- declare type CanvasActions = Partial<{
317
+ type CanvasActions = Partial<{
303
318
  changeViewBackgroundColor: boolean;
304
319
  clearCanvas: boolean;
305
320
  export: false | ExportOpts;
@@ -308,13 +323,13 @@ declare type CanvasActions = Partial<{
308
323
  toggleTheme: boolean | null;
309
324
  saveAsImage: boolean;
310
325
  }>;
311
- declare type UIOptions = Partial<{
326
+ type UIOptions = Partial<{
312
327
  dockedSidebarBreakpoint: number;
313
328
  canvasActions: CanvasActions;
314
329
  /** @deprecated does nothing. Will be removed in 0.15 */
315
330
  welcomeScreen?: boolean;
316
331
  }>;
317
- export declare type AppProps = Merge<ExcalidrawProps, {
332
+ export type AppProps = Merge<ExcalidrawProps, {
318
333
  UIOptions: Merge<UIOptions, {
319
334
  canvasActions: Required<CanvasActions> & {
320
335
  export: ExportOpts;
@@ -327,7 +342,7 @@ export declare type AppProps = Merge<ExcalidrawProps, {
327
342
  }>;
328
343
  /** A subset of App class properties that we need to use elsewhere
329
344
  * in the app, eg Manager. Factored out into a separate type to keep DRY. */
330
- export declare type AppClassProperties = {
345
+ export type AppClassProperties = {
331
346
  props: AppProps;
332
347
  canvas: HTMLCanvasElement | null;
333
348
  focusContainer(): void;
@@ -340,8 +355,11 @@ export declare type AppClassProperties = {
340
355
  device: App["device"];
341
356
  scene: App["scene"];
342
357
  pasteFromClipboard: App["pasteFromClipboard"];
358
+ id: App["id"];
359
+ onInsertElements: App["onInsertElements"];
360
+ onExportImage: App["onExportImage"];
343
361
  };
344
- export declare type PointerDownState = Readonly<{
362
+ export type PointerDownState = Readonly<{
345
363
  origin: Readonly<{
346
364
  x: number;
347
365
  y: number;
@@ -400,7 +418,7 @@ export declare type PointerDownState = Readonly<{
400
418
  };
401
419
  };
402
420
  }>;
403
- export declare type ExcalidrawImperativeAPI = {
421
+ export type ExcalidrawImperativeAPI = {
404
422
  updateScene: InstanceType<typeof App>["updateScene"];
405
423
  updateLibrary: InstanceType<typeof Library>["updateLibrary"];
406
424
  resetScene: InstanceType<typeof App>["resetScene"];
@@ -432,12 +450,13 @@ export declare type ExcalidrawImperativeAPI = {
432
450
  setActiveTool: InstanceType<typeof App>["setActiveTool"];
433
451
  setCursor: InstanceType<typeof App>["setCursor"];
434
452
  resetCursor: InstanceType<typeof App>["resetCursor"];
435
- toggleMenu: InstanceType<typeof App>["toggleMenu"];
453
+ toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
436
454
  };
437
- export declare type Device = Readonly<{
455
+ export type Device = Readonly<{
438
456
  isSmScreen: boolean;
439
457
  isMobile: boolean;
440
458
  isTouchScreen: boolean;
441
459
  canDeviceFitSidebar: boolean;
460
+ isLandscape: boolean;
442
461
  }>;
443
462
  export {};