@myoc/element 0.19.521 → 0.19.522
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 +128 -961
- 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/actionToggleZenMode.d.ts +13 -5
- package/dist/types/excalidraw/actions/index.d.ts +1 -2
- 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 +17 -12
- 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 +384 -60
- 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 +9 -0
- 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 +11 -0
- package/dist/types/excalidraw/components/Tools.d.ts +146 -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/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 +423 -27
- 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/actionSmartZoom.d.ts +0 -16
- 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/components/MobileToolBar.d.ts +0 -12
- 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,39 @@ 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
|
-
private magicGenerations;
|
|
311
|
-
private updateMagicGeneration;
|
|
312
|
-
plugins: {
|
|
313
|
-
diagramToCode?: {
|
|
314
|
-
generate: GenerateDiagramToCode;
|
|
315
|
-
};
|
|
316
|
-
};
|
|
317
|
-
setPlugins(plugins: Partial<App["plugins"]>): void;
|
|
318
|
-
private onMagicFrameGenerate;
|
|
319
|
-
private onIframeSrcCopy;
|
|
320
|
-
onMagicframeToolSelect: () => void;
|
|
321
395
|
private openEyeDropper;
|
|
322
396
|
dismissLinearEditor: () => void;
|
|
323
397
|
syncActionResult: (actionResult: ActionResult) => void;
|
|
398
|
+
scheduleCapture: () => void;
|
|
324
399
|
private onBlur;
|
|
325
400
|
private onUnload;
|
|
326
401
|
private disableEvent;
|
|
402
|
+
private preventBrowserZoomWheel;
|
|
403
|
+
private handleNavigationModeKeyDown;
|
|
404
|
+
/**
|
|
405
|
+
* PageUp/PageDown scroll the canvas by a page — vertically, or
|
|
406
|
+
* horizontally with shift. Respects `appState.scrollConstraints`
|
|
407
|
+
* (via `viewport.translate`).
|
|
408
|
+
*/
|
|
409
|
+
private maybeHandlePageScrollKeyDown;
|
|
410
|
+
private preventBrowserZoomKeyDown;
|
|
411
|
+
/** Ends active input sessions before switching to a view-mode/non-interactive
|
|
412
|
+
* mode. */
|
|
413
|
+
private terminateActiveInteraction;
|
|
414
|
+
private handleInteractionStateChange;
|
|
415
|
+
/** whether the two values reference the same tool (incl. custom subtype) */
|
|
416
|
+
private isSameForcedTool;
|
|
417
|
+
/**
|
|
418
|
+
* Keeps `state.activeTool` synced to the host-controlled
|
|
419
|
+
* `props.activeTool`. `setActiveTool` refuses non-matching activations
|
|
420
|
+
* while forced (user input, API); this backstop covers the writers that
|
|
421
|
+
* bypass the funnel (`actionFinalize`/`actionDeselect`, `restore()` on
|
|
422
|
+
* scene load, ...) and re-applies the tool once it becomes activatable
|
|
423
|
+
* (e.g. `interaction` config changes).
|
|
424
|
+
*/
|
|
425
|
+
private handleForcedToolChange;
|
|
327
426
|
private resetHistory;
|
|
328
427
|
private resetStore;
|
|
329
428
|
/**
|
|
@@ -355,6 +454,17 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
355
454
|
private onTouchEnd;
|
|
356
455
|
private insertClipboardContent;
|
|
357
456
|
pasteFromClipboard: (event: ClipboardEvent) => Promise<void>;
|
|
457
|
+
addElementsFromPasteOrLibrary: (opts: {
|
|
458
|
+
elements: readonly ExcalidrawElement[];
|
|
459
|
+
files: BinaryFiles | null;
|
|
460
|
+
position: {
|
|
461
|
+
clientX: number;
|
|
462
|
+
clientY: number;
|
|
463
|
+
} | "cursor" | "center";
|
|
464
|
+
retainSeed?: boolean;
|
|
465
|
+
fit?: SetViewportOptions["fit"];
|
|
466
|
+
preserveFrameChildrenOrder?: boolean;
|
|
467
|
+
}) => void;
|
|
358
468
|
addElementsFromPaste: (opts: {
|
|
359
469
|
elements: readonly ExcalidrawElement[];
|
|
360
470
|
files: BinaryFiles | null;
|
|
@@ -373,39 +483,41 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
373
483
|
toggleLock: (source?: "keyboard" | "ui") => void;
|
|
374
484
|
updateFrameRendering: (opts: Partial<AppState["frameRendering"]> | ((prevState: AppState["frameRendering"]) => Partial<AppState["frameRendering"]>)) => void;
|
|
375
485
|
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;
|
|
486
|
+
revealIfHidden: (elements: NonDeletedExcalidrawElement[]) => void;
|
|
387
487
|
scrollToViewport: (target: {
|
|
388
488
|
scrollX: number;
|
|
389
489
|
scrollY: number;
|
|
390
490
|
zoom: number;
|
|
391
|
-
},
|
|
491
|
+
}, _opts?: {
|
|
492
|
+
animate?: boolean;
|
|
493
|
+
duration?: number;
|
|
494
|
+
}) => void;
|
|
495
|
+
scrollToContent: (target?: SetViewportOptions["target"], opts?: {
|
|
392
496
|
animate?: boolean;
|
|
393
497
|
duration?: number;
|
|
498
|
+
fitToViewport?: boolean;
|
|
394
499
|
}) => void;
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
500
|
+
/** emits a follow/unfollow intent to the host (which owns the
|
|
501
|
+
* `userToFollow` state) via both the `onUserFollow` prop and the
|
|
502
|
+
* imperative API emitter */
|
|
503
|
+
emitUserFollowIntent: (payload: OnUserFollowedPayload) => void;
|
|
504
|
+
/** emits an UNFOLLOW intent if currently following someone — use on
|
|
505
|
+
* user-initiated viewport changes which should break follow mode */
|
|
506
|
+
requestUnfollow: () => void;
|
|
399
507
|
setToast: (toast: AppState["toast"]) => void;
|
|
400
|
-
private handleToastClose;
|
|
401
508
|
restoreFileFromShare: () => Promise<void>;
|
|
402
509
|
/**
|
|
403
510
|
* adds supplied files to existing files in the appState.
|
|
404
511
|
* NOTE if file already exists in editor state, the file data is not updated
|
|
405
512
|
* */
|
|
406
513
|
addFiles: ExcalidrawImperativeAPI["addFiles"];
|
|
514
|
+
addImageElementsToScene: ExcalidrawImperativeAPI["addImageElementsToScene"];
|
|
407
515
|
addImagePlaceholder: ExcalidrawImperativeAPI["addImagePlaceholder"];
|
|
408
|
-
|
|
516
|
+
setDownloadProgress: ExcalidrawImperativeAPI["setDownloadProgress"];
|
|
517
|
+
setDownloadError: ExcalidrawImperativeAPI["setDownloadError"];
|
|
518
|
+
setUploadProgress: ExcalidrawImperativeAPI["setUploadProgress"];
|
|
519
|
+
private updateImageStatus;
|
|
520
|
+
private areImageStatusesEqual;
|
|
409
521
|
private clearImageLoadingProgress;
|
|
410
522
|
private clearImageShapeCacheForFileId;
|
|
411
523
|
private addMissingFiles;
|
|
@@ -428,7 +540,9 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
428
540
|
}) => void;
|
|
429
541
|
applyDeltas: (deltas: StoreDelta[], options?: ApplyToOptions) => [SceneElementsMap, AppState, boolean];
|
|
430
542
|
mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
|
|
431
|
-
|
|
543
|
+
triggerRender: (
|
|
544
|
+
/** force always re-renders canvas even if no change */
|
|
545
|
+
force?: boolean) => void;
|
|
432
546
|
/**
|
|
433
547
|
* @returns whether the menu was toggled on or off
|
|
434
548
|
*/
|
|
@@ -438,10 +552,8 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
438
552
|
force?: boolean;
|
|
439
553
|
}) => boolean;
|
|
440
554
|
private updateCurrentCursorPosition;
|
|
441
|
-
getEditorUIOffsets: () => Offsets;
|
|
442
555
|
private onKeyDown;
|
|
443
556
|
private onKeyUp;
|
|
444
|
-
private isToolSupported;
|
|
445
557
|
setActiveTool: (tool: ({
|
|
446
558
|
type: ToolType;
|
|
447
559
|
} | {
|
|
@@ -450,10 +562,18 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
450
562
|
}) & {
|
|
451
563
|
locked?: boolean;
|
|
452
564
|
fromSelection?: boolean;
|
|
453
|
-
},
|
|
565
|
+
}, opts?: {
|
|
566
|
+
keepSelection?: boolean;
|
|
567
|
+
/**
|
|
568
|
+
* When `true`, re-activating an already-active toggle tool (see
|
|
569
|
+
* `TOGGLE_TOOLS`) switches back to the previously active tool.
|
|
570
|
+
* Activation is idempotent by default; toggle tools always record the
|
|
571
|
+
* previously active tool regardless (so ESC and the next `toggle`
|
|
572
|
+
* activation can switch back to it).
|
|
573
|
+
*/
|
|
574
|
+
toggle?: boolean;
|
|
575
|
+
}) => void;
|
|
454
576
|
setOpenDialog: (dialogType: AppState["openDialog"]) => void;
|
|
455
|
-
private setCursor;
|
|
456
|
-
private resetCursor;
|
|
457
577
|
/**
|
|
458
578
|
* returns whether user is making a gesture with >= 2 fingers (points)
|
|
459
579
|
* on o touch screen (not on a trackpad). Currently only relates to Darwin
|
|
@@ -469,32 +589,229 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
469
589
|
private deselectElements;
|
|
470
590
|
private getSelectedTextElement;
|
|
471
591
|
private getSelectedTextEditingContainerAtPosition;
|
|
472
|
-
|
|
592
|
+
getTextElementAtPosition(x: number, y: number): NonDeleted<ExcalidrawTextElement> | null;
|
|
473
593
|
private isHittingTextAutoResizeHandle;
|
|
474
594
|
private handleTextAutoResizeHandlePointerDown;
|
|
475
|
-
|
|
595
|
+
getElementAtPosition(x: number, y: number, opts?: ({
|
|
596
|
+
includeBoundTextElement?: boolean;
|
|
597
|
+
includeLockedElements?: boolean;
|
|
598
|
+
} | {
|
|
599
|
+
allHitElements: NonDeleted<ExcalidrawElement>[];
|
|
600
|
+
}) & {
|
|
601
|
+
preferSelected?: boolean;
|
|
602
|
+
}): NonDeleted<ExcalidrawElement> | null;
|
|
476
603
|
private getElementsAtPosition;
|
|
477
604
|
getElementHitThreshold(element: ExcalidrawElement): number;
|
|
478
605
|
private hitElement;
|
|
479
|
-
|
|
606
|
+
getTextBindableContainerAtPosition(x: number, y: number): (Readonly<{
|
|
607
|
+
id: string;
|
|
608
|
+
x: number;
|
|
609
|
+
y: number;
|
|
610
|
+
strokeColor: string;
|
|
611
|
+
backgroundColor: string;
|
|
612
|
+
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
613
|
+
strokeWidth: number;
|
|
614
|
+
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
615
|
+
roundness: null | {
|
|
616
|
+
type: import("@excalidraw/element/types").RoundnessType;
|
|
617
|
+
value?: number;
|
|
618
|
+
};
|
|
619
|
+
roughness: number;
|
|
620
|
+
opacity: number;
|
|
621
|
+
width: number;
|
|
622
|
+
height: number;
|
|
623
|
+
angle: Radians;
|
|
624
|
+
seed: number;
|
|
625
|
+
version: number;
|
|
626
|
+
versionNonce: number;
|
|
627
|
+
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
628
|
+
isDeleted: boolean;
|
|
629
|
+
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
630
|
+
frameId: string | null;
|
|
631
|
+
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
632
|
+
updated: number;
|
|
633
|
+
link: string | null;
|
|
634
|
+
locked: boolean;
|
|
635
|
+
customData?: Record<string, any>;
|
|
636
|
+
}> & {
|
|
637
|
+
type: "rectangle";
|
|
638
|
+
} & {
|
|
639
|
+
isDeleted: false;
|
|
640
|
+
}) | (Readonly<{
|
|
641
|
+
id: string;
|
|
642
|
+
x: number;
|
|
643
|
+
y: number;
|
|
644
|
+
strokeColor: string;
|
|
645
|
+
backgroundColor: string;
|
|
646
|
+
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
647
|
+
strokeWidth: number;
|
|
648
|
+
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
649
|
+
roundness: null | {
|
|
650
|
+
type: import("@excalidraw/element/types").RoundnessType;
|
|
651
|
+
value?: number;
|
|
652
|
+
};
|
|
653
|
+
roughness: number;
|
|
654
|
+
opacity: number;
|
|
655
|
+
width: number;
|
|
656
|
+
height: number;
|
|
657
|
+
angle: Radians;
|
|
658
|
+
seed: number;
|
|
659
|
+
version: number;
|
|
660
|
+
versionNonce: number;
|
|
661
|
+
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
662
|
+
isDeleted: boolean;
|
|
663
|
+
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
664
|
+
frameId: string | null;
|
|
665
|
+
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
666
|
+
updated: number;
|
|
667
|
+
link: string | null;
|
|
668
|
+
locked: boolean;
|
|
669
|
+
customData?: Record<string, any>;
|
|
670
|
+
}> & {
|
|
671
|
+
type: "diamond";
|
|
672
|
+
} & {
|
|
673
|
+
isDeleted: false;
|
|
674
|
+
}) | (Readonly<{
|
|
675
|
+
id: string;
|
|
676
|
+
x: number;
|
|
677
|
+
y: number;
|
|
678
|
+
strokeColor: string;
|
|
679
|
+
backgroundColor: string;
|
|
680
|
+
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
681
|
+
strokeWidth: number;
|
|
682
|
+
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
683
|
+
roundness: null | {
|
|
684
|
+
type: import("@excalidraw/element/types").RoundnessType;
|
|
685
|
+
value?: number;
|
|
686
|
+
};
|
|
687
|
+
roughness: number;
|
|
688
|
+
opacity: number;
|
|
689
|
+
width: number;
|
|
690
|
+
height: number;
|
|
691
|
+
angle: Radians;
|
|
692
|
+
seed: number;
|
|
693
|
+
version: number;
|
|
694
|
+
versionNonce: number;
|
|
695
|
+
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
696
|
+
isDeleted: boolean;
|
|
697
|
+
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
698
|
+
frameId: string | null;
|
|
699
|
+
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
700
|
+
updated: number;
|
|
701
|
+
link: string | null;
|
|
702
|
+
locked: boolean;
|
|
703
|
+
customData?: Record<string, any>;
|
|
704
|
+
}> & {
|
|
705
|
+
type: "ellipse";
|
|
706
|
+
} & {
|
|
707
|
+
isDeleted: false;
|
|
708
|
+
}) | (Readonly<{
|
|
709
|
+
id: string;
|
|
710
|
+
x: number;
|
|
711
|
+
y: number;
|
|
712
|
+
strokeColor: string;
|
|
713
|
+
backgroundColor: string;
|
|
714
|
+
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
715
|
+
strokeWidth: number;
|
|
716
|
+
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
717
|
+
roundness: null | {
|
|
718
|
+
type: import("@excalidraw/element/types").RoundnessType;
|
|
719
|
+
value?: number;
|
|
720
|
+
};
|
|
721
|
+
roughness: number;
|
|
722
|
+
opacity: number;
|
|
723
|
+
width: number;
|
|
724
|
+
height: number;
|
|
725
|
+
angle: Radians;
|
|
726
|
+
seed: number;
|
|
727
|
+
version: number;
|
|
728
|
+
versionNonce: number;
|
|
729
|
+
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
730
|
+
isDeleted: boolean;
|
|
731
|
+
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
732
|
+
frameId: string | null;
|
|
733
|
+
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
734
|
+
updated: number;
|
|
735
|
+
link: string | null;
|
|
736
|
+
locked: boolean;
|
|
737
|
+
customData?: Record<string, any>;
|
|
738
|
+
}> & Readonly<{
|
|
739
|
+
type: "line" | "arrow";
|
|
740
|
+
points: readonly LocalPoint[];
|
|
741
|
+
startBinding: import("@excalidraw/element/types").FixedPointBinding | null;
|
|
742
|
+
endBinding: import("@excalidraw/element/types").FixedPointBinding | null;
|
|
743
|
+
startArrowhead: import("@excalidraw/element/types").Arrowhead | null;
|
|
744
|
+
endArrowhead: import("@excalidraw/element/types").Arrowhead | null;
|
|
745
|
+
}> & Readonly<{
|
|
746
|
+
type: "arrow";
|
|
747
|
+
elbowed: boolean;
|
|
748
|
+
}> & {
|
|
749
|
+
isDeleted: false;
|
|
750
|
+
}) | null;
|
|
751
|
+
/**
|
|
752
|
+
* Whether a text element's content is still being authored.
|
|
753
|
+
*
|
|
754
|
+
* Creating a text reverts the tool to selection during pointerdown, so the
|
|
755
|
+
* pointerup that follows looks like an ordinary canvas click and would
|
|
756
|
+
* capture the still-empty element as a history entry of its own. Undo would
|
|
757
|
+
* then rewind only the typing, restoring an invisible, zero-content element
|
|
758
|
+
* (and, for an endpoint label, leaving the arrow bound to it) rather than
|
|
759
|
+
* removing it. The editor's own submit captures the finished text instead,
|
|
760
|
+
* so the whole create-and-type lands in a single entry.
|
|
761
|
+
*/
|
|
762
|
+
private isEditingTextContent;
|
|
480
763
|
private startTextEditing;
|
|
481
764
|
private startImageCropping;
|
|
482
765
|
private finishImageCropping;
|
|
483
766
|
private shouldHandleBrowserCanvasDoubleClick;
|
|
484
767
|
private handleCanvasDoubleClick;
|
|
485
768
|
private handleCanvasClick;
|
|
769
|
+
private getImageStatusActionAtPosition;
|
|
770
|
+
private isPointInsideImageStatusOverlay;
|
|
486
771
|
private getElementLinkAtPosition;
|
|
487
772
|
private handleElementLinkClick;
|
|
488
|
-
|
|
773
|
+
/**
|
|
774
|
+
* Applies (or clears) the element-link hover affordances — pointer cursor
|
|
775
|
+
* and tooltip — based on the current `hitLinkElement`. Returns whether a
|
|
776
|
+
* link is being hovered.
|
|
777
|
+
*/
|
|
778
|
+
private applyElementLinkHoverAffordance;
|
|
779
|
+
/**
|
|
780
|
+
* On touchscreens (where no hover precedes the tap) re-derives
|
|
781
|
+
* `hitLinkElement`, then opens the hit element link, if any.
|
|
782
|
+
* Returns whether a link click was handled.
|
|
783
|
+
*/
|
|
784
|
+
private maybeHandleElementLinkClick;
|
|
785
|
+
/**
|
|
786
|
+
* Restricted pointer handling for the non-interactive editor with links
|
|
787
|
+
* and/or embeds allowed (`interaction.enabled.links` / `.embeds` /
|
|
788
|
+
* `.interactiveContent`) — runs only the element-link & embed concerns
|
|
789
|
+
* (shared with the full pointer handlers above) so they behave like in
|
|
790
|
+
* view mode without the rest of the canvas pointer machinery.
|
|
791
|
+
*/
|
|
792
|
+
private handleInteractiveContentPointerMove;
|
|
793
|
+
private handleInteractiveContentPointerUp;
|
|
489
794
|
/**
|
|
490
795
|
* finds candidate frame under cursor (when dragging frame children/elements
|
|
491
796
|
* inside frames)
|
|
492
797
|
*/
|
|
493
|
-
|
|
798
|
+
getTopLayerFrameAtSceneCoords: (
|
|
799
|
+
/**
|
|
800
|
+
* should be already grid aligned (basically should be what the call site
|
|
801
|
+
* sets the element's coords to, if applicable)
|
|
802
|
+
*/
|
|
803
|
+
sceneCoords: {
|
|
804
|
+
x: number;
|
|
805
|
+
y: number;
|
|
806
|
+
}, opts?: {
|
|
807
|
+
/** to exclude selected elements when dragging, etc. */
|
|
808
|
+
excludeElementIds?: AppState["selectedElementIds"];
|
|
809
|
+
currentFrameId?: ExcalidrawElement["frameId"];
|
|
810
|
+
}) => NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
494
811
|
private updateFrameToHighlight;
|
|
495
812
|
private maybeUpdateFrameToHighlightOnPointerMove;
|
|
496
|
-
|
|
497
|
-
|
|
813
|
+
insertNewElements: (elements: readonly ExcalidrawElement[]) => void;
|
|
814
|
+
insertNewElement: (element: ExcalidrawElement) => void;
|
|
498
815
|
private handleCanvasPointerMove;
|
|
499
816
|
private handleEraser;
|
|
500
817
|
private handleTouchMove;
|
|
@@ -509,10 +826,13 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
509
826
|
* pointerup handlers manually
|
|
510
827
|
*/
|
|
511
828
|
private maybeCleanupAfterMissingPointerUp;
|
|
512
|
-
private handleCanvasZoomUsingZDrag;
|
|
513
|
-
private restoreCursorAfterZoomKey;
|
|
514
829
|
handleCanvasPanUsingWheelOrSpaceDrag: (event: React.PointerEvent<HTMLElement> | MouseEvent) => boolean;
|
|
515
830
|
private updateGestureOnPointerDown;
|
|
831
|
+
/**
|
|
832
|
+
* Tracks the pointer within the ongoing multi-touch gesture and applies
|
|
833
|
+
* the two-finger pinch zoom/pan, if any.
|
|
834
|
+
*/
|
|
835
|
+
private updateMultiTouchGesture;
|
|
516
836
|
private initialPointerDownState;
|
|
517
837
|
private handleDraggingScrollBar;
|
|
518
838
|
private clearSelectionIfNotUsingSelection;
|
|
@@ -577,9 +897,13 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
577
897
|
private maybeHandleCrop;
|
|
578
898
|
private maybeHandleResize;
|
|
579
899
|
private getContextMenuItems;
|
|
580
|
-
private getImageContextMenuItems;
|
|
581
900
|
private handleWheel;
|
|
582
|
-
|
|
901
|
+
getTextWysiwygSnappedToCenterPosition(x: number, y: number, appState: AppState, container?: ExcalidrawTextContainer | null): {
|
|
902
|
+
viewportX: number;
|
|
903
|
+
viewportY: number;
|
|
904
|
+
elementCenterX: number;
|
|
905
|
+
elementCenterY: number;
|
|
906
|
+
} | undefined;
|
|
583
907
|
private savePointer;
|
|
584
908
|
private resetShouldCacheIgnoreZoomDebounced;
|
|
585
909
|
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
|
+
}
|