@zsviczian/excalidraw 0.16.1-obsidian-8 → 0.17.0-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 (87) hide show
  1. package/dist/excalidraw.development.js +407 -110
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/dist/excalidraw.production.min.js.LICENSE.txt +1 -1
  4. package/main.js +7 -1
  5. package/package.json +1 -1
  6. package/types/actions/actionAddToLibrary.d.ts +33 -6
  7. package/types/actions/actionBoundText.d.ts +22 -4
  8. package/types/actions/actionCanvas.d.ts +144 -27
  9. package/types/actions/actionClipboard.d.ts +77 -14
  10. package/types/actions/actionDeleteSelected.d.ts +33 -6
  11. package/types/actions/actionElementLock.d.ts +22 -4
  12. package/types/actions/actionExport.d.ts +96 -23
  13. package/types/actions/actionFinalize.d.ts +22 -4
  14. package/types/actions/actionFrame.d.ts +33 -6
  15. package/types/actions/actionGroup.d.ts +23 -5
  16. package/types/actions/actionLinearEditor.d.ts +11 -2
  17. package/types/actions/actionMenu.d.ts +27 -20
  18. package/types/actions/actionProperties.d.ts +143 -26
  19. package/types/actions/actionSelectAll.d.ts +11 -2
  20. package/types/actions/actionStyles.d.ts +11 -2
  21. package/types/actions/actionToggleGridMode.d.ts +11 -2
  22. package/types/actions/actionToggleObjectsSnapMode.d.ts +11 -2
  23. package/types/actions/actionToggleStats.d.ts +11 -2
  24. package/types/actions/actionToggleViewMode.d.ts +11 -2
  25. package/types/actions/actionToggleZenMode.d.ts +11 -2
  26. package/types/actions/index.d.ts +1 -1
  27. package/types/appState.d.ts +3 -3
  28. package/types/components/Actions.d.ts +3 -2
  29. package/types/components/App.d.ts +43 -13
  30. package/types/components/Button.d.ts +1 -1
  31. package/types/components/ImageExportDialog.d.ts +1 -1
  32. package/types/components/InlineIcon.d.ts +3 -0
  33. package/types/components/LayerUI.d.ts +6 -2
  34. package/types/components/MagicButton.d.ts +9 -0
  35. package/types/components/MagicSettings.d.ts +8 -0
  36. package/types/components/MobileMenu.d.ts +4 -3
  37. package/types/components/Paragraph.d.ts +4 -0
  38. package/types/components/TTDDialog/MermaidToExcalidraw.d.ts +13 -0
  39. package/types/components/TTDDialog/TTDDialog.d.ts +29 -0
  40. package/types/components/TTDDialog/TTDDialogInput.d.ts +9 -0
  41. package/types/components/TTDDialog/TTDDialogOutput.d.ts +7 -0
  42. package/types/components/TTDDialog/TTDDialogPanel.d.ts +16 -0
  43. package/types/components/TTDDialog/TTDDialogPanels.d.ts +4 -0
  44. package/types/components/TTDDialog/TTDDialogTab.d.ts +7 -0
  45. package/types/components/TTDDialog/TTDDialogTabTrigger.d.ts +8 -0
  46. package/types/components/TTDDialog/TTDDialogTabTriggers.d.ts +6 -0
  47. package/types/components/TTDDialog/TTDDialogTabs.d.ts +9 -0
  48. package/types/components/TTDDialog/TTDDialogTrigger.d.ts +8 -0
  49. package/types/components/TTDDialog/common.d.ts +33 -0
  50. package/types/components/TextField.d.ts +16 -0
  51. package/types/components/dropdownMenu/DropdownMenu.d.ts +6 -0
  52. package/types/components/dropdownMenu/DropdownMenuItem.d.ts +12 -0
  53. package/types/components/icons.d.ts +6 -0
  54. package/types/components/main-menu/MainMenu.d.ts +6 -0
  55. package/types/constants.d.ts +30 -3
  56. package/types/context/tunnels.d.ts +1 -0
  57. package/types/data/EditorLocalStorage.d.ts +8 -0
  58. package/types/data/ai/types.d.ts +242 -0
  59. package/types/data/index.d.ts +10 -2
  60. package/types/data/magic.d.ts +23 -0
  61. package/types/data/transform.d.ts +11 -7
  62. package/types/element/ElementCanvasButtons.d.ts +6 -0
  63. package/types/element/Hyperlink.d.ts +11 -2
  64. package/types/element/collision.d.ts +2 -2
  65. package/types/element/embeddable.d.ts +17 -21
  66. package/types/element/index.d.ts +3 -4
  67. package/types/element/linearElementEditor.d.ts +11 -2
  68. package/types/element/newElement.d.ts +7 -1
  69. package/types/element/textElement.d.ts +2 -2
  70. package/types/element/typeChecks.d.ts +10 -7
  71. package/types/element/types.d.ts +31 -2
  72. package/types/errors.d.ts +5 -0
  73. package/types/frame.d.ts +31 -20
  74. package/types/packages/excalidraw/index.d.ts +5 -3
  75. package/types/packages/excalidraw/webpack.preact.config.d.ts +170 -0
  76. package/types/packages/utils.d.ts +5 -4
  77. package/types/packages/withinBounds.d.ts +2 -2
  78. package/types/renderer/renderElement.d.ts +6 -1
  79. package/types/renderer/renderScene.d.ts +10 -5
  80. package/types/scene/Scene.d.ts +11 -6
  81. package/types/scene/ShapeCache.d.ts +1 -1
  82. package/types/scene/comparisons.d.ts +7 -6
  83. package/types/scene/export.d.ts +6 -5
  84. package/types/scene/types.d.ts +2 -0
  85. package/types/shapes.d.ts +1 -1
  86. package/types/types.d.ts +42 -25
  87. package/types/utils.d.ts +8 -3
@@ -1,10 +1,10 @@
1
- import { NonDeletedExcalidrawElement } from "../element/types";
1
+ import { ExcalidrawFrameLikeElement, NonDeletedExcalidrawElement } from "../element/types";
2
2
  import { AppState, BinaryFiles } from "../types";
3
- import { serializeAsJSON } from "../data/json";
4
- export declare const exportToCanvas: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, { exportBackground, exportPadding, viewBackgroundColor, }: {
3
+ export declare const exportToCanvas: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, { exportBackground, exportPadding, viewBackgroundColor, exportingFrame, }: {
5
4
  exportBackground: boolean;
6
5
  exportPadding?: number | undefined;
7
6
  viewBackgroundColor: string;
7
+ exportingFrame?: ExcalidrawFrameLikeElement | null | undefined;
8
8
  }, createCanvas?: (width: number, height: number) => {
9
9
  canvas: HTMLCanvasElement;
10
10
  scale: number;
@@ -16,9 +16,10 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
16
16
  viewBackgroundColor: string;
17
17
  exportWithDarkMode?: boolean;
18
18
  exportEmbedScene?: boolean;
19
- renderFrame?: boolean;
19
+ frameRendering?: AppState["frameRendering"];
20
+ frameColor?: AppState["frameColor"];
20
21
  }, files: BinaryFiles | null, opts?: {
21
- serializeAsJSON?: () => string;
22
22
  renderEmbeddables?: boolean;
23
+ exportingFrame?: ExcalidrawFrameLikeElement | null;
23
24
  }) => Promise<SVGSVGElement>;
24
25
  export declare const getExportSize: (elements: readonly NonDeletedExcalidrawElement[], exportPadding: number, scale: number) => [number, number];
@@ -82,6 +82,7 @@ export type ElementShapes = {
82
82
  rectangle: Drawable;
83
83
  ellipse: Drawable;
84
84
  diamond: Drawable;
85
+ iframe: Drawable;
85
86
  embeddable: Drawable;
86
87
  freedraw: Drawable | null;
87
88
  arrow: Drawable[];
@@ -89,4 +90,5 @@ export type ElementShapes = {
89
90
  text: null;
90
91
  image: null;
91
92
  frame: null;
93
+ magicframe: null;
92
94
  };
package/types/shapes.d.ts CHANGED
@@ -59,4 +59,4 @@ export declare const SHAPES: readonly [{
59
59
  readonly numericKey: "0";
60
60
  readonly fillable: false;
61
61
  }];
62
- export declare const findShapeByKey: (key: string) => "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser" | null;
62
+ export declare const findShapeByKey: (key: string) => "text" | "image" | "line" | "arrow" | "selection" | "rectangle" | "diamond" | "ellipse" | "freedraw" | "eraser" | null;
package/types/types.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import React from "react";
2
- import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawFrameElement, ExcalidrawEmbeddableElement } from "./element/types";
2
+ import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType } from "./element/types";
3
+ import { Action } from "./actions/types";
3
4
  import { Point as RoughPoint } from "roughjs/bin/geometry";
4
5
  import { LinearElementEditor } from "./element/linearElementEditor";
5
6
  import { SuggestedBinding } from "./element/binding";
6
7
  import { ImportedDataState } from "./data/types";
7
8
  import type App from "./components/App";
8
- import type { ResolvablePromise, throttleRAF } from "./utils";
9
+ import type { throttleRAF } from "./utils";
9
10
  import { Spreadsheet } from "./charts";
10
11
  import { Language } from "./i18n";
11
12
  import { ClipboardData } from "./clipboard";
@@ -16,7 +17,7 @@ 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 { SnapLine } from "./snapping";
19
- import { Merge, ForwardRef, ValueOf } from "./utility-types";
20
+ import { Merge, ValueOf } from "./utility-types";
20
21
  import { ColorPaletteCustom } from "./colors";
21
22
  export type Point = Readonly<RoughPoint>;
22
23
  export type Collaborator = {
@@ -59,7 +60,8 @@ export type BinaryFileData = {
59
60
  };
60
61
  export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
61
62
  export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
62
- export type ToolType = "selection" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "embeddable" | "laser" | "mermaid";
63
+ export type ToolType = "selection" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser" | "mermaid";
64
+ export type ElementOrToolType = ExcalidrawElementType | ToolType | "custom";
63
65
  export type ActiveTool = {
64
66
  type: ToolType;
65
67
  customType: null;
@@ -107,13 +109,11 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
107
109
  suggestedBindings: AppState["suggestedBindings"];
108
110
  isRotating: AppState["isRotating"];
109
111
  elementsToHighlight: AppState["elementsToHighlight"];
110
- openSidebar: AppState["openSidebar"];
111
- showHyperlinkPopup: AppState["showHyperlinkPopup"];
112
112
  collaborators: AppState["collaborators"];
113
113
  snapLines: AppState["snapLines"];
114
114
  zenModeEnabled: AppState["zenModeEnabled"];
115
115
  }>;
116
- export type AppState = {
116
+ export interface AppState {
117
117
  contextMenu: {
118
118
  items: ContextMenuItems;
119
119
  top: number;
@@ -133,7 +133,7 @@ export type AppState = {
133
133
  isBindingEnabled: boolean;
134
134
  startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
135
135
  suggestedBindings: SuggestedBinding[];
136
- frameToHighlight: NonDeleted<ExcalidrawFrameElement> | null;
136
+ frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
137
137
  frameRendering: {
138
138
  enabled: boolean;
139
139
  name: boolean;
@@ -186,7 +186,15 @@ export type AppState = {
186
186
  name: SidebarName;
187
187
  tab?: SidebarTabName;
188
188
  } | null;
189
- openDialog: "imageExport" | "help" | "jsonExport" | "mermaid" | null;
189
+ openDialog: null | {
190
+ name: "imageExport" | "help" | "jsonExport";
191
+ } | {
192
+ name: "magicSettings";
193
+ source: "tool" | "generation" | "settings";
194
+ } | {
195
+ name: "ttd";
196
+ tab: string;
197
+ };
190
198
  /**
191
199
  * Reflects user preference for whether the default sidebar should be docked.
192
200
  *
@@ -268,6 +276,7 @@ export type AppState = {
268
276
  frameColor: {
269
277
  stroke: string;
270
278
  fill: string;
279
+ nameColor: string;
271
280
  };
272
281
  invertBindingBehaviour: boolean;
273
282
  selectedLinearElement: LinearElementEditor | null;
@@ -277,7 +286,7 @@ export type AppState = {
277
286
  y: number;
278
287
  } | null;
279
288
  objectsSnapModeEnabled: boolean;
280
- };
289
+ }
281
290
  export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
282
291
  export type NormalizedZoomValue = number & {
283
292
  _brand: "normalizedZoom";
@@ -319,17 +328,13 @@ export type LibraryItem = {
319
328
  export type LibraryItems = readonly LibraryItem[];
320
329
  export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
321
330
  export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
322
- export type ExcalidrawAPIRefValue = ExcalidrawImperativeAPI | {
323
- readyPromise?: ResolvablePromise<ExcalidrawImperativeAPI>;
324
- ready?: false;
325
- };
326
331
  export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
327
332
  libraryItems?: Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>;
328
333
  }>;
329
334
  export interface ExcalidrawProps {
330
335
  onChange?: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
331
336
  initialData?: ExcalidrawInitialDataState | null | Promise<ExcalidrawInitialDataState | null>;
332
- excalidrawRef?: ForwardRef<ExcalidrawAPIRefValue>;
337
+ excalidrawAPI?: (api: ExcalidrawImperativeAPI) => void;
333
338
  isCollaborating?: boolean;
334
339
  onPointerUpdate?: (payload: {
335
340
  pointer: {
@@ -375,6 +380,8 @@ export interface ExcalidrawProps {
375
380
  renderWebview?: boolean;
376
381
  renderEmbeddableMenu?: (appState: AppState) => JSX.Element | null;
377
382
  renderMermaid?: boolean;
383
+ onContextMenu?: (element: readonly NonDeletedExcalidrawElement[], appState: AppState, onClose: (callback?: () => void) => void) => JSX.Element | null;
384
+ aiEnabled?: boolean;
378
385
  }
379
386
  export type SceneData = {
380
387
  elements?: ImportedDataState["elements"];
@@ -392,7 +399,7 @@ export type ExportOpts = {
392
399
  onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => void;
393
400
  renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
394
401
  };
395
- type CanvasActions = Partial<{
402
+ export type CanvasActions = Partial<{
396
403
  changeViewBackgroundColor: boolean;
397
404
  clearCanvas: boolean;
398
405
  export: false | ExportOpts;
@@ -401,9 +408,12 @@ type CanvasActions = Partial<{
401
408
  toggleTheme: boolean | null;
402
409
  saveAsImage: boolean;
403
410
  }>;
404
- type UIOptions = Partial<{
411
+ export type UIOptions = Partial<{
405
412
  dockedSidebarBreakpoint: number;
406
413
  canvasActions: CanvasActions;
414
+ tools: {
415
+ image: boolean;
416
+ };
407
417
  /** @deprecated does nothing. Will be removed in 0.15 */
408
418
  welcomeScreen?: boolean;
409
419
  }>;
@@ -417,6 +427,7 @@ export type AppProps = Merge<ExcalidrawProps, {
417
427
  handleKeyboardGlobally: boolean;
418
428
  isCollaborating: boolean;
419
429
  children?: React.ReactNode;
430
+ aiEnabled: boolean;
420
431
  }>;
421
432
  /** A subset of App class properties that we need to use elsewhere
422
433
  * in the app, eg Manager. Factored out into a separate type to keep DRY. */
@@ -446,6 +457,8 @@ export type AppClassProperties = {
446
457
  togglePenMode: App["togglePenMode"];
447
458
  setActiveTool: App["setActiveTool"];
448
459
  setOpenDialog: App["setOpenDialog"];
460
+ insertEmbeddableElement: App["insertEmbeddableElement"];
461
+ onMagicframeToolSelect: App["onMagicframeToolSelect"];
449
462
  };
450
463
  export type PointerDownState = Readonly<{
451
464
  origin: Readonly<{
@@ -521,12 +534,11 @@ export type ExcalidrawImperativeAPI = {
521
534
  getSceneElements: InstanceType<typeof App>["getSceneElements"];
522
535
  getAppState: () => InstanceType<typeof App>["state"];
523
536
  getFiles: () => InstanceType<typeof App>["files"];
537
+ registerAction: (action: Action) => void;
524
538
  refresh: InstanceType<typeof App>["refresh"];
525
539
  setToast: InstanceType<typeof App>["setToast"];
526
540
  addFiles: (data: BinaryFileData[]) => void;
527
541
  updateContainerSize: InstanceType<typeof App>["updateContainerSize"];
528
- readyPromise: ResolvablePromise<ExcalidrawImperativeAPI>;
529
- ready: true;
530
542
  id: string;
531
543
  setLocalFont: (showOnPanel: boolean) => void;
532
544
  selectElements: (elements: readonly ExcalidrawElement[]) => void;
@@ -551,11 +563,15 @@ export type ExcalidrawImperativeAPI = {
551
563
  onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
552
564
  };
553
565
  export type Device = Readonly<{
554
- isSmScreen: boolean;
555
- isMobile: boolean;
566
+ viewport: {
567
+ isMobile: boolean;
568
+ isLandscape: boolean;
569
+ };
570
+ editor: {
571
+ isMobile: boolean;
572
+ canFitSidebar: boolean;
573
+ };
556
574
  isTouchScreen: boolean;
557
- canDeviceFitSidebar: boolean;
558
- isLandscape: boolean;
559
575
  }>;
560
576
  type FrameNameBounds = {
561
577
  x: number;
@@ -565,10 +581,10 @@ type FrameNameBounds = {
565
581
  angle: number;
566
582
  };
567
583
  export type FrameNameBoundsCache = {
568
- get: (frameElement: ExcalidrawFrameElement) => FrameNameBounds | null;
584
+ get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
569
585
  _cache: Map<string, FrameNameBounds & {
570
586
  zoom: AppState["zoom"]["value"];
571
- versionNonce: ExcalidrawFrameElement["versionNonce"];
587
+ versionNonce: ExcalidrawFrameLikeElement["versionNonce"];
572
588
  }>;
573
589
  };
574
590
  export type KeyboardModifiersObject = {
@@ -578,4 +594,5 @@ export type KeyboardModifiersObject = {
578
594
  metaKey: boolean;
579
595
  };
580
596
  export type Primitive = number | string | boolean | bigint | symbol | null | undefined;
597
+ export type JSONValue = string | number | boolean | null | object;
581
598
  export {};
package/types/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { EVENT } from "./constants";
2
- import { FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./element/types";
2
+ import { FontFamilyValues, FontString } from "./element/types";
3
3
  import { ActiveTool, AppState, ToolType, Zoom } from "./types";
4
4
  export declare const setDateTimeForTests: (dateTime: string) => void;
5
5
  export declare const getDateTime: () => string;
@@ -186,8 +186,11 @@ export declare const isShallowEqual: <T extends Record<string, any>, I extends k
186
186
  export declare const composeEventHandlers: <E>(originalEventHandler?: ((event: E) => void) | undefined, ourEventHandler?: ((event: E) => void) | undefined, { checkForDefaultPrevented }?: {
187
187
  checkForDefaultPrevented?: boolean | undefined;
188
188
  }) => (event: E) => void;
189
- export declare const isOnlyExportingSingleFrame: (elements: readonly NonDeletedExcalidrawElement[]) => boolean;
190
- export declare const assertNever: (value: never, message: string, softAssert?: boolean) => never;
189
+ /**
190
+ * supply `null` as message if non-never value is valid, you just need to
191
+ * typecheck against it
192
+ */
193
+ export declare const assertNever: (value: never, message: string | null, softAssert?: boolean) => never;
191
194
  /**
192
195
  * Memoizes on values of `opts` object (strict equality).
193
196
  */
@@ -197,3 +200,5 @@ export declare const memoize: <T extends Record<string, any>, R extends unknown>
197
200
  export declare const isRenderThrottlingEnabled: () => boolean;
198
201
  /** Checks if value is inside given collection. Useful for type-safety. */
199
202
  export declare const isMemberOf: <T extends string>(collection: Set<T> | Record<T, any> | Map<T, any> | readonly T[], value: string) => value is T;
203
+ export declare const cloneJSON: <T>(obj: T) => T;
204
+ export declare const isFiniteNumber: (value: any) => value is number;