@dwelle/excalidraw 0.4.0-d8d86cf → 0.4.0-da7ef3e
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 +706 -0
- package/README.md +18 -1422
- package/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.js → vendor-d415b28e9024dee4bb1b.js} +2 -2
- package/dist/excalidraw-assets-dev/{vendor-e6df8519da951026ff69.js → vendor-a14cd58fa2db417e42b2.js} +6 -6
- package/dist/excalidraw.development.js +3035 -1464
- package/dist/excalidraw.production.min.js +1 -1
- package/dist/excalidraw.production.min.js.LICENSE.txt +20 -0
- package/main.js +1 -8
- package/package.json +9 -4
- package/types/actions/actionAddToLibrary.d.ts +130 -52
- package/types/actions/actionAlign.d.ts +25 -32
- package/types/actions/actionBoundText.d.ts +191 -22
- package/types/actions/actionCanvas.d.ts +774 -174
- package/types/actions/actionClipboard.d.ts +232 -88
- package/types/actions/actionDeleteSelected.d.ts +129 -57
- package/types/actions/actionDistribute.d.ts +7 -12
- package/types/actions/actionDuplicateSelection.d.ts +2 -5
- package/types/actions/actionElementLock.d.ts +283 -0
- package/types/actions/actionExport.d.ts +448 -229
- package/types/actions/actionFinalize.d.ts +87 -41
- package/types/actions/actionFlip.d.ts +4 -7
- package/types/actions/actionFrame.d.ts +441 -0
- package/types/actions/actionGroup.d.ts +260 -15
- package/types/actions/actionHistory.d.ts +1 -1
- package/types/actions/actionLinearEditor.d.ts +46 -20
- package/types/actions/actionMenu.d.ts +136 -65
- package/types/actions/actionNavigate.d.ts +2 -3
- package/types/actions/actionProperties.d.ts +590 -277
- package/types/actions/actionSelectAll.d.ts +127 -2
- package/types/actions/actionStyles.d.ts +44 -19
- package/types/actions/actionToggleGridMode.d.ts +46 -19
- package/types/actions/{actionToggleLock.d.ts → actionToggleObjectsSnapMode.d.ts} +58 -31
- package/types/actions/actionToggleStats.d.ts +45 -19
- package/types/actions/actionToggleViewMode.d.ts +46 -19
- package/types/actions/actionToggleZenMode.d.ts +46 -19
- package/types/actions/actionZindex.d.ts +8 -16
- package/types/actions/index.d.ts +2 -1
- package/types/actions/manager.d.ts +3 -2
- package/types/actions/shortcuts.d.ts +2 -1
- package/types/actions/types.d.ts +16 -13
- package/types/appState.d.ts +23 -18
- package/types/charts.d.ts +2 -2
- package/types/clients.d.ts +5 -6
- package/types/clipboard.d.ts +3 -2
- package/types/colors.d.ts +60 -5
- package/types/components/Actions.d.ts +7 -7
- package/types/components/ActiveConfirmDialog.d.ts +4 -0
- package/types/components/App.d.ts +88 -74
- package/types/components/Avatar.d.ts +1 -2
- package/types/components/BraveMeasureTextError.d.ts +2 -0
- package/types/components/Button.d.ts +16 -0
- package/types/components/ButtonIconSelect.d.ts +11 -3
- package/types/components/Card.d.ts +6 -0
- package/types/components/ColorPicker/ColorInput.d.ts +9 -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 +20 -0
- package/types/components/ContextMenu.d.ts +9 -22
- package/types/components/DefaultSidebar.d.ts +29 -0
- package/types/components/Dialog.d.ts +3 -4
- package/types/components/ErrorDialog.d.ts +3 -2
- package/types/components/ExcalidrawLogo.d.ts +15 -0
- package/types/components/EyeDropper.d.ts +28 -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 +4 -5
- 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 +7 -5
- package/types/components/LayerUI.d.ts +10 -16
- 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 +10 -5
- package/types/components/LibraryMenuItems.d.ts +6 -7
- package/types/components/LibraryMenuSection.d.ts +22 -0
- package/types/components/LibraryUnit.d.ts +6 -3
- package/types/components/LoadingMessage.d.ts +0 -1
- package/types/components/LockButton.d.ts +1 -2
- package/types/components/MobileMenu.d.ts +10 -12
- 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/Section.d.ts +1 -1
- 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 +8 -0
- package/types/components/Sidebar/SidebarTabTrigger.d.ts +9 -0
- package/types/components/Sidebar/SidebarTabTriggers.d.ts +6 -0
- package/types/components/Sidebar/SidebarTabs.d.ts +6 -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 +9 -0
- package/types/components/UserList.d.ts +0 -2
- package/types/components/canvases/InteractiveCanvas.d.ts +27 -0
- package/types/components/canvases/StaticCanvas.d.ts +18 -0
- package/types/components/canvases/index.d.ts +3 -0
- 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 +10 -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 +15 -2
- package/types/components/live-collaboration/LiveCollaborationTrigger.d.ts +9 -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 +57 -0
- package/types/components/welcome-screen/WelcomeScreen.Hints.d.ts +19 -0
- package/types/components/welcome-screen/WelcomeScreen.d.ts +84 -0
- package/types/constants.d.ts +94 -18
- 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/transform.d.ts +71 -0
- package/types/data/types.d.ts +3 -5
- package/types/data/url.d.ts +7 -0
- package/types/element/Hyperlink.d.ts +57 -30
- package/types/element/binding.d.ts +4 -3
- package/types/element/bounds.d.ts +31 -7
- package/types/element/collision.d.ts +7 -7
- package/types/element/dragElements.d.ts +12 -2
- package/types/element/embeddable.d.ts +159 -0
- package/types/element/image.d.ts +11 -1
- package/types/element/index.d.ts +3 -2
- package/types/element/linearElementEditor.d.ts +49 -24
- package/types/element/mutateElement.d.ts +2 -1
- package/types/element/newElement.d.ts +48 -15
- package/types/element/resizeElements.d.ts +3 -2
- package/types/element/showSelectedShapeActions.d.ts +2 -2
- package/types/element/sizeHelpers.d.ts +8 -1
- package/types/element/sortElements.d.ts +2 -0
- package/types/element/textElement.d.ts +44 -11
- package/types/element/textWysiwyg.d.ts +7 -2
- package/types/element/transformHandles.d.ts +15 -8
- package/types/element/typeChecks.d.ts +13 -2
- package/types/element/types.d.ts +64 -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 +15 -11
- package/types/history.d.ts +3 -3
- package/types/hooks/useCreatePortalContainer.d.ts +4 -0
- package/types/hooks/useLibraryItemSvg.d.ts +11 -0
- package/types/hooks/useOutsideClick.d.ts +19 -2
- package/types/hooks/useScrollPosition.d.ts +1 -0
- package/types/hooks/useStable.d.ts +1 -0
- package/types/hooks/useTransition.d.ts +2 -0
- package/types/i18n.d.ts +11 -2
- package/types/jotai.d.ts +20 -108
- package/types/keys.d.ts +7 -4
- package/types/math.d.ts +6 -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 +182 -64
- package/types/packages/excalidraw/index.d.ts +19 -3
- package/types/packages/excalidraw/main.d.ts +3 -1
- package/types/packages/excalidraw/webpack.dev.config.d.ts +5 -2
- package/types/packages/excalidraw/webpack.prod.config.d.ts +3 -0
- package/types/packages/utils.d.ts +28 -24
- package/types/renderer/renderElement.d.ts +12 -22
- package/types/renderer/renderScene.d.ts +19 -29
- package/types/renderer/renderSnaps.d.ts +2 -0
- package/types/renderer/roundRect.d.ts +1 -1
- package/types/scene/Renderer.d.ts +25 -0
- package/types/scene/Scene.d.ts +27 -5
- package/types/scene/Shape.d.ts +12 -0
- package/types/scene/ShapeCache.d.ts +20 -0
- package/types/scene/comparisons.d.ts +1 -1
- package/types/scene/export.d.ts +182 -10
- package/types/scene/index.d.ts +1 -1
- package/types/scene/scroll.d.ts +1 -1
- package/types/scene/scrollbars.d.ts +2 -6
- package/types/scene/selection.d.ts +27 -6
- package/types/scene/types.d.ts +69 -26
- package/types/snapping.d.ts +108 -0
- package/types/types.d.ts +196 -81
- package/types/utility-types.d.ts +24 -0
- package/types/utils.d.ts +78 -12
- package/types/zindex.d.ts +4 -4
- 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
- /package/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.js.LICENSE.txt → vendor-d415b28e9024dee4bb1b.js.LICENSE.txt} +0 -0
- /package/types/packages/excalidraw/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.d.ts → vendor-d415b28e9024dee4bb1b.d.ts} +0 -0
- /package/types/packages/excalidraw/dist/excalidraw-assets-dev/{vendor-e6df8519da951026ff69.d.ts → vendor-a14cd58fa2db417e42b2.d.ts} +0 -0
|
@@ -1,21 +1,45 @@
|
|
|
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
|
+
export declare const getElementLineSegments: (element: ExcalidrawElement) => [Point, Point][];
|
|
19
|
+
/**
|
|
20
|
+
* Scene -> Scene coords, but in x1,x2,y1,y2 format.
|
|
21
|
+
*
|
|
22
|
+
* Rectangle here means any rectangular frame, not an excalidraw element.
|
|
23
|
+
*/
|
|
24
|
+
export declare const getRectangleBoxAbsoluteCoords: (boxSceneCoords: RectangleBox) => number[];
|
|
5
25
|
export declare const pointRelativeTo: (element: ExcalidrawElement, absoluteCoords: readonly [number, number]) => readonly [number, number];
|
|
6
26
|
export declare const getDiamondPoints: (element: ExcalidrawElement) => number[];
|
|
7
27
|
export declare const getCurvePathOps: (shape: Drawable) => Op[];
|
|
8
28
|
export declare const getMinMaxXYFromCurvePathOps: (ops: Op[], transformXY?: ((x: number, y: number) => [number, number]) | undefined) => [number, number, number, number];
|
|
9
29
|
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[]) =>
|
|
30
|
+
export declare const getElementBounds: (element: ExcalidrawElement) => Bounds;
|
|
31
|
+
export declare const getCommonBounds: (elements: readonly ExcalidrawElement[]) => Bounds;
|
|
32
|
+
export declare const getDraggedElementsBounds: (elements: ExcalidrawElement[], dragOffset: {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
}) => number[];
|
|
12
36
|
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])[]
|
|
37
|
+
export declare const getElementPointsCoords: (element: ExcalidrawLinearElement, points: readonly (readonly [number, number])[]) => [number, number, number, number];
|
|
14
38
|
export declare const getClosestElementBounds: (elements: readonly ExcalidrawElement[], from: {
|
|
15
39
|
x: number;
|
|
16
40
|
y: number;
|
|
17
|
-
}) =>
|
|
18
|
-
export interface
|
|
41
|
+
}) => Bounds;
|
|
42
|
+
export interface BoundingBox {
|
|
19
43
|
minX: number;
|
|
20
44
|
minY: number;
|
|
21
45
|
maxX: number;
|
|
@@ -25,4 +49,4 @@ export interface Box {
|
|
|
25
49
|
width: number;
|
|
26
50
|
height: number;
|
|
27
51
|
}
|
|
28
|
-
export declare const getCommonBoundingBox: (elements: ExcalidrawElement[] | readonly NonDeleted<ExcalidrawElement>[]) =>
|
|
52
|
+
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, ExcalidrawEmbeddableElement, 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 | ExcalidrawEmbeddableElement | 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,15 @@
|
|
|
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[], offset: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}, appState: AppState, scene: Scene, snapOffset: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}, gridSize: AppState["gridSize"]) => void;
|
|
4
11
|
export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
|
|
5
|
-
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
|
|
12
|
+
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, originOffset?: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
} | null) => void;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { ExcalidrawProps } from "../types";
|
|
2
|
+
import { ExcalidrawElement, ExcalidrawEmbeddableElement, NonDeletedExcalidrawElement, Theme } from "./types";
|
|
3
|
+
type EmbeddedLink = ({
|
|
4
|
+
aspectRatio: {
|
|
5
|
+
w: number;
|
|
6
|
+
h: number;
|
|
7
|
+
};
|
|
8
|
+
warning?: string;
|
|
9
|
+
} & ({
|
|
10
|
+
type: "video" | "generic";
|
|
11
|
+
link: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "document";
|
|
14
|
+
srcdoc: (theme: Theme) => string;
|
|
15
|
+
})) | null;
|
|
16
|
+
export declare const getEmbedLink: (link: string | null | undefined) => EmbeddedLink;
|
|
17
|
+
export declare const isEmbeddableOrFrameLabel: (element: NonDeletedExcalidrawElement) => Boolean;
|
|
18
|
+
export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawEmbeddableElement) => ExcalidrawElement;
|
|
19
|
+
export declare const actionSetEmbeddableAsActiveTool: {
|
|
20
|
+
name: "setEmbeddableAsActiveTool";
|
|
21
|
+
trackEvent: {
|
|
22
|
+
category: "toolbar";
|
|
23
|
+
};
|
|
24
|
+
perform: (elements: readonly ExcalidrawElement[], appState: Readonly<import("../types").AppState>, _: any, app: import("../types").AppClassProperties) => {
|
|
25
|
+
elements: readonly ExcalidrawElement[];
|
|
26
|
+
appState: {
|
|
27
|
+
activeTool: {
|
|
28
|
+
lastActiveTool: import("../types").LastActiveTool;
|
|
29
|
+
locked: boolean;
|
|
30
|
+
} & ({
|
|
31
|
+
type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand";
|
|
32
|
+
customType: null;
|
|
33
|
+
} | {
|
|
34
|
+
type: "custom";
|
|
35
|
+
customType: string;
|
|
36
|
+
});
|
|
37
|
+
contextMenu: {
|
|
38
|
+
items: import("../components/ContextMenu").ContextMenuItems;
|
|
39
|
+
top: number;
|
|
40
|
+
left: number;
|
|
41
|
+
} | null;
|
|
42
|
+
showWelcomeScreen: boolean;
|
|
43
|
+
isLoading: boolean;
|
|
44
|
+
errorMessage: import("react").ReactNode;
|
|
45
|
+
activeEmbeddable: {
|
|
46
|
+
element: NonDeletedExcalidrawElement;
|
|
47
|
+
state: "active" | "hover";
|
|
48
|
+
} | null;
|
|
49
|
+
draggingElement: NonDeletedExcalidrawElement | null;
|
|
50
|
+
resizingElement: NonDeletedExcalidrawElement | null;
|
|
51
|
+
multiElement: import("./types").NonDeleted<import("./types").ExcalidrawLinearElement> | null;
|
|
52
|
+
selectionElement: NonDeletedExcalidrawElement | null;
|
|
53
|
+
isBindingEnabled: boolean;
|
|
54
|
+
startBoundElement: import("./types").NonDeleted<import("./types").ExcalidrawBindableElement> | null;
|
|
55
|
+
suggestedBindings: import("./binding").SuggestedBinding[];
|
|
56
|
+
frameToHighlight: import("./types").NonDeleted<import("./types").ExcalidrawFrameElement> | null;
|
|
57
|
+
frameRendering: {
|
|
58
|
+
enabled: boolean;
|
|
59
|
+
name: boolean;
|
|
60
|
+
outline: boolean;
|
|
61
|
+
clip: boolean;
|
|
62
|
+
};
|
|
63
|
+
editingFrame: string | null;
|
|
64
|
+
elementsToHighlight: import("./types").NonDeleted<ExcalidrawElement>[] | null;
|
|
65
|
+
editingElement: NonDeletedExcalidrawElement | null;
|
|
66
|
+
editingLinearElement: import("./linearElementEditor").LinearElementEditor | null;
|
|
67
|
+
penMode: boolean;
|
|
68
|
+
penDetected: boolean;
|
|
69
|
+
exportBackground: boolean;
|
|
70
|
+
exportEmbedScene: boolean;
|
|
71
|
+
exportWithDarkMode: boolean;
|
|
72
|
+
exportScale: number;
|
|
73
|
+
currentItemStrokeColor: string;
|
|
74
|
+
currentItemBackgroundColor: string;
|
|
75
|
+
currentItemFillStyle: import("./types").FillStyle;
|
|
76
|
+
currentItemStrokeWidth: number;
|
|
77
|
+
currentItemStrokeStyle: import("./types").StrokeStyle;
|
|
78
|
+
currentItemRoughness: number;
|
|
79
|
+
currentItemOpacity: number;
|
|
80
|
+
currentItemFontFamily: number;
|
|
81
|
+
currentItemFontSize: number;
|
|
82
|
+
currentItemTextAlign: string;
|
|
83
|
+
currentItemStartArrowhead: import("./types").Arrowhead | null;
|
|
84
|
+
currentItemEndArrowhead: import("./types").Arrowhead | null;
|
|
85
|
+
currentItemRoundness: import("./types").StrokeRoundness;
|
|
86
|
+
viewBackgroundColor: string;
|
|
87
|
+
scrollX: number;
|
|
88
|
+
scrollY: number;
|
|
89
|
+
cursorButton: "up" | "down";
|
|
90
|
+
scrolledOutside: boolean;
|
|
91
|
+
name: string;
|
|
92
|
+
isResizing: boolean;
|
|
93
|
+
isRotating: boolean;
|
|
94
|
+
zoom: Readonly<{
|
|
95
|
+
value: import("../types").NormalizedZoomValue;
|
|
96
|
+
}>;
|
|
97
|
+
openMenu: "canvas" | "shape" | null;
|
|
98
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
|
|
99
|
+
openSidebar: {
|
|
100
|
+
name: string;
|
|
101
|
+
tab?: string | undefined;
|
|
102
|
+
} | null;
|
|
103
|
+
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
104
|
+
defaultSidebarDockedPreference: boolean;
|
|
105
|
+
lastPointerDownWith: import("./types").PointerType;
|
|
106
|
+
selectedElementIds: Readonly<{
|
|
107
|
+
[id: string]: true;
|
|
108
|
+
}>;
|
|
109
|
+
previousSelectedElementIds: {
|
|
110
|
+
[id: string]: true;
|
|
111
|
+
};
|
|
112
|
+
selectedElementsAreBeingDragged: boolean;
|
|
113
|
+
shouldCacheIgnoreZoom: boolean;
|
|
114
|
+
toast: {
|
|
115
|
+
message: string;
|
|
116
|
+
closable?: boolean | undefined;
|
|
117
|
+
duration?: number | undefined;
|
|
118
|
+
} | null;
|
|
119
|
+
zenModeEnabled: boolean;
|
|
120
|
+
theme: Theme;
|
|
121
|
+
gridSize: number | null;
|
|
122
|
+
viewModeEnabled: boolean;
|
|
123
|
+
selectedGroupIds: {
|
|
124
|
+
[groupId: string]: boolean;
|
|
125
|
+
};
|
|
126
|
+
editingGroupId: string | null;
|
|
127
|
+
width: number;
|
|
128
|
+
height: number;
|
|
129
|
+
offsetTop: number;
|
|
130
|
+
offsetLeft: number;
|
|
131
|
+
fileHandle: import("browser-fs-access").FileSystemHandle | null;
|
|
132
|
+
collaborators: Map<string, import("../types").Collaborator>;
|
|
133
|
+
showStats: boolean;
|
|
134
|
+
currentChartType: import("./types").ChartType;
|
|
135
|
+
pasteDialog: {
|
|
136
|
+
shown: false;
|
|
137
|
+
data: null;
|
|
138
|
+
} | {
|
|
139
|
+
shown: true;
|
|
140
|
+
data: import("../charts").Spreadsheet;
|
|
141
|
+
};
|
|
142
|
+
pendingImageElementId: string | null;
|
|
143
|
+
showHyperlinkPopup: false | "editor" | "info";
|
|
144
|
+
selectedLinearElement: import("./linearElementEditor").LinearElementEditor | null;
|
|
145
|
+
snapLines: import("../snapping").SnapLine[];
|
|
146
|
+
originSnapOffset: {
|
|
147
|
+
x: number;
|
|
148
|
+
y: number;
|
|
149
|
+
} | null;
|
|
150
|
+
objectsSnapModeEnabled: boolean;
|
|
151
|
+
};
|
|
152
|
+
commitToHistory: false;
|
|
153
|
+
};
|
|
154
|
+
} & {
|
|
155
|
+
keyTest?: undefined;
|
|
156
|
+
};
|
|
157
|
+
export declare const extractSrc: (htmlString: string) => string;
|
|
158
|
+
export declare const embeddableURLValidator: (url: string | null | undefined, validateEmbeddable: ExcalidrawProps["validateEmbeddable"]) => boolean;
|
|
159
|
+
export {};
|
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[];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer } from "./types";
|
|
3
|
-
import { Point, AppState, PointerCoords } from "../types";
|
|
2
|
+
import { Point, AppState, PointerCoords, InteractiveCanvasAppState } from "../types";
|
|
4
3
|
import History from "../history";
|
|
5
4
|
import Scene from "../scene/Scene";
|
|
6
5
|
declare const editorMidPointsCache: {
|
|
@@ -53,8 +52,8 @@ export declare class LinearElementEditor {
|
|
|
53
52
|
y: number;
|
|
54
53
|
}[]) => void, linearElementEditor: LinearElementEditor): boolean;
|
|
55
54
|
static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState): LinearElementEditor;
|
|
56
|
-
static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, appState:
|
|
57
|
-
static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, appState:
|
|
55
|
+
static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, appState: InteractiveCanvasAppState) => (typeof editorMidPointsCache)["points"];
|
|
56
|
+
static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, appState: InteractiveCanvasAppState) => void;
|
|
58
57
|
static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
|
|
59
58
|
x: number;
|
|
60
59
|
y: number;
|
|
@@ -62,7 +61,7 @@ export declare class LinearElementEditor {
|
|
|
62
61
|
static isSegmentTooShort(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, zoom: AppState["zoom"]): boolean;
|
|
63
62
|
static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, endPointIndex: number): readonly [number, number];
|
|
64
63
|
static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: Point): number;
|
|
65
|
-
static handlePointerDown(event: React.PointerEvent<
|
|
64
|
+
static handlePointerDown(event: React.PointerEvent<HTMLElement>, appState: AppState, history: History, scenePointer: {
|
|
66
65
|
x: number;
|
|
67
66
|
y: number;
|
|
68
67
|
}, linearElementEditor: LinearElementEditor): {
|
|
@@ -123,9 +122,18 @@ export declare class LinearElementEditor {
|
|
|
123
122
|
hoverPointIndex: number;
|
|
124
123
|
segmentMidPointHoveredCoords: readonly [number, number] | null;
|
|
125
124
|
};
|
|
125
|
+
contextMenu: {
|
|
126
|
+
items: import("../components/ContextMenu").ContextMenuItems;
|
|
127
|
+
top: number;
|
|
128
|
+
left: number;
|
|
129
|
+
} | null;
|
|
126
130
|
showWelcomeScreen: boolean;
|
|
127
131
|
isLoading: boolean;
|
|
128
|
-
errorMessage:
|
|
132
|
+
errorMessage: import("react").ReactNode;
|
|
133
|
+
activeEmbeddable: {
|
|
134
|
+
element: import("./types").NonDeletedExcalidrawElement;
|
|
135
|
+
state: "active" | "hover";
|
|
136
|
+
} | null;
|
|
129
137
|
draggingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
130
138
|
resizingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
131
139
|
multiElement: NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -133,18 +141,26 @@ export declare class LinearElementEditor {
|
|
|
133
141
|
isBindingEnabled: boolean;
|
|
134
142
|
startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
|
|
135
143
|
suggestedBindings: import("./binding").SuggestedBinding[];
|
|
144
|
+
frameToHighlight: NonDeleted<import("./types").ExcalidrawFrameElement> | null;
|
|
145
|
+
frameRendering: {
|
|
146
|
+
enabled: boolean;
|
|
147
|
+
name: boolean;
|
|
148
|
+
outline: boolean;
|
|
149
|
+
clip: boolean;
|
|
150
|
+
};
|
|
151
|
+
editingFrame: string | null;
|
|
152
|
+
elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
|
|
136
153
|
editingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
137
154
|
activeTool: {
|
|
138
|
-
|
|
139
|
-
lastActiveToolBeforeEraser: import("../types").LastActiveToolBeforeEraser;
|
|
155
|
+
lastActiveTool: import("../types").LastActiveTool;
|
|
140
156
|
locked: boolean;
|
|
157
|
+
} & ({
|
|
158
|
+
type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand";
|
|
141
159
|
customType: null;
|
|
142
160
|
} | {
|
|
143
161
|
type: "custom";
|
|
144
162
|
customType: string;
|
|
145
|
-
|
|
146
|
-
locked: boolean;
|
|
147
|
-
};
|
|
163
|
+
});
|
|
148
164
|
penMode: boolean;
|
|
149
165
|
penDetected: boolean;
|
|
150
166
|
exportBackground: boolean;
|
|
@@ -161,10 +177,9 @@ export declare class LinearElementEditor {
|
|
|
161
177
|
currentItemFontFamily: number;
|
|
162
178
|
currentItemFontSize: number;
|
|
163
179
|
currentItemTextAlign: string;
|
|
164
|
-
currentItemStrokeSharpness: import("./types").StrokeSharpness;
|
|
165
180
|
currentItemStartArrowhead: import("./types").Arrowhead | null;
|
|
166
181
|
currentItemEndArrowhead: import("./types").Arrowhead | null;
|
|
167
|
-
|
|
182
|
+
currentItemRoundness: import("./types").StrokeRoundness;
|
|
168
183
|
viewBackgroundColor: string;
|
|
169
184
|
scrollX: number;
|
|
170
185
|
scrollY: number;
|
|
@@ -177,17 +192,21 @@ export declare class LinearElementEditor {
|
|
|
177
192
|
value: import("../types").NormalizedZoomValue;
|
|
178
193
|
}>;
|
|
179
194
|
openMenu: "canvas" | "shape" | null;
|
|
180
|
-
openPopup: "
|
|
181
|
-
openSidebar:
|
|
182
|
-
|
|
183
|
-
|
|
195
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
|
|
196
|
+
openSidebar: {
|
|
197
|
+
name: string;
|
|
198
|
+
tab?: string | undefined;
|
|
199
|
+
} | null;
|
|
200
|
+
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
201
|
+
defaultSidebarDockedPreference: boolean;
|
|
184
202
|
lastPointerDownWith: import("./types").PointerType;
|
|
185
|
-
selectedElementIds: {
|
|
186
|
-
[id: string]:
|
|
187
|
-
}
|
|
203
|
+
selectedElementIds: Readonly<{
|
|
204
|
+
[id: string]: true;
|
|
205
|
+
}>;
|
|
188
206
|
previousSelectedElementIds: {
|
|
189
|
-
[id: string]:
|
|
207
|
+
[id: string]: true;
|
|
190
208
|
};
|
|
209
|
+
selectedElementsAreBeingDragged: boolean;
|
|
191
210
|
shouldCacheIgnoreZoom: boolean;
|
|
192
211
|
toast: {
|
|
193
212
|
message: string;
|
|
@@ -195,7 +214,7 @@ export declare class LinearElementEditor {
|
|
|
195
214
|
duration?: number | undefined;
|
|
196
215
|
} | null;
|
|
197
216
|
zenModeEnabled: boolean;
|
|
198
|
-
theme:
|
|
217
|
+
theme: import("./types").Theme;
|
|
199
218
|
gridSize: number | null;
|
|
200
219
|
viewModeEnabled: boolean;
|
|
201
220
|
selectedGroupIds: {
|
|
@@ -218,8 +237,14 @@ export declare class LinearElementEditor {
|
|
|
218
237
|
data: import("../charts").Spreadsheet;
|
|
219
238
|
};
|
|
220
239
|
pendingImageElementId: string | null;
|
|
221
|
-
showHyperlinkPopup: false | "
|
|
240
|
+
showHyperlinkPopup: false | "editor" | "info";
|
|
222
241
|
selectedLinearElement: LinearElementEditor | null;
|
|
242
|
+
snapLines: import("../snapping").SnapLine[];
|
|
243
|
+
originSnapOffset: {
|
|
244
|
+
x: number;
|
|
245
|
+
y: number;
|
|
246
|
+
} | null;
|
|
247
|
+
objectsSnapModeEnabled: boolean;
|
|
223
248
|
};
|
|
224
249
|
};
|
|
225
250
|
static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, pointIndices: readonly number[]): void;
|
|
@@ -235,7 +260,7 @@ export declare class LinearElementEditor {
|
|
|
235
260
|
endBinding?: PointBinding;
|
|
236
261
|
}): void;
|
|
237
262
|
static shouldAddMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState): boolean;
|
|
238
|
-
static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState): {
|
|
263
|
+
static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState, snapToGrid: boolean): {
|
|
239
264
|
pointerDownState: LinearElementEditor["pointerDownState"];
|
|
240
265
|
selectedPointsIndices: LinearElementEditor["selectedPointsIndices"];
|
|
241
266
|
} | undefined;
|
|
@@ -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,24 @@
|
|
|
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, ExcalidrawEmbeddableElement } from "../element/types";
|
|
2
2
|
import { AppState } from "../types";
|
|
3
|
-
|
|
3
|
+
import { MarkOptional, Mutable } from "../utility-types";
|
|
4
|
+
export 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 newEmbeddableElement: (opts: {
|
|
9
|
+
type: "embeddable";
|
|
10
|
+
validated: ExcalidrawEmbeddableElement["validated"];
|
|
11
|
+
} & ElementConstructorOpts) => NonDeleted<ExcalidrawEmbeddableElement>;
|
|
12
|
+
export declare const newFrameElement: (opts: ElementConstructorOpts) => NonDeleted<ExcalidrawFrameElement>;
|
|
7
13
|
export declare const newTextElement: (opts: {
|
|
8
14
|
text: string;
|
|
9
|
-
fontSize
|
|
10
|
-
fontFamily
|
|
11
|
-
textAlign
|
|
12
|
-
verticalAlign
|
|
13
|
-
containerId?: ExcalidrawTextContainer["id"];
|
|
15
|
+
fontSize?: number;
|
|
16
|
+
fontFamily?: FontFamilyValues;
|
|
17
|
+
textAlign?: TextAlign;
|
|
18
|
+
verticalAlign?: VerticalAlign;
|
|
19
|
+
containerId?: ExcalidrawTextContainer["id"] | null;
|
|
20
|
+
lineHeight?: ExcalidrawTextElement["lineHeight"];
|
|
21
|
+
strokeWidth?: ExcalidrawTextElement["strokeWidth"];
|
|
14
22
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
|
|
15
23
|
export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, text?: string) => {
|
|
16
24
|
x: number;
|
|
@@ -19,9 +27,7 @@ export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement,
|
|
|
19
27
|
height: number;
|
|
20
28
|
baseline: number;
|
|
21
29
|
text: string;
|
|
22
|
-
};
|
|
23
|
-
export declare const getMaxContainerWidth: (container: ExcalidrawElement) => number;
|
|
24
|
-
export declare const getMaxContainerHeight: (container: ExcalidrawElement) => number;
|
|
30
|
+
} | undefined;
|
|
25
31
|
export declare const updateTextElement: (textElement: ExcalidrawTextElement, { text, isDeleted, originalText, }: {
|
|
26
32
|
text: string;
|
|
27
33
|
isDeleted?: boolean | undefined;
|
|
@@ -34,8 +40,8 @@ export declare const newFreeDrawElement: (opts: {
|
|
|
34
40
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawFreeDrawElement>;
|
|
35
41
|
export declare const newLinearElement: (opts: {
|
|
36
42
|
type: ExcalidrawLinearElement["type"];
|
|
37
|
-
startArrowhead
|
|
38
|
-
endArrowhead
|
|
43
|
+
startArrowhead?: Arrowhead | null;
|
|
44
|
+
endArrowhead?: Arrowhead | null;
|
|
39
45
|
points?: ExcalidrawLinearElement["points"];
|
|
40
46
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawLinearElement>;
|
|
41
47
|
export declare const newImageElement: (opts: {
|
|
@@ -44,7 +50,21 @@ export declare const newImageElement: (opts: {
|
|
|
44
50
|
fileId?: ExcalidrawImageElement["fileId"];
|
|
45
51
|
scale?: ExcalidrawImageElement["scale"];
|
|
46
52
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawImageElement>;
|
|
47
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Clones ExcalidrawElement data structure. Does not regenerate id, nonce, or
|
|
55
|
+
* any value. The purpose is to to break object references for immutability
|
|
56
|
+
* reasons, whenever we want to keep the original element, but ensure it's not
|
|
57
|
+
* mutated.
|
|
58
|
+
*
|
|
59
|
+
* Only clones plain objects and arrays. Doesn't clone Date, RegExp, Map, Set,
|
|
60
|
+
* Typed arrays and other non-null objects.
|
|
61
|
+
*/
|
|
62
|
+
export declare const deepCopyElement: <T extends ExcalidrawElement>(val: T) => Mutable<T>;
|
|
63
|
+
/**
|
|
64
|
+
* utility wrapper to generate new id. In test env it reuses the old + postfix
|
|
65
|
+
* for test assertions.
|
|
66
|
+
*/
|
|
67
|
+
export declare const regenerateId: (previousId: string | null) => string;
|
|
48
68
|
/**
|
|
49
69
|
* Duplicate an element, often used in the alt-drag operation.
|
|
50
70
|
* Note that this method has gotten a bit complicated since the
|
|
@@ -59,5 +79,18 @@ export declare const deepCopyElement: (val: any, depth?: number) => any;
|
|
|
59
79
|
* @param element Element to duplicate
|
|
60
80
|
* @param overrides Any element properties to override
|
|
61
81
|
*/
|
|
62
|
-
export declare const duplicateElement: <TElement extends
|
|
63
|
-
|
|
82
|
+
export declare const duplicateElement: <TElement extends ExcalidrawElement>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement, overrides?: Partial<TElement> | undefined) => Readonly<TElement>;
|
|
83
|
+
/**
|
|
84
|
+
* Clones elements, regenerating their ids (including bindings) and group ids.
|
|
85
|
+
*
|
|
86
|
+
* If bindings don't exist in the elements array, they are removed. Therefore,
|
|
87
|
+
* it's advised to supply the whole elements array, or sets of elements that
|
|
88
|
+
* are encapsulated (such as library items), if the purpose is to retain
|
|
89
|
+
* bindings to the cloned elements intact.
|
|
90
|
+
*
|
|
91
|
+
* NOTE by default does not randomize or regenerate anything except the id.
|
|
92
|
+
*/
|
|
93
|
+
export declare const duplicateElements: (elements: readonly ExcalidrawElement[], opts?: {
|
|
94
|
+
/** NOTE also updates version flags and `updated` */
|
|
95
|
+
randomizeSeed: boolean;
|
|
96
|
+
}) => ExcalidrawElement[];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
|
|
2
2
|
import { MaybeTransformHandleType, TransformHandleDirection } from "./transformHandles";
|
|
3
|
-
import { PointerDownState } from "../types";
|
|
3
|
+
import { AppState, PointerDownState } from "../types";
|
|
4
4
|
export declare const normalizeAngle: (angle: number) => number;
|
|
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;
|
|
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, appState: AppState) => 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,6 +1,13 @@
|
|
|
1
1
|
import { ExcalidrawElement } from "./types";
|
|
2
|
-
import { AppState } from "../types";
|
|
2
|
+
import { AppState, Zoom } from "../types";
|
|
3
3
|
export declare const isInvisiblySmallElement: (element: ExcalidrawElement) => boolean;
|
|
4
|
+
export declare const isElementInViewport: (element: ExcalidrawElement, width: number, height: number, viewTransformations: {
|
|
5
|
+
zoom: Zoom;
|
|
6
|
+
offsetLeft: number;
|
|
7
|
+
offsetTop: number;
|
|
8
|
+
scrollX: number;
|
|
9
|
+
scrollY: number;
|
|
10
|
+
}) => boolean;
|
|
4
11
|
/**
|
|
5
12
|
* Makes a perfect shape or diagonal/horizontal/vertical line
|
|
6
13
|
*/
|