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

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 (90) hide show
  1. package/README.md +4 -0
  2. package/dist/excalidraw.development.js +333 -171
  3. package/dist/excalidraw.production.min.js +1 -1
  4. package/dist/excalidraw.production.min.js.LICENSE.txt +2 -0
  5. package/package.json +1 -1
  6. package/types/actions/actionAddToLibrary.d.ts +30 -3
  7. package/types/actions/actionAlign.d.ts +12 -6
  8. package/types/actions/actionBoundText.d.ts +21 -3
  9. package/types/actions/actionCanvas.d.ts +94 -10
  10. package/types/actions/actionClipboard.d.ts +47 -5
  11. package/types/actions/actionDeleteSelected.d.ts +27 -3
  12. package/types/actions/actionDistribute.d.ts +2 -2
  13. package/types/actions/actionElementLock.d.ts +21 -2
  14. package/types/actions/actionExport.d.ts +90 -9
  15. package/types/actions/actionFinalize.d.ts +20 -2
  16. package/types/actions/actionFlip.d.ts +2 -2
  17. package/types/actions/actionFrame.d.ts +475 -0
  18. package/types/actions/actionGroup.d.ts +2 -2
  19. package/types/actions/actionLinearEditor.d.ts +10 -1
  20. package/types/actions/actionMenu.d.ts +30 -3
  21. package/types/actions/actionNavigate.d.ts +1 -1
  22. package/types/actions/actionProperties.d.ts +130 -13
  23. package/types/actions/actionStyles.d.ts +10 -1
  24. package/types/actions/actionToggleGridMode.d.ts +10 -1
  25. package/types/actions/actionToggleStats.d.ts +10 -1
  26. package/types/actions/actionToggleViewMode.d.ts +10 -1
  27. package/types/actions/actionToggleZenMode.d.ts +10 -1
  28. package/types/actions/actionZindex.d.ts +4 -4
  29. package/types/actions/types.d.ts +1 -1
  30. package/types/appState.d.ts +1 -1
  31. package/types/clients.d.ts +1 -5
  32. package/types/colors.d.ts +1 -0
  33. package/types/components/ActiveConfirmDialog.d.ts +1 -21
  34. package/types/components/App.d.ts +20 -4
  35. package/types/components/Avatar.d.ts +0 -1
  36. package/types/components/ColorPicker/ColorInput.d.ts +1 -1
  37. package/types/components/ColorPicker/ColorPicker.d.ts +3 -2
  38. package/types/components/ColorPicker/CustomColorList.d.ts +1 -1
  39. package/types/components/ColorPicker/Picker.d.ts +4 -2
  40. package/types/components/ColorPicker/PickerColorList.d.ts +1 -1
  41. package/types/components/ColorPicker/ShadeList.d.ts +1 -1
  42. package/types/components/ColorPicker/TopPicks.d.ts +1 -1
  43. package/types/components/ColorPicker/colorPickerUtils.d.ts +4 -24
  44. package/types/components/ColorPicker/keyboardNavHandlers.d.ts +8 -3
  45. package/types/components/Dialog.d.ts +2 -3
  46. package/types/components/EyeDropper.d.ts +18 -0
  47. package/types/components/FilledButton.d.ts +2 -1
  48. package/types/components/LibraryMenu.d.ts +1 -21
  49. package/types/components/OverwriteConfirm/OverwriteConfirm.d.ts +17 -0
  50. package/types/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +17 -0
  51. package/types/components/OverwriteConfirm/OverwriteConfirmState.d.ts +22 -0
  52. package/types/components/Sidebar/Sidebar.d.ts +1 -21
  53. package/types/components/ToolButton.d.ts +2 -1
  54. package/types/components/dropdownMenu/DropdownMenu.d.ts +3 -2
  55. package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +4 -2
  56. package/types/components/icons.d.ts +5 -0
  57. package/types/components/main-menu/MainMenu.d.ts +3 -2
  58. package/types/constants.d.ts +24 -1
  59. package/types/context/tunnels.d.ts +1 -0
  60. package/types/data/library.d.ts +1 -45
  61. package/types/element/Hyperlink.d.ts +21 -6
  62. package/types/element/binding.d.ts +1 -1
  63. package/types/element/bounds.d.ts +31 -6
  64. package/types/element/collision.d.ts +7 -7
  65. package/types/element/dragElements.d.ts +2 -1
  66. package/types/element/iframe.d.ts +173 -0
  67. package/types/element/index.d.ts +3 -2
  68. package/types/element/linearElementEditor.d.ts +11 -2
  69. package/types/element/newElement.d.ts +8 -2
  70. package/types/element/transformHandles.d.ts +8 -1
  71. package/types/element/typeChecks.d.ts +5 -3
  72. package/types/element/types.d.ts +13 -4
  73. package/types/frame.d.ts +40 -0
  74. package/types/groups.d.ts +4 -0
  75. package/types/hooks/useCreatePortalContainer.d.ts +5 -0
  76. package/types/hooks/useLibraryItemSvg.d.ts +1 -21
  77. package/types/hooks/useOutsideClick.d.ts +19 -1
  78. package/types/jotai.d.ts +16 -104
  79. package/types/keys.d.ts +2 -0
  80. package/types/math.d.ts +1 -0
  81. package/types/packages/excalidraw/example/initialData.d.ts +6 -0
  82. package/types/renderer/renderElement.d.ts +3 -2
  83. package/types/renderer/renderScene.d.ts +12 -3
  84. package/types/renderer/roundRect.d.ts +1 -1
  85. package/types/scene/Scene.d.ts +8 -1
  86. package/types/scene/export.d.ts +1 -0
  87. package/types/scene/selection.d.ts +13 -3
  88. package/types/types.d.ts +35 -3
  89. package/types/utils.d.ts +5 -2
  90. package/types/zindex.d.ts +4 -4
package/types/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, ExcalidrawImageElement, Theme, StrokeRoundness } from "./element/types";
2
+ import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawFrameElement } from "./element/types";
3
3
  import { SHAPES } from "./shapes";
4
4
  import { Point as RoughPoint } from "roughjs/bin/geometry";
5
5
  import { LinearElementEditor } from "./element/linearElementEditor";
@@ -58,7 +58,7 @@ export type BinaryFileData = {
58
58
  export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
59
59
  export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
60
60
  export type LastActiveTool = {
61
- type: typeof SHAPES[number]["value"] | "eraser" | "hand";
61
+ type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame" | "iframe";
62
62
  customType: null;
63
63
  } | {
64
64
  type: "custom";
@@ -75,6 +75,10 @@ export type AppState = {
75
75
  showWelcomeScreen: boolean;
76
76
  isLoading: boolean;
77
77
  errorMessage: React.ReactNode;
78
+ activeIFrame: {
79
+ element: NonDeletedExcalidrawElement;
80
+ state: "hover" | "active";
81
+ } | null;
78
82
  draggingElement: NonDeletedExcalidrawElement | null;
79
83
  resizingElement: NonDeletedExcalidrawElement | null;
80
84
  multiElement: NonDeleted<ExcalidrawLinearElement> | null;
@@ -82,6 +86,10 @@ export type AppState = {
82
86
  isBindingEnabled: boolean;
83
87
  startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
84
88
  suggestedBindings: SuggestedBinding[];
89
+ frameToHighlight: NonDeleted<ExcalidrawFrameElement> | null;
90
+ shouldRenderFrames: boolean;
91
+ editingFrame: string | null;
92
+ elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
85
93
  editingElement: NonDeletedExcalidrawElement | null;
86
94
  editingLinearElement: LinearElementEditor | null;
87
95
  activeTool: {
@@ -92,7 +100,7 @@ export type AppState = {
92
100
  lastActiveTool: LastActiveTool;
93
101
  locked: boolean;
94
102
  } & ({
95
- type: typeof SHAPES[number]["value"] | "eraser" | "hand";
103
+ type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame" | "iframe";
96
104
  customType: null;
97
105
  } | {
98
106
  type: "custom";
@@ -148,6 +156,7 @@ export type AppState = {
148
156
  previousSelectedElementIds: {
149
157
  [id: string]: boolean;
150
158
  };
159
+ selectedElementsAreBeingDragged: boolean;
151
160
  shouldCacheIgnoreZoom: boolean;
152
161
  toast: {
153
162
  message: string;
@@ -297,6 +306,8 @@ export interface ExcalidrawProps {
297
306
  onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
298
307
  onScrollChange?: (scrollX: number, scrollY: number) => void;
299
308
  children?: React.ReactNode;
309
+ iframeURLWhitelist?: RegExp[];
310
+ renderCustomIFrame?: (element: NonDeletedExcalidrawElement, radius: number, appState: UIAppState) => JSX.Element | null;
300
311
  }
301
312
  export type SceneData = {
302
313
  elements?: ImportedDataState["elements"];
@@ -358,6 +369,7 @@ export type AppClassProperties = {
358
369
  id: App["id"];
359
370
  onInsertElements: App["onInsertElements"];
360
371
  onExportImage: App["onExportImage"];
372
+ lastViewportPosition: App["lastViewportPosition"];
361
373
  };
362
374
  export type PointerDownState = Readonly<{
363
375
  origin: Readonly<{
@@ -451,6 +463,12 @@ export type ExcalidrawImperativeAPI = {
451
463
  setCursor: InstanceType<typeof App>["setCursor"];
452
464
  resetCursor: InstanceType<typeof App>["resetCursor"];
453
465
  toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
466
+ /**
467
+ * Disables rendering of frames (including element clipping), but currently
468
+ * the frames are still interactive in edit mode. As such, this API should be
469
+ * used in conjunction with view mode (props.viewModeEnabled).
470
+ */
471
+ toggleFrameRendering: InstanceType<typeof App>["toggleFrameRendering"];
454
472
  };
455
473
  export type Device = Readonly<{
456
474
  isSmScreen: boolean;
@@ -459,4 +477,18 @@ export type Device = Readonly<{
459
477
  canDeviceFitSidebar: boolean;
460
478
  isLandscape: boolean;
461
479
  }>;
480
+ type FrameNameBounds = {
481
+ x: number;
482
+ y: number;
483
+ width: number;
484
+ height: number;
485
+ angle: number;
486
+ };
487
+ export type FrameNameBoundsCache = {
488
+ get: (frameElement: ExcalidrawFrameElement) => FrameNameBounds | null;
489
+ _cache: Map<string, FrameNameBounds & {
490
+ zoom: AppState["zoom"]["value"];
491
+ versionNonce: ExcalidrawFrameElement["versionNonce"];
492
+ }>;
493
+ };
462
494
  export {};
package/types/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { EVENT } from "./constants";
2
- import { FontFamilyValues, FontString } from "./element/types";
2
+ import { FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./element/types";
3
3
  import { AppState, LastActiveTool, Zoom } from "./types";
4
4
  import { SHAPES } from "./shapes";
5
5
  export declare const setDateTimeForTests: (dateTime: string) => void;
@@ -7,6 +7,7 @@ export declare const getDateTime: () => string;
7
7
  export declare const capitalizeString: (str: string) => string;
8
8
  export declare const isToolIcon: (target: Element | EventTarget | null) => target is HTMLElement;
9
9
  export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLBRElement | HTMLDivElement;
10
+ export declare const isInteractive: (target: Element | EventTarget | null) => boolean;
10
11
  export declare const isWritableElement: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLBRElement | HTMLDivElement;
11
12
  export declare const getFontFamilyString: ({ fontFamily, }: {
12
13
  fontFamily: FontFamilyValues;
@@ -53,7 +54,7 @@ export declare const selectNode: (node: Element) => void;
53
54
  export declare const removeSelection: () => void;
54
55
  export declare const distance: (x: number, y: number) => number;
55
56
  export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">, data: ({
56
- type: (typeof SHAPES)[number]["value"] | "eraser" | "hand";
57
+ type: (typeof SHAPES)[number]["value"] | "eraser" | "hand" | "frame" | "iframe";
57
58
  } | {
58
59
  type: "custom";
59
60
  customType: string;
@@ -154,9 +155,11 @@ export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) =
154
155
  export declare const updateObject: <T extends Record<string, any>>(obj: T, updates: Partial<T>) => T;
155
156
  export declare const isPrimitive: (val: any) => boolean;
156
157
  export declare const getFrame: () => "top" | "iframe";
158
+ export declare const isRunningInIframe: () => boolean;
157
159
  export declare const isPromiseLike: (value: any) => value is Promise<any>;
158
160
  export declare const queryFocusableElements: (container: HTMLElement | null) => HTMLElement[];
159
161
  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
162
  export declare const composeEventHandlers: <E>(originalEventHandler?: ((event: E) => void) | undefined, ourEventHandler?: ((event: E) => void) | undefined, { checkForDefaultPrevented }?: {
161
163
  checkForDefaultPrevented?: boolean | undefined;
162
164
  }) => (event: E) => void;
165
+ export declare const isOnlyExportingSingleFrame: (elements: readonly NonDeletedExcalidrawElement[]) => boolean;
package/types/zindex.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ExcalidrawElement } from "./element/types";
2
2
  import { AppState } from "./types";
3
- export declare const moveOneLeft: (elements: readonly ExcalidrawElement[], appState: AppState) => (import("./element/types").ExcalidrawLinearElement | import("./element/types").ExcalidrawSelectionElement | import("./element/types").ExcalidrawRectangleElement | import("./element/types").ExcalidrawDiamondElement | import("./element/types").ExcalidrawEllipseElement | import("./element/types").ExcalidrawImageElement | import("./element/types").ExcalidrawTextElement | import("./element/types").ExcalidrawFreeDrawElement)[];
4
- export declare const moveOneRight: (elements: readonly ExcalidrawElement[], appState: AppState) => (import("./element/types").ExcalidrawLinearElement | import("./element/types").ExcalidrawSelectionElement | import("./element/types").ExcalidrawRectangleElement | import("./element/types").ExcalidrawDiamondElement | import("./element/types").ExcalidrawEllipseElement | import("./element/types").ExcalidrawImageElement | import("./element/types").ExcalidrawTextElement | import("./element/types").ExcalidrawFreeDrawElement)[];
5
- export declare const moveAllLeft: (elements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[];
6
- export declare const moveAllRight: (elements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[];
3
+ export declare const moveOneLeft: (elements: readonly ExcalidrawElement[], appState: AppState, elementsToBeMoved?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
4
+ export declare const moveOneRight: (elements: readonly ExcalidrawElement[], appState: AppState, elementsToBeMoved?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
5
+ export declare const moveAllLeft: (elements: readonly ExcalidrawElement[], appState: AppState, elementsToBeMoved?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
6
+ export declare const moveAllRight: (elements: readonly ExcalidrawElement[], appState: AppState, elementsToBeMoved?: readonly ExcalidrawElement[]) => ExcalidrawElement[];