@myoc/element 0.19.521 → 0.19.523
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 +3049 -1222
- package/dist/dev/index.js.map +4 -4
- package/dist/prod/index.js +17 -17
- package/dist/types/common/src/colors.d.ts +14 -0
- package/dist/types/common/src/constants.d.ts +3 -0
- package/dist/types/common/src/keys.d.ts +2 -0
- package/dist/types/common/src/points.d.ts +1 -1
- package/dist/types/common/src/utils.d.ts +1 -1
- 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/arrowEndpointText.d.ts +49 -0
- package/dist/types/element/src/arrows/focus.d.ts +5 -2
- package/dist/types/element/src/binding.d.ts +17 -8
- package/dist/types/element/src/bounds.d.ts +5 -9
- package/dist/types/element/src/bucketFill.d.ts +110 -0
- package/dist/types/element/src/collision.d.ts +1 -1
- package/dist/types/element/src/comparisons.d.ts +4 -4
- package/dist/types/element/src/convertToShape.d.ts +23 -0
- package/dist/types/element/src/distribute.d.ts +2 -2
- package/dist/types/element/src/dragElements.d.ts +27 -0
- 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 +7 -7
- 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 +4 -1
- package/dist/types/element/src/linearElementEditor.d.ts +17 -10
- package/dist/types/element/src/newElement.d.ts +13 -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/shape.d.ts +12 -0
- package/dist/types/element/src/sortElements.d.ts +10 -0
- package/dist/types/element/src/textElement.d.ts +12 -9
- 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 +2 -1
- package/dist/types/element/src/zindex.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +24 -8
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +134 -967
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +24 -8
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +12 -4
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +38 -13
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +9 -4
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +12 -4
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +25 -9
- package/dist/types/excalidraw/actions/actionExport.d.ts +26 -10
- package/dist/types/excalidraw/actions/actionFrame.d.ts +47 -205
- package/dist/types/excalidraw/actions/actionGroup.d.ts +39 -23
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +15 -6
- package/dist/types/excalidraw/actions/actionLink.d.ts +13 -5
- package/dist/types/excalidraw/actions/actionMenu.d.ts +12 -4
- package/dist/types/excalidraw/actions/actionProperties.d.ts +43 -24
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +17 -9
- package/dist/types/excalidraw/actions/actionStyles.d.ts +12 -4
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +14 -6
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +16 -9
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +13 -5
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +13 -5
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +16 -9
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +13 -5
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +14 -6
- package/dist/types/excalidraw/actions/index.d.ts +2 -3
- package/dist/types/excalidraw/actions/manager.d.ts +1 -0
- package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +8 -4
- package/dist/types/excalidraw/appState.d.ts +10 -5
- package/dist/types/excalidraw/components/Actions.d.ts +18 -14
- package/dist/types/excalidraw/components/App.arrowText.d.ts +72 -0
- package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
- package/dist/types/excalidraw/components/App.cursor.d.ts +30 -0
- package/dist/types/excalidraw/components/App.d.ts +389 -61
- package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
- package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +73 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -3
- package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +3 -1
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -2
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
- package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +31 -0
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +1 -1
- package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
- package/dist/types/excalidraw/components/{ToolButton.d.ts → IconButton.d.ts} +16 -19
- package/dist/types/excalidraw/components/Island.d.ts +7 -0
- package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
- package/dist/types/excalidraw/components/LayerUI.d.ts +5 -2
- package/dist/types/excalidraw/components/LockButton.d.ts +9 -0
- package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
- package/dist/types/excalidraw/components/{MobileToolBar.d.ts → MobileToolbar.d.ts} +3 -4
- package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
- package/dist/types/excalidraw/components/Popover.d.ts +1 -3
- package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
- 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/ToolPopover.d.ts +3 -6
- package/dist/types/excalidraw/components/Toolbar.d.ts +13 -0
- package/dist/types/excalidraw/components/Tools.d.ts +151 -0
- package/dist/types/excalidraw/components/UserList.d.ts +3 -2
- package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -0
- package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -2
- package/dist/types/excalidraw/components/icons.d.ts +4 -1
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +0 -2
- package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
- package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
- package/dist/types/excalidraw/context/tunnels.d.ts +0 -1
- package/dist/types/excalidraw/data/blob.d.ts +14 -6
- package/dist/types/excalidraw/data/index.d.ts +4 -4
- package/dist/types/excalidraw/data/json.d.ts +20 -12
- package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
- package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
- package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +10 -3
- package/dist/types/excalidraw/scene/Renderer.d.ts +11 -11
- package/dist/types/excalidraw/scene/export.d.ts +3 -3
- package/dist/types/excalidraw/scene/index.d.ts +1 -1
- package/dist/types/excalidraw/scene/types.d.ts +4 -3
- package/dist/types/excalidraw/snapping.d.ts +7 -7
- package/dist/types/excalidraw/types.d.ts +432 -28
- package/dist/types/excalidraw/viewport.d.ts +283 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +2 -3
- package/dist/types/laser-pointer/src/state.d.ts +1 -0
- package/dist/types/math/src/index.d.ts +1 -0
- package/dist/types/math/src/pca.d.ts +79 -0
- package/dist/types/math/src/polygon.d.ts +25 -1
- package/dist/types/utils/src/export.d.ts +3 -3
- package/package.json +4 -4
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -180
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +0 -183
- package/dist/types/excalidraw/components/DefaultSidebar.d.ts +0 -27
- package/dist/types/excalidraw/components/ElementCanvasButtons.d.ts +0 -7
- package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
- package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
- package/dist/types/excalidraw/components/MagicButton.d.ts +0 -10
- package/dist/types/excalidraw/cursor.d.ts +0 -5
- package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
- package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
- package/dist/types/excalidraw/scroll.d.ts +0 -46
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { AppEventBus, type EXPORT_IMAGE_TYPES, Emitter, type EditorInterface, type StylesPanelMode } from "@excalidraw/common";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import type { ExcalidrawElement, NonDeleted, FileId, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered, SceneElementsMap } from "@excalidraw/element/types";
|
|
3
|
+
import { LinearElementEditor, Scene, Store, type ElementUpdate, StoreDelta, type ApplyToOptions } from "@excalidraw/element";
|
|
4
|
+
import type { LocalPoint, Radians } from "@excalidraw/math";
|
|
5
|
+
import type { ExcalidrawElement, ExcalidrawTextElement, NonDeleted, FileId, NonDeletedExcalidrawElement, ExcalidrawTextContainer, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered, SceneElementsMap } from "@excalidraw/element/types";
|
|
6
6
|
import type { Mutable } from "@excalidraw/common/utility-types";
|
|
7
7
|
import { ActionManager } from "../actions/manager";
|
|
8
8
|
import { History } from "../history";
|
|
9
9
|
import { Fonts } from "../fonts";
|
|
10
10
|
import { type WritableAtom } from "../editor-jotai";
|
|
11
11
|
import { Renderer } from "../scene/Renderer";
|
|
12
|
-
import { type
|
|
12
|
+
import { type SetViewportOptions } from "../viewport";
|
|
13
13
|
import { LaserTrails } from "../laserTrails";
|
|
14
14
|
import { isOverScrollBars } from "../scene/scrollbars";
|
|
15
15
|
import { LassoTrail } from "../lasso";
|
|
16
16
|
import { EraserTrail } from "../eraser";
|
|
17
|
+
import { AppArrowText } from "./App.arrowText";
|
|
18
|
+
import { AppBucketFill } from "./App.bucketFill";
|
|
19
|
+
import { AppCursor } from "./App.cursor";
|
|
20
|
+
import { AppDrawShape } from "./App.drawshape";
|
|
21
|
+
import { AppFlowchart } from "./App.flowchart";
|
|
22
|
+
import { AppViewport } from "./App.viewport";
|
|
23
|
+
import { CursorHints } from "./CursorHint";
|
|
17
24
|
import { type OnStateChange } from "./AppStateObserver";
|
|
18
25
|
import type { ExportedElements } from "../data";
|
|
19
|
-
import type { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType, OnUserFollowedPayload, ExcalidrawImperativeAPIEventMap,
|
|
26
|
+
import type { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType, OnUserFollowedPayload, ExcalidrawImperativeAPIEventMap, NullableGridSize, UIConfig, ImageStatus } from "../types";
|
|
20
27
|
import type { RoughCanvas } from "roughjs/bin/canvas";
|
|
21
28
|
import type { ActionResult } from "../actions/types";
|
|
22
29
|
declare const editorLifecycleEventBehavior: {
|
|
@@ -79,6 +86,9 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
79
86
|
fonts: Fonts;
|
|
80
87
|
renderer: Renderer;
|
|
81
88
|
visibleElements: readonly NonDeletedExcalidrawElement[];
|
|
89
|
+
/** whether the last render had any renderable elements (excludes e.g. the
|
|
90
|
+
* in-progress `newElement` and the edited text element) */
|
|
91
|
+
private hasRenderableElements;
|
|
82
92
|
private resizeObserver;
|
|
83
93
|
id: string;
|
|
84
94
|
private store;
|
|
@@ -91,8 +101,9 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
91
101
|
imageCache: AppClassProperties["imageCache"];
|
|
92
102
|
imageLoadingProgress: Map<FileId, number>;
|
|
93
103
|
imageLoadingProgressEmitter: Emitter<[]>;
|
|
104
|
+
imageStatus: Map<FileId, ImageStatus>;
|
|
105
|
+
imageStatusEmitter: Emitter<[]>;
|
|
94
106
|
imagePlaceholderUpdateEmitter: Emitter<[]>;
|
|
95
|
-
private imageTransitionPlaceholders;
|
|
96
107
|
private iFrameRefs;
|
|
97
108
|
/**
|
|
98
109
|
* Indicates whether the embeddable's url has been validated for rendering.
|
|
@@ -110,9 +121,17 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
110
121
|
onEvent: AppEventBus<ExcalidrawImperativeAPIEventMap, typeof editorLifecycleEventBehavior>["on"];
|
|
111
122
|
private appStateObserver;
|
|
112
123
|
onStateChange: OnStateChange;
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
bucketFill: AppBucketFill;
|
|
125
|
+
flowchart: AppFlowchart;
|
|
126
|
+
cursor: AppCursor;
|
|
127
|
+
arrowText: AppArrowText;
|
|
128
|
+
viewport: AppViewport;
|
|
129
|
+
get lastViewportPosition(): {
|
|
130
|
+
x: number;
|
|
131
|
+
y: number;
|
|
132
|
+
};
|
|
115
133
|
bindModeHandler: ReturnType<typeof setTimeout> | null;
|
|
134
|
+
private textWysiwygSubmitHandler;
|
|
116
135
|
hitLinkElement?: NonDeletedExcalidrawElement;
|
|
117
136
|
lastPointerDownEvent: React.PointerEvent<HTMLElement> | null;
|
|
118
137
|
lastPointerUpEvent: React.PointerEvent<HTMLElement> | PointerEvent | null;
|
|
@@ -129,13 +148,11 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
129
148
|
x: number;
|
|
130
149
|
y: number;
|
|
131
150
|
} | null;
|
|
132
|
-
|
|
133
|
-
x: number;
|
|
134
|
-
y: number;
|
|
135
|
-
};
|
|
151
|
+
drawShape: AppDrawShape;
|
|
136
152
|
laserTrails: LaserTrails;
|
|
137
153
|
eraserTrail: EraserTrail;
|
|
138
154
|
lassoTrail: LassoTrail;
|
|
155
|
+
cursorHints: CursorHints;
|
|
139
156
|
onChangeEmitter: Emitter<[elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles]>;
|
|
140
157
|
onPointerDownEmitter: Emitter<[activeTool: {
|
|
141
158
|
lastActiveTool: import("../types").ActiveTool | null;
|
|
@@ -268,9 +285,77 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
268
285
|
missingPointerEventCleanupEmitter: Emitter<[event: PointerEvent | null]>;
|
|
269
286
|
onRemoveEventListenersEmitter: Emitter<[]>;
|
|
270
287
|
api: ExcalidrawImperativeAPI;
|
|
271
|
-
addImageElementsToScene: ExcalidrawImperativeAPI["addImageElementsToScene"];
|
|
272
288
|
private createExcalidrawAPI;
|
|
273
289
|
constructor(props: AppProps);
|
|
290
|
+
/**
|
|
291
|
+
* Whether the editor accepts user input (pointer, keyboard, wheel, touch,
|
|
292
|
+
* clipboard, drag&drop). When `false`, the editor is fully inert for the
|
|
293
|
+
* user, but remains controllable through the imperative API.
|
|
294
|
+
*
|
|
295
|
+
* All user-input entry points must consult this getter (directly or by
|
|
296
|
+
* not being attached/rendered at all).
|
|
297
|
+
*/
|
|
298
|
+
isInteractionEnabled(props?: Pick<AppProps, "interaction">): boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Whether element links render their link icon and are clickable.
|
|
301
|
+
* True when fully interactive, or when `interaction: { enabled: { links:
|
|
302
|
+
* true } }`
|
|
303
|
+
* (in which case clicking anywhere on a linked element opens the link,
|
|
304
|
+
* same as in view mode).
|
|
305
|
+
*/
|
|
306
|
+
isLinksEnabled(props?: Pick<AppProps, "interaction">): boolean;
|
|
307
|
+
/**
|
|
308
|
+
* Whether canvas navigation — panning & zooming, view-mode style — is
|
|
309
|
+
* enabled. True when fully interactive, or when `interaction: { enabled:
|
|
310
|
+
* { navigation: true } }`. Respects `appState.scrollConstraints`.
|
|
311
|
+
*/
|
|
312
|
+
isNavigationEnabled(props?: Pick<AppProps, "interaction">): boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Whether embeddable & iframe elements are interactive (hover & click to
|
|
315
|
+
* activate, view-mode style). True when fully interactive, or when
|
|
316
|
+
* allowed via `interaction.enabled.embeds` / `.interactiveContent`.
|
|
317
|
+
*/
|
|
318
|
+
isEmbedsEnabled(props?: Pick<AppProps, "interaction">): boolean;
|
|
319
|
+
/**
|
|
320
|
+
* Whether the browser's own zoom (ctrl/cmd + wheel, pinch, keyboard
|
|
321
|
+
* shortcuts) stays available over the non-interactive editor.
|
|
322
|
+
* Prevented by default.
|
|
323
|
+
*/
|
|
324
|
+
isBrowserZoomEnabled(props?: Pick<AppProps, "interaction">): boolean;
|
|
325
|
+
/**
|
|
326
|
+
* Whether the tool can be activated & driven by user input. False when
|
|
327
|
+
* disabled via `UIOptions.tools`, or when the editor is non-interactive
|
|
328
|
+
* and the tool isn't kept user-driven via `interaction.enabled.tools`.
|
|
329
|
+
*
|
|
330
|
+
* (Once UI tool availability is split from input availability — e.g.
|
|
331
|
+
* `props.ui.tools` vs `interaction.disabled.tools` — the UI axis moves
|
|
332
|
+
* out into its own predicate.)
|
|
333
|
+
*
|
|
334
|
+
* We purposely widen the `tool` type so this helper can be called with
|
|
335
|
+
* any tool without having to type check it.
|
|
336
|
+
*/
|
|
337
|
+
isToolSupported: <T extends ToolType | "custom">(tool: T, props?: Pick<AppProps, "interaction" | "UIOptions">) => boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Whether the active tool is locked in place — via the tool lock
|
|
340
|
+
* (padlock / Q) or by being host-forced (`props.activeTool`). A locked
|
|
341
|
+
* tool doesn't revert to the selection tool after use, and elements drawn
|
|
342
|
+
* with it aren't selected. Forcing deliberately does not mutate
|
|
343
|
+
* `activeTool.locked`, which is the user's persisted padlock preference.
|
|
344
|
+
*/
|
|
345
|
+
isToolLocked(): boolean;
|
|
346
|
+
/**
|
|
347
|
+
* Whether the active tool captures the primary pointer instead of the
|
|
348
|
+
* view-mode drag-to-pan — the laser and host-implemented custom tools do;
|
|
349
|
+
* while non-interactive, any tool allowed via
|
|
350
|
+
* `interaction.enabled.tools` does. (Editing tools capture the pointer
|
|
351
|
+
* trivially since view mode implies they're not active; this predicate only
|
|
352
|
+
* matters where view-mode gates apply.)
|
|
353
|
+
*/
|
|
354
|
+
isActiveToolPointerCapturing(): boolean;
|
|
355
|
+
/** Whether Excalidraw's full default UI is rendered. */
|
|
356
|
+
isDefaultUIEnabled(props?: Pick<AppProps, "ui">): boolean;
|
|
357
|
+
/** Whether an individual default UI control is rendered. */
|
|
358
|
+
isUIControlEnabled(control: keyof UIConfig["enabled"], props?: Pick<AppProps, "ui">): boolean;
|
|
274
359
|
updateEditorAtom: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
|
|
275
360
|
private onWindowMessage;
|
|
276
361
|
private handleSkipBindMode;
|
|
@@ -305,25 +390,42 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
305
390
|
getSceneElements: () => readonly Ordered<NonDeletedExcalidrawElement>[];
|
|
306
391
|
onInsertElements: (elements: readonly ExcalidrawElement[]) => void;
|
|
307
392
|
onExportImage: (type: keyof typeof EXPORT_IMAGE_TYPES, elements: ExportedElements, opts: {
|
|
308
|
-
exportingFrame: ExcalidrawFrameLikeElement | null;
|
|
393
|
+
exportingFrame: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
309
394
|
}) => Promise<void>;
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
generate: GenerateDiagramToCode;
|
|
315
|
-
};
|
|
316
|
-
};
|
|
317
|
-
setPlugins(plugins: Partial<App["plugins"]>): void;
|
|
318
|
-
private onMagicFrameGenerate;
|
|
319
|
-
private onIframeSrcCopy;
|
|
320
|
-
onMagicframeToolSelect: () => void;
|
|
321
|
-
private openEyeDropper;
|
|
395
|
+
openEyeDropper: ({ type, swapPreviewOnAlt, }: {
|
|
396
|
+
type: "stroke" | "background";
|
|
397
|
+
swapPreviewOnAlt?: boolean;
|
|
398
|
+
}) => void;
|
|
322
399
|
dismissLinearEditor: () => void;
|
|
323
400
|
syncActionResult: (actionResult: ActionResult) => void;
|
|
401
|
+
scheduleCapture: () => void;
|
|
324
402
|
private onBlur;
|
|
325
403
|
private onUnload;
|
|
326
404
|
private disableEvent;
|
|
405
|
+
private preventBrowserZoomWheel;
|
|
406
|
+
private handleNavigationModeKeyDown;
|
|
407
|
+
/**
|
|
408
|
+
* PageUp/PageDown scroll the canvas by a page — vertically, or
|
|
409
|
+
* horizontally with shift. Respects `appState.scrollConstraints`
|
|
410
|
+
* (via `viewport.translate`).
|
|
411
|
+
*/
|
|
412
|
+
private maybeHandlePageScrollKeyDown;
|
|
413
|
+
private preventBrowserZoomKeyDown;
|
|
414
|
+
/** Ends active input sessions before switching to a view-mode/non-interactive
|
|
415
|
+
* mode. */
|
|
416
|
+
private terminateActiveInteraction;
|
|
417
|
+
private handleInteractionStateChange;
|
|
418
|
+
/** whether the two values reference the same tool (incl. custom subtype) */
|
|
419
|
+
private isSameForcedTool;
|
|
420
|
+
/**
|
|
421
|
+
* Keeps `state.activeTool` synced to the host-controlled
|
|
422
|
+
* `props.activeTool`. `setActiveTool` refuses non-matching activations
|
|
423
|
+
* while forced (user input, API); this backstop covers the writers that
|
|
424
|
+
* bypass the funnel (`actionFinalize`/`actionDeselect`, `restore()` on
|
|
425
|
+
* scene load, ...) and re-applies the tool once it becomes activatable
|
|
426
|
+
* (e.g. `interaction` config changes).
|
|
427
|
+
*/
|
|
428
|
+
private handleForcedToolChange;
|
|
327
429
|
private resetHistory;
|
|
328
430
|
private resetStore;
|
|
329
431
|
/**
|
|
@@ -355,6 +457,17 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
355
457
|
private onTouchEnd;
|
|
356
458
|
private insertClipboardContent;
|
|
357
459
|
pasteFromClipboard: (event: ClipboardEvent) => Promise<void>;
|
|
460
|
+
addElementsFromPasteOrLibrary: (opts: {
|
|
461
|
+
elements: readonly ExcalidrawElement[];
|
|
462
|
+
files: BinaryFiles | null;
|
|
463
|
+
position: {
|
|
464
|
+
clientX: number;
|
|
465
|
+
clientY: number;
|
|
466
|
+
} | "cursor" | "center";
|
|
467
|
+
retainSeed?: boolean;
|
|
468
|
+
fit?: SetViewportOptions["fit"];
|
|
469
|
+
preserveFrameChildrenOrder?: boolean;
|
|
470
|
+
}) => void;
|
|
358
471
|
addElementsFromPaste: (opts: {
|
|
359
472
|
elements: readonly ExcalidrawElement[];
|
|
360
473
|
files: BinaryFiles | null;
|
|
@@ -373,39 +486,41 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
373
486
|
toggleLock: (source?: "keyboard" | "ui") => void;
|
|
374
487
|
updateFrameRendering: (opts: Partial<AppState["frameRendering"]> | ((prevState: AppState["frameRendering"]) => Partial<AppState["frameRendering"]>)) => void;
|
|
375
488
|
togglePenMode: (force: boolean | null) => void;
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Zooms on canvas viewport center
|
|
379
|
-
*/
|
|
380
|
-
zoomCanvas: (
|
|
381
|
-
/**
|
|
382
|
-
* Decimal fraction, auto-clamped between MIN_ZOOM and MAX_ZOOM.
|
|
383
|
-
* 1 = 100% zoom, 2 = 200% zoom, 0.5 = 50% zoom
|
|
384
|
-
*/
|
|
385
|
-
value: number) => void;
|
|
386
|
-
private cancelInProgressAnimation;
|
|
489
|
+
revealIfHidden: (elements: NonDeletedExcalidrawElement[]) => void;
|
|
387
490
|
scrollToViewport: (target: {
|
|
388
491
|
scrollX: number;
|
|
389
492
|
scrollY: number;
|
|
390
493
|
zoom: number;
|
|
391
|
-
},
|
|
494
|
+
}, _opts?: {
|
|
392
495
|
animate?: boolean;
|
|
393
496
|
duration?: number;
|
|
394
497
|
}) => void;
|
|
395
|
-
scrollToContent: (target?:
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
498
|
+
scrollToContent: (target?: SetViewportOptions["target"], opts?: {
|
|
499
|
+
animate?: boolean;
|
|
500
|
+
duration?: number;
|
|
501
|
+
fitToViewport?: boolean;
|
|
502
|
+
}) => void;
|
|
503
|
+
/** emits a follow/unfollow intent to the host (which owns the
|
|
504
|
+
* `userToFollow` state) via both the `onUserFollow` prop and the
|
|
505
|
+
* imperative API emitter */
|
|
506
|
+
emitUserFollowIntent: (payload: OnUserFollowedPayload) => void;
|
|
507
|
+
/** emits an UNFOLLOW intent if currently following someone — use on
|
|
508
|
+
* user-initiated viewport changes which should break follow mode */
|
|
509
|
+
requestUnfollow: () => void;
|
|
399
510
|
setToast: (toast: AppState["toast"]) => void;
|
|
400
|
-
private handleToastClose;
|
|
401
511
|
restoreFileFromShare: () => Promise<void>;
|
|
402
512
|
/**
|
|
403
513
|
* adds supplied files to existing files in the appState.
|
|
404
514
|
* NOTE if file already exists in editor state, the file data is not updated
|
|
405
515
|
* */
|
|
406
516
|
addFiles: ExcalidrawImperativeAPI["addFiles"];
|
|
517
|
+
addImageElementsToScene: ExcalidrawImperativeAPI["addImageElementsToScene"];
|
|
407
518
|
addImagePlaceholder: ExcalidrawImperativeAPI["addImagePlaceholder"];
|
|
408
|
-
|
|
519
|
+
setDownloadProgress: ExcalidrawImperativeAPI["setDownloadProgress"];
|
|
520
|
+
setDownloadError: ExcalidrawImperativeAPI["setDownloadError"];
|
|
521
|
+
setUploadProgress: ExcalidrawImperativeAPI["setUploadProgress"];
|
|
522
|
+
private updateImageStatus;
|
|
523
|
+
private areImageStatusesEqual;
|
|
409
524
|
private clearImageLoadingProgress;
|
|
410
525
|
private clearImageShapeCacheForFileId;
|
|
411
526
|
private addMissingFiles;
|
|
@@ -428,7 +543,9 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
428
543
|
}) => void;
|
|
429
544
|
applyDeltas: (deltas: StoreDelta[], options?: ApplyToOptions) => [SceneElementsMap, AppState, boolean];
|
|
430
545
|
mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
|
|
431
|
-
|
|
546
|
+
triggerRender: (
|
|
547
|
+
/** force always re-renders canvas even if no change */
|
|
548
|
+
force?: boolean) => void;
|
|
432
549
|
/**
|
|
433
550
|
* @returns whether the menu was toggled on or off
|
|
434
551
|
*/
|
|
@@ -438,10 +555,8 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
438
555
|
force?: boolean;
|
|
439
556
|
}) => boolean;
|
|
440
557
|
private updateCurrentCursorPosition;
|
|
441
|
-
getEditorUIOffsets: () => Offsets;
|
|
442
558
|
private onKeyDown;
|
|
443
559
|
private onKeyUp;
|
|
444
|
-
private isToolSupported;
|
|
445
560
|
setActiveTool: (tool: ({
|
|
446
561
|
type: ToolType;
|
|
447
562
|
} | {
|
|
@@ -450,10 +565,18 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
450
565
|
}) & {
|
|
451
566
|
locked?: boolean;
|
|
452
567
|
fromSelection?: boolean;
|
|
453
|
-
},
|
|
568
|
+
}, opts?: {
|
|
569
|
+
keepSelection?: boolean;
|
|
570
|
+
/**
|
|
571
|
+
* When `true`, re-activating an already-active toggle tool (see
|
|
572
|
+
* `TOGGLE_TOOLS`) switches back to the previously active tool.
|
|
573
|
+
* Activation is idempotent by default; toggle tools always record the
|
|
574
|
+
* previously active tool regardless (so ESC and the next `toggle`
|
|
575
|
+
* activation can switch back to it).
|
|
576
|
+
*/
|
|
577
|
+
toggle?: boolean;
|
|
578
|
+
}) => void;
|
|
454
579
|
setOpenDialog: (dialogType: AppState["openDialog"]) => void;
|
|
455
|
-
private setCursor;
|
|
456
|
-
private resetCursor;
|
|
457
580
|
/**
|
|
458
581
|
* returns whether user is making a gesture with >= 2 fingers (points)
|
|
459
582
|
* on o touch screen (not on a trackpad). Currently only relates to Darwin
|
|
@@ -469,32 +592,229 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
469
592
|
private deselectElements;
|
|
470
593
|
private getSelectedTextElement;
|
|
471
594
|
private getSelectedTextEditingContainerAtPosition;
|
|
472
|
-
|
|
595
|
+
getTextElementAtPosition(x: number, y: number): NonDeleted<ExcalidrawTextElement> | null;
|
|
473
596
|
private isHittingTextAutoResizeHandle;
|
|
474
597
|
private handleTextAutoResizeHandlePointerDown;
|
|
475
|
-
|
|
598
|
+
getElementAtPosition(x: number, y: number, opts?: ({
|
|
599
|
+
includeBoundTextElement?: boolean;
|
|
600
|
+
includeLockedElements?: boolean;
|
|
601
|
+
} | {
|
|
602
|
+
allHitElements: NonDeleted<ExcalidrawElement>[];
|
|
603
|
+
}) & {
|
|
604
|
+
preferSelected?: boolean;
|
|
605
|
+
}): NonDeleted<ExcalidrawElement> | null;
|
|
476
606
|
private getElementsAtPosition;
|
|
477
607
|
getElementHitThreshold(element: ExcalidrawElement): number;
|
|
478
608
|
private hitElement;
|
|
479
|
-
|
|
609
|
+
getTextBindableContainerAtPosition(x: number, y: number): (Readonly<{
|
|
610
|
+
id: string;
|
|
611
|
+
x: number;
|
|
612
|
+
y: number;
|
|
613
|
+
strokeColor: string;
|
|
614
|
+
backgroundColor: string;
|
|
615
|
+
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
616
|
+
strokeWidth: number;
|
|
617
|
+
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
618
|
+
roundness: null | {
|
|
619
|
+
type: import("@excalidraw/element/types").RoundnessType;
|
|
620
|
+
value?: number;
|
|
621
|
+
};
|
|
622
|
+
roughness: number;
|
|
623
|
+
opacity: number;
|
|
624
|
+
width: number;
|
|
625
|
+
height: number;
|
|
626
|
+
angle: Radians;
|
|
627
|
+
seed: number;
|
|
628
|
+
version: number;
|
|
629
|
+
versionNonce: number;
|
|
630
|
+
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
631
|
+
isDeleted: boolean;
|
|
632
|
+
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
633
|
+
frameId: string | null;
|
|
634
|
+
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
635
|
+
updated: number;
|
|
636
|
+
link: string | null;
|
|
637
|
+
locked: boolean;
|
|
638
|
+
customData?: Record<string, any>;
|
|
639
|
+
}> & {
|
|
640
|
+
type: "rectangle";
|
|
641
|
+
} & {
|
|
642
|
+
isDeleted: false;
|
|
643
|
+
}) | (Readonly<{
|
|
644
|
+
id: string;
|
|
645
|
+
x: number;
|
|
646
|
+
y: number;
|
|
647
|
+
strokeColor: string;
|
|
648
|
+
backgroundColor: string;
|
|
649
|
+
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
650
|
+
strokeWidth: number;
|
|
651
|
+
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
652
|
+
roundness: null | {
|
|
653
|
+
type: import("@excalidraw/element/types").RoundnessType;
|
|
654
|
+
value?: number;
|
|
655
|
+
};
|
|
656
|
+
roughness: number;
|
|
657
|
+
opacity: number;
|
|
658
|
+
width: number;
|
|
659
|
+
height: number;
|
|
660
|
+
angle: Radians;
|
|
661
|
+
seed: number;
|
|
662
|
+
version: number;
|
|
663
|
+
versionNonce: number;
|
|
664
|
+
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
665
|
+
isDeleted: boolean;
|
|
666
|
+
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
667
|
+
frameId: string | null;
|
|
668
|
+
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
669
|
+
updated: number;
|
|
670
|
+
link: string | null;
|
|
671
|
+
locked: boolean;
|
|
672
|
+
customData?: Record<string, any>;
|
|
673
|
+
}> & {
|
|
674
|
+
type: "diamond";
|
|
675
|
+
} & {
|
|
676
|
+
isDeleted: false;
|
|
677
|
+
}) | (Readonly<{
|
|
678
|
+
id: string;
|
|
679
|
+
x: number;
|
|
680
|
+
y: number;
|
|
681
|
+
strokeColor: string;
|
|
682
|
+
backgroundColor: string;
|
|
683
|
+
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
684
|
+
strokeWidth: number;
|
|
685
|
+
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
686
|
+
roundness: null | {
|
|
687
|
+
type: import("@excalidraw/element/types").RoundnessType;
|
|
688
|
+
value?: number;
|
|
689
|
+
};
|
|
690
|
+
roughness: number;
|
|
691
|
+
opacity: number;
|
|
692
|
+
width: number;
|
|
693
|
+
height: number;
|
|
694
|
+
angle: Radians;
|
|
695
|
+
seed: number;
|
|
696
|
+
version: number;
|
|
697
|
+
versionNonce: number;
|
|
698
|
+
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
699
|
+
isDeleted: boolean;
|
|
700
|
+
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
701
|
+
frameId: string | null;
|
|
702
|
+
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
703
|
+
updated: number;
|
|
704
|
+
link: string | null;
|
|
705
|
+
locked: boolean;
|
|
706
|
+
customData?: Record<string, any>;
|
|
707
|
+
}> & {
|
|
708
|
+
type: "ellipse";
|
|
709
|
+
} & {
|
|
710
|
+
isDeleted: false;
|
|
711
|
+
}) | (Readonly<{
|
|
712
|
+
id: string;
|
|
713
|
+
x: number;
|
|
714
|
+
y: number;
|
|
715
|
+
strokeColor: string;
|
|
716
|
+
backgroundColor: string;
|
|
717
|
+
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
718
|
+
strokeWidth: number;
|
|
719
|
+
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
720
|
+
roundness: null | {
|
|
721
|
+
type: import("@excalidraw/element/types").RoundnessType;
|
|
722
|
+
value?: number;
|
|
723
|
+
};
|
|
724
|
+
roughness: number;
|
|
725
|
+
opacity: number;
|
|
726
|
+
width: number;
|
|
727
|
+
height: number;
|
|
728
|
+
angle: Radians;
|
|
729
|
+
seed: number;
|
|
730
|
+
version: number;
|
|
731
|
+
versionNonce: number;
|
|
732
|
+
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
733
|
+
isDeleted: boolean;
|
|
734
|
+
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
735
|
+
frameId: string | null;
|
|
736
|
+
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
737
|
+
updated: number;
|
|
738
|
+
link: string | null;
|
|
739
|
+
locked: boolean;
|
|
740
|
+
customData?: Record<string, any>;
|
|
741
|
+
}> & Readonly<{
|
|
742
|
+
type: "line" | "arrow";
|
|
743
|
+
points: readonly LocalPoint[];
|
|
744
|
+
startBinding: import("@excalidraw/element/types").FixedPointBinding | null;
|
|
745
|
+
endBinding: import("@excalidraw/element/types").FixedPointBinding | null;
|
|
746
|
+
startArrowhead: import("@excalidraw/element/types").Arrowhead | null;
|
|
747
|
+
endArrowhead: import("@excalidraw/element/types").Arrowhead | null;
|
|
748
|
+
}> & Readonly<{
|
|
749
|
+
type: "arrow";
|
|
750
|
+
elbowed: boolean;
|
|
751
|
+
}> & {
|
|
752
|
+
isDeleted: false;
|
|
753
|
+
}) | null;
|
|
754
|
+
/**
|
|
755
|
+
* Whether a text element's content is still being authored.
|
|
756
|
+
*
|
|
757
|
+
* Creating a text reverts the tool to selection during pointerdown, so the
|
|
758
|
+
* pointerup that follows looks like an ordinary canvas click and would
|
|
759
|
+
* capture the still-empty element as a history entry of its own. Undo would
|
|
760
|
+
* then rewind only the typing, restoring an invisible, zero-content element
|
|
761
|
+
* (and, for an endpoint label, leaving the arrow bound to it) rather than
|
|
762
|
+
* removing it. The editor's own submit captures the finished text instead,
|
|
763
|
+
* so the whole create-and-type lands in a single entry.
|
|
764
|
+
*/
|
|
765
|
+
private isEditingTextContent;
|
|
480
766
|
private startTextEditing;
|
|
481
767
|
private startImageCropping;
|
|
482
768
|
private finishImageCropping;
|
|
483
769
|
private shouldHandleBrowserCanvasDoubleClick;
|
|
484
770
|
private handleCanvasDoubleClick;
|
|
485
771
|
private handleCanvasClick;
|
|
772
|
+
private getImageStatusActionAtPosition;
|
|
773
|
+
private isPointInsideImageStatusOverlay;
|
|
486
774
|
private getElementLinkAtPosition;
|
|
487
775
|
private handleElementLinkClick;
|
|
488
|
-
|
|
776
|
+
/**
|
|
777
|
+
* Applies (or clears) the element-link hover affordances — pointer cursor
|
|
778
|
+
* and tooltip — based on the current `hitLinkElement`. Returns whether a
|
|
779
|
+
* link is being hovered.
|
|
780
|
+
*/
|
|
781
|
+
private applyElementLinkHoverAffordance;
|
|
782
|
+
/**
|
|
783
|
+
* On touchscreens (where no hover precedes the tap) re-derives
|
|
784
|
+
* `hitLinkElement`, then opens the hit element link, if any.
|
|
785
|
+
* Returns whether a link click was handled.
|
|
786
|
+
*/
|
|
787
|
+
private maybeHandleElementLinkClick;
|
|
788
|
+
/**
|
|
789
|
+
* Restricted pointer handling for the non-interactive editor with links
|
|
790
|
+
* and/or embeds allowed (`interaction.enabled.links` / `.embeds` /
|
|
791
|
+
* `.interactiveContent`) — runs only the element-link & embed concerns
|
|
792
|
+
* (shared with the full pointer handlers above) so they behave like in
|
|
793
|
+
* view mode without the rest of the canvas pointer machinery.
|
|
794
|
+
*/
|
|
795
|
+
private handleInteractiveContentPointerMove;
|
|
796
|
+
private handleInteractiveContentPointerUp;
|
|
489
797
|
/**
|
|
490
798
|
* finds candidate frame under cursor (when dragging frame children/elements
|
|
491
799
|
* inside frames)
|
|
492
800
|
*/
|
|
493
|
-
|
|
801
|
+
getTopLayerFrameAtSceneCoords: (
|
|
802
|
+
/**
|
|
803
|
+
* should be already grid aligned (basically should be what the call site
|
|
804
|
+
* sets the element's coords to, if applicable)
|
|
805
|
+
*/
|
|
806
|
+
sceneCoords: {
|
|
807
|
+
x: number;
|
|
808
|
+
y: number;
|
|
809
|
+
}, opts?: {
|
|
810
|
+
/** to exclude selected elements when dragging, etc. */
|
|
811
|
+
excludeElementIds?: AppState["selectedElementIds"];
|
|
812
|
+
currentFrameId?: ExcalidrawElement["frameId"];
|
|
813
|
+
}) => NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
494
814
|
private updateFrameToHighlight;
|
|
495
815
|
private maybeUpdateFrameToHighlightOnPointerMove;
|
|
496
|
-
|
|
497
|
-
|
|
816
|
+
insertNewElements: (elements: readonly ExcalidrawElement[]) => void;
|
|
817
|
+
insertNewElement: (element: ExcalidrawElement) => void;
|
|
498
818
|
private handleCanvasPointerMove;
|
|
499
819
|
private handleEraser;
|
|
500
820
|
private handleTouchMove;
|
|
@@ -509,10 +829,13 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
509
829
|
* pointerup handlers manually
|
|
510
830
|
*/
|
|
511
831
|
private maybeCleanupAfterMissingPointerUp;
|
|
512
|
-
private handleCanvasZoomUsingZDrag;
|
|
513
|
-
private restoreCursorAfterZoomKey;
|
|
514
832
|
handleCanvasPanUsingWheelOrSpaceDrag: (event: React.PointerEvent<HTMLElement> | MouseEvent) => boolean;
|
|
515
833
|
private updateGestureOnPointerDown;
|
|
834
|
+
/**
|
|
835
|
+
* Tracks the pointer within the ongoing multi-touch gesture and applies
|
|
836
|
+
* the two-finger pinch zoom/pan, if any.
|
|
837
|
+
*/
|
|
838
|
+
private updateMultiTouchGesture;
|
|
516
839
|
private initialPointerDownState;
|
|
517
840
|
private handleDraggingScrollBar;
|
|
518
841
|
private clearSelectionIfNotUsingSelection;
|
|
@@ -576,10 +899,15 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
576
899
|
private maybeDragNewGenericElement;
|
|
577
900
|
private maybeHandleCrop;
|
|
578
901
|
private maybeHandleResize;
|
|
579
|
-
private getContextMenuItems;
|
|
580
902
|
private getImageContextMenuItems;
|
|
903
|
+
private getContextMenuItems;
|
|
581
904
|
private handleWheel;
|
|
582
|
-
|
|
905
|
+
getTextWysiwygSnappedToCenterPosition(x: number, y: number, appState: AppState, container?: ExcalidrawTextContainer | null): {
|
|
906
|
+
viewportX: number;
|
|
907
|
+
viewportY: number;
|
|
908
|
+
elementCenterX: number;
|
|
909
|
+
elementCenterY: number;
|
|
910
|
+
} | undefined;
|
|
583
911
|
private savePointer;
|
|
584
912
|
private resetShouldCacheIgnoreZoomDebounced;
|
|
585
913
|
private updateDOMRect;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { DrawShapeTrail } from "../drawShapeTrail";
|
|
2
|
+
import type App from "./App";
|
|
3
|
+
import type { PointerDownState } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* Captures the App state management for the drawShape tool (free-form
|
|
6
|
+
* sketch converted into a recognized excalidraw element). Pointer events
|
|
7
|
+
* are piped here from App.
|
|
8
|
+
*
|
|
9
|
+
* The gesture is committed by `finalize()` — recognize → (maybe upgrade
|
|
10
|
+
* line to arrow) → insert → bind endpoints — which is invoked from within
|
|
11
|
+
* `actionFinalize`, the editor's single finalization funnel. Whatever
|
|
12
|
+
* triggers a finalize (the gesture's own pointerup, a mid-gesture paste
|
|
13
|
+
* switching tools, …), the pending sketch resolves there exactly once.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AppDrawShape {
|
|
16
|
+
private app;
|
|
17
|
+
trail: DrawShapeTrail;
|
|
18
|
+
/** a pointerdown started a sketch that `finalize()` hasn't resolved yet */
|
|
19
|
+
private gestureInProgress;
|
|
20
|
+
constructor(app: App);
|
|
21
|
+
stop: () => void;
|
|
22
|
+
hasPendingGesture: () => boolean;
|
|
23
|
+
handlePointerDown: (pointerDownState: PointerDownState) => void;
|
|
24
|
+
/** returns true when the pointermove was consumed by the shape preview */
|
|
25
|
+
handlePointerMove: (pointerCoords: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
}) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Binds both endpoints of a freshly inserted drawShape arrow to the
|
|
31
|
+
* bindable elements they hover, if any.
|
|
32
|
+
*
|
|
33
|
+
* Endpoints bind in "orbit" mode — the arrow starts/ends at the target's
|
|
34
|
+
* outline — even when the stroke was started or released inside the shape
|
|
35
|
+
* (a sketched connector aims at the shape, not at a point inside it). The
|
|
36
|
+
* exception is a sketch contained in a single shape: both ends then bind
|
|
37
|
+
* "inside" and stay where they were drawn, like the interactive
|
|
38
|
+
* inside→inside flow.
|
|
39
|
+
*/
|
|
40
|
+
private bindRecognizedArrow;
|
|
41
|
+
/**
|
|
42
|
+
* A sketched line that connects a bindable element with something else —
|
|
43
|
+
* another element or blank canvas — was meant as a connector: upgrade it
|
|
44
|
+
* to an arrow (called before insertion). A line touching no shape, or
|
|
45
|
+
* contained in a single shape (an annotation, not a connector), stays a
|
|
46
|
+
* line.
|
|
47
|
+
*/
|
|
48
|
+
private maybeUpgradeLineToArrow;
|
|
49
|
+
/**
|
|
50
|
+
* Commits the pending sketch, if any, and clears the trail. Invoked from
|
|
51
|
+
* within `actionFinalize` — never call directly, execute `actionFinalize`
|
|
52
|
+
* instead so element insertion flows into the action's returned elements.
|
|
53
|
+
*/
|
|
54
|
+
finalize: () => void;
|
|
55
|
+
}
|