@excalidraw/math 0.18.0-0457ac9 → 0.18.0-063e025
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/types/common/src/colors.d.ts +1 -1
- package/dist/types/common/src/constants.d.ts +9 -7
- package/dist/types/common/src/utils.d.ts +0 -42
- package/dist/types/element/src/Scene.d.ts +1 -1
- package/dist/types/element/src/align.d.ts +2 -2
- package/dist/types/element/src/binding.d.ts +6 -6
- package/dist/types/element/src/bounds.d.ts +19 -6
- package/dist/types/element/src/collision.d.ts +1 -1
- package/dist/types/element/src/comparisons.d.ts +1 -0
- package/dist/types/element/src/distribute.d.ts +2 -2
- package/dist/types/element/src/duplicate.d.ts +3 -3
- package/dist/types/element/src/embeddable.d.ts +2 -2
- package/dist/types/element/src/flowchart.d.ts +3 -3
- package/dist/types/element/src/fractionalIndex.d.ts +2 -2
- package/dist/types/element/src/frame.d.ts +4 -4
- package/dist/types/element/src/groups.d.ts +9 -9
- package/dist/types/element/src/index.d.ts +1 -1
- package/dist/types/element/src/linearElementEditor.d.ts +10 -10
- package/dist/types/element/src/newElement.d.ts +1 -0
- package/dist/types/element/src/renderElement.d.ts +0 -3
- package/dist/types/element/src/resizeElements.d.ts +2 -2
- package/dist/types/element/src/selection.d.ts +5 -5
- package/dist/types/element/src/textElement.d.ts +7 -7
- package/dist/types/element/src/transform.d.ts +2 -2
- package/dist/types/element/src/typeChecks.d.ts +25 -25
- package/dist/types/element/src/types.d.ts +8 -1
- package/dist/types/element/src/zindex.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +12 -6
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +8 -4
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +61 -389
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +8 -4
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +13 -7
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +9 -5
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionExport.d.ts +8 -4
- package/dist/types/excalidraw/actions/actionFrame.d.ts +29 -20
- package/dist/types/excalidraw/actions/actionGroup.d.ts +23 -19
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +7 -4
- package/dist/types/excalidraw/actions/actionLink.d.ts +5 -3
- package/dist/types/excalidraw/actions/actionMenu.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionProperties.d.ts +35 -22
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +9 -7
- package/dist/types/excalidraw/actions/actionStyles.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +5 -3
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +8 -7
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +5 -3
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +5 -3
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +8 -7
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +5 -3
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +5 -3
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +5 -3
- package/dist/types/excalidraw/actions/index.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +4 -4
- package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
- package/dist/types/excalidraw/appState.d.ts +2 -1
- package/dist/types/excalidraw/components/Actions.d.ts +2 -3
- package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/App.d.ts +61 -32
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +2 -2
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
- package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -2
- package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
- package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
- package/dist/types/excalidraw/components/Island.d.ts +7 -0
- package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
- package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
- package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
- package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
- package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
- package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -2
- package/dist/types/excalidraw/components/icons.d.ts +2 -0
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +6 -3
- package/dist/types/excalidraw/data/blob.d.ts +8 -4
- package/dist/types/excalidraw/data/index.d.ts +4 -4
- package/dist/types/excalidraw/data/json.d.ts +10 -8
- package/dist/types/excalidraw/data/library.d.ts +1 -1
- package/dist/types/excalidraw/eraser/index.d.ts +2 -3
- package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
- package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
- package/dist/types/excalidraw/lasso/index.d.ts +2 -3
- package/dist/types/excalidraw/renderer/animation.d.ts +5 -1
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -3
- package/dist/types/excalidraw/scene/Renderer.d.ts +12 -11
- package/dist/types/excalidraw/scene/export.d.ts +3 -3
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/types.d.ts +1 -3
- package/dist/types/excalidraw/snapping.d.ts +7 -7
- package/dist/types/excalidraw/types.d.ts +168 -11
- package/dist/types/excalidraw/viewport.d.ts +316 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +2 -3
- package/dist/types/laser-pointer/src/index.d.ts +2 -0
- package/dist/types/laser-pointer/src/math.d.ts +16 -0
- package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
- package/dist/types/laser-pointer/src/state.d.ts +35 -0
- package/dist/types/utils/src/export.d.ts +3 -3
- package/dist/types/utils/src/index.d.ts +1 -2
- package/package.json +2 -2
- package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
- package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
- package/dist/types/utils/src/bbox.d.ts +0 -9
- package/dist/types/utils/src/withinBounds.d.ts +0 -19
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import type { SceneBounds } from "@excalidraw/element";
|
|
2
|
+
import type { Bounds } from "@excalidraw/common";
|
|
3
|
+
import type { ExcalidrawElement, NonDeleted, NonDeletedSceneElementsMap } from "@excalidraw/element/types";
|
|
4
|
+
import type { AppState, NormalizedZoomValue, Offsets, PointerCoords, ScrollConstraints, ViewportOffsets, Zoom } from "./types";
|
|
5
|
+
export declare const SCROLL_TO_CONTENT_ANIMATION_KEY = "animateScrollToContent";
|
|
6
|
+
/** default rubberband overscroll give for scroll locks, in viewport px */
|
|
7
|
+
export declare const DEFAULT_OVERSCROLL = 150;
|
|
8
|
+
export type AnimationOptions = {
|
|
9
|
+
duration?: number;
|
|
10
|
+
};
|
|
11
|
+
export type SetViewportRect = {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
};
|
|
17
|
+
export declare const isSetViewportRect: (target: unknown) => target is SetViewportRect;
|
|
18
|
+
export type SetViewportOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* what to show in the viewport: an explicit scene-coordinate box/rect,
|
|
21
|
+
* element(s), or an element id / element-link URL.
|
|
22
|
+
*
|
|
23
|
+
* IMPORTANT: if supplying ExcalidrawElement(s), only non-deleted elements
|
|
24
|
+
* that actually exist on the canvas are considered. If you want to navigate
|
|
25
|
+
* to elements that's not on canvas yet, supply their bounds by using
|
|
26
|
+
* `getCommonBounds` (see {@link getCommonBounds}).
|
|
27
|
+
*/
|
|
28
|
+
target: Bounds | SetViewportRect | ExcalidrawElement | readonly ExcalidrawElement[] | string;
|
|
29
|
+
/**
|
|
30
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/object-fit
|
|
31
|
+
*
|
|
32
|
+
* - `scale-down` - zoom out so the target fits the viewport, never zooming past 100%
|
|
33
|
+
* - `contain` - zoom the target so it fills the viewport (may exceed 100%)
|
|
34
|
+
* - `none` - keep the current zoom, only center the target in the viewport
|
|
35
|
+
*/
|
|
36
|
+
fit?: "scale-down" | "contain" | "none";
|
|
37
|
+
lock?: {
|
|
38
|
+
/** constraints panning to the target box */
|
|
39
|
+
scroll?: ScrollConstraints["lockScroll"];
|
|
40
|
+
/** makes the resolved zoom the minimum zoom */
|
|
41
|
+
zoom?: ScrollConstraints["lockZoom"];
|
|
42
|
+
/**
|
|
43
|
+
* Rubberband give past the lock, in viewport px (zoom-independent): how
|
|
44
|
+
* far the user can pan beyond the constraint before snapping back.
|
|
45
|
+
* `true` (default) uses {@link DEFAULT_OVERSCROLL}, `false` disables
|
|
46
|
+
* (rigid lock), a number sets the give explicitly.
|
|
47
|
+
*/
|
|
48
|
+
overscroll?: boolean | number;
|
|
49
|
+
};
|
|
50
|
+
animation?: AnimationOptions | boolean;
|
|
51
|
+
/**
|
|
52
|
+
* CSS-style per-side viewport insets, in viewport pixels
|
|
53
|
+
* (zoom-independent) — static values, editor-UI-derived (`ui`), or a
|
|
54
|
+
* combination. See {@link ViewportOffsets}.
|
|
55
|
+
*/
|
|
56
|
+
offsets?: ViewportOffsets;
|
|
57
|
+
};
|
|
58
|
+
type Viewport = Pick<AppState, "scrollX" | "scrollY" | "zoom">;
|
|
59
|
+
/**
|
|
60
|
+
* Clamps a proposed scroll/zoom against the active lock (`scrollConstraints`).
|
|
61
|
+
* Returns the input scroll/zoom unchanged when there is no lock.
|
|
62
|
+
* `overscroll` (screen px, zoom-independent) is rubberband give past the
|
|
63
|
+
* resting clamp — pass 0 for a hard clamp.
|
|
64
|
+
*/
|
|
65
|
+
export declare const constrainScrollState: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">, overscroll?: number) => Viewport;
|
|
66
|
+
export declare const isViewportOverscrolled: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">) => boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Rubberband snap-back: animates the viewport from its current (possibly
|
|
69
|
+
* overscrolled) position back inside the lock box via the shared
|
|
70
|
+
* AnimationController. No-op when already within the hard bounds (or when there
|
|
71
|
+
* is no lock).
|
|
72
|
+
*/
|
|
73
|
+
export declare const animateToConstraints: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">, onFrame: (viewport: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom">) => void, duration?: number) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Scrolls (and, per `fit`, zooms) the viewport so the given target box is in
|
|
76
|
+
* view, optionally animating the transition. `onComplete` runs once the
|
|
77
|
+
* viewport has settled on the target.
|
|
78
|
+
*/
|
|
79
|
+
export declare const setViewportToBounds: (state: AppState, bounds: Bounds, opts: Pick<SetViewportOptions, "fit" | "animation"> & {
|
|
80
|
+
offsets?: Offsets;
|
|
81
|
+
}, onFrame: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom">) => void, onComplete?: () => void) => void;
|
|
82
|
+
export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, minZoom, maxZoom, steppedZoom, }: {
|
|
83
|
+
bounds: SceneBounds;
|
|
84
|
+
canvasOffsets?: Offsets;
|
|
85
|
+
appState: Readonly<AppState>;
|
|
86
|
+
fit?: SetViewportOptions["fit"];
|
|
87
|
+
minZoom?: number;
|
|
88
|
+
maxZoom?: number;
|
|
89
|
+
steppedZoom?: boolean;
|
|
90
|
+
}) => {
|
|
91
|
+
appState: {
|
|
92
|
+
scrollX: number;
|
|
93
|
+
scrollY: number;
|
|
94
|
+
zoom: {
|
|
95
|
+
value: NormalizedZoomValue;
|
|
96
|
+
};
|
|
97
|
+
contextMenu: {
|
|
98
|
+
items: import("./components/ContextMenu").ContextMenuItems;
|
|
99
|
+
top: number;
|
|
100
|
+
left: number;
|
|
101
|
+
} | null;
|
|
102
|
+
showWelcomeScreen: boolean;
|
|
103
|
+
isLoading: boolean;
|
|
104
|
+
errorMessage: React.ReactNode;
|
|
105
|
+
activeEmbeddable: {
|
|
106
|
+
element: import("@excalidraw/element/types").NonDeletedExcalidrawElement;
|
|
107
|
+
state: "hover" | "active";
|
|
108
|
+
} | null;
|
|
109
|
+
newElement: NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
|
|
110
|
+
resizingElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
|
|
111
|
+
multiElement: NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
|
|
112
|
+
selectionElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
|
|
113
|
+
isBindingEnabled: boolean;
|
|
114
|
+
boxSelectionMode: import("./types").BoxSelectionMode;
|
|
115
|
+
bindingPreference: "enabled" | "disabled";
|
|
116
|
+
isMidpointSnappingEnabled: boolean;
|
|
117
|
+
suggestedBinding: {
|
|
118
|
+
element: NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
|
|
119
|
+
midPoint?: import("@excalidraw/math").GlobalPoint;
|
|
120
|
+
} | null;
|
|
121
|
+
frameToHighlight: NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
|
|
122
|
+
frameRendering: {
|
|
123
|
+
enabled: boolean;
|
|
124
|
+
name: boolean;
|
|
125
|
+
outline: boolean;
|
|
126
|
+
clip: boolean;
|
|
127
|
+
};
|
|
128
|
+
editingFrame: string | null;
|
|
129
|
+
elementsToHighlight: readonly import("@excalidraw/element/types").NonDeletedExcalidrawElement[] | null;
|
|
130
|
+
editingTextElement: import("@excalidraw/element/types").ExcalidrawTextElement | null;
|
|
131
|
+
activeTool: {
|
|
132
|
+
lastActiveTool: import("./types").ActiveTool | null;
|
|
133
|
+
locked: boolean;
|
|
134
|
+
fromSelection: boolean;
|
|
135
|
+
} & import("./types").ActiveTool;
|
|
136
|
+
preferredSelectionTool: {
|
|
137
|
+
type: "selection" | "lasso";
|
|
138
|
+
initialized: boolean;
|
|
139
|
+
};
|
|
140
|
+
penMode: boolean;
|
|
141
|
+
penDetected: boolean;
|
|
142
|
+
exportBackground: boolean;
|
|
143
|
+
exportEmbedScene: boolean;
|
|
144
|
+
exportWithDarkMode: boolean;
|
|
145
|
+
exportScale: number;
|
|
146
|
+
currentItemStrokeColor: string;
|
|
147
|
+
currentItemBackgroundColor: string;
|
|
148
|
+
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
149
|
+
currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
|
|
150
|
+
currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
|
|
151
|
+
currentItemRoughness: number;
|
|
152
|
+
currentItemStrokeVariability: import("@excalidraw/element/types").StrokeVariability;
|
|
153
|
+
currentItemOpacity: number;
|
|
154
|
+
currentItemFontFamily: import("@excalidraw/element/types").FontFamilyValues;
|
|
155
|
+
currentItemFontSize: number;
|
|
156
|
+
currentItemTextAlign: import("@excalidraw/element/types").TextAlign;
|
|
157
|
+
currentItemStartArrowhead: import("@excalidraw/element/types").Arrowhead | null;
|
|
158
|
+
currentItemEndArrowhead: import("@excalidraw/element/types").Arrowhead | null;
|
|
159
|
+
currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
|
|
160
|
+
currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
|
|
161
|
+
currentItemArrowType: "sharp" | "round" | "elbow";
|
|
162
|
+
viewBackgroundColor: string;
|
|
163
|
+
scrollConstraints: ScrollConstraints | null;
|
|
164
|
+
cursorButton: "up" | "down";
|
|
165
|
+
scrolledOutside: boolean;
|
|
166
|
+
name: string | null;
|
|
167
|
+
isResizing: boolean;
|
|
168
|
+
isRotating: boolean;
|
|
169
|
+
openMenu: "canvas" | null;
|
|
170
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
|
|
171
|
+
openSidebar: {
|
|
172
|
+
name: import("./types").SidebarName;
|
|
173
|
+
tab?: import("./types").SidebarTabName;
|
|
174
|
+
} | null;
|
|
175
|
+
openDialog: null | {
|
|
176
|
+
name: "imageExport" | "help" | "jsonExport";
|
|
177
|
+
} | {
|
|
178
|
+
name: "ttd";
|
|
179
|
+
tab: "text-to-diagram" | "mermaid";
|
|
180
|
+
} | {
|
|
181
|
+
name: "commandPalette";
|
|
182
|
+
} | {
|
|
183
|
+
name: "settings";
|
|
184
|
+
} | {
|
|
185
|
+
name: "elementLinkSelector";
|
|
186
|
+
sourceElementId: ExcalidrawElement["id"];
|
|
187
|
+
} | {
|
|
188
|
+
name: "charts";
|
|
189
|
+
data: import("./charts").Spreadsheet;
|
|
190
|
+
rawText: string;
|
|
191
|
+
};
|
|
192
|
+
defaultSidebarDockedPreference: boolean;
|
|
193
|
+
lastPointerDownWith: import("@excalidraw/element/types").PointerType;
|
|
194
|
+
selectedElementIds: Readonly<{
|
|
195
|
+
[id: string]: true;
|
|
196
|
+
}>;
|
|
197
|
+
hoveredElementIds: Readonly<{
|
|
198
|
+
[id: string]: true;
|
|
199
|
+
}>;
|
|
200
|
+
previousSelectedElementIds: {
|
|
201
|
+
[id: string]: true;
|
|
202
|
+
};
|
|
203
|
+
selectedElementsAreBeingDragged: boolean;
|
|
204
|
+
shouldCacheIgnoreZoom: boolean;
|
|
205
|
+
toast: {
|
|
206
|
+
message: React.ReactNode;
|
|
207
|
+
closable?: boolean;
|
|
208
|
+
duration?: number;
|
|
209
|
+
} | null;
|
|
210
|
+
zenModeEnabled: boolean;
|
|
211
|
+
theme: import("@excalidraw/element/types").Theme;
|
|
212
|
+
gridSize: number;
|
|
213
|
+
gridStep: number;
|
|
214
|
+
gridModeEnabled: boolean;
|
|
215
|
+
viewModeEnabled: boolean;
|
|
216
|
+
selectedGroupIds: {
|
|
217
|
+
[groupId: string]: boolean;
|
|
218
|
+
};
|
|
219
|
+
editingGroupId: import("@excalidraw/element/types").GroupId | null;
|
|
220
|
+
width: number;
|
|
221
|
+
height: number;
|
|
222
|
+
offsetTop: number;
|
|
223
|
+
offsetLeft: number;
|
|
224
|
+
fileHandle: FileSystemFileHandle | null;
|
|
225
|
+
collaborators: Map<import("./types").SocketId, import("./types").Collaborator>;
|
|
226
|
+
stats: {
|
|
227
|
+
open: boolean;
|
|
228
|
+
panels: number;
|
|
229
|
+
};
|
|
230
|
+
showHyperlinkPopup: false | "info" | "editor";
|
|
231
|
+
selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
|
|
232
|
+
snapLines: readonly import("./snapping").SnapLine[];
|
|
233
|
+
originSnapOffset: {
|
|
234
|
+
x: number;
|
|
235
|
+
y: number;
|
|
236
|
+
} | null;
|
|
237
|
+
objectsSnapModeEnabled: boolean;
|
|
238
|
+
userToFollow: import("./types").UserToFollow | null;
|
|
239
|
+
followedBy: Set<import("./types").SocketId>;
|
|
240
|
+
isCropping: boolean;
|
|
241
|
+
croppingElementId: ExcalidrawElement["id"] | null;
|
|
242
|
+
searchMatches: Readonly<{
|
|
243
|
+
focusedId: ExcalidrawElement["id"] | null;
|
|
244
|
+
matches: readonly import("./types").SearchMatch[];
|
|
245
|
+
}> | null;
|
|
246
|
+
activeLockedId: string | null;
|
|
247
|
+
lockedMultiSelections: {
|
|
248
|
+
[groupId: string]: true;
|
|
249
|
+
};
|
|
250
|
+
bindMode: import("@excalidraw/element/types").BindMode;
|
|
251
|
+
};
|
|
252
|
+
captureUpdate: "EVENTUALLY";
|
|
253
|
+
};
|
|
254
|
+
/** Computes the viewport (scroll + zoom) that brings the target box into view,
|
|
255
|
+
* based on the requested fit behavior. */
|
|
256
|
+
export declare const getTargetViewport: (state: AppState, bounds: Bounds, fit?: SetViewportOptions["fit"], offsets?: Offsets) => Viewport;
|
|
257
|
+
export type ResolvedViewportTarget = {
|
|
258
|
+
/** null when the target couldn't be resolved (unknown id/link, or all
|
|
259
|
+
* supplied elements deleted) */
|
|
260
|
+
bounds: Bounds | null;
|
|
261
|
+
/** how the target was specified, so callers can react to unresolved
|
|
262
|
+
* targets themselves (e.g. toast on a broken element link) */
|
|
263
|
+
type: "element" | "area" | "link";
|
|
264
|
+
};
|
|
265
|
+
/** Resolves a `setViewport` target to a scene-coordinate box. */
|
|
266
|
+
export declare const resolveViewportTarget: (target: SetViewportOptions["target"], elementsMap: NonDeletedSceneElementsMap, appState: Pick<AppState, "width" | "height">) => ResolvedViewportTarget;
|
|
267
|
+
/** Computes the viewport patch for landing on `bounds`: the target
|
|
268
|
+
* scroll/zoom, plus the scroll lock to install — or `scrollConstraints: null`
|
|
269
|
+
* to clear a previous lock when none is requested. */
|
|
270
|
+
export declare const getConstrainedTargetViewport: (appState: AppState, bounds: Bounds, { fit, offsets, lock, }: Pick<SetViewportOptions, "fit" | "lock"> & {
|
|
271
|
+
offsets?: Offsets;
|
|
272
|
+
}) => Viewport & {
|
|
273
|
+
scrollConstraints: ScrollConstraints | null;
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Interpolates the viewport from `from` to `target` at the (already-eased)
|
|
277
|
+
* blend amount `factor` (0 = `from`, 1 = `target`).
|
|
278
|
+
*
|
|
279
|
+
* Zoom is interpolated geometrically (so it feels uniform), but the pan can't
|
|
280
|
+
* simply lerp alongside it: pairing a geometric zoom with a linear scroll (or
|
|
281
|
+
* a linearly-tweened focal point) makes scene points swoop along curved,
|
|
282
|
+
* non-monotone screen paths once the zoom ratio exceeds ~e (the destination
|
|
283
|
+
* visibly drifts away before converging). Instead we interpolate the view
|
|
284
|
+
* transform affinely — a scene point maps to screen as
|
|
285
|
+
* `(scenePt + scroll) * zoom`, and requiring every point to travel a straight
|
|
286
|
+
* screen line forces `zoom` to be a convex blend `(1-m)*z0 + m*z1` with
|
|
287
|
+
* `scroll * zoom` lerped by that same weight. Deriving `m` from the geometric
|
|
288
|
+
* zoom keeps its pacing while making all screen trajectories straight and
|
|
289
|
+
* monotone.
|
|
290
|
+
*/
|
|
291
|
+
export declare const interpolateViewport: ({ from, target, factor, }: {
|
|
292
|
+
from: Viewport;
|
|
293
|
+
target: Viewport;
|
|
294
|
+
factor: number;
|
|
295
|
+
}) => Viewport;
|
|
296
|
+
export declare const getClosestElementBounds: (elements: readonly ExcalidrawElement[], from: {
|
|
297
|
+
x: number;
|
|
298
|
+
y: number;
|
|
299
|
+
}) => Bounds;
|
|
300
|
+
export declare const centerScrollOn: ({ scenePoint, viewportDimensions, zoom, offsets, }: {
|
|
301
|
+
scenePoint: PointerCoords;
|
|
302
|
+
viewportDimensions: {
|
|
303
|
+
height: number;
|
|
304
|
+
width: number;
|
|
305
|
+
};
|
|
306
|
+
zoom: Zoom;
|
|
307
|
+
offsets?: Offsets;
|
|
308
|
+
}) => {
|
|
309
|
+
scrollX: number;
|
|
310
|
+
scrollY: number;
|
|
311
|
+
};
|
|
312
|
+
export declare const getScrollToContentState: (elements: readonly ExcalidrawElement[], appState: AppState) => {
|
|
313
|
+
scrollX: number;
|
|
314
|
+
scrollY: number;
|
|
315
|
+
};
|
|
316
|
+
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExcalidrawTextElement } from "@excalidraw/element/types";
|
|
2
2
|
import type App from "../components/App";
|
|
3
3
|
type SubmitHandler = () => void;
|
|
4
|
-
export declare const textWysiwyg: ({
|
|
5
|
-
id: ExcalidrawElement["id"];
|
|
4
|
+
export declare const textWysiwyg: ({ onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, initialCaretSceneCoords, }: {
|
|
6
5
|
/**
|
|
7
6
|
* textWysiwyg only deals with `originalText`
|
|
8
7
|
*
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Point = [x: number, y: number, r: number];
|
|
2
|
+
export declare function add([ax, ay, ar]: Point, [bx, by, br]: Point): Point;
|
|
3
|
+
export declare function sub([ax, ay, ar]: Point, [bx, by, br]: Point): Point;
|
|
4
|
+
export declare function smul([x, y, r]: Point, s: number): Point;
|
|
5
|
+
export declare function norm([x, y, r]: Point): Point;
|
|
6
|
+
export declare function rot([x, y, r]: Point, rad: number): Point;
|
|
7
|
+
export declare function plerp(a: Point, b: Point, t: number): Point;
|
|
8
|
+
export declare function lerp(a: number, b: number, t: number): number;
|
|
9
|
+
export declare function angle(p: Point, p1: Point, p2: Point): number;
|
|
10
|
+
export declare function normAngle(a: number): number;
|
|
11
|
+
export declare function mag([x, y]: Point): number;
|
|
12
|
+
export declare function dist([ax, ay]: Point, [bx, by]: Point): number;
|
|
13
|
+
export declare function getCircleAndPerpendicularLineIntersectionsAtPoint(point: Point, direction: Point, radius: number): [Point, Point];
|
|
14
|
+
export declare function runLength(ps: Point[]): number;
|
|
15
|
+
export declare const clamp: (v: number, min: number, max: number) => number;
|
|
16
|
+
export declare function distancePointToSegment(p3: Point, p1: Point, p2: Point): number;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Point } from "./math";
|
|
2
|
+
export type SizeMappingDetails = {
|
|
3
|
+
pressure: number;
|
|
4
|
+
runningLength: number;
|
|
5
|
+
currentIndex: number;
|
|
6
|
+
totalLength: number;
|
|
7
|
+
};
|
|
8
|
+
export type LaserPointerOptions = {
|
|
9
|
+
size: number;
|
|
10
|
+
streamline: number;
|
|
11
|
+
simplify: number;
|
|
12
|
+
simplifyPhase: "tail" | "output" | "input";
|
|
13
|
+
keepHead: boolean;
|
|
14
|
+
sizeMapping: (details: SizeMappingDetails) => number;
|
|
15
|
+
};
|
|
16
|
+
export declare class LaserPointer {
|
|
17
|
+
static defaults: LaserPointerOptions;
|
|
18
|
+
static constants: {
|
|
19
|
+
cornerDetectionMaxAngle: number;
|
|
20
|
+
cornerDetectionVariance: (s: number) => 1 | 0.5;
|
|
21
|
+
maxTailLength: number;
|
|
22
|
+
};
|
|
23
|
+
options: LaserPointerOptions;
|
|
24
|
+
constructor(options: Partial<LaserPointerOptions>);
|
|
25
|
+
originalPoints: Point[];
|
|
26
|
+
private stablePoints;
|
|
27
|
+
private tailPoints;
|
|
28
|
+
private isFresh;
|
|
29
|
+
private get lastPoint();
|
|
30
|
+
addPoint(point: Point): void;
|
|
31
|
+
close(): void;
|
|
32
|
+
stabilizeTail(): void;
|
|
33
|
+
private getSize;
|
|
34
|
+
getStrokeOutline(sizeOverride?: number | undefined): Point[];
|
|
35
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { MIME_TYPES } from "@excalidraw/common";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
3
3
|
import type { AppState, BinaryFiles } from "@excalidraw/excalidraw/types";
|
|
4
4
|
export { MIME_TYPES };
|
|
5
5
|
type ExportOpts = {
|
|
6
|
-
elements: readonly
|
|
6
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
7
7
|
appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
|
|
8
8
|
files: BinaryFiles | null;
|
|
9
9
|
maxWidthOrHeight?: number;
|
|
10
|
-
exportingFrame?: ExcalidrawFrameLikeElement | null;
|
|
10
|
+
exportingFrame?: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
11
11
|
getDimensions?: (width: number, height: number) => {
|
|
12
12
|
width: number;
|
|
13
13
|
height: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@excalidraw/math",
|
|
3
|
-
"version": "0.18.0-
|
|
3
|
+
"version": "0.18.0-063e025",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/types/math/src/index.d.ts",
|
|
6
6
|
"main": "./dist/prod/index.js",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@excalidraw/common": "0.18.0-
|
|
64
|
+
"@excalidraw/common": "0.18.0-063e025"
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export type AnimationCallback = (timestamp: number) => void | boolean;
|
|
2
|
-
export type AnimationTarget = {
|
|
3
|
-
callback: AnimationCallback;
|
|
4
|
-
stopped: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare class AnimationFrameHandler {
|
|
7
|
-
private targets;
|
|
8
|
-
private rafIds;
|
|
9
|
-
register(key: object, callback: AnimationCallback): void;
|
|
10
|
-
start(key: object): void;
|
|
11
|
-
stop(key: object): void;
|
|
12
|
-
private constructFrame;
|
|
13
|
-
private scheduleFrame;
|
|
14
|
-
private cancelFrame;
|
|
15
|
-
private onFrame;
|
|
16
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ExcalidrawElement } from "@excalidraw/element/types";
|
|
2
|
-
import type { AppState, Offsets, PointerCoords, Zoom } from "../types";
|
|
3
|
-
export declare const centerScrollOn: ({ scenePoint, viewportDimensions, zoom, offsets, }: {
|
|
4
|
-
scenePoint: PointerCoords;
|
|
5
|
-
viewportDimensions: {
|
|
6
|
-
height: number;
|
|
7
|
-
width: number;
|
|
8
|
-
};
|
|
9
|
-
zoom: Zoom;
|
|
10
|
-
offsets?: Offsets;
|
|
11
|
-
}) => {
|
|
12
|
-
scrollX: number;
|
|
13
|
-
scrollY: number;
|
|
14
|
-
};
|
|
15
|
-
export declare const calculateScrollCenter: (elements: readonly ExcalidrawElement[], appState: AppState) => {
|
|
16
|
-
scrollX: number;
|
|
17
|
-
scrollY: number;
|
|
18
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
|
|
2
|
-
import type { Bounds } from "@excalidraw/common";
|
|
3
|
-
export type LineSegment<P extends LocalPoint | GlobalPoint> = [P, P];
|
|
4
|
-
export declare function getBBox<P extends LocalPoint | GlobalPoint>(line: LineSegment<P>): Bounds;
|
|
5
|
-
export declare function doBBoxesIntersect(a: Bounds, b: Bounds): boolean;
|
|
6
|
-
export declare function isPointOnLine<P extends GlobalPoint | LocalPoint>(l: LineSegment<P>, p: P): boolean;
|
|
7
|
-
export declare function isPointRightOfLine<P extends GlobalPoint | LocalPoint>(l: LineSegment<P>, p: P): boolean;
|
|
8
|
-
export declare function isLineSegmentTouchingOrCrossingLine<P extends GlobalPoint | LocalPoint>(a: LineSegment<P>, b: LineSegment<P>): boolean;
|
|
9
|
-
export declare function doLineSegmentsIntersect<P extends GlobalPoint | LocalPoint>(a: LineSegment<P>, b: LineSegment<P>): boolean;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type Bounds } from "@excalidraw/common";
|
|
2
|
-
import type { ExcalidrawElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
3
|
-
type Element = NonDeletedExcalidrawElement;
|
|
4
|
-
type Elements = readonly NonDeletedExcalidrawElement[];
|
|
5
|
-
export declare const isElementInsideBBox: (element: Element, bbox: Bounds, eitherDirection?: boolean) => boolean;
|
|
6
|
-
export declare const elementPartiallyOverlapsWithOrContainsBBox: (element: Element, bbox: Bounds) => boolean;
|
|
7
|
-
export declare const elementsOverlappingBBox: ({ elements, bounds, type, errorMargin, }: {
|
|
8
|
-
elements: Elements;
|
|
9
|
-
bounds: Bounds | ExcalidrawElement;
|
|
10
|
-
/** safety offset. Defaults to 0. */
|
|
11
|
-
errorMargin?: number;
|
|
12
|
-
/**
|
|
13
|
-
* - overlap: elements overlapping or inside bounds
|
|
14
|
-
* - contain: elements inside bounds or bounds inside elements
|
|
15
|
-
* - inside: elements inside bounds
|
|
16
|
-
**/
|
|
17
|
-
type: "overlap" | "contain" | "inside";
|
|
18
|
-
}) => NonDeletedExcalidrawElement[];
|
|
19
|
-
export {};
|