@zsviczian/excalidraw 0.12.0-obsidian-11 → 0.13.0-obsidian

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 (45) hide show
  1. package/README.md +68 -14
  2. package/dist/excalidraw.development.js +138 -61
  3. package/dist/excalidraw.production.min.js +1 -1
  4. package/package.json +1 -1
  5. package/types/actions/actionAddToLibrary.d.ts +6 -6
  6. package/types/actions/actionBoundText.d.ts +2 -2
  7. package/types/actions/actionCanvas.d.ts +18 -18
  8. package/types/actions/actionClipboard.d.ts +10 -10
  9. package/types/actions/actionDeleteSelected.d.ts +6 -6
  10. package/types/actions/actionExport.d.ts +18 -18
  11. package/types/actions/actionFinalize.d.ts +4 -4
  12. package/types/actions/actionLinearEditor.d.ts +2 -2
  13. package/types/actions/actionMenu.d.ts +6 -6
  14. package/types/actions/actionProperties.d.ts +26 -26
  15. package/types/actions/actionStyles.d.ts +2 -2
  16. package/types/actions/actionToggleGridMode.d.ts +2 -2
  17. package/types/actions/actionToggleLock.d.ts +2 -2
  18. package/types/actions/actionToggleStats.d.ts +2 -2
  19. package/types/actions/actionToggleViewMode.d.ts +2 -2
  20. package/types/actions/actionToggleZenMode.d.ts +2 -2
  21. package/types/appState.d.ts +2 -2
  22. package/types/components/App.d.ts +6 -1
  23. package/types/components/HintViewer.d.ts +3 -2
  24. package/types/components/LayerUI.d.ts +2 -1
  25. package/types/components/LibraryMenu.d.ts +14 -5
  26. package/types/components/LibraryMenuHeaderContent.d.ts +12 -0
  27. package/types/components/LibraryMenuItems.d.ts +2 -14
  28. package/types/components/LibraryUnit.d.ts +2 -3
  29. package/types/components/MobileMenu.d.ts +4 -3
  30. package/types/components/Sidebar/Sidebar.d.ts +73 -0
  31. package/types/components/Sidebar/SidebarHeader.d.ts +20 -0
  32. package/types/components/Sidebar/common.d.ts +15 -0
  33. package/types/components/hoc/withUpstreamOverride.d.ts +10 -0
  34. package/types/data/restore.d.ts +1 -1
  35. package/types/data/types.d.ts +16 -1
  36. package/types/element/Hyperlink.d.ts +2 -2
  37. package/types/element/index.d.ts +1 -1
  38. package/types/element/linearElementEditor.d.ts +2 -2
  39. package/types/element/newElement.d.ts +8 -0
  40. package/types/keys.d.ts +3 -3
  41. package/types/packages/excalidraw/example/App.d.ts +2 -1
  42. package/types/packages/excalidraw/example/sidebar/ExampleSidebar.d.ts +5 -0
  43. package/types/packages/excalidraw/index.d.ts +1 -0
  44. package/types/scene/scrollbars.d.ts +1 -1
  45. package/types/types.d.ts +8 -2
@@ -8,7 +8,7 @@ export declare type RestoredDataState = {
8
8
  appState: RestoredAppState;
9
9
  files: BinaryFiles;
10
10
  };
11
- export declare const restoreElements: (elements: ImportedDataState["elements"], localElements: readonly ExcalidrawElement[] | null | undefined) => ExcalidrawElement[];
11
+ export declare const restoreElements: (elements: ImportedDataState["elements"], localElements: readonly ExcalidrawElement[] | null | undefined, refreshDimensions?: boolean) => ExcalidrawElement[];
12
12
  export declare const restoreAppState: (appState: ImportedDataState["appState"], localAppState: Partial<AppState> | null | undefined) => RestoredAppState;
13
13
  export declare const restore: (data: Pick<ImportedDataState, "appState" | "elements" | "files"> | null, localAppState: Partial<AppState> | null | undefined, localElements: readonly ExcalidrawElement[] | null | undefined) => RestoredDataState;
14
14
  export declare const restoreLibraryItems: (libraryItems: ImportedDataState["libraryItems"], defaultStatus: LibraryItem["status"]) => LibraryItem[];
@@ -10,12 +10,27 @@ export interface ExportedDataState {
10
10
  appState: ReturnType<typeof cleanAppStateForExport>;
11
11
  files: BinaryFiles | undefined;
12
12
  }
13
+ /**
14
+ * Map of legacy AppState keys, with values of:
15
+ * [<legacy type>, <new AppState proeprty>]
16
+ *
17
+ * This is a helper type used in downstream abstractions.
18
+ * Don't consume on its own.
19
+ */
20
+ export declare type LegacyAppState = {
21
+ /** @deprecated #5663 TODO remove 22-12-15 */
22
+ isLibraryOpen: [boolean, "openSidebar"];
23
+ /** @deprecated #5663 TODO remove 22-12-15 */
24
+ isLibraryMenuDocked: [boolean, "isSidebarDocked"];
25
+ };
13
26
  export interface ImportedDataState {
14
27
  type?: string;
15
28
  version?: number;
16
29
  source?: string;
17
30
  elements?: readonly ExcalidrawElement[] | null;
18
- appState?: Readonly<Partial<AppState>> | null;
31
+ appState?: Readonly<Partial<AppState & {
32
+ [T in keyof LegacyAppState]: LegacyAppState[T][0];
33
+ }>> | null;
19
34
  scrollToContent?: boolean;
20
35
  libraryItems?: LibraryItems_anyVersion;
21
36
  files?: BinaryFiles;
@@ -72,6 +72,8 @@ export declare const actionLink: {
72
72
  value: import("../types").NormalizedZoomValue;
73
73
  }>;
74
74
  openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
75
+ openSidebar: "library" | "customSidebar" | null;
76
+ isSidebarDocked: boolean;
75
77
  lastPointerDownWith: import("./types").PointerType;
76
78
  selectedElementIds: {
77
79
  [id: string]: boolean;
@@ -98,8 +100,6 @@ export declare const actionLink: {
98
100
  height: number;
99
101
  offsetTop: number;
100
102
  offsetLeft: number;
101
- isLibraryOpen: boolean;
102
- isLibraryMenuDocked: boolean;
103
103
  fileHandle: import("browser-fs-access").FileSystemHandle | null;
104
104
  collaborators: Map<string, import("../types").Collaborator>;
105
105
  showStats: boolean;
@@ -1,5 +1,5 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
2
- export { newElement, newTextElement, updateTextElement, newLinearElement, newImageElement, duplicateElement, } from "./newElement";
2
+ export { newElement, newTextElement, updateTextElement, refreshTextDimensions, newLinearElement, newImageElement, duplicateElement, } from "./newElement";
3
3
  export { getElementAbsoluteCoords, getElementBounds, getCommonBounds, getDiamondPoints, getArrowheadPoints, getClosestElementBounds, } from "./bounds";
4
4
  export { OMIT_SIDES_FOR_MULTIPLE_ELEMENTS, getTransformHandlesFromCoords, getTransformHandles, } from "./transformHandles";
5
5
  export { hitTest, isHittingElementBoundingBoxWithoutHittingElement, } from "./collision";
@@ -160,6 +160,8 @@ export declare class LinearElementEditor {
160
160
  }>;
161
161
  openMenu: "canvas" | "shape" | null;
162
162
  openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
163
+ openSidebar: "library" | "customSidebar" | null;
164
+ isSidebarDocked: boolean;
163
165
  lastPointerDownWith: import("./types").PointerType;
164
166
  selectedElementIds: {
165
167
  [id: string]: boolean;
@@ -186,8 +188,6 @@ export declare class LinearElementEditor {
186
188
  height: number;
187
189
  offsetTop: number;
188
190
  offsetLeft: number;
189
- isLibraryOpen: boolean;
190
- isLibraryMenuDocked: boolean;
191
191
  fileHandle: import("browser-fs-access").FileSystemHandle | null;
192
192
  collaborators: Map<string, import("../types").Collaborator>;
193
193
  showStats: boolean;
@@ -13,6 +13,14 @@ export declare const newTextElement: (opts: {
13
13
  verticalAlign: VerticalAlign;
14
14
  containerId?: ExcalidrawRectangleElement["id"];
15
15
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
16
+ export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, text?: string) => {
17
+ x: number;
18
+ y: number;
19
+ width: number;
20
+ height: number;
21
+ baseline: number;
22
+ text: string;
23
+ };
16
24
  export declare const getMaxContainerWidth: (container: ExcalidrawElement) => number;
17
25
  export declare const getMaxContainerHeight: (container: ExcalidrawElement) => number;
18
26
  export declare const updateTextElement: (textElement: ExcalidrawTextElement, { text, isDeleted, originalText, rawText, link, }: {
package/types/keys.d.ts CHANGED
@@ -17,11 +17,8 @@ export declare const CODES: {
17
17
  readonly SLASH: "Slash";
18
18
  readonly C: "KeyC";
19
19
  readonly D: "KeyD";
20
- readonly G: "KeyG";
21
- readonly F: "KeyF";
22
20
  readonly H: "KeyH";
23
21
  readonly V: "KeyV";
24
- readonly X: "KeyX";
25
22
  readonly Z: "KeyZ";
26
23
  readonly R: "KeyR";
27
24
  };
@@ -44,9 +41,12 @@ export declare const KEYS: {
44
41
  readonly PERIOD: ".";
45
42
  readonly COMMA: ",";
46
43
  readonly A: "a";
44
+ readonly C: "c";
47
45
  readonly D: "d";
48
46
  readonly E: "e";
47
+ readonly F: "f";
49
48
  readonly G: "g";
49
+ readonly H: "h";
50
50
  readonly I: "i";
51
51
  readonly L: "l";
52
52
  readonly O: "o";
@@ -1,7 +1,8 @@
1
+ import type * as TExcalidraw from "../index";
1
2
  import "./App.scss";
2
3
  declare global {
3
4
  interface Window {
4
- ExcalidrawLib: any;
5
+ ExcalidrawLib: typeof TExcalidraw;
5
6
  }
6
7
  }
7
8
  export default function App(): JSX.Element;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import "./ExampleSidebar.scss";
3
+ export default function Sidebar({ children }: {
4
+ children: React.ReactNode;
5
+ }): JSX.Element;
@@ -18,3 +18,4 @@ export { FONT_FAMILY, THEME, MIME_TYPES } from "../../constants";
18
18
  export { mutateElement, newElementWith, bumpVersion, } from "../../element/mutateElement";
19
19
  export { parseLibraryTokensFromUrl, useHandleLibrary, } from "../../data/library";
20
20
  export { sceneCoordsToViewportCoords, viewportCoordsToSceneCoords, } from "../../utils";
21
+ export { Sidebar } from "../../components/Sidebar/Sidebar";
@@ -3,7 +3,7 @@ import { Zoom } from "../types";
3
3
  import { ScrollBars } from "./types";
4
4
  export declare const SCROLLBAR_MARGIN = 4;
5
5
  export declare const SCROLLBAR_WIDTH = 6;
6
- export declare const SCROLLBAR_COLOR = "rgba(0,0,0,0.3)";
6
+ export declare const SCROLLBAR_COLOR = "rgba(128,128,128,0.3)";
7
7
  export declare const getScrollBars: (elements: readonly ExcalidrawElement[], viewportWidth: number, viewportHeight: number, { scrollX, scrollY, zoom, }: {
8
8
  scrollX: number;
9
9
  scrollY: number;
package/types/types.d.ts CHANGED
@@ -104,6 +104,8 @@ export declare type AppState = {
104
104
  zoom: Zoom;
105
105
  openMenu: "canvas" | "shape" | null;
106
106
  openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
107
+ openSidebar: "library" | "customSidebar" | null;
108
+ isSidebarDocked: boolean;
107
109
  lastPointerDownWith: PointerType;
108
110
  selectedElementIds: {
109
111
  [id: string]: boolean;
@@ -133,8 +135,6 @@ export declare type AppState = {
133
135
  height: number;
134
136
  offsetTop: number;
135
137
  offsetLeft: number;
136
- isLibraryOpen: boolean;
137
- isLibraryMenuDocked: boolean;
138
138
  fileHandle: FileSystemHandle | null;
139
139
  collaborators: Map<string, Collaborator>;
140
140
  showStats: boolean;
@@ -251,6 +251,10 @@ export interface ExcalidrawProps {
251
251
  onLinkHover?: (element: NonDeletedExcalidrawElement, event: React.PointerEvent<HTMLCanvasElement>) => void;
252
252
  onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
253
253
  onScrollChange?: (scrollX: number, scrollY: number) => void;
254
+ /**
255
+ * Render function that renders custom <Sidebar /> component.
256
+ */
257
+ renderSidebar?: () => JSX.Element | null;
254
258
  }
255
259
  export declare type SceneData = {
256
260
  elements?: ImportedDataState["elements"];
@@ -287,6 +291,7 @@ export declare type AppProps = Merge<ExcalidrawProps, {
287
291
  detectScroll: boolean;
288
292
  handleKeyboardGlobally: boolean;
289
293
  isCollaborating: boolean;
294
+ children?: React.ReactNode;
290
295
  }>;
291
296
  /** A subset of App class properties that we need to use elsewhere
292
297
  * in the app, eg Manager. Factored out into a separate type to keep DRY. */
@@ -393,6 +398,7 @@ export declare type ExcalidrawImperativeAPI = {
393
398
  setActiveTool: InstanceType<typeof App>["setActiveTool"];
394
399
  setCursor: InstanceType<typeof App>["setCursor"];
395
400
  resetCursor: InstanceType<typeof App>["resetCursor"];
401
+ toggleMenu: InstanceType<typeof App>["toggleMenu"];
396
402
  };
397
403
  export declare type Device = Readonly<{
398
404
  isSmScreen: boolean;