@zsviczian/excalidraw 0.15.2-obsidian-4 → 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 (71) hide show
  1. package/README.md +4 -0
  2. package/dist/excalidraw.development.js +249 -141
  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/components/App.d.ts +17 -2
  33. package/types/components/Avatar.d.ts +0 -1
  34. package/types/components/Dialog.d.ts +2 -1
  35. package/types/components/FilledButton.d.ts +2 -1
  36. package/types/components/OverwriteConfirm/OverwriteConfirm.d.ts +17 -0
  37. package/types/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +17 -0
  38. package/types/components/OverwriteConfirm/OverwriteConfirmState.d.ts +22 -0
  39. package/types/components/ToolButton.d.ts +2 -1
  40. package/types/components/dropdownMenu/DropdownMenu.d.ts +3 -2
  41. package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +4 -2
  42. package/types/components/icons.d.ts +4 -0
  43. package/types/components/main-menu/MainMenu.d.ts +3 -2
  44. package/types/constants.d.ts +23 -1
  45. package/types/context/tunnels.d.ts +1 -0
  46. package/types/element/Hyperlink.d.ts +21 -6
  47. package/types/element/binding.d.ts +1 -1
  48. package/types/element/bounds.d.ts +31 -6
  49. package/types/element/collision.d.ts +7 -7
  50. package/types/element/dragElements.d.ts +2 -1
  51. package/types/element/iframe.d.ts +173 -0
  52. package/types/element/index.d.ts +3 -2
  53. package/types/element/linearElementEditor.d.ts +11 -2
  54. package/types/element/newElement.d.ts +8 -2
  55. package/types/element/transformHandles.d.ts +8 -1
  56. package/types/element/typeChecks.d.ts +5 -3
  57. package/types/element/types.d.ts +13 -4
  58. package/types/frame.d.ts +40 -0
  59. package/types/groups.d.ts +4 -0
  60. package/types/keys.d.ts +2 -0
  61. package/types/math.d.ts +1 -0
  62. package/types/packages/excalidraw/example/initialData.d.ts +6 -0
  63. package/types/renderer/renderElement.d.ts +3 -2
  64. package/types/renderer/renderScene.d.ts +12 -3
  65. package/types/renderer/roundRect.d.ts +1 -1
  66. package/types/scene/Scene.d.ts +8 -1
  67. package/types/scene/export.d.ts +1 -0
  68. package/types/scene/selection.d.ts +13 -3
  69. package/types/types.d.ts +34 -3
  70. package/types/utils.d.ts +5 -2
  71. package/types/zindex.d.ts +4 -4
@@ -0,0 +1,173 @@
1
+ /// <reference types="react" />
2
+ import { ExcalidrawProps } from "../types";
3
+ import { ExcalidrawElement, NonDeletedExcalidrawElement } from "./types";
4
+ type EmbeddedLink = {
5
+ link: string;
6
+ aspectRatio: {
7
+ w: number;
8
+ h: number;
9
+ };
10
+ type: "video" | "generic";
11
+ } | null;
12
+ export declare const getEmbedLink: (link?: string | null) => EmbeddedLink;
13
+ export declare const hideActionForIFrame: (element: ExcalidrawElement | undefined, props: ExcalidrawProps) => boolean | "" | null;
14
+ export declare const isIFrameOrFrameLabel: (element: NonDeletedExcalidrawElement) => Boolean;
15
+ export declare const createPlaceholderiFrameLabel: (element: NonDeletedExcalidrawElement) => ExcalidrawElement;
16
+ export declare const actionSetIFrameAsActiveTool: {
17
+ name: "setIFrameAsActiveTool";
18
+ trackEvent: {
19
+ category: "toolbar";
20
+ };
21
+ perform: (elements: readonly ExcalidrawElement[], appState: Readonly<import("../types").AppState>, _: any, app: import("../types").AppClassProperties) => {
22
+ elements: readonly ExcalidrawElement[];
23
+ appState: {
24
+ activeTool: {
25
+ lastActiveTool: import("../types").LastActiveTool;
26
+ locked: boolean;
27
+ } & ({
28
+ type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "iframe" | "image" | "frame" | "freedraw" | "eraser" | "hand";
29
+ customType: null;
30
+ } | {
31
+ type: "custom";
32
+ customType: string;
33
+ });
34
+ contextMenu: {
35
+ items: import("../components/ContextMenu").ContextMenuItems;
36
+ top: number;
37
+ left: number;
38
+ } | null;
39
+ showWelcomeScreen: boolean;
40
+ isLoading: boolean;
41
+ errorMessage: import("react").ReactNode;
42
+ activeIFrame: {
43
+ element: NonDeletedExcalidrawElement;
44
+ state: "active" | "hover";
45
+ } | null;
46
+ draggingElement: NonDeletedExcalidrawElement | null;
47
+ resizingElement: NonDeletedExcalidrawElement | null;
48
+ multiElement: import("./types").NonDeleted<import("./types").ExcalidrawLinearElement> | null;
49
+ selectionElement: NonDeletedExcalidrawElement | null;
50
+ isBindingEnabled: boolean;
51
+ startBoundElement: import("./types").NonDeleted<import("./types").ExcalidrawBindableElement> | null;
52
+ suggestedBindings: import("./binding").SuggestedBinding[];
53
+ frameToHighlight: import("./types").NonDeleted<import("./types").ExcalidrawFrameElement> | null;
54
+ shouldRenderFrames: boolean;
55
+ editingFrame: string | null;
56
+ elementsToHighlight: import("./types").NonDeleted<ExcalidrawElement>[] | null;
57
+ editingElement: NonDeletedExcalidrawElement | null;
58
+ editingLinearElement: import("./linearElementEditor").LinearElementEditor | null;
59
+ penMode: boolean;
60
+ penDetected: boolean;
61
+ exportBackground: boolean;
62
+ exportEmbedScene: boolean;
63
+ exportWithDarkMode: boolean;
64
+ exportScale: number;
65
+ currentItemStrokeColor: string;
66
+ currentItemBackgroundColor: string;
67
+ currentItemFillStyle: import("./types").FillStyle;
68
+ currentItemStrokeWidth: number;
69
+ currentItemStrokeStyle: import("./types").StrokeStyle;
70
+ currentItemRoughness: number;
71
+ currentItemOpacity: number;
72
+ currentItemFontFamily: number;
73
+ currentItemFontSize: number;
74
+ currentItemTextAlign: string;
75
+ currentItemStartArrowhead: import("./types").Arrowhead | null;
76
+ currentItemEndArrowhead: import("./types").Arrowhead | null;
77
+ currentItemRoundness: import("./types").StrokeRoundness;
78
+ viewBackgroundColor: string;
79
+ scrollX: number;
80
+ scrollY: number;
81
+ cursorButton: "up" | "down";
82
+ scrolledOutside: boolean;
83
+ name: string;
84
+ isResizing: boolean;
85
+ isRotating: boolean;
86
+ zoom: Readonly<{
87
+ value: import("../types").NormalizedZoomValue;
88
+ }>;
89
+ openMenu: "canvas" | "shape" | null;
90
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
91
+ openSidebar: {
92
+ name: string;
93
+ tab?: string | undefined;
94
+ } | null;
95
+ openDialog: "imageExport" | "help" | "jsonExport" | null;
96
+ defaultSidebarDockedPreference: boolean;
97
+ lastPointerDownWith: import("./types").PointerType;
98
+ selectedElementIds: {
99
+ [id: string]: boolean;
100
+ };
101
+ previousSelectedElementIds: {
102
+ [id: string]: boolean;
103
+ };
104
+ selectedElementsAreBeingDragged: boolean;
105
+ shouldCacheIgnoreZoom: boolean;
106
+ toast: {
107
+ message: string;
108
+ closable?: boolean | undefined;
109
+ duration?: number | undefined;
110
+ } | null;
111
+ zenModeEnabled: boolean;
112
+ theme: string;
113
+ gridSize: number | null;
114
+ previousGridSize: number | null;
115
+ viewModeEnabled: boolean;
116
+ selectedGroupIds: {
117
+ [groupId: string]: boolean;
118
+ };
119
+ editingGroupId: string | null;
120
+ width: number;
121
+ height: number;
122
+ offsetTop: number;
123
+ offsetLeft: number;
124
+ fileHandle: import("browser-fs-access").FileSystemHandle | null;
125
+ collaborators: Map<string, import("../types").Collaborator>;
126
+ showStats: boolean;
127
+ currentChartType: import("./types").ChartType;
128
+ pasteDialog: {
129
+ shown: false;
130
+ data: null;
131
+ } | {
132
+ shown: true;
133
+ data: import("../charts").Spreadsheet;
134
+ };
135
+ pendingImageElementId: string | null;
136
+ showHyperlinkPopup: false | "info" | "editor";
137
+ linkOpacity: number;
138
+ trayModeEnabled: boolean;
139
+ colorPalette?: {
140
+ canvasBackground: import("../colors").ColorPaletteCustom;
141
+ elementBackground: import("../colors").ColorPaletteCustom;
142
+ elementStroke: import("../colors").ColorPaletteCustom;
143
+ topPicks: {
144
+ canvasBackground: [string, string, string, string, string];
145
+ elementStroke: [string, string, string, string, string];
146
+ elementBackground: [string, string, string, string, string];
147
+ };
148
+ } | undefined;
149
+ allowWheelZoom?: boolean | undefined;
150
+ allowPinchZoom?: boolean | undefined;
151
+ pinnedScripts?: string[] | undefined;
152
+ customPens?: any[] | undefined;
153
+ currentStrokeOptions?: any;
154
+ resetCustomPen?: any;
155
+ gridColor: string;
156
+ dynamicStyle: string;
157
+ invertBindingBehaviour: boolean;
158
+ selectedLinearElement: import("./linearElementEditor").LinearElementEditor | null;
159
+ };
160
+ commitToHistory: false;
161
+ };
162
+ keyTest: (event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean;
163
+ } & {
164
+ keyTest?: ((event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean) | undefined;
165
+ };
166
+ export declare class IFrameURLValidator {
167
+ private static instance;
168
+ private validators;
169
+ private constructor();
170
+ static getInstance(validators?: RegExp[]): IFrameURLValidator;
171
+ run(url: string | null | undefined): boolean;
172
+ }
173
+ export {};
@@ -1,4 +1,4 @@
1
- import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
1
+ import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameElement } from "./types";
2
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";
@@ -6,7 +6,7 @@ export { hitTest, isHittingElementBoundingBoxWithoutHittingElement, } from "./co
6
6
  export { resizeTest, getCursorForResizingElement, getElementWithTransformHandleType, getTransformHandleTypeFromCoords, } from "./resizeTest";
7
7
  export { transformElements, getResizeOffsetXY, getResizeArrowDirection, } from "./resizeElements";
8
8
  export { dragSelectedElements, getDragOffsetXY, dragNewElement, } from "./dragElements";
9
- export { isTextElement, isExcalidrawElement } from "./typeChecks";
9
+ export { isTextElement, isExcalidrawElement, isFrameElement, } from "./typeChecks";
10
10
  export { textWysiwyg } from "./textWysiwyg";
11
11
  export { redrawTextBoundingBox } from "./textElement";
12
12
  export { getPerfectElementSize, getLockedLinearCursorAlignSize, isInvisiblySmallElement, resizePerfectLineForNWHandler, getNormalizedDimensions, } from "./sizeHelpers";
@@ -14,6 +14,7 @@ export { showSelectedShapeActions } from "./showSelectedShapeActions";
14
14
  export declare const getSceneVersion: (elements: readonly ExcalidrawElement[]) => number;
15
15
  export declare const getVisibleElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
16
16
  export declare const getNonDeletedElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
17
+ export declare const getNonDeletedFrames: (frames: readonly ExcalidrawFrameElement[]) => readonly NonDeleted<ExcalidrawFrameElement>[];
17
18
  export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element: T) => element is NonDeleted<T>;
18
19
  export declare const clearElementsForDatabase: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
19
20
  export declare const clearElementsForExport: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
@@ -62,7 +62,7 @@ export declare class LinearElementEditor {
62
62
  static isSegmentTooShort(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, zoom: AppState["zoom"]): boolean;
63
63
  static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, endPointIndex: number): readonly [number, number];
64
64
  static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: Point): number;
65
- static handlePointerDown(event: React.PointerEvent<HTMLCanvasElement>, appState: AppState, history: History, scenePointer: {
65
+ static handlePointerDown(event: React.PointerEvent<HTMLElement>, appState: AppState, history: History, scenePointer: {
66
66
  x: number;
67
67
  y: number;
68
68
  }, linearElementEditor: LinearElementEditor): {
@@ -131,6 +131,10 @@ export declare class LinearElementEditor {
131
131
  showWelcomeScreen: boolean;
132
132
  isLoading: boolean;
133
133
  errorMessage: import("react").ReactNode;
134
+ activeIFrame: {
135
+ element: import("./types").NonDeletedExcalidrawElement;
136
+ state: "active" | "hover";
137
+ } | null;
134
138
  draggingElement: import("./types").NonDeletedExcalidrawElement | null;
135
139
  resizingElement: import("./types").NonDeletedExcalidrawElement | null;
136
140
  multiElement: NonDeleted<ExcalidrawLinearElement> | null;
@@ -138,12 +142,16 @@ export declare class LinearElementEditor {
138
142
  isBindingEnabled: boolean;
139
143
  startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
140
144
  suggestedBindings: import("./binding").SuggestedBinding[];
145
+ frameToHighlight: NonDeleted<import("./types").ExcalidrawFrameElement> | null;
146
+ shouldRenderFrames: boolean;
147
+ editingFrame: string | null;
148
+ elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
141
149
  editingElement: import("./types").NonDeletedExcalidrawElement | null;
142
150
  activeTool: {
143
151
  lastActiveTool: import("../types").LastActiveTool;
144
152
  locked: boolean;
145
153
  } & ({
146
- type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser" | "hand";
154
+ type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "iframe" | "image" | "frame" | "freedraw" | "eraser" | "hand";
147
155
  customType: null;
148
156
  } | {
149
157
  type: "custom";
@@ -194,6 +202,7 @@ export declare class LinearElementEditor {
194
202
  previousSelectedElementIds: {
195
203
  [id: string]: boolean;
196
204
  };
205
+ selectedElementsAreBeingDragged: boolean;
197
206
  shouldCacheIgnoreZoom: boolean;
198
207
  toast: {
199
208
  message: string;
@@ -1,10 +1,15 @@
1
- import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer } from "../element/types";
1
+ import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawIFrameElement } from "../element/types";
2
2
  import { AppState } from "../types";
3
3
  import { MarkOptional, Mutable } from "../utility-types";
4
- type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity">;
4
+ type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity">;
5
5
  export declare const newElement: (opts: {
6
6
  type: ExcalidrawGenericElement["type"];
7
7
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawGenericElement>;
8
+ export declare const newIFrameElement: (opts: {
9
+ type: "iframe";
10
+ whitelisted: boolean;
11
+ } & ElementConstructorOpts) => NonDeleted<ExcalidrawIFrameElement>;
12
+ export declare const newFrameElement: (opts: ElementConstructorOpts) => NonDeleted<ExcalidrawFrameElement>;
8
13
  export declare const newTextElement: (opts: {
9
14
  text: string;
10
15
  rawText: string;
@@ -15,6 +20,7 @@ export declare const newTextElement: (opts: {
15
20
  containerId?: ExcalidrawTextContainer["id"];
16
21
  lineHeight?: ExcalidrawTextElement["lineHeight"];
17
22
  strokeWidth?: ExcalidrawTextElement["strokeWidth"];
23
+ isFrameName?: boolean;
18
24
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
19
25
  export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, text?: string) => {
20
26
  x: number;
@@ -13,11 +13,18 @@ export declare const OMIT_SIDES_FOR_MULTIPLE_ELEMENTS: {
13
13
  n: boolean;
14
14
  w: boolean;
15
15
  };
16
+ export declare const OMIT_SIDES_FOR_FRAME: {
17
+ e: boolean;
18
+ s: boolean;
19
+ n: boolean;
20
+ w: boolean;
21
+ rotation: boolean;
22
+ };
16
23
  export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [number, number, number, number, number, number], angle: number, zoom: Zoom, pointerType: PointerType, omitSides?: {
17
24
  s?: boolean | undefined;
18
25
  e?: boolean | undefined;
19
- n?: boolean | undefined;
20
26
  w?: boolean | undefined;
27
+ n?: boolean | undefined;
21
28
  nw?: boolean | undefined;
22
29
  ne?: boolean | undefined;
23
30
  sw?: boolean | undefined;
@@ -1,17 +1,19 @@
1
1
  import { AppState } from "../types";
2
2
  import { MarkNonNullable } from "../utility-types";
3
- import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawGenericElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, RoundnessType } from "./types";
3
+ import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawIFrameElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawGenericElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType } from "./types";
4
4
  export declare const isGenericElement: (element: ExcalidrawElement | null) => element is ExcalidrawGenericElement;
5
5
  export declare const isInitializedImageElement: (element: ExcalidrawElement | null) => element is InitializedExcalidrawImageElement;
6
6
  export declare const isImageElement: (element: ExcalidrawElement | null) => element is ExcalidrawImageElement;
7
+ export declare const isIFrameElement: (element: ExcalidrawElement | null | undefined) => element is ExcalidrawIFrameElement;
7
8
  export declare const isTextElement: (element: ExcalidrawElement | null) => element is ExcalidrawTextElement;
9
+ export declare const isFrameElement: (element: ExcalidrawElement | null) => element is ExcalidrawFrameElement;
8
10
  export declare const isFreeDrawElement: (element?: ExcalidrawElement | null) => element is ExcalidrawFreeDrawElement;
9
11
  export declare const isFreeDrawElementType: (elementType: ExcalidrawElement["type"]) => boolean;
10
12
  export declare const isLinearElement: (element?: ExcalidrawElement | null) => element is ExcalidrawLinearElement;
11
13
  export declare const isArrowElement: (element?: ExcalidrawElement | null) => element is ExcalidrawLinearElement;
12
- export declare const isLinearElementType: (elementType: AppState["activeTool"]["type"]) => boolean;
14
+ export declare const isLinearElementType: (elementType: AppState["activeTool"]["type"] | "iframe") => boolean;
13
15
  export declare const isBindingElement: (element?: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawLinearElement;
14
- export declare const isBindingElementType: (elementType: AppState["activeTool"]["type"]) => boolean;
16
+ export declare const isBindingElementType: (elementType: AppState["activeTool"]["type"] | "iframe") => boolean;
15
17
  export declare const isBindableElement: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawBindableElement;
16
18
  export declare const isTextBindableContainer: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawTextContainer;
17
19
  export declare const isExcalidrawElement: (element: any) => boolean;
@@ -49,6 +49,7 @@ type _ExcalidrawElementBase = Readonly<{
49
49
  /** List of groups the element belongs to.
50
50
  Ordered from deepest to shallowest. */
51
51
  groupIds: readonly GroupId[];
52
+ frameId: string | null;
52
53
  /** other elements that are bound to this element */
53
54
  boundElements: readonly Readonly<{
54
55
  id: ExcalidrawLinearElement["id"];
@@ -72,6 +73,10 @@ export type ExcalidrawDiamondElement = _ExcalidrawElementBase & {
72
73
  export type ExcalidrawEllipseElement = _ExcalidrawElementBase & {
73
74
  type: "ellipse";
74
75
  };
76
+ export type ExcalidrawIFrameElement = _ExcalidrawElementBase & Readonly<{
77
+ whitelisted?: boolean;
78
+ type: "iframe";
79
+ }>;
75
80
  export type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
76
81
  type: "image";
77
82
  fileId: FileId | null;
@@ -81,16 +86,20 @@ export type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
81
86
  scale: [number, number];
82
87
  }>;
83
88
  export type InitializedExcalidrawImageElement = MarkNonNullable<ExcalidrawImageElement, "fileId">;
89
+ export type ExcalidrawFrameElement = _ExcalidrawElementBase & {
90
+ type: "frame";
91
+ name: string | null;
92
+ };
84
93
  /**
85
94
  * These are elements that don't have any additional properties.
86
95
  */
87
- export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
96
+ export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawIFrameElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
88
97
  /**
89
98
  * ExcalidrawElement should be JSON serializable and (eventually) contain
90
99
  * no computed data. The list of all ExcalidrawElements should be shareable
91
100
  * between peers and contain no state local to the peer.
92
101
  */
93
- export type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement;
102
+ export type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement | ExcalidrawFrameElement;
94
103
  export type NonDeleted<TElement extends ExcalidrawElement> = TElement & {
95
104
  isDeleted: boolean;
96
105
  };
@@ -114,8 +123,8 @@ export type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
114
123
  _brand: "unitlessLineHeight";
115
124
  };
116
125
  }>;
117
- export type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement;
118
- export type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawImageElement | ExcalidrawArrowElement;
126
+ export type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement | ExcalidrawIFrameElement | ExcalidrawFrameElement;
127
+ export type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawArrowElement | ExcalidrawIFrameElement;
119
128
  export type ExcalidrawTextElementWithContainer = {
120
129
  containerId: ExcalidrawTextContainer["id"];
121
130
  } & ExcalidrawTextElement;
@@ -0,0 +1,40 @@
1
+ import { ExcalidrawElement, ExcalidrawFrameElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
2
+ import { AppState } from "./types";
3
+ import { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
4
+ export declare const bindElementsToFramesAfterDuplication: (nextElements: ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
5
+ export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
6
+ export declare const isElementContainingFrame: (elements: readonly ExcalidrawElement[], element: ExcalidrawElement, frame: ExcalidrawFrameElement) => boolean;
7
+ export declare const getElementsIntersectingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
8
+ export declare const elementsAreInFrameBounds: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => boolean;
9
+ export declare const elementOverlapsWithFrame: (element: ExcalidrawElement, frame: ExcalidrawFrameElement) => boolean;
10
+ export declare const isCursorInFrame: (cursorCoords: {
11
+ x: number;
12
+ y: number;
13
+ }, frame: NonDeleted<ExcalidrawFrameElement>) => boolean;
14
+ export declare const groupsAreAtLeastIntersectingTheFrame: (elements: readonly NonDeletedExcalidrawElement[], groupIds: readonly string[], frame: ExcalidrawFrameElement) => boolean;
15
+ export declare const groupsAreCompletelyOutOfFrame: (elements: readonly NonDeletedExcalidrawElement[], groupIds: readonly string[], frame: ExcalidrawFrameElement) => boolean;
16
+ /**
17
+ * Returns a map of frameId to frame elements. Includes empty frames.
18
+ */
19
+ export declare const groupByFrames: (elements: readonly ExcalidrawElement[]) => Map<string, ExcalidrawElement[]>;
20
+ export declare const getFrameElements: (allElements: ExcalidrawElementsIncludingDeleted, frameId: string) => ExcalidrawElement[];
21
+ export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
22
+ export declare const getElementsInNewFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement) => ExcalidrawElement[];
23
+ export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap?: Map<string, ExcalidrawElement>) => ExcalidrawFrameElement | null;
24
+ export declare const addElementsToFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToAdd: NonDeletedExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
25
+ export declare const removeElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToRemove: NonDeletedExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
26
+ export declare const removeAllElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
27
+ export declare const replaceAllElementsInFrame: (allElements: ExcalidrawElementsIncludingDeleted, nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
28
+ /** does not mutate elements, but return new ones */
29
+ export declare const updateFrameMembershipOfSelectedElements: (allElements: ExcalidrawElementsIncludingDeleted, appState: AppState) => ExcalidrawElementsIncludingDeleted;
30
+ /**
31
+ * filters out elements that are inside groups that contain a frame element
32
+ * anywhere in the group tree
33
+ */
34
+ export declare const omitGroupsContainingFrames: (allElements: ExcalidrawElementsIncludingDeleted, selectedElements?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
35
+ /**
36
+ * depending on the appState, return target frame, which is the frame the given element
37
+ * is going to be added to or remove from
38
+ */
39
+ export declare const getTargetFrame: (element: ExcalidrawElement, appState: AppState) => ExcalidrawFrameElement | null;
40
+ export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ExcalidrawElementsIncludingDeleted, appState: AppState) => boolean;
package/types/groups.d.ts CHANGED
@@ -13,6 +13,9 @@ export declare const getSelectedGroupIds: (appState: AppState) => GroupId[];
13
13
  * you're currently editing that group.
14
14
  */
15
15
  export declare const selectGroupsForSelectedElements: (appState: AppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => AppState;
16
+ export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: AppState) => {
17
+ [groupId: string]: boolean;
18
+ };
16
19
  export declare const editGroupForSelectedElement: (appState: AppState, element: NonDeleted<ExcalidrawElement>) => AppState;
17
20
  export declare const isElementInGroup: (element: ExcalidrawElement, groupId: string) => boolean;
18
21
  export declare const getElementsInGroup: (elements: readonly ExcalidrawElement[], groupId: string) => ExcalidrawElement[];
@@ -25,3 +28,4 @@ export declare const removeFromSelectedGroups: (groupIds: ExcalidrawElement["gro
25
28
  [groupId: string]: boolean;
26
29
  }) => string[];
27
30
  export declare const getMaximumGroups: (elements: ExcalidrawElement[]) => ExcalidrawElement[][];
31
+ export declare const elementsAreInSameGroup: (elements: ExcalidrawElement[]) => boolean;
package/types/keys.d.ts CHANGED
@@ -39,6 +39,7 @@ export declare const KEYS: {
39
39
  readonly CHEVRON_RIGHT: ">";
40
40
  readonly PERIOD: ".";
41
41
  readonly COMMA: ",";
42
+ readonly SUBTRACT: "-";
42
43
  readonly A: "a";
43
44
  readonly C: "c";
44
45
  readonly D: "d";
@@ -59,6 +60,7 @@ export declare const KEYS: {
59
60
  readonly Y: "y";
60
61
  readonly Z: "z";
61
62
  readonly K: "k";
63
+ readonly W: "w";
62
64
  readonly 0: "0";
63
65
  readonly 1: "1";
64
66
  readonly 2: "2";
package/types/math.d.ts CHANGED
@@ -17,6 +17,7 @@ export declare const distance2d: (x1: number, y1: number, x2: number, y2: number
17
17
  export declare const centerPoint: (a: readonly [number, number], b: readonly [number, number]) => readonly [number, number];
18
18
  export declare const isPathALoop: (points: ExcalidrawLinearElement["points"], zoomValue?: Zoom["value"]) => boolean;
19
19
  export declare const isPointInPolygon: (points: Point[], x: number, y: number) => boolean;
20
+ export declare const isPointWithinBounds: (p: readonly [number, number], q: readonly [number, number], r: readonly [number, number]) => boolean;
20
21
  export declare const getGridPoint: (x: number, y: number, gridSize: number | null) => [number, number];
21
22
  export declare const getCornerRadius: (x: number, element: ExcalidrawElement) => number;
22
23
  export declare const getControlPointsForBezierCurve: (element: NonDeleted<ExcalidrawLinearElement>, endPoint: readonly [number, number]) => [number, number][] | null;
@@ -19,6 +19,7 @@ declare namespace _default {
19
19
  height: number;
20
20
  seed: number;
21
21
  groupIds: never[];
22
+ frameId: null;
22
23
  fileId?: undefined;
23
24
  strokeSharpness?: undefined;
24
25
  boundElements?: undefined;
@@ -42,6 +43,7 @@ declare namespace _default {
42
43
  roughness: number;
43
44
  opacity: number;
44
45
  groupIds: never[];
46
+ frameId: null;
45
47
  strokeSharpness: string;
46
48
  seed: number;
47
49
  version: number;
@@ -79,6 +81,7 @@ declare namespace _default {
79
81
  height: number;
80
82
  seed: number;
81
83
  groupIds: string[];
84
+ frameId: null;
82
85
  strokeSharpness: string;
83
86
  boundElementIds: never[];
84
87
  startBinding: null;
@@ -107,6 +110,7 @@ declare namespace _default {
107
110
  height: number;
108
111
  seed: number;
109
112
  groupIds: string[];
113
+ frameId: null;
110
114
  strokeSharpness: string;
111
115
  boundElementIds: string[];
112
116
  startBinding?: undefined;
@@ -135,6 +139,7 @@ declare namespace _default {
135
139
  height: number;
136
140
  seed: number;
137
141
  groupIds: string[];
142
+ frameId: null;
138
143
  strokeSharpness: string;
139
144
  boundElementIds: string[];
140
145
  points?: undefined;
@@ -161,6 +166,7 @@ declare namespace _default {
161
166
  height: number;
162
167
  seed: number;
163
168
  groupIds: string[];
169
+ frameId: null;
164
170
  strokeSharpness: string;
165
171
  boundElementIds: never[];
166
172
  points: number[][];
@@ -13,6 +13,7 @@ export interface ExcalidrawElementWithCanvas {
13
13
  canvasOffsetX: number;
14
14
  canvasOffsetY: number;
15
15
  boundTextElementVersion: number | null;
16
+ containingFrameOpacity: number;
16
17
  }
17
18
  export declare const DEFAULT_LINK_SIZE = 14;
18
19
  type ElementShape = Drawable | Drawable[] | null;
@@ -26,9 +27,9 @@ type ElementShapes = {
26
27
  export declare const getShapeForElement: <T extends ExcalidrawElement>(element: T) => T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : Drawable | null | undefined;
27
28
  export declare const setShapeForElement: <T extends ExcalidrawElement>(element: T, shape: T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable) => WeakMap<ExcalidrawElement, ElementShape>;
28
29
  export declare const invalidateShapeForElement: (element: ExcalidrawElement) => boolean;
29
- export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
30
+ export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean, isExporting?: boolean) => Options;
30
31
  export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: RenderConfig, appState: AppState) => void;
31
- export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, exportWithDarkMode?: boolean) => void;
32
+ export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, exportWithDarkMode?: boolean, exportingFrameId?: string | null) => void;
32
33
  export declare const pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
33
34
  export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
34
35
  export declare function getFreeDrawPath2D(element: ExcalidrawFreeDrawElement): Path2D | undefined;
@@ -1,8 +1,9 @@
1
1
  import { RoughCanvas } from "roughjs/bin/canvas";
2
2
  import { RoughSVG } from "roughjs/bin/svg";
3
- import { AppState, BinaryFiles } from "../types";
4
- import { NonDeletedExcalidrawElement } from "../element/types";
3
+ import { AppState, BinaryFiles, Zoom } from "../types";
4
+ import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
5
5
  import { RenderConfig } from "../scene/types";
6
+ import "canvas-roundrect-polyfill";
6
7
  export declare const DEFAULT_SPACING = 2;
7
8
  export declare const _renderScene: ({ elements, appState, scale, rc, canvas, renderConfig, }: {
8
9
  elements: readonly NonDeletedExcalidrawElement[];
@@ -34,8 +35,16 @@ export declare const renderScene: <T extends boolean = false>(config: {
34
35
  atLeastOneVisibleElement: boolean;
35
36
  scrollBars: import("../scene/types").ScrollBars | undefined;
36
37
  };
37
- export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, { offsetX, offsetY, exportWithDarkMode, }?: {
38
+ export declare const isVisibleElement: (element: ExcalidrawElement, canvasWidth: number, canvasHeight: number, viewTransformations: {
39
+ zoom: Zoom;
40
+ offsetLeft: number;
41
+ offsetTop: number;
42
+ scrollX: number;
43
+ scrollY: number;
44
+ }) => boolean;
45
+ export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, { offsetX, offsetY, exportWithDarkMode, exportingFrameId, }?: {
38
46
  offsetX?: number | undefined;
39
47
  offsetY?: number | undefined;
40
48
  exportWithDarkMode?: boolean | undefined;
49
+ exportingFrameId?: string | null | undefined;
41
50
  }) => void;
@@ -8,4 +8,4 @@
8
8
  * @param {Number} height The height of the rectangle
9
9
  * @param {Number} radius The corner radius
10
10
  */
11
- export declare const roundRect: (context: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number) => void;
11
+ export declare const roundRect: (context: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number, strokeColor?: string) => void;
@@ -1,9 +1,10 @@
1
- import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "../element/types";
1
+ import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameElement } from "../element/types";
2
2
  import { LinearElementEditor } from "../element/linearElementEditor";
3
3
  type ElementIdKey = InstanceType<typeof LinearElementEditor>["elementId"];
4
4
  type ElementKey = ExcalidrawElement | ElementIdKey;
5
5
  type SceneStateCallback = () => void;
6
6
  type SceneStateCallbackRemover = () => void;
7
+ export type ExcalidrawElementsIncludingDeleted = readonly ExcalidrawElement[];
7
8
  declare class Scene {
8
9
  private static sceneMapByElement;
9
10
  private static sceneMapById;
@@ -12,9 +13,13 @@ declare class Scene {
12
13
  private callbacks;
13
14
  private nonDeletedElements;
14
15
  private elements;
16
+ private nonDeletedFrames;
17
+ private frames;
15
18
  private elementsMap;
16
19
  getElementsIncludingDeleted(): readonly ExcalidrawElement[];
17
20
  getNonDeletedElements(): readonly NonDeletedExcalidrawElement[];
21
+ getFramesIncludingDeleted(): readonly ExcalidrawFrameElement[];
22
+ getNonDeletedFrames(): readonly NonDeleted<ExcalidrawFrameElement>[];
18
23
  getElement<T extends ExcalidrawElement>(id: T["id"]): T | null;
19
24
  getNonDeletedElement(id: ExcalidrawElement["id"]): NonDeleted<ExcalidrawElement> | null;
20
25
  /**
@@ -35,6 +40,8 @@ declare class Scene {
35
40
  addCallback(cb: SceneStateCallback): SceneStateCallbackRemover;
36
41
  destroy(): void;
37
42
  insertElementAtIndex(element: ExcalidrawElement, index: number): void;
43
+ insertElementsAtIndex(elements: ExcalidrawElement[], index: number): void;
44
+ addNewElement: (element: ExcalidrawElement) => void;
38
45
  getElementIndex(elementId: string): number;
39
46
  }
40
47
  export default Scene;
@@ -17,6 +17,7 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
17
17
  viewBackgroundColor: string;
18
18
  exportWithDarkMode?: boolean;
19
19
  exportEmbedScene?: boolean;
20
+ renderFrame?: boolean;
20
21
  }, files: BinaryFiles | null, opts?: {
21
22
  serializeAsJSON?: () => string;
22
23
  }) => Promise<SVGSVGElement>;
@@ -1,11 +1,21 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
2
2
  import { AppState } from "../types";
3
- export declare const getElementsWithinSelection: (elements: readonly NonDeletedExcalidrawElement[], selection: NonDeletedExcalidrawElement) => NonDeletedExcalidrawElement[];
3
+ /**
4
+ * Frames and their containing elements are not to be selected at the same time.
5
+ * Given an array of selected elements, if there are frames and their containing elements
6
+ * we only keep the frames.
7
+ * @param selectedElements
8
+ */
9
+ export declare const excludeElementsInFramesFromSelection: <T extends ExcalidrawElement>(selectedElements: readonly T[]) => T[];
10
+ export declare const getElementsWithinSelection: (elements: readonly NonDeletedExcalidrawElement[], selection: NonDeletedExcalidrawElement, excludeElementsInFrames?: boolean) => NonDeletedExcalidrawElement[];
4
11
  export declare const isSomeElementSelected: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">) => boolean;
5
12
  /**
6
13
  * Returns common attribute (picked by `getAttribute` callback) of selected
7
14
  * elements. If elements don't share the same value, returns `null`.
8
15
  */
9
16
  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[];
17
+ export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, opts?: {
18
+ includeBoundTextElement?: boolean;
19
+ includeElementsInFrames?: boolean;
20
+ }) => ExcalidrawElement[];
21
+ export declare const getTargetElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds" | "editingElement">) => ExcalidrawElement[];