@zsviczian/excalidraw 0.18.0-6 → 0.18.0-60
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/excalidraw.development.js +757 -504
- package/dist/excalidraw.production.min.js +1 -1
- package/dist/excalidraw.production.min.js.LICENSE.txt +0 -2
- package/dist/styles.development.css +1080 -437
- package/dist/styles.production.css +26 -22
- package/package.json +15 -4
- package/types/common/src/commonObsidianUtils.d.ts +20 -0
- package/types/common/src/constants.d.ts +42 -18
- package/types/common/src/editorInterface.d.ts +35 -0
- package/types/{excalidraw → common/src}/emitter.d.ts +1 -1
- package/types/common/src/font-metadata.d.ts +4 -2
- package/types/common/src/index.d.ts +4 -0
- package/types/common/src/utility-types.d.ts +5 -0
- package/types/common/src/utils.d.ts +25 -6
- package/types/{excalidraw → common/src}/visualdebug.d.ts +2 -2
- package/types/{excalidraw/scene → element/src}/Scene.d.ts +16 -15
- package/types/element/src/align.d.ts +4 -3
- package/types/element/src/binding.d.ts +62 -41
- package/types/element/src/bounds.d.ts +14 -6
- package/types/element/src/collision.d.ts +23 -13
- package/types/element/src/cropElement.d.ts +1 -1
- package/types/{excalidraw/change.d.ts → element/src/delta.d.ts} +77 -40
- package/types/element/src/distance.d.ts +2 -2
- package/types/element/src/distribute.d.ts +2 -1
- package/types/element/src/dragElements.d.ts +3 -2
- package/types/element/src/duplicate.d.ts +10 -13
- package/types/element/src/elbowArrow.d.ts +1 -1
- package/types/element/src/flowchart.d.ts +3 -2
- package/types/element/src/fractionalIndex.d.ts +9 -3
- package/types/element/src/frame.d.ts +5 -4
- package/types/element/src/groups.d.ts +1 -0
- package/types/element/src/index.d.ts +44 -5
- package/types/element/src/linearElementEditor.d.ts +34 -50
- package/types/element/src/mutateElement.d.ts +11 -3
- package/types/element/src/newElement.d.ts +6 -4
- package/types/element/src/positionElementsOnGrid.d.ts +2 -0
- package/types/element/src/renderElement.d.ts +5 -2
- package/types/element/src/resizeElements.d.ts +6 -5
- package/types/element/src/resizeTest.d.ts +5 -4
- package/types/element/src/selection.d.ts +11 -5
- package/types/element/src/shape.d.ts +42 -0
- package/types/element/src/sizeHelpers.d.ts +2 -2
- package/types/element/src/store.d.ts +237 -0
- package/types/element/src/textElement.d.ts +4 -3
- package/types/element/src/transformHandles.d.ts +5 -4
- package/types/element/src/typeChecks.d.ts +20 -3
- package/types/element/src/types.d.ts +31 -12
- package/types/element/src/utils.d.ts +17 -6
- package/types/element/src/zindex.d.ts +8 -2
- package/types/excalidraw/actions/actionAddToLibrary.d.ts +88 -58
- package/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/types/excalidraw/actions/actionBoundText.d.ts +61 -41
- package/types/excalidraw/actions/actionCanvas.d.ts +430 -519
- package/types/excalidraw/actions/actionClipboard.d.ts +81 -944
- package/types/excalidraw/actions/actionCropEditor.d.ts +30 -20
- package/types/excalidraw/actions/actionDeleteSelected.d.ts +97 -68
- package/types/excalidraw/actions/actionDistribute.d.ts +2 -2
- package/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
- package/types/excalidraw/actions/actionElementLink.d.ts +28 -20
- package/types/excalidraw/actions/actionElementLock.d.ts +73 -54
- package/types/excalidraw/actions/actionEmbeddable.d.ts +30 -20
- package/types/excalidraw/actions/actionExport.d.ts +142 -1185
- package/types/excalidraw/actions/actionFinalize.d.ts +10 -424
- package/types/excalidraw/actions/actionFlip.d.ts +2 -2
- package/types/excalidraw/actions/actionFrame.d.ts +176 -129
- package/types/excalidraw/actions/actionGroup.d.ts +60 -40
- package/types/excalidraw/actions/actionHistory.d.ts +1 -2
- package/types/excalidraw/actions/actionLinearEditor.d.ts +564 -22
- package/types/excalidraw/actions/actionLink.d.ts +27 -17
- package/types/excalidraw/actions/actionMenu.d.ts +27 -457
- package/types/excalidraw/actions/actionNavigate.d.ts +21 -431
- package/types/excalidraw/actions/actionProperties.d.ts +169 -2702
- package/types/excalidraw/actions/actionSelectAll.d.ts +30 -20
- package/types/excalidraw/actions/actionStyles.d.ts +31 -21
- package/types/excalidraw/actions/actionTextAutoResize.d.ts +1 -1
- package/types/excalidraw/actions/actionToggleGridMode.d.ts +29 -19
- package/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +29 -19
- package/types/excalidraw/actions/actionToggleSearchMenu.d.ts +27 -224
- package/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
- package/types/excalidraw/actions/actionToggleStats.d.ts +29 -19
- package/types/excalidraw/actions/actionToggleViewMode.d.ts +30 -20
- package/types/excalidraw/actions/actionToggleZenMode.d.ts +30 -20
- package/types/excalidraw/actions/actionTrayMenu.d.ts +229 -0
- package/types/excalidraw/actions/actionZindex.d.ts +2 -2
- package/types/excalidraw/actions/index.d.ts +4 -2
- package/types/excalidraw/actions/manager.d.ts +1 -1
- package/types/excalidraw/actions/register.d.ts +1 -1
- package/types/excalidraw/actions/types.d.ts +7 -6
- package/types/excalidraw/appState.d.ts +22 -7
- package/types/excalidraw/clipboard.d.ts +68 -5
- package/types/excalidraw/components/Actions.d.ts +20 -7
- package/types/excalidraw/components/App.d.ts +68 -46
- package/types/excalidraw/components/ButtonIcon.d.ts +1 -0
- package/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
- package/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +5 -1
- package/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
- package/types/excalidraw/components/ColorPicker/Picker.d.ts +4 -3
- package/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +3 -3
- package/types/excalidraw/components/ColorPicker/ShadeList.d.ts +3 -2
- package/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
- package/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
- package/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
- package/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
- package/types/excalidraw/components/CommandPalette/types.d.ts +1 -2
- package/types/excalidraw/components/ConvertElementTypePopup.d.ts +23 -0
- package/types/excalidraw/components/ElementLinkDialog.d.ts +4 -3
- package/types/excalidraw/components/Ellipsify.d.ts +3 -0
- package/types/excalidraw/components/ExcalidrawLogo.d.ts +1 -1
- package/types/excalidraw/components/FilledButton.d.ts +1 -1
- package/types/excalidraw/components/FixedSideContainer.d.ts +2 -1
- package/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
- package/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -1
- package/types/excalidraw/components/HintViewer.d.ts +4 -3
- package/types/excalidraw/components/InlineIcon.d.ts +3 -1
- package/types/excalidraw/components/LayerUI.d.ts +2 -1
- package/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
- package/types/excalidraw/components/LinkButton.d.ts +4 -0
- package/types/excalidraw/components/MobileMenu.d.ts +4 -5
- package/types/excalidraw/components/MobileToolBar.d.ts +10 -0
- package/types/excalidraw/components/Popover.d.ts +2 -1
- package/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
- package/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
- package/types/excalidraw/components/Range.d.ts +3 -3
- package/types/excalidraw/components/Section.d.ts +1 -0
- package/types/excalidraw/components/Stats/Angle.d.ts +1 -1
- package/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
- package/types/excalidraw/components/Stats/CanvasGridSize.d.ts +1 -1
- package/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
- package/types/excalidraw/components/Stats/Dimension.d.ts +1 -1
- package/types/excalidraw/components/Stats/DragInput.d.ts +12 -2
- package/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
- package/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -1
- package/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
- package/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
- package/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
- package/types/excalidraw/components/Stats/Position.d.ts +1 -1
- package/types/excalidraw/components/Stats/utils.d.ts +4 -11
- package/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -2
- package/types/excalidraw/components/TextField.d.ts +1 -0
- package/types/excalidraw/components/ToolPopover.d.ts +25 -0
- package/types/excalidraw/components/TrayMenu.d.ts +26 -0
- package/types/excalidraw/components/UnlockPopup.d.ts +8 -0
- package/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +7 -3
- package/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +4 -2
- package/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +2 -1
- package/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
- package/types/excalidraw/components/hyperlink/helpers.d.ts +2 -1
- package/types/excalidraw/components/icons.d.ts +17 -0
- package/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +14 -1
- package/types/excalidraw/components/main-menu/MainMenu.d.ts +0 -3
- package/types/excalidraw/components/shapes.d.ts +115 -5
- package/types/excalidraw/data/blob.d.ts +3 -7
- package/types/excalidraw/data/reconcile.d.ts +1 -0
- package/types/excalidraw/data/restore.d.ts +7 -2
- package/types/excalidraw/data/transform.d.ts +1 -1
- package/types/excalidraw/data/types.d.ts +4 -1
- package/types/excalidraw/editor-jotai.d.ts +6 -6
- package/types/excalidraw/eraser/index.d.ts +0 -2
- package/types/excalidraw/fonts/Fonts.d.ts +1 -1
- package/types/excalidraw/history.d.ts +30 -22
- package/types/excalidraw/hooks/useEmitter.d.ts +1 -1
- package/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/types/excalidraw/hooks/useOutsideClick.d.ts +3 -1
- package/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
- package/types/excalidraw/index.d.ts +16 -15
- package/types/excalidraw/lasso/index.d.ts +1 -0
- package/types/excalidraw/lasso/utils.d.ts +2 -1
- package/types/excalidraw/obsidianUtils.d.ts +22 -9
- package/types/excalidraw/renderer/animation.d.ts +12 -0
- package/types/excalidraw/renderer/helpers.d.ts +3 -2
- package/types/excalidraw/renderer/interactiveScene.d.ts +5 -13
- package/types/excalidraw/renderer/staticScene.d.ts +4 -1
- package/types/excalidraw/scene/Renderer.d.ts +1 -2
- package/types/excalidraw/scene/index.d.ts +2 -2
- package/types/excalidraw/scene/scrollbars.d.ts +2 -3
- package/types/excalidraw/scene/types.d.ts +17 -3
- package/types/excalidraw/shortcut.d.ts +1 -0
- package/types/excalidraw/snapping.d.ts +2 -2
- package/types/excalidraw/types.d.ts +83 -33
- package/types/excalidraw/webpack.dev.config.d.ts +2 -0
- package/types/excalidraw/webpack.prod.config.d.ts +2 -0
- package/types/excalidraw/wysiwyg/textWysiwyg.d.ts +3 -1
- package/types/math/src/angle.d.ts +2 -0
- package/types/math/src/constants.d.ts +3 -0
- package/types/math/src/curve.d.ts +34 -0
- package/types/math/src/index.d.ts +1 -0
- package/types/math/src/point.d.ts +1 -1
- package/types/math/src/rectangle.d.ts +2 -0
- package/types/math/src/segment.d.ts +1 -0
- package/types/math/src/vector.d.ts +8 -2
- package/types/utils/src/bbox.d.ts +1 -1
- package/types/utils/src/index.d.ts +1 -1
- package/types/utils/src/withinBounds.d.ts +1 -1
- package/types/element/src/Shape.d.ts +0 -17
- package/types/element/src/ShapeCache.d.ts +0 -25
- package/types/element/src/shapes.d.ts +0 -23
- package/types/excalidraw/components/ButtonSelect.d.ts +0 -9
- package/types/excalidraw/store.d.ts +0 -129
- package/types/utils/src/collision.d.ts +0 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { UserIdleState } from "@excalidraw/common";
|
|
1
|
+
import type { UserIdleState, EditorInterface } from "@excalidraw/common";
|
|
2
2
|
import type { ExcalidrawElement, NonDeletedElementsMap, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap } from "@excalidraw/element/types";
|
|
3
3
|
import type { MakeBrand } from "@excalidraw/common/utility-types";
|
|
4
|
-
import type { AppClassProperties, AppState, EmbedsValidationStatus, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState, SocketId,
|
|
4
|
+
import type { AppClassProperties, AppState, EmbedsValidationStatus, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState, SocketId, PendingExcalidrawElements } from "../types";
|
|
5
5
|
import type { RoughCanvas } from "roughjs/bin/canvas";
|
|
6
6
|
import type { Drawable } from "roughjs/bin/core";
|
|
7
7
|
export type RenderableElementsMap = NonDeletedElementsMap & MakeBrand<"RenderableElementsMap">;
|
|
@@ -45,6 +45,10 @@ export type InteractiveCanvasRenderConfig = {
|
|
|
45
45
|
remotePointerUsernames: Map<SocketId, string>;
|
|
46
46
|
remotePointerButton: Map<SocketId, string | undefined>;
|
|
47
47
|
selectionColor: string;
|
|
48
|
+
lastViewportPosition: {
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
};
|
|
48
52
|
renderScrollbars?: boolean;
|
|
49
53
|
};
|
|
50
54
|
export type RenderInteractiveSceneCallback = {
|
|
@@ -62,7 +66,13 @@ export type StaticSceneRenderConfig = {
|
|
|
62
66
|
appState: StaticCanvasAppState;
|
|
63
67
|
renderConfig: StaticCanvasRenderConfig;
|
|
64
68
|
};
|
|
69
|
+
export type InteractiveSceneRenderAnimationState = {
|
|
70
|
+
bindingHighlight: {
|
|
71
|
+
runtime: number;
|
|
72
|
+
} | undefined;
|
|
73
|
+
};
|
|
65
74
|
export type InteractiveSceneRenderConfig = {
|
|
75
|
+
app: AppClassProperties;
|
|
66
76
|
canvas: HTMLCanvasElement | null;
|
|
67
77
|
elementsMap: RenderableElementsMap;
|
|
68
78
|
visibleElements: readonly NonDeletedExcalidrawElement[];
|
|
@@ -71,8 +81,10 @@ export type InteractiveSceneRenderConfig = {
|
|
|
71
81
|
scale: number;
|
|
72
82
|
appState: InteractiveCanvasAppState;
|
|
73
83
|
renderConfig: InteractiveCanvasRenderConfig;
|
|
74
|
-
|
|
84
|
+
editorInterface: EditorInterface;
|
|
75
85
|
callback: (data: RenderInteractiveSceneCallback) => void;
|
|
86
|
+
animationState?: InteractiveSceneRenderAnimationState;
|
|
87
|
+
deltaTime: number;
|
|
76
88
|
};
|
|
77
89
|
export type NewElementSceneRenderConfig = {
|
|
78
90
|
canvas: HTMLCanvasElement | null;
|
|
@@ -95,12 +107,14 @@ export type ScrollBars = {
|
|
|
95
107
|
y: number;
|
|
96
108
|
width: number;
|
|
97
109
|
height: number;
|
|
110
|
+
deltaMultiplier: number;
|
|
98
111
|
} | null;
|
|
99
112
|
vertical: {
|
|
100
113
|
x: number;
|
|
101
114
|
y: number;
|
|
102
115
|
width: number;
|
|
103
116
|
height: number;
|
|
117
|
+
deltaMultiplier: number;
|
|
104
118
|
} | null;
|
|
105
119
|
};
|
|
106
120
|
export type ElementShape = Drawable | Drawable[] | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getShortcutKey: (shortcut: string) => string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type GlobalPoint } from "@excalidraw/math";
|
|
2
2
|
import type { InclusiveRange } from "@excalidraw/math";
|
|
3
|
-
import type { Bounds } from "@excalidraw/element
|
|
4
|
-
import type { MaybeTransformHandleType } from "@excalidraw/element
|
|
3
|
+
import type { Bounds } from "@excalidraw/element";
|
|
4
|
+
import type { MaybeTransformHandleType } from "@excalidraw/element";
|
|
5
5
|
import type { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
6
6
|
import type { AppClassProperties, AppState, KeyboardModifiersObject } from "./types";
|
|
7
7
|
export declare const getSnapDistance: (zoomValue: number) => number;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, ColorPaletteCustom } from "@excalidraw/common";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement } from "@excalidraw/element/types";
|
|
1
|
+
import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, ColorPaletteCustom, EditorInterface } from "@excalidraw/common";
|
|
2
|
+
import type { LinearElementEditor } from "@excalidraw/element";
|
|
3
|
+
import type { MaybeTransformHandleType } from "@excalidraw/element";
|
|
4
|
+
import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode } from "@excalidraw/element/types";
|
|
6
5
|
import type { Merge, MaybePromise, ValueOf, MakeBrand } from "@excalidraw/common/utility-types";
|
|
6
|
+
import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
|
|
7
7
|
import type { Action } from "./actions/types";
|
|
8
8
|
import type { Spreadsheet } from "./charts";
|
|
9
9
|
import type { ClipboardData } from "./clipboard";
|
|
@@ -12,7 +12,6 @@ import type Library from "./data/library";
|
|
|
12
12
|
import type { FileSystemHandle } from "./data/filesystem";
|
|
13
13
|
import type { ContextMenuItems } from "./components/ContextMenu";
|
|
14
14
|
import type { SnapLine } from "./snapping";
|
|
15
|
-
import type { CaptureUpdateActionType } from "./store";
|
|
16
15
|
import type { ImportedDataState } from "./data/types";
|
|
17
16
|
import type { Language } from "./i18n";
|
|
18
17
|
import type { isOverScrollBars } from "./scene/scrollbars";
|
|
@@ -113,7 +112,6 @@ type _CommonCanvasAppState = {
|
|
|
113
112
|
offsetLeft: AppState["offsetLeft"];
|
|
114
113
|
offsetTop: AppState["offsetTop"];
|
|
115
114
|
theme: AppState["theme"];
|
|
116
|
-
pendingImageElementId: AppState["pendingImageElementId"];
|
|
117
115
|
};
|
|
118
116
|
export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
119
117
|
shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
|
|
@@ -126,31 +124,41 @@ export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
126
124
|
frameRendering: AppState["frameRendering"];
|
|
127
125
|
linkOpacity: AppState["linkOpacity"];
|
|
128
126
|
gridColor: AppState["gridColor"];
|
|
127
|
+
gridDirection: AppState["gridDirection"];
|
|
129
128
|
frameColor: AppState["frameColor"];
|
|
130
129
|
currentHoveredFontFamily: AppState["currentHoveredFontFamily"];
|
|
131
130
|
hoveredElementIds: AppState["hoveredElementIds"];
|
|
131
|
+
suggestedBinding: AppState["suggestedBinding"];
|
|
132
132
|
croppingElementId: AppState["croppingElementId"];
|
|
133
133
|
}>;
|
|
134
134
|
export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
135
135
|
activeEmbeddable: AppState["activeEmbeddable"];
|
|
136
|
-
editingLinearElement: AppState["editingLinearElement"];
|
|
137
136
|
selectionElement: AppState["selectionElement"];
|
|
138
137
|
selectedGroupIds: AppState["selectedGroupIds"];
|
|
139
138
|
selectedLinearElement: AppState["selectedLinearElement"];
|
|
140
139
|
multiElement: AppState["multiElement"];
|
|
140
|
+
newElement: AppState["newElement"];
|
|
141
141
|
isBindingEnabled: AppState["isBindingEnabled"];
|
|
142
|
-
|
|
142
|
+
suggestedBinding: AppState["suggestedBinding"];
|
|
143
143
|
isRotating: AppState["isRotating"];
|
|
144
144
|
elementsToHighlight: AppState["elementsToHighlight"];
|
|
145
145
|
collaborators: AppState["collaborators"];
|
|
146
146
|
snapLines: AppState["snapLines"];
|
|
147
147
|
zenModeEnabled: AppState["zenModeEnabled"];
|
|
148
148
|
editingTextElement: AppState["editingTextElement"];
|
|
149
|
+
viewBackgroundColor: AppState["viewBackgroundColor"];
|
|
149
150
|
gridColor: AppState["gridColor"];
|
|
151
|
+
gridDirection: AppState["gridDirection"];
|
|
150
152
|
highlightSearchResult: AppState["highlightSearchResult"];
|
|
151
153
|
isCropping: AppState["isCropping"];
|
|
152
154
|
croppingElementId: AppState["croppingElementId"];
|
|
153
155
|
searchMatches: AppState["searchMatches"];
|
|
156
|
+
activeLockedId: AppState["activeLockedId"];
|
|
157
|
+
hoveredElementIds: AppState["hoveredElementIds"];
|
|
158
|
+
frameRendering: AppState["frameRendering"];
|
|
159
|
+
frameColor: AppState["frameColor"];
|
|
160
|
+
shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
|
|
161
|
+
exportScale: AppState["exportScale"];
|
|
154
162
|
}>;
|
|
155
163
|
export type ObservedAppState = ObservedStandaloneAppState & ObservedElementsAppState;
|
|
156
164
|
export type ObservedStandaloneAppState = {
|
|
@@ -161,9 +169,13 @@ export type ObservedElementsAppState = {
|
|
|
161
169
|
editingGroupId: AppState["editingGroupId"];
|
|
162
170
|
selectedElementIds: AppState["selectedElementIds"];
|
|
163
171
|
selectedGroupIds: AppState["selectedGroupIds"];
|
|
164
|
-
|
|
165
|
-
|
|
172
|
+
selectedLinearElement: {
|
|
173
|
+
elementId: LinearElementEditor["elementId"];
|
|
174
|
+
isEditing: boolean;
|
|
175
|
+
} | null;
|
|
166
176
|
croppingElementId: AppState["croppingElementId"];
|
|
177
|
+
lockedMultiSelections: AppState["lockedMultiSelections"];
|
|
178
|
+
activeLockedId: AppState["activeLockedId"];
|
|
167
179
|
};
|
|
168
180
|
export interface AppState {
|
|
169
181
|
contextMenu: {
|
|
@@ -200,13 +212,15 @@ export interface AppState {
|
|
|
200
212
|
selectionElement: NonDeletedExcalidrawElement | null;
|
|
201
213
|
isBindingEnabled: boolean;
|
|
202
214
|
startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
|
|
203
|
-
|
|
215
|
+
suggestedBinding: NonDeleted<ExcalidrawBindableElement> | null;
|
|
204
216
|
frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
205
217
|
frameRendering: {
|
|
206
218
|
enabled: boolean;
|
|
207
219
|
name: boolean;
|
|
208
220
|
outline: boolean;
|
|
209
221
|
clip: boolean;
|
|
222
|
+
markerName: boolean;
|
|
223
|
+
markerEnabled: boolean;
|
|
210
224
|
};
|
|
211
225
|
editingFrame: string | null;
|
|
212
226
|
elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
|
|
@@ -214,7 +228,6 @@ export interface AppState {
|
|
|
214
228
|
* set when a new text is created or when an existing text is being edited
|
|
215
229
|
*/
|
|
216
230
|
editingTextElement: NonDeletedExcalidrawElement | null;
|
|
217
|
-
editingLinearElement: LinearElementEditor | null;
|
|
218
231
|
activeTool: {
|
|
219
232
|
/**
|
|
220
233
|
* indicates a previous tool we should revert back to if we deselect the
|
|
@@ -224,6 +237,10 @@ export interface AppState {
|
|
|
224
237
|
locked: boolean;
|
|
225
238
|
fromSelection: boolean;
|
|
226
239
|
} & ActiveTool;
|
|
240
|
+
preferredSelectionTool: {
|
|
241
|
+
type: "selection" | "lasso";
|
|
242
|
+
initialized: boolean;
|
|
243
|
+
};
|
|
227
244
|
penMode: boolean;
|
|
228
245
|
penDetected: boolean;
|
|
229
246
|
exportBackground: boolean;
|
|
@@ -245,6 +262,7 @@ export interface AppState {
|
|
|
245
262
|
currentHoveredFontFamily: FontFamilyValues | null;
|
|
246
263
|
currentItemRoundness: StrokeRoundness;
|
|
247
264
|
currentItemArrowType: "sharp" | "round" | "elbow";
|
|
265
|
+
currentItemFrameRole: ExcalidrawFrameLikeElement["frameRole"] | null;
|
|
248
266
|
viewBackgroundColor: string;
|
|
249
267
|
scrollX: number;
|
|
250
268
|
scrollY: number;
|
|
@@ -255,7 +273,7 @@ export interface AppState {
|
|
|
255
273
|
isRotating: boolean;
|
|
256
274
|
zoom: Zoom;
|
|
257
275
|
openMenu: "canvas" | "shape" | null;
|
|
258
|
-
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | null;
|
|
276
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
|
|
259
277
|
openSidebar: {
|
|
260
278
|
name: SidebarName;
|
|
261
279
|
tab?: SidebarTabName;
|
|
@@ -267,6 +285,8 @@ export interface AppState {
|
|
|
267
285
|
tab: "text-to-diagram" | "mermaid";
|
|
268
286
|
} | {
|
|
269
287
|
name: "commandPalette";
|
|
288
|
+
} | {
|
|
289
|
+
name: "settings";
|
|
270
290
|
} | {
|
|
271
291
|
name: "elementLinkSelector";
|
|
272
292
|
sourceElementId: ExcalidrawElement["id"];
|
|
@@ -329,11 +349,8 @@ export interface AppState {
|
|
|
329
349
|
shown: true;
|
|
330
350
|
data: Spreadsheet;
|
|
331
351
|
};
|
|
332
|
-
/** imageElement waiting to be placed on canvas */
|
|
333
|
-
pendingImageElementId: ExcalidrawImageElement["id"] | null;
|
|
334
352
|
showHyperlinkPopup: false | "info" | "editor";
|
|
335
353
|
linkOpacity: number;
|
|
336
|
-
trayModeEnabled: boolean;
|
|
337
354
|
colorPalette?: {
|
|
338
355
|
canvasBackground: ColorPaletteCustom;
|
|
339
356
|
elementBackground: ColorPaletteCustom;
|
|
@@ -346,6 +363,7 @@ export interface AppState {
|
|
|
346
363
|
};
|
|
347
364
|
allowWheelZoom?: boolean;
|
|
348
365
|
allowPinchZoom?: boolean;
|
|
366
|
+
disableContextMenu: boolean;
|
|
349
367
|
pinnedScripts?: string[];
|
|
350
368
|
customPens?: any[];
|
|
351
369
|
currentStrokeOptions?: any;
|
|
@@ -354,6 +372,10 @@ export interface AppState {
|
|
|
354
372
|
Bold: string;
|
|
355
373
|
Regular: string;
|
|
356
374
|
};
|
|
375
|
+
gridDirection: {
|
|
376
|
+
horizontal: boolean;
|
|
377
|
+
vertical: boolean;
|
|
378
|
+
};
|
|
357
379
|
highlightSearchResult: boolean;
|
|
358
380
|
dynamicStyle: {
|
|
359
381
|
[x: string]: string;
|
|
@@ -378,9 +400,19 @@ export interface AppState {
|
|
|
378
400
|
/** image cropping */
|
|
379
401
|
isCropping: boolean;
|
|
380
402
|
croppingElementId: ExcalidrawElement["id"] | null;
|
|
381
|
-
|
|
403
|
+
/** null if no search matches found / search closed */
|
|
404
|
+
searchMatches: Readonly<{
|
|
405
|
+
focusedId: ExcalidrawElement["id"] | null;
|
|
406
|
+
matches: readonly SearchMatch[];
|
|
407
|
+
}> | null;
|
|
408
|
+
/** the locked element/group that's active and shows unlock popup */
|
|
409
|
+
activeLockedId: string | null;
|
|
410
|
+
lockedMultiSelections: {
|
|
411
|
+
[groupId: string]: true;
|
|
412
|
+
};
|
|
413
|
+
bindMode: BindMode;
|
|
382
414
|
}
|
|
383
|
-
type SearchMatch = {
|
|
415
|
+
export type SearchMatch = {
|
|
384
416
|
id: string;
|
|
385
417
|
focus: boolean;
|
|
386
418
|
matchedLines: {
|
|
@@ -388,9 +420,10 @@ type SearchMatch = {
|
|
|
388
420
|
offsetY: number;
|
|
389
421
|
width: number;
|
|
390
422
|
height: number;
|
|
423
|
+
showOnCanvas: boolean;
|
|
391
424
|
}[];
|
|
392
425
|
};
|
|
393
|
-
export type UIAppState = Omit<AppState, "
|
|
426
|
+
export type UIAppState = Omit<AppState, "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
|
|
394
427
|
export type NormalizedZoomValue = number & {
|
|
395
428
|
_brand: "normalizedZoom";
|
|
396
429
|
};
|
|
@@ -440,6 +473,7 @@ export type OnUserFollowedPayload = {
|
|
|
440
473
|
};
|
|
441
474
|
export interface ExcalidrawProps {
|
|
442
475
|
onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
|
|
476
|
+
onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
|
|
443
477
|
initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
|
|
444
478
|
excalidrawAPI?: (api: ExcalidrawImperativeAPI) => void;
|
|
445
479
|
isCollaborating?: boolean;
|
|
@@ -468,6 +502,7 @@ export interface ExcalidrawProps {
|
|
|
468
502
|
onDuplicate?: (nextElements: readonly ExcalidrawElement[],
|
|
469
503
|
/** excludes the duplicated elements */
|
|
470
504
|
prevElements: readonly ExcalidrawElement[]) => ExcalidrawElement[] | void;
|
|
505
|
+
renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
471
506
|
renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
472
507
|
langCode?: Language["code"];
|
|
473
508
|
viewModeEnabled?: boolean;
|
|
@@ -512,6 +547,7 @@ export interface ExcalidrawProps {
|
|
|
512
547
|
aiEnabled?: boolean;
|
|
513
548
|
showDeprecatedFonts?: boolean;
|
|
514
549
|
insertLinkAction?: (linkVal: string) => void;
|
|
550
|
+
renderScrollbars?: boolean;
|
|
515
551
|
}
|
|
516
552
|
export type SceneData = {
|
|
517
553
|
elements?: ImportedDataState["elements"];
|
|
@@ -539,6 +575,12 @@ export type UIOptions = Partial<{
|
|
|
539
575
|
tools: {
|
|
540
576
|
image: boolean;
|
|
541
577
|
};
|
|
578
|
+
/**
|
|
579
|
+
* Optionally control the editor form factor and desktop UI mode from the host app.
|
|
580
|
+
* If not provided, we will take care of it internally.
|
|
581
|
+
*/
|
|
582
|
+
formFactor?: EditorInterface["formFactor"];
|
|
583
|
+
desktopUIMode?: EditorInterface["desktopUIMode"];
|
|
542
584
|
/** @deprecated does nothing. Will be removed in 0.15 */
|
|
543
585
|
welcomeScreen?: boolean;
|
|
544
586
|
}>;
|
|
@@ -569,7 +611,7 @@ export type AppClassProperties = {
|
|
|
569
611
|
mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
|
|
570
612
|
}>;
|
|
571
613
|
files: BinaryFiles;
|
|
572
|
-
|
|
614
|
+
editorInterface: App["editorInterface"];
|
|
573
615
|
scene: App["scene"];
|
|
574
616
|
syncActionResult: App["syncActionResult"];
|
|
575
617
|
fonts: App["fonts"];
|
|
@@ -598,6 +640,9 @@ export type AppClassProperties = {
|
|
|
598
640
|
visibleElements: App["visibleElements"];
|
|
599
641
|
excalidrawContainerValue: App["excalidrawContainerValue"];
|
|
600
642
|
onPointerUpEmitter: App["onPointerUpEmitter"];
|
|
643
|
+
updateEditorAtom: App["updateEditorAtom"];
|
|
644
|
+
onPointerDownEmitter: App["onPointerDownEmitter"];
|
|
645
|
+
bindModeHandler: App["bindModeHandler"];
|
|
601
646
|
};
|
|
602
647
|
export type PointerDownState = Readonly<{
|
|
603
648
|
origin: Readonly<{
|
|
@@ -641,6 +686,11 @@ export type PointerDownState = Readonly<{
|
|
|
641
686
|
x: number;
|
|
642
687
|
y: number;
|
|
643
688
|
} | null;
|
|
689
|
+
origin: {
|
|
690
|
+
x: number;
|
|
691
|
+
y: number;
|
|
692
|
+
};
|
|
693
|
+
blockDragging: boolean;
|
|
644
694
|
};
|
|
645
695
|
eventListeners: {
|
|
646
696
|
onMove: null | ReturnType<typeof throttleRAF>;
|
|
@@ -655,13 +705,23 @@ export type PointerDownState = Readonly<{
|
|
|
655
705
|
export type UnsubscribeCallback = () => void;
|
|
656
706
|
export interface ExcalidrawImperativeAPI {
|
|
657
707
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
708
|
+
applyDeltas: InstanceType<typeof App>["applyDeltas"];
|
|
709
|
+
mutateElement: InstanceType<typeof App>["mutateElement"];
|
|
658
710
|
updateLibrary: InstanceType<typeof Library>["updateLibrary"];
|
|
659
711
|
resetScene: InstanceType<typeof App>["resetScene"];
|
|
660
712
|
getSceneElementsIncludingDeleted: InstanceType<typeof App>["getSceneElementsIncludingDeleted"];
|
|
713
|
+
getSceneElementsMapIncludingDeleted: InstanceType<typeof App>["getSceneElementsMapIncludingDeleted"];
|
|
661
714
|
history: {
|
|
662
715
|
clear: InstanceType<typeof App>["resetHistory"];
|
|
663
716
|
};
|
|
717
|
+
setForceRenderAllEmbeddables: InstanceType<typeof App>["setForceRenderAllEmbeddables"];
|
|
664
718
|
zoomToFit: InstanceType<typeof App>["zoomToFit"];
|
|
719
|
+
refreshEditorInterface: InstanceType<typeof App>["refreshEditorInterface"];
|
|
720
|
+
isTouchScreen: InstanceType<typeof App>["isTouchScreen"];
|
|
721
|
+
setTrayModeEnabled: InstanceType<typeof App>["setTrayModeEnabled"];
|
|
722
|
+
setDesktopUIMode: InstanceType<typeof App>["setDesktopUIMode"];
|
|
723
|
+
setMobileModeAllowed: InstanceType<typeof App>["setMobileModeAllowed"];
|
|
724
|
+
isTrayModeEnabled: InstanceType<typeof App>["isTrayModeEnabled"];
|
|
665
725
|
getColorAtScenePoint: InstanceType<typeof App>["getColorAtScenePoint"];
|
|
666
726
|
startLineEditor: InstanceType<typeof App>["startLineEditor"];
|
|
667
727
|
getSceneElements: InstanceType<typeof App>["getSceneElements"];
|
|
@@ -680,12 +740,12 @@ export interface ExcalidrawImperativeAPI {
|
|
|
680
740
|
bringForward: (elements: readonly ExcalidrawElement[]) => void;
|
|
681
741
|
sendToBack: (elements: readonly ExcalidrawElement[]) => void;
|
|
682
742
|
bringToFront: (elements: readonly ExcalidrawElement[]) => void;
|
|
683
|
-
setMobileModeAllowed: (allow: boolean) => void;
|
|
684
743
|
setActiveTool: InstanceType<typeof App>["setActiveTool"];
|
|
685
744
|
setCursor: InstanceType<typeof App>["setCursor"];
|
|
686
745
|
resetCursor: InstanceType<typeof App>["resetCursor"];
|
|
687
746
|
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
|
688
747
|
getHTMLIFrameElement: InstanceType<typeof App>["getHTMLIFrameElement"];
|
|
748
|
+
getEditorInterface: () => EditorInterface;
|
|
689
749
|
/**
|
|
690
750
|
* Disables rendering of frames (including element clipping), but currently
|
|
691
751
|
* the frames are still interactive in edit mode. As such, this API should be
|
|
@@ -693,22 +753,12 @@ export interface ExcalidrawImperativeAPI {
|
|
|
693
753
|
*/
|
|
694
754
|
updateFrameRendering: InstanceType<typeof App>["updateFrameRendering"];
|
|
695
755
|
onChange: (callback: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void) => UnsubscribeCallback;
|
|
756
|
+
onIncrement: (callback: (event: DurableIncrement | EphemeralIncrement) => void) => UnsubscribeCallback;
|
|
696
757
|
onPointerDown: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: React.PointerEvent<HTMLElement>) => void) => UnsubscribeCallback;
|
|
697
758
|
onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
|
|
698
759
|
onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
|
|
699
760
|
onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
|
|
700
761
|
}
|
|
701
|
-
export type Device = Readonly<{
|
|
702
|
-
viewport: {
|
|
703
|
-
isMobile: boolean;
|
|
704
|
-
isLandscape: boolean;
|
|
705
|
-
};
|
|
706
|
-
editor: {
|
|
707
|
-
isMobile: boolean;
|
|
708
|
-
canFitSidebar: boolean;
|
|
709
|
-
};
|
|
710
|
-
isTouchScreen: boolean;
|
|
711
|
-
}>;
|
|
712
762
|
export type FrameNameBounds = {
|
|
713
763
|
x: number;
|
|
714
764
|
y: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExcalidrawElement, ExcalidrawTextElement } from "@excalidraw/element/types";
|
|
2
2
|
import type App from "../components/App";
|
|
3
|
+
type SubmitHandler = () => void;
|
|
3
4
|
export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, }: {
|
|
4
5
|
id: ExcalidrawElement["id"];
|
|
5
6
|
/**
|
|
@@ -19,4 +20,5 @@ export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords,
|
|
|
19
20
|
excalidrawContainer: HTMLDivElement | null;
|
|
20
21
|
app: App;
|
|
21
22
|
autoSelect?: boolean | undefined;
|
|
22
|
-
}) =>
|
|
23
|
+
}) => SubmitHandler;
|
|
24
|
+
export {};
|
|
@@ -15,3 +15,5 @@ export declare function radiansToDegrees(degrees: Radians): Degrees;
|
|
|
15
15
|
* @returns TRUE if the provided angle is a right angle
|
|
16
16
|
*/
|
|
17
17
|
export declare function isRightAngleRads(rads: Radians): boolean;
|
|
18
|
+
export declare function radiansBetweenAngles(a: Radians, min: Radians, max: Radians): boolean;
|
|
19
|
+
export declare function radiansDifference(a: Radians, b: Radians): Radians;
|
|
@@ -8,6 +8,7 @@ import type { Curve, GlobalPoint, LineSegment, LocalPoint } from "./types";
|
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
10
|
export declare function curve<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point, c: Point, d: Point): Curve<Point>;
|
|
11
|
+
export declare const bezierEquation: <Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, t: number) => Point;
|
|
11
12
|
/**
|
|
12
13
|
* Computes the intersection between a cubic spline and a line segment.
|
|
13
14
|
*/
|
|
@@ -38,3 +39,36 @@ export declare function curvePointDistance<Point extends GlobalPoint | LocalPoin
|
|
|
38
39
|
* Determines if the parameter is a Curve
|
|
39
40
|
*/
|
|
40
41
|
export declare function isCurve<P extends GlobalPoint | LocalPoint>(v: unknown): v is Curve<P>;
|
|
42
|
+
export declare function curveTangent<Point extends GlobalPoint | LocalPoint>([p0, p1, p2, p3]: Curve<Point>, t: number): import("./types").Vector;
|
|
43
|
+
export declare function curveCatmullRomQuadraticApproxPoints(points: GlobalPoint[], tension?: number): [GlobalPoint, GlobalPoint][] | undefined;
|
|
44
|
+
export declare function curveCatmullRomCubicApproxPoints<Point extends GlobalPoint | LocalPoint>(points: Point[], tension?: number): Curve<Point>[] | undefined;
|
|
45
|
+
export declare function curveOffsetPoints([p0, p1, p2, p3]: Curve<GlobalPoint>, offset: number, steps?: number): GlobalPoint[];
|
|
46
|
+
export declare function offsetPointsForQuadraticBezier(p0: GlobalPoint, p1: GlobalPoint, p2: GlobalPoint, offsetDist: number, steps?: number): GlobalPoint[];
|
|
47
|
+
/**
|
|
48
|
+
* Implementation based on Legendre-Gauss quadrature for more accurate arc
|
|
49
|
+
* length calculation.
|
|
50
|
+
*
|
|
51
|
+
* Reference: https://pomax.github.io/bezierinfo/#arclength
|
|
52
|
+
*
|
|
53
|
+
* @param c The curve to calculate the length of
|
|
54
|
+
* @returns The approximated length of the curve
|
|
55
|
+
*/
|
|
56
|
+
export declare function curveLength<P extends GlobalPoint | LocalPoint>(c: Curve<P>): number;
|
|
57
|
+
/**
|
|
58
|
+
* Calculates the curve length from t=0 to t=parameter using the same
|
|
59
|
+
* Legendre-Gauss quadrature method used in curveLength
|
|
60
|
+
*
|
|
61
|
+
* @param c The curve to calculate the partial length for
|
|
62
|
+
* @param t The parameter value (0 to 1) to calculate length up to
|
|
63
|
+
* @returns The length of the curve from beginning to parameter t
|
|
64
|
+
*/
|
|
65
|
+
export declare function curveLengthAtParameter<P extends GlobalPoint | LocalPoint>(c: Curve<P>, t: number): number;
|
|
66
|
+
/**
|
|
67
|
+
* Calculates the point at a specific percentage of a curve's total length
|
|
68
|
+
* using binary search for improved efficiency and accuracy.
|
|
69
|
+
*
|
|
70
|
+
* @param c The curve to calculate point on
|
|
71
|
+
* @param percent A value between 0 and 1 representing the percentage of the curve's length
|
|
72
|
+
* @returns The point at the specified percentage of curve length
|
|
73
|
+
*/
|
|
74
|
+
export declare function curvePointAtLength<P extends GlobalPoint | LocalPoint>(c: Curve<P>, percent: number): P;
|
|
@@ -43,7 +43,7 @@ export declare function isPoint(p: unknown): p is LocalPoint | GlobalPoint;
|
|
|
43
43
|
* @param b Point The second point to compare
|
|
44
44
|
* @returns TRUE if the points are sufficiently close to each other
|
|
45
45
|
*/
|
|
46
|
-
export declare function pointsEqual<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point): boolean;
|
|
46
|
+
export declare function pointsEqual<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point, tolerance?: number): boolean;
|
|
47
47
|
/**
|
|
48
48
|
* Rotate a point by [angle] radians.
|
|
49
49
|
*
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { GlobalPoint, LineSegment, LocalPoint, Rectangle } from "./types";
|
|
2
2
|
export declare function rectangle<P extends GlobalPoint | LocalPoint>(topLeft: P, bottomRight: P): Rectangle<P>;
|
|
3
|
+
export declare function rectangleFromNumberSequence<Point extends LocalPoint | GlobalPoint>(minX: number, minY: number, maxX: number, maxY: number): Rectangle<Point>;
|
|
3
4
|
export declare function rectangleIntersectLineSegment<Point extends LocalPoint | GlobalPoint>(r: Rectangle<Point>, l: LineSegment<Point>): Point[];
|
|
5
|
+
export declare function rectangleIntersectRectangle<Point extends LocalPoint | GlobalPoint>(rectangle1: Rectangle<Point>, rectangle2: Rectangle<Point>): boolean;
|
|
@@ -37,3 +37,4 @@ export declare const distanceToLineSegment: <Point extends GlobalPoint | LocalPo
|
|
|
37
37
|
* @returns
|
|
38
38
|
*/
|
|
39
39
|
export declare function lineSegmentIntersectionPoints<Point extends GlobalPoint | LocalPoint>(l: LineSegment<Point>, s: LineSegment<Point>, threshold?: number): Point | null;
|
|
40
|
+
export declare function lineSegmentsDistance<Point extends GlobalPoint | LocalPoint>(s1: LineSegment<Point>, s2: LineSegment<Point>): number;
|
|
@@ -12,9 +12,11 @@ export declare function vector(x: number, y: number, originX?: number, originY?:
|
|
|
12
12
|
*
|
|
13
13
|
* @param p The point to turn into a vector
|
|
14
14
|
* @param origin The origin point in a given coordiante system
|
|
15
|
-
* @
|
|
15
|
+
* @param threshold The threshold to consider the vector as 'undefined'
|
|
16
|
+
* @param defaultValue The default value to return if the vector is 'undefined'
|
|
17
|
+
* @returns The created vector from the point and the origin or default
|
|
16
18
|
*/
|
|
17
|
-
export declare function vectorFromPoint<Point extends GlobalPoint | LocalPoint>(p: Point, origin?: Point): Vector;
|
|
19
|
+
export declare function vectorFromPoint<Point extends GlobalPoint | LocalPoint>(p: Point, origin?: Point, threshold?: number, defaultValue?: Vector): Vector;
|
|
18
20
|
/**
|
|
19
21
|
* Cross product is a binary operation on two vectors in 2D space.
|
|
20
22
|
* It results in a vector that is perpendicular to both vectors.
|
|
@@ -86,3 +88,7 @@ export declare function vectorMagnitude(v: Vector): number;
|
|
|
86
88
|
* @returns The new normalized vector
|
|
87
89
|
*/
|
|
88
90
|
export declare const vectorNormalize: (v: Vector) => Vector;
|
|
91
|
+
/**
|
|
92
|
+
* Calculate the right-hand normal of the vector.
|
|
93
|
+
*/
|
|
94
|
+
export declare const vectorNormal: (v: Vector) => Vector;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
|
|
2
|
-
import type { Bounds } from "@excalidraw/element
|
|
2
|
+
import type { Bounds } from "@excalidraw/element";
|
|
3
3
|
export type LineSegment<P extends LocalPoint | GlobalPoint> = [P, P];
|
|
4
4
|
export declare function getBBox<P extends LocalPoint | GlobalPoint>(line: LineSegment<P>): Bounds;
|
|
5
5
|
export declare function doBBoxesIntersect(a: Bounds, b: Bounds): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Bounds } from "@excalidraw/element
|
|
1
|
+
import type { Bounds } from "@excalidraw/element";
|
|
2
2
|
import type { ExcalidrawElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
3
3
|
type Element = NonDeletedExcalidrawElement;
|
|
4
4
|
type Elements = readonly NonDeletedExcalidrawElement[];
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { EmbedsValidationStatus } from "@excalidraw/excalidraw/types";
|
|
2
|
-
import type { ExcalidrawElement, NonDeletedExcalidrawElement, ExcalidrawSelectionElement } from "./types";
|
|
3
|
-
import type { Drawable, Options } from "roughjs/bin/core";
|
|
4
|
-
import type { RoughGenerator } from "roughjs/bin/generator";
|
|
5
|
-
export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
|
|
6
|
-
/**
|
|
7
|
-
* Generates the roughjs shape for given element.
|
|
8
|
-
*
|
|
9
|
-
* Low-level. Use `ShapeCache.generateElementShape` instead.
|
|
10
|
-
*
|
|
11
|
-
* @private
|
|
12
|
-
*/
|
|
13
|
-
export declare const _generateElementShape: (element: Exclude<NonDeletedExcalidrawElement, ExcalidrawSelectionElement>, generator: RoughGenerator, { isExporting, canvasBackgroundColor, embedsValidationStatus, }: {
|
|
14
|
-
isExporting: boolean;
|
|
15
|
-
canvasBackgroundColor: string;
|
|
16
|
-
embedsValidationStatus: EmbedsValidationStatus | null;
|
|
17
|
-
}) => Drawable | Drawable[] | null;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { AppState, EmbedsValidationStatus } from "@excalidraw/excalidraw/types";
|
|
2
|
-
import type { ElementShape, ElementShapes } from "@excalidraw/excalidraw/scene/types";
|
|
3
|
-
import type { ExcalidrawElement } from "./types";
|
|
4
|
-
import type { Drawable } from "roughjs/bin/core";
|
|
5
|
-
export declare class ShapeCache {
|
|
6
|
-
private static rg;
|
|
7
|
-
private static cache;
|
|
8
|
-
/**
|
|
9
|
-
* Retrieves shape from cache if available. Use this only if shape
|
|
10
|
-
* is optional and you have a fallback in case it's not cached.
|
|
11
|
-
*/
|
|
12
|
-
static get: <T extends ExcalidrawElement>(element: T) => T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined;
|
|
13
|
-
static set: <T extends ExcalidrawElement>(element: T, shape: T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable) => WeakMap<ExcalidrawElement, ElementShape>;
|
|
14
|
-
static delete: (element: ExcalidrawElement) => boolean;
|
|
15
|
-
static destroy: () => void;
|
|
16
|
-
/**
|
|
17
|
-
* Generates & caches shape for element if not already cached, otherwise
|
|
18
|
-
* returns cached shape.
|
|
19
|
-
*/
|
|
20
|
-
static generateElementShape: <T extends import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawArrowElement | import("./types").ExcalidrawFreeDrawElement>(element: T, renderConfig: {
|
|
21
|
-
isExporting: boolean;
|
|
22
|
-
canvasBackgroundColor: AppState["viewBackgroundColor"];
|
|
23
|
-
embedsValidationStatus: EmbedsValidationStatus;
|
|
24
|
-
} | null) => ((T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined) & ({} | null)) | (T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable | null);
|
|
25
|
-
}
|