@excalidraw/common 0.18.0-063e025 → 0.18.0-1acf66e
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 +9 -5
- package/dist/dev/index.js.map +2 -2
- package/dist/prod/index.js +3 -3
- package/dist/types/common/src/constants.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/arrowEndpointText.d.ts +49 -0
- package/dist/types/element/src/arrows/focus.d.ts +5 -2
- package/dist/types/element/src/binding.d.ts +12 -3
- 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/dragElements.d.ts +27 -0
- package/dist/types/element/src/flowchart.d.ts +6 -6
- package/dist/types/element/src/groups.d.ts +1 -1
- package/dist/types/element/src/index.d.ts +2 -0
- package/dist/types/element/src/linearElementEditor.d.ts +7 -0
- package/dist/types/element/src/newElement.d.ts +13 -0
- package/dist/types/element/src/selection.d.ts +1 -1
- package/dist/types/element/src/textElement.d.ts +6 -3
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +15 -3
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +99 -565
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +16 -3
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionExport.d.ts +15 -7
- package/dist/types/excalidraw/actions/actionFrame.d.ts +15 -178
- package/dist/types/excalidraw/actions/actionGroup.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +6 -1
- package/dist/types/excalidraw/actions/actionLink.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionProperties.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionStyles.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +6 -2
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +5 -1
- package/dist/types/excalidraw/actions/index.d.ts +0 -1
- 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 +5 -1
- package/dist/types/excalidraw/appState.d.ts +5 -5
- package/dist/types/excalidraw/components/Actions.d.ts +16 -10
- package/dist/types/excalidraw/components/App.arrowText.d.ts +72 -0
- package/dist/types/excalidraw/components/App.cursor.d.ts +31 -0
- package/dist/types/excalidraw/components/App.d.ts +322 -76
- 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/{ToolButton.d.ts → IconButton.d.ts} +16 -19
- package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
- package/dist/types/excalidraw/components/LayerUI.d.ts +4 -2
- package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
- package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
- 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/ToolPopover.d.ts +3 -6
- package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
- package/dist/types/excalidraw/components/Tools.d.ts +145 -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/icons.d.ts +1 -1
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +1 -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/data/blob.d.ts +20 -12
- package/dist/types/excalidraw/data/json.d.ts +10 -6
- package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
- package/dist/types/excalidraw/scene/types.d.ts +3 -0
- package/dist/types/excalidraw/types.d.ts +199 -13
- package/dist/types/excalidraw/viewport.d.ts +20 -64
- 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/package.json +1 -1
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -173
- package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -10
- package/dist/types/excalidraw/components/shapes.d.ts +0 -270
- package/dist/types/excalidraw/cursor.d.ts +0 -5
- package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GlobalPoint } from "@excalidraw/math";
|
|
2
|
+
import type App from "./components/App";
|
|
3
|
+
import type { Trail } from "./animatedTrail";
|
|
4
|
+
export declare class DrawShapeTrail implements Trail {
|
|
5
|
+
private app;
|
|
6
|
+
private trail;
|
|
7
|
+
constructor(app: App);
|
|
8
|
+
private getTrailOptions;
|
|
9
|
+
startPath(x: number, y: number): void;
|
|
10
|
+
addPointToPath(x: number, y: number): void;
|
|
11
|
+
endPath(): void;
|
|
12
|
+
clearTrails(): void;
|
|
13
|
+
getCurrentPoints(): GlobalPoint[];
|
|
14
|
+
start(container: SVGSVGElement): void;
|
|
15
|
+
stop(): void;
|
|
16
|
+
}
|
|
@@ -9,6 +9,9 @@ export type StaticCanvasRenderConfig = {
|
|
|
9
9
|
canvasBackgroundColor: AppState["viewBackgroundColor"];
|
|
10
10
|
imageCache: AppClassProperties["imageCache"];
|
|
11
11
|
renderGrid: boolean;
|
|
12
|
+
/** whether to render link icons on elements with links (never rendered
|
|
13
|
+
when exporting). @default true */
|
|
14
|
+
renderLinks?: boolean;
|
|
12
15
|
/** when exporting the behavior is slightly different (e.g. we can't use
|
|
13
16
|
CSS filters), and we disable render optimizations for best output */
|
|
14
17
|
isExporting: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface, StrokeWidthKey } from "@excalidraw/common";
|
|
2
2
|
import type { LinearElementEditor } from "@excalidraw/element";
|
|
3
3
|
import type { MaybeTransformHandleType } from "@excalidraw/element";
|
|
4
|
-
import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode, ExcalidrawTextElement, StrokeVariability } from "@excalidraw/element/types";
|
|
4
|
+
import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, ExcalidrawArrowElement, Arrowhead, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode, ExcalidrawTextElement, StrokeVariability } from "@excalidraw/element/types";
|
|
5
5
|
import type { Merge, MaybePromise, ValueOf, MakeBrand } from "@excalidraw/common/utility-types";
|
|
6
6
|
import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
|
|
7
7
|
import type { GlobalPoint } from "@excalidraw/math";
|
|
@@ -85,7 +85,7 @@ export type BinaryFileData = {
|
|
|
85
85
|
};
|
|
86
86
|
export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
|
|
87
87
|
export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
|
|
88
|
-
export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser";
|
|
88
|
+
export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser" | "autoshape";
|
|
89
89
|
export type ElementOrToolType = ExcalidrawElementType | ToolType | "custom";
|
|
90
90
|
export type ActiveTool = {
|
|
91
91
|
type: ToolType;
|
|
@@ -139,7 +139,9 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
139
139
|
newElement: AppState["newElement"];
|
|
140
140
|
isBindingEnabled: AppState["isBindingEnabled"];
|
|
141
141
|
isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
|
|
142
|
+
gridModeEnabled: AppState["gridModeEnabled"];
|
|
142
143
|
suggestedBinding: AppState["suggestedBinding"];
|
|
144
|
+
hoveredArrowTextAnchor: AppState["hoveredArrowTextAnchor"];
|
|
143
145
|
isRotating: AppState["isRotating"];
|
|
144
146
|
elementsToHighlight: AppState["elementsToHighlight"];
|
|
145
147
|
collaborators: AppState["collaborators"];
|
|
@@ -261,6 +263,15 @@ export interface AppState {
|
|
|
261
263
|
element: NonDeleted<ExcalidrawBindableElement>;
|
|
262
264
|
midPoint?: GlobalPoint;
|
|
263
265
|
} | null;
|
|
266
|
+
/**
|
|
267
|
+
* Where on a hovered arrow the text tool would attach text if clicked —
|
|
268
|
+
* a free endpoint (binds the arrow to a new text element positioned against
|
|
269
|
+
* that endpoint) or the arrow's midpoint (adds a label bound to the arrow).
|
|
270
|
+
*/
|
|
271
|
+
hoveredArrowTextAnchor: {
|
|
272
|
+
elementId: ExcalidrawArrowElement["id"];
|
|
273
|
+
anchor: "start" | "end" | "label";
|
|
274
|
+
} | null;
|
|
264
275
|
frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
265
276
|
frameRendering: {
|
|
266
277
|
enabled: boolean;
|
|
@@ -268,7 +279,10 @@ export interface AppState {
|
|
|
268
279
|
outline: boolean;
|
|
269
280
|
clip: boolean;
|
|
270
281
|
};
|
|
271
|
-
|
|
282
|
+
/**
|
|
283
|
+
* frame-like element whose name is currently being edited
|
|
284
|
+
*/
|
|
285
|
+
editingFrame: ExcalidrawFrameLikeElement["id"] | null;
|
|
272
286
|
elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
|
|
273
287
|
/**
|
|
274
288
|
* set when a new text is created or when an existing text is being edited
|
|
@@ -430,7 +444,7 @@ export type SearchMatch = {
|
|
|
430
444
|
showOnCanvas: boolean;
|
|
431
445
|
}[];
|
|
432
446
|
};
|
|
433
|
-
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "frameToHighlight" | "elementsToHighlight">;
|
|
447
|
+
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "hoveredArrowTextAnchor" | "frameToHighlight" | "elementsToHighlight">;
|
|
434
448
|
export type NormalizedZoomValue = number & {
|
|
435
449
|
_brand: "normalizedZoom";
|
|
436
450
|
};
|
|
@@ -487,6 +501,111 @@ export type OnExportProgress = {
|
|
|
487
501
|
/** 0-1 range */
|
|
488
502
|
progress?: number;
|
|
489
503
|
};
|
|
504
|
+
export type InteractionConfig = {
|
|
505
|
+
/**
|
|
506
|
+
* Interactions that stay enabled while the editor is otherwise
|
|
507
|
+
* non-interactive. Opt-in: anything omitted or `false` is disabled.
|
|
508
|
+
*/
|
|
509
|
+
enabled?: {
|
|
510
|
+
/**
|
|
511
|
+
* Element links render their link icon and stay clickable — clicking
|
|
512
|
+
* anywhere on a linked element opens the link, same as in view mode.
|
|
513
|
+
* When disabled, link icons are not rendered at all.
|
|
514
|
+
*
|
|
515
|
+
* @default false
|
|
516
|
+
*/
|
|
517
|
+
links?: boolean;
|
|
518
|
+
/**
|
|
519
|
+
* Embeddable & iframe elements stay interactive — hovering & clicking
|
|
520
|
+
* activates them so their content can be used, same as in view mode.
|
|
521
|
+
*
|
|
522
|
+
* @default false
|
|
523
|
+
*/
|
|
524
|
+
embeds?: boolean;
|
|
525
|
+
/**
|
|
526
|
+
* Umbrella for all interactive content on canvas — shorthand for
|
|
527
|
+
* enabling `links` & `embeds` (and future interactive content kinds)
|
|
528
|
+
* together. Additive: `interactiveContent: true` enables them
|
|
529
|
+
* regardless of their individual values.
|
|
530
|
+
*
|
|
531
|
+
* @default false
|
|
532
|
+
*/
|
|
533
|
+
interactiveContent?: boolean;
|
|
534
|
+
/**
|
|
535
|
+
* Canvas navigation — panning (pointer drag, wheel, PageUp/PageDown)
|
|
536
|
+
* and zooming (ctrl/cmd + wheel, pinch, and the canvas zoom &
|
|
537
|
+
* zoom-to-fit shortcuts: ctrl/cmd +/-/0, shift+1/2/3), same as in view
|
|
538
|
+
* mode. Respects `appState.scrollConstraints` if set, so it composes
|
|
539
|
+
* with viewport locking. The rest of the keyboard stays disabled. Note
|
|
540
|
+
* the editor consumes wheel & touch input again when enabled, so the
|
|
541
|
+
* page no longer scrolls over the editor.
|
|
542
|
+
*
|
|
543
|
+
* @default false
|
|
544
|
+
*/
|
|
545
|
+
navigation?: boolean;
|
|
546
|
+
/**
|
|
547
|
+
* Whether the browser's own zoom remains available over the editor —
|
|
548
|
+
* ctrl/cmd + wheel, pinch, and (while the editor has focus)
|
|
549
|
+
* ctrl/cmd +/-/0 shortcuts. Prevented by default, mirroring the
|
|
550
|
+
* interactive editor. Regular page scrolling stays available either way.
|
|
551
|
+
* With `navigation` enabled, the zoom input (wheel, pinch, keyboard
|
|
552
|
+
* shortcuts) zooms the canvas instead either way, making this moot.
|
|
553
|
+
*
|
|
554
|
+
* @default false
|
|
555
|
+
*/
|
|
556
|
+
browserZoom?: boolean;
|
|
557
|
+
/**
|
|
558
|
+
* Tools that stay user-driven while the editor is otherwise
|
|
559
|
+
* non-interactive: pointer input keeps driving the listed tool when it's
|
|
560
|
+
* the active tool. Does not enable user-driven tool *switching* — the
|
|
561
|
+
* keyboard stays disabled and tool selection remains host-driven
|
|
562
|
+
* (`ExcalidrawAPI.setActiveTool`).
|
|
563
|
+
*
|
|
564
|
+
* Composes with `navigation`: the enabled tool wins the primary-pointer
|
|
565
|
+
* drag, while wheel input (and wheel-button drag) still pans/zooms.
|
|
566
|
+
*/
|
|
567
|
+
tools?: {
|
|
568
|
+
/**
|
|
569
|
+
* The laser pointer stays usable — pointer strokes draw laser trails
|
|
570
|
+
* and pointer positions keep broadcasting via `onPointerUpdate`, so
|
|
571
|
+
* e.g. collaborators see a presenter's laser & cursor.
|
|
572
|
+
*
|
|
573
|
+
* @default false
|
|
574
|
+
*/
|
|
575
|
+
laser?: boolean;
|
|
576
|
+
/**
|
|
577
|
+
* Custom tools (`activeTool.type === "custom"`) stay usable — the
|
|
578
|
+
* editor keeps dispatching `onPointerDown` / `onPointerUp` for them.
|
|
579
|
+
* Tool behavior is host-implemented; activate custom tools with
|
|
580
|
+
* `locked: true` or they revert to the selection tool (and go inert)
|
|
581
|
+
* after the first pointer interaction.
|
|
582
|
+
*
|
|
583
|
+
* @default false
|
|
584
|
+
*/
|
|
585
|
+
custom?: boolean;
|
|
586
|
+
};
|
|
587
|
+
};
|
|
588
|
+
};
|
|
589
|
+
export type UIConfig = {
|
|
590
|
+
/**
|
|
591
|
+
* Default UI controls that stay enabled while the rest of Excalidraw's
|
|
592
|
+
* default UI is hidden. Opt-in: anything omitted or `false` is disabled.
|
|
593
|
+
*/
|
|
594
|
+
enabled: {
|
|
595
|
+
/**
|
|
596
|
+
* The zoom-out, reset-zoom, and zoom-in controls.
|
|
597
|
+
*
|
|
598
|
+
* @default false
|
|
599
|
+
*/
|
|
600
|
+
zoom?: boolean;
|
|
601
|
+
/**
|
|
602
|
+
* The button shown when the viewport is scrolled away from all content.
|
|
603
|
+
*
|
|
604
|
+
* @default false
|
|
605
|
+
*/
|
|
606
|
+
scrollBackToContent?: boolean;
|
|
607
|
+
};
|
|
608
|
+
};
|
|
490
609
|
export interface ExcalidrawProps {
|
|
491
610
|
onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
|
|
492
611
|
onThemeChange?: (theme: Theme | "system") => void;
|
|
@@ -542,6 +661,70 @@ export interface ExcalidrawProps {
|
|
|
542
661
|
renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
543
662
|
langCode?: Language["code"];
|
|
544
663
|
viewModeEnabled?: boolean;
|
|
664
|
+
/**
|
|
665
|
+
* Whether the editor accepts user input (pointer, keyboard, wheel, touch,
|
|
666
|
+
* clipboard, drag&drop). When `false`, the scene still renders and reacts
|
|
667
|
+
* to programmatic updates (imperative API), but the user cannot affect it
|
|
668
|
+
* in any way. Implies view mode.
|
|
669
|
+
*
|
|
670
|
+
* Pass a config object to keep specific interactions enabled while the
|
|
671
|
+
* editor is otherwise non-interactive (see `InteractionConfig`):
|
|
672
|
+
*
|
|
673
|
+
* ```tsx
|
|
674
|
+
* <Excalidraw interaction={{ enabled: { links: true } }} />
|
|
675
|
+
* ```
|
|
676
|
+
*
|
|
677
|
+
* @default true
|
|
678
|
+
*/
|
|
679
|
+
interaction?: boolean | InteractionConfig;
|
|
680
|
+
/**
|
|
681
|
+
* Whether Excalidraw's default UI is rendered — toolbar, default menus,
|
|
682
|
+
* footer controls, sidebars, and canvas popups. Host UI passed through
|
|
683
|
+
* children (including exported components such as `MainMenu` and `Footer`)
|
|
684
|
+
* or render props continues to render, together with any supporting dialogs
|
|
685
|
+
* it opens.
|
|
686
|
+
*
|
|
687
|
+
* Canvas content (elements, text editing surface, frame names, embeds) still
|
|
688
|
+
* renders, and the editor remains interactive unless `interaction` is set to
|
|
689
|
+
* `false`.
|
|
690
|
+
*
|
|
691
|
+
* Pass a config object to keep specific default controls rendered while the
|
|
692
|
+
* rest of the default UI is hidden (see `UIConfig`):
|
|
693
|
+
*
|
|
694
|
+
* ```tsx
|
|
695
|
+
* <Excalidraw ui={{ enabled: { zoom: true } }} />
|
|
696
|
+
* ```
|
|
697
|
+
*
|
|
698
|
+
* NOTE: this is WIP and what default UI is/is not rendered when ui=false
|
|
699
|
+
* may yet change.
|
|
700
|
+
*
|
|
701
|
+
* @default true
|
|
702
|
+
*/
|
|
703
|
+
ui?: boolean | UIConfig;
|
|
704
|
+
/**
|
|
705
|
+
* Forces the active editor tool (controlled). While set, user- and
|
|
706
|
+
* API-driven tool switching is ignored — `setActiveTool` refuses with a
|
|
707
|
+
* console warning, non-forced toolbar buttons render disabled — and the
|
|
708
|
+
* editor snaps back if internal flows reset the tool. The forced tool
|
|
709
|
+
* behaves as if locked (see the tool lock / padlock): it doesn't revert to
|
|
710
|
+
* the selection tool after use, and elements drawn with it aren't
|
|
711
|
+
* auto-selected — without mutating `appState.activeTool.locked`, so the
|
|
712
|
+
* user's persisted padlock preference stays untouched. Unset to return
|
|
713
|
+
* tool control to the editor (the current tool stays active).
|
|
714
|
+
*
|
|
715
|
+
* The forced tool must be activatable to take effect: not disabled via
|
|
716
|
+
* `UIOptions.tools`, and — while the editor is non-interactive — allowed
|
|
717
|
+
* via `interaction.enabled.tools`. Otherwise the editor stays on (or, when
|
|
718
|
+
* non-interactive, resets to) the `selection` tool, and the forced tool is
|
|
719
|
+
* applied once it becomes activatable. `image` cannot be forced (its
|
|
720
|
+
* activation opens the file picker).
|
|
721
|
+
*/
|
|
722
|
+
activeTool?: {
|
|
723
|
+
type: Exclude<ToolType, "image">;
|
|
724
|
+
} | {
|
|
725
|
+
type: "custom";
|
|
726
|
+
customType: string;
|
|
727
|
+
};
|
|
545
728
|
zenModeEnabled?: boolean;
|
|
546
729
|
gridModeEnabled?: boolean;
|
|
547
730
|
objectsSnapModeEnabled?: boolean;
|
|
@@ -678,8 +861,7 @@ export type AppClassProperties = {
|
|
|
678
861
|
id: App["id"];
|
|
679
862
|
onInsertElements: App["onInsertElements"];
|
|
680
863
|
onExportImage: App["onExportImage"];
|
|
681
|
-
|
|
682
|
-
setViewport: App["setViewport"];
|
|
864
|
+
viewport: App["viewport"];
|
|
683
865
|
addFiles: App["addFiles"];
|
|
684
866
|
addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
|
|
685
867
|
togglePenMode: App["togglePenMode"];
|
|
@@ -690,11 +872,13 @@ export type AppClassProperties = {
|
|
|
690
872
|
onMagicframeToolSelect: App["onMagicframeToolSelect"];
|
|
691
873
|
getName: App["getName"];
|
|
692
874
|
dismissLinearEditor: App["dismissLinearEditor"];
|
|
693
|
-
|
|
875
|
+
flowchart: App["flowchart"];
|
|
876
|
+
drawShape: App["drawShape"];
|
|
877
|
+
cursor: App["cursor"];
|
|
878
|
+
isToolLocked: App["isToolLocked"];
|
|
694
879
|
getEffectiveGridSize: App["getEffectiveGridSize"];
|
|
695
880
|
setPlugins: App["setPlugins"];
|
|
696
881
|
plugins: App["plugins"];
|
|
697
|
-
getViewportOffsets: App["getViewportOffsets"];
|
|
698
882
|
visibleElements: App["visibleElements"];
|
|
699
883
|
excalidrawContainerValue: App["excalidrawContainerValue"];
|
|
700
884
|
onPointerUpEmitter: App["onPointerUpEmitter"];
|
|
@@ -703,8 +887,11 @@ export type AppClassProperties = {
|
|
|
703
887
|
onEvent: App["onEvent"];
|
|
704
888
|
onStateChange: App["onStateChange"];
|
|
705
889
|
lastPointerMoveCoords: App["lastPointerMoveCoords"];
|
|
890
|
+
lastPointerMoveEvent: App["lastPointerMoveEvent"];
|
|
706
891
|
bindModeHandler: App["bindModeHandler"];
|
|
707
892
|
setAppState: App["setAppState"];
|
|
893
|
+
isInteractionEnabled: App["isInteractionEnabled"];
|
|
894
|
+
isNavigationEnabled: App["isNavigationEnabled"];
|
|
708
895
|
};
|
|
709
896
|
export type PointerDownState = Readonly<{
|
|
710
897
|
origin: Readonly<{
|
|
@@ -791,16 +978,16 @@ export interface ExcalidrawImperativeAPI {
|
|
|
791
978
|
getAppState: () => InstanceType<typeof App>["state"];
|
|
792
979
|
getFiles: () => InstanceType<typeof App>["files"];
|
|
793
980
|
getName: InstanceType<typeof App>["getName"];
|
|
794
|
-
setViewport: InstanceType<typeof App>["setViewport"];
|
|
795
|
-
getViewportOffsets: InstanceType<typeof App>["
|
|
981
|
+
setViewport: InstanceType<typeof App>["viewport"]["setViewport"];
|
|
982
|
+
getViewportOffsets: InstanceType<typeof App>["viewport"]["getOffsets"];
|
|
796
983
|
registerAction: (action: Action) => void;
|
|
797
984
|
refresh: InstanceType<typeof App>["refresh"];
|
|
798
985
|
setToast: InstanceType<typeof App>["setToast"];
|
|
799
986
|
addFiles: (data: BinaryFileData[]) => void;
|
|
800
987
|
id: string;
|
|
801
988
|
setActiveTool: InstanceType<typeof App>["setActiveTool"];
|
|
802
|
-
setCursor: InstanceType<typeof App>["
|
|
803
|
-
resetCursor: InstanceType<typeof App>["
|
|
989
|
+
setCursor: InstanceType<typeof App>["cursor"]["set"];
|
|
990
|
+
resetCursor: InstanceType<typeof App>["cursor"]["reset"];
|
|
804
991
|
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
|
805
992
|
getEditorInterface: () => EditorInterface;
|
|
806
993
|
/**
|
|
@@ -823,7 +1010,6 @@ export type FrameNameBounds = {
|
|
|
823
1010
|
y: number;
|
|
824
1011
|
width: number;
|
|
825
1012
|
height: number;
|
|
826
|
-
angle: number;
|
|
827
1013
|
};
|
|
828
1014
|
export type FrameNameBoundsCache = {
|
|
829
1015
|
get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { SceneBounds } from "@excalidraw/element";
|
|
2
2
|
import type { Bounds } from "@excalidraw/common";
|
|
3
|
-
import type { ExcalidrawElement
|
|
3
|
+
import type { ExcalidrawElement } from "@excalidraw/element/types";
|
|
4
4
|
import type { AppState, NormalizedZoomValue, Offsets, PointerCoords, ScrollConstraints, ViewportOffsets, Zoom } from "./types";
|
|
5
|
-
export declare const SCROLL_TO_CONTENT_ANIMATION_KEY = "animateScrollToContent";
|
|
6
5
|
/** default rubberband overscroll give for scroll locks, in viewport px */
|
|
7
6
|
export declare const DEFAULT_OVERSCROLL = 150;
|
|
7
|
+
type ZoomOptions = {
|
|
8
|
+
viewportX: number;
|
|
9
|
+
viewportY: number;
|
|
10
|
+
nextZoom: NormalizedZoomValue;
|
|
11
|
+
};
|
|
8
12
|
export type AnimationOptions = {
|
|
9
13
|
duration?: number;
|
|
10
14
|
};
|
|
@@ -14,7 +18,6 @@ export type SetViewportRect = {
|
|
|
14
18
|
width?: number;
|
|
15
19
|
height?: number;
|
|
16
20
|
};
|
|
17
|
-
export declare const isSetViewportRect: (target: unknown) => target is SetViewportRect;
|
|
18
21
|
export type SetViewportOptions = {
|
|
19
22
|
/**
|
|
20
23
|
* what to show in the viewport: an explicit scene-coordinate box/rect,
|
|
@@ -63,22 +66,13 @@ type Viewport = Pick<AppState, "scrollX" | "scrollY" | "zoom">;
|
|
|
63
66
|
* resting clamp — pass 0 for a hard clamp.
|
|
64
67
|
*/
|
|
65
68
|
export declare const constrainScrollState: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">, overscroll?: number) => Viewport;
|
|
66
|
-
export declare const isViewportOverscrolled: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">) => boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Rubberband snap-back: animates the viewport from its current (possibly
|
|
69
|
-
* overscrolled) position back inside the lock box via the shared
|
|
70
|
-
* AnimationController. No-op when already within the hard bounds (or when there
|
|
71
|
-
* is no lock).
|
|
72
|
-
*/
|
|
73
|
-
export declare const animateToConstraints: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">, onFrame: (viewport: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom">) => void, duration?: number) => void;
|
|
74
69
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
70
|
+
* Resolves a focal-point zoom against the active scroll constraints while
|
|
71
|
+
* preserving the current rubberband displacement in screen pixels. This lets
|
|
72
|
+
* zoom and scroll-constraint snap-back compose without either visually
|
|
73
|
+
* cancelling the other.
|
|
78
74
|
*/
|
|
79
|
-
export declare const
|
|
80
|
-
offsets?: Offsets;
|
|
81
|
-
}, onFrame: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom">) => void, onComplete?: () => void) => void;
|
|
75
|
+
export declare const getViewportForZoomWithScrollConstraints: (opts: ZoomOptions, state: AppState) => Viewport;
|
|
82
76
|
export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, minZoom, maxZoom, steppedZoom, }: {
|
|
83
77
|
bounds: SceneBounds;
|
|
84
78
|
canvasOffsets?: Offsets;
|
|
@@ -106,26 +100,30 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, m
|
|
|
106
100
|
element: import("@excalidraw/element/types").NonDeletedExcalidrawElement;
|
|
107
101
|
state: "hover" | "active";
|
|
108
102
|
} | null;
|
|
109
|
-
newElement: NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
|
|
103
|
+
newElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
|
|
110
104
|
resizingElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
|
|
111
|
-
multiElement: NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
|
|
105
|
+
multiElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
|
|
112
106
|
selectionElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
|
|
113
107
|
isBindingEnabled: boolean;
|
|
114
108
|
boxSelectionMode: import("./types").BoxSelectionMode;
|
|
115
109
|
bindingPreference: "enabled" | "disabled";
|
|
116
110
|
isMidpointSnappingEnabled: boolean;
|
|
117
111
|
suggestedBinding: {
|
|
118
|
-
element: NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
|
|
112
|
+
element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
|
|
119
113
|
midPoint?: import("@excalidraw/math").GlobalPoint;
|
|
120
114
|
} | null;
|
|
121
|
-
|
|
115
|
+
hoveredArrowTextAnchor: {
|
|
116
|
+
elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
|
|
117
|
+
anchor: "start" | "end" | "label";
|
|
118
|
+
} | null;
|
|
119
|
+
frameToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
|
|
122
120
|
frameRendering: {
|
|
123
121
|
enabled: boolean;
|
|
124
122
|
name: boolean;
|
|
125
123
|
outline: boolean;
|
|
126
124
|
clip: boolean;
|
|
127
125
|
};
|
|
128
|
-
editingFrame:
|
|
126
|
+
editingFrame: import("@excalidraw/element/types").ExcalidrawFrameLikeElement["id"] | null;
|
|
129
127
|
elementsToHighlight: readonly import("@excalidraw/element/types").NonDeletedExcalidrawElement[] | null;
|
|
130
128
|
editingTextElement: import("@excalidraw/element/types").ExcalidrawTextElement | null;
|
|
131
129
|
activeTool: {
|
|
@@ -251,48 +249,6 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, m
|
|
|
251
249
|
};
|
|
252
250
|
captureUpdate: "EVENTUALLY";
|
|
253
251
|
};
|
|
254
|
-
/** Computes the viewport (scroll + zoom) that brings the target box into view,
|
|
255
|
-
* based on the requested fit behavior. */
|
|
256
|
-
export declare const getTargetViewport: (state: AppState, bounds: Bounds, fit?: SetViewportOptions["fit"], offsets?: Offsets) => Viewport;
|
|
257
|
-
export type ResolvedViewportTarget = {
|
|
258
|
-
/** null when the target couldn't be resolved (unknown id/link, or all
|
|
259
|
-
* supplied elements deleted) */
|
|
260
|
-
bounds: Bounds | null;
|
|
261
|
-
/** how the target was specified, so callers can react to unresolved
|
|
262
|
-
* targets themselves (e.g. toast on a broken element link) */
|
|
263
|
-
type: "element" | "area" | "link";
|
|
264
|
-
};
|
|
265
|
-
/** Resolves a `setViewport` target to a scene-coordinate box. */
|
|
266
|
-
export declare const resolveViewportTarget: (target: SetViewportOptions["target"], elementsMap: NonDeletedSceneElementsMap, appState: Pick<AppState, "width" | "height">) => ResolvedViewportTarget;
|
|
267
|
-
/** Computes the viewport patch for landing on `bounds`: the target
|
|
268
|
-
* scroll/zoom, plus the scroll lock to install — or `scrollConstraints: null`
|
|
269
|
-
* to clear a previous lock when none is requested. */
|
|
270
|
-
export declare const getConstrainedTargetViewport: (appState: AppState, bounds: Bounds, { fit, offsets, lock, }: Pick<SetViewportOptions, "fit" | "lock"> & {
|
|
271
|
-
offsets?: Offsets;
|
|
272
|
-
}) => Viewport & {
|
|
273
|
-
scrollConstraints: ScrollConstraints | null;
|
|
274
|
-
};
|
|
275
|
-
/**
|
|
276
|
-
* Interpolates the viewport from `from` to `target` at the (already-eased)
|
|
277
|
-
* blend amount `factor` (0 = `from`, 1 = `target`).
|
|
278
|
-
*
|
|
279
|
-
* Zoom is interpolated geometrically (so it feels uniform), but the pan can't
|
|
280
|
-
* simply lerp alongside it: pairing a geometric zoom with a linear scroll (or
|
|
281
|
-
* a linearly-tweened focal point) makes scene points swoop along curved,
|
|
282
|
-
* non-monotone screen paths once the zoom ratio exceeds ~e (the destination
|
|
283
|
-
* visibly drifts away before converging). Instead we interpolate the view
|
|
284
|
-
* transform affinely — a scene point maps to screen as
|
|
285
|
-
* `(scenePt + scroll) * zoom`, and requiring every point to travel a straight
|
|
286
|
-
* screen line forces `zoom` to be a convex blend `(1-m)*z0 + m*z1` with
|
|
287
|
-
* `scroll * zoom` lerped by that same weight. Deriving `m` from the geometric
|
|
288
|
-
* zoom keeps its pacing while making all screen trajectories straight and
|
|
289
|
-
* monotone.
|
|
290
|
-
*/
|
|
291
|
-
export declare const interpolateViewport: ({ from, target, factor, }: {
|
|
292
|
-
from: Viewport;
|
|
293
|
-
target: Viewport;
|
|
294
|
-
factor: number;
|
|
295
|
-
}) => Viewport;
|
|
296
252
|
export declare const getClosestElementBounds: (elements: readonly ExcalidrawElement[], from: {
|
|
297
253
|
x: number;
|
|
298
254
|
y: number;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { GlobalPoint, LocalPoint, Vector } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* The principal axes of a point set, i.e. the eigen decomposition of its
|
|
4
|
+
* 2x2 covariance matrix.
|
|
5
|
+
*
|
|
6
|
+
* The axes are orthonormal and ordered by variance, so `major` is the
|
|
7
|
+
* direction along which the points spread the most. Together with `centroid`
|
|
8
|
+
* they define a canonical frame: expressing the points in it removes
|
|
9
|
+
* translation and rotation, and dividing by `sqrt(majorVariance)` removes
|
|
10
|
+
* scale.
|
|
11
|
+
*/
|
|
12
|
+
export type PrincipalAxes<Point extends GlobalPoint | LocalPoint> = {
|
|
13
|
+
centroid: Point;
|
|
14
|
+
/** Unit vector along the direction of largest variance. */
|
|
15
|
+
major: Vector;
|
|
16
|
+
/** Unit vector along the direction of smallest variance, normal to major. */
|
|
17
|
+
minor: Vector;
|
|
18
|
+
/** Variance along `major` (the larger eigenvalue, λ₁). */
|
|
19
|
+
majorVariance: number;
|
|
20
|
+
/** Variance along `minor` (the smaller eigenvalue, λ₂). */
|
|
21
|
+
minorVariance: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A point expressed in a principal axes frame: `u` along the major axis,
|
|
25
|
+
* `v` along the minor axis, both relative to the centroid.
|
|
26
|
+
*/
|
|
27
|
+
export type PrincipalCoords = [u: number, v: number];
|
|
28
|
+
/**
|
|
29
|
+
* Compute the centroid of a point set.
|
|
30
|
+
*/
|
|
31
|
+
export declare function centroid<Point extends GlobalPoint | LocalPoint>(points: readonly Point[]): Point;
|
|
32
|
+
/**
|
|
33
|
+
* Principal component analysis of a 2D point set.
|
|
34
|
+
*
|
|
35
|
+
* Computes the centroid and the eigen decomposition of the covariance matrix
|
|
36
|
+
* [[μ20, μ11], [μ11, μ02]].
|
|
37
|
+
*
|
|
38
|
+
* @param points At least two points; fewer leaves the axes degenerate.
|
|
39
|
+
* @returns The centroid, the orthonormal axes and their variances.
|
|
40
|
+
*/
|
|
41
|
+
export declare function principalAxes<Point extends GlobalPoint | LocalPoint>(points: readonly Point[]): PrincipalAxes<Point>;
|
|
42
|
+
/**
|
|
43
|
+
* Express points in the frame of the given principal axes, making the point
|
|
44
|
+
* cloud rotation, scale and translation invariant.
|
|
45
|
+
*/
|
|
46
|
+
export declare function principalCoords<Point extends GlobalPoint | LocalPoint>(points: readonly Point[], axes: PrincipalAxes<Point>, scale?: number): PrincipalCoords[];
|
|
47
|
+
/**
|
|
48
|
+
* Flip the major axis so that it points toward the denser end of the point
|
|
49
|
+
* cloud, resolving the 180° sign ambiguity of the eigenvector.
|
|
50
|
+
*
|
|
51
|
+
* @returns The axes with `major`/`minor` flipped if needed. Variances are
|
|
52
|
+
* unchanged, as they are invariant to axis sign.
|
|
53
|
+
*/
|
|
54
|
+
export declare function orientPrincipalAxes<Point extends GlobalPoint | LocalPoint>(points: readonly Point[], axes: PrincipalAxes<Point>): PrincipalAxes<Point>;
|
|
55
|
+
/**
|
|
56
|
+
* Ratio of the minor to the major variance in [0, 1]
|
|
57
|
+
*
|
|
58
|
+
* @returns 0 is a perfectly straight stroke, 1 is a stroke with no preferred
|
|
59
|
+
* direction.
|
|
60
|
+
*/
|
|
61
|
+
export declare function elongation<Point extends GlobalPoint | LocalPoint>(axes: PrincipalAxes<Point>): number;
|
|
62
|
+
/**
|
|
63
|
+
* The `order`-th standardized moment of a sample in a rotation and scale
|
|
64
|
+
* invariant way (sandardizing by sigma).
|
|
65
|
+
*
|
|
66
|
+
* @returns 0 for a degenerate (zero variance) sample.
|
|
67
|
+
*/
|
|
68
|
+
export declare function standardizedMoment(values: readonly number[], order: number): number;
|
|
69
|
+
/**
|
|
70
|
+
* Third standardized moment: how lopsided a sample is.
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
export declare function skewness(values: readonly number[]): number;
|
|
74
|
+
/**
|
|
75
|
+
* Fourth standardized moment: how the mass is split between the tails and the
|
|
76
|
+
* middle of a sample. Not excess kurtosis, a normal sample gives 3.
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
export declare function kurtosis(values: readonly number[]): number;
|
|
@@ -3,4 +3,28 @@ export declare function polygon<Point extends GlobalPoint | LocalPoint>(...point
|
|
|
3
3
|
export declare function polygonFromPoints<Point extends GlobalPoint | LocalPoint>(points: Point[]): Polygon<Point>;
|
|
4
4
|
export declare const polygonIncludesPoint: <Point extends LocalPoint | GlobalPoint>(point: Point, polygon: Polygon<Point>) => boolean;
|
|
5
5
|
export declare const polygonIncludesPointNonZero: <Point extends [number, number]>(point: Point, polygon: Point[]) => boolean;
|
|
6
|
-
export declare
|
|
6
|
+
export declare function polygonIsClosed<Point extends LocalPoint | GlobalPoint>(polygon: readonly Point[], tolerance?: number): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The signed area of a polygon via the shoelace formula. Positive when the
|
|
9
|
+
* vertices wind counter-clockwise in a y-down coordinate system.
|
|
10
|
+
*
|
|
11
|
+
* The polygon may be given open or closed; a closing vertex is ignored.
|
|
12
|
+
*/
|
|
13
|
+
export declare function polygonSignedArea<Point extends LocalPoint | GlobalPoint>(polygon: readonly Point[]): number;
|
|
14
|
+
export declare function polygonArea<Point extends LocalPoint | GlobalPoint>(polygon: readonly Point[]): number;
|
|
15
|
+
/**
|
|
16
|
+
* The convex hull of a point set via Andrew's monotone chain.
|
|
17
|
+
*
|
|
18
|
+
* @returns The hull vertices in counter-clockwise order (y-down), without a
|
|
19
|
+
* repeated closing vertex.
|
|
20
|
+
*/
|
|
21
|
+
export declare function convexHull<Point extends LocalPoint | GlobalPoint>(points: readonly Point[]): Point[];
|
|
22
|
+
/**
|
|
23
|
+
* Drop the points of a convex polygon that only contribute a shallow turn,
|
|
24
|
+
* merging each run of near-collinear points into one.
|
|
25
|
+
*
|
|
26
|
+
* @param polygon A convex polygon, as returned by `convexHull`.
|
|
27
|
+
* @param angleThreshold Minimum accumulated turn (radians) for a vertex to be
|
|
28
|
+
* kept.
|
|
29
|
+
*/
|
|
30
|
+
export declare function simplifyConvexPolygon<Point extends LocalPoint | GlobalPoint>(polygon: readonly Point[], angleThreshold: number): Point[];
|