@dwelle/excalidraw 0.4.0-d8d86cf → 0.4.0-e03b600
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/CHANGELOG.md +458 -0
- package/README.md +18 -1422
- package/dist/excalidraw.development.js +1882 -498
- package/dist/excalidraw.production.min.js +1 -1
- package/dist/excalidraw.production.min.js.LICENSE.txt +20 -0
- package/package.json +3 -3
- package/types/actions/actionAddToLibrary.d.ts +68 -34
- package/types/actions/actionAlign.d.ts +12 -18
- package/types/actions/actionBoundText.d.ts +158 -19
- package/types/actions/actionCanvas.d.ts +544 -118
- package/types/actions/actionClipboard.d.ts +132 -59
- package/types/actions/actionDeleteSelected.d.ts +72 -41
- package/types/actions/actionDistribute.d.ts +2 -6
- package/types/actions/actionDuplicateSelection.d.ts +2 -4
- package/types/actions/actionElementLock.d.ts +254 -0
- package/types/actions/actionExport.d.ts +215 -131
- package/types/actions/actionFinalize.d.ts +47 -27
- package/types/actions/actionFlip.d.ts +2 -4
- package/types/actions/actionFrame.d.ts +397 -0
- package/types/actions/actionGroup.d.ts +6 -10
- package/types/actions/actionHistory.d.ts +1 -1
- package/types/actions/actionLinearEditor.d.ts +25 -13
- package/types/actions/actionMenu.d.ts +73 -46
- package/types/actions/actionNavigate.d.ts +2 -3
- package/types/actions/actionProperties.d.ts +315 -198
- package/types/actions/actionStyles.d.ts +23 -12
- package/types/actions/actionToggleGridMode.d.ts +25 -12
- package/types/actions/actionToggleStats.d.ts +24 -12
- package/types/actions/actionToggleViewMode.d.ts +25 -12
- package/types/actions/actionToggleZenMode.d.ts +25 -12
- package/types/actions/actionZindex.d.ts +8 -16
- package/types/actions/index.d.ts +1 -1
- package/types/actions/manager.d.ts +3 -2
- package/types/actions/shortcuts.d.ts +2 -1
- package/types/actions/types.d.ts +13 -11
- package/types/appState.d.ts +16 -12
- package/types/charts.d.ts +2 -2
- package/types/clients.d.ts +5 -6
- package/types/clipboard.d.ts +2 -2
- package/types/colors.d.ts +60 -5
- package/types/components/Actions.d.ts +5 -5
- package/types/components/ActiveConfirmDialog.d.ts +4 -0
- package/types/components/App.d.ts +58 -68
- package/types/components/Avatar.d.ts +1 -2
- package/types/components/BraveMeasureTextError.d.ts +2 -0
- package/types/components/Button.d.ts +17 -0
- package/types/components/ButtonIconSelect.d.ts +11 -3
- package/types/components/Card.d.ts +7 -0
- package/types/components/ColorPicker/ColorInput.d.ts +7 -0
- package/types/components/ColorPicker/ColorPicker.d.ts +19 -0
- package/types/components/ColorPicker/CustomColorList.d.ts +8 -0
- package/types/components/ColorPicker/HotkeyLabel.d.ts +8 -0
- package/types/components/ColorPicker/Picker.d.ts +18 -0
- package/types/components/ColorPicker/PickerColorList.d.ts +10 -0
- package/types/components/ColorPicker/PickerHeading.d.ts +5 -0
- package/types/components/ColorPicker/ShadeList.d.ts +8 -0
- package/types/components/ColorPicker/TopPicks.d.ts +9 -0
- package/types/components/ColorPicker/colorPickerUtils.d.ts +21 -0
- package/types/components/ColorPicker/keyboardNavHandlers.d.ts +21 -0
- package/types/components/ContextMenu.d.ts +9 -22
- package/types/components/DefaultSidebar.d.ts +30 -0
- package/types/components/Dialog.d.ts +3 -4
- package/types/components/ErrorDialog.d.ts +3 -2
- package/types/components/EyeDropper.d.ts +18 -0
- package/types/components/FilledButton.d.ts +17 -0
- package/types/components/FixedSideContainer.d.ts +1 -1
- package/types/components/HandButton.d.ts +10 -0
- package/types/components/HelpButton.d.ts +1 -2
- package/types/components/HintViewer.d.ts +2 -2
- package/types/components/HomeButton.d.ts +1 -1
- package/types/components/ImageExportDialog.d.ts +8 -13
- package/types/components/Island.d.ts +1 -1
- package/types/components/JSONExportDialog.d.ts +6 -4
- package/types/components/LayerUI.d.ts +7 -15
- package/types/components/LibraryMenu.d.ts +13 -14
- package/types/components/LibraryMenuBrowseButton.d.ts +2 -2
- package/types/components/LibraryMenuControlButtons.d.ts +9 -0
- package/types/components/LibraryMenuHeaderContent.d.ts +11 -5
- package/types/components/LibraryMenuItems.d.ts +6 -7
- package/types/components/LibraryMenuSection.d.ts +22 -0
- package/types/components/LibraryUnit.d.ts +7 -3
- package/types/components/LockButton.d.ts +1 -2
- package/types/components/MobileMenu.d.ts +8 -11
- package/types/components/OverwriteConfirm/OverwriteConfirm.d.ts +17 -0
- package/types/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +17 -0
- package/types/components/OverwriteConfirm/OverwriteConfirmState.d.ts +22 -0
- package/types/components/PasteChartDialog.d.ts +4 -5
- package/types/components/PenModeButton.d.ts +1 -1
- package/types/components/Popover.d.ts +1 -1
- package/types/components/ProjectName.d.ts +2 -1
- package/types/components/PublishLibrary.d.ts +2 -2
- package/types/components/RadioGroup.d.ts +12 -0
- package/types/components/Sidebar/Sidebar.d.ts +66 -63
- package/types/components/Sidebar/SidebarHeader.d.ts +6 -19
- package/types/components/Sidebar/SidebarTab.d.ts +9 -0
- package/types/components/Sidebar/SidebarTabTrigger.d.ts +10 -0
- package/types/components/Sidebar/SidebarTabTriggers.d.ts +7 -0
- package/types/components/Sidebar/SidebarTabs.d.ts +7 -0
- package/types/components/Sidebar/SidebarTrigger.d.ts +6 -0
- package/types/components/Sidebar/common.d.ts +24 -7
- package/types/components/Spinner.d.ts +2 -1
- package/types/components/Stack.d.ts +4 -3
- package/types/components/Stats.d.ts +3 -3
- package/types/components/Switch.d.ts +9 -0
- package/types/components/ToolButton.d.ts +6 -5
- package/types/components/Tooltip.d.ts +1 -1
- package/types/components/Trans.d.ts +8 -0
- package/types/components/UserList.d.ts +0 -2
- package/types/components/dropdownMenu/DropdownMenu.d.ts +67 -0
- package/types/components/dropdownMenu/DropdownMenuContent.d.ts +15 -0
- package/types/components/dropdownMenu/DropdownMenuGroup.d.ts +11 -0
- package/types/components/dropdownMenu/DropdownMenuItem.d.ts +12 -0
- package/types/components/dropdownMenu/DropdownMenuItemContent.d.ts +6 -0
- package/types/components/dropdownMenu/DropdownMenuItemCustom.d.ts +6 -0
- package/types/components/dropdownMenu/DropdownMenuItemLink.d.ts +13 -0
- package/types/components/dropdownMenu/DropdownMenuSeparator.d.ts +5 -0
- package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +11 -0
- package/types/components/dropdownMenu/common.d.ts +6 -0
- package/types/components/dropdownMenu/dropdownMenuUtils.d.ts +3 -0
- package/types/components/footer/Footer.d.ts +12 -0
- package/types/components/footer/FooterCenter.d.ts +8 -0
- package/types/components/hoc/withInternalFallback.d.ts +4 -0
- package/types/components/icons.d.ts +14 -2
- package/types/components/live-collaboration/LiveCollaborationTrigger.d.ts +10 -0
- package/types/components/main-menu/DefaultItems.d.ts +47 -0
- package/types/components/main-menu/MainMenu.d.ts +61 -0
- package/types/components/welcome-screen/WelcomeScreen.Center.d.ts +58 -0
- package/types/components/welcome-screen/WelcomeScreen.Hints.d.ts +19 -0
- package/types/components/welcome-screen/WelcomeScreen.d.ts +85 -0
- package/types/constants.d.ts +73 -16
- package/types/context/tunnels.d.ts +19 -0
- package/types/context/ui-appState.d.ts +4 -0
- package/types/data/blob.d.ts +3 -2
- package/types/data/encode.d.ts +1 -1
- package/types/data/filesystem.d.ts +2 -1
- package/types/data/index.d.ts +1 -1
- package/types/data/library.d.ts +3 -45
- package/types/data/restore.d.ts +10 -4
- package/types/data/types.d.ts +3 -5
- package/types/element/Hyperlink.d.ts +27 -18
- package/types/element/binding.d.ts +3 -3
- package/types/element/bounds.d.ts +32 -7
- package/types/element/collision.d.ts +7 -7
- package/types/element/dragElements.d.ts +2 -1
- package/types/element/image.d.ts +11 -1
- package/types/element/index.d.ts +3 -2
- package/types/element/linearElementEditor.d.ts +24 -13
- package/types/element/mutateElement.d.ts +2 -1
- package/types/element/newElement.d.ts +37 -11
- package/types/element/resizeElements.d.ts +1 -0
- package/types/element/showSelectedShapeActions.d.ts +2 -2
- package/types/element/sortElements.d.ts +2 -0
- package/types/element/textElement.d.ts +40 -5
- package/types/element/textWysiwyg.d.ts +6 -1
- package/types/element/transformHandles.d.ts +12 -5
- package/types/element/typeChecks.d.ts +12 -2
- package/types/element/types.d.ts +53 -36
- package/types/emitter.d.ts +1 -1
- package/types/errors.d.ts +1 -1
- package/types/frame.d.ts +40 -0
- package/types/ga.d.ts +5 -5
- package/types/groups.d.ts +4 -0
- package/types/hooks/useCreatePortalContainer.d.ts +4 -0
- package/types/hooks/useLibraryItemSvg.d.ts +11 -0
- package/types/hooks/useOutsideClick.d.ts +19 -1
- package/types/hooks/useScrollPosition.d.ts +2 -0
- package/types/hooks/useTransition.d.ts +2 -0
- package/types/i18n.d.ts +7 -1
- package/types/jotai.d.ts +20 -108
- package/types/keys.d.ts +4 -4
- package/types/math.d.ts +4 -1
- package/types/packages/excalidraw/example/App.d.ts +7 -1
- package/types/packages/excalidraw/example/CustomFooter.d.ts +5 -0
- package/types/packages/excalidraw/example/MobileFooter.d.ts +5 -0
- package/types/packages/excalidraw/example/initialData.d.ts +6 -0
- package/types/packages/excalidraw/index.d.ts +17 -3
- package/types/packages/utils.d.ts +26 -25
- package/types/renderer/renderElement.d.ts +7 -5
- package/types/renderer/renderScene.d.ts +13 -6
- package/types/renderer/roundRect.d.ts +1 -1
- package/types/scene/Scene.d.ts +12 -5
- package/types/scene/comparisons.d.ts +1 -1
- package/types/scene/export.d.ts +157 -10
- package/types/scene/index.d.ts +1 -1
- package/types/scene/selection.d.ts +15 -5
- package/types/scene/types.d.ts +13 -5
- package/types/types.d.ts +126 -77
- package/types/utility-types.d.ts +22 -0
- package/types/utils.d.ts +30 -9
- package/types/zindex.d.ts +4 -4
- package/types/actions/actionToggleLock.d.ts +0 -116
- package/types/components/ActiveFile.d.ts +0 -7
- package/types/components/ClearCanvas.d.ts +0 -4
- package/types/components/CollabButton.d.ts +0 -6
- package/types/components/ColorPicker.d.ts +0 -14
- package/types/components/Footer.d.ts +0 -10
- package/types/components/LibraryButton.d.ts +0 -8
- package/types/components/MenuItem.d.ts +0 -11
- package/types/components/MenuUtils.d.ts +0 -1
- package/types/components/SingleLibraryItem.d.ts +0 -10
- package/types/components/WelcomeScreen.d.ts +0 -10
- package/types/components/WelcomeScreenDecor.d.ts +0 -6
- package/types/components/hoc/withUpstreamOverride.d.ts +0 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { AppState, ExcalidrawProps } from "../types";
|
|
2
|
+
import { AppState, ExcalidrawProps, UIAppState } from "../types";
|
|
3
3
|
import { NonDeletedExcalidrawElement } from "./types";
|
|
4
4
|
import { Bounds } from "./bounds";
|
|
5
5
|
import "./Hyperlink.scss";
|
|
@@ -18,9 +18,14 @@ export declare const actionLink: {
|
|
|
18
18
|
appState: {
|
|
19
19
|
showHyperlinkPopup: "editor";
|
|
20
20
|
openMenu: null;
|
|
21
|
+
contextMenu: {
|
|
22
|
+
items: import("../components/ContextMenu").ContextMenuItems;
|
|
23
|
+
top: number;
|
|
24
|
+
left: number;
|
|
25
|
+
} | null;
|
|
21
26
|
showWelcomeScreen: boolean;
|
|
22
27
|
isLoading: boolean;
|
|
23
|
-
errorMessage:
|
|
28
|
+
errorMessage: import("react").ReactNode;
|
|
24
29
|
draggingElement: NonDeletedExcalidrawElement | null;
|
|
25
30
|
resizingElement: NonDeletedExcalidrawElement | null;
|
|
26
31
|
multiElement: import("./types").NonDeleted<import("./types").ExcalidrawLinearElement> | null;
|
|
@@ -28,19 +33,22 @@ export declare const actionLink: {
|
|
|
28
33
|
isBindingEnabled: boolean;
|
|
29
34
|
startBoundElement: import("./types").NonDeleted<import("./types").ExcalidrawBindableElement> | null;
|
|
30
35
|
suggestedBindings: import("./binding").SuggestedBinding[];
|
|
36
|
+
frameToHighlight: import("./types").NonDeleted<import("./types").ExcalidrawFrameElement> | null;
|
|
37
|
+
shouldRenderFrames: boolean;
|
|
38
|
+
editingFrame: string | null;
|
|
39
|
+
elementsToHighlight: import("./types").NonDeleted<import("./types").ExcalidrawElement>[] | null;
|
|
31
40
|
editingElement: NonDeletedExcalidrawElement | null;
|
|
32
41
|
editingLinearElement: import("./linearElementEditor").LinearElementEditor | null;
|
|
33
42
|
activeTool: {
|
|
34
|
-
|
|
35
|
-
lastActiveToolBeforeEraser: import("../types").LastActiveToolBeforeEraser;
|
|
43
|
+
lastActiveTool: import("../types").LastActiveTool;
|
|
36
44
|
locked: boolean;
|
|
45
|
+
} & ({
|
|
46
|
+
type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "frame" | "freedraw" | "eraser" | "hand";
|
|
37
47
|
customType: null;
|
|
38
48
|
} | {
|
|
39
49
|
type: "custom";
|
|
40
50
|
customType: string;
|
|
41
|
-
|
|
42
|
-
locked: boolean;
|
|
43
|
-
};
|
|
51
|
+
});
|
|
44
52
|
penMode: boolean;
|
|
45
53
|
penDetected: boolean;
|
|
46
54
|
exportBackground: boolean;
|
|
@@ -57,10 +65,9 @@ export declare const actionLink: {
|
|
|
57
65
|
currentItemFontFamily: number;
|
|
58
66
|
currentItemFontSize: number;
|
|
59
67
|
currentItemTextAlign: string;
|
|
60
|
-
currentItemStrokeSharpness: import("./types").StrokeSharpness;
|
|
61
68
|
currentItemStartArrowhead: import("./types").Arrowhead | null;
|
|
62
69
|
currentItemEndArrowhead: import("./types").Arrowhead | null;
|
|
63
|
-
|
|
70
|
+
currentItemRoundness: import("./types").StrokeRoundness;
|
|
64
71
|
viewBackgroundColor: string;
|
|
65
72
|
scrollX: number;
|
|
66
73
|
scrollY: number;
|
|
@@ -72,10 +79,13 @@ export declare const actionLink: {
|
|
|
72
79
|
zoom: Readonly<{
|
|
73
80
|
value: import("../types").NormalizedZoomValue;
|
|
74
81
|
}>;
|
|
75
|
-
openPopup: "
|
|
76
|
-
openSidebar:
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
|
|
83
|
+
openSidebar: {
|
|
84
|
+
name: string;
|
|
85
|
+
tab?: string | undefined;
|
|
86
|
+
} | null;
|
|
87
|
+
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
88
|
+
defaultSidebarDockedPreference: boolean;
|
|
79
89
|
lastPointerDownWith: import("./types").PointerType;
|
|
80
90
|
selectedElementIds: {
|
|
81
91
|
[id: string]: boolean;
|
|
@@ -83,6 +93,7 @@ export declare const actionLink: {
|
|
|
83
93
|
previousSelectedElementIds: {
|
|
84
94
|
[id: string]: boolean;
|
|
85
95
|
};
|
|
96
|
+
selectedElementsAreBeingDragged: boolean;
|
|
86
97
|
shouldCacheIgnoreZoom: boolean;
|
|
87
98
|
toast: {
|
|
88
99
|
message: string;
|
|
@@ -123,15 +134,13 @@ export declare const actionLink: {
|
|
|
123
134
|
};
|
|
124
135
|
keyTest: (event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean;
|
|
125
136
|
contextItemLabel: (elements: readonly import("./types").ExcalidrawElement[], appState: Readonly<AppState>) => "labels.link.edit" | "labels.link.create";
|
|
126
|
-
|
|
127
|
-
PanelComponent: ({ elements, appState, updateData }: import("../actions/types").PanelComponentProps
|
|
128
|
-
isInHamburgerMenu: boolean;
|
|
129
|
-
}) => JSX.Element;
|
|
137
|
+
predicate: (elements: readonly import("./types").ExcalidrawElement[], appState: AppState) => boolean;
|
|
138
|
+
PanelComponent: ({ elements, appState, updateData }: import("../actions/types").PanelComponentProps) => JSX.Element;
|
|
130
139
|
} & {
|
|
131
140
|
keyTest?: ((event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean) | undefined;
|
|
132
141
|
};
|
|
133
142
|
export declare const getContextMenuLabel: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => "labels.link.edit" | "labels.link.create";
|
|
134
|
-
export declare const getLinkHandleFromCoords: ([x1, y1, x2, y2]: Bounds, angle: number, appState:
|
|
143
|
+
export declare const getLinkHandleFromCoords: ([x1, y1, x2, y2]: Bounds, angle: number, appState: UIAppState) => [x: number, y: number, width: number, height: number];
|
|
135
144
|
export declare const isPointHittingLinkIcon: (element: NonDeletedExcalidrawElement, appState: AppState, [x, y]: readonly [number, number], isMobile: boolean) => boolean;
|
|
136
145
|
export declare const showHyperlinkTooltip: (element: NonDeletedExcalidrawElement, appState: AppState) => void;
|
|
137
146
|
export declare const hideHyperlinkToolip: () => void;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ExcalidrawLinearElement, ExcalidrawBindableElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawElement } from "./types";
|
|
2
2
|
import { AppState } from "../types";
|
|
3
3
|
import Scene from "../scene/Scene";
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type SuggestedBinding = NonDeleted<ExcalidrawBindableElement> | SuggestedPointBinding;
|
|
5
|
+
export type SuggestedPointBinding = [
|
|
6
6
|
NonDeleted<ExcalidrawLinearElement>,
|
|
7
7
|
"start" | "end" | "both",
|
|
8
8
|
NonDeleted<ExcalidrawBindableElement>
|
|
9
9
|
];
|
|
10
|
-
export declare const shouldEnableBindingForPointerEvent: (event: React.PointerEvent<
|
|
10
|
+
export declare const shouldEnableBindingForPointerEvent: (event: React.PointerEvent<HTMLElement>) => boolean;
|
|
11
11
|
export declare const isBindingEnabled: (appState: AppState) => boolean;
|
|
12
12
|
export declare const bindOrUnbindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, startBindingElement: ExcalidrawBindableElement | null | "keep", endBindingElement: ExcalidrawBindableElement | null | "keep") => void;
|
|
13
13
|
export declare const bindOrUnbindSelectedElements: (elements: NonDeleted<ExcalidrawElement>[]) => void;
|
|
@@ -1,21 +1,46 @@
|
|
|
1
1
|
import { ExcalidrawElement, ExcalidrawLinearElement, Arrowhead, NonDeleted } from "./types";
|
|
2
2
|
import { Drawable, Op } from "roughjs/bin/core";
|
|
3
|
-
|
|
3
|
+
import { Point } from "../types";
|
|
4
|
+
export type RectangleBox = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
angle: number;
|
|
10
|
+
};
|
|
11
|
+
export type Bounds = readonly [x1: number, y1: number, x2: number, y2: number];
|
|
12
|
+
export declare class ElementBounds {
|
|
13
|
+
private static boundsCache;
|
|
14
|
+
static getBounds(element: ExcalidrawElement): Bounds;
|
|
15
|
+
private static calculateBounds;
|
|
16
|
+
}
|
|
4
17
|
export declare const getElementAbsoluteCoords: (element: ExcalidrawElement, includeBoundText?: boolean) => [number, number, number, number, number, number];
|
|
18
|
+
/**
|
|
19
|
+
* for a given element, `getElementLineSegments` returns line segments
|
|
20
|
+
* that can be used for visual collision detection (useful for frames)
|
|
21
|
+
* as opposed to bounding box collision detection
|
|
22
|
+
*/
|
|
23
|
+
export declare const getElementLineSegments: (element: ExcalidrawElement) => [Point, Point][];
|
|
24
|
+
/**
|
|
25
|
+
* Scene -> Scene coords, but in x1,x2,y1,y2 format.
|
|
26
|
+
*
|
|
27
|
+
* Rectangle here means any rectangular frame, not an excalidraw element.
|
|
28
|
+
*/
|
|
29
|
+
export declare const getRectangleBoxAbsoluteCoords: (boxSceneCoords: RectangleBox) => number[];
|
|
5
30
|
export declare const pointRelativeTo: (element: ExcalidrawElement, absoluteCoords: readonly [number, number]) => readonly [number, number];
|
|
6
31
|
export declare const getDiamondPoints: (element: ExcalidrawElement) => number[];
|
|
7
32
|
export declare const getCurvePathOps: (shape: Drawable) => Op[];
|
|
8
33
|
export declare const getMinMaxXYFromCurvePathOps: (ops: Op[], transformXY?: ((x: number, y: number) => [number, number]) | undefined) => [number, number, number, number];
|
|
9
34
|
export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead) => number[] | null;
|
|
10
|
-
export declare const getElementBounds: (element: ExcalidrawElement) =>
|
|
11
|
-
export declare const getCommonBounds: (elements: readonly ExcalidrawElement[]) =>
|
|
35
|
+
export declare const getElementBounds: (element: ExcalidrawElement) => Bounds;
|
|
36
|
+
export declare const getCommonBounds: (elements: readonly ExcalidrawElement[]) => Bounds;
|
|
12
37
|
export declare const getResizedElementAbsoluteCoords: (element: ExcalidrawElement, nextWidth: number, nextHeight: number, normalizePoints: boolean) => [number, number, number, number];
|
|
13
|
-
export declare const getElementPointsCoords: (element: ExcalidrawLinearElement, points: readonly (readonly [number, number])[]
|
|
38
|
+
export declare const getElementPointsCoords: (element: ExcalidrawLinearElement, points: readonly (readonly [number, number])[]) => [number, number, number, number];
|
|
14
39
|
export declare const getClosestElementBounds: (elements: readonly ExcalidrawElement[], from: {
|
|
15
40
|
x: number;
|
|
16
41
|
y: number;
|
|
17
|
-
}) =>
|
|
18
|
-
export interface
|
|
42
|
+
}) => Bounds;
|
|
43
|
+
export interface BoundingBox {
|
|
19
44
|
minX: number;
|
|
20
45
|
minY: number;
|
|
21
46
|
maxX: number;
|
|
@@ -25,4 +50,4 @@ export interface Box {
|
|
|
25
50
|
width: number;
|
|
26
51
|
height: number;
|
|
27
52
|
}
|
|
28
|
-
export declare const getCommonBoundingBox: (elements: ExcalidrawElement[] | readonly NonDeleted<ExcalidrawElement>[]) =>
|
|
53
|
+
export declare const getCommonBoundingBox: (elements: ExcalidrawElement[] | readonly NonDeleted<ExcalidrawElement>[]) => BoundingBox;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as GA from "../ga";
|
|
2
|
-
import { NonDeletedExcalidrawElement, ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawRectangleElement, ExcalidrawDiamondElement, ExcalidrawTextElement, ExcalidrawEllipseElement, NonDeleted, ExcalidrawImageElement } from "./types";
|
|
3
|
-
import { Point } from "../types";
|
|
2
|
+
import { NonDeletedExcalidrawElement, ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawRectangleElement, ExcalidrawDiamondElement, ExcalidrawTextElement, ExcalidrawEllipseElement, NonDeleted, ExcalidrawImageElement, ExcalidrawFrameElement } from "./types";
|
|
3
|
+
import { FrameNameBoundsCache, Point } from "../types";
|
|
4
4
|
import { AppState } from "../types";
|
|
5
|
-
export declare const hitTest: (element: NonDeletedExcalidrawElement, appState: AppState, x: number, y: number) => boolean;
|
|
6
|
-
export declare const isHittingElementBoundingBoxWithoutHittingElement: (element: NonDeletedExcalidrawElement, appState: AppState, x: number, y: number) => boolean;
|
|
7
|
-
export declare const isHittingElementNotConsideringBoundingBox: (element: NonDeletedExcalidrawElement, appState: AppState, point: readonly [number, number]) => boolean;
|
|
8
|
-
export declare const isPointHittingElementBoundingBox: (element: NonDeleted<ExcalidrawElement>, [x, y]: readonly [number, number], threshold: number) => boolean;
|
|
5
|
+
export declare const hitTest: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache, x: number, y: number) => boolean;
|
|
6
|
+
export declare const isHittingElementBoundingBoxWithoutHittingElement: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache, x: number, y: number) => boolean;
|
|
7
|
+
export declare const isHittingElementNotConsideringBoundingBox: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache | null, point: readonly [number, number]) => boolean;
|
|
8
|
+
export declare const isPointHittingElementBoundingBox: (element: NonDeleted<ExcalidrawElement>, [x, y]: readonly [number, number], threshold: number, frameNameBoundsCache: FrameNameBoundsCache | null) => boolean;
|
|
9
9
|
export declare const bindingBorderTest: (element: NonDeleted<ExcalidrawBindableElement>, { x, y }: {
|
|
10
10
|
x: number;
|
|
11
11
|
y: number;
|
|
@@ -18,4 +18,4 @@ export declare const determineFocusPoint: (element: ExcalidrawBindableElement, f
|
|
|
18
18
|
export declare const intersectElementWithLine: (element: ExcalidrawBindableElement, a: readonly [number, number], b: readonly [number, number], gap?: number) => Point[];
|
|
19
19
|
export declare const getCircleIntersections: (center: readonly [number, number, number, number, number, number, number, number], radius: number, line: readonly [number, number, number, number, number, number, number, number]) => GA.Point[];
|
|
20
20
|
export declare const findFocusPointForEllipse: (ellipse: ExcalidrawEllipseElement, relativeDistance: number, point: readonly [number, number, number, number, number, number, number, number]) => readonly [number, number, number, number, number, number, number, number];
|
|
21
|
-
export declare const findFocusPointForRectangulars: (element: ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawDiamondElement | ExcalidrawTextElement, relativeDistance: number, point: readonly [number, number, number, number, number, number, number, number]) => readonly [number, number, number, number, number, number, number, number];
|
|
21
|
+
export declare const findFocusPointForRectangulars: (element: ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawDiamondElement | ExcalidrawTextElement | ExcalidrawFrameElement, relativeDistance: number, point: readonly [number, number, number, number, number, number, number, number]) => readonly [number, number, number, number, number, number, number, number];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NonDeletedExcalidrawElement } from "./types";
|
|
2
2
|
import { AppState, PointerDownState } from "../types";
|
|
3
|
-
|
|
3
|
+
import Scene from "../scene/Scene";
|
|
4
|
+
export declare const dragSelectedElements: (pointerDownState: PointerDownState, selectedElements: NonDeletedExcalidrawElement[], pointerX: number, pointerY: number, lockDirection: boolean | undefined, distanceX: number | undefined, distanceY: number | undefined, appState: AppState, scene: Scene) => void;
|
|
4
5
|
export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
|
|
5
6
|
export declare const dragNewElement: (draggingElement: NonDeletedExcalidrawElement, elementType: AppState["activeTool"]["type"], originX: number, originY: number, x: number, y: number, width: number, height: number, shouldMaintainAspectRatio: boolean, shouldResizeFromCenter: boolean, widthAspectRatio?: number | null) => void;
|
package/types/element/image.d.ts
CHANGED
|
@@ -10,7 +10,17 @@ export declare const updateImageCache: ({ fileIds, files, imageCache, }: {
|
|
|
10
10
|
}) => Promise<{
|
|
11
11
|
imageCache: Map<FileId, {
|
|
12
12
|
image: HTMLImageElement | Promise<HTMLImageElement>;
|
|
13
|
-
mimeType: "
|
|
13
|
+
mimeType: import("../utility-types").ValueOf<{
|
|
14
|
+
readonly svg: "image/svg+xml";
|
|
15
|
+
readonly png: "image/png";
|
|
16
|
+
readonly jpg: "image/jpeg";
|
|
17
|
+
readonly gif: "image/gif";
|
|
18
|
+
readonly webp: "image/webp";
|
|
19
|
+
readonly bmp: "image/bmp";
|
|
20
|
+
readonly ico: "image/x-icon";
|
|
21
|
+
readonly avif: "image/avif";
|
|
22
|
+
readonly jfif: "image/jfif";
|
|
23
|
+
}>;
|
|
14
24
|
}>;
|
|
15
25
|
/** includes errored files because they cache was updated nonetheless */
|
|
16
26
|
updatedFiles: Map<FileId, true>;
|
package/types/element/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
|
|
1
|
+
import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameElement } from "./types";
|
|
2
2
|
export { newElement, newTextElement, updateTextElement, refreshTextDimensions, newLinearElement, newImageElement, duplicateElement, } from "./newElement";
|
|
3
3
|
export { getElementAbsoluteCoords, getElementBounds, getCommonBounds, getDiamondPoints, getArrowheadPoints, getClosestElementBounds, } from "./bounds";
|
|
4
4
|
export { OMIT_SIDES_FOR_MULTIPLE_ELEMENTS, getTransformHandlesFromCoords, getTransformHandles, } from "./transformHandles";
|
|
@@ -6,7 +6,7 @@ export { hitTest, isHittingElementBoundingBoxWithoutHittingElement, } from "./co
|
|
|
6
6
|
export { resizeTest, getCursorForResizingElement, getElementWithTransformHandleType, getTransformHandleTypeFromCoords, } from "./resizeTest";
|
|
7
7
|
export { transformElements, getResizeOffsetXY, getResizeArrowDirection, } from "./resizeElements";
|
|
8
8
|
export { dragSelectedElements, getDragOffsetXY, dragNewElement, } from "./dragElements";
|
|
9
|
-
export { isTextElement, isExcalidrawElement } from "./typeChecks";
|
|
9
|
+
export { isTextElement, isExcalidrawElement, isFrameElement, } from "./typeChecks";
|
|
10
10
|
export { textWysiwyg } from "./textWysiwyg";
|
|
11
11
|
export { redrawTextBoundingBox } from "./textElement";
|
|
12
12
|
export { getPerfectElementSize, getLockedLinearCursorAlignSize, isInvisiblySmallElement, resizePerfectLineForNWHandler, getNormalizedDimensions, } from "./sizeHelpers";
|
|
@@ -14,6 +14,7 @@ export { showSelectedShapeActions } from "./showSelectedShapeActions";
|
|
|
14
14
|
export declare const getSceneVersion: (elements: readonly ExcalidrawElement[]) => number;
|
|
15
15
|
export declare const getVisibleElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
|
|
16
16
|
export declare const getNonDeletedElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
|
|
17
|
+
export declare const getNonDeletedFrames: (frames: readonly ExcalidrawFrameElement[]) => readonly NonDeleted<ExcalidrawFrameElement>[];
|
|
17
18
|
export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element: T) => element is NonDeleted<T>;
|
|
18
19
|
export declare const clearElementsForDatabase: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
19
20
|
export declare const clearElementsForExport: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
@@ -62,7 +62,7 @@ export declare class LinearElementEditor {
|
|
|
62
62
|
static isSegmentTooShort(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, zoom: AppState["zoom"]): boolean;
|
|
63
63
|
static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, endPointIndex: number): readonly [number, number];
|
|
64
64
|
static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: Point): number;
|
|
65
|
-
static handlePointerDown(event: React.PointerEvent<
|
|
65
|
+
static handlePointerDown(event: React.PointerEvent<HTMLElement>, appState: AppState, history: History, scenePointer: {
|
|
66
66
|
x: number;
|
|
67
67
|
y: number;
|
|
68
68
|
}, linearElementEditor: LinearElementEditor): {
|
|
@@ -123,9 +123,14 @@ export declare class LinearElementEditor {
|
|
|
123
123
|
hoverPointIndex: number;
|
|
124
124
|
segmentMidPointHoveredCoords: readonly [number, number] | null;
|
|
125
125
|
};
|
|
126
|
+
contextMenu: {
|
|
127
|
+
items: import("../components/ContextMenu").ContextMenuItems;
|
|
128
|
+
top: number;
|
|
129
|
+
left: number;
|
|
130
|
+
} | null;
|
|
126
131
|
showWelcomeScreen: boolean;
|
|
127
132
|
isLoading: boolean;
|
|
128
|
-
errorMessage:
|
|
133
|
+
errorMessage: import("react").ReactNode;
|
|
129
134
|
draggingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
130
135
|
resizingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
131
136
|
multiElement: NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -133,18 +138,21 @@ export declare class LinearElementEditor {
|
|
|
133
138
|
isBindingEnabled: boolean;
|
|
134
139
|
startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
|
|
135
140
|
suggestedBindings: import("./binding").SuggestedBinding[];
|
|
141
|
+
frameToHighlight: NonDeleted<import("./types").ExcalidrawFrameElement> | null;
|
|
142
|
+
shouldRenderFrames: boolean;
|
|
143
|
+
editingFrame: string | null;
|
|
144
|
+
elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
|
|
136
145
|
editingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
137
146
|
activeTool: {
|
|
138
|
-
|
|
139
|
-
lastActiveToolBeforeEraser: import("../types").LastActiveToolBeforeEraser;
|
|
147
|
+
lastActiveTool: import("../types").LastActiveTool;
|
|
140
148
|
locked: boolean;
|
|
149
|
+
} & ({
|
|
150
|
+
type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "frame" | "freedraw" | "eraser" | "hand";
|
|
141
151
|
customType: null;
|
|
142
152
|
} | {
|
|
143
153
|
type: "custom";
|
|
144
154
|
customType: string;
|
|
145
|
-
|
|
146
|
-
locked: boolean;
|
|
147
|
-
};
|
|
155
|
+
});
|
|
148
156
|
penMode: boolean;
|
|
149
157
|
penDetected: boolean;
|
|
150
158
|
exportBackground: boolean;
|
|
@@ -161,10 +169,9 @@ export declare class LinearElementEditor {
|
|
|
161
169
|
currentItemFontFamily: number;
|
|
162
170
|
currentItemFontSize: number;
|
|
163
171
|
currentItemTextAlign: string;
|
|
164
|
-
currentItemStrokeSharpness: import("./types").StrokeSharpness;
|
|
165
172
|
currentItemStartArrowhead: import("./types").Arrowhead | null;
|
|
166
173
|
currentItemEndArrowhead: import("./types").Arrowhead | null;
|
|
167
|
-
|
|
174
|
+
currentItemRoundness: import("./types").StrokeRoundness;
|
|
168
175
|
viewBackgroundColor: string;
|
|
169
176
|
scrollX: number;
|
|
170
177
|
scrollY: number;
|
|
@@ -177,10 +184,13 @@ export declare class LinearElementEditor {
|
|
|
177
184
|
value: import("../types").NormalizedZoomValue;
|
|
178
185
|
}>;
|
|
179
186
|
openMenu: "canvas" | "shape" | null;
|
|
180
|
-
openPopup: "
|
|
181
|
-
openSidebar:
|
|
182
|
-
|
|
183
|
-
|
|
187
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
|
|
188
|
+
openSidebar: {
|
|
189
|
+
name: string;
|
|
190
|
+
tab?: string | undefined;
|
|
191
|
+
} | null;
|
|
192
|
+
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
193
|
+
defaultSidebarDockedPreference: boolean;
|
|
184
194
|
lastPointerDownWith: import("./types").PointerType;
|
|
185
195
|
selectedElementIds: {
|
|
186
196
|
[id: string]: boolean;
|
|
@@ -188,6 +198,7 @@ export declare class LinearElementEditor {
|
|
|
188
198
|
previousSelectedElementIds: {
|
|
189
199
|
[id: string]: boolean;
|
|
190
200
|
};
|
|
201
|
+
selectedElementsAreBeingDragged: boolean;
|
|
191
202
|
shouldCacheIgnoreZoom: boolean;
|
|
192
203
|
toast: {
|
|
193
204
|
message: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ExcalidrawElement } from "./types";
|
|
2
|
-
|
|
2
|
+
import { Mutable } from "../utility-types";
|
|
3
|
+
type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce">;
|
|
3
4
|
export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
|
|
4
5
|
export declare const newElementWith: <TElement extends ExcalidrawElement>(element: TElement, updates: ElementUpdate<TElement>) => TElement;
|
|
5
6
|
/**
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer } from "../element/types";
|
|
1
|
+
import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement } from "../element/types";
|
|
2
2
|
import { AppState } from "../types";
|
|
3
|
-
|
|
3
|
+
import { MarkOptional, Mutable } from "../utility-types";
|
|
4
|
+
type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity">;
|
|
4
5
|
export declare const newElement: (opts: {
|
|
5
6
|
type: ExcalidrawGenericElement["type"];
|
|
6
7
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawGenericElement>;
|
|
8
|
+
export declare const newFrameElement: (opts: ElementConstructorOpts) => NonDeleted<ExcalidrawFrameElement>;
|
|
7
9
|
export declare const newTextElement: (opts: {
|
|
8
10
|
text: string;
|
|
9
|
-
fontSize
|
|
10
|
-
fontFamily
|
|
11
|
-
textAlign
|
|
12
|
-
verticalAlign
|
|
11
|
+
fontSize?: number;
|
|
12
|
+
fontFamily?: FontFamilyValues;
|
|
13
|
+
textAlign?: TextAlign;
|
|
14
|
+
verticalAlign?: VerticalAlign;
|
|
13
15
|
containerId?: ExcalidrawTextContainer["id"];
|
|
16
|
+
lineHeight?: ExcalidrawTextElement["lineHeight"];
|
|
17
|
+
strokeWidth?: ExcalidrawTextElement["strokeWidth"];
|
|
18
|
+
isFrameName?: boolean;
|
|
14
19
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
|
|
15
20
|
export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, text?: string) => {
|
|
16
21
|
x: number;
|
|
@@ -19,9 +24,7 @@ export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement,
|
|
|
19
24
|
height: number;
|
|
20
25
|
baseline: number;
|
|
21
26
|
text: string;
|
|
22
|
-
};
|
|
23
|
-
export declare const getMaxContainerWidth: (container: ExcalidrawElement) => number;
|
|
24
|
-
export declare const getMaxContainerHeight: (container: ExcalidrawElement) => number;
|
|
27
|
+
} | undefined;
|
|
25
28
|
export declare const updateTextElement: (textElement: ExcalidrawTextElement, { text, isDeleted, originalText, }: {
|
|
26
29
|
text: string;
|
|
27
30
|
isDeleted?: boolean | undefined;
|
|
@@ -44,7 +47,16 @@ export declare const newImageElement: (opts: {
|
|
|
44
47
|
fileId?: ExcalidrawImageElement["fileId"];
|
|
45
48
|
scale?: ExcalidrawImageElement["scale"];
|
|
46
49
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawImageElement>;
|
|
47
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Clones ExcalidrawElement data structure. Does not regenerate id, nonce, or
|
|
52
|
+
* any value. The purpose is to to break object references for immutability
|
|
53
|
+
* reasons, whenever we want to keep the original element, but ensure it's not
|
|
54
|
+
* mutated.
|
|
55
|
+
*
|
|
56
|
+
* Only clones plain objects and arrays. Doesn't clone Date, RegExp, Map, Set,
|
|
57
|
+
* Typed arrays and other non-null objects.
|
|
58
|
+
*/
|
|
59
|
+
export declare const deepCopyElement: <T extends ExcalidrawElement>(val: T) => Mutable<T>;
|
|
48
60
|
/**
|
|
49
61
|
* Duplicate an element, often used in the alt-drag operation.
|
|
50
62
|
* Note that this method has gotten a bit complicated since the
|
|
@@ -59,5 +71,19 @@ export declare const deepCopyElement: (val: any, depth?: number) => any;
|
|
|
59
71
|
* @param element Element to duplicate
|
|
60
72
|
* @param overrides Any element properties to override
|
|
61
73
|
*/
|
|
62
|
-
export declare const duplicateElement: <TElement extends
|
|
74
|
+
export declare const duplicateElement: <TElement extends ExcalidrawElement>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement, overrides?: Partial<TElement> | undefined) => Readonly<TElement>;
|
|
75
|
+
/**
|
|
76
|
+
* Clones elements, regenerating their ids (including bindings) and group ids.
|
|
77
|
+
*
|
|
78
|
+
* If bindings don't exist in the elements array, they are removed. Therefore,
|
|
79
|
+
* it's advised to supply the whole elements array, or sets of elements that
|
|
80
|
+
* are encapsulated (such as library items), if the purpose is to retain
|
|
81
|
+
* bindings to the cloned elements intact.
|
|
82
|
+
*
|
|
83
|
+
* NOTE by default does not randomize or regenerate anything except the id.
|
|
84
|
+
*/
|
|
85
|
+
export declare const duplicateElements: (elements: readonly ExcalidrawElement[], opts?: {
|
|
86
|
+
/** NOTE also updates version flags and `updated` */
|
|
87
|
+
randomizeSeed: boolean;
|
|
88
|
+
}) => ExcalidrawElement[];
|
|
63
89
|
export {};
|
|
@@ -4,5 +4,6 @@ import { PointerDownState } from "../types";
|
|
|
4
4
|
export declare const normalizeAngle: (angle: number) => number;
|
|
5
5
|
export declare const transformElements: (pointerDownState: PointerDownState, transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], resizeArrowDirection: "origin" | "end", shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
|
|
6
6
|
export declare const resizeSingleElement: (originalElements: PointerDownState["originalElements"], shouldMaintainAspectRatio: boolean, element: NonDeletedExcalidrawElement, transformHandleDirection: TransformHandleDirection, shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
|
|
7
|
+
export declare const resizeMultipleElements: (pointerDownState: PointerDownState, selectedElements: readonly NonDeletedExcalidrawElement[], transformHandleType: "nw" | "ne" | "sw" | "se", shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
|
|
7
8
|
export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
|
|
8
9
|
export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AppState } from "../types";
|
|
2
1
|
import { NonDeletedExcalidrawElement } from "./types";
|
|
3
|
-
|
|
2
|
+
import { UIAppState } from "../types";
|
|
3
|
+
export declare const showSelectedShapeActions: (appState: UIAppState, elements: readonly NonDeletedExcalidrawElement[]) => boolean;
|
|
@@ -1,23 +1,44 @@
|
|
|
1
|
-
import { ExcalidrawElement, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontString, NonDeletedExcalidrawElement } from "./types";
|
|
1
|
+
import { ExcalidrawElement, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./types";
|
|
2
2
|
import { MaybeTransformHandleType } from "./transformHandles";
|
|
3
3
|
import { AppState } from "../types";
|
|
4
|
+
import { ExtractSetType } from "../utility-types";
|
|
4
5
|
export declare const normalizeText: (text: string) => string;
|
|
6
|
+
export declare const splitIntoLines: (text: string) => string[];
|
|
5
7
|
export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null) => void;
|
|
6
8
|
export declare const bindTextToShapeAfterDuplication: (sceneElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
|
|
7
9
|
export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, transformHandleType: MaybeTransformHandleType) => void;
|
|
8
|
-
export declare const
|
|
10
|
+
export declare const computeBoundTextPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
export declare const measureText: (text: string, font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => {
|
|
9
15
|
width: number;
|
|
10
16
|
height: number;
|
|
11
17
|
baseline: number;
|
|
12
18
|
};
|
|
13
|
-
export declare const
|
|
19
|
+
export declare const measureBaseline: (text: string, font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"], wrapInContainer?: boolean) => number;
|
|
20
|
+
/**
|
|
21
|
+
* To get unitless line-height (if unknown) we can calculate it by dividing
|
|
22
|
+
* height-per-line by fontSize.
|
|
23
|
+
*/
|
|
24
|
+
export declare const detectLineHeight: (textElement: ExcalidrawTextElement) => number & {
|
|
25
|
+
_brand: "unitlessLineHeight";
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* We calculate the line height from the font size and the unitless line height,
|
|
29
|
+
* aligning with the W3C spec.
|
|
30
|
+
*/
|
|
31
|
+
export declare const getLineHeightInPx: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
32
|
+
export declare const getApproxMinLineHeight: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
33
|
+
export declare const getTextWidth: (text: string, font: FontString) => number;
|
|
34
|
+
export declare const getTextHeight: (text: string, fontSize: number, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
35
|
+
export declare const parseTokens: (text: string) => string[];
|
|
14
36
|
export declare const wrapText: (text: string, font: FontString, maxWidth: number) => string;
|
|
15
37
|
export declare const charWidth: {
|
|
16
38
|
calculate: (char: string, font: FontString) => number;
|
|
17
39
|
getCache: (font: FontString) => number[];
|
|
18
40
|
};
|
|
19
|
-
export declare const getApproxMinLineWidth: (font: FontString) => number;
|
|
20
|
-
export declare const getApproxMinLineHeight: (font: FontString) => number;
|
|
41
|
+
export declare const getApproxMinLineWidth: (font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
21
42
|
export declare const getMinCharWidth: (font: FontString) => number;
|
|
22
43
|
export declare const getMaxCharWidth: (font: FontString) => number;
|
|
23
44
|
export declare const getApproxCharsToFitInWidth: (font: FontString, width: number) => number;
|
|
@@ -34,6 +55,10 @@ export declare const getContainerCenter: (container: ExcalidrawElement, appState
|
|
|
34
55
|
x: number;
|
|
35
56
|
y: number;
|
|
36
57
|
};
|
|
58
|
+
export declare const getContainerCoords: (container: NonDeletedExcalidrawElement) => {
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
};
|
|
37
62
|
export declare const getTextElementAngle: (textElement: ExcalidrawTextElement) => number;
|
|
38
63
|
export declare const getBoundTextElementOffset: (boundTextElement: ExcalidrawTextElement | null) => number;
|
|
39
64
|
export declare const getBoundTextElementPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
|
|
@@ -41,5 +66,15 @@ export declare const getBoundTextElementPosition: (container: ExcalidrawElement,
|
|
|
41
66
|
y: number;
|
|
42
67
|
} | undefined;
|
|
43
68
|
export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
|
|
69
|
+
export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
|
|
44
70
|
export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], appState: AppState, x: number, y: number) => ExcalidrawTextContainer | null;
|
|
71
|
+
declare const VALID_CONTAINER_TYPES: Set<string>;
|
|
45
72
|
export declare const isValidTextContainer: (element: ExcalidrawElement) => boolean;
|
|
73
|
+
export declare const computeContainerDimensionForBoundText: (dimension: number, containerType: ExtractSetType<typeof VALID_CONTAINER_TYPES>) => number;
|
|
74
|
+
export declare const getBoundTextMaxWidth: (container: ExcalidrawElement) => number;
|
|
75
|
+
export declare const getBoundTextMaxHeight: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => number;
|
|
76
|
+
export declare const isMeasureTextSupported: () => boolean;
|
|
77
|
+
export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
|
|
78
|
+
_brand: "unitlessLineHeight";
|
|
79
|
+
};
|
|
80
|
+
export {};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { ExcalidrawElement, ExcalidrawTextElement } from "./types";
|
|
1
|
+
import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawTextContainer } from "./types";
|
|
2
2
|
import App from "../components/App";
|
|
3
|
+
export declare const updateOriginalContainerCache: (id: ExcalidrawTextContainer["id"], height: ExcalidrawTextContainer["height"]) => {
|
|
4
|
+
height: ExcalidrawTextContainer["height"];
|
|
5
|
+
};
|
|
6
|
+
export declare const resetOriginalContainerCache: (id: ExcalidrawTextContainer["id"]) => void;
|
|
7
|
+
export declare const getOriginalContainerHeightFromCache: (id: ExcalidrawTextContainer["id"]) => number | null;
|
|
3
8
|
export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, }: {
|
|
4
9
|
id: ExcalidrawElement["id"];
|
|
5
10
|
onChange?: ((text: string) => void) | undefined;
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
|
|
2
2
|
import { AppState, Zoom } from "../types";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
3
|
+
export type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
|
|
4
|
+
export type TransformHandleType = TransformHandleDirection | "rotation";
|
|
5
|
+
export type TransformHandle = [number, number, number, number];
|
|
6
|
+
export type TransformHandles = Partial<{
|
|
7
7
|
[T in TransformHandleType]: TransformHandle;
|
|
8
8
|
}>;
|
|
9
|
-
export
|
|
9
|
+
export type MaybeTransformHandleType = TransformHandleType | false;
|
|
10
10
|
export declare const OMIT_SIDES_FOR_MULTIPLE_ELEMENTS: {
|
|
11
11
|
e: boolean;
|
|
12
12
|
s: boolean;
|
|
13
13
|
n: boolean;
|
|
14
14
|
w: boolean;
|
|
15
15
|
};
|
|
16
|
+
export declare const OMIT_SIDES_FOR_FRAME: {
|
|
17
|
+
e: boolean;
|
|
18
|
+
s: boolean;
|
|
19
|
+
n: boolean;
|
|
20
|
+
w: boolean;
|
|
21
|
+
rotation: boolean;
|
|
22
|
+
};
|
|
16
23
|
export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [number, number, number, number, number, number], angle: number, zoom: Zoom, pointerType: PointerType, omitSides?: {
|
|
17
24
|
s?: boolean | undefined;
|
|
18
25
|
e?: boolean | undefined;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AppState } from "../types";
|
|
2
|
-
import {
|
|
2
|
+
import { MarkNonNullable } from "../utility-types";
|
|
3
|
+
import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawGenericElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType } from "./types";
|
|
3
4
|
export declare const isGenericElement: (element: ExcalidrawElement | null) => element is ExcalidrawGenericElement;
|
|
4
5
|
export declare const isInitializedImageElement: (element: ExcalidrawElement | null) => element is InitializedExcalidrawImageElement;
|
|
5
6
|
export declare const isImageElement: (element: ExcalidrawElement | null) => element is ExcalidrawImageElement;
|
|
6
7
|
export declare const isTextElement: (element: ExcalidrawElement | null) => element is ExcalidrawTextElement;
|
|
8
|
+
export declare const isFrameElement: (element: ExcalidrawElement | null) => element is ExcalidrawFrameElement;
|
|
7
9
|
export declare const isFreeDrawElement: (element?: ExcalidrawElement | null) => element is ExcalidrawFreeDrawElement;
|
|
8
10
|
export declare const isFreeDrawElementType: (elementType: ExcalidrawElement["type"]) => boolean;
|
|
9
11
|
export declare const isLinearElement: (element?: ExcalidrawElement | null) => element is ExcalidrawLinearElement;
|
|
@@ -14,5 +16,13 @@ export declare const isBindingElementType: (elementType: AppState["activeTool"][
|
|
|
14
16
|
export declare const isBindableElement: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawBindableElement;
|
|
15
17
|
export declare const isTextBindableContainer: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawTextContainer;
|
|
16
18
|
export declare const isExcalidrawElement: (element: any) => boolean;
|
|
17
|
-
export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is ExcalidrawBindableElement
|
|
19
|
+
export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is MarkNonNullable<ExcalidrawBindableElement, "boundElements">;
|
|
18
20
|
export declare const isBoundToContainer: (element: ExcalidrawElement | null) => element is ExcalidrawTextElementWithContainer;
|
|
21
|
+
export declare const isUsingAdaptiveRadius: (type: string) => boolean;
|
|
22
|
+
export declare const isUsingProportionalRadius: (type: string) => boolean;
|
|
23
|
+
export declare const canApplyRoundnessTypeToElement: (roundnessType: RoundnessType, element: ExcalidrawElement) => boolean;
|
|
24
|
+
export declare const getDefaultRoundnessTypeForElement: (element: ExcalidrawElement) => {
|
|
25
|
+
type: 2;
|
|
26
|
+
} | {
|
|
27
|
+
type: 3;
|
|
28
|
+
} | null;
|