@zsviczian/excalidraw 0.17.6-26 → 0.17.6-28
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 +118 -85
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +4 -2
- package/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
- package/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
- package/types/excalidraw/components/EyeDropper.d.ts +1 -1
- package/types/excalidraw/components/LibraryMenu.d.ts +1 -1
- package/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
- package/types/excalidraw/components/SearchMenu.d.ts +1 -1
- package/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
- package/types/excalidraw/context/tunnels.d.ts +2 -1
- package/types/excalidraw/data/library.d.ts +2 -2
- package/types/excalidraw/editor-jotai.d.ts +56 -0
- package/types/excalidraw/element/binding.d.ts +1 -1
- package/types/excalidraw/element/elbowArrow.d.ts +14 -0
- package/types/excalidraw/element/heading.d.ts +5 -1
- package/types/excalidraw/element/linearElementEditor.d.ts +9 -11
- package/types/excalidraw/element/mutateElement.d.ts +3 -1
- package/types/excalidraw/element/newElement.d.ts +8 -7
- package/types/excalidraw/element/resizeElements.d.ts +1 -2
- package/types/excalidraw/element/types.d.ts +22 -0
- package/types/excalidraw/frame.d.ts +8 -3
- package/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/types/excalidraw/visualdebug.d.ts +8 -1
- package/types/math/line.d.ts +19 -0
- package/types/math/point.d.ts +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zsviczian/excalidraw",
|
|
3
|
-
"version": "0.17.6-
|
|
3
|
+
"version": "0.17.6-28",
|
|
4
4
|
"main": "main.js",
|
|
5
5
|
"types": "types/excalidraw/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
"fractional-indexing": "3.2.0",
|
|
59
59
|
"fuzzy": "0.1.3",
|
|
60
60
|
"image-blob-reduce": "3.0.1",
|
|
61
|
-
"jotai": "
|
|
61
|
+
"jotai": "2.11.0",
|
|
62
|
+
"jotai-scope": "0.7.2",
|
|
62
63
|
"lodash.throttle": "4.1.1",
|
|
63
64
|
"nanoid": "3.3.3",
|
|
64
65
|
"open-color": "1.9.1",
|
|
@@ -104,6 +105,7 @@
|
|
|
104
105
|
"fonteditor-core": "2.4.1",
|
|
105
106
|
"harfbuzzjs": "0.3.6",
|
|
106
107
|
"import-meta-loader": "1.1.0",
|
|
108
|
+
"jest-diff": "29.7.0",
|
|
107
109
|
"mini-css-extract-plugin": "2.6.1",
|
|
108
110
|
"postcss-loader": "7.0.1",
|
|
109
111
|
"sass-loader": "13.0.2",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const activeConfirmDialogAtom: import("jotai").PrimitiveAtom<"clearCanvas" | null> & {
|
|
1
|
+
export declare const activeConfirmDialogAtom: import("jotai/vanilla/atom").PrimitiveAtom<"clearCanvas" | null> & {
|
|
2
2
|
init: "clearCanvas" | null;
|
|
3
3
|
};
|
|
4
4
|
export declare const ActiveConfirmDialog: () => JSX.Element | null;
|
|
@@ -14,7 +14,7 @@ export declare const isCustomColor: ({ color, palette, }: {
|
|
|
14
14
|
}) => boolean;
|
|
15
15
|
export declare const getMostUsedCustomColors: (elements: readonly ExcalidrawElement[], type: "elementBackground" | "elementStroke", palette: ColorPaletteCustom) => string[];
|
|
16
16
|
export type ActiveColorPickerSectionAtomType = "custom" | "baseColors" | "shades" | "hex" | null;
|
|
17
|
-
export declare const activeColorPickerSectionAtom: import("jotai").PrimitiveAtom<ActiveColorPickerSectionAtomType> & {
|
|
17
|
+
export declare const activeColorPickerSectionAtom: import("jotai/vanilla/atom").PrimitiveAtom<ActiveColorPickerSectionAtomType> & {
|
|
18
18
|
init: ActiveColorPickerSectionAtomType;
|
|
19
19
|
};
|
|
20
20
|
export declare const getContrastYIQ: (bgHex: string, isCustomColor: boolean) => "white" | "black";
|
|
@@ -13,7 +13,7 @@ export type EyeDropperProperties = {
|
|
|
13
13
|
**/
|
|
14
14
|
colorPickerType: ColorPickerType;
|
|
15
15
|
};
|
|
16
|
-
export declare const activeEyeDropperAtom: import("jotai").PrimitiveAtom<EyeDropperProperties | null> & {
|
|
16
|
+
export declare const activeEyeDropperAtom: import("jotai/vanilla/atom").PrimitiveAtom<EyeDropperProperties | null> & {
|
|
17
17
|
init: EyeDropperProperties | null;
|
|
18
18
|
};
|
|
19
19
|
export declare const EyeDropper: React.FC<{
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import type Library from "../data/library";
|
|
3
3
|
import type { LibraryItems, LibraryItem, ExcalidrawProps, UIAppState } from "../types";
|
|
4
4
|
import "./LibraryMenu.scss";
|
|
5
|
-
export declare const isLibraryMenuOpenAtom: import("jotai").PrimitiveAtom<boolean> & {
|
|
5
|
+
export declare const isLibraryMenuOpenAtom: import("jotai/vanilla/atom").PrimitiveAtom<boolean> & {
|
|
6
6
|
init: boolean;
|
|
7
7
|
};
|
|
8
8
|
export declare const LibraryMenuContent: ({ onInsertLibraryItems, pendingElements, onAddToLibrary, setAppState, libraryReturnUrl, library, id, theme, selectedItems, onSelectItems, }: {
|
|
@@ -11,7 +11,7 @@ export type OverwriteConfirmState = {
|
|
|
11
11
|
} | {
|
|
12
12
|
active: false;
|
|
13
13
|
};
|
|
14
|
-
export declare const overwriteConfirmStateAtom: import("jotai").PrimitiveAtom<OverwriteConfirmState> & {
|
|
14
|
+
export declare const overwriteConfirmStateAtom: import("jotai/vanilla/atom").PrimitiveAtom<OverwriteConfirmState> & {
|
|
15
15
|
init: OverwriteConfirmState;
|
|
16
16
|
};
|
|
17
17
|
export declare function openConfirmModal({ title, description, actionLabel, color, }: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./SearchMenu.scss";
|
|
2
|
-
export declare const searchItemInFocusAtom: import("jotai").PrimitiveAtom<number | null> & {
|
|
2
|
+
export declare const searchItemInFocusAtom: import("jotai/vanilla/atom").PrimitiveAtom<number | null> & {
|
|
3
3
|
init: number | null;
|
|
4
4
|
};
|
|
5
5
|
export declare const SearchMenu: () => JSX.Element;
|
|
@@ -8,7 +8,7 @@ import "./Sidebar.scss";
|
|
|
8
8
|
*
|
|
9
9
|
* Since we can only render one Sidebar at a time, we can use a simple flag.
|
|
10
10
|
*/
|
|
11
|
-
export declare const isSidebarDockedAtom: import("jotai").PrimitiveAtom<boolean> & {
|
|
11
|
+
export declare const isSidebarDockedAtom: import("jotai/vanilla/atom").PrimitiveAtom<boolean> & {
|
|
12
12
|
init: boolean;
|
|
13
13
|
};
|
|
14
14
|
export declare const SidebarInner: React.ForwardRefExoticComponent<Omit<{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import tunnel from "tunnel-rat";
|
|
3
|
+
import { createIsolation } from "jotai-scope";
|
|
3
4
|
export type Tunnel = ReturnType<typeof tunnel>;
|
|
4
5
|
type TunnelsContextValue = {
|
|
5
6
|
MainMenuTunnel: Tunnel;
|
|
@@ -12,7 +13,7 @@ type TunnelsContextValue = {
|
|
|
12
13
|
DefaultSidebarTabTriggersTunnel: Tunnel;
|
|
13
14
|
OverwriteConfirmDialogTunnel: Tunnel;
|
|
14
15
|
TTDDialogTriggerTunnel: Tunnel;
|
|
15
|
-
|
|
16
|
+
tunnelsJotai: ReturnType<typeof createIsolation>;
|
|
16
17
|
};
|
|
17
18
|
export declare const TunnelsContext: React.Context<TunnelsContextValue>;
|
|
18
19
|
export declare const useTunnels: () => TunnelsContextValue;
|
|
@@ -37,7 +37,7 @@ export interface LibraryMigrationAdapter {
|
|
|
37
37
|
/** clears entire storage afterwards */
|
|
38
38
|
clear(): MaybePromise<void>;
|
|
39
39
|
}
|
|
40
|
-
export declare const libraryItemsAtom: import("jotai").PrimitiveAtom<{
|
|
40
|
+
export declare const libraryItemsAtom: import("jotai/vanilla/atom").PrimitiveAtom<{
|
|
41
41
|
status: "loading" | "loaded";
|
|
42
42
|
/** indicates whether library is initialized with library items (has gone
|
|
43
43
|
* through at least one update). Used in UI. Specific to this atom only. */
|
|
@@ -83,7 +83,7 @@ declare class Library {
|
|
|
83
83
|
}
|
|
84
84
|
export default Library;
|
|
85
85
|
export declare const distributeLibraryItemsOnSquareGrid: (libraryItems: LibraryItems) => ExcalidrawElement[];
|
|
86
|
-
declare const validateLibraryUrl: (libraryUrl: string, validator?: ((libraryUrl: string) => boolean)
|
|
86
|
+
export declare const validateLibraryUrl: (libraryUrl: string, validator?: string[] | ((libraryUrl: string) => boolean)) => true;
|
|
87
87
|
export declare const parseLibraryTokensFromUrl: () => {
|
|
88
88
|
libraryUrl: string;
|
|
89
89
|
idToken: string | null;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { atom, createStore, type PrimitiveAtom } from "jotai";
|
|
2
|
+
import { createIsolation } from "jotai-scope";
|
|
3
|
+
export { atom, PrimitiveAtom };
|
|
4
|
+
export declare const useAtom: typeof import("jotai").useAtom, useSetAtom: typeof import("jotai").useSetAtom, useAtomValue: typeof import("jotai").useAtomValue, useStore: (options?: {
|
|
5
|
+
store?: {
|
|
6
|
+
get: <Value>(atom: import("jotai").Atom<Value>) => Value;
|
|
7
|
+
set: <Value_1, Args extends unknown[], Result>(atom: import("jotai").WritableAtom<Value_1, Args, Result>, ...args: Args) => Result;
|
|
8
|
+
sub: (atom: import("jotai").Atom<unknown>, listener: () => void) => () => void;
|
|
9
|
+
} | ({
|
|
10
|
+
get: <Value_2>(atom: import("jotai").Atom<Value_2>) => Value_2;
|
|
11
|
+
set: <Value_1_1, Args_1 extends unknown[], Result_1>(atom: import("jotai").WritableAtom<Value_1_1, Args_1, Result_1>, ...args: Args_1) => Result_1;
|
|
12
|
+
sub: (atom: import("jotai").Atom<unknown>, listener: () => void) => () => void;
|
|
13
|
+
} & {
|
|
14
|
+
dev4_get_internal_weak_map: () => WeakMap<import("jotai").Atom<unknown>, {
|
|
15
|
+
readonly d: Map<import("jotai").Atom<unknown>, number>;
|
|
16
|
+
readonly p: Set<import("jotai").Atom<unknown>>;
|
|
17
|
+
n: number;
|
|
18
|
+
m?: {
|
|
19
|
+
readonly l: Set<() => void>;
|
|
20
|
+
readonly d: Set<import("jotai").Atom<unknown>>;
|
|
21
|
+
readonly t: Set<import("jotai").Atom<unknown>>;
|
|
22
|
+
u?: (() => void) | undefined;
|
|
23
|
+
} | undefined;
|
|
24
|
+
v?: unknown;
|
|
25
|
+
e?: unknown;
|
|
26
|
+
}>;
|
|
27
|
+
dev4_get_mounted_atoms: () => Set<import("jotai").Atom<unknown>>;
|
|
28
|
+
dev4_restore_atoms: (values: Iterable<readonly [import("jotai").Atom<unknown>, unknown]>) => void;
|
|
29
|
+
}) | undefined;
|
|
30
|
+
} | undefined) => {
|
|
31
|
+
get: <Value_3>(atom: import("jotai").Atom<Value_3>) => Value_3;
|
|
32
|
+
set: <Value_1_2, Args_2 extends unknown[], Result_2>(atom: import("jotai").WritableAtom<Value_1_2, Args_2, Result_2>, ...args: Args_2) => Result_2;
|
|
33
|
+
sub: (atom: import("jotai").Atom<unknown>, listener: () => void) => () => void;
|
|
34
|
+
} | ({
|
|
35
|
+
get: <Value_4>(atom: import("jotai").Atom<Value_4>) => Value_4;
|
|
36
|
+
set: <Value_1_3, Args_3 extends unknown[], Result_3>(atom: import("jotai").WritableAtom<Value_1_3, Args_3, Result_3>, ...args: Args_3) => Result_3;
|
|
37
|
+
sub: (atom: import("jotai").Atom<unknown>, listener: () => void) => () => void;
|
|
38
|
+
} & {
|
|
39
|
+
dev4_get_internal_weak_map: () => WeakMap<import("jotai").Atom<unknown>, {
|
|
40
|
+
readonly d: Map<import("jotai").Atom<unknown>, number>;
|
|
41
|
+
readonly p: Set<import("jotai").Atom<unknown>>;
|
|
42
|
+
n: number;
|
|
43
|
+
m?: {
|
|
44
|
+
readonly l: Set<() => void>;
|
|
45
|
+
readonly d: Set<import("jotai").Atom<unknown>>;
|
|
46
|
+
readonly t: Set<import("jotai").Atom<unknown>>;
|
|
47
|
+
u?: (() => void) | undefined;
|
|
48
|
+
} | undefined;
|
|
49
|
+
v?: unknown;
|
|
50
|
+
e?: unknown;
|
|
51
|
+
}>;
|
|
52
|
+
dev4_get_mounted_atoms: () => Set<import("jotai").Atom<unknown>>;
|
|
53
|
+
dev4_restore_atoms: (values: Iterable<readonly [import("jotai").Atom<unknown>, unknown]>) => void;
|
|
54
|
+
});
|
|
55
|
+
export declare const EditorJotaiProvider: ReturnType<typeof createIsolation>["Provider"];
|
|
56
|
+
export declare const editorJotaiStore: ReturnType<typeof createStore>;
|
|
@@ -37,7 +37,6 @@ export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawE
|
|
|
37
37
|
height: number;
|
|
38
38
|
};
|
|
39
39
|
changedElements?: Map<string, OrderedExcalidrawElement>;
|
|
40
|
-
zoom?: AppState["zoom"];
|
|
41
40
|
}) => void;
|
|
42
41
|
export declare const getHeadingForElbowArrowSnap: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined | null, aabb: Bounds | undefined | null, elementsMap: ElementsMap, origPoint: GlobalPoint, zoom?: AppState["zoom"]) => Heading;
|
|
43
42
|
export declare const bindPointToSnapToElementOutline: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined, elementsMap: ElementsMap) => GlobalPoint;
|
|
@@ -98,5 +97,6 @@ export declare class BindableElement {
|
|
|
98
97
|
static rebindAffected: (elements: ElementsMap, bindableElement: ExcalidrawElement | undefined, updateElementWith: (affected: ExcalidrawElement, updates: ElementUpdate<ExcalidrawElement>) => void) => void;
|
|
99
98
|
}
|
|
100
99
|
export declare const getGlobalFixedPointForBindableElement: (fixedPointRatio: [number, number], element: ExcalidrawBindableElement) => GlobalPoint;
|
|
100
|
+
export declare const getGlobalFixedPoints: (arrow: ExcalidrawElbowArrowElement, elementsMap: ElementsMap) => [GlobalPoint, GlobalPoint];
|
|
101
101
|
export declare const getArrowLocalFixedPoints: (arrow: ExcalidrawElbowArrowElement, elementsMap: ElementsMap) => LocalPoint[];
|
|
102
102
|
export declare const normalizeFixedPoint: <T extends FixedPoint | null>(fixedPoint: T) => T extends null ? null : FixedPoint;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type LocalPoint } from "../../math";
|
|
2
|
+
import { type ElementUpdate } from "./mutateElement";
|
|
3
|
+
import { type ExcalidrawElbowArrowElement, type NonDeletedSceneElementsMap, type SceneElementsMap } from "./types";
|
|
4
|
+
import type { FixedSegment } from "./types";
|
|
5
|
+
export declare const BASE_PADDING = 40;
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export declare const updateElbowArrowPoints: (arrow: Readonly<ExcalidrawElbowArrowElement>, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap, updates: {
|
|
10
|
+
points?: readonly LocalPoint[];
|
|
11
|
+
fixedSegments?: FixedSegment[] | null;
|
|
12
|
+
}, options?: {
|
|
13
|
+
isDragging?: boolean;
|
|
14
|
+
}) => ElementUpdate<ExcalidrawElbowArrowElement>;
|
|
@@ -7,6 +7,10 @@ export declare const HEADING_UP: Heading;
|
|
|
7
7
|
export type Heading = [1, 0] | [0, 1] | [-1, 0] | [0, -1];
|
|
8
8
|
export declare const headingForDiamond: <Point extends GlobalPoint | LocalPoint>(a: Point, b: Point) => Heading;
|
|
9
9
|
export declare const vectorToHeading: (vec: Vector) => Heading;
|
|
10
|
+
export declare const headingForPoint: <P extends GlobalPoint | LocalPoint>(p: P, o: P) => Heading;
|
|
11
|
+
export declare const headingForPointIsHorizontal: <P extends GlobalPoint | LocalPoint>(p: P, o: P) => boolean;
|
|
10
12
|
export declare const compareHeading: (a: Heading, b: Heading) => boolean;
|
|
11
|
-
export declare const
|
|
13
|
+
export declare const headingIsHorizontal: (a: Heading) => boolean;
|
|
14
|
+
export declare const headingIsVertical: (a: Heading) => boolean;
|
|
15
|
+
export declare const headingForPointFromElement: <Point extends GlobalPoint | LocalPoint>(element: Readonly<ExcalidrawBindableElement>, aabb: readonly [minX: number, minY: number, maxX: number, maxY: number], p: Readonly<Point>) => Heading;
|
|
12
16
|
export declare const flipHeading: (h: Heading) => Heading;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap,
|
|
1
|
+
import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, SceneElementsMap, ExcalidrawElbowArrowElement } from "./types";
|
|
2
2
|
import type { Bounds } from "./bounds";
|
|
3
|
-
import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize } from "../types";
|
|
3
|
+
import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize, Zoom } from "../types";
|
|
4
4
|
import type { Store } from "../store";
|
|
5
5
|
import type Scene from "../scene/Scene";
|
|
6
6
|
import { type GlobalPoint, type LocalPoint } from "../../math";
|
|
@@ -48,7 +48,7 @@ export declare class LinearElementEditor {
|
|
|
48
48
|
* @param id the `elementId` from the instance of this class (so that we can
|
|
49
49
|
* statically guarantee this method returns an ExcalidrawLinearElement)
|
|
50
50
|
*/
|
|
51
|
-
static getElement(id: InstanceType<typeof LinearElementEditor>["elementId"], elementsMap: ElementsMap):
|
|
51
|
+
static getElement<T extends ExcalidrawLinearElement>(id: InstanceType<typeof LinearElementEditor>["elementId"], elementsMap: ElementsMap): T | null;
|
|
52
52
|
static handleBoxSelection(event: PointerEvent, appState: AppState, setState: React.Component<any, AppState>["setState"], elementsMap: NonDeletedSceneElementsMap): false | undefined;
|
|
53
53
|
/** @returns whether point was dragged */
|
|
54
54
|
static handlePointDragging(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, maybeSuggestBinding: (element: NonDeleted<ExcalidrawLinearElement>, pointSceneCoords: {
|
|
@@ -62,7 +62,7 @@ export declare class LinearElementEditor {
|
|
|
62
62
|
x: number;
|
|
63
63
|
y: number;
|
|
64
64
|
}, appState: AppState, elementsMap: ElementsMap) => GlobalPoint | null;
|
|
65
|
-
static isSegmentTooShort(element: NonDeleted<ExcalidrawLinearElement>, startPoint:
|
|
65
|
+
static isSegmentTooShort<P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, startPoint: P, endPoint: P, index: number, zoom: Zoom): boolean;
|
|
66
66
|
static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: GlobalPoint, endPoint: GlobalPoint, endPointIndex: number, elementsMap: ElementsMap): GlobalPoint;
|
|
67
67
|
static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: GlobalPoint, elementsMap: ElementsMap): number;
|
|
68
68
|
static handlePointerDown(event: React.PointerEvent<HTMLElement>, app: AppClassProperties, store: Store, scenePointer: {
|
|
@@ -96,21 +96,17 @@ export declare class LinearElementEditor {
|
|
|
96
96
|
};
|
|
97
97
|
static normalizePoints(element: NonDeleted<ExcalidrawLinearElement>): void;
|
|
98
98
|
static duplicateSelectedPoints(appState: AppState, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap): AppState;
|
|
99
|
-
static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, pointIndices: readonly number[]
|
|
99
|
+
static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, pointIndices: readonly number[]): void;
|
|
100
100
|
static addPoints(element: NonDeleted<ExcalidrawLinearElement>, targetPoints: {
|
|
101
101
|
point: LocalPoint;
|
|
102
|
-
}[]
|
|
102
|
+
}[]): void;
|
|
103
103
|
static movePoints(element: NonDeleted<ExcalidrawLinearElement>, targetPoints: {
|
|
104
104
|
index: number;
|
|
105
105
|
point: LocalPoint;
|
|
106
106
|
isDragging?: boolean;
|
|
107
|
-
}[],
|
|
107
|
+
}[], otherUpdates?: {
|
|
108
108
|
startBinding?: PointBinding | null;
|
|
109
109
|
endBinding?: PointBinding | null;
|
|
110
|
-
}, options?: {
|
|
111
|
-
changedElements?: Map<string, OrderedExcalidrawElement>;
|
|
112
|
-
isDragging?: boolean;
|
|
113
|
-
zoom?: AppState["zoom"];
|
|
114
110
|
}): void;
|
|
115
111
|
static shouldAddMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState, elementsMap: ElementsMap): boolean;
|
|
116
112
|
static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, app: AppClassProperties, snapToGrid: boolean, elementsMap: ElementsMap): {
|
|
@@ -125,5 +121,7 @@ export declare class LinearElementEditor {
|
|
|
125
121
|
};
|
|
126
122
|
static getMinMaxXYWithBoundText: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, elementBounds: Bounds, boundTextElement: ExcalidrawTextElementWithContainer) => [number, number, number, number, number, number];
|
|
127
123
|
static getElementAbsoluteCoords: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
|
|
124
|
+
static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number, elementsMap: ElementsMap): LinearElementEditor;
|
|
125
|
+
static deleteFixedSegment(element: ExcalidrawElbowArrowElement, index: number): void;
|
|
128
126
|
}
|
|
129
127
|
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ExcalidrawElement } from "./types";
|
|
2
2
|
import type { Mutable } from "../utility-types";
|
|
3
3
|
export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce" | "updated">;
|
|
4
|
-
export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean
|
|
4
|
+
export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean, options?: {
|
|
5
|
+
isDragging?: boolean;
|
|
6
|
+
}) => TElement;
|
|
5
7
|
export declare const newElementWith: <TElement extends ExcalidrawElement>(element: TElement, updates: ElementUpdate<TElement>, force?: boolean) => TElement;
|
|
6
8
|
/**
|
|
7
9
|
* Mutates element, bumping `version`, `versionNonce`, and `updated`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement } from "./types";
|
|
1
|
+
import type { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement, FixedSegment, ExcalidrawElbowArrowElement } from "./types";
|
|
2
2
|
import type { AppState } from "../types";
|
|
3
3
|
import type { MarkOptional, Mutable } from "../utility-types";
|
|
4
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">;
|
|
@@ -46,13 +46,14 @@ export declare const newLinearElement: (opts: {
|
|
|
46
46
|
type: ExcalidrawLinearElement["type"];
|
|
47
47
|
points?: ExcalidrawLinearElement["points"];
|
|
48
48
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawLinearElement>;
|
|
49
|
-
export declare const newArrowElement: (opts: {
|
|
49
|
+
export declare const newArrowElement: <T extends boolean>(opts: {
|
|
50
50
|
type: ExcalidrawArrowElement["type"];
|
|
51
|
-
startArrowhead?: Arrowhead | null;
|
|
52
|
-
endArrowhead?: Arrowhead | null;
|
|
53
|
-
points?:
|
|
54
|
-
elbowed?:
|
|
55
|
-
|
|
51
|
+
startArrowhead?: Arrowhead | null | undefined;
|
|
52
|
+
endArrowhead?: Arrowhead | null | undefined;
|
|
53
|
+
points?: readonly import("../../math").LocalPoint[] | undefined;
|
|
54
|
+
elbowed?: T | undefined;
|
|
55
|
+
fixedSegments?: FixedSegment[] | null | undefined;
|
|
56
|
+
} & Omit<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "angle" | "link" | "width" | "height" | "backgroundColor" | "strokeColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData"> & Partial<Pick<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "angle" | "link" | "width" | "height" | "backgroundColor" | "strokeColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData">>) => T extends true ? NonDeleted<ExcalidrawElbowArrowElement> : NonDeleted<ExcalidrawArrowElement>;
|
|
56
57
|
export declare const newImageElement: (opts: {
|
|
57
58
|
type: ExcalidrawImageElement["type"];
|
|
58
59
|
status?: ExcalidrawImageElement["status"];
|
|
@@ -27,13 +27,12 @@ export declare const getNextSingleWidthAndHeightFromPointer: (latestElement: Exc
|
|
|
27
27
|
nextWidth: number;
|
|
28
28
|
nextHeight: number;
|
|
29
29
|
};
|
|
30
|
-
export declare const resizeMultipleElements: (selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: ElementsMap, handleDirection: TransformHandleDirection, scene: Scene, { shouldMaintainAspectRatio, shouldResizeFromCenter, flipByX, flipByY, nextHeight, nextWidth,
|
|
30
|
+
export declare const resizeMultipleElements: (selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: ElementsMap, handleDirection: TransformHandleDirection, scene: Scene, originalElementsMap: ElementsMap, { shouldMaintainAspectRatio, shouldResizeFromCenter, flipByX, flipByY, nextHeight, nextWidth, originalBoundingBox, }?: {
|
|
31
31
|
nextWidth?: number | undefined;
|
|
32
32
|
nextHeight?: number | undefined;
|
|
33
33
|
shouldMaintainAspectRatio?: boolean | undefined;
|
|
34
34
|
shouldResizeFromCenter?: boolean | undefined;
|
|
35
35
|
flipByX?: boolean | undefined;
|
|
36
36
|
flipByY?: boolean | undefined;
|
|
37
|
-
originalElementsMap?: ElementsMap | undefined;
|
|
38
37
|
originalBoundingBox?: BoundingBox | undefined;
|
|
39
38
|
}) => void;
|
|
@@ -218,6 +218,11 @@ export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
|
|
|
218
218
|
startArrowhead: Arrowhead | null;
|
|
219
219
|
endArrowhead: Arrowhead | null;
|
|
220
220
|
}>;
|
|
221
|
+
export type FixedSegment = {
|
|
222
|
+
start: LocalPoint;
|
|
223
|
+
end: LocalPoint;
|
|
224
|
+
index: number;
|
|
225
|
+
};
|
|
221
226
|
export type ExcalidrawArrowElement = ExcalidrawLinearElement & Readonly<{
|
|
222
227
|
type: "arrow";
|
|
223
228
|
elbowed: boolean;
|
|
@@ -226,6 +231,23 @@ export type ExcalidrawElbowArrowElement = Merge<ExcalidrawArrowElement, {
|
|
|
226
231
|
elbowed: true;
|
|
227
232
|
startBinding: FixedPointBinding | null;
|
|
228
233
|
endBinding: FixedPointBinding | null;
|
|
234
|
+
fixedSegments: FixedSegment[] | null;
|
|
235
|
+
/**
|
|
236
|
+
* Marks that the 3rd point should be used as the 2nd point of the arrow in
|
|
237
|
+
* order to temporarily hide the first segment of the arrow without losing
|
|
238
|
+
* the data from the points array. It allows creating the expected arrow
|
|
239
|
+
* path when the arrow with fixed segments is bound on a horizontal side and
|
|
240
|
+
* moved to a vertical and vica versa.
|
|
241
|
+
*/
|
|
242
|
+
startIsSpecial: boolean | null;
|
|
243
|
+
/**
|
|
244
|
+
* Marks that the 3rd point backwards from the end should be used as the 2nd
|
|
245
|
+
* point of the arrow in order to temporarily hide the last segment of the
|
|
246
|
+
* arrow without losing the data from the points array. It allows creating
|
|
247
|
+
* the expected arrow path when the arrow with fixed segments is bound on a
|
|
248
|
+
* horizontal side and moved to a vertical and vica versa.
|
|
249
|
+
*/
|
|
250
|
+
endIsSpecial: boolean | null;
|
|
229
251
|
}>;
|
|
230
252
|
export type ExcalidrawFreeDrawElement = _ExcalidrawElementBase & Readonly<{
|
|
231
253
|
type: "freedraw";
|
|
@@ -5,7 +5,7 @@ import type { ReadonlySetLike } from "./utility-types";
|
|
|
5
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
|
-
export declare const isElementContainingFrame: (
|
|
8
|
+
export declare const isElementContainingFrame: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => boolean;
|
|
9
9
|
export declare const getElementsIntersectingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
|
|
10
10
|
export declare const elementsAreInFrameBounds: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => boolean;
|
|
11
11
|
export declare const elementOverlapsWithFrame: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => boolean;
|
|
@@ -31,7 +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) =>
|
|
34
|
+
export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./element/types").ExcalidrawSelectionElement | import("./element/types").ExcalidrawRectangleElement | import("./element/types").ExcalidrawDiamondElement | import("./element/types").ExcalidrawEllipseElement | import("./element/types").ExcalidrawTextElement | import("./element/types").ExcalidrawLinearElement | import("./element/types").ExcalidrawFreeDrawElement | import("./element/types").ExcalidrawImageElement | import("./element/types").ExcalidrawFrameElement | import("./element/types").ExcalidrawMagicFrameElement | import("./element/types").ExcalidrawIframeElement | import("./element/types").ExcalidrawEmbeddableElement)[];
|
|
35
|
+
export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./element/types").ExcalidrawSelectionElement | import("./element/types").ExcalidrawRectangleElement | import("./element/types").ExcalidrawDiamondElement | import("./element/types").ExcalidrawEllipseElement | import("./element/types").ExcalidrawTextElement | import("./element/types").ExcalidrawLinearElement | import("./element/types").ExcalidrawFreeDrawElement | import("./element/types").ExcalidrawImageElement | import("./element/types").ExcalidrawFrameElement | import("./element/types").ExcalidrawMagicFrameElement | import("./element/types").ExcalidrawIframeElement | import("./element/types").ExcalidrawEmbeddableElement)[];
|
|
35
36
|
export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap: ElementsMap) => ExcalidrawFrameLikeElement | null;
|
|
36
37
|
/** */
|
|
37
38
|
export declare const filterElementsEligibleAsFrameChildren: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
|
|
@@ -58,6 +59,10 @@ export declare const omitGroupsContainingFrameLikes: (allElements: ElementsMapOr
|
|
|
58
59
|
* is going to be added to or remove from
|
|
59
60
|
*/
|
|
60
61
|
export declare const getTargetFrame: (element: ExcalidrawElement, elementsMap: ElementsMap, appState: StaticCanvasAppState) => import("./element/types").ExcalidrawFrameElement | import("./element/types").ExcalidrawMagicFrameElement | null;
|
|
61
|
-
export declare const isElementInFrame: (element: ExcalidrawElement, allElementsMap: ElementsMap, appState: StaticCanvasAppState
|
|
62
|
+
export declare const isElementInFrame: (element: ExcalidrawElement, allElementsMap: ElementsMap, appState: StaticCanvasAppState, opts?: {
|
|
63
|
+
targetFrame?: ExcalidrawFrameLikeElement;
|
|
64
|
+
checkedGroups?: Map<string, boolean>;
|
|
65
|
+
}) => boolean;
|
|
66
|
+
export declare const shouldApplyFrameClip: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, appState: StaticCanvasAppState, elementsMap: ElementsMap, checkedGroups?: Map<string, boolean>) => boolean;
|
|
62
67
|
export declare const getFrameLikeTitle: (element: ExcalidrawFrameLikeElement) => string;
|
|
63
68
|
export declare const getElementsOverlappingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => NonDeletedExcalidrawElement[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LibraryItem } from "../types";
|
|
2
2
|
export type SvgCache = Map<LibraryItem["id"], SVGSVGElement>;
|
|
3
|
-
export declare const libraryItemSvgsCache: import("jotai").PrimitiveAtom<SvgCache> & {
|
|
3
|
+
export declare const libraryItemSvgsCache: import("jotai/vanilla/atom").PrimitiveAtom<SvgCache> & {
|
|
4
4
|
init: SvgCache;
|
|
5
5
|
};
|
|
6
6
|
export declare const useLibraryItemSvg: (id: LibraryItem["id"] | null, elements: LibraryItem["elements"] | undefined, svgCache: SvgCache) => SVGSVGElement | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type GlobalPoint } from "../math";
|
|
1
|
+
import { type GlobalPoint, type LocalPoint } from "../math";
|
|
2
2
|
import type { LineSegment } from "../utils";
|
|
3
3
|
import type { BoundingBox, Bounds } from "./element/bounds";
|
|
4
4
|
declare global {
|
|
@@ -7,6 +7,8 @@ declare global {
|
|
|
7
7
|
data: DebugElement[][];
|
|
8
8
|
currentFrame?: number;
|
|
9
9
|
};
|
|
10
|
+
debugDrawPoint: typeof debugDrawPoint;
|
|
11
|
+
debugDrawLine: typeof debugDrawLine;
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
export type DebugElement = {
|
|
@@ -31,5 +33,10 @@ export declare const debugDrawBounds: (box: Bounds | Bounds[], opts?: {
|
|
|
31
33
|
color?: string;
|
|
32
34
|
permanent?: boolean;
|
|
33
35
|
}) => void;
|
|
36
|
+
export declare const debugDrawPoints: ({ x, y, points, }: {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
points: LocalPoint[];
|
|
40
|
+
}, options?: any) => void;
|
|
34
41
|
export declare const debugCloseFrame: () => void;
|
|
35
42
|
export declare const debugClear: () => void;
|
package/types/math/line.d.ts
CHANGED
|
@@ -23,4 +23,23 @@ export declare function lineFromPointPair<P extends GlobalPoint | LocalPoint>([a
|
|
|
23
23
|
* @returns
|
|
24
24
|
*/
|
|
25
25
|
export declare function lineFromPointArray<P extends GlobalPoint | LocalPoint>(pointArray: P[]): Line<P> | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Return the coordinates resulting from rotating the given line about an
|
|
28
|
+
* origin by an angle in degrees note that when the origin is not given,
|
|
29
|
+
* the midpoint of the given line is used as the origin
|
|
30
|
+
*
|
|
31
|
+
* @param l
|
|
32
|
+
* @param angle
|
|
33
|
+
* @param origin
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
26
36
|
export declare const lineRotate: <Point extends GlobalPoint | LocalPoint>(l: Line<Point>, angle: Radians, origin?: Point | undefined) => Line<Point>;
|
|
37
|
+
/**
|
|
38
|
+
* Determines the intersection point (unless the lines are parallel) of two
|
|
39
|
+
* lines
|
|
40
|
+
*
|
|
41
|
+
* @param a
|
|
42
|
+
* @param b
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
export declare const linesIntersectAt: <Point extends GlobalPoint | LocalPoint>(a: Line<Point>, b: Line<Point>) => Point | null;
|
package/types/math/point.d.ts
CHANGED
|
@@ -28,6 +28,16 @@ export declare function pointFromPair<Point extends GlobalPoint | LocalPoint>(pa
|
|
|
28
28
|
* @returns The point the vector points at with origin 0,0
|
|
29
29
|
*/
|
|
30
30
|
export declare function pointFromVector<P extends GlobalPoint | LocalPoint>(v: Vector): P;
|
|
31
|
+
/**
|
|
32
|
+
* Convert the coordiante object to a point.
|
|
33
|
+
*
|
|
34
|
+
* @param coords The coordinate object with x and y properties
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export declare function pointFromCoords<Point extends GlobalPoint | LocalPoint>({ x, y, }: {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
}): Point;
|
|
31
41
|
/**
|
|
32
42
|
* Checks if the provided value has the shape of a Point.
|
|
33
43
|
*
|