@zsviczian/excalidraw 0.17.1-obsidian-20 → 0.17.1-obsidian-21
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/dist/excalidraw.development.js +190 -80
- package/dist/excalidraw.production.min.js +1 -1
- package/dist/styles.development.css +78 -50
- package/dist/styles.production.css +5 -5
- package/package.json +2 -1
- package/types/excalidraw/actions/actionAddToLibrary.d.ts +4 -4
- package/types/excalidraw/actions/actionAlign.d.ts +20 -20
- package/types/excalidraw/actions/actionBoundText.d.ts +7 -7
- package/types/excalidraw/actions/actionCanvas.d.ts +65 -65
- package/types/excalidraw/actions/actionClipboard.d.ts +24 -24
- package/types/excalidraw/actions/actionDeleteSelected.d.ts +8 -8
- package/types/excalidraw/actions/actionDistribute.d.ts +8 -8
- package/types/excalidraw/actions/actionDuplicateSelection.d.ts +5 -6
- package/types/excalidraw/actions/actionElementLock.d.ts +8 -8
- package/types/excalidraw/actions/actionExport.d.ts +32 -32
- package/types/excalidraw/actions/actionFinalize.d.ts +8 -8
- package/types/excalidraw/actions/actionFlip.d.ts +9 -9
- package/types/excalidraw/actions/actionFrame.d.ts +14 -202
- package/types/excalidraw/actions/actionGroup.d.ts +11 -387
- package/types/excalidraw/actions/actionHistory.d.ts +3 -2
- package/types/excalidraw/actions/actionLinearEditor.d.ts +2 -2
- package/types/excalidraw/actions/actionLink.d.ts +5 -5
- package/types/excalidraw/actions/actionMenu.d.ts +8 -8
- package/types/excalidraw/actions/actionNavigate.d.ts +3 -3
- package/types/excalidraw/actions/actionProperties.d.ts +32 -32
- package/types/excalidraw/actions/actionSelectAll.d.ts +4 -4
- package/types/excalidraw/actions/actionStyles.d.ts +9 -12
- package/types/excalidraw/actions/actionToggleGridMode.d.ts +6 -4
- package/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +4 -4
- package/types/excalidraw/actions/actionToggleStats.d.ts +4 -4
- package/types/excalidraw/actions/actionToggleViewMode.d.ts +4 -4
- package/types/excalidraw/actions/actionToggleZenMode.d.ts +4 -4
- package/types/excalidraw/actions/actionZindex.d.ts +18 -19
- package/types/excalidraw/actions/manager.d.ts +3 -3
- package/types/excalidraw/actions/types.d.ts +4 -4
- package/types/excalidraw/appState.d.ts +4 -4
- package/types/excalidraw/change.d.ts +191 -0
- package/types/excalidraw/components/App.d.ts +22 -8
- package/types/excalidraw/components/RadioGroup.d.ts +2 -1
- package/types/excalidraw/components/ToolButton.d.ts +1 -0
- package/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -1
- package/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +17 -0
- package/types/excalidraw/components/icons.d.ts +4 -0
- package/types/excalidraw/components/main-menu/DefaultItems.d.ts +12 -2
- package/types/excalidraw/constants.d.ts +3 -0
- package/types/excalidraw/data/reconcile.d.ts +6 -0
- package/types/excalidraw/data/restore.d.ts +3 -3
- package/types/excalidraw/data/transform.d.ts +1 -1
- package/types/excalidraw/data/url.d.ts +1 -0
- package/types/excalidraw/element/binding.d.ts +52 -9
- package/types/excalidraw/element/bounds.d.ts +0 -1
- package/types/excalidraw/element/collision.d.ts +14 -19
- package/types/excalidraw/element/embeddable.d.ts +7 -4
- package/types/excalidraw/element/index.d.ts +0 -1
- package/types/excalidraw/element/linearElementEditor.d.ts +12 -12
- package/types/excalidraw/element/mutateElement.d.ts +1 -2
- package/types/excalidraw/element/newElement.d.ts +1 -1
- package/types/excalidraw/element/resizeElements.d.ts +1 -1
- package/types/excalidraw/element/resizeTest.d.ts +4 -4
- package/types/excalidraw/element/textElement.d.ts +1 -2
- package/types/excalidraw/element/transformHandles.d.ts +22 -4
- package/types/excalidraw/element/typeChecks.d.ts +2 -2
- package/types/excalidraw/element/types.d.ts +22 -6
- package/types/excalidraw/errors.d.ts +3 -0
- package/types/excalidraw/fractionalIndex.d.ts +40 -0
- package/types/excalidraw/frame.d.ts +1 -1
- package/types/excalidraw/groups.d.ts +2 -0
- package/types/excalidraw/history.d.ts +34 -46
- package/types/excalidraw/hooks/useEmitter.d.ts +2 -0
- package/types/excalidraw/index.d.ts +2 -0
- package/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
- package/types/excalidraw/scene/Scene.d.ts +7 -6
- package/types/excalidraw/scene/types.d.ts +2 -1
- package/types/excalidraw/store.d.ts +99 -0
- package/types/excalidraw/types.d.ts +18 -4
- package/types/excalidraw/utils.d.ts +7 -0
- package/types/excalidraw/webpack.prod.config.d.ts +1 -1
- package/types/excalidraw/zindex.d.ts +2 -2
- package/types/utils/collision.d.ts +4 -0
- package/types/utils/export.d.ts +2 -2
- package/types/utils/geometry/geometry.d.ts +71 -0
- package/types/utils/geometry/shape.d.ts +56 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AppState } from "../types";
|
|
3
|
-
import
|
|
1
|
+
import { ExcalidrawBindableElement, ExcalidrawElement, NonDeleted, ExcalidrawLinearElement, NonDeletedExcalidrawElement, ElementsMap, NonDeletedSceneElementsMap } from "./types";
|
|
2
|
+
import { AppClassProperties, AppState, Point } from "../types";
|
|
3
|
+
import { ElementUpdate } from "./mutateElement";
|
|
4
4
|
export type SuggestedBinding = NonDeleted<ExcalidrawBindableElement> | SuggestedPointBinding;
|
|
5
5
|
export type SuggestedPointBinding = [
|
|
6
6
|
NonDeleted<ExcalidrawLinearElement>,
|
|
@@ -10,18 +10,18 @@ export type SuggestedPointBinding = [
|
|
|
10
10
|
export declare const shouldEnableBindingForPointerEvent: (event: React.PointerEvent<HTMLElement>) => boolean;
|
|
11
11
|
export declare const isBindingEnabled: (appState: AppState) => boolean;
|
|
12
12
|
export declare const bindOrUnbindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, startBindingElement: ExcalidrawBindableElement | null | "keep", endBindingElement: ExcalidrawBindableElement | null | "keep", elementsMap: NonDeletedSceneElementsMap) => void;
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
13
|
+
export declare const bindOrUnbindLinearElements: (selectedElements: NonDeleted<ExcalidrawLinearElement>[], app: AppClassProperties, isBindingEnabled: boolean, draggingPoints: readonly number[] | null) => void;
|
|
14
|
+
export declare const getSuggestedBindingsForArrows: (selectedElements: NonDeleted<ExcalidrawElement>[], app: AppClassProperties) => SuggestedBinding[];
|
|
15
|
+
export declare const maybeBindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, appState: AppState, pointerCoords: {
|
|
15
16
|
x: number;
|
|
16
17
|
y: number;
|
|
17
|
-
},
|
|
18
|
+
}, app: AppClassProperties) => void;
|
|
18
19
|
export declare const bindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: NonDeletedSceneElementsMap) => void;
|
|
19
20
|
export declare const isLinearElementSimpleAndAlreadyBound: (linearElement: NonDeleted<ExcalidrawLinearElement>, alreadyBoundToId: ExcalidrawBindableElement["id"] | undefined, bindableElement: ExcalidrawBindableElement) => boolean;
|
|
20
|
-
export declare const unbindLinearElements: (elements: NonDeleted<ExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap) => void;
|
|
21
21
|
export declare const getHoveredElementForBinding: (pointerCoords: {
|
|
22
22
|
x: number;
|
|
23
23
|
y: number;
|
|
24
|
-
},
|
|
24
|
+
}, app: AppClassProperties) => NonDeleted<ExcalidrawBindableElement> | null;
|
|
25
25
|
export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement, elementsMap: ElementsMap, options?: {
|
|
26
26
|
simultaneouslyUpdated?: readonly ExcalidrawElement[];
|
|
27
27
|
newSize?: {
|
|
@@ -29,6 +29,49 @@ export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawE
|
|
|
29
29
|
height: number;
|
|
30
30
|
};
|
|
31
31
|
}) => void;
|
|
32
|
-
export declare const getEligibleElementsForBinding: (selectedElements: NonDeleted<ExcalidrawElement>[], elements: readonly ExcalidrawElement[], elementsMap: NonDeletedSceneElementsMap) => SuggestedBinding[];
|
|
33
32
|
export declare const fixBindingsAfterDuplication: (sceneElements: readonly ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicatesServeAsOld?: "duplicatesServeAsOld" | undefined) => void;
|
|
34
33
|
export declare const fixBindingsAfterDeletion: (sceneElements: readonly ExcalidrawElement[], deletedElements: readonly ExcalidrawElement[]) => void;
|
|
34
|
+
export declare const maxBindingGap: (element: ExcalidrawElement, elementWidth: number, elementHeight: number) => number;
|
|
35
|
+
export declare const determineFocusDistance: (element: ExcalidrawBindableElement, a: readonly [number, number], b: readonly [number, number], elementsMap: ElementsMap) => number;
|
|
36
|
+
export declare const intersectElementWithLine: (element: ExcalidrawBindableElement, a: readonly [number, number], b: readonly [number, number], gap: number | undefined, elementsMap: ElementsMap) => Point[];
|
|
37
|
+
export declare const bindingProperties: Set<BindableProp | BindingProp>;
|
|
38
|
+
export type BindableProp = "boundElements";
|
|
39
|
+
export type BindingProp = "frameId" | "containerId" | "startBinding" | "endBinding";
|
|
40
|
+
/**
|
|
41
|
+
* Bound element containing bindings to `frameId`, `containerId`, `startBinding` or `endBinding`.
|
|
42
|
+
*/
|
|
43
|
+
export declare class BoundElement {
|
|
44
|
+
/**
|
|
45
|
+
* Unbind the affected non deleted bindable elements (removing element from `boundElements`).
|
|
46
|
+
* - iterates non deleted bindable elements (`containerId` | `startBinding.elementId` | `endBinding.elementId`) of the current element
|
|
47
|
+
* - prepares updates to unbind each bindable element's `boundElements` from the current element
|
|
48
|
+
*/
|
|
49
|
+
static unbindAffected(elements: ElementsMap, boundElement: ExcalidrawElement | undefined, updateElementWith: (affected: ExcalidrawElement, updates: ElementUpdate<ExcalidrawElement>) => void): void;
|
|
50
|
+
/**
|
|
51
|
+
* Rebind the next affected non deleted bindable elements (adding element to `boundElements`).
|
|
52
|
+
* - iterates non deleted bindable elements (`containerId` | `startBinding.elementId` | `endBinding.elementId`) of the current element
|
|
53
|
+
* - prepares updates to rebind each bindable element's `boundElements` to the current element
|
|
54
|
+
*
|
|
55
|
+
* NOTE: rebind expects that affected elements were previously unbound with `BoundElement.unbindAffected`
|
|
56
|
+
*/
|
|
57
|
+
static rebindAffected: (elements: ElementsMap, boundElement: ExcalidrawElement | undefined, updateElementWith: (affected: ExcalidrawElement, updates: ElementUpdate<ExcalidrawElement>) => void) => void;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Bindable element containing bindings to `boundElements`.
|
|
61
|
+
*/
|
|
62
|
+
export declare class BindableElement {
|
|
63
|
+
/**
|
|
64
|
+
* Unbind the affected non deleted bound elements (resetting `containerId`, `startBinding`, `endBinding` to `null`).
|
|
65
|
+
* - iterates through non deleted `boundElements` of the current element
|
|
66
|
+
* - prepares updates to unbind each bound element from the current element
|
|
67
|
+
*/
|
|
68
|
+
static unbindAffected(elements: ElementsMap, bindableElement: ExcalidrawElement | undefined, updateElementWith: (affected: ExcalidrawElement, updates: ElementUpdate<ExcalidrawElement>) => void): void;
|
|
69
|
+
/**
|
|
70
|
+
* Rebind the affected non deleted bound elements (for now setting only `containerId`, as we cannot rebind arrows atm).
|
|
71
|
+
* - iterates through non deleted `boundElements` of the current element
|
|
72
|
+
* - prepares updates to rebind each bound element to the current element or unbind it from `boundElements` in case of conflicts
|
|
73
|
+
*
|
|
74
|
+
* NOTE: rebind expects that affected elements were previously unbound with `BindaleElement.unbindAffected`
|
|
75
|
+
*/
|
|
76
|
+
static rebindAffected: (elements: ElementsMap, bindableElement: ExcalidrawElement | undefined, updateElementWith: (affected: ExcalidrawElement, updates: ElementUpdate<ExcalidrawElement>) => void) => void;
|
|
77
|
+
}
|
|
@@ -36,7 +36,6 @@ export declare const getElementLineSegments: (element: ExcalidrawElement, elemen
|
|
|
36
36
|
* Rectangle here means any rectangular frame, not an excalidraw element.
|
|
37
37
|
*/
|
|
38
38
|
export declare const getRectangleBoxAbsoluteCoords: (boxSceneCoords: RectangleBox) => number[];
|
|
39
|
-
export declare const pointRelativeTo: (element: ExcalidrawElement, absoluteCoords: readonly [number, number]) => readonly [number, number];
|
|
40
39
|
export declare const getDiamondPoints: (element: ExcalidrawElement) => number[];
|
|
41
40
|
export declare const getCurvePathOps: (shape: Drawable) => Op[];
|
|
42
41
|
export declare const getMinMaxXYFromCurvePathOps: (ops: Op[], transformXY?: ((x: number, y: number) => [number, number]) | undefined) => Bounds;
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export declare const isHittingElementBoundingBoxWithoutHittingElement: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache, x: number, y: number, elementsMap: ElementsMap) => boolean;
|
|
7
|
-
export declare const isHittingElementNotConsideringBoundingBox: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache | null, point: readonly [number, number], elementsMap: ElementsMap) => boolean;
|
|
8
|
-
export declare const isPointHittingElementBoundingBox: (element: NonDeleted<ExcalidrawElement>, elementsMap: ElementsMap, [x, y]: readonly [number, number], threshold: number, frameNameBoundsCache: FrameNameBoundsCache | null) => boolean;
|
|
9
|
-
export declare const bindingBorderTest: (element: NonDeleted<ExcalidrawBindableElement>, { x, y }: {
|
|
1
|
+
import { ElementsMap, ExcalidrawElement } from "./types";
|
|
2
|
+
import { FrameNameBounds } from "../types";
|
|
3
|
+
import { GeometricShape } from "../../utils/geometry/shape";
|
|
4
|
+
export declare const shouldTestInside: (element: ExcalidrawElement) => boolean;
|
|
5
|
+
export type HitTestArgs = {
|
|
10
6
|
x: number;
|
|
11
7
|
y: number;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export declare const
|
|
18
|
-
export declare const
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const findFocusPointForRectangulars: (element: ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawDiamondElement | ExcalidrawTextElement | ExcalidrawIframeLikeElement | ExcalidrawFrameLikeElement, relativeDistance: number, point: readonly [number, number, number, number, number, number, number, number]) => readonly [number, number, number, number, number, number, number, number];
|
|
8
|
+
element: ExcalidrawElement;
|
|
9
|
+
shape: GeometricShape;
|
|
10
|
+
threshold?: number;
|
|
11
|
+
frameNameBound?: FrameNameBounds | null;
|
|
12
|
+
};
|
|
13
|
+
export declare const hitElementItself: ({ x, y, element, shape, threshold, frameNameBound, }: HitTestArgs) => boolean;
|
|
14
|
+
export declare const hitElementBoundingBox: (x: number, y: number, element: ExcalidrawElement, elementsMap: ElementsMap, tolerance?: number) => boolean;
|
|
15
|
+
export declare const hitElementBoundingBoxOnly: (hitArgs: HitTestArgs, elementsMap: ElementsMap) => boolean;
|
|
16
|
+
export declare const hitElementBoundText: (x: number, y: number, textShape: GeometricShape | null) => boolean | null;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ExcalidrawProps } from "../types";
|
|
2
2
|
import { ExcalidrawElement, ExcalidrawIframeLikeElement, IframeData } from "./types";
|
|
3
|
+
import { MarkRequired } from "../utility-types";
|
|
4
|
+
type IframeDataWithSandbox = MarkRequired<IframeData, "sandbox">;
|
|
3
5
|
export declare const createSrcDoc: (body: string) => string;
|
|
4
|
-
export declare const getEmbedLink: (link: string | null | undefined) =>
|
|
6
|
+
export declare const getEmbedLink: (link: string | null | undefined) => IframeDataWithSandbox | null;
|
|
5
7
|
export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawIframeLikeElement) => ExcalidrawElement;
|
|
6
8
|
export declare const actionSetEmbeddableAsActiveTool: {
|
|
7
9
|
name: "setEmbeddableAsActiveTool";
|
|
@@ -10,8 +12,8 @@ export declare const actionSetEmbeddableAsActiveTool: {
|
|
|
10
12
|
};
|
|
11
13
|
target: string;
|
|
12
14
|
label: string;
|
|
13
|
-
perform: (elements: readonly
|
|
14
|
-
elements: readonly
|
|
15
|
+
perform: (elements: readonly import("./types").OrderedExcalidrawElement[], appState: Readonly<import("../types").AppState>, _: any, app: import("../types").AppClassProperties) => {
|
|
16
|
+
elements: readonly import("./types").OrderedExcalidrawElement[];
|
|
15
17
|
appState: {
|
|
16
18
|
activeTool: {
|
|
17
19
|
lastActiveTool: import("../types").ActiveTool | null;
|
|
@@ -197,10 +199,11 @@ export declare const actionSetEmbeddableAsActiveTool: {
|
|
|
197
199
|
userToFollow: import("../types").UserToFollow | null;
|
|
198
200
|
followedBy: Set<import("../types").SocketId>;
|
|
199
201
|
};
|
|
200
|
-
|
|
202
|
+
storeAction: import("../store").StoreActionType;
|
|
201
203
|
};
|
|
202
204
|
} & {
|
|
203
205
|
keyTest?: undefined;
|
|
204
206
|
};
|
|
205
207
|
export declare const maybeParseEmbedSrc: (str: string) => string;
|
|
206
208
|
export declare const embeddableURLValidator: (url: string | null | undefined, validateEmbeddable: ExcalidrawProps["validateEmbeddable"]) => boolean;
|
|
209
|
+
export {};
|
|
@@ -2,7 +2,6 @@ import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "./ty
|
|
|
2
2
|
export { newElement, newTextElement, updateTextElement, refreshTextDimensions, newLinearElement, newImageElement, duplicateElement, } from "./newElement";
|
|
3
3
|
export { getElementAbsoluteCoords, getElementBounds, getCommonBounds, getDiamondPoints, getArrowheadPoints, getClosestElementBounds, } from "./bounds";
|
|
4
4
|
export { OMIT_SIDES_FOR_MULTIPLE_ELEMENTS, getTransformHandlesFromCoords, getTransformHandles, } from "./transformHandles";
|
|
5
|
-
export { hitTest, isHittingElementBoundingBoxWithoutHittingElement, } from "./collision";
|
|
6
5
|
export { resizeTest, getCursorForResizingElement, getElementWithTransformHandleType, getTransformHandleTypeFromCoords, } from "./resizeTest";
|
|
7
6
|
export { transformElements, getResizeOffsetXY, getResizeArrowDirection, } from "./resizeElements";
|
|
8
7
|
export { dragSelectedElements, getDragOffsetXY, dragNewElement, } from "./dragElements";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap,
|
|
1
|
+
import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap } from "./types";
|
|
2
2
|
import { Bounds } from "./bounds";
|
|
3
|
-
import { Point, AppState, PointerCoords, InteractiveCanvasAppState } from "../types";
|
|
4
|
-
import
|
|
3
|
+
import { Point, AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties } from "../types";
|
|
4
|
+
import { Store } from "../store";
|
|
5
5
|
declare const editorMidPointsCache: {
|
|
6
6
|
version: number | null;
|
|
7
7
|
points: (Point | null)[];
|
|
@@ -51,7 +51,7 @@ export declare class LinearElementEditor {
|
|
|
51
51
|
x: number;
|
|
52
52
|
y: number;
|
|
53
53
|
}[]) => void, linearElementEditor: LinearElementEditor, elementsMap: NonDeletedSceneElementsMap): boolean;
|
|
54
|
-
static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState,
|
|
54
|
+
static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState, app: AppClassProperties): LinearElementEditor;
|
|
55
55
|
static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (typeof editorMidPointsCache)["points"];
|
|
56
56
|
static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => void;
|
|
57
57
|
static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
|
|
@@ -61,10 +61,10 @@ export declare class LinearElementEditor {
|
|
|
61
61
|
static isSegmentTooShort(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, zoom: AppState["zoom"]): boolean;
|
|
62
62
|
static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, endPointIndex: number, elementsMap: ElementsMap): readonly [number, number];
|
|
63
63
|
static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: Point, elementsMap: ElementsMap): number;
|
|
64
|
-
static handlePointerDown(event: React.PointerEvent<HTMLElement>, appState: AppState,
|
|
64
|
+
static handlePointerDown(event: React.PointerEvent<HTMLElement>, appState: AppState, store: Store, scenePointer: {
|
|
65
65
|
x: number;
|
|
66
66
|
y: number;
|
|
67
|
-
}, linearElementEditor: LinearElementEditor,
|
|
67
|
+
}, linearElementEditor: LinearElementEditor, app: AppClassProperties): {
|
|
68
68
|
didAddPoint: boolean;
|
|
69
69
|
hitElement: NonDeleted<ExcalidrawElement> | null;
|
|
70
70
|
linearElementEditor: LinearElementEditor | null;
|
|
@@ -132,13 +132,13 @@ export declare class LinearElementEditor {
|
|
|
132
132
|
isLoading: boolean;
|
|
133
133
|
errorMessage: import("react").ReactNode;
|
|
134
134
|
activeEmbeddable: {
|
|
135
|
-
element: NonDeletedExcalidrawElement;
|
|
135
|
+
element: import("./types").NonDeletedExcalidrawElement;
|
|
136
136
|
state: "active" | "hover";
|
|
137
137
|
} | null;
|
|
138
|
-
draggingElement: NonDeletedExcalidrawElement | null;
|
|
139
|
-
resizingElement: NonDeletedExcalidrawElement | null;
|
|
138
|
+
draggingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
139
|
+
resizingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
140
140
|
multiElement: NonDeleted<ExcalidrawLinearElement> | null;
|
|
141
|
-
selectionElement: NonDeletedExcalidrawElement | null;
|
|
141
|
+
selectionElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
142
142
|
isBindingEnabled: boolean;
|
|
143
143
|
startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
|
|
144
144
|
suggestedBindings: import("./binding").SuggestedBinding[];
|
|
@@ -151,7 +151,7 @@ export declare class LinearElementEditor {
|
|
|
151
151
|
};
|
|
152
152
|
editingFrame: string | null;
|
|
153
153
|
elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
|
|
154
|
-
editingElement: NonDeletedExcalidrawElement | null;
|
|
154
|
+
editingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
155
155
|
activeTool: {
|
|
156
156
|
lastActiveTool: import("../types").ActiveTool | null;
|
|
157
157
|
locked: boolean;
|
|
@@ -238,7 +238,7 @@ export declare class LinearElementEditor {
|
|
|
238
238
|
button?: "up" | "down" | undefined;
|
|
239
239
|
selectedElementIds?: Readonly<{
|
|
240
240
|
[id: string]: true;
|
|
241
|
-
}> | undefined;
|
|
241
|
+
}> | undefined; /** index */
|
|
242
242
|
username?: string | null | undefined;
|
|
243
243
|
userState?: import("../types").UserIdleState | undefined;
|
|
244
244
|
color?: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExcalidrawElement } from "./types";
|
|
2
2
|
import { Mutable } from "../utility-types";
|
|
3
|
-
type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce">;
|
|
3
|
+
export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce" | "updated">;
|
|
4
4
|
export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
|
|
5
5
|
export declare const newElementWith: <TElement extends ExcalidrawElement>(element: TElement, updates: ElementUpdate<TElement>) => TElement;
|
|
6
6
|
/**
|
|
@@ -9,4 +9,3 @@ export declare const newElementWith: <TElement extends ExcalidrawElement>(elemen
|
|
|
9
9
|
* NOTE: does not trigger re-render.
|
|
10
10
|
*/
|
|
11
11
|
export declare const bumpVersion: <T extends Mutable<ExcalidrawElement>>(element: T, version?: ExcalidrawElement["version"]) => T;
|
|
12
|
-
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap } from "./types";
|
|
2
2
|
import { AppState } from "../types";
|
|
3
3
|
import { MarkOptional, Mutable } from "../utility-types";
|
|
4
|
-
export type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity" | "customData">;
|
|
4
|
+
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">;
|
|
5
5
|
export declare const newElement: (opts: {
|
|
6
6
|
type: ExcalidrawGenericElement["type"];
|
|
7
7
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawGenericElement>;
|
|
@@ -4,6 +4,6 @@ import { PointerDownState } from "../types";
|
|
|
4
4
|
export declare const normalizeAngle: (angle: number) => number;
|
|
5
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
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:
|
|
7
|
+
export declare const resizeMultipleElements: (originalElements: PointerDownState["originalElements"], selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: ElementsMap, transformHandleType: TransformHandleDirection, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number) => void;
|
|
8
8
|
export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, x: number, y: number) => [number, number];
|
|
9
9
|
export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ExcalidrawElement, PointerType, NonDeletedExcalidrawElement, ElementsMap } from "./types";
|
|
2
2
|
import { MaybeTransformHandleType } from "./transformHandles";
|
|
3
|
-
import { AppState, Zoom } from "../types";
|
|
3
|
+
import { AppState, Device, Zoom } from "../types";
|
|
4
4
|
import { Bounds } from "./bounds";
|
|
5
|
-
export declare const resizeTest: (element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, x: number, y: number, zoom: Zoom, pointerType: PointerType) => MaybeTransformHandleType;
|
|
6
|
-
export declare const getElementWithTransformHandleType: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, elementsMap: ElementsMap) => {
|
|
5
|
+
export declare const resizeTest: (element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, x: number, y: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
|
|
6
|
+
export declare const getElementWithTransformHandleType: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, elementsMap: ElementsMap, device: Device) => {
|
|
7
7
|
element: NonDeletedExcalidrawElement;
|
|
8
8
|
transformHandleType: MaybeTransformHandleType;
|
|
9
9
|
} | null;
|
|
10
|
-
export declare const getTransformHandleTypeFromCoords: ([x1, y1, x2, y2]: Bounds, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType) => MaybeTransformHandleType;
|
|
10
|
+
export declare const getTransformHandleTypeFromCoords: ([x1, y1, x2, y2]: Bounds, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
|
|
11
11
|
export declare const getCursorForResizingElement: (resizingElement: {
|
|
12
12
|
element?: ExcalidrawElement;
|
|
13
13
|
transformHandleType: MaybeTransformHandleType;
|
|
@@ -3,7 +3,7 @@ import { MaybeTransformHandleType } from "./transformHandles";
|
|
|
3
3
|
import { AppState } from "../types";
|
|
4
4
|
import { ExtractSetType, MakeBrand } from "../utility-types";
|
|
5
5
|
export declare const normalizeText: (text: string) => string;
|
|
6
|
-
export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, elementsMap: ElementsMap) => void;
|
|
6
|
+
export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, elementsMap: ElementsMap, informMutation?: boolean) => void;
|
|
7
7
|
export declare const bindTextToShapeAfterDuplication: (newElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
|
|
8
8
|
export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, elementsMap: ElementsMap, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean) => void;
|
|
9
9
|
export declare const computeBoundTextPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
|
|
@@ -61,7 +61,6 @@ export declare const getBoundTextElementPosition: (container: ExcalidrawElement,
|
|
|
61
61
|
} | undefined;
|
|
62
62
|
export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap) => boolean;
|
|
63
63
|
export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap) => boolean;
|
|
64
|
-
export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], appState: AppState, x: number, y: number, elementsMap: ElementsMap) => ExcalidrawTextContainer | null;
|
|
65
64
|
declare const VALID_CONTAINER_TYPES: Set<string>;
|
|
66
65
|
export declare const isValidTextContainer: (element: {
|
|
67
66
|
type: ExcalidrawElementType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
|
|
2
2
|
import { Bounds } from "./bounds";
|
|
3
|
-
import { InteractiveCanvasAppState, Zoom } from "../types";
|
|
3
|
+
import { Device, InteractiveCanvasAppState, Zoom } from "../types";
|
|
4
4
|
export type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
|
|
5
5
|
export type TransformHandleType = TransformHandleDirection | "rotation";
|
|
6
6
|
export type TransformHandle = Bounds;
|
|
@@ -8,6 +8,12 @@ export type TransformHandles = Partial<{
|
|
|
8
8
|
[T in TransformHandleType]: TransformHandle;
|
|
9
9
|
}>;
|
|
10
10
|
export type MaybeTransformHandleType = TransformHandleType | false;
|
|
11
|
+
export declare const DEFAULT_OMIT_SIDES: {
|
|
12
|
+
e: boolean;
|
|
13
|
+
s: boolean;
|
|
14
|
+
n: boolean;
|
|
15
|
+
w: boolean;
|
|
16
|
+
};
|
|
11
17
|
export declare const OMIT_SIDES_FOR_MULTIPLE_ELEMENTS: {
|
|
12
18
|
e: boolean;
|
|
13
19
|
s: boolean;
|
|
@@ -21,16 +27,28 @@ export declare const OMIT_SIDES_FOR_FRAME: {
|
|
|
21
27
|
w: boolean;
|
|
22
28
|
rotation: boolean;
|
|
23
29
|
};
|
|
30
|
+
export declare const canResizeFromSides: (device: Device) => boolean;
|
|
31
|
+
export declare const getOmitSidesForDevice: (device: Device) => {};
|
|
24
32
|
export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [number, number, number, number, number, number], angle: number, zoom: Zoom, pointerType: PointerType, omitSides?: {
|
|
25
33
|
s?: boolean | undefined;
|
|
26
|
-
n?: boolean | undefined;
|
|
27
|
-
w?: boolean | undefined;
|
|
28
34
|
e?: boolean | undefined;
|
|
35
|
+
w?: boolean | undefined;
|
|
36
|
+
n?: boolean | undefined;
|
|
29
37
|
nw?: boolean | undefined;
|
|
30
38
|
ne?: boolean | undefined;
|
|
31
39
|
sw?: boolean | undefined;
|
|
32
40
|
se?: boolean | undefined;
|
|
33
41
|
rotation?: boolean | undefined;
|
|
34
42
|
}, margin?: number) => TransformHandles;
|
|
35
|
-
export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoom, elementsMap: ElementsMap, pointerType?: PointerType
|
|
43
|
+
export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoom, elementsMap: ElementsMap, pointerType?: PointerType, omitSides?: {
|
|
44
|
+
s?: boolean | undefined;
|
|
45
|
+
e?: boolean | undefined;
|
|
46
|
+
w?: boolean | undefined;
|
|
47
|
+
n?: boolean | undefined;
|
|
48
|
+
nw?: boolean | undefined;
|
|
49
|
+
ne?: boolean | undefined;
|
|
50
|
+
sw?: boolean | undefined;
|
|
51
|
+
se?: boolean | undefined;
|
|
52
|
+
rotation?: boolean | undefined;
|
|
53
|
+
}) => TransformHandles;
|
|
36
54
|
export declare const shouldShowBoundingBox: (elements: readonly NonDeletedExcalidrawElement[], appState: InteractiveCanvasAppState) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ElementOrToolType } from "../types";
|
|
2
2
|
import { MarkNonNullable } from "../utility-types";
|
|
3
|
-
import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawEmbeddableElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeElement, ExcalidrawIframeLikeElement, ExcalidrawMagicFrameElement } from "./types";
|
|
3
|
+
import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawEmbeddableElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeElement, ExcalidrawIframeLikeElement, ExcalidrawMagicFrameElement, ExcalidrawArrowElement } from "./types";
|
|
4
4
|
export declare const isInitializedImageElement: (element: ExcalidrawElement | null) => element is InitializedExcalidrawImageElement;
|
|
5
5
|
export declare const isImageElement: (element: ExcalidrawElement | null) => element is ExcalidrawImageElement;
|
|
6
6
|
export declare const isEmbeddableElement: (element: ExcalidrawElement | null | undefined) => element is ExcalidrawEmbeddableElement;
|
|
@@ -13,7 +13,7 @@ export declare const isFrameLikeElement: (element: ExcalidrawElement | null) =>
|
|
|
13
13
|
export declare const isFreeDrawElement: (element?: ExcalidrawElement | null) => element is ExcalidrawFreeDrawElement;
|
|
14
14
|
export declare const isFreeDrawElementType: (elementType: ExcalidrawElementType) => boolean;
|
|
15
15
|
export declare const isLinearElement: (element?: ExcalidrawElement | null) => element is ExcalidrawLinearElement;
|
|
16
|
-
export declare const isArrowElement: (element?: ExcalidrawElement | null) => element is
|
|
16
|
+
export declare const isArrowElement: (element?: ExcalidrawElement | null) => element is ExcalidrawArrowElement;
|
|
17
17
|
export declare const isLinearElementType: (elementType: ElementOrToolType) => boolean;
|
|
18
18
|
export declare const isBindingElement: (element?: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawLinearElement;
|
|
19
19
|
export declare const isBindingElementType: (elementType: ElementOrToolType) => boolean;
|
|
@@ -18,6 +18,13 @@ export type StrokeStyle = "solid" | "dashed" | "dotted";
|
|
|
18
18
|
export type TextAlign = typeof TEXT_ALIGN[keyof typeof TEXT_ALIGN];
|
|
19
19
|
type VerticalAlignKeys = keyof typeof VERTICAL_ALIGN;
|
|
20
20
|
export type VerticalAlign = typeof VERTICAL_ALIGN[VerticalAlignKeys];
|
|
21
|
+
export type FractionalIndex = string & {
|
|
22
|
+
_brand: "franctionalIndex";
|
|
23
|
+
};
|
|
24
|
+
export type BoundElement = Readonly<{
|
|
25
|
+
id: ExcalidrawLinearElement["id"];
|
|
26
|
+
type: "arrow" | "text";
|
|
27
|
+
}>;
|
|
21
28
|
type _ExcalidrawElementBase = Readonly<{
|
|
22
29
|
id: string;
|
|
23
30
|
x: number;
|
|
@@ -46,16 +53,18 @@ type _ExcalidrawElementBase = Readonly<{
|
|
|
46
53
|
Used for deterministic reconciliation of updates during collaboration,
|
|
47
54
|
in case the versions (see above) are identical. */
|
|
48
55
|
versionNonce: number;
|
|
56
|
+
/** String in a fractional form defined by https://github.com/rocicorp/fractional-indexing.
|
|
57
|
+
Used for ordering in multiplayer scenarios, such as during reconciliation or undo / redo.
|
|
58
|
+
Always kept in sync with the array order by `syncMovedIndices` and `syncInvalidIndices`.
|
|
59
|
+
Could be null, i.e. for new elements which were not yet assigned to the scene. */
|
|
60
|
+
index: FractionalIndex | null;
|
|
49
61
|
isDeleted: boolean;
|
|
50
62
|
/** List of groups the element belongs to.
|
|
51
63
|
Ordered from deepest to shallowest. */
|
|
52
64
|
groupIds: readonly GroupId[];
|
|
53
65
|
frameId: string | null;
|
|
54
66
|
/** other elements that are bound to this element */
|
|
55
|
-
boundElements: readonly
|
|
56
|
-
id: ExcalidrawLinearElement["id"];
|
|
57
|
-
type: "arrow" | "text";
|
|
58
|
-
}>[] | null;
|
|
67
|
+
boundElements: readonly BoundElement[] | null;
|
|
59
68
|
/** epoch (ms) timestamp of last element update */
|
|
60
69
|
updated: number;
|
|
61
70
|
link: string | null;
|
|
@@ -92,6 +101,9 @@ export type IframeData = ({
|
|
|
92
101
|
h: number;
|
|
93
102
|
};
|
|
94
103
|
error?: Error;
|
|
104
|
+
sandbox?: {
|
|
105
|
+
allowSameOrigin?: boolean;
|
|
106
|
+
};
|
|
95
107
|
} & ({
|
|
96
108
|
type: "video" | "generic";
|
|
97
109
|
link: string;
|
|
@@ -127,6 +139,10 @@ export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRe
|
|
|
127
139
|
* between peers and contain no state local to the peer.
|
|
128
140
|
*/
|
|
129
141
|
export type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement | ExcalidrawFrameElement | ExcalidrawMagicFrameElement | ExcalidrawIframeElement | ExcalidrawEmbeddableElement;
|
|
142
|
+
export type Ordered<TElement extends ExcalidrawElement> = TElement & {
|
|
143
|
+
index: FractionalIndex;
|
|
144
|
+
};
|
|
145
|
+
export type OrderedExcalidrawElement = Ordered<ExcalidrawElement>;
|
|
130
146
|
export type NonDeleted<TElement extends ExcalidrawElement> = TElement & {
|
|
131
147
|
isDeleted: boolean;
|
|
132
148
|
};
|
|
@@ -198,11 +214,11 @@ export type NonDeletedElementsMap = Map<ExcalidrawElement["id"], NonDeletedExcal
|
|
|
198
214
|
* Map of all excalidraw Scene elements, including deleted.
|
|
199
215
|
* Not a subset. Use this type when you need access to current Scene elements.
|
|
200
216
|
*/
|
|
201
|
-
export type SceneElementsMap = Map<ExcalidrawElement["id"], ExcalidrawElement
|
|
217
|
+
export type SceneElementsMap = Map<ExcalidrawElement["id"], Ordered<ExcalidrawElement>> & MakeBrand<"SceneElementsMap">;
|
|
202
218
|
/**
|
|
203
219
|
* Map of all non-deleted Scene elements.
|
|
204
220
|
* Not a subset. Use this type when you need access to current Scene elements.
|
|
205
221
|
*/
|
|
206
|
-
export type NonDeletedSceneElementsMap = Map<ExcalidrawElement["id"], NonDeletedExcalidrawElement
|
|
222
|
+
export type NonDeletedSceneElementsMap = Map<ExcalidrawElement["id"], Ordered<NonDeletedExcalidrawElement>> & MakeBrand<"NonDeletedSceneElementsMap">;
|
|
207
223
|
export type ElementsMapOrArray = readonly ExcalidrawElement[] | Readonly<ElementsMap>;
|
|
208
224
|
export {};
|
|
@@ -10,4 +10,7 @@ export declare class ImageSceneDataError extends Error {
|
|
|
10
10
|
code: ImageSceneDataErrorCode;
|
|
11
11
|
constructor(message?: string, code?: ImageSceneDataErrorCode);
|
|
12
12
|
}
|
|
13
|
+
export declare class InvalidFractionalIndexError extends Error {
|
|
14
|
+
code: "ELEMENT_HAS_INVALID_INDEX";
|
|
15
|
+
}
|
|
13
16
|
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ExcalidrawElement, OrderedExcalidrawElement } from "./element/types";
|
|
2
|
+
/**
|
|
3
|
+
* Envisioned relation between array order and fractional indices:
|
|
4
|
+
*
|
|
5
|
+
* 1) Array (or array-like ordered data structure) should be used as a cache of elements order, hiding the internal fractional indices implementation.
|
|
6
|
+
* - it's undesirable to to perform reorder for each related operation, thefeore it's necessary to cache the order defined by fractional indices into an ordered data structure
|
|
7
|
+
* - it's easy enough to define the order of the elements from the outside (boundaries), without worrying about the underlying structure of fractional indices (especially for the host apps)
|
|
8
|
+
* - it's necessary to always keep the array support for backwards compatibility (restore) - old scenes, old libraries, supporting multiple excalidraw versions etc.
|
|
9
|
+
* - it's necessary to always keep the fractional indices in sync with the array order
|
|
10
|
+
* - elements with invalid indices should be detected and synced, without altering the already valid indices
|
|
11
|
+
*
|
|
12
|
+
* 2) Fractional indices should be used to reorder the elements, whenever the cached order is expected to be invalidated.
|
|
13
|
+
* - as the fractional indices are encoded as part of the elements, it opens up possibilties for incremental-like APIs
|
|
14
|
+
* - re-order based on fractional indices should be part of (multiplayer) operations such as reconcillitation & undo/redo
|
|
15
|
+
* - technically all the z-index actions could perform also re-order based on fractional indices,but in current state it would not bring much benefits,
|
|
16
|
+
* as it's faster & more efficient to perform re-order based on array manipulation and later synchronisation of moved indices with the array order
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Ensure that all elements have valid fractional indices.
|
|
20
|
+
*
|
|
21
|
+
* @throws `InvalidFractionalIndexError` if invalid index is detected.
|
|
22
|
+
*/
|
|
23
|
+
export declare const validateFractionalIndices: (indices: (ExcalidrawElement["index"] | undefined)[]) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Order the elements based on the fractional indices.
|
|
26
|
+
* - when fractional indices are identical, break the tie based on the element id
|
|
27
|
+
* - when there is no fractional index in one of the elements, respect the order of the array
|
|
28
|
+
*/
|
|
29
|
+
export declare const orderByFractionalIndex: (elements: OrderedExcalidrawElement[]) => OrderedExcalidrawElement[];
|
|
30
|
+
/**
|
|
31
|
+
* Synchronizes invalid fractional indices of moved elements with the array order by mutating passed elements.
|
|
32
|
+
* If the synchronization fails or the result is invalid, it fallbacks to `syncInvalidIndices`.
|
|
33
|
+
*/
|
|
34
|
+
export declare const syncMovedIndices: (elements: readonly ExcalidrawElement[], movedElements: Map<string, ExcalidrawElement>) => OrderedExcalidrawElement[];
|
|
35
|
+
/**
|
|
36
|
+
* Synchronizes all invalid fractional indices with the array order by mutating passed elements.
|
|
37
|
+
*
|
|
38
|
+
* WARN: in edge cases it could modify the elements which were not moved, as it's impossible to guess the actually moved elements from the elements array itself.
|
|
39
|
+
*/
|
|
40
|
+
export declare const syncInvalidIndices: (elements: readonly ExcalidrawElement[]) => OrderedExcalidrawElement[];
|
|
@@ -2,7 +2,7 @@ import { ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFrameLike
|
|
|
2
2
|
import { AppClassProperties, AppState, StaticCanvasAppState } from "./types";
|
|
3
3
|
import type { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
|
|
4
4
|
import { ReadonlySetLike } from "./utility-types";
|
|
5
|
-
export declare const bindElementsToFramesAfterDuplication: (nextElements: ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
|
|
5
|
+
export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: 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: (elements: readonly ExcalidrawElement[], element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => boolean;
|
|
@@ -28,4 +28,6 @@ export declare const removeFromSelectedGroups: (groupIds: ExcalidrawElement["gro
|
|
|
28
28
|
[groupId: string]: boolean;
|
|
29
29
|
}) => string[];
|
|
30
30
|
export declare const getMaximumGroups: (elements: ExcalidrawElement[], elementsMap: ElementsMap) => ExcalidrawElement[][];
|
|
31
|
+
export declare const getNonDeletedGroupIds: (elements: ElementsMap) => Set<string>;
|
|
31
32
|
export declare const elementsAreInSameGroup: (elements: ExcalidrawElement[]) => boolean;
|
|
33
|
+
export declare const isInGroup: (element: NonDeletedExcalidrawElement) => boolean;
|