@zsviczian/excalidraw 0.15.2-obsidian-7 → 0.15.2-obsidian-9

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/dist/excalidraw.development.js +50 -50
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/package.json +1 -1
  4. package/types/actions/actionAddToLibrary.d.ts +27 -12
  5. package/types/actions/actionAlign.d.ts +19 -19
  6. package/types/actions/actionBoundText.d.ts +24 -14
  7. package/types/actions/actionCanvas.d.ts +120 -60
  8. package/types/actions/actionClipboard.d.ts +47 -22
  9. package/types/actions/actionDeleteSelected.d.ts +27 -12
  10. package/types/actions/actionDistribute.d.ts +5 -5
  11. package/types/actions/actionElementLock.d.ts +23 -13
  12. package/types/actions/actionExport.d.ts +82 -36
  13. package/types/actions/actionFinalize.d.ts +18 -11
  14. package/types/actions/actionFlip.d.ts +2 -2
  15. package/types/actions/actionFrame.d.ts +35 -20
  16. package/types/actions/actionGroup.d.ts +5 -5
  17. package/types/actions/actionLinearEditor.d.ts +11 -6
  18. package/types/actions/actionMenu.d.ts +27 -12
  19. package/types/actions/actionProperties.d.ts +117 -52
  20. package/types/actions/actionStyles.d.ts +9 -4
  21. package/types/actions/actionToggleGridMode.d.ts +9 -4
  22. package/types/actions/actionToggleStats.d.ts +9 -4
  23. package/types/actions/actionToggleViewMode.d.ts +9 -4
  24. package/types/actions/actionToggleZenMode.d.ts +9 -4
  25. package/types/actions/types.d.ts +4 -3
  26. package/types/appState.d.ts +2 -2
  27. package/types/components/App.d.ts +13 -8
  28. package/types/components/HintViewer.d.ts +3 -4
  29. package/types/components/LayerUI.d.ts +2 -1
  30. package/types/components/MobileMenu.d.ts +3 -2
  31. package/types/constants.d.ts +2 -2
  32. package/types/data/url.d.ts +5 -0
  33. package/types/element/Hyperlink.d.ts +9 -4
  34. package/types/element/collision.d.ts +2 -2
  35. package/types/element/embeddable.d.ts +176 -0
  36. package/types/element/linearElementEditor.d.ts +9 -4
  37. package/types/element/newElement.d.ts +4 -4
  38. package/types/element/typeChecks.d.ts +4 -4
  39. package/types/element/types.d.ts +6 -6
  40. package/types/frame.d.ts +2 -2
  41. package/types/groups.d.ts +3 -3
  42. package/types/scene/Scene.d.ts +13 -0
  43. package/types/types.d.ts +15 -10
  44. package/types/utility-types.d.ts +2 -0
  45. package/types/utils.d.ts +1 -1
package/types/groups.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { GroupId, ExcalidrawElement, NonDeleted } from "./element/types";
2
- import { AppState } from "./types";
1
+ import { GroupId, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
2
+ import { AppClassProperties, AppState } from "./types";
3
3
  export declare const selectGroup: (groupId: GroupId, appState: AppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => AppState;
4
4
  /**
5
5
  * If the element's group is selected, don't render an individual
@@ -12,7 +12,7 @@ export declare const getSelectedGroupIds: (appState: AppState) => GroupId[];
12
12
  * When you select an element, you often want to actually select the whole group it's in, unless
13
13
  * you're currently editing that group.
14
14
  */
15
- export declare const selectGroupsForSelectedElements: (appState: AppState, elements: readonly NonDeleted<ExcalidrawElement>[], prevAppState: AppState) => AppState;
15
+ export declare const selectGroupsForSelectedElements: (appState: AppState, elements: readonly NonDeletedExcalidrawElement[], prevAppState: AppState, app: AppClassProperties | null) => AppState;
16
16
  export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: AppState) => {
17
17
  [groupId: string]: boolean;
18
18
  };
@@ -1,5 +1,6 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameElement } from "../element/types";
2
2
  import { LinearElementEditor } from "../element/linearElementEditor";
3
+ import { AppState } from "../types";
3
4
  type ElementIdKey = InstanceType<typeof LinearElementEditor>["elementId"];
4
5
  type ElementKey = ExcalidrawElement | ElementIdKey;
5
6
  type SceneStateCallback = () => void;
@@ -16,9 +17,21 @@ declare class Scene {
16
17
  private nonDeletedFrames;
17
18
  private frames;
18
19
  private elementsMap;
20
+ private selectedElementsCache;
19
21
  getElementsIncludingDeleted(): readonly ExcalidrawElement[];
20
22
  getNonDeletedElements(): readonly NonDeletedExcalidrawElement[];
21
23
  getFramesIncludingDeleted(): readonly ExcalidrawFrameElement[];
24
+ getSelectedElements(opts: {
25
+ selectedElementIds: AppState["selectedElementIds"];
26
+ /**
27
+ * for specific cases where you need to use elements not from current
28
+ * scene state. This in effect will likely result in cache-miss, and
29
+ * the cache won't be updated in this case.
30
+ */
31
+ elements?: readonly ExcalidrawElement[];
32
+ includeBoundTextElement?: boolean;
33
+ includeElementsInFrames?: boolean;
34
+ }): NonDeleted<ExcalidrawElement>[];
22
35
  getNonDeletedFrames(): readonly NonDeleted<ExcalidrawFrameElement>[];
23
36
  getElement<T extends ExcalidrawElement>(id: T["id"]): T | null;
24
37
  getNonDeletedElement(id: ExcalidrawElement["id"]): NonDeleted<ExcalidrawElement> | null;
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, ExcalidrawFrameElement } from "./element/types";
2
+ import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawFrameElement, ExcalidrawEmbeddableElement } 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" | "frame" | "iframe";
61
+ type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame" | "embeddable";
62
62
  customType: null;
63
63
  } | {
64
64
  type: "custom";
@@ -75,7 +75,7 @@ export type AppState = {
75
75
  showWelcomeScreen: boolean;
76
76
  isLoading: boolean;
77
77
  errorMessage: React.ReactNode;
78
- activeIFrame: {
78
+ activeEmbeddable: {
79
79
  element: NonDeletedExcalidrawElement;
80
80
  state: "hover" | "active";
81
81
  } | null;
@@ -87,7 +87,12 @@ export type AppState = {
87
87
  startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
88
88
  suggestedBindings: SuggestedBinding[];
89
89
  frameToHighlight: NonDeleted<ExcalidrawFrameElement> | null;
90
- shouldRenderFrames: boolean;
90
+ frameRendering: {
91
+ enabled: boolean;
92
+ name: boolean;
93
+ outline: boolean;
94
+ clip: boolean;
95
+ };
91
96
  editingFrame: string | null;
92
97
  elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
93
98
  editingElement: NonDeletedExcalidrawElement | null;
@@ -100,7 +105,7 @@ export type AppState = {
100
105
  lastActiveTool: LastActiveTool;
101
106
  locked: boolean;
102
107
  } & ({
103
- type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame" | "iframe";
108
+ type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame" | "embeddable";
104
109
  customType: null;
105
110
  } | {
106
111
  type: "custom";
@@ -306,10 +311,10 @@ export interface ExcalidrawProps {
306
311
  onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
307
312
  onScrollChange?: (scrollX: number, scrollY: number) => void;
308
313
  children?: React.ReactNode;
309
- validateIFrame?: boolean | RegExp | RegExp[] | ((link: string) => boolean | undefined);
310
- renderCustomIFrame?: (element: NonDeletedExcalidrawElement, radius: number, appState: UIAppState) => JSX.Element | null;
314
+ validateEmbeddable?: boolean | string[] | RegExp | RegExp[] | ((link: string) => boolean | undefined);
315
+ renderEmbeddable?: (element: NonDeleted<ExcalidrawEmbeddableElement>, appState: AppState) => JSX.Element | null;
311
316
  renderWebview?: boolean;
312
- renderIFrameMenu?: (//zsivzian
317
+ renderEmbeddableMenu?: (//zsivzian
313
318
  appState: AppState) => JSX.Element | null;
314
319
  }
315
320
  export type SceneData = {
@@ -466,13 +471,13 @@ export type ExcalidrawImperativeAPI = {
466
471
  setCursor: InstanceType<typeof App>["setCursor"];
467
472
  resetCursor: InstanceType<typeof App>["resetCursor"];
468
473
  toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
469
- getIFrameElementById: InstanceType<typeof App>["getIFrameElementById"];
474
+ getHTMLIFrameElement: InstanceType<typeof App>["getHTMLIFrameElement"];
470
475
  /**
471
476
  * Disables rendering of frames (including element clipping), but currently
472
477
  * the frames are still interactive in edit mode. As such, this API should be
473
478
  * used in conjunction with view mode (props.viewModeEnabled).
474
479
  */
475
- toggleFrameRendering: InstanceType<typeof App>["toggleFrameRendering"];
480
+ updateFrameRendering: InstanceType<typeof App>["updateFrameRendering"];
476
481
  };
477
482
  export type Device = Readonly<{
478
483
  isSmScreen: boolean;
@@ -20,3 +20,5 @@ export type SignatureType<T> = T extends (...args: infer R) => any ? R : never;
20
20
  export type CallableType<T extends (...args: any[]) => any> = (...args: SignatureType<T>) => ReturnType<T>;
21
21
  export type ForwardRef<T, P = any> = Parameters<CallableType<React.ForwardRefRenderFunction<T, P>>>[1];
22
22
  export type ExtractSetType<T extends Set<any>> = T extends Set<infer U> ? U : never;
23
+ export type SameType<T, U> = T extends U ? (U extends T ? true : false) : false;
24
+ export type Assert<T extends true> = T;
package/types/utils.d.ts CHANGED
@@ -81,7 +81,7 @@ export declare const selectNode: (node: Element) => void;
81
81
  export declare const removeSelection: () => void;
82
82
  export declare const distance: (x: number, y: number) => number;
83
83
  export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">, data: ({
84
- type: (typeof SHAPES)[number]["value"] | "eraser" | "hand" | "frame" | "iframe";
84
+ type: (typeof SHAPES)[number]["value"] | "eraser" | "hand" | "frame" | "embeddable";
85
85
  } | {
86
86
  type: "custom";
87
87
  customType: string;