@excalidraw/math 0.18.0-4e758db → 0.18.0-4f68076
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/dev/index.js +8 -2
- package/dist/dev/index.js.map +2 -2
- package/dist/prod/index.js +1 -1
- package/dist/types/common/src/constants.d.ts +10 -0
- package/dist/types/common/src/utils.d.ts +5 -0
- package/dist/types/element/src/binding.d.ts +13 -7
- package/dist/types/element/src/collision.d.ts +14 -5
- package/dist/types/element/src/duplicate.d.ts +60 -0
- package/dist/types/element/src/index.d.ts +1 -0
- package/dist/types/element/src/listMarker.d.ts +34 -0
- package/dist/types/element/src/newElement.d.ts +15 -1
- package/dist/types/element/src/renderElement.d.ts +21 -4
- package/dist/types/element/src/shape.d.ts +15 -1
- package/dist/types/element/src/textElement.d.ts +7 -0
- package/dist/types/element/src/utils.d.ts +8 -1
- package/dist/types/element/src/zindex.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +30 -3
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +70 -7
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +30 -3
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +13 -1
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionExport.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionFrame.d.ts +30 -3
- package/dist/types/excalidraw/actions/actionGroup.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionLink.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionProperties.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionStyles.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +197 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +10 -1
- package/dist/types/excalidraw/actions/index.d.ts +1 -0
- package/dist/types/excalidraw/actions/types.d.ts +1 -1
- package/dist/types/excalidraw/appState.d.ts +2 -0
- package/dist/types/excalidraw/components/App.arrowText.d.ts +5 -39
- package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
- package/dist/types/excalidraw/components/App.d.ts +82 -262
- package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
- package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
- package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
- package/dist/types/excalidraw/components/App.selectionTool.d.ts +57 -0
- package/dist/types/excalidraw/components/App.text.d.ts +146 -0
- package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +41 -1
- package/dist/types/excalidraw/components/App.wheel.d.ts +3 -10
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
- package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
- package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
- package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
- package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
- package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
- package/dist/types/excalidraw/components/Tooltip.d.ts +15 -1
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
- package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +1 -0
- package/dist/types/excalidraw/data/blob.d.ts +20 -2
- package/dist/types/excalidraw/data/json.d.ts +10 -1
- package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
- package/dist/types/excalidraw/scene/Renderer.d.ts +14 -1
- package/dist/types/excalidraw/scene/types.d.ts +2 -1
- package/dist/types/excalidraw/types.d.ts +92 -19
- package/dist/types/excalidraw/viewport.d.ts +23 -1
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +12 -1
- package/package.json +2 -2
- package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +0 -31
|
@@ -25,10 +25,9 @@ export type BindingStrategy = {
|
|
|
25
25
|
* IMPORTANT: currently must be > 0 (this also applies to the computed gap)
|
|
26
26
|
*/
|
|
27
27
|
export declare const BASE_BINDING_GAP = 5;
|
|
28
|
-
export declare const BASE_BINDING_GAP_ELBOW = 5;
|
|
29
28
|
export declare const BASE_ARROW_MIN_LENGTH = 10;
|
|
30
29
|
export declare const FOCUS_POINT_SIZE: number;
|
|
31
|
-
export declare const getBindingGap: (bindTarget: Pick<ExcalidrawBindableElement, "strokeWidth"
|
|
30
|
+
export declare const getBindingGap: (bindTarget: Pick<ExcalidrawBindableElement, "strokeWidth">) => number;
|
|
32
31
|
export declare const maxBindingDistance_simple: (zoom?: AppState["zoom"]) => number;
|
|
33
32
|
export declare const isBindingEnabled: (appState: {
|
|
34
33
|
isBindingEnabled: AppState["isBindingEnabled"];
|
|
@@ -49,16 +48,17 @@ export declare const getBindingStrategyForDraggingBindingElementEndpoints: (arro
|
|
|
49
48
|
altKey?: boolean;
|
|
50
49
|
finalize?: boolean;
|
|
51
50
|
initialBinding?: boolean;
|
|
52
|
-
zoom?: AppState["zoom"];
|
|
53
51
|
gridSize?: NullableGridSize;
|
|
54
52
|
}) => {
|
|
55
53
|
start: BindingStrategy;
|
|
56
54
|
end: BindingStrategy;
|
|
57
55
|
};
|
|
58
56
|
export declare const bindOrUnbindBindingElements: (selectedArrows: NonDeleted<ExcalidrawArrowElement>[], scene: Scene, appState: AppState) => void;
|
|
59
|
-
export declare const bindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, hoveredElement: NonDeleted<ExcalidrawBindableElement>, mode: BindMode, startOrEnd: "start" | "end", scene: Scene, focusPoint?: GlobalPoint, shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => void;
|
|
57
|
+
export declare const bindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, hoveredElement: NonDeleted<ExcalidrawBindableElement>, mode: BindMode, startOrEnd: "start" | "end", scene: Scene, zoom: AppState["zoom"], focusPoint?: GlobalPoint, shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => void;
|
|
60
58
|
export declare const unbindBindingElement: (arrow: ExcalidrawArrowElement, startOrEnd: "start" | "end", scene: Scene) => ExcalidrawBindableElement["id"] | null;
|
|
59
|
+
export declare const reanchorBindingsToOutline: (changedElement: NonDeleted<ExcalidrawBindableElement>, scene: Scene, zoom: AppState["zoom"]) => void;
|
|
61
60
|
export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement, scene: Scene, options?: {
|
|
61
|
+
/** see `getSimultaneouslyUpdatedElementIds` for how to pass it */
|
|
62
62
|
simultaneouslyUpdated?: readonly NonDeletedExcalidrawElement[];
|
|
63
63
|
changedElements?: Map<string, ExcalidrawElement>;
|
|
64
64
|
}) => void;
|
|
@@ -69,12 +69,18 @@ export declare const updateBindings: (latestElement: NonDeletedExcalidrawElement
|
|
|
69
69
|
height: number;
|
|
70
70
|
};
|
|
71
71
|
}) => void;
|
|
72
|
+
/**
|
|
73
|
+
* The id set of `simultaneouslyUpdated`, shared by every `updateBoundElements()`
|
|
74
|
+
* call given the same array. Pass one array instance for all elements of an
|
|
75
|
+
* operation, and don't change its membership after the first lookup, or the
|
|
76
|
+
* cached ids go stale.
|
|
77
|
+
*/
|
|
78
|
+
export declare const getSimultaneouslyUpdatedElementIds: (simultaneouslyUpdated: readonly ExcalidrawElement[] | undefined) => ReadonlySet<ExcalidrawElement["id"]>;
|
|
72
79
|
export declare const getHeadingForElbowArrowSnap: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined | null, aabb: Bounds | undefined | null, origPoint: GlobalPoint, elementsMap: ElementsMap, zoom?: AppState["zoom"]) => Heading;
|
|
73
|
-
export declare const bindPointToSnapToElementOutline: (arrowElement: ExcalidrawArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, customIntersector?: LineSegment<GlobalPoint>, isMidpointSnappingEnabled?: boolean) => GlobalPoint;
|
|
80
|
+
export declare const bindPointToSnapToElementOutline: (arrowElement: ExcalidrawArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, zoom: AppState["zoom"], customIntersector?: LineSegment<GlobalPoint>, isMidpointSnappingEnabled?: boolean) => GlobalPoint;
|
|
74
81
|
export declare const avoidRectangularCorner: (arrowElement: ExcalidrawArrowElement, bindTarget: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint) => GlobalPoint;
|
|
75
|
-
export declare const snapToMid: (bindTarget: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint, tolerance?: number, arrowElement?: ExcalidrawArrowElement) => GlobalPoint | undefined;
|
|
76
82
|
export declare const updateBoundPoint: (arrow: NonDeleted<ExcalidrawArrowElement>, startOrEnd: "startBinding" | "endBinding", binding: FixedPointBinding | null | undefined, bindableElement: ExcalidrawBindableElement, elementsMap: ElementsMap, dragging?: boolean) => LocalPoint | null;
|
|
77
|
-
export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => {
|
|
83
|
+
export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, zoom: AppState["zoom"], shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => {
|
|
78
84
|
fixedPoint: FixedPoint;
|
|
79
85
|
};
|
|
80
86
|
export declare const calculateFixedPointForNonElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawArrowElement>, hoveredElement: NonDeleted<ExcalidrawBindableElement>, startOrEnd: "start" | "end", elementsMap: ElementsMap, focusPoint?: GlobalPoint) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GlobalPoint, LineSegment } from "@excalidraw/math";
|
|
2
|
-
import type { FrameNameBounds } from "@excalidraw/excalidraw/types";
|
|
3
|
-
import type { ElementsMap,
|
|
2
|
+
import type { AppState, FrameNameBounds } from "@excalidraw/excalidraw/types";
|
|
3
|
+
import type { ElementsMap, ExcalidrawBindableElement, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap, Ordered } from "./types";
|
|
4
4
|
export declare const shouldTestInside: (element: ExcalidrawElement) => boolean;
|
|
5
5
|
export type HitTestArgs = {
|
|
6
6
|
point: GlobalPoint;
|
|
@@ -14,9 +14,18 @@ export declare const hitElementItself: ({ point, element, threshold, elementsMap
|
|
|
14
14
|
export declare const hitElementBoundingBox: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap, tolerance?: number) => boolean;
|
|
15
15
|
export declare const hitElementBoundingBoxOnly: (hitArgs: HitTestArgs, elementsMap: ElementsMap) => boolean;
|
|
16
16
|
export declare const hitElementBoundText: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Whether the element hides what is behind it from binding — an arrow's or a
|
|
19
|
+
* text label's. Images count as opaque, and frames once they support a
|
|
20
|
+
* background.
|
|
21
|
+
*/
|
|
22
|
+
export declare const isOpaqueForBinding: (element: ExcalidrawElement) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* All elements an arrow endpoint at the point could bind to. Always includes
|
|
25
|
+
* the result of `getHoveredElementForBinding` for the same arguments.
|
|
26
|
+
*/
|
|
27
|
+
export declare const getAllHoveredElementAtPoint: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => NonDeleted<ExcalidrawBindableElement>[];
|
|
28
|
+
export declare const getHoveredElementForBinding: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => NonDeleted<ExcalidrawBindableElement> | null;
|
|
20
29
|
/**
|
|
21
30
|
* Intersect a line with an element for binding test
|
|
22
31
|
*
|
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import type { Mutable } from "@excalidraw/common/utility-types";
|
|
2
2
|
import type { AppState } from "@excalidraw/excalidraw/types";
|
|
3
3
|
import type { ExcalidrawElement, GroupId, NonDeletedExcalidrawElement } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Lookups supplied to the host's `props.onDuplicate`, covering just the
|
|
6
|
+
* elements taking part in the duplication.
|
|
7
|
+
*/
|
|
8
|
+
export type OnDuplicateData = {
|
|
9
|
+
/** the duplicates, by their id */
|
|
10
|
+
duplicateElements: ReadonlyMap<ExcalidrawElement["id"], ExcalidrawElement>;
|
|
11
|
+
/**
|
|
12
|
+
* The elements the duplicates were made from, by their id.
|
|
13
|
+
*
|
|
14
|
+
* On paste and library insert these are the inserted elements, which aren't
|
|
15
|
+
* part of the scene (though they may share ids with the scene elements they
|
|
16
|
+
* were copied from).
|
|
17
|
+
*/
|
|
18
|
+
originalElements: ReadonlyMap<ExcalidrawElement["id"], ExcalidrawElement>;
|
|
19
|
+
/**
|
|
20
|
+
* id of an original -> id of its duplicate (e.g. to remap element ids you
|
|
21
|
+
* keep in `customData`, which the duplicate copied from its original)
|
|
22
|
+
*/
|
|
23
|
+
origIdToDuplicateId: ReadonlyMap<ExcalidrawElement["id"], ExcalidrawElement["id"]>;
|
|
24
|
+
/**
|
|
25
|
+
* id of a duplicate -> id of its original (e.g. to look up the original in
|
|
26
|
+
* `originalElements` while modifying the duplicate)
|
|
27
|
+
*/
|
|
28
|
+
duplicateIdToOrigId: ReadonlyMap<ExcalidrawElement["id"], ExcalidrawElement["id"]>;
|
|
29
|
+
};
|
|
4
30
|
/**
|
|
5
31
|
* Duplicate an element, often used in the alt-drag operation.
|
|
6
32
|
* Note that this method has gotten a bit complicated since the
|
|
@@ -49,8 +75,42 @@ export declare const duplicateElements: (opts: {
|
|
|
49
75
|
})) => {
|
|
50
76
|
duplicatedElements: NonDeletedExcalidrawElement[];
|
|
51
77
|
duplicateElementsMap: Map<string, NonDeletedExcalidrawElement>;
|
|
78
|
+
origElementsMap: Map<string, ExcalidrawElement>;
|
|
52
79
|
elementsWithDuplicates: ExcalidrawElement[];
|
|
53
80
|
origIdToDuplicateId: Map<string, string>;
|
|
81
|
+
duplicateIdToOrigId: Map<string, string>;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Folds the elements returned by the host (`props.onDuplicate`) back into the
|
|
85
|
+
* duplicates the editor created, so that everything that follows (frame
|
|
86
|
+
* assignment, bound text redraw, selection, alt-drag handover) can keep
|
|
87
|
+
* working with the editor's own objects, whether the host mutated the
|
|
88
|
+
* duplicates or returned new objects for them.
|
|
89
|
+
*
|
|
90
|
+
* - A returned element with a duplicate's id is shallow-merged into that
|
|
91
|
+
* duplicate, which takes its place in the returned array. Properties the
|
|
92
|
+
* host omits are kept, so that a partial element can't invalidate the
|
|
93
|
+
* duplicate. Safe only because the duplicates are fresh (not in the scene or
|
|
94
|
+
* the store snapshot yet), which is why nothing but the passed duplicates is
|
|
95
|
+
* ever merged into. Since the merge goes around `mutateElement`, what may
|
|
96
|
+
* have been cached for the duplicate by then is invalidated here.
|
|
97
|
+
* - A duplicate missing from the returned array (or returned as deleted) is
|
|
98
|
+
* vetoed. So is the bound text of a vetoed container. What the remaining
|
|
99
|
+
* duplicates reference of the vetoed ones is cleared, as if those were never
|
|
100
|
+
* part of the duplication (see `fixDuplicatedBindingsAfterDuplication`).
|
|
101
|
+
* - Any other returned element is used as is (existing elements must not be
|
|
102
|
+
* mutated, so the host replaces them).
|
|
103
|
+
* - `false` vetoes all the duplicates.
|
|
104
|
+
*
|
|
105
|
+
* @returns next elements, and the duplicates that weren't vetoed
|
|
106
|
+
*/
|
|
107
|
+
export declare const reconcileDuplicatedElements: <TDuplicate extends ExcalidrawElement>(
|
|
108
|
+
/** what the host returned from `props.onDuplicate`, if anything */
|
|
109
|
+
hostElements: readonly ExcalidrawElement[] | void | false,
|
|
110
|
+
/** elements that were passed to the host */
|
|
111
|
+
nextElements: ExcalidrawElement[], duplicatedElements: TDuplicate[]) => {
|
|
112
|
+
elements: ExcalidrawElement[];
|
|
113
|
+
duplicatedElements: TDuplicate[];
|
|
54
114
|
};
|
|
55
115
|
/**
|
|
56
116
|
* Clones ExcalidrawElement data structure. Does not regenerate id, nonce, or
|
|
@@ -36,6 +36,7 @@ export * from "./groups";
|
|
|
36
36
|
export * from "./heading";
|
|
37
37
|
export * from "./image";
|
|
38
38
|
export * from "./linearElementEditor";
|
|
39
|
+
export * from "./listMarker";
|
|
39
40
|
export * from "./mutateElement";
|
|
40
41
|
export * from "./newElement";
|
|
41
42
|
export * from "./positionElementsOnGrid";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Scene } from "./Scene";
|
|
2
|
+
import type { ExcalidrawElement, ExcalidrawTextElement } from "./types";
|
|
3
|
+
/** a list marker advanced by duplication, to go back and forth */
|
|
4
|
+
export type ListMarkerAdvance = {
|
|
5
|
+
elementId: ExcalidrawTextElement["id"];
|
|
6
|
+
prevOriginalText: string;
|
|
7
|
+
nextOriginalText: string;
|
|
8
|
+
/**
|
|
9
|
+
* where the item's text (after the marker and whitespace) starts in
|
|
10
|
+
* `nextOriginalText` (its length if there's none)
|
|
11
|
+
*/
|
|
12
|
+
contentStart: number;
|
|
13
|
+
/** the label's container before the label (may have) grown it */
|
|
14
|
+
prevContainerSize: {
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
} | null;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Advances the list markers of the duplicated texts and labels, so that
|
|
21
|
+
* duplicating `1. foo` gives `2. foo` (and `1` gives `2`).
|
|
22
|
+
*
|
|
23
|
+
* Duplicating several list items at once continues the list from the
|
|
24
|
+
* highest of them: duplicating `1.`, `3.`, `5.` gives `6.`, `7.`, `8.` (only
|
|
25
|
+
* if they're just markers, i.e. without text).
|
|
26
|
+
*
|
|
27
|
+
* Only if nothing but list items (texts, or containers with list item labels)
|
|
28
|
+
* is duplicated.
|
|
29
|
+
*/
|
|
30
|
+
export declare const advanceDuplicatedListMarkers: (duplicatedElements: readonly ExcalidrawElement[], scene: Scene) => ListMarkerAdvance[];
|
|
31
|
+
/**
|
|
32
|
+
* Sets the advanced list markers back (`"prev"`), or forth again (`"next"`).
|
|
33
|
+
*/
|
|
34
|
+
export declare const applyListMarkerAdvances: (advances: readonly ListMarkerAdvance[], direction: "prev" | "next", scene: Scene) => void;
|
|
@@ -62,7 +62,21 @@ export declare const newTextElement: (opts: {
|
|
|
62
62
|
labelPosition?: ExcalidrawTextElement["labelPosition"];
|
|
63
63
|
baseFontSize?: ExcalidrawTextElement["baseFontSize"];
|
|
64
64
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
|
|
65
|
-
export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null, elementsMap: ElementsMap, text?: string
|
|
65
|
+
export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null, elementsMap: ElementsMap, text?: string,
|
|
66
|
+
/**
|
|
67
|
+
* For a free text that grows with its content (`autoResize`): the widest
|
|
68
|
+
* it may grow to. Crossing it, the text stops growing and wraps at this
|
|
69
|
+
* width from then on (`autoResize: false`), anchored as its growth was. A
|
|
70
|
+
* text that is already wider keeps growing.
|
|
71
|
+
*/
|
|
72
|
+
maxWidth?: number) => {
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
text: string;
|
|
78
|
+
autoResize: boolean;
|
|
79
|
+
} | {
|
|
66
80
|
x: number;
|
|
67
81
|
y: number;
|
|
68
82
|
width: number;
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { type GlobalPoint } from "@excalidraw/math";
|
|
2
|
-
import type { AppState, StaticCanvasAppState, InteractiveCanvasAppState,
|
|
2
|
+
import type { AppState, StaticCanvasAppState, InteractiveCanvasAppState, ElementRenderOverrides } from "@excalidraw/excalidraw/types";
|
|
3
3
|
import type { StaticCanvasRenderConfig, RenderableElementsMap, InteractiveCanvasRenderConfig } from "@excalidraw/excalidraw/scene/types";
|
|
4
|
-
import type { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawImageElement,
|
|
4
|
+
import type { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawImageElement, NonDeletedSceneElementsMap, ElementsMap } from "./types";
|
|
5
5
|
import type { RoughCanvas } from "roughjs/bin/canvas";
|
|
6
|
-
export
|
|
6
|
+
export type RenderPositionOffset = Readonly<{
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}>;
|
|
10
|
+
/** Bound labels follow their container; a label's own offset is ignored. */
|
|
11
|
+
export declare const getElementRenderOffset: (element: ExcalidrawElement, elementsMap: ElementsMap, overrides: ElementRenderOverrides | undefined) => RenderPositionOffset | undefined;
|
|
12
|
+
export declare const getRenderElementWithPositionOverride: <TElement extends ExcalidrawElement>(element: TElement, positionOffset: RenderPositionOffset) => TElement;
|
|
13
|
+
export type ElementRenderState = Readonly<{
|
|
14
|
+
/** Alpha including frame opacity and pending erasure; selection dimming is separate. */
|
|
15
|
+
opacity: number;
|
|
16
|
+
offset: RenderPositionOffset;
|
|
17
|
+
}>;
|
|
18
|
+
/** Resolve visual state at the drawing boundary, preserving document cache keys. */
|
|
19
|
+
export declare const resolveElementRenderState: (element: ExcalidrawElement, elementsMap: ElementsMap, renderConfig: Pick<StaticCanvasRenderConfig, "elementRenderOverrides" | "elementsPendingErasure" | "pendingFlowchartNodes">, allElementsMap?: ElementsMap) => ElementRenderState;
|
|
7
20
|
export interface ExcalidrawElementWithCanvas {
|
|
8
21
|
element: ExcalidrawElement | ExcalidrawTextElement;
|
|
9
22
|
canvas: HTMLCanvasElement;
|
|
@@ -18,5 +31,9 @@ export interface ExcalidrawElementWithCanvas {
|
|
|
18
31
|
export declare const DEFAULT_LINK_SIZE = 14;
|
|
19
32
|
export declare const elementWithCanvasCache: WeakMap<ExcalidrawElement, ExcalidrawElementWithCanvas>;
|
|
20
33
|
export declare const renderSelectionElement: (element: NonDeletedExcalidrawElement, context: CanvasRenderingContext2D, appState: InteractiveCanvasAppState, selectionColor: InteractiveCanvasRenderConfig["selectionColor"]) => void;
|
|
21
|
-
export declare const renderElement: (element: NonDeletedExcalidrawElement, elementsMap: RenderableElementsMap, allElementsMap: NonDeletedSceneElementsMap, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState | InteractiveCanvasAppState
|
|
34
|
+
export declare const renderElement: (element: NonDeletedExcalidrawElement, elementsMap: RenderableElementsMap, allElementsMap: NonDeletedSceneElementsMap, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState | InteractiveCanvasAppState, renderState?: Readonly<{
|
|
35
|
+
/** Alpha including frame opacity and pending erasure; selection dimming is separate. */
|
|
36
|
+
opacity: number;
|
|
37
|
+
offset: RenderPositionOffset;
|
|
38
|
+
}>) => void;
|
|
22
39
|
export declare function getFreedrawOutlineAsSegments(element: ExcalidrawFreeDrawElement, points: [number, number][], elementsMap: ElementsMap): import("@excalidraw/math").LineSegment<GlobalPoint>[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type GeometricShape } from "@excalidraw/utils/shape";
|
|
2
2
|
import { type LocalPoint } from "@excalidraw/math";
|
|
3
|
-
import type { GlobalPoint } from "@excalidraw/math";
|
|
3
|
+
import type { GlobalPoint, Polygon } from "@excalidraw/math";
|
|
4
4
|
import type { AppState, EmbedsValidationStatus } from "@excalidraw/excalidraw/types";
|
|
5
5
|
import type { ElementShape, ElementShapes } from "@excalidraw/excalidraw/scene/types";
|
|
6
6
|
import type { ExcalidrawElement, ExcalidrawSelectionElement, ExcalidrawLinearElement, ExcalidrawFreeDrawElement, ElementsMap, ExcalidrawLineElement } from "./types";
|
|
@@ -27,6 +27,11 @@ export declare class ShapeCache {
|
|
|
27
27
|
} | null) => ((T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined) & {}) | (T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable | null);
|
|
28
28
|
}
|
|
29
29
|
export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean, isDarkMode?: boolean) => Options;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the flattened fill contour of a freedraw loop in local, unrotated
|
|
32
|
+
* coordinates, following the rendered fill rather than the stroke outline.
|
|
33
|
+
*/
|
|
34
|
+
export declare const getFreedrawFillPolygon: (element: ExcalidrawFreeDrawElement) => Polygon<LocalPoint>;
|
|
30
35
|
export declare const generateLinearCollisionShape: (element: ExcalidrawLinearElement | ExcalidrawFreeDrawElement, elementsMap: ElementsMap) => {
|
|
31
36
|
op: string;
|
|
32
37
|
data: number[];
|
|
@@ -41,6 +46,15 @@ export declare const toggleLinePolygonState: (element: ExcalidrawLineElement, ne
|
|
|
41
46
|
points: ExcalidrawLineElement["points"];
|
|
42
47
|
} | null;
|
|
43
48
|
export declare const getFreedrawOutlinePoints: (element: ExcalidrawFreeDrawElement) => [number, number][];
|
|
49
|
+
/**
|
|
50
|
+
* Upper bound on how far a freedraw stroke's ink reaches past its centerline
|
|
51
|
+
* points. Both stroke generators scale the stroke size by at most 1 (easing
|
|
52
|
+
* or pressure), so the size itself bounds the radius, except for
|
|
53
|
+
* perfect-freehand's short strokes: under 3px long, the start cap is drawn
|
|
54
|
+
* around the first point from an outline point of the last one (reaching
|
|
55
|
+
* sqrt(size² + 3²)), and a single point gets a synthetic neighbor 1px away.
|
|
56
|
+
*/
|
|
57
|
+
export declare const getFreedrawMaxStrokeRadius: (element: ExcalidrawFreeDrawElement) => number;
|
|
44
58
|
/**
|
|
45
59
|
* The streamline-smoothed centerline the freedraw stroke is rendered
|
|
46
60
|
* around, in element-local coordinates. Boundary-sensitive consumers (e.g.
|
|
@@ -29,6 +29,13 @@ export declare const getBoundTextElementPosition: (container: ExcalidrawElement,
|
|
|
29
29
|
x: number;
|
|
30
30
|
y: number;
|
|
31
31
|
} | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the text element with its accurate coords. An arrow label's
|
|
34
|
+
* position is derived from the arrow at render time rather than kept in
|
|
35
|
+
* sync on the element itself (see getBoundTextElementPosition), so
|
|
36
|
+
* consumers reading a label's coords directly must go through this helper.
|
|
37
|
+
*/
|
|
38
|
+
export declare const getTextElementWithAccuratePosition: <T extends ExcalidrawTextElement>(textElement: T, elementsMap: ElementsMap) => T;
|
|
32
39
|
export declare const shouldAllowVerticalAlign: (selectedElements: readonly ExcalidrawElement[], elementsMap: ElementsMap) => boolean;
|
|
33
40
|
export declare const suppportsHorizontalAlign: (selectedElements: readonly ExcalidrawElement[], elementsMap: ElementsMap) => boolean;
|
|
34
41
|
declare const VALID_CONTAINER_TYPES: Set<string>;
|
|
@@ -35,6 +35,13 @@ export declare const isPathALoop: (points: ExcalidrawLinearElement["points"],
|
|
|
35
35
|
/** supply if you want the loop detection to account for current zoom */
|
|
36
36
|
zoomValue?: Zoom["value"]) => boolean;
|
|
37
37
|
export declare const getCornerRadius: (x: number, element: ExcalidrawElement) => number;
|
|
38
|
-
export declare const
|
|
38
|
+
export declare const getAllMidpoints: (element: ExcalidrawBindableElement, elementsMap: ElementsMap) => GlobalPoint[];
|
|
39
|
+
export declare const getElbowArrowSnapMidPoint: (point: GlobalPoint, element: ExcalidrawBindableElement, elementsMap: ElementsMap, zoom: AppState["zoom"]) => {
|
|
40
|
+
point: GlobalPoint;
|
|
41
|
+
onAxis: boolean;
|
|
42
|
+
} | undefined;
|
|
43
|
+
export declare const getSnapOutlineMidPoint: (point: GlobalPoint, element: ExcalidrawBindableElement, elementsMap: ElementsMap, zoom: AppState["zoom"], arrow: {
|
|
44
|
+
elbowed: boolean;
|
|
45
|
+
}) => GlobalPoint | undefined;
|
|
39
46
|
export declare const projectFixedPointOntoDiagonal: (arrow: ExcalidrawArrowElement, point: GlobalPoint, element: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, zoom: AppState["zoom"], isMidpointSnappingEnabled?: boolean) => GlobalPoint | null;
|
|
40
47
|
export {};
|
|
@@ -6,7 +6,7 @@ import type { ExcalidrawArrowElement, ExcalidrawElement, NonDeletedExcalidrawEle
|
|
|
6
6
|
* Moves the arrow element above any bindable elements it intersects with or
|
|
7
7
|
* hovers over.
|
|
8
8
|
*/
|
|
9
|
-
export declare const moveArrowAboveBindable: (point: GlobalPoint, arrow: ExcalidrawArrowElement, elements: readonly OrderedExcalidrawElement[], elementsMap: NonDeletedSceneElementsMap, scene: Scene,
|
|
9
|
+
export declare const moveArrowAboveBindable: (point: GlobalPoint, arrow: ExcalidrawArrowElement, elements: readonly OrderedExcalidrawElement[], elementsMap: NonDeletedSceneElementsMap, scene: Scene, hoveredElement: NonDeletedExcalidrawElement) => readonly OrderedExcalidrawElement[];
|
|
10
10
|
export declare const moveOneLeft: (allElements: readonly ExcalidrawElement[], appState: AppState, scene: Scene) => readonly ExcalidrawElement[];
|
|
11
11
|
export declare const moveOneRight: (allElements: readonly ExcalidrawElement[], appState: AppState, scene: Scene) => readonly ExcalidrawElement[];
|
|
12
12
|
export declare const moveAllLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[] | ExcalidrawElement[];
|
|
@@ -29,12 +29,20 @@ export declare const actionAddToLibrary: {
|
|
|
29
29
|
boxSelectionMode: import("../types").BoxSelectionMode;
|
|
30
30
|
bindingPreference: "enabled" | "disabled";
|
|
31
31
|
isMidpointSnappingEnabled: boolean;
|
|
32
|
+
showHints: boolean;
|
|
32
33
|
inputDevice: import("../types").InputDevice;
|
|
33
34
|
suggestedBinding: {
|
|
34
35
|
element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
|
|
35
36
|
midPoint?: import("@excalidraw/math").GlobalPoint;
|
|
36
37
|
} | null;
|
|
37
|
-
|
|
38
|
+
textToolHover: {
|
|
39
|
+
type: "text";
|
|
40
|
+
elementId: import("@excalidraw/element/types").ExcalidrawElement["id"];
|
|
41
|
+
} | {
|
|
42
|
+
type: "container";
|
|
43
|
+
elementId: import("@excalidraw/element/types").ExcalidrawElement["id"];
|
|
44
|
+
} | {
|
|
45
|
+
type: "arrow";
|
|
38
46
|
elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
|
|
39
47
|
anchor: "start" | "end" | "label";
|
|
40
48
|
} | null;
|
|
@@ -173,6 +181,7 @@ export declare const actionAddToLibrary: {
|
|
|
173
181
|
stickyNoteStroke: readonly string[] | null;
|
|
174
182
|
stickyNoteBackground: readonly string[] | null;
|
|
175
183
|
};
|
|
184
|
+
fontTopPicks: readonly import("@excalidraw/element/types").FontFamilyValues[] | null;
|
|
176
185
|
};
|
|
177
186
|
} | {
|
|
178
187
|
captureUpdate: "EVENTUALLY";
|
|
@@ -197,12 +206,20 @@ export declare const actionAddToLibrary: {
|
|
|
197
206
|
boxSelectionMode: import("../types").BoxSelectionMode;
|
|
198
207
|
bindingPreference: "enabled" | "disabled";
|
|
199
208
|
isMidpointSnappingEnabled: boolean;
|
|
209
|
+
showHints: boolean;
|
|
200
210
|
inputDevice: import("../types").InputDevice;
|
|
201
211
|
suggestedBinding: {
|
|
202
212
|
element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
|
|
203
213
|
midPoint?: import("@excalidraw/math").GlobalPoint;
|
|
204
214
|
} | null;
|
|
205
|
-
|
|
215
|
+
textToolHover: {
|
|
216
|
+
type: "text";
|
|
217
|
+
elementId: import("@excalidraw/element/types").ExcalidrawElement["id"];
|
|
218
|
+
} | {
|
|
219
|
+
type: "container";
|
|
220
|
+
elementId: import("@excalidraw/element/types").ExcalidrawElement["id"];
|
|
221
|
+
} | {
|
|
222
|
+
type: "arrow";
|
|
206
223
|
elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
|
|
207
224
|
anchor: "start" | "end" | "label";
|
|
208
225
|
} | null;
|
|
@@ -346,6 +363,7 @@ export declare const actionAddToLibrary: {
|
|
|
346
363
|
stickyNoteStroke: readonly string[] | null;
|
|
347
364
|
stickyNoteBackground: readonly string[] | null;
|
|
348
365
|
};
|
|
366
|
+
fontTopPicks: readonly import("@excalidraw/element/types").FontFamilyValues[] | null;
|
|
349
367
|
};
|
|
350
368
|
}> | {
|
|
351
369
|
captureUpdate: "EVENTUALLY";
|
|
@@ -370,12 +388,20 @@ export declare const actionAddToLibrary: {
|
|
|
370
388
|
boxSelectionMode: import("../types").BoxSelectionMode;
|
|
371
389
|
bindingPreference: "enabled" | "disabled";
|
|
372
390
|
isMidpointSnappingEnabled: boolean;
|
|
391
|
+
showHints: boolean;
|
|
373
392
|
inputDevice: import("../types").InputDevice;
|
|
374
393
|
suggestedBinding: {
|
|
375
394
|
element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
|
|
376
395
|
midPoint?: import("@excalidraw/math").GlobalPoint;
|
|
377
396
|
} | null;
|
|
378
|
-
|
|
397
|
+
textToolHover: {
|
|
398
|
+
type: "text";
|
|
399
|
+
elementId: import("@excalidraw/element/types").ExcalidrawElement["id"];
|
|
400
|
+
} | {
|
|
401
|
+
type: "container";
|
|
402
|
+
elementId: import("@excalidraw/element/types").ExcalidrawElement["id"];
|
|
403
|
+
} | {
|
|
404
|
+
type: "arrow";
|
|
379
405
|
elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
|
|
380
406
|
anchor: "start" | "end" | "label";
|
|
381
407
|
} | null;
|
|
@@ -519,6 +545,7 @@ export declare const actionAddToLibrary: {
|
|
|
519
545
|
stickyNoteStroke: readonly string[] | null;
|
|
520
546
|
stickyNoteBackground: readonly string[] | null;
|
|
521
547
|
};
|
|
548
|
+
fontTopPicks: readonly import("@excalidraw/element/types").FontFamilyValues[] | null;
|
|
522
549
|
};
|
|
523
550
|
};
|
|
524
551
|
label: string;
|
|
@@ -49,12 +49,20 @@ export declare const actionBindText: {
|
|
|
49
49
|
boxSelectionMode: import("../types").BoxSelectionMode;
|
|
50
50
|
bindingPreference: "enabled" | "disabled";
|
|
51
51
|
isMidpointSnappingEnabled: boolean;
|
|
52
|
+
showHints: boolean;
|
|
52
53
|
inputDevice: import("../types").InputDevice;
|
|
53
54
|
suggestedBinding: {
|
|
54
55
|
element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
|
|
55
56
|
midPoint?: import("@excalidraw/math").GlobalPoint;
|
|
56
57
|
} | null;
|
|
57
|
-
|
|
58
|
+
textToolHover: {
|
|
59
|
+
type: "text";
|
|
60
|
+
elementId: ExcalidrawElement["id"];
|
|
61
|
+
} | {
|
|
62
|
+
type: "container";
|
|
63
|
+
elementId: ExcalidrawElement["id"];
|
|
64
|
+
} | {
|
|
65
|
+
type: "arrow";
|
|
58
66
|
elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
|
|
59
67
|
anchor: "start" | "end" | "label";
|
|
60
68
|
} | null;
|
|
@@ -195,6 +203,7 @@ export declare const actionBindText: {
|
|
|
195
203
|
stickyNoteStroke: readonly string[] | null;
|
|
196
204
|
stickyNoteBackground: readonly string[] | null;
|
|
197
205
|
};
|
|
206
|
+
fontTopPicks: readonly import("@excalidraw/element/types").FontFamilyValues[] | null;
|
|
198
207
|
};
|
|
199
208
|
captureUpdate: "IMMEDIATELY";
|
|
200
209
|
};
|
|
@@ -234,12 +243,20 @@ export declare const actionWrapTextInContainer: {
|
|
|
234
243
|
boxSelectionMode: import("../types").BoxSelectionMode;
|
|
235
244
|
bindingPreference: "enabled" | "disabled";
|
|
236
245
|
isMidpointSnappingEnabled: boolean;
|
|
246
|
+
showHints: boolean;
|
|
237
247
|
inputDevice: import("../types").InputDevice;
|
|
238
248
|
suggestedBinding: {
|
|
239
249
|
element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
|
|
240
250
|
midPoint?: import("@excalidraw/math").GlobalPoint;
|
|
241
251
|
} | null;
|
|
242
|
-
|
|
252
|
+
textToolHover: {
|
|
253
|
+
type: "text";
|
|
254
|
+
elementId: ExcalidrawElement["id"];
|
|
255
|
+
} | {
|
|
256
|
+
type: "container";
|
|
257
|
+
elementId: ExcalidrawElement["id"];
|
|
258
|
+
} | {
|
|
259
|
+
type: "arrow";
|
|
243
260
|
elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
|
|
244
261
|
anchor: "start" | "end" | "label";
|
|
245
262
|
} | null;
|
|
@@ -380,6 +397,7 @@ export declare const actionWrapTextInContainer: {
|
|
|
380
397
|
stickyNoteStroke: readonly string[] | null;
|
|
381
398
|
stickyNoteBackground: readonly string[] | null;
|
|
382
399
|
};
|
|
400
|
+
fontTopPicks: readonly import("@excalidraw/element/types").FontFamilyValues[] | null;
|
|
383
401
|
};
|
|
384
402
|
captureUpdate: "IMMEDIATELY";
|
|
385
403
|
};
|