@zsviczian/excalidraw 0.14.2-obsidian-5 → 0.15.2-obsidian-2

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 (70) hide show
  1. package/README.md +2 -2
  2. package/dist/excalidraw.development.js +469 -226
  3. package/dist/excalidraw.production.min.js +1 -1
  4. package/package.json +1 -1
  5. package/types/actions/actionAddToLibrary.d.ts +18 -6
  6. package/types/actions/actionBoundText.d.ts +14 -6
  7. package/types/actions/actionCanvas.d.ts +60 -20
  8. package/types/actions/actionClipboard.d.ts +30 -10
  9. package/types/actions/actionDeleteSelected.d.ts +18 -6
  10. package/types/actions/actionExport.d.ts +54 -18
  11. package/types/actions/actionFinalize.d.ts +12 -4
  12. package/types/actions/actionLinearEditor.d.ts +6 -2
  13. package/types/actions/actionMenu.d.ts +20 -8
  14. package/types/actions/actionProperties.d.ts +78 -26
  15. package/types/actions/actionStyles.d.ts +6 -2
  16. package/types/actions/actionToggleGridMode.d.ts +6 -2
  17. package/types/actions/actionToggleLock.d.ts +6 -2
  18. package/types/actions/actionToggleStats.d.ts +6 -2
  19. package/types/actions/actionToggleViewMode.d.ts +6 -2
  20. package/types/actions/actionToggleZenMode.d.ts +6 -2
  21. package/types/actions/types.d.ts +1 -1
  22. package/types/appState.d.ts +5 -2
  23. package/types/clipboard.d.ts +2 -2
  24. package/types/components/Actions.d.ts +5 -5
  25. package/types/components/App.d.ts +10 -3
  26. package/types/components/Button.d.ts +3 -1
  27. package/types/components/DefaultSidebar.d.ts +30 -0
  28. package/types/components/HintViewer.d.ts +2 -2
  29. package/types/components/ImageExportDialog.d.ts +4 -4
  30. package/types/components/JSONExportDialog.d.ts +3 -3
  31. package/types/components/LayerUI.d.ts +3 -10
  32. package/types/components/LibraryMenu.d.ts +32 -13
  33. package/types/components/LibraryMenuBrowseButton.d.ts +2 -2
  34. package/types/components/LibraryMenuControlButtons.d.ts +9 -0
  35. package/types/components/LibraryMenuHeaderContent.d.ts +9 -28
  36. package/types/components/LibraryMenuItems.d.ts +2 -2
  37. package/types/components/MobileMenu.d.ts +3 -3
  38. package/types/components/PasteChartDialog.d.ts +4 -5
  39. package/types/components/PublishLibrary.d.ts +2 -2
  40. package/types/components/Sidebar/Sidebar.d.ts +68 -45
  41. package/types/components/Sidebar/SidebarHeader.d.ts +6 -19
  42. package/types/components/Sidebar/SidebarTab.d.ts +9 -0
  43. package/types/components/Sidebar/SidebarTabTrigger.d.ts +10 -0
  44. package/types/components/Sidebar/SidebarTabTriggers.d.ts +7 -0
  45. package/types/components/Sidebar/SidebarTabs.d.ts +7 -0
  46. package/types/components/Sidebar/SidebarTrigger.d.ts +6 -0
  47. package/types/components/Sidebar/common.d.ts +23 -6
  48. package/types/components/Stats.d.ts +3 -3
  49. package/types/components/Trans.d.ts +8 -0
  50. package/types/components/footer/Footer.d.ts +2 -2
  51. package/types/constants.d.ts +34 -7
  52. package/types/context/tunnels.d.ts +18 -0
  53. package/types/context/ui-appState.d.ts +4 -0
  54. package/types/data/blob.d.ts +2 -2
  55. package/types/data/filesystem.d.ts +2 -1
  56. package/types/data/types.d.ts +2 -4
  57. package/types/element/Hyperlink.d.ts +8 -4
  58. package/types/element/image.d.ts +11 -1
  59. package/types/element/linearElementEditor.d.ts +7 -6
  60. package/types/element/newElement.d.ts +31 -7
  61. package/types/element/showSelectedShapeActions.d.ts +2 -2
  62. package/types/element/textElement.d.ts +3 -2
  63. package/types/hooks/useOutsideClick.d.ts +1 -1
  64. package/types/packages/excalidraw/index.d.ts +2 -1
  65. package/types/packages/utils.d.ts +1 -1
  66. package/types/renderer/renderElement.d.ts +1 -0
  67. package/types/scene/export.d.ts +4 -1
  68. package/types/scene/selection.d.ts +4 -4
  69. package/types/types.d.ts +28 -16
  70. package/types/utils.d.ts +2 -2
@@ -9,6 +9,7 @@ export interface ExcalidrawElementWithCanvas {
9
9
  canvas: HTMLCanvasElement;
10
10
  theme: RenderConfig["theme"];
11
11
  scale: number;
12
+ zoomValue: RenderConfig["zoom"]["value"];
12
13
  canvasOffsetX: number;
13
14
  canvasOffsetY: number;
14
15
  boundTextElementVersion: number | null;
@@ -1,5 +1,6 @@
1
1
  import { NonDeletedExcalidrawElement } from "../element/types";
2
2
  import { AppState, BinaryFiles } from "../types";
3
+ import { serializeAsJSON } from "../data/json";
3
4
  export declare const SVG_EXPORT_TAG = "<!-- svg-source:excalidraw -->";
4
5
  export declare const exportToCanvas: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, { exportBackground, exportPadding, viewBackgroundColor, }: {
5
6
  exportBackground: boolean;
@@ -16,5 +17,7 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
16
17
  viewBackgroundColor: string;
17
18
  exportWithDarkMode?: boolean;
18
19
  exportEmbedScene?: boolean;
19
- }, files: BinaryFiles | null) => Promise<SVGSVGElement>;
20
+ }, files: BinaryFiles | null, opts?: {
21
+ serializeAsJSON?: () => string;
22
+ }) => Promise<SVGSVGElement>;
20
23
  export declare const getExportSize: (elements: readonly NonDeletedExcalidrawElement[], exportPadding: number, scale: number) => [number, number];
@@ -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[];
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";
@@ -13,10 +14,9 @@ import { isOverScrollBars } from "./scene";
13
14
  import { MaybeTransformHandleType } from "./element/transformHandles";
14
15
  import Library from "./data/library";
15
16
  import type { FileSystemHandle } from "./data/filesystem";
16
- import type { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
17
+ import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
17
18
  import { ContextMenuItems } from "./components/ContextMenu";
18
- import { Merge, ForwardRef } from "./utility-types";
19
- import React from "react";
19
+ import { Merge, ForwardRef, ValueOf } from "./utility-types";
20
20
  export declare type Point = Readonly<RoughPoint>;
21
21
  export declare type Collaborator = {
22
22
  pointer?: {
@@ -38,7 +38,7 @@ export declare type DataURL = string & {
38
38
  _brand: "DataURL";
39
39
  };
40
40
  export declare type BinaryFileData = {
41
- mimeType: typeof ALLOWED_IMAGE_MIME_TYPES[number] | typeof MIME_TYPES.binary;
41
+ mimeType: ValueOf<typeof IMAGE_MIME_TYPES> | typeof MIME_TYPES.binary;
42
42
  id: FileId;
43
43
  dataURL: DataURL;
44
44
  /**
@@ -63,6 +63,8 @@ export declare type LastActiveTool = {
63
63
  type: "custom";
64
64
  customType: string;
65
65
  } | null;
66
+ export declare type SidebarName = string;
67
+ export declare type SidebarTabName = string;
66
68
  export declare type AppState = {
67
69
  contextMenu: {
68
70
  items: ContextMenuItems;
@@ -125,9 +127,19 @@ export declare type AppState = {
125
127
  zoom: Zoom;
126
128
  openMenu: "canvas" | "shape" | null;
127
129
  openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
128
- openSidebar: "library" | "customSidebar" | null;
130
+ openSidebar: {
131
+ name: SidebarName;
132
+ tab?: SidebarTabName;
133
+ } | null;
129
134
  openDialog: "imageExport" | "help" | "jsonExport" | null;
130
- isSidebarDocked: boolean;
135
+ /**
136
+ * Reflects user preference for whether the default sidebar should be docked.
137
+ *
138
+ * NOTE this is only a user preference and does not reflect the actual docked
139
+ * state of the sidebar, because the host apps can override this through
140
+ * a DefaultSidebar prop, which is not reflected back to the appState.
141
+ */
142
+ defaultSidebarDockedPreference: boolean;
131
143
  lastPointerDownWith: PointerType;
132
144
  selectedElementIds: {
133
145
  [id: string]: boolean;
@@ -186,8 +198,10 @@ export declare type AppState = {
186
198
  resetCustomPen?: any;
187
199
  gridColor: string;
188
200
  dynamicStyle: string;
201
+ invertBindingBehaviour: boolean;
189
202
  selectedLinearElement: LinearElementEditor | null;
190
203
  };
204
+ export declare type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
191
205
  export declare type NormalizedZoomValue = number & {
192
206
  _brand: "normalizedZoom";
193
207
  };
@@ -250,7 +264,7 @@ export interface ExcalidrawProps {
250
264
  }) => void;
251
265
  onPaste?: (data: ClipboardData, event: ClipboardEvent | null) => Promise<boolean> | boolean;
252
266
  onDrop?: (event: React.DragEvent<HTMLDivElement>) => Promise<boolean> | boolean;
253
- renderTopRightUI?: (isMobile: boolean, appState: AppState) => JSX.Element | null;
267
+ renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
254
268
  langCode?: Language["code"];
255
269
  viewModeEnabled?: boolean;
256
270
  zenModeEnabled?: boolean;
@@ -259,7 +273,7 @@ export interface ExcalidrawProps {
259
273
  initState?: AppState;
260
274
  theme?: Theme;
261
275
  name?: string;
262
- renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => JSX.Element;
276
+ renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
263
277
  UIOptions?: Partial<UIOptions>;
264
278
  detectScroll?: boolean;
265
279
  handleKeyboardGlobally?: boolean;
@@ -276,10 +290,6 @@ export interface ExcalidrawProps {
276
290
  onLinkHover?: (element: NonDeletedExcalidrawElement, event: React.PointerEvent<HTMLCanvasElement>) => void;
277
291
  onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
278
292
  onScrollChange?: (scrollX: number, scrollY: number) => void;
279
- /**
280
- * Render function that renders custom <Sidebar /> component.
281
- */
282
- renderSidebar?: () => JSX.Element | null;
283
293
  children?: React.ReactNode;
284
294
  }
285
295
  export declare type SceneData = {
@@ -295,8 +305,8 @@ export declare enum UserIdleState {
295
305
  }
296
306
  export declare type ExportOpts = {
297
307
  saveFileToDisk?: boolean;
298
- onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => void;
299
- renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => JSX.Element;
308
+ onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => void;
309
+ renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => JSX.Element;
300
310
  };
301
311
  declare type CanvasActions = Partial<{
302
312
  changeViewBackgroundColor: boolean;
@@ -333,12 +343,14 @@ export declare type AppClassProperties = {
333
343
  library: Library;
334
344
  imageCache: Map<FileId, {
335
345
  image: HTMLImageElement | Promise<HTMLImageElement>;
336
- mimeType: typeof ALLOWED_IMAGE_MIME_TYPES[number];
346
+ mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
337
347
  }>;
338
348
  files: BinaryFiles;
339
349
  device: App["device"];
340
350
  scene: App["scene"];
341
351
  pasteFromClipboard: App["pasteFromClipboard"];
352
+ id: App["id"];
353
+ onInsertElements: App["onInsertElements"];
342
354
  };
343
355
  export declare type PointerDownState = Readonly<{
344
356
  origin: Readonly<{
@@ -431,7 +443,7 @@ export declare type ExcalidrawImperativeAPI = {
431
443
  setActiveTool: InstanceType<typeof App>["setActiveTool"];
432
444
  setCursor: InstanceType<typeof App>["setCursor"];
433
445
  resetCursor: InstanceType<typeof App>["resetCursor"];
434
- toggleMenu: InstanceType<typeof App>["toggleMenu"];
446
+ toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
435
447
  };
436
448
  export declare type Device = Readonly<{
437
449
  isSmScreen: boolean;
package/types/utils.d.ts CHANGED
@@ -63,7 +63,7 @@ export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">,
63
63
  export declare const resetCursor: (canvas: HTMLCanvasElement | null) => void;
64
64
  export declare const setCursor: (canvas: HTMLCanvasElement | null, cursor: string) => void;
65
65
  export declare const setEraserCursor: (canvas: HTMLCanvasElement | null, theme: AppState["theme"]) => void;
66
- export declare const setCursorForShape: (canvas: HTMLCanvasElement | null, appState: AppState) => void;
66
+ export declare const setCursorForShape: (canvas: HTMLCanvasElement | null, appState: Pick<AppState, "activeTool" | "theme">) => void;
67
67
  export declare const isFullScreen: () => boolean;
68
68
  export declare const allowFullScreen: () => Promise<void>;
69
69
  export declare const exitFullScreen: () => Promise<void>;
@@ -156,7 +156,7 @@ export declare const isPrimitive: (val: any) => boolean;
156
156
  export declare const getFrame: () => "top" | "iframe";
157
157
  export declare const isPromiseLike: (value: any) => value is Promise<any>;
158
158
  export declare const queryFocusableElements: (container: HTMLElement | null) => HTMLElement[];
159
- export declare const isShallowEqual: <T extends Record<string, any>>(objA: T, objB: T) => boolean;
159
+ export declare const isShallowEqual: <T extends Record<string, any>, I extends keyof T>(objA: T, objB: T, comparators?: Record<I, (a: T[I], b: T[I]) => boolean> | undefined, debug?: boolean) => boolean;
160
160
  export declare const composeEventHandlers: <E>(originalEventHandler?: ((event: E) => void) | undefined, ourEventHandler?: ((event: E) => void) | undefined, { checkForDefaultPrevented }?: {
161
161
  checkForDefaultPrevented?: boolean | undefined;
162
162
  }) => (event: E) => void;