@excalidraw/excalidraw 0.16.1-4765f55 → 0.16.1-4c35eba
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 +51 -18
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +1 -1
- package/types/actions/actionAddToLibrary.d.ts +18 -0
- package/types/actions/actionBoundText.d.ts +12 -0
- package/types/actions/actionCanvas.d.ts +66 -0
- package/types/actions/actionClipboard.d.ts +30 -0
- package/types/actions/actionDeleteSelected.d.ts +18 -0
- package/types/actions/actionElementLock.d.ts +12 -0
- package/types/actions/actionExport.d.ts +54 -0
- package/types/actions/actionFinalize.d.ts +12 -0
- package/types/actions/actionFrame.d.ts +18 -0
- package/types/actions/actionGroup.d.ts +12 -0
- package/types/actions/actionLinearEditor.d.ts +6 -0
- package/types/actions/actionMenu.d.ts +18 -0
- package/types/actions/actionProperties.d.ts +78 -0
- package/types/actions/actionSelectAll.d.ts +6 -0
- package/types/actions/actionStyles.d.ts +6 -0
- package/types/actions/actionToggleGridMode.d.ts +6 -0
- package/types/actions/actionToggleObjectsSnapMode.d.ts +143 -0
- package/types/actions/actionToggleStats.d.ts +6 -0
- package/types/actions/actionToggleViewMode.d.ts +6 -0
- package/types/actions/actionToggleZenMode.d.ts +6 -0
- package/types/actions/index.d.ts +1 -0
- package/types/actions/shortcuts.d.ts +1 -1
- package/types/actions/types.d.ts +1 -1
- package/types/appState.d.ts +1 -0
- package/types/components/App.d.ts +2 -0
- package/types/element/Hyperlink.d.ts +6 -0
- package/types/element/bounds.d.ts +4 -5
- package/types/element/dragElements.d.ts +11 -2
- package/types/element/embeddable.d.ts +6 -0
- package/types/element/linearElementEditor.d.ts +6 -0
- package/types/element/resizeElements.d.ts +2 -2
- package/types/keys.d.ts +1 -0
- package/types/math.d.ts +2 -0
- package/types/renderer/renderSnaps.d.ts +2 -0
- package/types/scene/selection.d.ts +1 -0
- package/types/snapping.d.ts +108 -0
- package/types/types.d.ts +16 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Bounds } from "./element/bounds";
|
|
2
|
+
import { MaybeTransformHandleType } from "./element/transformHandles";
|
|
3
|
+
import { ExcalidrawElement, NonDeletedExcalidrawElement } from "./element/types";
|
|
4
|
+
import { AppState, KeyboardModifiersObject, Point } from "./types";
|
|
5
|
+
export declare const getSnapDistance: (zoomValue: number) => number;
|
|
6
|
+
type Vector2D = {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
type PointPair = [Point, Point];
|
|
11
|
+
export type PointSnap = {
|
|
12
|
+
type: "point";
|
|
13
|
+
points: PointPair;
|
|
14
|
+
offset: number;
|
|
15
|
+
};
|
|
16
|
+
export type Gap = {
|
|
17
|
+
startBounds: Bounds;
|
|
18
|
+
endBounds: Bounds;
|
|
19
|
+
startSide: [Point, Point];
|
|
20
|
+
endSide: [Point, Point];
|
|
21
|
+
overlap: [number, number];
|
|
22
|
+
length: number;
|
|
23
|
+
};
|
|
24
|
+
export type GapSnap = {
|
|
25
|
+
type: "gap";
|
|
26
|
+
direction: "center_horizontal" | "center_vertical" | "side_left" | "side_right" | "side_top" | "side_bottom";
|
|
27
|
+
gap: Gap;
|
|
28
|
+
offset: number;
|
|
29
|
+
};
|
|
30
|
+
export type GapSnaps = GapSnap[];
|
|
31
|
+
export type Snap = GapSnap | PointSnap;
|
|
32
|
+
export type Snaps = Snap[];
|
|
33
|
+
export type PointSnapLine = {
|
|
34
|
+
type: "points";
|
|
35
|
+
points: Point[];
|
|
36
|
+
};
|
|
37
|
+
export type PointerSnapLine = {
|
|
38
|
+
type: "pointer";
|
|
39
|
+
points: PointPair;
|
|
40
|
+
direction: "horizontal" | "vertical";
|
|
41
|
+
};
|
|
42
|
+
export type GapSnapLine = {
|
|
43
|
+
type: "gap";
|
|
44
|
+
direction: "horizontal" | "vertical";
|
|
45
|
+
points: PointPair;
|
|
46
|
+
};
|
|
47
|
+
export type SnapLine = PointSnapLine | GapSnapLine | PointerSnapLine;
|
|
48
|
+
export declare class SnapCache {
|
|
49
|
+
private static referenceSnapPoints;
|
|
50
|
+
private static visibleGaps;
|
|
51
|
+
static setReferenceSnapPoints: (snapPoints: Point[] | null) => void;
|
|
52
|
+
static getReferenceSnapPoints: () => (readonly [number, number])[] | null;
|
|
53
|
+
static setVisibleGaps: (gaps: {
|
|
54
|
+
verticalGaps: Gap[];
|
|
55
|
+
horizontalGaps: Gap[];
|
|
56
|
+
} | null) => void;
|
|
57
|
+
static getVisibleGaps: () => {
|
|
58
|
+
verticalGaps: Gap[];
|
|
59
|
+
horizontalGaps: Gap[];
|
|
60
|
+
} | null;
|
|
61
|
+
static destroy: () => void;
|
|
62
|
+
}
|
|
63
|
+
export declare const isSnappingEnabled: ({ event, appState, selectedElements, }: {
|
|
64
|
+
appState: AppState;
|
|
65
|
+
event: KeyboardModifiersObject;
|
|
66
|
+
selectedElements: NonDeletedExcalidrawElement[];
|
|
67
|
+
}) => boolean;
|
|
68
|
+
export declare const areRoughlyEqual: (a: number, b: number, precision?: number) => boolean;
|
|
69
|
+
export declare const getElementsCorners: (elements: ExcalidrawElement[], { omitCenter, boundingBoxCorners, dragOffset, }?: {
|
|
70
|
+
omitCenter?: boolean | undefined;
|
|
71
|
+
boundingBoxCorners?: boolean | undefined;
|
|
72
|
+
dragOffset?: Vector2D | undefined;
|
|
73
|
+
}) => Point[];
|
|
74
|
+
export declare const getVisibleGaps: (elements: readonly NonDeletedExcalidrawElement[], selectedElements: ExcalidrawElement[], appState: AppState) => {
|
|
75
|
+
horizontalGaps: Gap[];
|
|
76
|
+
verticalGaps: Gap[];
|
|
77
|
+
};
|
|
78
|
+
export declare const getReferenceSnapPoints: (elements: readonly NonDeletedExcalidrawElement[], selectedElements: ExcalidrawElement[], appState: AppState) => (readonly [number, number])[];
|
|
79
|
+
export declare const snapDraggedElements: (selectedElements: ExcalidrawElement[], dragOffset: Vector2D, appState: AppState, event: KeyboardModifiersObject) => {
|
|
80
|
+
snapOffset: {
|
|
81
|
+
x: number;
|
|
82
|
+
y: number;
|
|
83
|
+
};
|
|
84
|
+
snapLines: (PointSnapLine | GapSnapLine)[];
|
|
85
|
+
};
|
|
86
|
+
export declare const snapResizingElements: (selectedElements: ExcalidrawElement[], selectedOriginalElements: ExcalidrawElement[], appState: AppState, event: KeyboardModifiersObject, dragOffset: Vector2D, transformHandle: MaybeTransformHandleType) => {
|
|
87
|
+
snapOffset: {
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
};
|
|
91
|
+
snapLines: PointSnapLine[];
|
|
92
|
+
};
|
|
93
|
+
export declare const snapNewElement: (draggingElement: ExcalidrawElement, appState: AppState, event: KeyboardModifiersObject, origin: Vector2D, dragOffset: Vector2D) => {
|
|
94
|
+
snapOffset: {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
};
|
|
98
|
+
snapLines: PointSnapLine[];
|
|
99
|
+
};
|
|
100
|
+
export declare const getSnapLinesAtPointer: (elements: readonly ExcalidrawElement[], appState: AppState, pointer: Vector2D, event: KeyboardModifiersObject) => {
|
|
101
|
+
originOffset: {
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
};
|
|
105
|
+
snapLines: PointerSnapLine[];
|
|
106
|
+
};
|
|
107
|
+
export declare const isActiveToolNonLinearSnappable: (activeToolType: AppState["activeTool"]["type"]) => boolean;
|
|
108
|
+
export {};
|
package/types/types.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ import Library from "./data/library";
|
|
|
16
16
|
import type { FileSystemHandle } from "./data/filesystem";
|
|
17
17
|
import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
|
|
18
18
|
import { ContextMenuItems } from "./components/ContextMenu";
|
|
19
|
+
import { SnapLine } from "./snapping";
|
|
19
20
|
import { Merge, ForwardRef, ValueOf } from "./utility-types";
|
|
20
21
|
export type Point = Readonly<RoughPoint>;
|
|
21
22
|
export type Collaborator = {
|
|
@@ -103,6 +104,8 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
103
104
|
openSidebar: AppState["openSidebar"];
|
|
104
105
|
showHyperlinkPopup: AppState["showHyperlinkPopup"];
|
|
105
106
|
collaborators: AppState["collaborators"];
|
|
107
|
+
snapLines: AppState["snapLines"];
|
|
108
|
+
zenModeEnabled: AppState["zenModeEnabled"];
|
|
106
109
|
}>;
|
|
107
110
|
export type AppState = {
|
|
108
111
|
contextMenu: {
|
|
@@ -236,6 +239,12 @@ export type AppState = {
|
|
|
236
239
|
pendingImageElementId: ExcalidrawImageElement["id"] | null;
|
|
237
240
|
showHyperlinkPopup: false | "info" | "editor";
|
|
238
241
|
selectedLinearElement: LinearElementEditor | null;
|
|
242
|
+
snapLines: SnapLine[];
|
|
243
|
+
originSnapOffset: {
|
|
244
|
+
x: number;
|
|
245
|
+
y: number;
|
|
246
|
+
} | null;
|
|
247
|
+
objectsSnapModeEnabled: boolean;
|
|
239
248
|
};
|
|
240
249
|
export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
|
|
241
250
|
export type NormalizedZoomValue = number & {
|
|
@@ -304,6 +313,7 @@ export interface ExcalidrawProps {
|
|
|
304
313
|
viewModeEnabled?: boolean;
|
|
305
314
|
zenModeEnabled?: boolean;
|
|
306
315
|
gridModeEnabled?: boolean;
|
|
316
|
+
objectsSnapModeEnabled?: boolean;
|
|
307
317
|
libraryReturnUrl?: string;
|
|
308
318
|
theme?: Theme;
|
|
309
319
|
name?: string;
|
|
@@ -496,4 +506,10 @@ export type FrameNameBoundsCache = {
|
|
|
496
506
|
versionNonce: ExcalidrawFrameElement["versionNonce"];
|
|
497
507
|
}>;
|
|
498
508
|
};
|
|
509
|
+
export type KeyboardModifiersObject = {
|
|
510
|
+
ctrlKey: boolean;
|
|
511
|
+
shiftKey: boolean;
|
|
512
|
+
altKey: boolean;
|
|
513
|
+
metaKey: boolean;
|
|
514
|
+
};
|
|
499
515
|
export {};
|