@excalidraw/excalidraw 0.15.2-bb985eb → 0.15.2-d73cd14

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 +156 -79
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/dist/excalidraw.production.min.js.LICENSE.txt +0 -15
  4. package/package.json +3 -3
  5. package/types/actions/actionFinalize.d.ts +1 -1
  6. package/types/actions/actionGroup.d.ts +241 -3
  7. package/types/actions/actionProperties.d.ts +2 -0
  8. package/types/actions/actionSelectAll.d.ts +121 -1
  9. package/types/clipboard.d.ts +1 -0
  10. package/types/components/Actions.d.ts +2 -2
  11. package/types/components/App.d.ts +8 -6
  12. package/types/components/ExcalidrawLogo.d.ts +15 -0
  13. package/types/components/JSONExportDialog.d.ts +1 -1
  14. package/types/components/LayerUI.d.ts +3 -2
  15. package/types/components/MobileMenu.d.ts +2 -2
  16. package/types/components/canvases/InteractiveCanvas.d.ts +27 -0
  17. package/types/components/canvases/StaticCanvas.d.ts +18 -0
  18. package/types/components/canvases/index.d.ts +3 -0
  19. package/types/constants.d.ts +1 -0
  20. package/types/data/transform.d.ts +71 -0
  21. package/types/element/Hyperlink.d.ts +1 -1
  22. package/types/element/binding.d.ts +1 -0
  23. package/types/element/linearElementEditor.d.ts +4 -4
  24. package/types/element/newElement.d.ts +10 -6
  25. package/types/element/sizeHelpers.d.ts +8 -1
  26. package/types/element/textElement.d.ts +3 -1
  27. package/types/element/textWysiwyg.d.ts +1 -1
  28. package/types/element/transformHandles.d.ts +2 -2
  29. package/types/element/types.d.ts +5 -5
  30. package/types/frame.d.ts +4 -4
  31. package/types/groups.d.ts +11 -11
  32. package/types/packages/excalidraw/example/initialData.d.ts +182 -70
  33. package/types/packages/excalidraw/index.d.ts +1 -0
  34. package/types/renderer/renderElement.d.ts +9 -21
  35. package/types/renderer/renderScene.d.ts +16 -36
  36. package/types/scene/Renderer.d.ts +25 -0
  37. package/types/scene/Scene.d.ts +2 -0
  38. package/types/scene/Shape.d.ts +12 -0
  39. package/types/scene/ShapeCache.d.ts +20 -0
  40. package/types/scene/scroll.d.ts +1 -1
  41. package/types/scene/scrollbars.d.ts +2 -6
  42. package/types/scene/selection.d.ts +2 -2
  43. package/types/scene/types.d.ts +57 -24
  44. package/types/types.d.ts +43 -3
  45. package/types/utils.d.ts +12 -4
@@ -143,6 +143,7 @@ export declare const EXPORT_DATA_TYPES: {
143
143
  readonly excalidraw: "excalidraw";
144
144
  readonly excalidrawClipboard: "excalidraw/clipboard";
145
145
  readonly excalidrawLibrary: "excalidrawlib";
146
+ readonly excalidrawClipboardWithAPI: "excalidraw-api/clipboard";
146
147
  };
147
148
  export declare const EXPORT_SOURCE: string;
148
149
  export declare const IMAGE_RENDER_TIMEOUT = 500;
@@ -0,0 +1,71 @@
1
+ import { ElementConstructorOpts } from "../element/newElement";
2
+ import { ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawEmbeddableElement, ExcalidrawFrameElement, ExcalidrawFreeDrawElement, ExcalidrawGenericElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawSelectionElement, ExcalidrawTextElement, FileId, FontFamilyValues, TextAlign, VerticalAlign } from "../element/types";
3
+ import { MarkOptional } from "../utility-types";
4
+ export type ValidLinearElement = {
5
+ type: "arrow" | "line";
6
+ x: number;
7
+ y: number;
8
+ label?: {
9
+ text: string;
10
+ fontSize?: number;
11
+ fontFamily?: FontFamilyValues;
12
+ textAlign?: TextAlign;
13
+ verticalAlign?: VerticalAlign;
14
+ } & MarkOptional<ElementConstructorOpts, "x" | "y">;
15
+ end?: (({
16
+ type: Exclude<ExcalidrawBindableElement["type"], "image" | "text" | "frame" | "embeddable">;
17
+ id?: ExcalidrawGenericElement["id"];
18
+ } | {
19
+ id: ExcalidrawGenericElement["id"];
20
+ type?: Exclude<ExcalidrawBindableElement["type"], "image" | "text" | "frame" | "embeddable">;
21
+ }) | (({
22
+ type: "text";
23
+ text: string;
24
+ } | {
25
+ type?: "text";
26
+ id: ExcalidrawTextElement["id"];
27
+ text: string;
28
+ }) & Partial<ExcalidrawTextElement>)) & MarkOptional<ElementConstructorOpts, "x" | "y">;
29
+ start?: (({
30
+ type: Exclude<ExcalidrawBindableElement["type"], "image" | "text" | "frame" | "embeddable">;
31
+ id?: ExcalidrawGenericElement["id"];
32
+ } | {
33
+ id: ExcalidrawGenericElement["id"];
34
+ type?: Exclude<ExcalidrawBindableElement["type"], "image" | "text" | "frame" | "embeddable">;
35
+ }) | (({
36
+ type: "text";
37
+ text: string;
38
+ } | {
39
+ type?: "text";
40
+ id: ExcalidrawTextElement["id"];
41
+ text: string;
42
+ }) & Partial<ExcalidrawTextElement>)) & MarkOptional<ElementConstructorOpts, "x" | "y">;
43
+ } & Partial<ExcalidrawLinearElement>;
44
+ export type ValidContainer = {
45
+ type: Exclude<ExcalidrawGenericElement["type"], "selection">;
46
+ id?: ExcalidrawGenericElement["id"];
47
+ label?: {
48
+ text: string;
49
+ fontSize?: number;
50
+ fontFamily?: FontFamilyValues;
51
+ textAlign?: TextAlign;
52
+ verticalAlign?: VerticalAlign;
53
+ } & MarkOptional<ElementConstructorOpts, "x" | "y">;
54
+ } & ElementConstructorOpts;
55
+ export type ExcalidrawElementSkeleton = Extract<Exclude<ExcalidrawElement, ExcalidrawSelectionElement>, ExcalidrawEmbeddableElement | ExcalidrawFreeDrawElement | ExcalidrawFrameElement> | ({
56
+ type: Extract<ExcalidrawLinearElement["type"], "line">;
57
+ x: number;
58
+ y: number;
59
+ } & Partial<ExcalidrawLinearElement>) | ValidContainer | ValidLinearElement | ({
60
+ type: "text";
61
+ text: string;
62
+ x: number;
63
+ y: number;
64
+ id?: ExcalidrawTextElement["id"];
65
+ } & Partial<ExcalidrawTextElement>) | ({
66
+ type: Extract<ExcalidrawImageElement["type"], "image">;
67
+ x: number;
68
+ y: number;
69
+ fileId: FileId;
70
+ } & Partial<ExcalidrawImageElement>);
71
+ export declare const convertToExcalidrawElements: (elements: ExcalidrawElementSkeleton[] | null) => ExcalidrawElement[];
@@ -151,7 +151,7 @@ export declare const actionLink: {
151
151
  keyTest?: ((event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean) | undefined;
152
152
  };
153
153
  export declare const getContextMenuLabel: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => "labels.link.editEmbed" | "labels.link.edit" | "labels.link.createEmbed" | "labels.link.create";
154
- export declare const getLinkHandleFromCoords: ([x1, y1, x2, y2]: Bounds, angle: number, appState: UIAppState) => [x: number, y: number, width: number, height: number];
154
+ export declare const getLinkHandleFromCoords: ([x1, y1, x2, y2]: Bounds, angle: number, appState: Pick<UIAppState, "zoom">) => [x: number, y: number, width: number, height: number];
155
155
  export declare const isPointHittingLinkIcon: (element: NonDeletedExcalidrawElement, appState: AppState, [x, y]: readonly [number, number]) => boolean;
156
156
  export declare const isPointHittingLink: (element: NonDeletedExcalidrawElement, appState: AppState, [x, y]: readonly [number, number], isMobile: boolean) => boolean;
157
157
  export declare const showHyperlinkTooltip: (element: NonDeletedExcalidrawElement, appState: AppState) => void;
@@ -15,6 +15,7 @@ export declare const maybeBindLinearElement: (linearElement: NonDeleted<Excalidr
15
15
  x: number;
16
16
  y: number;
17
17
  }) => void;
18
+ export declare const bindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end") => void;
18
19
  export declare const isLinearElementSimpleAndAlreadyBound: (linearElement: NonDeleted<ExcalidrawLinearElement>, alreadyBoundToId: ExcalidrawBindableElement["id"] | undefined, bindableElement: ExcalidrawBindableElement) => boolean;
19
20
  export declare const unbindLinearElements: (elements: NonDeleted<ExcalidrawElement>[]) => void;
20
21
  export declare const getHoveredElementForBinding: (pointerCoords: {
@@ -1,5 +1,5 @@
1
1
  import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer } from "./types";
2
- import { Point, AppState, PointerCoords } from "../types";
2
+ import { Point, AppState, PointerCoords, InteractiveCanvasAppState } from "../types";
3
3
  import History from "../history";
4
4
  import Scene from "../scene/Scene";
5
5
  declare const editorMidPointsCache: {
@@ -52,8 +52,8 @@ export declare class LinearElementEditor {
52
52
  y: number;
53
53
  }[]) => void, linearElementEditor: LinearElementEditor): boolean;
54
54
  static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState): LinearElementEditor;
55
- static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, appState: AppState) => (typeof editorMidPointsCache)["points"];
56
- static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, appState: AppState) => void;
55
+ static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, appState: InteractiveCanvasAppState) => (typeof editorMidPointsCache)["points"];
56
+ static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, appState: InteractiveCanvasAppState) => void;
57
57
  static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
58
58
  x: number;
59
59
  y: number;
@@ -179,7 +179,7 @@ export declare class LinearElementEditor {
179
179
  currentItemTextAlign: string;
180
180
  currentItemStartArrowhead: import("./types").Arrowhead | null;
181
181
  currentItemEndArrowhead: import("./types").Arrowhead | null;
182
- currentItemRoundness: import("./types").StrokeRoundness; /** @returns whether point was dragged */
182
+ currentItemRoundness: import("./types").StrokeRoundness;
183
183
  viewBackgroundColor: string;
184
184
  scrollX: number;
185
185
  scrollY: number;
@@ -1,13 +1,13 @@
1
1
  import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement } 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" | "frameId" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity">;
4
+ export 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
8
  export declare const newEmbeddableElement: (opts: {
9
9
  type: "embeddable";
10
- validated: boolean | undefined;
10
+ validated: ExcalidrawEmbeddableElement["validated"];
11
11
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawEmbeddableElement>;
12
12
  export declare const newFrameElement: (opts: ElementConstructorOpts) => NonDeleted<ExcalidrawFrameElement>;
13
13
  export declare const newTextElement: (opts: {
@@ -16,7 +16,7 @@ export declare const newTextElement: (opts: {
16
16
  fontFamily?: FontFamilyValues;
17
17
  textAlign?: TextAlign;
18
18
  verticalAlign?: VerticalAlign;
19
- containerId?: ExcalidrawTextContainer["id"];
19
+ containerId?: ExcalidrawTextContainer["id"] | null;
20
20
  lineHeight?: ExcalidrawTextElement["lineHeight"];
21
21
  strokeWidth?: ExcalidrawTextElement["strokeWidth"];
22
22
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
@@ -40,8 +40,8 @@ export declare const newFreeDrawElement: (opts: {
40
40
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawFreeDrawElement>;
41
41
  export declare const newLinearElement: (opts: {
42
42
  type: ExcalidrawLinearElement["type"];
43
- startArrowhead: Arrowhead | null;
44
- endArrowhead: Arrowhead | null;
43
+ startArrowhead?: Arrowhead | null;
44
+ endArrowhead?: Arrowhead | null;
45
45
  points?: ExcalidrawLinearElement["points"];
46
46
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawLinearElement>;
47
47
  export declare const newImageElement: (opts: {
@@ -60,6 +60,11 @@ export declare const newImageElement: (opts: {
60
60
  * Typed arrays and other non-null objects.
61
61
  */
62
62
  export declare const deepCopyElement: <T extends ExcalidrawElement>(val: T) => Mutable<T>;
63
+ /**
64
+ * utility wrapper to generate new id. In test env it reuses the old + postfix
65
+ * for test assertions.
66
+ */
67
+ export declare const regenerateId: (previousId: string | null) => string;
63
68
  /**
64
69
  * Duplicate an element, often used in the alt-drag operation.
65
70
  * Note that this method has gotten a bit complicated since the
@@ -89,4 +94,3 @@ export declare const duplicateElements: (elements: readonly ExcalidrawElement[],
89
94
  /** NOTE also updates version flags and `updated` */
90
95
  randomizeSeed: boolean;
91
96
  }) => ExcalidrawElement[];
92
- export {};
@@ -1,6 +1,13 @@
1
1
  import { ExcalidrawElement } from "./types";
2
- import { AppState } from "../types";
2
+ import { AppState, Zoom } from "../types";
3
3
  export declare const isInvisiblySmallElement: (element: ExcalidrawElement) => boolean;
4
+ export declare const isElementInViewport: (element: ExcalidrawElement, width: number, height: number, viewTransformations: {
5
+ zoom: Zoom;
6
+ offsetLeft: number;
7
+ offsetTop: number;
8
+ scrollX: number;
9
+ scrollY: number;
10
+ }) => boolean;
4
11
  /**
5
12
  * Makes a perfect shape or diagonal/horizontal/vertical line
6
13
  */
@@ -65,7 +65,9 @@ export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExca
65
65
  export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
66
66
  export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], appState: AppState, x: number, y: number) => ExcalidrawTextContainer | null;
67
67
  declare const VALID_CONTAINER_TYPES: Set<string>;
68
- export declare const isValidTextContainer: (element: ExcalidrawElement) => boolean;
68
+ export declare const isValidTextContainer: (element: {
69
+ type: ExcalidrawElement["type"];
70
+ }) => boolean;
69
71
  export declare const computeContainerDimensionForBoundText: (dimension: number, containerType: ExtractSetType<typeof VALID_CONTAINER_TYPES>) => number;
70
72
  export declare const getBoundTextMaxWidth: (container: ExcalidrawElement, boundTextElement?: ExcalidrawTextElement | null) => number;
71
73
  export declare const getBoundTextMaxHeight: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => number;
@@ -15,7 +15,7 @@ export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords,
15
15
  }) => void;
16
16
  getViewportCoords: (x: number, y: number) => [number, number];
17
17
  element: ExcalidrawTextElement;
18
- canvas: HTMLCanvasElement | null;
18
+ canvas: HTMLCanvasElement;
19
19
  excalidrawContainer: HTMLDivElement | null;
20
20
  app: App;
21
21
  }) => void;
@@ -1,5 +1,5 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
2
- import { AppState, Zoom } from "../types";
2
+ import { InteractiveCanvasAppState, Zoom } from "../types";
3
3
  export type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
4
4
  export type TransformHandleType = TransformHandleDirection | "rotation";
5
5
  export type TransformHandle = [number, number, number, number];
@@ -32,4 +32,4 @@ export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [
32
32
  rotation?: boolean | undefined;
33
33
  }, margin?: number) => TransformHandles;
34
34
  export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoom, pointerType?: PointerType) => TransformHandles;
35
- export declare const shouldShowBoundingBox: (elements: NonDeletedExcalidrawElement[], appState: AppState) => boolean;
35
+ export declare const shouldShowBoundingBox: (elements: readonly NonDeletedExcalidrawElement[], appState: InteractiveCanvasAppState) => boolean;
@@ -74,15 +74,15 @@ export type ExcalidrawEllipseElement = _ExcalidrawElementBase & {
74
74
  type: "ellipse";
75
75
  };
76
76
  export type ExcalidrawEmbeddableElement = _ExcalidrawElementBase & Readonly<{
77
+ type: "embeddable";
77
78
  /**
78
79
  * indicates whether the embeddable src (url) has been validated for rendering.
79
- * nullish value indicates that the validation is pending. We reset the
80
+ * null value indicates that the validation is pending. We reset the
80
81
  * value on each restore (or url change) so that we can guarantee
81
82
  * the validation came from a trusted source (the editor). Also because we
82
83
  * may not have access to host-app supplied url validator during restore.
83
84
  */
84
- validated?: boolean;
85
- type: "embeddable";
85
+ validated: boolean | null;
86
86
  }>;
87
87
  export type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
88
88
  type: "image";
@@ -100,13 +100,13 @@ export type ExcalidrawFrameElement = _ExcalidrawElementBase & {
100
100
  /**
101
101
  * These are elements that don't have any additional properties.
102
102
  */
103
- export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawEmbeddableElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
103
+ export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
104
104
  /**
105
105
  * ExcalidrawElement should be JSON serializable and (eventually) contain
106
106
  * no computed data. The list of all ExcalidrawElements should be shareable
107
107
  * between peers and contain no state local to the peer.
108
108
  */
109
- export type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement | ExcalidrawFrameElement;
109
+ export type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement | ExcalidrawFrameElement | ExcalidrawEmbeddableElement;
110
110
  export type NonDeleted<TElement extends ExcalidrawElement> = TElement & {
111
111
  isDeleted: boolean;
112
112
  };
package/types/frame.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ExcalidrawElement, ExcalidrawFrameElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
2
- import { AppClassProperties, AppState } from "./types";
2
+ import { AppClassProperties, AppState, StaticCanvasAppState } from "./types";
3
3
  import { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
4
4
  export declare const bindElementsToFramesAfterDuplication: (nextElements: ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
5
5
  export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
@@ -25,7 +25,7 @@ export declare const addElementsToFrame: (allElements: ExcalidrawElementsIncludi
25
25
  export declare const removeElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToRemove: NonDeletedExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
26
26
  export declare const removeAllElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
27
27
  export declare const replaceAllElementsInFrame: (allElements: ExcalidrawElementsIncludingDeleted, nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
28
- /** does not mutate elements, but return new ones */
28
+ /** does not mutate elements, but returns new ones */
29
29
  export declare const updateFrameMembershipOfSelectedElements: (allElements: ExcalidrawElementsIncludingDeleted, appState: AppState, app: AppClassProperties) => ExcalidrawElementsIncludingDeleted;
30
30
  /**
31
31
  * filters out elements that are inside groups that contain a frame element
@@ -36,5 +36,5 @@ export declare const omitGroupsContainingFrames: (allElements: ExcalidrawElement
36
36
  * depending on the appState, return target frame, which is the frame the given element
37
37
  * is going to be added to or remove from
38
38
  */
39
- export declare const getTargetFrame: (element: ExcalidrawElement, appState: AppState) => ExcalidrawFrameElement | null;
40
- export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ExcalidrawElementsIncludingDeleted, appState: AppState) => boolean;
39
+ export declare const getTargetFrame: (element: ExcalidrawElement, appState: StaticCanvasAppState) => ExcalidrawFrameElement | null;
40
+ export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ExcalidrawElementsIncludingDeleted, appState: StaticCanvasAppState) => boolean;
package/types/groups.d.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import { GroupId, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
2
- import { AppClassProperties, AppState } from "./types";
3
- export declare const selectGroup: (groupId: GroupId, appState: AppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => AppState;
2
+ import { AppClassProperties, AppState, InteractiveCanvasAppState } from "./types";
3
+ import { Mutable } from "./utility-types";
4
+ export declare const selectGroup: (groupId: GroupId, appState: InteractiveCanvasAppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => Pick<InteractiveCanvasAppState, "selectedGroupIds" | "selectedElementIds" | "editingGroupId">;
5
+ export declare const selectGroupsForSelectedElements: {
6
+ (appState: Pick<AppState, "selectedElementIds" | "editingGroupId">, elements: readonly NonDeletedExcalidrawElement[], prevAppState: InteractiveCanvasAppState, app: AppClassProperties | null): Mutable<Pick<InteractiveCanvasAppState, "selectedGroupIds" | "editingGroupId" | "selectedElementIds">>;
7
+ clearCache(): void;
8
+ };
4
9
  /**
5
10
  * If the element's group is selected, don't render an individual
6
11
  * selection border around it.
7
12
  */
8
- export declare const isSelectedViaGroup: (appState: AppState, element: ExcalidrawElement) => boolean;
9
- export declare const getSelectedGroupForElement: (appState: AppState, element: ExcalidrawElement) => string | undefined;
10
- export declare const getSelectedGroupIds: (appState: AppState) => GroupId[];
11
- /**
12
- * When you select an element, you often want to actually select the whole group it's in, unless
13
- * you're currently editing that group.
14
- */
15
- export declare const selectGroupsForSelectedElements: (appState: AppState, elements: readonly NonDeletedExcalidrawElement[], prevAppState: AppState, app: AppClassProperties | null) => AppState;
16
- export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: AppState) => {
13
+ export declare const isSelectedViaGroup: (appState: InteractiveCanvasAppState, element: ExcalidrawElement) => boolean;
14
+ export declare const getSelectedGroupForElement: (appState: InteractiveCanvasAppState, element: ExcalidrawElement) => string | undefined;
15
+ export declare const getSelectedGroupIds: (appState: InteractiveCanvasAppState) => GroupId[];
16
+ export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: InteractiveCanvasAppState) => {
17
17
  [groupId: string]: boolean;
18
18
  };
19
19
  export declare const editGroupForSelectedElement: (appState: AppState, element: NonDeleted<ExcalidrawElement>) => AppState;
@@ -1,10 +1,42 @@
1
- declare namespace _default {
2
- const elements: ({
1
+ import { ExcalidrawElementSkeleton } from "../../../data/transform";
2
+ declare const _default: {
3
+ elements: ExcalidrawElementSkeleton[];
4
+ appState: {
5
+ viewBackgroundColor: string;
6
+ currentItemFontFamily: number;
7
+ };
8
+ scrollToContent: boolean;
9
+ libraryItems: ({
10
+ type: string;
11
+ x: number;
12
+ y: number;
13
+ strokeColor: string;
14
+ backgroundColor: string;
15
+ width: number;
16
+ height: number;
17
+ strokeSharpness: string;
18
+ points: number[][];
19
+ }[] | ({
20
+ type: string;
21
+ fillStyle: string;
22
+ strokeWidth: number;
23
+ strokeStyle: string;
24
+ x: number;
25
+ y: number;
26
+ strokeColor: string;
27
+ backgroundColor: string;
28
+ width: number;
29
+ height: number;
30
+ groupIds: string[];
31
+ points: number[][];
32
+ roughness?: undefined;
33
+ opacity?: undefined;
34
+ angle?: undefined;
35
+ seed?: undefined;
36
+ strokeSharpness?: undefined;
37
+ boundElementIds?: undefined;
38
+ } | {
3
39
  type: string;
4
- version: number;
5
- versionNonce: number;
6
- isDeleted: boolean;
7
- id: string;
8
40
  fillStyle: string;
9
41
  strokeWidth: number;
10
42
  strokeStyle: string;
@@ -18,50 +50,72 @@ declare namespace _default {
18
50
  width: number;
19
51
  height: number;
20
52
  seed: number;
21
- groupIds: never[];
22
- frameId: null;
23
- fileId?: undefined;
24
- strokeSharpness?: undefined;
25
- boundElements?: undefined;
26
- updated?: undefined;
27
- link?: undefined;
28
- status?: undefined;
29
- scale?: undefined;
53
+ groupIds: string[];
54
+ strokeSharpness: string;
55
+ points: number[][];
56
+ boundElementIds?: undefined;
30
57
  } | {
31
- fileId: string;
32
58
  type: string;
59
+ fillStyle: string;
60
+ strokeWidth: number;
61
+ strokeStyle: string;
62
+ roughness: number;
63
+ opacity: number;
64
+ angle: number;
33
65
  x: number;
34
66
  y: number;
67
+ strokeColor: string;
68
+ backgroundColor: string;
35
69
  width: number;
36
70
  height: number;
71
+ seed: number;
72
+ groupIds: string[];
73
+ strokeSharpness: string;
74
+ boundElementIds: string[];
75
+ points?: undefined;
76
+ } | {
77
+ type: string;
78
+ fillStyle: string;
79
+ strokeWidth: number;
80
+ strokeStyle: string;
81
+ roughness: number;
82
+ opacity: number;
37
83
  angle: number;
84
+ x: number;
85
+ y: number;
38
86
  strokeColor: string;
39
87
  backgroundColor: string;
88
+ width: number;
89
+ height: number;
90
+ seed: number;
91
+ groupIds: string[];
92
+ strokeSharpness: string;
93
+ points?: undefined;
94
+ boundElementIds?: undefined;
95
+ })[] | ({
96
+ type: string;
40
97
  fillStyle: string;
41
98
  strokeWidth: number;
42
99
  strokeStyle: string;
43
100
  roughness: number;
44
101
  opacity: number;
45
- groupIds: never[];
46
- frameId: null;
47
- strokeSharpness: string;
102
+ angle: number;
103
+ x: number;
104
+ y: number;
105
+ strokeColor: string;
106
+ backgroundColor: string;
107
+ width: number;
108
+ height: number;
48
109
  seed: number;
49
- version: number;
50
- versionNonce: number;
51
- isDeleted: boolean;
52
- boundElements: null;
53
- updated: number;
54
- link: null;
55
- status: string;
56
- scale: number[];
110
+ groupIds: string[];
111
+ strokeSharpness: string;
112
+ points: number[][];
113
+ version?: undefined;
114
+ versionNonce?: undefined;
115
+ isDeleted?: undefined;
57
116
  id?: undefined;
58
- })[];
59
- namespace appState {
60
- const viewBackgroundColor: string;
61
- const currentItemFontFamily: number;
62
- }
63
- const scrollToContent: boolean;
64
- const libraryItems: (({
117
+ boundElementIds?: undefined;
118
+ } | {
65
119
  type: string;
66
120
  version: number;
67
121
  versionNonce: number;
@@ -81,21 +135,11 @@ declare namespace _default {
81
135
  height: number;
82
136
  seed: number;
83
137
  groupIds: string[];
84
- frameId: null;
85
138
  strokeSharpness: string;
86
- boundElementIds: never[];
87
- startBinding: null;
88
- endBinding: null;
89
139
  points: number[][];
90
- lastCommittedPoint: null;
91
- startArrowhead: null;
92
- endArrowhead: null;
140
+ boundElementIds?: undefined;
93
141
  } | {
94
142
  type: string;
95
- version: number;
96
- versionNonce: number;
97
- isDeleted: boolean;
98
- id: string;
99
143
  fillStyle: string;
100
144
  strokeWidth: number;
101
145
  strokeStyle: string;
@@ -110,21 +154,15 @@ declare namespace _default {
110
154
  height: number;
111
155
  seed: number;
112
156
  groupIds: string[];
113
- frameId: null;
114
157
  strokeSharpness: string;
115
158
  boundElementIds: string[];
116
- startBinding?: undefined;
117
- endBinding?: undefined;
118
159
  points?: undefined;
119
- lastCommittedPoint?: undefined;
120
- startArrowhead?: undefined;
121
- endArrowhead?: undefined;
160
+ version?: undefined;
161
+ versionNonce?: undefined;
162
+ isDeleted?: undefined;
163
+ id?: undefined;
122
164
  })[] | ({
123
165
  type: string;
124
- version: number;
125
- versionNonce: number;
126
- isDeleted: boolean;
127
- id: string;
128
166
  fillStyle: string;
129
167
  strokeWidth: number;
130
168
  strokeStyle: string;
@@ -139,19 +177,10 @@ declare namespace _default {
139
177
  height: number;
140
178
  seed: number;
141
179
  groupIds: string[];
142
- frameId: null;
143
180
  strokeSharpness: string;
144
- boundElementIds: string[];
145
181
  points?: undefined;
146
- lastCommittedPoint?: undefined;
147
- startArrowhead?: undefined;
148
- endArrowhead?: undefined;
149
182
  } | {
150
183
  type: string;
151
- version: number;
152
- versionNonce: number;
153
- isDeleted: boolean;
154
- id: string;
155
184
  fillStyle: string;
156
185
  strokeWidth: number;
157
186
  strokeStyle: string;
@@ -166,13 +195,96 @@ declare namespace _default {
166
195
  height: number;
167
196
  seed: number;
168
197
  groupIds: string[];
169
- frameId: null;
170
198
  strokeSharpness: string;
171
- boundElementIds: never[];
172
199
  points: number[][];
173
- lastCommittedPoint: null;
174
- startArrowhead: null;
175
- endArrowhead: null;
200
+ } | {
201
+ type: string;
202
+ fillStyle: string;
203
+ strokeWidth: number;
204
+ strokeStyle: string;
205
+ x: number;
206
+ y: number;
207
+ strokeColor: string;
208
+ backgroundColor: string;
209
+ width: number;
210
+ height: number;
211
+ groupIds: string[];
212
+ strokeSharpness: string;
213
+ points: number[][];
214
+ roughness?: undefined;
215
+ opacity?: undefined;
216
+ angle?: undefined;
217
+ seed?: undefined;
218
+ } | {
219
+ type: string;
220
+ fillStyle: string;
221
+ strokeWidth: number;
222
+ strokeStyle: string;
223
+ roughness: number;
224
+ opacity: number;
225
+ angle: number;
226
+ x: number;
227
+ y: number;
228
+ strokeColor: string;
229
+ backgroundColor: string;
230
+ width: number;
231
+ height: number;
232
+ groupIds: string[];
233
+ strokeSharpness: string;
234
+ points: number[][];
235
+ seed?: undefined;
236
+ } | {
237
+ type: string;
238
+ fillStyle: string;
239
+ strokeWidth: number;
240
+ strokeStyle: string;
241
+ opacity: number;
242
+ x: number;
243
+ y: number;
244
+ strokeColor: string;
245
+ backgroundColor: string;
246
+ width: number;
247
+ height: number;
248
+ seed: number;
249
+ groupIds: string[];
250
+ strokeSharpness: string;
251
+ points: number[][];
252
+ roughness?: undefined;
253
+ angle?: undefined;
254
+ })[] | ({
255
+ type: string;
256
+ fillStyle: string;
257
+ strokeWidth: number;
258
+ strokeStyle: string;
259
+ roughness: number;
260
+ opacity: number;
261
+ angle: number;
262
+ x: number;
263
+ y: number;
264
+ strokeColor: string;
265
+ backgroundColor: string;
266
+ width: number;
267
+ height: number;
268
+ seed: number;
269
+ groupIds: string[];
270
+ strokeSharpness: string;
271
+ } | {
272
+ type: string;
273
+ fillStyle: string;
274
+ strokeWidth: number;
275
+ strokeStyle: string;
276
+ x: number;
277
+ y: number;
278
+ strokeColor: string;
279
+ backgroundColor: string;
280
+ width: number;
281
+ height: number;
282
+ seed: number;
283
+ groupIds: string[];
284
+ strokeSharpness: string;
285
+ roughness?: undefined;
286
+ opacity?: undefined;
287
+ angle?: undefined;
176
288
  })[])[];
177
- }
289
+ };
178
290
  export default _default;
@@ -26,3 +26,4 @@ export { WelcomeScreen };
26
26
  export { LiveCollaborationTrigger };
27
27
  export { DefaultSidebar } from "../../components/DefaultSidebar";
28
28
  export { normalizeLink } from "../../data/url";
29
+ export { convertToExcalidrawElements } from "../../data/transform";