@zsviczian/excalidraw 0.17.1-obsidian-12 → 0.17.1-obsidian-14

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 (74) hide show
  1. package/dist/excalidraw.development.js +66 -55
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/dist/styles.development.css +633 -627
  4. package/dist/styles.production.css +4 -4
  5. package/package.json +1 -1
  6. package/types/excalidraw/actions/actionAddToLibrary.d.ts +3 -3
  7. package/types/excalidraw/actions/actionAlign.d.ts +6 -6
  8. package/types/excalidraw/actions/actionBoundText.d.ts +2 -2
  9. package/types/excalidraw/actions/actionCanvas.d.ts +28 -28
  10. package/types/excalidraw/actions/actionClipboard.d.ts +7 -7
  11. package/types/excalidraw/actions/actionDeleteSelected.d.ts +3 -3
  12. package/types/excalidraw/actions/actionDistribute.d.ts +2 -2
  13. package/types/excalidraw/actions/actionElementLock.d.ts +2 -2
  14. package/types/excalidraw/actions/actionExport.d.ts +8 -8
  15. package/types/excalidraw/actions/actionFinalize.d.ts +2 -2
  16. package/types/excalidraw/actions/actionFlip.d.ts +2 -2
  17. package/types/excalidraw/actions/actionFrame.d.ts +4 -4
  18. package/types/excalidraw/actions/actionGroup.d.ts +2 -2
  19. package/types/excalidraw/actions/actionLinearEditor.d.ts +1 -1
  20. package/types/excalidraw/actions/actionMenu.d.ts +2 -2
  21. package/types/excalidraw/actions/actionNavigate.d.ts +2 -2
  22. package/types/excalidraw/actions/actionProperties.d.ts +26 -26
  23. package/types/excalidraw/actions/actionSelectAll.d.ts +1 -1
  24. package/types/excalidraw/actions/actionStyles.d.ts +3 -3
  25. package/types/excalidraw/actions/actionToggleGridMode.d.ts +1 -1
  26. package/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +1 -1
  27. package/types/excalidraw/actions/actionToggleStats.d.ts +1 -1
  28. package/types/excalidraw/actions/actionToggleViewMode.d.ts +1 -1
  29. package/types/excalidraw/actions/actionToggleZenMode.d.ts +1 -1
  30. package/types/excalidraw/align.d.ts +2 -2
  31. package/types/excalidraw/components/Actions.d.ts +3 -3
  32. package/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -2
  33. package/types/excalidraw/components/canvases/StaticCanvas.d.ts +4 -3
  34. package/types/excalidraw/constants.d.ts +1 -0
  35. package/types/excalidraw/distribute.d.ts +2 -2
  36. package/types/excalidraw/element/Hyperlink.d.ts +1 -1
  37. package/types/excalidraw/element/bounds.d.ts +2 -2
  38. package/types/excalidraw/element/collision.d.ts +3 -3
  39. package/types/excalidraw/element/containerCache.d.ts +11 -0
  40. package/types/excalidraw/element/embeddable.d.ts +7 -8
  41. package/types/excalidraw/element/index.d.ts +0 -1
  42. package/types/excalidraw/element/linearElementEditor.d.ts +8 -8
  43. package/types/excalidraw/element/newElement.d.ts +2 -2
  44. package/types/excalidraw/element/resizeElements.d.ts +5 -5
  45. package/types/excalidraw/element/textElement.d.ts +9 -12
  46. package/types/excalidraw/element/textWysiwyg.d.ts +1 -6
  47. package/types/excalidraw/element/transformHandles.d.ts +2 -2
  48. package/types/excalidraw/element/types.d.ts +24 -2
  49. package/types/excalidraw/frame.d.ts +16 -10
  50. package/types/excalidraw/groups.d.ts +3 -3
  51. package/types/excalidraw/index.d.ts +1 -1
  52. package/types/excalidraw/renderer/renderElement.d.ts +4 -4
  53. package/types/excalidraw/renderer/renderScene.d.ts +5 -7
  54. package/types/excalidraw/scene/Renderer.d.ts +1 -1
  55. package/types/excalidraw/scene/Scene.d.ts +9 -3
  56. package/types/excalidraw/scene/index.d.ts +0 -1
  57. package/types/excalidraw/scene/scrollbars.d.ts +2 -3
  58. package/types/excalidraw/scene/selection.d.ts +3 -3
  59. package/types/excalidraw/scene/types.d.ts +7 -4
  60. package/types/excalidraw/types.d.ts +2 -1
  61. package/types/excalidraw/utility-types.d.ts +5 -0
  62. package/types/excalidraw/utils.d.ts +16 -1
  63. package/types/excalidraw/components/LaserTool/LaserPathManager.d.ts +0 -28
  64. package/types/excalidraw/components/LaserTool/LaserPointerButton.d.ts +0 -10
  65. package/types/excalidraw/components/LaserTool/LaserTool.d.ts +0 -7
  66. package/types/excalidraw/example/App.d.ts +0 -14
  67. package/types/excalidraw/example/CustomFooter.d.ts +0 -5
  68. package/types/excalidraw/example/MobileFooter.d.ts +0 -5
  69. package/types/excalidraw/example/index.d.ts +0 -1
  70. package/types/excalidraw/example/initialData.d.ts +0 -290
  71. package/types/excalidraw/example/sidebar/ExampleSidebar.d.ts +0 -4
  72. package/types/excalidraw/rollup.config.d.ts +0 -10
  73. package/types/excalidraw/vite.config.d.mts +0 -2
  74. package/types/utils/index.d.ts +0 -1
@@ -1,9 +1,9 @@
1
1
  import * as GA from "../ga";
2
- import { NonDeletedExcalidrawElement, ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawRectangleElement, ExcalidrawDiamondElement, ExcalidrawTextElement, ExcalidrawEllipseElement, NonDeleted, ExcalidrawImageElement, ExcalidrawFrameLikeElement, ExcalidrawIframeLikeElement } from "./types";
2
+ import { NonDeletedExcalidrawElement, ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawRectangleElement, ExcalidrawDiamondElement, ExcalidrawTextElement, ExcalidrawEllipseElement, NonDeleted, ExcalidrawImageElement, ExcalidrawFrameLikeElement, ExcalidrawIframeLikeElement, ElementsMap } from "./types";
3
3
  import { FrameNameBoundsCache, Point } from "../types";
4
4
  import { AppState } from "../types";
5
- export declare const hitTest: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache, x: number, y: number) => boolean;
6
- export declare const isHittingElementBoundingBoxWithoutHittingElement: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache, x: number, y: number) => boolean;
5
+ export declare const hitTest: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache, x: number, y: number, elementsMap: ElementsMap) => boolean;
6
+ export declare const isHittingElementBoundingBoxWithoutHittingElement: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache, x: number, y: number, elementsMap: ElementsMap) => boolean;
7
7
  export declare const isHittingElementNotConsideringBoundingBox: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache | null, point: readonly [number, number]) => boolean;
8
8
  export declare const isPointHittingElementBoundingBox: (element: NonDeleted<ExcalidrawElement>, [x, y]: readonly [number, number], threshold: number, frameNameBoundsCache: FrameNameBoundsCache | null) => boolean;
9
9
  export declare const bindingBorderTest: (element: NonDeleted<ExcalidrawBindableElement>, { x, y }: {
@@ -0,0 +1,11 @@
1
+ import { ExcalidrawTextContainer } from "./types";
2
+ export declare const originalContainerCache: {
3
+ [id: ExcalidrawTextContainer["id"]]: {
4
+ height: ExcalidrawTextContainer["height"];
5
+ } | undefined;
6
+ };
7
+ export declare const updateOriginalContainerCache: (id: ExcalidrawTextContainer["id"], height: ExcalidrawTextContainer["height"]) => {
8
+ height: ExcalidrawTextContainer["height"];
9
+ };
10
+ export declare const resetOriginalContainerCache: (id: ExcalidrawTextContainer["id"]) => void;
11
+ export declare const getOriginalContainerHeightFromCache: (id: ExcalidrawTextContainer["id"]) => number | null;
@@ -1,8 +1,7 @@
1
1
  import { ExcalidrawProps } from "../types";
2
- import { ExcalidrawElement, ExcalidrawIframeLikeElement, IframeData, NonDeletedExcalidrawElement } from "./types";
2
+ import { ExcalidrawElement, ExcalidrawIframeLikeElement, IframeData } from "./types";
3
3
  export declare const createSrcDoc: (body: string) => string;
4
4
  export declare const getEmbedLink: (link: string | null | undefined) => IframeData | null;
5
- export declare const isIframeLikeOrItsLabel: (element: NonDeletedExcalidrawElement) => Boolean;
6
5
  export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawIframeLikeElement) => ExcalidrawElement;
7
6
  export declare const actionSetEmbeddableAsActiveTool: {
8
7
  name: "setEmbeddableAsActiveTool";
@@ -25,13 +24,13 @@ export declare const actionSetEmbeddableAsActiveTool: {
25
24
  isLoading: boolean;
26
25
  errorMessage: import("react").ReactNode;
27
26
  activeEmbeddable: {
28
- element: NonDeletedExcalidrawElement;
27
+ element: import("./types").NonDeletedExcalidrawElement;
29
28
  state: "active" | "hover";
30
29
  } | null;
31
- draggingElement: NonDeletedExcalidrawElement | null;
32
- resizingElement: NonDeletedExcalidrawElement | null;
30
+ draggingElement: import("./types").NonDeletedExcalidrawElement | null;
31
+ resizingElement: import("./types").NonDeletedExcalidrawElement | null;
33
32
  multiElement: import("./types").NonDeleted<import("./types").ExcalidrawLinearElement> | null;
34
- selectionElement: NonDeletedExcalidrawElement | null;
33
+ selectionElement: import("./types").NonDeletedExcalidrawElement | null;
35
34
  isBindingEnabled: boolean;
36
35
  startBoundElement: import("./types").NonDeleted<import("./types").ExcalidrawBindableElement> | null;
37
36
  suggestedBindings: import("./binding").SuggestedBinding[];
@@ -44,7 +43,7 @@ export declare const actionSetEmbeddableAsActiveTool: {
44
43
  };
45
44
  editingFrame: string | null;
46
45
  elementsToHighlight: import("./types").NonDeleted<ExcalidrawElement>[] | null;
47
- editingElement: NonDeletedExcalidrawElement | null;
46
+ editingElement: import("./types").NonDeletedExcalidrawElement | null;
48
47
  editingLinearElement: import("./linearElementEditor").LinearElementEditor | null;
49
48
  penMode: boolean;
50
49
  penDetected: boolean;
@@ -83,7 +82,7 @@ export declare const actionSetEmbeddableAsActiveTool: {
83
82
  tab?: string | undefined;
84
83
  } | null;
85
84
  openDialog: {
86
- name: "help" | "imageExport" | "jsonExport";
85
+ name: "imageExport" | "help" | "jsonExport";
87
86
  } | {
88
87
  name: "settings";
89
88
  source: "settings" | "tool" | "generation";
@@ -7,7 +7,6 @@ export { resizeTest, getCursorForResizingElement, getElementWithTransformHandleT
7
7
  export { transformElements, getResizeOffsetXY, getResizeArrowDirection, } from "./resizeElements";
8
8
  export { dragSelectedElements, getDragOffsetXY, dragNewElement, } from "./dragElements";
9
9
  export { isTextElement, isExcalidrawElement } from "./typeChecks";
10
- export { textWysiwyg } from "./textWysiwyg";
11
10
  export { redrawTextBoundingBox } from "./textElement";
12
11
  export { getPerfectElementSize, getLockedLinearCursorAlignSize, isInvisiblySmallElement, resizePerfectLineForNWHandler, getNormalizedDimensions, } from "./sizeHelpers";
13
12
  export { showSelectedShapeActions } from "./showSelectedShapeActions";
@@ -1,4 +1,4 @@
1
- import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer } from "./types";
1
+ import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap } from "./types";
2
2
  import { Bounds } from "./bounds";
3
3
  import { Point, AppState, PointerCoords, InteractiveCanvasAppState } from "../types";
4
4
  import History from "../history";
@@ -51,21 +51,21 @@ export declare class LinearElementEditor {
51
51
  static handlePointDragging(event: PointerEvent, appState: AppState, scenePointerX: number, scenePointerY: number, maybeSuggestBinding: (element: NonDeleted<ExcalidrawLinearElement>, pointSceneCoords: {
52
52
  x: number;
53
53
  y: number;
54
- }[]) => void, linearElementEditor: LinearElementEditor): boolean;
54
+ }[]) => void, linearElementEditor: LinearElementEditor, elementsMap: ElementsMap): boolean;
55
55
  static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState): LinearElementEditor;
56
- static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, appState: InteractiveCanvasAppState) => (typeof editorMidPointsCache)["points"];
56
+ static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (typeof editorMidPointsCache)["points"];
57
57
  static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, appState: InteractiveCanvasAppState) => void;
58
58
  static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
59
59
  x: number;
60
60
  y: number;
61
- }, appState: AppState) => readonly [number, number] | null;
61
+ }, appState: AppState, elementsMap: ElementsMap) => readonly [number, number] | null;
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
- static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: Point): number;
64
+ static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: Point, elementsMap: ElementsMap): number;
65
65
  static handlePointerDown(event: React.PointerEvent<HTMLElement>, appState: AppState, history: History, scenePointer: {
66
66
  x: number;
67
67
  y: number;
68
- }, linearElementEditor: LinearElementEditor): {
68
+ }, linearElementEditor: LinearElementEditor, elementsMap: ElementsMap): {
69
69
  didAddPoint: boolean;
70
70
  hitElement: NonDeleted<ExcalidrawElement> | null;
71
71
  linearElementEditor: LinearElementEditor | null;
@@ -193,7 +193,7 @@ export declare class LinearElementEditor {
193
193
  tab?: string | undefined;
194
194
  } | null;
195
195
  openDialog: {
196
- name: "help" | "imageExport" | "jsonExport";
196
+ name: "imageExport" | "help" | "jsonExport";
197
197
  } | {
198
198
  name: "settings";
199
199
  source: "settings" | "tool" | "generation";
@@ -326,6 +326,6 @@ export declare class LinearElementEditor {
326
326
  y: number;
327
327
  };
328
328
  static getMinMaxXYWithBoundText: (element: ExcalidrawLinearElement, elementBounds: Bounds, boundTextElement: ExcalidrawTextElementWithContainer) => [number, number, number, number, number, number];
329
- static getElementAbsoluteCoords: (element: ExcalidrawLinearElement, includeBoundText?: boolean) => [number, number, number, number, number, number];
329
+ static getElementAbsoluteCoords: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
330
330
  }
331
331
  export {};
@@ -28,7 +28,7 @@ export declare const newTextElement: (opts: {
28
28
  lineHeight?: ExcalidrawTextElement["lineHeight"];
29
29
  strokeWidth?: ExcalidrawTextElement["strokeWidth"];
30
30
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
31
- export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, text?: string) => {
31
+ export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null, text?: string) => {
32
32
  x: number;
33
33
  y: number;
34
34
  width: number;
@@ -36,7 +36,7 @@ export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement,
36
36
  baseline: number;
37
37
  text: string;
38
38
  } | undefined;
39
- export declare const updateTextElement: (textElement: ExcalidrawTextElement, { text, isDeleted, originalText, rawText, link, }: {
39
+ export declare const updateTextElement: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null, { text, isDeleted, originalText, rawText, link, }: {
40
40
  text: string;
41
41
  isDeleted?: boolean | undefined;
42
42
  originalText: string;
@@ -1,9 +1,9 @@
1
- import { ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
1
+ import { ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, ElementsMap } from "./types";
2
2
  import { MaybeTransformHandleType, TransformHandleDirection } from "./transformHandles";
3
- import { AppState, PointerDownState } from "../types";
3
+ import { PointerDownState } from "../types";
4
4
  export declare const normalizeAngle: (angle: number) => number;
5
- export declare const transformElements: (pointerDownState: PointerDownState, transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], resizeArrowDirection: "origin" | "end", shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number, appState: AppState) => boolean;
6
- export declare const resizeSingleElement: (originalElements: PointerDownState["originalElements"], shouldMaintainAspectRatio: boolean, element: NonDeletedExcalidrawElement, transformHandleDirection: TransformHandleDirection, shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
7
- export declare const resizeMultipleElements: (pointerDownState: PointerDownState, selectedElements: readonly NonDeletedExcalidrawElement[], transformHandleType: "nw" | "ne" | "sw" | "se", shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
5
+ export declare const transformElements: (originalElements: PointerDownState["originalElements"], transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: ElementsMap, shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
6
+ export declare const resizeSingleElement: (originalElements: PointerDownState["originalElements"], shouldMaintainAspectRatio: boolean, element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, transformHandleDirection: TransformHandleDirection, shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
7
+ export declare const resizeMultipleElements: (originalElements: PointerDownState["originalElements"], selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: ElementsMap, transformHandleType: "nw" | "ne" | "sw" | "se", shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
8
8
  export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
9
9
  export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
@@ -1,11 +1,11 @@
1
- import { ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./types";
1
+ import { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./types";
2
2
  import { MaybeTransformHandleType } from "./transformHandles";
3
3
  import { AppState } from "../types";
4
4
  import { ExtractSetType } from "../utility-types";
5
5
  export declare const normalizeText: (text: string) => string;
6
6
  export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null) => void;
7
7
  export declare const bindTextToShapeAfterDuplication: (sceneElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
8
- export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean) => void;
8
+ export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, elementsMap: ElementsMap, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean) => void;
9
9
  export declare const computeBoundTextPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
10
10
  x: number;
11
11
  y: number;
@@ -42,11 +42,9 @@ export declare const getMinCharWidth: (font: FontString) => number;
42
42
  export declare const getMaxCharWidth: (font: FontString) => number;
43
43
  export declare const getApproxCharsToFitInWidth: (font: FontString, width: number) => number;
44
44
  export declare const getBoundTextElementId: (container: ExcalidrawElement | null) => string | null;
45
- export declare const getBoundTextElement: (element: ExcalidrawElement | null) => ExcalidrawTextElementWithContainer | null;
46
- export declare const getContainerElement: (element: (ExcalidrawElement & {
47
- containerId: ExcalidrawElement["id"] | null;
48
- }) | null) => ExcalidrawElement | null;
49
- export declare const getContainerCenter: (container: ExcalidrawElement, appState: AppState) => {
45
+ export declare const getBoundTextElement: (element: ExcalidrawElement | null, elementsMap: ElementsMap) => ExcalidrawTextElementWithContainer | null;
46
+ export declare const getContainerElement: (element: ExcalidrawTextElement | null, elementsMap: ElementsMap) => ExcalidrawTextContainer | null;
47
+ export declare const getContainerCenter: (container: ExcalidrawElement, appState: AppState, elementsMap: ElementsMap) => {
50
48
  x: number;
51
49
  y: number;
52
50
  };
@@ -54,21 +52,20 @@ export declare const getContainerCoords: (container: NonDeletedExcalidrawElement
54
52
  x: number;
55
53
  y: number;
56
54
  };
57
- export declare const getTextElementAngle: (textElement: ExcalidrawTextElement) => number;
58
- export declare const getBoundTextElementOffset: (boundTextElement: ExcalidrawTextElement | null) => number;
55
+ export declare const getTextElementAngle: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null) => number;
59
56
  export declare const getBoundTextElementPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
60
57
  x: number;
61
58
  y: number;
62
59
  } | undefined;
63
- export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
64
- export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
60
+ export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap) => boolean;
61
+ export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap) => boolean;
65
62
  export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], appState: AppState, x: number, y: number) => ExcalidrawTextContainer | null;
66
63
  declare const VALID_CONTAINER_TYPES: Set<string>;
67
64
  export declare const isValidTextContainer: (element: {
68
65
  type: ExcalidrawElementType;
69
66
  }) => boolean;
70
67
  export declare const computeContainerDimensionForBoundText: (dimension: number, containerType: ExtractSetType<typeof VALID_CONTAINER_TYPES>, legacy?: boolean) => number;
71
- export declare const getBoundTextMaxWidth: (container: ExcalidrawElement, boundTextElement?: ExcalidrawTextElement | null) => number;
68
+ export declare const getBoundTextMaxWidth: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElement | null) => number;
72
69
  export declare const getBoundTextMaxHeight: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => number;
73
70
  export declare const isMeasureTextSupported: () => boolean;
74
71
  export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
@@ -1,10 +1,5 @@
1
- import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawTextContainer } from "./types";
1
+ import { ExcalidrawElement, ExcalidrawTextElement } from "./types";
2
2
  import App from "../components/App";
3
- export declare const updateOriginalContainerCache: (id: ExcalidrawTextContainer["id"], height: ExcalidrawTextContainer["height"]) => {
4
- height: ExcalidrawTextContainer["height"];
5
- };
6
- export declare const resetOriginalContainerCache: (id: ExcalidrawTextContainer["id"]) => void;
7
- export declare const getOriginalContainerHeightFromCache: (id: ExcalidrawTextContainer["id"]) => number | null;
8
3
  export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, }: {
9
4
  id: ExcalidrawElement["id"];
10
5
  onChange?: ((text: string) => void) | undefined;
@@ -23,9 +23,9 @@ export declare const OMIT_SIDES_FOR_FRAME: {
23
23
  };
24
24
  export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [number, number, number, number, number, number], angle: number, zoom: Zoom, pointerType: PointerType, omitSides?: {
25
25
  s?: boolean | undefined;
26
- e?: boolean | undefined;
27
- w?: boolean | undefined;
28
26
  n?: boolean | undefined;
27
+ w?: boolean | undefined;
28
+ e?: boolean | undefined;
29
29
  nw?: boolean | undefined;
30
30
  ne?: boolean | undefined;
31
31
  sw?: boolean | undefined;
@@ -1,6 +1,6 @@
1
1
  import { Point } from "../types";
2
2
  import { FONT_FAMILY, ROUNDNESS, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "../constants";
3
- import { MarkNonNullable, ValueOf } from "../utility-types";
3
+ import { MakeBrand, MarkNonNullable, ValueOf } from "../utility-types";
4
4
  import { MagicCacheData } from "../data/magic";
5
5
  export type ChartType = "bar" | "line";
6
6
  export type FillStyle = "hachure" | "cross-hatch" | "solid" | "zigzag";
@@ -91,7 +91,7 @@ export type IframeData = ({
91
91
  w: number;
92
92
  h: number;
93
93
  };
94
- warning?: string;
94
+ error?: Error;
95
95
  } & ({
96
96
  type: "video" | "generic";
97
97
  link: string;
@@ -184,4 +184,26 @@ export type FileId = string & {
184
184
  _brand: "FileId";
185
185
  };
186
186
  export type ExcalidrawElementType = ExcalidrawElement["type"];
187
+ /**
188
+ * Map of excalidraw elements.
189
+ * Unspecified whether deleted or non-deleted.
190
+ * Can be a subset of Scene elements.
191
+ */
192
+ export type ElementsMap = Map<ExcalidrawElement["id"], ExcalidrawElement>;
193
+ /**
194
+ * Map of non-deleted elements.
195
+ * Can be a subset of Scene elements.
196
+ */
197
+ export type NonDeletedElementsMap = Map<ExcalidrawElement["id"], NonDeletedExcalidrawElement> & MakeBrand<"NonDeletedElementsMap">;
198
+ /**
199
+ * Map of all excalidraw Scene elements, including deleted.
200
+ * Not a subset. Use this type when you need access to current Scene elements.
201
+ */
202
+ export type SceneElementsMap = Map<ExcalidrawElement["id"], ExcalidrawElement> & MakeBrand<"SceneElementsMap">;
203
+ /**
204
+ * Map of all non-deleted Scene elements.
205
+ * Not a subset. Use this type when you need access to current Scene elements.
206
+ */
207
+ export type NonDeletedSceneElementsMap = Map<ExcalidrawElement["id"], NonDeletedExcalidrawElement> & MakeBrand<"NonDeletedSceneElementsMap">;
208
+ export type ElementsMapOrArray = readonly ExcalidrawElement[] | Readonly<ElementsMap>;
187
209
  export {};
@@ -1,6 +1,7 @@
1
- import { ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
1
+ import { ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
2
2
  import { AppClassProperties, AppState, StaticCanvasAppState } from "./types";
3
3
  import { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
4
+ import { ReadonlySetLike } from "./utility-types";
4
5
  export declare const bindElementsToFramesAfterDuplication: (nextElements: ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
5
6
  export declare function isElementIntersectingFrame(element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement): boolean;
6
7
  export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
@@ -18,7 +19,7 @@ export declare const groupsAreCompletelyOutOfFrame: (elements: readonly NonDelet
18
19
  * Returns a map of frameId to frame elements. Includes empty frames.
19
20
  */
20
21
  export declare const groupByFrameLikes: (elements: readonly ExcalidrawElement[]) => Map<string, ExcalidrawElement[]>;
21
- export declare const getFrameChildren: (allElements: ExcalidrawElementsIncludingDeleted, frameId: string) => ExcalidrawElement[];
22
+ export declare const getFrameChildren: (allElements: ElementsMapOrArray, frameId: string) => ExcalidrawElement[];
22
23
  export declare const getFrameLikeElements: (allElements: ExcalidrawElementsIncludingDeleted) => ExcalidrawFrameLikeElement[];
23
24
  /**
24
25
  * Returns ExcalidrawFrameElements and non-frame-children elements.
@@ -32,26 +33,31 @@ export declare const getRootElements: (allElements: ExcalidrawElementsIncludingD
32
33
  export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, appState: AppState) => ExcalidrawElement[];
33
34
  export declare const getElementsInNewFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
34
35
  export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap?: Map<string, ExcalidrawElement>) => ExcalidrawFrameLikeElement | null;
36
+ /** */
37
+ export declare const filterElementsEligibleAsFrameChildren: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
35
38
  /**
36
39
  * Retains (or repairs for target frame) the ordering invriant where children
37
40
  * elements come right before the parent frame:
38
41
  * [el, el, child, child, frame, el]
42
+ *
43
+ * @returns mutated allElements (same data structure)
39
44
  */
40
- export declare const addElementsToFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToAdd: NonDeletedExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
41
- export declare const removeElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToRemove: NonDeletedExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
42
- export declare const removeAllElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, appState: AppState) => ExcalidrawElement[];
43
- export declare const replaceAllElementsInFrame: (allElements: ExcalidrawElementsIncludingDeleted, nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, appState: AppState) => ExcalidrawElement[];
45
+ export declare const addElementsToFrame: <T extends ElementsMapOrArray>(allElements: T, elementsToAdd: NonDeletedExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => T;
46
+ export declare const removeElementsFromFrame: (elementsToRemove: ReadonlySetLike<NonDeletedExcalidrawElement>, elementsMap: ElementsMap) => void;
47
+ export declare const removeAllElementsFromFrame: <T extends ExcalidrawElement>(allElements: readonly T[], frame: ExcalidrawFrameLikeElement) => readonly T[];
48
+ export declare const replaceAllElementsInFrame: <T extends ExcalidrawElement>(allElements: readonly T[], nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, app: AppClassProperties) => T[];
44
49
  /** does not mutate elements, but returns new ones */
45
- export declare const updateFrameMembershipOfSelectedElements: (allElements: ExcalidrawElementsIncludingDeleted, appState: AppState, app: AppClassProperties) => ExcalidrawElementsIncludingDeleted;
50
+ export declare const updateFrameMembershipOfSelectedElements: <T extends ElementsMapOrArray>(allElements: T, appState: AppState, app: AppClassProperties) => T;
46
51
  /**
47
52
  * filters out elements that are inside groups that contain a frame element
48
53
  * anywhere in the group tree
49
54
  */
50
- export declare const omitGroupsContainingFrameLikes: (allElements: ExcalidrawElementsIncludingDeleted, selectedElements?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
55
+ export declare const omitGroupsContainingFrameLikes: (allElements: ElementsMapOrArray, selectedElements?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
51
56
  /**
52
57
  * depending on the appState, return target frame, which is the frame the given element
53
58
  * is going to be added to or remove from
54
59
  */
55
- export declare const getTargetFrame: (element: ExcalidrawElement, appState: StaticCanvasAppState) => import("./element/types").ExcalidrawFrameElement | import("./element/types").ExcalidrawMagicFrameElement | null;
56
- export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ExcalidrawElementsIncludingDeleted, appState: StaticCanvasAppState) => boolean;
60
+ export declare const getTargetFrame: (element: ExcalidrawElement, elementsMap: ElementsMap, appState: StaticCanvasAppState) => import("./element/types").ExcalidrawFrameElement | import("./element/types").ExcalidrawMagicFrameElement | null;
61
+ export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ElementsMap, appState: StaticCanvasAppState) => boolean;
57
62
  export declare const getFrameLikeTitle: (element: ExcalidrawFrameLikeElement, frameIdx: number) => string;
63
+ export declare const getElementsOverlappingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => NonDeletedExcalidrawElement[];
@@ -1,4 +1,4 @@
1
- import { GroupId, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
1
+ import { GroupId, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ElementsMapOrArray, ElementsMap } from "./element/types";
2
2
  import { AppClassProperties, AppState, InteractiveCanvasAppState } from "./types";
3
3
  import { Mutable } from "./utility-types";
4
4
  export declare const selectGroup: (groupId: GroupId, appState: InteractiveCanvasAppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => Pick<InteractiveCanvasAppState, "selectedGroupIds" | "selectedElementIds" | "editingGroupId">;
@@ -18,7 +18,7 @@ export declare const selectGroupsFromGivenElements: (elements: readonly NonDelet
18
18
  };
19
19
  export declare const editGroupForSelectedElement: (appState: AppState, element: NonDeleted<ExcalidrawElement>) => AppState;
20
20
  export declare const isElementInGroup: (element: ExcalidrawElement, groupId: string) => boolean;
21
- export declare const getElementsInGroup: (elements: readonly ExcalidrawElement[], groupId: string) => ExcalidrawElement[];
21
+ export declare const getElementsInGroup: (elements: ElementsMapOrArray, groupId: string) => ExcalidrawElement[];
22
22
  export declare const getSelectedGroupIdForElement: (element: ExcalidrawElement, selectedGroupIds: {
23
23
  [groupId: string]: boolean;
24
24
  }) => string | undefined;
@@ -27,5 +27,5 @@ export declare const addToGroup: (prevGroupIds: ExcalidrawElement["groupIds"], n
27
27
  export declare const removeFromSelectedGroups: (groupIds: ExcalidrawElement["groupIds"], selectedGroupIds: {
28
28
  [groupId: string]: boolean;
29
29
  }) => string[];
30
- export declare const getMaximumGroups: (elements: ExcalidrawElement[]) => ExcalidrawElement[][];
30
+ export declare const getMaximumGroups: (elements: ExcalidrawElement[], elementsMap: ElementsMap) => ExcalidrawElement[][];
31
31
  export declare const elementsAreInSameGroup: (elements: ExcalidrawElement[]) => boolean;
@@ -22,7 +22,7 @@ getFontString, //zsviczian
22
22
  getBoundTextMaxWidth, //zsviczian
23
23
  exportToClipboard, mergeLibraryItems, mermaidToExcalidraw, } from "../utils/export";
24
24
  export { isLinearElement } from "./element/typeChecks";
25
- export { FONT_FAMILY, THEME, MIME_TYPES } from "./constants";
25
+ export { FONT_FAMILY, THEME, MIME_TYPES, ROUNDNESS } from "./constants";
26
26
  export { mutateElement, newElementWith, bumpVersion, } from "./element/mutateElement";
27
27
  export { parseLibraryTokensFromUrl, useHandleLibrary } from "./data/library";
28
28
  export { sceneCoordsToViewportCoords, viewportCoordsToSceneCoords, } from "./utils";
@@ -1,7 +1,7 @@
1
- import { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawFrameLikeElement } from "../element/types";
1
+ import { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawFrameLikeElement, NonDeletedSceneElementsMap } from "../element/types";
2
2
  import type { RoughCanvas } from "roughjs/bin/canvas";
3
3
  import type { RoughSVG } from "roughjs/bin/svg";
4
- import { SVGRenderConfig, StaticCanvasRenderConfig } from "../scene/types";
4
+ import { SVGRenderConfig, StaticCanvasRenderConfig, RenderableElementsMap } from "../scene/types";
5
5
  import { AppState, StaticCanvasAppState, BinaryFiles, InteractiveCanvasAppState, ElementsPendingErasure } from "../types";
6
6
  export declare const getRenderOpacity: (element: ExcalidrawElement, containingFrame: ExcalidrawFrameLikeElement | null, elementsPendingErasure: ElementsPendingErasure) => number;
7
7
  export interface ExcalidrawElementWithCanvas {
@@ -18,8 +18,8 @@ export interface ExcalidrawElementWithCanvas {
18
18
  export declare const DEFAULT_LINK_SIZE = 14;
19
19
  export declare const elementWithCanvasCache: WeakMap<ExcalidrawElement, ExcalidrawElementWithCanvas>;
20
20
  export declare const renderSelectionElement: (element: NonDeletedExcalidrawElement, context: CanvasRenderingContext2D, appState: InteractiveCanvasAppState) => void;
21
- export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState) => void;
22
- export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, renderConfig: SVGRenderConfig) => void;
21
+ export declare const renderElement: (element: NonDeletedExcalidrawElement, elementsMap: RenderableElementsMap, allElementsMap: NonDeletedSceneElementsMap, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState) => void;
22
+ export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, elementsMap: RenderableElementsMap, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, renderConfig: SVGRenderConfig) => void;
23
23
  export declare const pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
24
24
  export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
25
25
  export declare function getFreeDrawPath2D(element: ExcalidrawFreeDrawElement): Path2D | undefined;
@@ -1,25 +1,23 @@
1
1
  import { RoughSVG } from "roughjs/bin/svg";
2
2
  import { BinaryFiles } from "../types";
3
3
  import { NonDeletedExcalidrawElement } from "../element/types";
4
- import { InteractiveSceneRenderConfig, SVGRenderConfig, StaticSceneRenderConfig } from "../scene/types";
5
- import "canvas-roundrect-polyfill";
6
- export declare const DEFAULT_SPACING = 2;
4
+ import { InteractiveSceneRenderConfig, SVGRenderConfig, StaticSceneRenderConfig, RenderableElementsMap } from "../scene/types";
7
5
  /**
8
6
  * Interactive scene is the ui-canvas where we render boundinb boxes, selections
9
7
  * and other ui stuff.
10
8
  */
11
- export declare const renderInteractiveScene: <U extends ({ canvas, elements, visibleElements, selectedElements, scale, appState, renderConfig, }: InteractiveSceneRenderConfig) => {
9
+ export declare const renderInteractiveScene: <U extends ({ canvas, elementsMap, visibleElements, selectedElements, scale, appState, renderConfig, }: InteractiveSceneRenderConfig) => {
12
10
  atLeastOneVisibleElement: boolean;
13
- elements: readonly NonDeletedExcalidrawElement[];
11
+ elementsMap: RenderableElementsMap;
14
12
  scrollBars?: undefined;
15
13
  } | {
16
14
  scrollBars: import("../scene/types").ScrollBars | undefined;
17
15
  atLeastOneVisibleElement: boolean;
18
- elements: readonly NonDeletedExcalidrawElement[];
16
+ elementsMap: RenderableElementsMap;
19
17
  }, T extends boolean = false>(renderConfig: InteractiveSceneRenderConfig, throttle?: T | undefined) => T extends true ? void : ReturnType<U>;
20
18
  /**
21
19
  * Static scene is the non-ui canvas where we render elements.
22
20
  */
23
21
  export declare const renderStaticScene: (renderConfig: StaticSceneRenderConfig, throttle?: boolean) => void;
24
22
  export declare const cancelRender: () => void;
25
- export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, renderConfig: SVGRenderConfig) => void;
23
+ export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], elementsMap: RenderableElementsMap, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, renderConfig: SVGRenderConfig) => void;
@@ -16,7 +16,7 @@ export declare class Renderer {
16
16
  pendingImageElementId: AppState["pendingImageElementId"];
17
17
  versionNonce: ReturnType<InstanceType<typeof Scene>["getVersionNonce"]>;
18
18
  }) => {
19
- canvasElements: NonDeletedExcalidrawElement[];
19
+ elementsMap: Map<string, NonDeletedExcalidrawElement> & import("../utility-types").MakeBrand<"NonDeletedElementsMap"> & import("../utility-types").MakeBrand<"RenderableElementsMap">;
20
20
  visibleElements: readonly NonDeletedExcalidrawElement[];
21
21
  }) & {
22
22
  clear: () => void;
@@ -1,4 +1,4 @@
1
- import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameLikeElement } from "../element/types";
1
+ import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameLikeElement, ElementsMapOrArray } from "../element/types";
2
2
  import { LinearElementEditor } from "../element/linearElementEditor";
3
3
  import { AppState } from "../types";
4
4
  type ElementIdKey = InstanceType<typeof LinearElementEditor>["elementId"];
@@ -18,12 +18,15 @@ declare class Scene {
18
18
  static getScene(elementKey: ElementKey): Scene | null;
19
19
  private callbacks;
20
20
  private nonDeletedElements;
21
+ private nonDeletedElementsMap;
21
22
  private elements;
22
23
  private nonDeletedFramesLikes;
23
24
  private frames;
24
25
  private elementsMap;
25
26
  private selectedElementsCache;
26
27
  private versionNonce;
28
+ getElementsMapIncludingDeleted(): Map<string, ExcalidrawElement> & import("../utility-types").MakeBrand<"SceneElementsMap">;
29
+ getNonDeletedElementsMap(): Map<string, NonDeletedExcalidrawElement> & import("../utility-types").MakeBrand<"NonDeletedSceneElementsMap">;
27
30
  getElementsIncludingDeleted(): readonly ExcalidrawElement[];
28
31
  getNonDeletedElements(): readonly NonDeletedExcalidrawElement[];
29
32
  getFramesIncludingDeleted(): readonly ExcalidrawFrameLikeElement[];
@@ -34,7 +37,7 @@ declare class Scene {
34
37
  * scene state. This in effect will likely result in cache-miss, and
35
38
  * the cache won't be updated in this case.
36
39
  */
37
- elements?: readonly ExcalidrawElement[];
40
+ elements?: ElementsMapOrArray;
38
41
  includeBoundTextElement?: boolean;
39
42
  includeElementsInFrames?: boolean;
40
43
  }): NonDeleted<ExcalidrawElement>[];
@@ -55,7 +58,7 @@ declare class Scene {
55
58
  * @returns whether a change was made
56
59
  */
57
60
  mapElements(iteratee: (element: ExcalidrawElement) => ExcalidrawElement): boolean;
58
- replaceAllElements(nextElements: readonly ExcalidrawElement[], mapElementIds?: boolean): void;
61
+ replaceAllElements(nextElements: ElementsMapOrArray, mapElementIds?: boolean): void;
59
62
  informMutation(): void;
60
63
  addCallback(cb: SceneStateCallback): SceneStateCallbackRemover;
61
64
  destroy(): void;
@@ -63,5 +66,8 @@ declare class Scene {
63
66
  insertElementsAtIndex(elements: ExcalidrawElement[], index: number): void;
64
67
  addNewElement: (element: ExcalidrawElement) => void;
65
68
  getElementIndex(elementId: string): number;
69
+ getContainerElement: (element: (ExcalidrawElement & {
70
+ containerId: ExcalidrawElement["id"] | null;
71
+ }) | null) => ExcalidrawElement | null;
66
72
  }
67
73
  export default Scene;
@@ -1,4 +1,3 @@
1
- export { isOverScrollBars } from "./scrollbars";
2
1
  export { isSomeElementSelected, getElementsWithinSelection, getCommonAttributeOfSelectedElements, getSelectedElements, getTargetElements, } from "./selection";
3
2
  export { calculateScrollCenter } from "./scroll";
4
3
  export { hasBackground, hasStrokeWidth, hasStrokeStyle, canHaveArrowheads, canChangeRoundness, getElementAtPosition, getElementsAtPosition, } from "./comparisons";
@@ -1,10 +1,9 @@
1
- import { ExcalidrawElement } from "../element/types";
2
1
  import { InteractiveCanvasAppState } from "../types";
3
- import { ScrollBars } from "./types";
2
+ import { RenderableElementsMap, ScrollBars } from "./types";
4
3
  export declare const SCROLLBAR_MARGIN = 4;
5
4
  export declare const SCROLLBAR_WIDTH = 6;
6
5
  export declare const SCROLLBAR_COLOR = "rgba(128,128,128,0.3)";
7
- export declare const getScrollBars: (elements: readonly ExcalidrawElement[], viewportWidth: number, viewportHeight: number, appState: InteractiveCanvasAppState) => ScrollBars;
6
+ export declare const getScrollBars: (elements: RenderableElementsMap, viewportWidth: number, viewportHeight: number, appState: InteractiveCanvasAppState) => ScrollBars;
8
7
  export declare const isOverScrollBars: (scrollBars: ScrollBars, x: number, y: number) => {
9
8
  isOverEither: boolean;
10
9
  isOverHorizontal: boolean;
@@ -1,4 +1,4 @@
1
- import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
1
+ import { ElementsMapOrArray, ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
2
2
  import { AppState, InteractiveCanvasAppState } from "../types";
3
3
  /**
4
4
  * Frames and their containing elements are not to be selected at the same time.
@@ -18,11 +18,11 @@ export declare const isSomeElementSelected: {
18
18
  * elements. If elements don't share the same value, returns `null`.
19
19
  */
20
20
  export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, getAttribute: (element: ExcalidrawElement) => T) => T | null;
21
- export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<InteractiveCanvasAppState, "selectedElementIds">, opts?: {
21
+ export declare const getSelectedElements: (elements: ElementsMapOrArray, appState: Pick<InteractiveCanvasAppState, "selectedElementIds">, opts?: {
22
22
  includeBoundTextElement?: boolean;
23
23
  includeElementsInFrames?: boolean;
24
24
  }) => ExcalidrawElement[];
25
- export declare const getTargetElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds" | "editingElement">) => ExcalidrawElement[];
25
+ export declare const getTargetElements: (elements: ElementsMapOrArray, appState: Pick<AppState, "selectedElementIds" | "editingElement">) => ExcalidrawElement[];
26
26
  /**
27
27
  * returns prevState's selectedElementids if no change from previous, so as to
28
28
  * retain reference identity for memoization
@@ -1,7 +1,9 @@
1
1
  import type { RoughCanvas } from "roughjs/bin/canvas";
2
2
  import { Drawable } from "roughjs/bin/core";
3
- import { ExcalidrawTextElement, NonDeletedExcalidrawElement } from "../element/types";
3
+ import { ExcalidrawTextElement, NonDeletedElementsMap, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap } from "../element/types";
4
4
  import { AppClassProperties, AppState, EmbedsValidationStatus, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState } from "../types";
5
+ import { MakeBrand } from "../utility-types";
6
+ export type RenderableElementsMap = NonDeletedElementsMap & MakeBrand<"RenderableElementsMap">;
5
7
  export type StaticCanvasRenderConfig = {
6
8
  canvasBackgroundColor: AppState["viewBackgroundColor"];
7
9
  imageCache: AppClassProperties["imageCache"];
@@ -47,13 +49,14 @@ export type InteractiveCanvasRenderConfig = {
47
49
  };
48
50
  export type RenderInteractiveSceneCallback = {
49
51
  atLeastOneVisibleElement: boolean;
50
- elements: readonly NonDeletedExcalidrawElement[];
52
+ elementsMap: RenderableElementsMap;
51
53
  scrollBars?: ScrollBars;
52
54
  };
53
55
  export type StaticSceneRenderConfig = {
54
56
  canvas: HTMLCanvasElement;
55
57
  rc: RoughCanvas;
56
- elements: readonly NonDeletedExcalidrawElement[];
58
+ elementsMap: RenderableElementsMap;
59
+ allElementsMap: NonDeletedSceneElementsMap;
57
60
  visibleElements: readonly NonDeletedExcalidrawElement[];
58
61
  scale: number;
59
62
  appState: StaticCanvasAppState;
@@ -61,7 +64,7 @@ export type StaticSceneRenderConfig = {
61
64
  };
62
65
  export type InteractiveSceneRenderConfig = {
63
66
  canvas: HTMLCanvasElement | null;
64
- elements: readonly NonDeletedExcalidrawElement[];
67
+ elementsMap: RenderableElementsMap;
65
68
  visibleElements: readonly NonDeletedExcalidrawElement[];
66
69
  selectedElements: readonly NonDeletedExcalidrawElement[];
67
70
  scale: number;
@@ -10,7 +10,7 @@ import type { throttleRAF } from "./utils";
10
10
  import { Spreadsheet } from "./charts";
11
11
  import { Language } from "./i18n";
12
12
  import { ClipboardData } from "./clipboard";
13
- import { isOverScrollBars } from "./scene";
13
+ import { isOverScrollBars } from "./scene/scrollbars";
14
14
  import { MaybeTransformHandleType } from "./element/transformHandles";
15
15
  import Library from "./data/library";
16
16
  import type { FileSystemHandle } from "./data/filesystem";
@@ -391,6 +391,7 @@ export interface ExcalidrawProps {
391
391
  }>) => void;
392
392
  onLinkHover?: (element: NonDeletedExcalidrawElement, event: React.PointerEvent<HTMLCanvasElement>) => void;
393
393
  onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
394
+ onPointerUp?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
394
395
  onScrollChange?: (scrollX: number, scrollY: number, zoom: Zoom) => void;
395
396
  onUserFollow?: (payload: OnUserFollowedPayload) => void;
396
397
  children?: React.ReactNode;