@excalidraw/math 0.18.0-2b1c2a9 → 0.18.0-2c3dcc0
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/colors.d.ts +3 -0
- package/dist/types/common/src/constants.d.ts +56 -0
- package/dist/types/common/src/keys.d.ts +4 -0
- package/dist/types/common/src/random.d.ts +7 -0
- package/dist/types/common/src/utils.d.ts +12 -1
- package/dist/types/element/src/Scene.d.ts +1 -1
- package/dist/types/element/src/align.d.ts +4 -1
- package/dist/types/element/src/binding.d.ts +75 -7
- package/dist/types/element/src/bounds.d.ts +10 -2
- package/dist/types/element/src/collision.d.ts +21 -5
- package/dist/types/element/src/comparisons.d.ts +5 -3
- package/dist/types/element/src/cropElement.d.ts +36 -4
- package/dist/types/element/src/delta.d.ts +30 -2
- package/dist/types/element/src/distribute.d.ts +4 -1
- package/dist/types/element/src/dragElements.d.ts +8 -3
- package/dist/types/element/src/duplicate.d.ts +60 -0
- package/dist/types/element/src/elbowArrow.d.ts +5 -0
- package/dist/types/element/src/embeddable.d.ts +2 -1
- package/dist/types/element/src/flowchart.d.ts +6 -8
- package/dist/types/element/src/frame.d.ts +21 -3
- package/dist/types/element/src/groups.d.ts +1 -6
- package/dist/types/element/src/image.d.ts +5 -2
- package/dist/types/element/src/index.d.ts +3 -0
- package/dist/types/element/src/linearElementEditor.d.ts +4 -1
- package/dist/types/element/src/listMarker.d.ts +39 -0
- package/dist/types/element/src/mutateElement.d.ts +1 -1
- package/dist/types/element/src/newElement.d.ts +40 -3
- package/dist/types/element/src/renderElement.d.ts +31 -4
- package/dist/types/element/src/renderEnvironment.d.ts +66 -0
- package/dist/types/element/src/resizeElements.d.ts +15 -5
- package/dist/types/element/src/selection.d.ts +4 -10
- package/dist/types/element/src/shape.d.ts +17 -1
- package/dist/types/element/src/sizeHelpers.d.ts +6 -0
- package/dist/types/element/src/stickyNote.d.ts +191 -0
- package/dist/types/element/src/textElement.d.ts +10 -2
- package/dist/types/element/src/textMeasurements.d.ts +15 -11
- package/dist/types/element/src/textWrapping.d.ts +3 -2
- package/dist/types/element/src/transform.d.ts +30 -7
- package/dist/types/element/src/typeChecks.d.ts +3 -2
- package/dist/types/element/src/types.d.ts +28 -6
- 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 +48 -3
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +62 -208
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +121 -16
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +32 -2
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -546
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +32 -2
- package/dist/types/excalidraw/actions/actionExport.d.ts +39 -9
- package/dist/types/excalidraw/actions/actionFrame.d.ts +92 -479
- package/dist/types/excalidraw/actions/actionGroup.d.ts +34 -4
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +66 -2
- package/dist/types/excalidraw/actions/actionLink.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionProperties.d.ts +42 -8
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +17 -2
- package/dist/types/excalidraw/actions/actionStyles.d.ts +17 -2
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +452 -6
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +201 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +198 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +16 -1
- package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
- package/dist/types/excalidraw/actions/index.d.ts +3 -0
- package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +1 -1
- package/dist/types/excalidraw/appState.d.ts +26 -8
- package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
- package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
- package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
- package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
- package/dist/types/excalidraw/charts/index.d.ts +2 -1
- package/dist/types/excalidraw/components/Actions.d.ts +10 -2
- 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 +129 -218
- package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
- package/dist/types/excalidraw/components/App.host.d.ts +102 -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.selection.d.ts +265 -0
- package/dist/types/excalidraw/components/App.selectionTool.d.ts +94 -0
- package/dist/types/excalidraw/components/App.text.d.ts +194 -0
- package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
- package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +64 -4
- package/dist/types/excalidraw/components/App.wheel.d.ts +30 -0
- package/dist/types/excalidraw/components/App.wrap.d.ts +39 -0
- 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/ConvertElementTypePopup.d.ts +2 -1
- 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/IconButton.d.ts +2 -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/Minimap/Minimap.d.ts +15 -0
- package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
- package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
- package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
- package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
- package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
- package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
- package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
- package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
- package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
- package/dist/types/excalidraw/components/Tools.d.ts +7 -2
- package/dist/types/excalidraw/components/Tooltip.d.ts +26 -2
- 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/canvases/InteractiveCanvas.d.ts +0 -1
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +2 -0
- package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
- package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +13 -2
- package/dist/types/excalidraw/components/icons.d.ts +2 -0
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +3 -0
- package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +2 -2
- package/dist/types/excalidraw/data/blob.d.ts +46 -16
- package/dist/types/excalidraw/data/index.d.ts +3 -3
- package/dist/types/excalidraw/data/json.d.ts +23 -8
- package/dist/types/excalidraw/fonts/Fonts.d.ts +9 -6
- package/dist/types/excalidraw/history.d.ts +10 -4
- package/dist/types/excalidraw/mermaid.d.ts +7 -0
- package/dist/types/excalidraw/reactUtils.d.ts +1 -1
- package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
- package/dist/types/excalidraw/renderer/animation.d.ts +11 -4
- package/dist/types/excalidraw/renderer/helpers.d.ts +18 -0
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
- package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
- package/dist/types/excalidraw/scene/Renderer.d.ts +64 -3
- package/dist/types/excalidraw/scene/export.d.ts +343 -20
- package/dist/types/excalidraw/scene/index.d.ts +1 -1
- package/dist/types/excalidraw/scene/types.d.ts +26 -2
- package/dist/types/excalidraw/types.d.ts +191 -22
- package/dist/types/excalidraw/viewport.d.ts +29 -1
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +12 -1
- package/dist/types/utils/src/index.d.ts +3 -1
- package/dist/types/utils/src/shape.d.ts +2 -2
- package/package.json +2 -2
- package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +0 -31
- package/dist/types/utils/src/export.d.ts +0 -35
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { AppEventBus, type EXPORT_IMAGE_TYPES, Emitter, type EditorInterface, type StylesPanelMode } from "@excalidraw/common";
|
|
3
3
|
import { LinearElementEditor, Scene, Store, type ElementUpdate, StoreDelta, type ApplyToOptions } from "@excalidraw/element";
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
4
|
+
import type { ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered, SceneElementsMap } from "@excalidraw/element/types";
|
|
5
|
+
import type { RenderEnvironment, TransformHandleDirection } from "@excalidraw/element";
|
|
6
6
|
import type { Mutable } from "@excalidraw/common/utility-types";
|
|
7
7
|
import { ActionManager } from "../actions/manager";
|
|
8
8
|
import { History } from "../history";
|
|
@@ -15,15 +15,27 @@ import { isOverScrollBars } from "../scene/scrollbars";
|
|
|
15
15
|
import { LassoTrail } from "../lasso";
|
|
16
16
|
import { EraserTrail } from "../eraser";
|
|
17
17
|
import { AppArrowText } from "./App.arrowText";
|
|
18
|
+
import { AppClipboard } from "./App.clipboard";
|
|
19
|
+
import { AppText } from "./App.text";
|
|
20
|
+
import { AppTextTool } from "./App.textTool";
|
|
18
21
|
import { AppBucketFill } from "./App.bucketFill";
|
|
22
|
+
import { AppToolDrag } from "./App.toolDrag";
|
|
19
23
|
import { AppCursor } from "./App.cursor";
|
|
20
24
|
import { AppDrawShape } from "./App.drawshape";
|
|
25
|
+
import { AppDuplicate } from "./App.duplicate";
|
|
21
26
|
import { AppFlowchart } from "./App.flowchart";
|
|
27
|
+
import { AppModifiers } from "./App.modifiers";
|
|
28
|
+
import { AppPan } from "./App.pan";
|
|
22
29
|
import { AppViewport } from "./App.viewport";
|
|
30
|
+
import { AppWheel } from "./App.wheel";
|
|
31
|
+
import { AppSelection } from "./App.selection";
|
|
32
|
+
import { AppSelectionTool } from "./App.selectionTool";
|
|
33
|
+
import { AppWrap } from "./App.wrap";
|
|
34
|
+
import { AppHost } from "./App.host";
|
|
23
35
|
import { CursorHints } from "./CursorHint";
|
|
24
36
|
import { type OnStateChange } from "./AppStateObserver";
|
|
25
37
|
import type { ExportedElements } from "../data";
|
|
26
|
-
import type { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType, OnUserFollowedPayload, ExcalidrawImperativeAPIEventMap, GenerateDiagramToCode, NullableGridSize,
|
|
38
|
+
import type { AppClassProperties, AppProps, AppState, ElementRenderOverrides, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, PointerDownState, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, KeyboardModifiersObject, ToolType, OnUserFollowedPayload, ExcalidrawImperativeAPIEventMap, GenerateDiagramToCode, NullableGridSize, UIControl } from "../types";
|
|
27
39
|
import type { RoughCanvas } from "roughjs/bin/canvas";
|
|
28
40
|
import type { ActionResult } from "../actions/types";
|
|
29
41
|
declare const editorLifecycleEventBehavior: {
|
|
@@ -82,8 +94,17 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
82
94
|
editorInterface: EditorInterface;
|
|
83
95
|
private stylesPanelMode;
|
|
84
96
|
private excalidrawContainerRef;
|
|
97
|
+
private zenModeTransitionTimer;
|
|
85
98
|
get ownerDocument(): Document;
|
|
86
99
|
get ownerWindow(): Window & typeof globalThis;
|
|
100
|
+
/**
|
|
101
|
+
* Everything binding this editor to the document/window it renders into
|
|
102
|
+
* (render environment, hyperlink tooltip ownership). Delegated to so the
|
|
103
|
+
* cross-document ownership rules live in one place.
|
|
104
|
+
*/
|
|
105
|
+
host: AppHost;
|
|
106
|
+
/** @see AppHost.renderEnvironment */
|
|
107
|
+
get renderEnvironment(): RenderEnvironment;
|
|
87
108
|
scene: Scene;
|
|
88
109
|
fonts: Fonts;
|
|
89
110
|
renderer: Renderer;
|
|
@@ -95,7 +116,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
95
116
|
library: AppClassProperties["library"];
|
|
96
117
|
libraryItemsFromStorage: LibraryItems | undefined;
|
|
97
118
|
id: string;
|
|
98
|
-
|
|
119
|
+
store: Store;
|
|
99
120
|
private history;
|
|
100
121
|
excalidrawContainerValue: {
|
|
101
122
|
container: HTMLDivElement | null;
|
|
@@ -121,14 +142,30 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
121
142
|
private appStateObserver;
|
|
122
143
|
onStateChange: OnStateChange;
|
|
123
144
|
bucketFill: AppBucketFill;
|
|
145
|
+
duplicate: AppDuplicate;
|
|
146
|
+
toolDrag: AppToolDrag;
|
|
124
147
|
flowchart: AppFlowchart;
|
|
125
148
|
cursor: AppCursor;
|
|
126
149
|
arrowText: AppArrowText;
|
|
150
|
+
pan: AppPan;
|
|
151
|
+
textTool: AppTextTool;
|
|
152
|
+
clipboard: AppClipboard;
|
|
153
|
+
text: AppText;
|
|
127
154
|
viewport: AppViewport;
|
|
155
|
+
wheel: AppWheel;
|
|
156
|
+
selection: AppSelection;
|
|
157
|
+
selectionTool: AppSelectionTool;
|
|
158
|
+
wrap: AppWrap;
|
|
128
159
|
bindModeHandler: ReturnType<typeof setTimeout> | null;
|
|
129
|
-
private textWysiwygSubmitHandler;
|
|
130
160
|
hitLinkElement?: NonDeletedExcalidrawElement;
|
|
131
161
|
lastPointerDownEvent: React.PointerEvent<HTMLElement> | null;
|
|
162
|
+
/**
|
|
163
|
+
* the handle of the resize in progress while `state.isResizing` — for UI
|
|
164
|
+
* that words itself by handle (a sticky note's corners resize
|
|
165
|
+
* proportionally, its edges freely); not app state, so it costs no
|
|
166
|
+
* re-render of its own
|
|
167
|
+
*/
|
|
168
|
+
activeResizeHandle: TransformHandleDirection | null;
|
|
132
169
|
lastPointerUpEvent: React.PointerEvent<HTMLElement> | PointerEvent | null;
|
|
133
170
|
lastPointerUpIsDoubleClick: boolean;
|
|
134
171
|
lastPointerMoveEvent: PointerEvent | null;
|
|
@@ -138,11 +175,6 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
138
175
|
y: number;
|
|
139
176
|
} | null;
|
|
140
177
|
private lastCompletedCanvasClicks;
|
|
141
|
-
/** previous frame pointer coords */
|
|
142
|
-
previousPointerMoveCoords: {
|
|
143
|
-
x: number;
|
|
144
|
-
y: number;
|
|
145
|
-
} | null;
|
|
146
178
|
drawShape: AppDrawShape;
|
|
147
179
|
laserTrails: LaserTrails;
|
|
148
180
|
eraserTrail: EraserTrail;
|
|
@@ -185,7 +217,10 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
185
217
|
element: NonDeleted<ExcalidrawElement> | null;
|
|
186
218
|
allHitElements: NonDeleted<ExcalidrawElement>[];
|
|
187
219
|
wasAddedToSelection: boolean;
|
|
220
|
+
cycleTarget: NonDeleted<ExcalidrawElement> | null;
|
|
188
221
|
hasBeenDuplicated: boolean;
|
|
222
|
+
advancedListMarkers: readonly import("@excalidraw/element").ListMarkerAdvance[];
|
|
223
|
+
editedTextId: import("@excalidraw/element/types").ExcalidrawTextElement["id"] | null;
|
|
189
224
|
hasHitCommonBoundingBoxOfSelectedElements: boolean;
|
|
190
225
|
arrowLabel: boolean;
|
|
191
226
|
};
|
|
@@ -200,6 +235,10 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
200
235
|
x: number;
|
|
201
236
|
y: number;
|
|
202
237
|
};
|
|
238
|
+
lastOffset: {
|
|
239
|
+
x: number;
|
|
240
|
+
y: number;
|
|
241
|
+
};
|
|
203
242
|
blockDragging: boolean;
|
|
204
243
|
};
|
|
205
244
|
eventListeners: {
|
|
@@ -248,7 +287,10 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
248
287
|
element: NonDeleted<ExcalidrawElement> | null;
|
|
249
288
|
allHitElements: NonDeleted<ExcalidrawElement>[];
|
|
250
289
|
wasAddedToSelection: boolean;
|
|
290
|
+
cycleTarget: NonDeleted<ExcalidrawElement> | null;
|
|
251
291
|
hasBeenDuplicated: boolean;
|
|
292
|
+
advancedListMarkers: readonly import("@excalidraw/element").ListMarkerAdvance[];
|
|
293
|
+
editedTextId: import("@excalidraw/element/types").ExcalidrawTextElement["id"] | null;
|
|
252
294
|
hasHitCommonBoundingBoxOfSelectedElements: boolean;
|
|
253
295
|
arrowLabel: boolean;
|
|
254
296
|
};
|
|
@@ -263,6 +305,10 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
263
305
|
x: number;
|
|
264
306
|
y: number;
|
|
265
307
|
};
|
|
308
|
+
lastOffset: {
|
|
309
|
+
x: number;
|
|
310
|
+
y: number;
|
|
311
|
+
};
|
|
266
312
|
blockDragging: boolean;
|
|
267
313
|
};
|
|
268
314
|
eventListeners: {
|
|
@@ -281,7 +327,14 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
281
327
|
}>]>;
|
|
282
328
|
missingPointerEventCleanupEmitter: Emitter<[event: PointerEvent | null]>;
|
|
283
329
|
onRemoveEventListenersEmitter: Emitter<[]>;
|
|
330
|
+
modifiers: AppModifiers;
|
|
284
331
|
api: ExcalidrawImperativeAPI;
|
|
332
|
+
private elementRenderOverrides;
|
|
333
|
+
/** offsets of `elementRenderOverrides`; keeps its identity while they don't change */
|
|
334
|
+
private elementRenderOffsets;
|
|
335
|
+
private renderOverridesUpdatePending;
|
|
336
|
+
private getRenderOverrideConfig;
|
|
337
|
+
private getElementRenderState;
|
|
285
338
|
private createExcalidrawAPI;
|
|
286
339
|
constructor(props: AppProps);
|
|
287
340
|
/**
|
|
@@ -349,10 +402,13 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
349
402
|
* matters where view-mode gates apply.)
|
|
350
403
|
*/
|
|
351
404
|
isActiveToolPointerCapturing(): boolean;
|
|
352
|
-
/**
|
|
405
|
+
/**
|
|
406
|
+
* Whether Excalidraw's default UI is rendered (with `ui.disabled`, minus the
|
|
407
|
+
* controls it removes).
|
|
408
|
+
*/
|
|
353
409
|
isDefaultUIEnabled(props?: Pick<AppProps, "ui">): boolean;
|
|
354
410
|
/** Whether an individual default UI control is rendered. */
|
|
355
|
-
isUIControlEnabled(control:
|
|
411
|
+
isUIControlEnabled: (control: UIControl, props?: Pick<AppProps, "ui">) => boolean;
|
|
356
412
|
updateEditorAtom: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
|
|
357
413
|
private onWindowMessage;
|
|
358
414
|
private handleSkipBindMode;
|
|
@@ -365,7 +421,6 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
365
421
|
* If disabled, returns null.
|
|
366
422
|
*/
|
|
367
423
|
getEffectiveGridSize: () => NullableGridSize;
|
|
368
|
-
private getTextCreationGridPoint;
|
|
369
424
|
private getHTMLIFrameElement;
|
|
370
425
|
/**
|
|
371
426
|
* AI-generated iframe elements aren't interactive while their generation
|
|
@@ -412,7 +467,8 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
412
467
|
private onBlur;
|
|
413
468
|
private onUnload;
|
|
414
469
|
private disableEvent;
|
|
415
|
-
private
|
|
470
|
+
private isFileDropEnabled;
|
|
471
|
+
private onDragOver;
|
|
416
472
|
private handleNavigationModeKeyDown;
|
|
417
473
|
/**
|
|
418
474
|
* PageUp/PageDown scroll the canvas by a page — vertically, or
|
|
@@ -457,16 +513,20 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
457
513
|
private onFullscreenChange;
|
|
458
514
|
private removeEventListeners;
|
|
459
515
|
private addEventListeners;
|
|
516
|
+
getSnapshotBeforeUpdate(prevProps: AppProps, prevState: AppState): null;
|
|
517
|
+
/**
|
|
518
|
+
* Flags the container while toggling zen mode so that UI chrome
|
|
519
|
+
* (backgrounds etc.) animates only then, and hover transitions stay
|
|
520
|
+
* instant. A data attribute so that React doesn't reset it on re-render.
|
|
521
|
+
*/
|
|
522
|
+
private markZenModeTransition;
|
|
523
|
+
private unmarkZenModeTransition;
|
|
460
524
|
componentDidUpdate(prevProps: AppProps, prevState: AppState): void;
|
|
461
525
|
private renderInteractiveSceneCallback;
|
|
462
526
|
private onScroll;
|
|
463
|
-
private onCut;
|
|
464
|
-
private onCopy;
|
|
465
527
|
private static resetTapTwice;
|
|
466
528
|
private onTouchStart;
|
|
467
529
|
private onTouchEnd;
|
|
468
|
-
private insertClipboardContent;
|
|
469
|
-
pasteFromClipboard: (event: ClipboardEvent) => Promise<void>;
|
|
470
530
|
addElementsFromPasteOrLibrary: (opts: {
|
|
471
531
|
elements: readonly ExcalidrawElement[];
|
|
472
532
|
files: BinaryFiles | null;
|
|
@@ -478,8 +538,6 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
478
538
|
fit?: SetViewportOptions["fit"];
|
|
479
539
|
preserveFrameChildrenOrder?: boolean;
|
|
480
540
|
}) => void;
|
|
481
|
-
private addElementsFromMixedContentPaste;
|
|
482
|
-
private addTextFromPaste;
|
|
483
541
|
setAppState: React.Component<any, AppState>["setState"];
|
|
484
542
|
removePointer: (event: React.PointerEvent<HTMLElement> | PointerEvent) => void;
|
|
485
543
|
toggleLock: (source?: "keyboard" | "ui") => void;
|
|
@@ -491,10 +549,11 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
491
549
|
* imperative API emitter */
|
|
492
550
|
emitUserFollowIntent: (payload: OnUserFollowedPayload) => void;
|
|
493
551
|
/** emits an UNFOLLOW intent if currently following someone — use on
|
|
494
|
-
*
|
|
552
|
+
* viewport changes that take the view over from the followed user (user
|
|
553
|
+
* pans and zooms, `setViewport` navigation) */
|
|
495
554
|
requestUnfollow: () => void;
|
|
496
555
|
setToast: (toast: AppState["toast"]) => void;
|
|
497
|
-
|
|
556
|
+
private showSceneReplacedToast;
|
|
498
557
|
/**
|
|
499
558
|
* adds supplied files to existing files in the appState.
|
|
500
559
|
* NOTE if file already exists in editor state, the file data is not updated
|
|
@@ -518,6 +577,10 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
518
577
|
*/
|
|
519
578
|
captureUpdate?: SceneData["captureUpdate"];
|
|
520
579
|
}) => void;
|
|
580
|
+
/**
|
|
581
|
+
* see {@link ExcalidrawImperativeAPI.setElementRenderOverrides} for details
|
|
582
|
+
*/
|
|
583
|
+
setElementRenderOverrides: (overrides: ElementRenderOverrides | null) => void;
|
|
521
584
|
applyDeltas: (deltas: StoreDelta[], options?: ApplyToOptions) => [SceneElementsMap, AppState, boolean];
|
|
522
585
|
mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
|
|
523
586
|
triggerRender: (
|
|
@@ -565,13 +628,6 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
565
628
|
private onGestureStart;
|
|
566
629
|
private onGestureChange;
|
|
567
630
|
private onGestureEnd;
|
|
568
|
-
private handleTextWysiwyg;
|
|
569
|
-
private deselectElements;
|
|
570
|
-
private getSelectedTextElement;
|
|
571
|
-
private getSelectedTextEditingContainerAtPosition;
|
|
572
|
-
getTextElementAtPosition(x: number, y: number): NonDeleted<ExcalidrawTextElement> | null;
|
|
573
|
-
private isHittingTextAutoResizeHandle;
|
|
574
|
-
private handleTextAutoResizeHandlePointerDown;
|
|
575
631
|
getElementAtPosition(x: number, y: number, opts?: ({
|
|
576
632
|
includeBoundTextElement?: boolean;
|
|
577
633
|
includeLockedElements?: boolean;
|
|
@@ -584,172 +640,22 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
584
640
|
includeBoundTextElement?: boolean;
|
|
585
641
|
includeLockedElements?: boolean;
|
|
586
642
|
}): NonDeleted<ExcalidrawElement>[];
|
|
643
|
+
/**
|
|
644
|
+
* Whether the element's frame clips it away at the position — hitting a
|
|
645
|
+
* frame's element from outside the frame is not considered a hit.
|
|
646
|
+
*/
|
|
647
|
+
isClippedByFrameAt(x: number, y: number, element: ExcalidrawElement): boolean;
|
|
587
648
|
getElementHitThreshold(element: ExcalidrawElement): number;
|
|
588
649
|
hitElement(x: number, y: number, element: NonDeletedExcalidrawElement, considerBoundingBox?: boolean): boolean;
|
|
589
|
-
getTextBindableContainerAtPosition(x: number, y: number): (Readonly<{
|
|
590
|
-
id: string;
|
|
591
|
-
x: number;
|
|
592
|
-
y: number;
|
|
593
|
-
strokeColor: string;
|
|
594
|
-
backgroundColor: string;
|
|
595
|
-
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
596
|
-
strokeWidth: number;
|
|
597
|
-
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
598
|
-
roundness: null | {
|
|
599
|
-
type: import("@excalidraw/element/types").RoundnessType;
|
|
600
|
-
value?: number;
|
|
601
|
-
};
|
|
602
|
-
roughness: number;
|
|
603
|
-
opacity: number;
|
|
604
|
-
width: number;
|
|
605
|
-
height: number;
|
|
606
|
-
angle: Radians;
|
|
607
|
-
seed: number;
|
|
608
|
-
version: number;
|
|
609
|
-
versionNonce: number;
|
|
610
|
-
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
611
|
-
isDeleted: boolean;
|
|
612
|
-
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
613
|
-
frameId: string | null;
|
|
614
|
-
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
615
|
-
updated: number;
|
|
616
|
-
link: string | null;
|
|
617
|
-
locked: boolean;
|
|
618
|
-
customData?: Record<string, any>;
|
|
619
|
-
}> & {
|
|
620
|
-
type: "rectangle";
|
|
621
|
-
} & {
|
|
622
|
-
isDeleted: false;
|
|
623
|
-
}) | (Readonly<{
|
|
624
|
-
id: string;
|
|
625
|
-
x: number;
|
|
626
|
-
y: number;
|
|
627
|
-
strokeColor: string;
|
|
628
|
-
backgroundColor: string;
|
|
629
|
-
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
630
|
-
strokeWidth: number;
|
|
631
|
-
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
632
|
-
roundness: null | {
|
|
633
|
-
type: import("@excalidraw/element/types").RoundnessType;
|
|
634
|
-
value?: number;
|
|
635
|
-
};
|
|
636
|
-
roughness: number;
|
|
637
|
-
opacity: number;
|
|
638
|
-
width: number;
|
|
639
|
-
height: number;
|
|
640
|
-
angle: Radians;
|
|
641
|
-
seed: number;
|
|
642
|
-
version: number;
|
|
643
|
-
versionNonce: number;
|
|
644
|
-
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
645
|
-
isDeleted: boolean;
|
|
646
|
-
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
647
|
-
frameId: string | null;
|
|
648
|
-
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
649
|
-
updated: number;
|
|
650
|
-
link: string | null;
|
|
651
|
-
locked: boolean;
|
|
652
|
-
customData?: Record<string, any>;
|
|
653
|
-
}> & {
|
|
654
|
-
type: "diamond";
|
|
655
|
-
} & {
|
|
656
|
-
isDeleted: false;
|
|
657
|
-
}) | (Readonly<{
|
|
658
|
-
id: string;
|
|
659
|
-
x: number;
|
|
660
|
-
y: number;
|
|
661
|
-
strokeColor: string;
|
|
662
|
-
backgroundColor: string;
|
|
663
|
-
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
664
|
-
strokeWidth: number;
|
|
665
|
-
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
666
|
-
roundness: null | {
|
|
667
|
-
type: import("@excalidraw/element/types").RoundnessType;
|
|
668
|
-
value?: number;
|
|
669
|
-
};
|
|
670
|
-
roughness: number;
|
|
671
|
-
opacity: number;
|
|
672
|
-
width: number;
|
|
673
|
-
height: number;
|
|
674
|
-
angle: Radians;
|
|
675
|
-
seed: number;
|
|
676
|
-
version: number;
|
|
677
|
-
versionNonce: number;
|
|
678
|
-
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
679
|
-
isDeleted: boolean;
|
|
680
|
-
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
681
|
-
frameId: string | null;
|
|
682
|
-
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
683
|
-
updated: number;
|
|
684
|
-
link: string | null;
|
|
685
|
-
locked: boolean;
|
|
686
|
-
customData?: Record<string, any>;
|
|
687
|
-
}> & {
|
|
688
|
-
type: "ellipse";
|
|
689
|
-
} & {
|
|
690
|
-
isDeleted: false;
|
|
691
|
-
}) | (Readonly<{
|
|
692
|
-
id: string;
|
|
693
|
-
x: number;
|
|
694
|
-
y: number;
|
|
695
|
-
strokeColor: string;
|
|
696
|
-
backgroundColor: string;
|
|
697
|
-
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
698
|
-
strokeWidth: number;
|
|
699
|
-
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
700
|
-
roundness: null | {
|
|
701
|
-
type: import("@excalidraw/element/types").RoundnessType;
|
|
702
|
-
value?: number;
|
|
703
|
-
};
|
|
704
|
-
roughness: number;
|
|
705
|
-
opacity: number;
|
|
706
|
-
width: number;
|
|
707
|
-
height: number;
|
|
708
|
-
angle: Radians;
|
|
709
|
-
seed: number;
|
|
710
|
-
version: number;
|
|
711
|
-
versionNonce: number;
|
|
712
|
-
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
713
|
-
isDeleted: boolean;
|
|
714
|
-
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
715
|
-
frameId: string | null;
|
|
716
|
-
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
717
|
-
updated: number;
|
|
718
|
-
link: string | null;
|
|
719
|
-
locked: boolean;
|
|
720
|
-
customData?: Record<string, any>;
|
|
721
|
-
}> & Readonly<{
|
|
722
|
-
type: "line" | "arrow";
|
|
723
|
-
points: readonly LocalPoint[];
|
|
724
|
-
startBinding: import("@excalidraw/element/types").FixedPointBinding | null;
|
|
725
|
-
endBinding: import("@excalidraw/element/types").FixedPointBinding | null;
|
|
726
|
-
startArrowhead: import("@excalidraw/element/types").Arrowhead | null;
|
|
727
|
-
endArrowhead: import("@excalidraw/element/types").Arrowhead | null;
|
|
728
|
-
}> & Readonly<{
|
|
729
|
-
type: "arrow";
|
|
730
|
-
elbowed: boolean;
|
|
731
|
-
}> & {
|
|
732
|
-
isDeleted: false;
|
|
733
|
-
}) | null;
|
|
734
|
-
/**
|
|
735
|
-
* Whether a text element's content is still being authored.
|
|
736
|
-
*
|
|
737
|
-
* Creating a text reverts the tool to selection during pointerdown, so the
|
|
738
|
-
* pointerup that follows looks like an ordinary canvas click and would
|
|
739
|
-
* capture the still-empty element as a history entry of its own. Undo would
|
|
740
|
-
* then rewind only the typing, restoring an invisible, zero-content element
|
|
741
|
-
* (and, for an endpoint label, leaving the arrow bound to it) rather than
|
|
742
|
-
* removing it. The editor's own submit captures the finished text instead,
|
|
743
|
-
* so the whole create-and-type lands in a single entry.
|
|
744
|
-
*/
|
|
745
|
-
private isEditingTextContent;
|
|
746
|
-
private startTextEditing;
|
|
747
650
|
private startImageCropping;
|
|
748
|
-
|
|
651
|
+
finishImageCropping: () => void;
|
|
749
652
|
private shouldHandleBrowserCanvasDoubleClick;
|
|
750
653
|
private handleCanvasDoubleClick;
|
|
751
654
|
private handleCanvasClick;
|
|
752
|
-
|
|
655
|
+
getElementLinkAtPosition: (scenePointer: Readonly<{
|
|
656
|
+
x: number;
|
|
657
|
+
y: number;
|
|
658
|
+
}>, hitElementMightBeLocked: NonDeletedExcalidrawElement | null) => NonDeletedExcalidrawElement | undefined;
|
|
753
659
|
private handleElementLinkClick;
|
|
754
660
|
/**
|
|
755
661
|
* Applies (or clears) the element-link hover affordances — pointer cursor
|
|
@@ -789,7 +695,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
789
695
|
excludeElementIds?: AppState["selectedElementIds"];
|
|
790
696
|
currentFrameId?: ExcalidrawElement["frameId"];
|
|
791
697
|
}) => NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
792
|
-
|
|
698
|
+
updateFrameToHighlight: (frameToHighlight: AppState["frameToHighlight"]) => void;
|
|
793
699
|
private maybeUpdateFrameToHighlightOnPointerMove;
|
|
794
700
|
insertNewElements: (elements: readonly ExcalidrawElement[]) => void;
|
|
795
701
|
insertNewElement: (element: ExcalidrawElement) => void;
|
|
@@ -802,6 +708,13 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
802
708
|
*/
|
|
803
709
|
handleHoverSelectedLinearElement(linearElementEditor: LinearElementEditor, scenePointerX: number, scenePointerY: number): void;
|
|
804
710
|
private handleCanvasPointerDown;
|
|
711
|
+
/**
|
|
712
|
+
* The browser took the pointer over (scroll, pinch, palm rejection): no
|
|
713
|
+
* pointerup will follow, so the gesture is torn down here and now — the
|
|
714
|
+
* same cleanup a lost pointerup gets at the next press, only not left
|
|
715
|
+
* lying in wait for it, where its replay would tangle with that press.
|
|
716
|
+
*/
|
|
717
|
+
private handleCanvasPointerCancel;
|
|
805
718
|
private handleCanvasPointerUp;
|
|
806
719
|
private maybeOpenContextMenuAfterPointerDownOnTouchDevices;
|
|
807
720
|
private resetContextMenuTimer;
|
|
@@ -811,7 +724,6 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
811
724
|
* pointerup handlers manually
|
|
812
725
|
*/
|
|
813
726
|
private maybeCleanupAfterMissingPointerUp;
|
|
814
|
-
handleCanvasPanUsingWheelOrSpaceDrag: (event: React.PointerEvent<HTMLElement> | MouseEvent) => boolean;
|
|
815
727
|
private updateGestureOnPointerDown;
|
|
816
728
|
/**
|
|
817
729
|
* Tracks the pointer within the ongoing multi-touch gesture and applies
|
|
@@ -820,14 +732,6 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
820
732
|
private updateMultiTouchGesture;
|
|
821
733
|
private initialPointerDownState;
|
|
822
734
|
private handleDraggingScrollBar;
|
|
823
|
-
private clearSelectionIfNotUsingSelection;
|
|
824
|
-
/**
|
|
825
|
-
* @returns whether the pointer event has been completely handled
|
|
826
|
-
*/
|
|
827
|
-
private handleSelectionOnPointerDown;
|
|
828
|
-
private isASelectedElement;
|
|
829
|
-
private isHittingCommonBoundingBoxOfSelectedElements;
|
|
830
|
-
private handleTextOnPointerDown;
|
|
831
735
|
private handleFreeDrawElementOnPointerDown;
|
|
832
736
|
insertIframeElement: ({ sceneX, sceneY, width, height, }: {
|
|
833
737
|
sceneX: number;
|
|
@@ -842,12 +746,14 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
842
746
|
}) => NonDeleted<ExcalidrawEmbeddableElement> | undefined;
|
|
843
747
|
private newImagePlaceholder;
|
|
844
748
|
private handleLinearElementOnPointerDown;
|
|
845
|
-
|
|
846
|
-
|
|
749
|
+
getCurrentItemRoundness(elementType: "selection" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "iframe" | "embeddable"): {
|
|
750
|
+
type: 2 | 3;
|
|
751
|
+
} | null;
|
|
752
|
+
getCurrentItemStrokeWidth(elementType: ExcalidrawElement["type"]): number;
|
|
847
753
|
private createGenericElementOnPointerDown;
|
|
848
754
|
private createFrameElementOnPointerDown;
|
|
849
|
-
|
|
850
|
-
|
|
755
|
+
maybeCacheReferenceSnapPoints(event: KeyboardModifiersObject, selectedElements: readonly NonDeletedExcalidrawElement[], recomputeAnyways?: boolean): void;
|
|
756
|
+
maybeCacheVisibleGaps(event: KeyboardModifiersObject, selectedElements: readonly NonDeletedExcalidrawElement[], recomputeAnyways?: boolean): void;
|
|
851
757
|
private onKeyDownFromPointerDownHandler;
|
|
852
758
|
private onKeyUpFromPointerDownHandler;
|
|
853
759
|
private onPointerMoveFromPointerDownHandler;
|
|
@@ -872,25 +778,30 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
872
778
|
/** generally you should use `addNewImagesToImageCache()` directly if you need
|
|
873
779
|
* to render new images. This is just a failsafe */
|
|
874
780
|
private scheduleImageRefresh;
|
|
875
|
-
private clearSelection;
|
|
876
781
|
private handleInteractiveCanvasRef;
|
|
877
|
-
|
|
782
|
+
insertImages: (imageFiles: File[], sceneX: number, sceneY: number) => Promise<void>;
|
|
878
783
|
private handleAppOnDrop;
|
|
879
|
-
|
|
784
|
+
/** @returns true if the file replaced the scene */
|
|
785
|
+
loadFileToCanvas: (file: File, fileHandle: FileSystemFileHandle | null, insertPosition?: {
|
|
786
|
+
clientX: number;
|
|
787
|
+
clientY: number;
|
|
788
|
+
}) => Promise<true | undefined>;
|
|
880
789
|
private handleCanvasContextMenu;
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
790
|
+
/** opens the context menu for the element under the pointer, or the canvas */
|
|
791
|
+
openContextMenu: (pointer: {
|
|
792
|
+
clientX: number;
|
|
793
|
+
clientY: number;
|
|
794
|
+
button?: number;
|
|
795
|
+
pointerType?: string;
|
|
796
|
+
}) => void;
|
|
797
|
+
maybeDragNewGenericElement: (pointerDownState: PointerDownState, event: MouseEvent | KeyboardEvent, informMutation?: boolean) => void;
|
|
884
798
|
private getContextMenuItems;
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
} | undefined;
|
|
892
|
-
private savePointer;
|
|
893
|
-
private resetShouldCacheIgnoreZoomDebounced;
|
|
799
|
+
savePointer: (x: number, y: number, button: "up" | "down") => void;
|
|
800
|
+
resetShouldCacheIgnoreZoomDebounced: {
|
|
801
|
+
(): void;
|
|
802
|
+
flush(): void;
|
|
803
|
+
cancel(): void;
|
|
804
|
+
};
|
|
894
805
|
private updateDOMRect;
|
|
895
806
|
refresh: () => void;
|
|
896
807
|
private getCanvasOffsets;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { duplicateElements } from "@excalidraw/element";
|
|
2
|
+
import type { ExcalidrawElement, ExcalidrawTextElement } from "@excalidraw/element/types";
|
|
3
|
+
import type { PointerDownState } from "../types";
|
|
4
|
+
import type App from "./App";
|
|
5
|
+
type Duplication = Pick<ReturnType<typeof duplicateElements>, "duplicatedElements" | "duplicateElementsMap" | "origElementsMap" | "origIdToDuplicateId" | "duplicateIdToOrigId">;
|
|
6
|
+
/**
|
|
7
|
+
* Owns the duplication paths which involve the host (`props.onDuplicate`):
|
|
8
|
+
* duplicating elements into the scene (paste, library insert etc.), and
|
|
9
|
+
* duplicating the dragged selection (alt-drag). The duplicate action shares
|
|
10
|
+
* `runOnDuplicate()`.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AppDuplicate {
|
|
13
|
+
private app;
|
|
14
|
+
private dependencies;
|
|
15
|
+
constructor(app: App, dependencies: {
|
|
16
|
+
/** pointers currently down */
|
|
17
|
+
getPointerCount: () => number;
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Hands the duplication over to the host's `props.onDuplicate` (if any),
|
|
21
|
+
* and reconciles what it returned with the duplicates.
|
|
22
|
+
*
|
|
23
|
+
* @returns next elements, and the duplicates that weren't vetoed
|
|
24
|
+
*/
|
|
25
|
+
runOnDuplicate: (duplication: Duplication, nextElements: ExcalidrawElement[],
|
|
26
|
+
/** excludes the duplicated elements */
|
|
27
|
+
prevElements: readonly ExcalidrawElement[]) => {
|
|
28
|
+
elements: ExcalidrawElement[];
|
|
29
|
+
duplicatedElements: import("@excalidraw/element/types").NonDeletedExcalidrawElement[];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Runs `update` once what's pending is committed, capturing what it changes
|
|
33
|
+
* (if it returns `true`) as a separate undo step.
|
|
34
|
+
*/
|
|
35
|
+
private afterCommit;
|
|
36
|
+
/**
|
|
37
|
+
* Advances the list markers of the duplicated texts (`1.` -> `2.`) once
|
|
38
|
+
* the duplication is committed, as a separate undo step, so that undo
|
|
39
|
+
* reverts the markers first.
|
|
40
|
+
*/
|
|
41
|
+
advanceListMarkers: (duplicatedElements: readonly ExcalidrawElement[]) => void;
|
|
42
|
+
/**
|
|
43
|
+
* The text whose editing an alt-press on it ended, while the press is
|
|
44
|
+
* handed over to the canvas (see `handOverTextEditorPress()`).
|
|
45
|
+
*/
|
|
46
|
+
handedOverTextId: ExcalidrawTextElement["id"] | null;
|
|
47
|
+
/**
|
|
48
|
+
* An alt-press on the text being edited, once it ended the editing, is
|
|
49
|
+
* handed over to the canvas, for the text to be alt-dragged (duplicated) as
|
|
50
|
+
* on the canvas — its duplicate is then edited on drop.
|
|
51
|
+
*/
|
|
52
|
+
handOverTextEditorPress: (event: PointerEvent, textElementId: ExcalidrawTextElement["id"]) => void;
|
|
53
|
+
/**
|
|
54
|
+
* The pointer down a handed-over press is replayed as (see
|
|
55
|
+
* `handOverTextEditorPress()`) moves what was edited — the text, or its
|
|
56
|
+
* container — and nothing beneath the editor, which reaches past the text:
|
|
57
|
+
* no resize handle, nor an arrow's point, midpoint or label.
|
|
58
|
+
*
|
|
59
|
+
* @returns `false` if the pointer down isn't a handed-over press
|
|
60
|
+
*/
|
|
61
|
+
hitEditedElement: (pointerDownState: PointerDownState) => boolean;
|
|
62
|
+
/**
|
|
63
|
+
* On alt-drag drop: the list markers advanced along with the drag go back,
|
|
64
|
+
* for the drag to be committed as is, and forth again once it is, as
|
|
65
|
+
* a separate undo step (before the browser gets to paint either).
|
|
66
|
+
*
|
|
67
|
+
* A duplicate is then edited (once the drop is committed): a single list
|
|
68
|
+
* item with text after its marker, with that text selected (`1. |foo|`),
|
|
69
|
+
* as it's likely to differ from the original's — or else the duplicate of
|
|
70
|
+
* the text the drag ended the editing of, with all of it selected.
|
|
71
|
+
*/
|
|
72
|
+
commitDraggedDuplicates: ({ hit }: PointerDownState, { editText, }: {
|
|
73
|
+
/** `false` if the drag didn't end with a genuine pointerup */
|
|
74
|
+
editText: boolean;
|
|
75
|
+
}) => void;
|
|
76
|
+
private editDuplicatedText;
|
|
77
|
+
/**
|
|
78
|
+
* Duplicates elements so that they end up centered at the scene coords
|
|
79
|
+
* (and in the frame at that point, if any). Doesn't update the scene.
|
|
80
|
+
*
|
|
81
|
+
* @returns `null` if the host vetoed the duplication
|
|
82
|
+
*/
|
|
83
|
+
duplicateAtSceneCoords: (elements: readonly ExcalidrawElement[], { x, y }: {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
}, opts?: {
|
|
87
|
+
retainSeed?: boolean;
|
|
88
|
+
preserveFrameChildrenOrder?: boolean;
|
|
89
|
+
}) => {
|
|
90
|
+
nextElements: ExcalidrawElement[];
|
|
91
|
+
duplicatedElements: import("@excalidraw/element/types").NonDeletedExcalidrawElement[];
|
|
92
|
+
} | null;
|
|
93
|
+
/**
|
|
94
|
+
* Duplicates the selection being dragged: the originals go back to where
|
|
95
|
+
* the drag started, and the drag continues with the duplicates.
|
|
96
|
+
*
|
|
97
|
+
* If the host vetoes the duplication, the originals keep being dragged.
|
|
98
|
+
*/
|
|
99
|
+
duplicateDraggedSelection: (pointerDownState: PointerDownState, event: PointerEvent) => void;
|
|
100
|
+
}
|
|
101
|
+
export {};
|