@dwelle/excalidraw 0.5.0-ff7b5f2db → 0.5.0-ffade30
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.
- package/CHANGELOG.md +2385 -0
- package/dist/dev/{chunk-56C7N44U.js → chunk-CB6O5JO7.js} +16177 -10984
- package/dist/dev/chunk-CB6O5JO7.js.map +7 -0
- package/dist/dev/{chunk-DGCWVQGA.js → chunk-JB4JDZ66.js} +15 -4
- package/dist/dev/chunk-JB4JDZ66.js.map +7 -0
- package/dist/dev/chunk-QXVP5PAI.js +7 -0
- package/dist/dev/chunk-QXVP5PAI.js.map +7 -0
- package/dist/dev/data/{image-BLSI3C2P.js → image-JTJWA4BG.js} +3 -3
- package/dist/dev/index.css +143 -68
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +3978 -6519
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-AAITTNRF.js → en-PIB5PD3P.js} +2 -2
- package/dist/dev/subset-shared.chunk.js +1 -1
- package/dist/dev/subset-worker.chunk.js +1 -1
- package/dist/prod/chunk-JEM5OQGK.js +33 -0
- package/dist/prod/chunk-JH36RZFS.js +7 -0
- package/dist/prod/{chunk-OV23WS6X.js → chunk-KC3NX2DX.js} +4 -4
- package/dist/prod/data/image-UJJWHTZ6.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +22 -21
- package/dist/prod/locales/{en-YOZMX4VX.js → en-RKTHI3YA.js} +1 -1
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/common/src/colors.d.ts +1 -0
- package/dist/types/common/src/constants.d.ts +11 -1
- package/dist/types/{excalidraw → common/src}/emitter.d.ts +1 -1
- package/dist/types/common/src/font-metadata.d.ts +4 -2
- package/dist/types/common/src/index.d.ts +1 -0
- package/dist/types/common/src/utility-types.d.ts +5 -0
- package/dist/types/common/src/utils.d.ts +22 -5
- package/dist/types/{excalidraw/scene → element/src}/Scene.d.ts +11 -14
- package/dist/types/element/src/ShapeCache.d.ts +1 -1
- package/dist/types/element/src/align.d.ts +3 -3
- package/dist/types/element/src/binding.d.ts +19 -11
- package/dist/types/element/src/bounds.d.ts +7 -2
- package/dist/types/element/src/collision.d.ts +1 -1
- package/dist/types/{excalidraw/change.d.ts → element/src/delta.d.ts} +40 -35
- package/dist/types/element/src/dragElements.d.ts +3 -2
- package/dist/types/element/src/duplicate.d.ts +10 -13
- package/dist/types/element/src/elbowArrow.d.ts +1 -1
- package/dist/types/element/src/flowchart.d.ts +3 -2
- package/dist/types/element/src/fractionalIndex.d.ts +2 -2
- package/dist/types/element/src/frame.d.ts +5 -4
- package/dist/types/element/src/heading.d.ts +0 -1
- package/dist/types/element/src/index.d.ts +45 -2
- package/dist/types/element/src/linearElementEditor.d.ts +19 -31
- package/dist/types/element/src/mutateElement.d.ts +10 -2
- package/dist/types/element/src/newElement.d.ts +4 -3
- package/dist/types/element/src/resizeElements.d.ts +4 -4
- package/dist/types/element/src/selection.d.ts +11 -5
- package/dist/types/element/src/shapes.d.ts +5 -1
- package/dist/types/element/src/sizeHelpers.d.ts +1 -1
- package/dist/types/element/src/store.d.ts +227 -0
- package/dist/types/element/src/textElement.d.ts +5 -3
- package/dist/types/element/src/transformHandles.d.ts +4 -4
- package/dist/types/element/src/typeChecks.d.ts +15 -1
- package/dist/types/element/src/types.d.ts +14 -1
- package/dist/types/element/src/zindex.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +42 -45
- package/dist/types/excalidraw/actions/actionAlign.d.ts +8 -8
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +28 -30
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +438 -275
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +86 -92
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +14 -15
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +40 -43
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +14 -15
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +43 -47
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +14 -15
- package/dist/types/excalidraw/actions/actionExport.d.ts +219 -228
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +73 -36
- package/dist/types/excalidraw/actions/actionFlip.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionFrame.d.ts +100 -104
- package/dist/types/excalidraw/actions/actionGroup.d.ts +34 -36
- package/dist/types/excalidraw/actions/actionHistory.d.ts +1 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +506 -14
- package/dist/types/excalidraw/actions/actionLink.d.ts +14 -15
- package/dist/types/excalidraw/actions/actionMenu.d.ts +42 -45
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +27 -29
- package/dist/types/excalidraw/actions/actionProperties.d.ts +207 -214
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +16 -17
- package/dist/types/excalidraw/actions/actionStyles.d.ts +18 -19
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +16 -17
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +16 -17
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +16 -189
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +16 -18
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +16 -18
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +16 -18
- package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
- package/dist/types/excalidraw/actions/types.d.ts +4 -3
- package/dist/types/excalidraw/animated-trail.d.ts +7 -1
- package/dist/types/excalidraw/appState.d.ts +40 -30
- package/dist/types/excalidraw/components/App.d.ts +30 -12
- package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +5 -1
- package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/HotkeyLabel.d.ts +1 -2
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -3
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -3
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -2
- package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +2 -2
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +23 -0
- package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +4 -3
- package/dist/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
- package/dist/types/excalidraw/components/Range.d.ts +3 -3
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Position.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -11
- package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
- package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -1
- package/dist/types/excalidraw/components/icons.d.ts +4 -0
- package/dist/types/excalidraw/components/shapes.d.ts +1 -1
- package/dist/types/excalidraw/data/blob.d.ts +1 -1
- package/dist/types/excalidraw/data/transform.d.ts +1 -1
- package/dist/types/excalidraw/editor-jotai.d.ts +6 -6
- package/dist/types/excalidraw/eraser/index.d.ts +14 -0
- package/dist/types/excalidraw/fonts/Fonts.d.ts +1 -1
- package/dist/types/excalidraw/history.d.ts +14 -22
- package/dist/types/excalidraw/hooks/useEmitter.d.ts +1 -1
- package/dist/types/excalidraw/index.d.ts +9 -9
- package/dist/types/excalidraw/lasso/index.d.ts +16 -0
- package/dist/types/excalidraw/lasso/utils.d.ts +12 -0
- package/dist/types/excalidraw/renderer/helpers.d.ts +6 -1
- package/dist/types/excalidraw/scene/Renderer.d.ts +1 -1
- package/dist/types/excalidraw/scene/export.d.ts +1 -1
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/scrollbars.d.ts +2 -3
- package/dist/types/excalidraw/scene/types.d.ts +2 -0
- package/dist/types/excalidraw/snapping.d.ts +2 -2
- package/dist/types/excalidraw/types.d.ts +30 -7
- package/dist/types/excalidraw/visualdebug.d.ts +1 -1
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +3 -1
- package/dist/types/math/src/curve.d.ts +2 -0
- package/dist/types/math/src/point.d.ts +1 -1
- package/dist/types/math/src/polygon.d.ts +1 -0
- package/dist/types/math/src/segment.d.ts +1 -1
- package/dist/types/math/src/types.d.ts +1 -0
- package/dist/types/math/src/vector.d.ts +4 -0
- package/dist/types/utils/src/bbox.d.ts +1 -1
- package/dist/types/utils/src/index.d.ts +1 -1
- package/dist/types/utils/src/withinBounds.d.ts +1 -1
- package/history.ts +186 -0
- package/package.json +9 -4
- package/dist/dev/chunk-56C7N44U.js.map +0 -7
- package/dist/dev/chunk-DGCWVQGA.js.map +0 -7
- package/dist/dev/chunk-HQHB2BE4.js +0 -7
- package/dist/dev/chunk-HQHB2BE4.js.map +0 -7
- package/dist/prod/chunk-BUJ2ENHZ.js +0 -31
- package/dist/prod/chunk-C3FOHAIA.js +0 -7
- package/dist/prod/data/image-MI7OQWUS.js +0 -1
- package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
- package/dist/types/excalidraw/store.d.ts +0 -129
- /package/dist/dev/data/{image-BLSI3C2P.js.map → image-JTJWA4BG.js.map} +0 -0
- /package/dist/dev/locales/{en-AAITTNRF.js.map → en-PIB5PD3P.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExcalidrawElement, OrderedExcalidrawElement } from "./types";
|
|
1
|
+
import type { ElementsMap, ExcalidrawElement, OrderedExcalidrawElement } from "./types";
|
|
2
2
|
export declare class InvalidFractionalIndexError extends Error {
|
|
3
3
|
code: "ELEMENT_HAS_INVALID_INDEX";
|
|
4
4
|
}
|
|
@@ -42,7 +42,7 @@ export declare const orderByFractionalIndex: (elements: OrderedExcalidrawElement
|
|
|
42
42
|
* Synchronizes invalid fractional indices of moved elements with the array order by mutating passed elements.
|
|
43
43
|
* If the synchronization fails or the result is invalid, it fallbacks to `syncInvalidIndices`.
|
|
44
44
|
*/
|
|
45
|
-
export declare const syncMovedIndices: (elements: readonly ExcalidrawElement[], movedElements:
|
|
45
|
+
export declare const syncMovedIndices: (elements: readonly ExcalidrawElement[], movedElements: ElementsMap) => OrderedExcalidrawElement[];
|
|
46
46
|
/**
|
|
47
47
|
* Synchronizes all invalid fractional indices with the array order by mutating passed elements.
|
|
48
48
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ExcalidrawElementsIncludingDeleted } from "@excalidraw/excalidraw/scene/Scene";
|
|
2
1
|
import type { AppClassProperties, AppState, StaticCanvasAppState } from "@excalidraw/excalidraw/types";
|
|
3
2
|
import type { ReadonlySetLike } from "@excalidraw/common/utility-types";
|
|
3
|
+
import type { ExcalidrawElementsIncludingDeleted } from "./Scene";
|
|
4
4
|
import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./types";
|
|
5
|
-
export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[],
|
|
5
|
+
export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[], origElements: readonly ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
|
|
6
6
|
export declare function isElementIntersectingFrame(element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap): boolean;
|
|
7
7
|
export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => ExcalidrawElement[];
|
|
8
8
|
export declare const isElementContainingFrame: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => boolean;
|
|
@@ -31,8 +31,8 @@ export declare const getFrameLikeElements: (allElements: ExcalidrawElementsInclu
|
|
|
31
31
|
*/
|
|
32
32
|
export declare const getRootElements: (allElements: ExcalidrawElementsIncludingDeleted) => ExcalidrawElement[];
|
|
33
33
|
export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, appState: AppState, elementsMap: ElementsMap) => ExcalidrawElement[];
|
|
34
|
-
export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").
|
|
35
|
-
export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").
|
|
34
|
+
export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawFreeDrawElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawEmbeddableElement)[];
|
|
35
|
+
export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawFreeDrawElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawEmbeddableElement)[];
|
|
36
36
|
export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap: ElementsMap) => ExcalidrawFrameLikeElement | null;
|
|
37
37
|
/** */
|
|
38
38
|
export declare const filterElementsEligibleAsFrameChildren: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
|
|
@@ -64,6 +64,7 @@ export declare const isElementInFrame: (element: ExcalidrawElement, allElementsM
|
|
|
64
64
|
checkedGroups?: Map<string, boolean>;
|
|
65
65
|
}) => boolean;
|
|
66
66
|
export declare const shouldApplyFrameClip: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, appState: StaticCanvasAppState, elementsMap: ElementsMap, checkedGroups?: Map<string, boolean>) => boolean;
|
|
67
|
+
export declare const getDefaultFrameName: (element: ExcalidrawFrameLikeElement) => "Frame" | "AI Frame";
|
|
67
68
|
export declare const getFrameLikeTitle: (element: ExcalidrawFrameLikeElement) => string;
|
|
68
69
|
export declare const getElementsOverlappingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => NonDeletedExcalidrawElement[];
|
|
69
70
|
export declare const frameAndChildrenSelectedTogether: (selectedElements: readonly ExcalidrawElement[]) => boolean;
|
|
@@ -5,7 +5,6 @@ export declare const HEADING_DOWN: Heading;
|
|
|
5
5
|
export declare const HEADING_LEFT: Heading;
|
|
6
6
|
export declare const HEADING_UP: Heading;
|
|
7
7
|
export type Heading = [1, 0] | [0, 1] | [-1, 0] | [0, -1];
|
|
8
|
-
export declare const headingForDiamond: <Point extends GlobalPoint | LocalPoint>(a: Point, b: Point) => Heading;
|
|
9
8
|
export declare const vectorToHeading: (vec: Vector) => Heading;
|
|
10
9
|
export declare const headingForPoint: <P extends GlobalPoint | LocalPoint>(p: P, o: P) => Heading;
|
|
11
10
|
export declare const headingForPointIsHorizontal: <P extends GlobalPoint | LocalPoint>(p: P, o: P) => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
|
|
1
|
+
import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ElementsMapOrArray } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* @deprecated unsafe, use hashElementsVersion instead
|
|
4
4
|
*/
|
|
@@ -6,7 +6,7 @@ export declare const getSceneVersion: (elements: readonly ExcalidrawElement[]) =
|
|
|
6
6
|
/**
|
|
7
7
|
* Hashes elements' versionNonce (using djb2 algo). Order of elements matters.
|
|
8
8
|
*/
|
|
9
|
-
export declare const hashElementsVersion: (elements:
|
|
9
|
+
export declare const hashElementsVersion: (elements: ElementsMapOrArray) => number;
|
|
10
10
|
export declare const hashString: (s: string) => number;
|
|
11
11
|
export declare const getVisibleElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
|
|
12
12
|
export declare const getNonDeletedElements: <T extends ExcalidrawElement>(elements: readonly T[]) => readonly NonDeleted<T>[];
|
|
@@ -14,3 +14,46 @@ export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element:
|
|
|
14
14
|
export declare const clearElementsForDatabase: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
15
15
|
export declare const clearElementsForExport: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
16
16
|
export declare const clearElementsForLocalStorage: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
17
|
+
export * from "./align";
|
|
18
|
+
export * from "./binding";
|
|
19
|
+
export * from "./bounds";
|
|
20
|
+
export * from "./collision";
|
|
21
|
+
export * from "./comparisons";
|
|
22
|
+
export * from "./containerCache";
|
|
23
|
+
export * from "./cropElement";
|
|
24
|
+
export * from "./delta";
|
|
25
|
+
export * from "./distance";
|
|
26
|
+
export * from "./distribute";
|
|
27
|
+
export * from "./dragElements";
|
|
28
|
+
export * from "./duplicate";
|
|
29
|
+
export * from "./elbowArrow";
|
|
30
|
+
export * from "./elementLink";
|
|
31
|
+
export * from "./embeddable";
|
|
32
|
+
export * from "./flowchart";
|
|
33
|
+
export * from "./fractionalIndex";
|
|
34
|
+
export * from "./frame";
|
|
35
|
+
export * from "./groups";
|
|
36
|
+
export * from "./heading";
|
|
37
|
+
export * from "./image";
|
|
38
|
+
export * from "./linearElementEditor";
|
|
39
|
+
export * from "./mutateElement";
|
|
40
|
+
export * from "./newElement";
|
|
41
|
+
export * from "./renderElement";
|
|
42
|
+
export * from "./resizeElements";
|
|
43
|
+
export * from "./resizeTest";
|
|
44
|
+
export * from "./Scene";
|
|
45
|
+
export * from "./selection";
|
|
46
|
+
export * from "./Shape";
|
|
47
|
+
export * from "./ShapeCache";
|
|
48
|
+
export * from "./shapes";
|
|
49
|
+
export * from "./showSelectedShapeActions";
|
|
50
|
+
export * from "./sizeHelpers";
|
|
51
|
+
export * from "./sortElements";
|
|
52
|
+
export * from "./store";
|
|
53
|
+
export * from "./textElement";
|
|
54
|
+
export * from "./textMeasurements";
|
|
55
|
+
export * from "./textWrapping";
|
|
56
|
+
export * from "./transformHandles";
|
|
57
|
+
export * from "./typeChecks";
|
|
58
|
+
export * from "./utils";
|
|
59
|
+
export * from "./zindex";
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
|
|
3
|
-
import
|
|
4
|
-
import type { Store } from "@excalidraw/excalidraw/store";
|
|
3
|
+
import type { Store } from "@excalidraw/element";
|
|
5
4
|
import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize, Zoom } from "@excalidraw/excalidraw/types";
|
|
5
|
+
import type { Scene } from "./Scene";
|
|
6
6
|
import type { Bounds } from "./bounds";
|
|
7
|
-
import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap,
|
|
8
|
-
declare const editorMidPointsCache: {
|
|
9
|
-
version: number | null;
|
|
10
|
-
points: (GlobalPoint | null)[];
|
|
11
|
-
zoom: number | null;
|
|
12
|
-
};
|
|
7
|
+
import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, ExcalidrawElbowArrowElement, PointsPositionUpdates } from "./types";
|
|
13
8
|
export declare class LinearElementEditor {
|
|
14
9
|
readonly elementId: ExcalidrawElement["id"] & {
|
|
15
10
|
_brand: "excalidrawLinearElementId";
|
|
@@ -43,7 +38,7 @@ export declare class LinearElementEditor {
|
|
|
43
38
|
readonly hoverPointIndex: number;
|
|
44
39
|
readonly segmentMidPointHoveredCoords: GlobalPoint | null;
|
|
45
40
|
readonly elbowed: boolean;
|
|
46
|
-
constructor(element: NonDeleted<ExcalidrawLinearElement
|
|
41
|
+
constructor(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap);
|
|
47
42
|
static POINT_HANDLE_SIZE: number;
|
|
48
43
|
/**
|
|
49
44
|
* @param id the `elementId` from the instance of this class (so that we can
|
|
@@ -59,8 +54,7 @@ export declare class LinearElementEditor {
|
|
|
59
54
|
y: number;
|
|
60
55
|
}[]) => void, linearElementEditor: LinearElementEditor, scene: Scene): LinearElementEditor | null;
|
|
61
56
|
static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState, scene: Scene): LinearElementEditor;
|
|
62
|
-
static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (
|
|
63
|
-
static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => void;
|
|
57
|
+
static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (GlobalPoint | null)[];
|
|
64
58
|
static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
|
|
65
59
|
x: number;
|
|
66
60
|
y: number;
|
|
@@ -77,7 +71,7 @@ export declare class LinearElementEditor {
|
|
|
77
71
|
linearElementEditor: LinearElementEditor | null;
|
|
78
72
|
};
|
|
79
73
|
static arePointsEqual<Point extends LocalPoint | GlobalPoint>(point1: Point | null, point2: Point | null): boolean;
|
|
80
|
-
static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, app: AppClassProperties
|
|
74
|
+
static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, app: AppClassProperties): LinearElementEditor | null;
|
|
81
75
|
/** scene coords */
|
|
82
76
|
static getPointGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, p: LocalPoint, elementsMap: ElementsMap): GlobalPoint;
|
|
83
77
|
/** scene coords */
|
|
@@ -89,30 +83,25 @@ export declare class LinearElementEditor {
|
|
|
89
83
|
static createPointAt(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, scenePointerX: number, scenePointerY: number, gridSize: NullableGridSize): LocalPoint;
|
|
90
84
|
/**
|
|
91
85
|
* Normalizes line points so that the start point is at [0,0]. This is
|
|
92
|
-
* expected in various parts of the codebase.
|
|
93
|
-
*
|
|
86
|
+
* expected in various parts of the codebase.
|
|
87
|
+
*
|
|
88
|
+
* Also returns normalized x and y coords to account for the normalization
|
|
89
|
+
* of the points.
|
|
94
90
|
*/
|
|
95
|
-
static
|
|
91
|
+
static getNormalizeElementPointsAndCoords(element: ExcalidrawLinearElement): {
|
|
96
92
|
points: LocalPoint[];
|
|
97
93
|
x: number;
|
|
98
94
|
y: number;
|
|
99
95
|
};
|
|
100
|
-
static
|
|
101
|
-
static
|
|
102
|
-
static
|
|
103
|
-
static
|
|
104
|
-
point: LocalPoint;
|
|
105
|
-
}[]): void;
|
|
106
|
-
static movePoints(element: NonDeleted<ExcalidrawLinearElement>, targetPoints: {
|
|
107
|
-
index: number;
|
|
108
|
-
point: LocalPoint;
|
|
109
|
-
isDragging?: boolean;
|
|
110
|
-
}[], otherUpdates?: {
|
|
96
|
+
static duplicateSelectedPoints(appState: AppState, scene: Scene): AppState;
|
|
97
|
+
static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, app: AppClassProperties, pointIndices: readonly number[]): void;
|
|
98
|
+
static addPoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, addedPoints: LocalPoint[]): void;
|
|
99
|
+
static movePoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, pointUpdates: PointsPositionUpdates, otherUpdates?: {
|
|
111
100
|
startBinding?: PointBinding | null;
|
|
112
101
|
endBinding?: PointBinding | null;
|
|
113
|
-
}
|
|
102
|
+
}): void;
|
|
114
103
|
static shouldAddMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState, elementsMap: ElementsMap): boolean;
|
|
115
|
-
static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, app: AppClassProperties, snapToGrid: boolean,
|
|
104
|
+
static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, app: AppClassProperties, snapToGrid: boolean, scene: Scene): {
|
|
116
105
|
pointerDownState: LinearElementEditor["pointerDownState"];
|
|
117
106
|
selectedPointsIndices: LinearElementEditor["selectedPointsIndices"];
|
|
118
107
|
} | undefined;
|
|
@@ -124,7 +113,6 @@ export declare class LinearElementEditor {
|
|
|
124
113
|
};
|
|
125
114
|
static getMinMaxXYWithBoundText: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, elementBounds: Bounds, boundTextElement: ExcalidrawTextElementWithContainer) => [number, number, number, number, number, number];
|
|
126
115
|
static getElementAbsoluteCoords: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
|
|
127
|
-
static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number,
|
|
128
|
-
static deleteFixedSegment(element: ExcalidrawElbowArrowElement, index: number): void;
|
|
116
|
+
static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number, scene: Scene): LinearElementEditor;
|
|
117
|
+
static deleteFixedSegment(element: ExcalidrawElbowArrowElement, scene: Scene, index: number): void;
|
|
129
118
|
}
|
|
130
|
-
export {};
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { Mutable } from "@excalidraw/common/utility-types";
|
|
2
|
-
import type { ExcalidrawElement } from "./types";
|
|
2
|
+
import type { ElementsMap, ExcalidrawElement } from "./types";
|
|
3
3
|
export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce" | "updated">;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This function tracks updates of text elements for the purposes for collaboration.
|
|
6
|
+
* The version is used to compare updates when more than one user is working in
|
|
7
|
+
* the same drawing.
|
|
8
|
+
*
|
|
9
|
+
* WARNING: this won't trigger the component to update, so if you need to trigger component update,
|
|
10
|
+
* use `scene.mutateElement` or `ExcalidrawImperativeAPI.mutateElement` instead.
|
|
11
|
+
*/
|
|
12
|
+
export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, elementsMap: ElementsMap, updates: ElementUpdate<TElement>, options?: {
|
|
5
13
|
isDragging?: boolean;
|
|
6
14
|
}) => TElement;
|
|
7
15
|
export declare const newElementWith: <TElement extends ExcalidrawElement>(element: TElement, updates: ElementUpdate<TElement>, force?: boolean) => TElement;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MarkOptional } from "@excalidraw/common/utility-types";
|
|
2
|
-
import type { ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement,
|
|
2
|
+
import type { ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, ExcalidrawLineElement } from "./types";
|
|
3
3
|
export type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "index" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity" | "customData">;
|
|
4
4
|
export declare const newElement: (opts: {
|
|
5
5
|
type: ExcalidrawGenericElement["type"];
|
|
@@ -43,6 +43,7 @@ export declare const newFreeDrawElement: (opts: {
|
|
|
43
43
|
export declare const newLinearElement: (opts: {
|
|
44
44
|
type: ExcalidrawLinearElement["type"];
|
|
45
45
|
points?: ExcalidrawLinearElement["points"];
|
|
46
|
+
polygon?: ExcalidrawLineElement["polygon"];
|
|
46
47
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawLinearElement>;
|
|
47
48
|
export declare const newArrowElement: <T extends boolean>(opts: {
|
|
48
49
|
type: ExcalidrawArrowElement["type"];
|
|
@@ -50,8 +51,8 @@ export declare const newArrowElement: <T extends boolean>(opts: {
|
|
|
50
51
|
endArrowhead?: Arrowhead | null | undefined;
|
|
51
52
|
points?: readonly import("@excalidraw/math").LocalPoint[] | undefined;
|
|
52
53
|
elbowed?: T | undefined;
|
|
53
|
-
fixedSegments?: FixedSegment[] | null | undefined;
|
|
54
|
-
} & Omit<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "
|
|
54
|
+
fixedSegments?: readonly import("./types").FixedSegment[] | null | undefined;
|
|
55
|
+
} & Omit<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "link" | "strokeColor" | "backgroundColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "width" | "height" | "angle" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData"> & Partial<Pick<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "link" | "strokeColor" | "backgroundColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "width" | "height" | "angle" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData">>) => T extends true ? NonDeleted<ExcalidrawElbowArrowElement> : NonDeleted<ExcalidrawArrowElement>;
|
|
55
56
|
export declare const newImageElement: (opts: {
|
|
56
57
|
type: ExcalidrawImageElement["type"];
|
|
57
58
|
status?: ExcalidrawImageElement["status"];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type LocalPoint } from "@excalidraw/math";
|
|
2
|
-
import type Scene from "@excalidraw/excalidraw/scene/Scene";
|
|
3
2
|
import type { PointerDownState } from "@excalidraw/excalidraw/types";
|
|
3
|
+
import type { Scene } from "./Scene";
|
|
4
4
|
import type { BoundingBox } from "./bounds";
|
|
5
5
|
import type { MaybeTransformHandleType, TransformHandleDirection } from "./transformHandles";
|
|
6
|
-
import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawElement, ElementsMap
|
|
7
|
-
export declare const transformElements: (originalElements: PointerDownState["originalElements"], transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[],
|
|
6
|
+
import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawElement, ElementsMap } from "./types";
|
|
7
|
+
export declare const transformElements: (originalElements: PointerDownState["originalElements"], transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], scene: Scene, shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
|
|
8
8
|
export declare const rescalePointsInElement: (element: NonDeletedExcalidrawElement, width: number, height: number, normalizePoints: boolean) => {
|
|
9
9
|
points: LocalPoint[];
|
|
10
10
|
} | {
|
|
@@ -15,7 +15,7 @@ export declare const measureFontSizeFromWidth: (element: NonDeleted<ExcalidrawTe
|
|
|
15
15
|
} | null;
|
|
16
16
|
export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, x: number, y: number) => [number, number];
|
|
17
17
|
export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
|
|
18
|
-
export declare const resizeSingleElement: (nextWidth: number, nextHeight: number, latestElement: ExcalidrawElement, origElement: ExcalidrawElement,
|
|
18
|
+
export declare const resizeSingleElement: (nextWidth: number, nextHeight: number, latestElement: ExcalidrawElement, origElement: ExcalidrawElement, originalElementsMap: ElementsMap, scene: Scene, handleDirection: TransformHandleDirection, { shouldInformMutation, shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
|
|
19
19
|
shouldMaintainAspectRatio?: boolean | undefined;
|
|
20
20
|
shouldResizeFromCenter?: boolean | undefined;
|
|
21
21
|
shouldInformMutation?: boolean | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AppState, InteractiveCanvasAppState } from "@excalidraw/excalidraw/types";
|
|
2
|
+
import { LinearElementEditor } from "./linearElementEditor";
|
|
2
3
|
import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, NonDeletedExcalidrawElement } from "./types";
|
|
3
4
|
/**
|
|
4
5
|
* Frames and their containing elements are not to be selected at the same time.
|
|
@@ -13,11 +14,6 @@ export declare const isSomeElementSelected: {
|
|
|
13
14
|
(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">): boolean;
|
|
14
15
|
clearCache(): void;
|
|
15
16
|
};
|
|
16
|
-
/**
|
|
17
|
-
* Returns common attribute (picked by `getAttribute` callback) of selected
|
|
18
|
-
* elements. If elements don't share the same value, returns `null`.
|
|
19
|
-
*/
|
|
20
|
-
export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, getAttribute: (element: ExcalidrawElement) => T) => T | null;
|
|
21
17
|
export declare const getSelectedElements: (elements: ElementsMapOrArray, appState: Pick<InteractiveCanvasAppState, "selectedElementIds">, opts?: {
|
|
22
18
|
includeBoundTextElement?: boolean;
|
|
23
19
|
includeElementsInFrames?: boolean;
|
|
@@ -30,3 +26,13 @@ export declare const getTargetElements: (elements: ElementsMapOrArray, appState:
|
|
|
30
26
|
export declare const makeNextSelectedElementIds: (nextSelectedElementIds: AppState["selectedElementIds"], prevState: Pick<AppState, "selectedElementIds">) => Readonly<{
|
|
31
27
|
[id: string]: true;
|
|
32
28
|
}>;
|
|
29
|
+
export declare const getSelectionStateForElements: (targetElements: readonly ExcalidrawElement[], allElements: readonly NonDeletedExcalidrawElement[], appState: AppState) => {
|
|
30
|
+
selectedElementIds: Readonly<{
|
|
31
|
+
[id: string]: true;
|
|
32
|
+
}>;
|
|
33
|
+
selectedGroupIds: {
|
|
34
|
+
[groupId: string]: boolean;
|
|
35
|
+
};
|
|
36
|
+
editingGroupId: string | null;
|
|
37
|
+
selectedLinearElement: LinearElementEditor | null;
|
|
38
|
+
};
|
|
@@ -2,7 +2,7 @@ import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
|
|
|
2
2
|
import { type GeometricShape } from "@excalidraw/utils/shape";
|
|
3
3
|
import type { Zoom } from "@excalidraw/excalidraw/types";
|
|
4
4
|
import { type Bounds } from "./bounds";
|
|
5
|
-
import type { ElementsMap, ExcalidrawElement, ExcalidrawLinearElement, NonDeleted } from "./types";
|
|
5
|
+
import type { ElementsMap, ExcalidrawElement, ExcalidrawLinearElement, ExcalidrawLineElement, NonDeleted } from "./types";
|
|
6
6
|
/**
|
|
7
7
|
* get the pure geometric shape of an excalidraw elementw
|
|
8
8
|
* which is then used for hit detection
|
|
@@ -21,3 +21,7 @@ export declare const pointInsideBounds: <P extends GlobalPoint | LocalPoint>(p:
|
|
|
21
21
|
export declare const aabbsOverlapping: (a: Bounds, b: Bounds) => boolean;
|
|
22
22
|
export declare const getCornerRadius: (x: number, element: ExcalidrawElement) => number;
|
|
23
23
|
export declare const isPathALoop: (points: ExcalidrawLinearElement["points"], zoomValue?: Zoom["value"]) => boolean;
|
|
24
|
+
export declare const toggleLinePolygonState: (element: ExcalidrawLineElement, nextPolygonState: boolean) => {
|
|
25
|
+
polygon: ExcalidrawLineElement["polygon"];
|
|
26
|
+
points: ExcalidrawLineElement["points"];
|
|
27
|
+
} | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AppState, Offsets, Zoom } from "@excalidraw/excalidraw/types";
|
|
2
2
|
import type { ElementsMap, ExcalidrawElement } from "./types";
|
|
3
|
+
export declare const INVISIBLY_SMALL_ELEMENT_SIZE = 0.1;
|
|
3
4
|
export declare const isInvisiblySmallElement: (element: ExcalidrawElement) => boolean;
|
|
4
5
|
export declare const isElementInViewport: (element: ExcalidrawElement, width: number, height: number, viewTransformations: {
|
|
5
6
|
zoom: Zoom;
|
|
@@ -26,7 +27,6 @@ export declare const getLockedLinearCursorAlignSize: (originX: number, originY:
|
|
|
26
27
|
width: number;
|
|
27
28
|
height: number;
|
|
28
29
|
};
|
|
29
|
-
export declare const resizePerfectLineForNWHandler: (element: ExcalidrawElement, x: number, y: number) => void;
|
|
30
30
|
export declare const getNormalizedDimensions: (element: Pick<ExcalidrawElement, "width" | "height" | "x" | "y">) => {
|
|
31
31
|
width: ExcalidrawElement["width"];
|
|
32
32
|
height: ExcalidrawElement["height"];
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { Emitter } from "@excalidraw/common";
|
|
2
|
+
import type App from "@excalidraw/excalidraw/components/App";
|
|
3
|
+
import type { DTO, ValueOf } from "@excalidraw/common/utility-types";
|
|
4
|
+
import type { AppState, ObservedAppState } from "@excalidraw/excalidraw/types";
|
|
5
|
+
import { ElementsDelta, AppStateDelta } from "./delta";
|
|
6
|
+
import type { OrderedExcalidrawElement, SceneElementsMap } from "./types";
|
|
7
|
+
export declare const CaptureUpdateAction: {
|
|
8
|
+
/**
|
|
9
|
+
* Immediately undoable.
|
|
10
|
+
*
|
|
11
|
+
* Use for updates which should be captured.
|
|
12
|
+
* Should be used for most of the local updates, except ephemerals such as dragging or resizing.
|
|
13
|
+
*
|
|
14
|
+
* These updates will _immediately_ make it to the local undo / redo stacks.
|
|
15
|
+
*/
|
|
16
|
+
readonly IMMEDIATELY: "IMMEDIATELY";
|
|
17
|
+
/**
|
|
18
|
+
* Never undoable.
|
|
19
|
+
*
|
|
20
|
+
* Use for updates which should never be recorded, such as remote updates
|
|
21
|
+
* or scene initialization.
|
|
22
|
+
*
|
|
23
|
+
* These updates will _never_ make it to the local undo / redo stacks.
|
|
24
|
+
*/
|
|
25
|
+
readonly NEVER: "NEVER";
|
|
26
|
+
/**
|
|
27
|
+
* Eventually undoable.
|
|
28
|
+
*
|
|
29
|
+
* Use for updates which should not be captured immediately - likely
|
|
30
|
+
* exceptions which are part of some async multi-step process. Otherwise, all
|
|
31
|
+
* such updates would end up being captured with the next
|
|
32
|
+
* `CaptureUpdateAction.IMMEDIATELY` - triggered either by the next `updateScene`
|
|
33
|
+
* or internally by the editor.
|
|
34
|
+
*
|
|
35
|
+
* These updates will _eventually_ make it to the local undo / redo stacks.
|
|
36
|
+
*/
|
|
37
|
+
readonly EVENTUALLY: "EVENTUALLY";
|
|
38
|
+
};
|
|
39
|
+
export type CaptureUpdateActionType = ValueOf<typeof CaptureUpdateAction>;
|
|
40
|
+
/**
|
|
41
|
+
* Store which captures the observed changes and emits them as `StoreIncrement` events.
|
|
42
|
+
*/
|
|
43
|
+
export declare class Store {
|
|
44
|
+
private readonly app;
|
|
45
|
+
readonly onDurableIncrementEmitter: Emitter<[DurableIncrement]>;
|
|
46
|
+
readonly onStoreIncrementEmitter: Emitter<[DurableIncrement | EphemeralIncrement]>;
|
|
47
|
+
private scheduledMacroActions;
|
|
48
|
+
private scheduledMicroActions;
|
|
49
|
+
private _snapshot;
|
|
50
|
+
get snapshot(): StoreSnapshot;
|
|
51
|
+
set snapshot(snapshot: StoreSnapshot);
|
|
52
|
+
constructor(app: App);
|
|
53
|
+
scheduleAction(action: CaptureUpdateActionType): void;
|
|
54
|
+
/**
|
|
55
|
+
* Use to schedule a delta calculation, which will consquentially be emitted as `DurableStoreIncrement` and pushed in the undo stack.
|
|
56
|
+
*/
|
|
57
|
+
scheduleCapture(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Schedule special "micro" actions, to-be executed before the next commit, before it executes a scheduled "macro" action.
|
|
60
|
+
*/
|
|
61
|
+
scheduleMicroAction(params: {
|
|
62
|
+
action: CaptureUpdateActionType;
|
|
63
|
+
elements: SceneElementsMap | undefined;
|
|
64
|
+
appState: AppState | ObservedAppState | undefined;
|
|
65
|
+
} | {
|
|
66
|
+
action: typeof CaptureUpdateAction.IMMEDIATELY;
|
|
67
|
+
change: StoreChange;
|
|
68
|
+
delta: StoreDelta;
|
|
69
|
+
} | {
|
|
70
|
+
action: typeof CaptureUpdateAction.NEVER | typeof CaptureUpdateAction.EVENTUALLY;
|
|
71
|
+
change: StoreChange;
|
|
72
|
+
}): void;
|
|
73
|
+
/**
|
|
74
|
+
* Performs the incoming `CaptureUpdateAction` and emits the corresponding `StoreIncrement`.
|
|
75
|
+
* Emits `DurableStoreIncrement` when action is "capture", emits `EphemeralStoreIncrement` otherwise.
|
|
76
|
+
*
|
|
77
|
+
* @emits StoreIncrement
|
|
78
|
+
*/
|
|
79
|
+
commit(elements: SceneElementsMap | undefined, appState: AppState | ObservedAppState | undefined): void;
|
|
80
|
+
/**
|
|
81
|
+
* Clears the store instance.
|
|
82
|
+
*/
|
|
83
|
+
clear(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Performs delta & change calculation and emits a durable increment.
|
|
86
|
+
*
|
|
87
|
+
* @emits StoreIncrement.
|
|
88
|
+
*/
|
|
89
|
+
private emitDurableIncrement;
|
|
90
|
+
/**
|
|
91
|
+
* Performs change calculation and emits an ephemeral increment.
|
|
92
|
+
*
|
|
93
|
+
* @emits EphemeralStoreIncrement
|
|
94
|
+
*/
|
|
95
|
+
private emitEphemeralIncrement;
|
|
96
|
+
private applyChangeToSnapshot;
|
|
97
|
+
/**
|
|
98
|
+
* Clones the snapshot if there are changes detected.
|
|
99
|
+
*/
|
|
100
|
+
private maybeCloneSnapshot;
|
|
101
|
+
private flushMicroActions;
|
|
102
|
+
private processAction;
|
|
103
|
+
/**
|
|
104
|
+
* Returns the scheduled macro action.
|
|
105
|
+
*/
|
|
106
|
+
private getScheduledMacroAction;
|
|
107
|
+
/**
|
|
108
|
+
* Ensures that the scheduled actions invariant is satisfied.
|
|
109
|
+
*/
|
|
110
|
+
private satisfiesScheduledActionsInvariant;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Repsents a change to the store containing changed elements and appState.
|
|
114
|
+
*/
|
|
115
|
+
export declare class StoreChange {
|
|
116
|
+
readonly elements: Record<string, OrderedExcalidrawElement>;
|
|
117
|
+
readonly appState: Partial<ObservedAppState>;
|
|
118
|
+
private constructor();
|
|
119
|
+
static create(prevSnapshot: StoreSnapshot, nextSnapshot: StoreSnapshot): StoreChange;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Encpasulates any change to the store (durable or ephemeral).
|
|
123
|
+
*/
|
|
124
|
+
export declare abstract class StoreIncrement {
|
|
125
|
+
readonly type: "durable" | "ephemeral";
|
|
126
|
+
readonly change: StoreChange;
|
|
127
|
+
protected constructor(type: "durable" | "ephemeral", change: StoreChange);
|
|
128
|
+
static isDurable(increment: StoreIncrement): increment is DurableIncrement;
|
|
129
|
+
static isEphemeral(increment: StoreIncrement): increment is EphemeralIncrement;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Represents a durable change to the store.
|
|
133
|
+
*/
|
|
134
|
+
export declare class DurableIncrement extends StoreIncrement {
|
|
135
|
+
readonly change: StoreChange;
|
|
136
|
+
readonly delta: StoreDelta;
|
|
137
|
+
constructor(change: StoreChange, delta: StoreDelta);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Represents an ephemeral change to the store.
|
|
141
|
+
*/
|
|
142
|
+
export declare class EphemeralIncrement extends StoreIncrement {
|
|
143
|
+
readonly change: StoreChange;
|
|
144
|
+
constructor(change: StoreChange);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Represents a captured delta by the Store.
|
|
148
|
+
*/
|
|
149
|
+
export declare class StoreDelta {
|
|
150
|
+
readonly id: string;
|
|
151
|
+
readonly elements: ElementsDelta;
|
|
152
|
+
readonly appState: AppStateDelta;
|
|
153
|
+
protected constructor(id: string, elements: ElementsDelta, appState: AppStateDelta);
|
|
154
|
+
/**
|
|
155
|
+
* Create a new instance of `StoreDelta`.
|
|
156
|
+
*/
|
|
157
|
+
static create(elements: ElementsDelta, appState: AppStateDelta, opts?: {
|
|
158
|
+
id: string;
|
|
159
|
+
}): StoreDelta;
|
|
160
|
+
/**
|
|
161
|
+
* Restore a store delta instance from a DTO.
|
|
162
|
+
*/
|
|
163
|
+
static restore(storeDeltaDTO: DTO<StoreDelta>): StoreDelta;
|
|
164
|
+
/**
|
|
165
|
+
* Parse and load the delta from the remote payload.
|
|
166
|
+
*/
|
|
167
|
+
static load({ id, elements: { added, removed, updated }, }: DTO<StoreDelta>): StoreDelta;
|
|
168
|
+
/**
|
|
169
|
+
* Inverse store delta, creates new instance of `StoreDelta`.
|
|
170
|
+
*/
|
|
171
|
+
static inverse(delta: StoreDelta): StoreDelta;
|
|
172
|
+
/**
|
|
173
|
+
* Apply latest (remote) changes to the delta, creates new instance of `StoreDelta`.
|
|
174
|
+
*/
|
|
175
|
+
static applyLatestChanges(delta: StoreDelta, elements: SceneElementsMap, modifierOptions: "deleted" | "inserted"): StoreDelta;
|
|
176
|
+
/**
|
|
177
|
+
* Apply the delta to the passed elements and appState, does not modify the snapshot.
|
|
178
|
+
*/
|
|
179
|
+
static applyTo(delta: StoreDelta, elements: SceneElementsMap, appState: AppState, prevSnapshot?: StoreSnapshot): [SceneElementsMap, AppState, boolean];
|
|
180
|
+
isEmpty(): boolean;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Represents a snapshot of the captured or updated changes in the store,
|
|
184
|
+
* used for producing deltas and emitting `DurableStoreIncrement`s.
|
|
185
|
+
*/
|
|
186
|
+
export declare class StoreSnapshot {
|
|
187
|
+
readonly elements: SceneElementsMap;
|
|
188
|
+
readonly appState: ObservedAppState;
|
|
189
|
+
readonly metadata: {
|
|
190
|
+
didElementsChange: boolean;
|
|
191
|
+
didAppStateChange: boolean;
|
|
192
|
+
isEmpty?: boolean;
|
|
193
|
+
};
|
|
194
|
+
private _lastChangedElementsHash;
|
|
195
|
+
private _lastChangedAppStateHash;
|
|
196
|
+
private constructor();
|
|
197
|
+
static create(elements: SceneElementsMap, appState: AppState | ObservedAppState, metadata?: {
|
|
198
|
+
didElementsChange: boolean;
|
|
199
|
+
didAppStateChange: boolean;
|
|
200
|
+
}): StoreSnapshot;
|
|
201
|
+
static empty(): StoreSnapshot;
|
|
202
|
+
getChangedElements(prevSnapshot: StoreSnapshot): Record<string, OrderedExcalidrawElement>;
|
|
203
|
+
getChangedAppState(prevSnapshot: StoreSnapshot): Partial<ObservedAppState>;
|
|
204
|
+
isEmpty(): boolean | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* Apply the change and return a new snapshot instance.
|
|
207
|
+
*/
|
|
208
|
+
applyChange(change: StoreChange): StoreSnapshot;
|
|
209
|
+
/**
|
|
210
|
+
* Efficiently clone the existing snapshot, only if we detected changes.
|
|
211
|
+
*
|
|
212
|
+
* @returns same instance if there are no changes detected, new instance otherwise.
|
|
213
|
+
*/
|
|
214
|
+
maybeClone(action: CaptureUpdateActionType, elements: SceneElementsMap | undefined, appState: AppState | ObservedAppState | undefined): StoreSnapshot;
|
|
215
|
+
private maybeCreateAppStateSnapshot;
|
|
216
|
+
private maybeCreateElementsSnapshot;
|
|
217
|
+
private detectChangedAppState;
|
|
218
|
+
/**
|
|
219
|
+
* Detect if there any changed elements.
|
|
220
|
+
*/
|
|
221
|
+
private detectChangedElements;
|
|
222
|
+
/**
|
|
223
|
+
* Perform structural clone, deep cloning only elements that changed.
|
|
224
|
+
*/
|
|
225
|
+
private createElementsSnapshot;
|
|
226
|
+
}
|
|
227
|
+
export declare const getObservedAppState: (appState: AppState) => ObservedAppState;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { AppState } from "@excalidraw/excalidraw/types";
|
|
2
2
|
import type { ExtractSetType } from "@excalidraw/common/utility-types";
|
|
3
|
+
import type { Radians } from "@excalidraw/math";
|
|
4
|
+
import type { Scene } from "./Scene";
|
|
3
5
|
import type { MaybeTransformHandleType } from "./transformHandles";
|
|
4
6
|
import type { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, NonDeletedExcalidrawElement } from "./types";
|
|
5
|
-
export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null,
|
|
6
|
-
export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement,
|
|
7
|
+
export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, scene: Scene) => void;
|
|
8
|
+
export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, scene: Scene, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean) => void;
|
|
7
9
|
export declare const computeBoundTextPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
|
|
8
10
|
x: number;
|
|
9
11
|
y: number;
|
|
@@ -19,7 +21,7 @@ export declare const getContainerCoords: (container: NonDeletedExcalidrawElement
|
|
|
19
21
|
x: number;
|
|
20
22
|
y: number;
|
|
21
23
|
};
|
|
22
|
-
export declare const getTextElementAngle: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null) =>
|
|
24
|
+
export declare const getTextElementAngle: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null) => 0 | Radians;
|
|
23
25
|
export declare const getBoundTextElementPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
|
|
24
26
|
x: number;
|
|
25
27
|
y: number;
|
|
@@ -32,9 +32,9 @@ export declare const canResizeFromSides: (device: Device) => boolean;
|
|
|
32
32
|
export declare const getOmitSidesForDevice: (device: Device) => {};
|
|
33
33
|
export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [number, number, number, number, number, number], angle: Radians, zoom: Zoom, pointerType: PointerType, omitSides?: {
|
|
34
34
|
s?: boolean | undefined;
|
|
35
|
-
n?: boolean | undefined;
|
|
36
|
-
w?: boolean | undefined;
|
|
37
35
|
e?: boolean | undefined;
|
|
36
|
+
w?: boolean | undefined;
|
|
37
|
+
n?: boolean | undefined;
|
|
38
38
|
nw?: boolean | undefined;
|
|
39
39
|
ne?: boolean | undefined;
|
|
40
40
|
sw?: boolean | undefined;
|
|
@@ -43,9 +43,9 @@ export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [
|
|
|
43
43
|
}, margin?: number, spacing?: number) => TransformHandles;
|
|
44
44
|
export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoom, elementsMap: ElementsMap, pointerType?: PointerType, omitSides?: {
|
|
45
45
|
s?: boolean | undefined;
|
|
46
|
-
n?: boolean | undefined;
|
|
47
|
-
w?: boolean | undefined;
|
|
48
46
|
e?: boolean | undefined;
|
|
47
|
+
w?: boolean | undefined;
|
|
48
|
+
n?: boolean | undefined;
|
|
49
49
|
nw?: boolean | undefined;
|
|
50
50
|
ne?: boolean | undefined;
|
|
51
51
|
sw?: boolean | undefined;
|