@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,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
|
-
export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, transformHandleType: MaybeTransformHandleType) => void;
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean) => void;
|
|
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;
|
|
@@ -26,14 +47,14 @@ export declare const getBoundTextElement: (element: ExcalidrawElement | null) =>
|
|
|
26
47
|
export declare const getContainerElement: (element: (ExcalidrawElement & {
|
|
27
48
|
containerId: ExcalidrawElement["id"] | null;
|
|
28
49
|
}) | null) => ExcalidrawElement | null;
|
|
29
|
-
export declare const getContainerDims: (element: ExcalidrawElement) => {
|
|
30
|
-
width: number;
|
|
31
|
-
height: number;
|
|
32
|
-
};
|
|
33
50
|
export declare const getContainerCenter: (container: ExcalidrawElement, appState: AppState) => {
|
|
34
51
|
x: number;
|
|
35
52
|
y: number;
|
|
36
53
|
};
|
|
54
|
+
export declare const getContainerCoords: (container: NonDeletedExcalidrawElement) => {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
};
|
|
37
58
|
export declare const getTextElementAngle: (textElement: ExcalidrawTextElement) => number;
|
|
38
59
|
export declare const getBoundTextElementOffset: (boundTextElement: ExcalidrawTextElement | null) => number;
|
|
39
60
|
export declare const getBoundTextElementPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
|
|
@@ -41,5 +62,17 @@ export declare const getBoundTextElementPosition: (container: ExcalidrawElement,
|
|
|
41
62
|
y: number;
|
|
42
63
|
} | undefined;
|
|
43
64
|
export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
|
|
65
|
+
export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
|
|
44
66
|
export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], appState: AppState, x: number, y: number) => ExcalidrawTextContainer | null;
|
|
45
|
-
|
|
67
|
+
declare const VALID_CONTAINER_TYPES: Set<string>;
|
|
68
|
+
export declare const isValidTextContainer: (element: {
|
|
69
|
+
type: ExcalidrawElement["type"];
|
|
70
|
+
}) => boolean;
|
|
71
|
+
export declare const computeContainerDimensionForBoundText: (dimension: number, containerType: ExtractSetType<typeof VALID_CONTAINER_TYPES>) => number;
|
|
72
|
+
export declare const getBoundTextMaxWidth: (container: ExcalidrawElement, boundTextElement?: ExcalidrawTextElement | null) => number;
|
|
73
|
+
export declare const getBoundTextMaxHeight: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => number;
|
|
74
|
+
export declare const isMeasureTextSupported: () => boolean;
|
|
75
|
+
export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
|
|
76
|
+
_brand: "unitlessLineHeight";
|
|
77
|
+
};
|
|
78
|
+
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;
|
|
@@ -10,7 +15,7 @@ export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords,
|
|
|
10
15
|
}) => void;
|
|
11
16
|
getViewportCoords: (x: number, y: number) => [number, number];
|
|
12
17
|
element: ExcalidrawTextElement;
|
|
13
|
-
canvas: HTMLCanvasElement
|
|
18
|
+
canvas: HTMLCanvasElement;
|
|
14
19
|
excalidrawContainer: HTMLDivElement | null;
|
|
15
20
|
app: App;
|
|
16
21
|
}) => void;
|
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
import { ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
2
|
+
import { InteractiveCanvasAppState, Zoom } from "../types";
|
|
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;
|
|
19
|
-
n?: boolean | undefined;
|
|
20
26
|
w?: boolean | undefined;
|
|
27
|
+
n?: boolean | undefined;
|
|
21
28
|
nw?: boolean | undefined;
|
|
22
29
|
ne?: boolean | undefined;
|
|
23
30
|
sw?: boolean | undefined;
|
|
@@ -25,4 +32,4 @@ export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [
|
|
|
25
32
|
rotation?: boolean | undefined;
|
|
26
33
|
}, margin?: number) => TransformHandles;
|
|
27
34
|
export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoom, pointerType?: PointerType) => TransformHandles;
|
|
28
|
-
export declare const shouldShowBoundingBox: (elements: NonDeletedExcalidrawElement[], appState:
|
|
35
|
+
export declare const shouldShowBoundingBox: (elements: readonly NonDeletedExcalidrawElement[], appState: InteractiveCanvasAppState) => boolean;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { AppState } from "../types";
|
|
2
|
-
import {
|
|
2
|
+
import { MarkNonNullable } from "../utility-types";
|
|
3
|
+
import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawEmbeddableElement, 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;
|
|
7
|
+
export declare const isEmbeddableElement: (element: ExcalidrawElement | null | undefined) => element is ExcalidrawEmbeddableElement;
|
|
6
8
|
export declare const isTextElement: (element: ExcalidrawElement | null) => element is ExcalidrawTextElement;
|
|
9
|
+
export declare const isFrameElement: (element: ExcalidrawElement | null) => element is ExcalidrawFrameElement;
|
|
7
10
|
export declare const isFreeDrawElement: (element?: ExcalidrawElement | null) => element is ExcalidrawFreeDrawElement;
|
|
8
11
|
export declare const isFreeDrawElementType: (elementType: ExcalidrawElement["type"]) => boolean;
|
|
9
12
|
export declare const isLinearElement: (element?: ExcalidrawElement | null) => element is ExcalidrawLinearElement;
|
|
@@ -14,5 +17,13 @@ export declare const isBindingElementType: (elementType: AppState["activeTool"][
|
|
|
14
17
|
export declare const isBindableElement: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawBindableElement;
|
|
15
18
|
export declare const isTextBindableContainer: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawTextContainer;
|
|
16
19
|
export declare const isExcalidrawElement: (element: any) => boolean;
|
|
17
|
-
export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is ExcalidrawBindableElement
|
|
20
|
+
export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is MarkNonNullable<ExcalidrawBindableElement, "boundElements">;
|
|
18
21
|
export declare const isBoundToContainer: (element: ExcalidrawElement | null) => element is ExcalidrawTextElementWithContainer;
|
|
22
|
+
export declare const isUsingAdaptiveRadius: (type: string) => boolean;
|
|
23
|
+
export declare const isUsingProportionalRadius: (type: string) => boolean;
|
|
24
|
+
export declare const canApplyRoundnessTypeToElement: (roundnessType: RoundnessType, element: ExcalidrawElement) => boolean;
|
|
25
|
+
export declare const getDefaultRoundnessTypeForElement: (element: ExcalidrawElement) => {
|
|
26
|
+
type: 2;
|
|
27
|
+
} | {
|
|
28
|
+
type: 3;
|
|
29
|
+
} | null;
|
package/types/element/types.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { Point } from "../types";
|
|
2
|
-
import { FONT_FAMILY, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "../constants";
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
2
|
+
import { FONT_FAMILY, ROUNDNESS, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "../constants";
|
|
3
|
+
import { MarkNonNullable, ValueOf } from "../utility-types";
|
|
4
|
+
export type ChartType = "bar" | "line";
|
|
5
|
+
export type FillStyle = "hachure" | "cross-hatch" | "solid" | "zigzag";
|
|
6
|
+
export type FontFamilyKeys = keyof typeof FONT_FAMILY;
|
|
7
|
+
export type FontFamilyValues = typeof FONT_FAMILY[FontFamilyKeys];
|
|
8
|
+
export type Theme = typeof THEME[keyof typeof THEME];
|
|
9
|
+
export type FontString = string & {
|
|
9
10
|
_brand: "fontString";
|
|
10
11
|
};
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
export type GroupId = string;
|
|
13
|
+
export type PointerType = "mouse" | "pen" | "touch";
|
|
14
|
+
export type StrokeRoundness = "round" | "sharp";
|
|
15
|
+
export type RoundnessType = ValueOf<typeof ROUNDNESS>;
|
|
16
|
+
export type StrokeStyle = "solid" | "dashed" | "dotted";
|
|
17
|
+
export type TextAlign = typeof TEXT_ALIGN[keyof typeof TEXT_ALIGN];
|
|
18
|
+
type VerticalAlignKeys = keyof typeof VERTICAL_ALIGN;
|
|
19
|
+
export type VerticalAlign = typeof VERTICAL_ALIGN[VerticalAlignKeys];
|
|
20
|
+
type _ExcalidrawElementBase = Readonly<{
|
|
19
21
|
id: string;
|
|
20
22
|
x: number;
|
|
21
23
|
y: number;
|
|
@@ -24,7 +26,10 @@ declare type _ExcalidrawElementBase = Readonly<{
|
|
|
24
26
|
fillStyle: FillStyle;
|
|
25
27
|
strokeWidth: number;
|
|
26
28
|
strokeStyle: StrokeStyle;
|
|
27
|
-
|
|
29
|
+
roundness: null | {
|
|
30
|
+
type: RoundnessType;
|
|
31
|
+
value?: number;
|
|
32
|
+
};
|
|
28
33
|
roughness: number;
|
|
29
34
|
opacity: number;
|
|
30
35
|
width: number;
|
|
@@ -44,6 +49,7 @@ declare type _ExcalidrawElementBase = Readonly<{
|
|
|
44
49
|
/** List of groups the element belongs to.
|
|
45
50
|
Ordered from deepest to shallowest. */
|
|
46
51
|
groupIds: readonly GroupId[];
|
|
52
|
+
frameId: string | null;
|
|
47
53
|
/** other elements that are bound to this element */
|
|
48
54
|
boundElements: readonly Readonly<{
|
|
49
55
|
id: ExcalidrawLinearElement["id"];
|
|
@@ -55,19 +61,30 @@ declare type _ExcalidrawElementBase = Readonly<{
|
|
|
55
61
|
locked: boolean;
|
|
56
62
|
customData?: Record<string, any>;
|
|
57
63
|
}>;
|
|
58
|
-
export
|
|
64
|
+
export type ExcalidrawSelectionElement = _ExcalidrawElementBase & {
|
|
59
65
|
type: "selection";
|
|
60
66
|
};
|
|
61
|
-
export
|
|
67
|
+
export type ExcalidrawRectangleElement = _ExcalidrawElementBase & {
|
|
62
68
|
type: "rectangle";
|
|
63
69
|
};
|
|
64
|
-
export
|
|
70
|
+
export type ExcalidrawDiamondElement = _ExcalidrawElementBase & {
|
|
65
71
|
type: "diamond";
|
|
66
72
|
};
|
|
67
|
-
export
|
|
73
|
+
export type ExcalidrawEllipseElement = _ExcalidrawElementBase & {
|
|
68
74
|
type: "ellipse";
|
|
69
75
|
};
|
|
70
|
-
export
|
|
76
|
+
export type ExcalidrawEmbeddableElement = _ExcalidrawElementBase & Readonly<{
|
|
77
|
+
type: "embeddable";
|
|
78
|
+
/**
|
|
79
|
+
* indicates whether the embeddable src (url) has been validated for rendering.
|
|
80
|
+
* null value indicates that the validation is pending. We reset the
|
|
81
|
+
* value on each restore (or url change) so that we can guarantee
|
|
82
|
+
* the validation came from a trusted source (the editor). Also because we
|
|
83
|
+
* may not have access to host-app supplied url validator during restore.
|
|
84
|
+
*/
|
|
85
|
+
validated: boolean | null;
|
|
86
|
+
}>;
|
|
87
|
+
export type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
|
|
71
88
|
type: "image";
|
|
72
89
|
fileId: FileId | null;
|
|
73
90
|
/** whether respective file is persisted */
|
|
@@ -75,22 +92,26 @@ export declare type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
|
|
|
75
92
|
/** X and Y scale factors <-1, 1>, used for image axis flipping */
|
|
76
93
|
scale: [number, number];
|
|
77
94
|
}>;
|
|
78
|
-
export
|
|
95
|
+
export type InitializedExcalidrawImageElement = MarkNonNullable<ExcalidrawImageElement, "fileId">;
|
|
96
|
+
export type ExcalidrawFrameElement = _ExcalidrawElementBase & {
|
|
97
|
+
type: "frame";
|
|
98
|
+
name: string | null;
|
|
99
|
+
};
|
|
79
100
|
/**
|
|
80
101
|
* These are elements that don't have any additional properties.
|
|
81
102
|
*/
|
|
82
|
-
export
|
|
103
|
+
export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
|
|
83
104
|
/**
|
|
84
105
|
* ExcalidrawElement should be JSON serializable and (eventually) contain
|
|
85
106
|
* no computed data. The list of all ExcalidrawElements should be shareable
|
|
86
107
|
* between peers and contain no state local to the peer.
|
|
87
108
|
*/
|
|
88
|
-
export
|
|
89
|
-
export
|
|
109
|
+
export type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement | ExcalidrawFrameElement | ExcalidrawEmbeddableElement;
|
|
110
|
+
export type NonDeleted<TElement extends ExcalidrawElement> = TElement & {
|
|
90
111
|
isDeleted: boolean;
|
|
91
112
|
};
|
|
92
|
-
export
|
|
93
|
-
export
|
|
113
|
+
export type NonDeletedExcalidrawElement = NonDeleted<ExcalidrawElement>;
|
|
114
|
+
export type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
|
|
94
115
|
type: "text";
|
|
95
116
|
fontSize: number;
|
|
96
117
|
fontFamily: FontFamilyValues;
|
|
@@ -100,19 +121,26 @@ export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
|
|
|
100
121
|
verticalAlign: VerticalAlign;
|
|
101
122
|
containerId: ExcalidrawGenericElement["id"] | null;
|
|
102
123
|
originalText: string;
|
|
124
|
+
/**
|
|
125
|
+
* Unitless line height (aligned to W3C). To get line height in px, multiply
|
|
126
|
+
* with font size (using `getLineHeightInPx` helper).
|
|
127
|
+
*/
|
|
128
|
+
lineHeight: number & {
|
|
129
|
+
_brand: "unitlessLineHeight";
|
|
130
|
+
};
|
|
103
131
|
}>;
|
|
104
|
-
export
|
|
105
|
-
export
|
|
106
|
-
export
|
|
132
|
+
export type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement | ExcalidrawEmbeddableElement | ExcalidrawFrameElement;
|
|
133
|
+
export type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawArrowElement;
|
|
134
|
+
export type ExcalidrawTextElementWithContainer = {
|
|
107
135
|
containerId: ExcalidrawTextContainer["id"];
|
|
108
136
|
} & ExcalidrawTextElement;
|
|
109
|
-
export
|
|
137
|
+
export type PointBinding = {
|
|
110
138
|
elementId: ExcalidrawBindableElement["id"];
|
|
111
139
|
focus: number;
|
|
112
140
|
gap: number;
|
|
113
141
|
};
|
|
114
|
-
export
|
|
115
|
-
export
|
|
142
|
+
export type Arrowhead = "arrow" | "bar" | "dot" | "triangle";
|
|
143
|
+
export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
|
|
116
144
|
type: "line" | "arrow";
|
|
117
145
|
points: readonly Point[];
|
|
118
146
|
lastCommittedPoint: Point | null;
|
|
@@ -121,17 +149,17 @@ export declare type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<
|
|
|
121
149
|
startArrowhead: Arrowhead | null;
|
|
122
150
|
endArrowhead: Arrowhead | null;
|
|
123
151
|
}>;
|
|
124
|
-
export
|
|
152
|
+
export type ExcalidrawArrowElement = ExcalidrawLinearElement & Readonly<{
|
|
125
153
|
type: "arrow";
|
|
126
154
|
}>;
|
|
127
|
-
export
|
|
155
|
+
export type ExcalidrawFreeDrawElement = _ExcalidrawElementBase & Readonly<{
|
|
128
156
|
type: "freedraw";
|
|
129
157
|
points: readonly Point[];
|
|
130
158
|
pressures: readonly number[];
|
|
131
159
|
simulatePressure: boolean;
|
|
132
160
|
lastCommittedPoint: Point | null;
|
|
133
161
|
}>;
|
|
134
|
-
export
|
|
162
|
+
export type FileId = string & {
|
|
135
163
|
_brand: "FileId";
|
|
136
164
|
};
|
|
137
165
|
export {};
|
package/types/emitter.d.ts
CHANGED
package/types/errors.d.ts
CHANGED
package/types/frame.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ExcalidrawElement, ExcalidrawFrameElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
|
|
2
|
+
import { AppClassProperties, AppState, StaticCanvasAppState } from "./types";
|
|
3
|
+
import { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
|
|
4
|
+
export declare const bindElementsToFramesAfterDuplication: (nextElements: ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
|
|
5
|
+
export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
|
|
6
|
+
export declare const isElementContainingFrame: (elements: readonly ExcalidrawElement[], element: ExcalidrawElement, frame: ExcalidrawFrameElement) => boolean;
|
|
7
|
+
export declare const getElementsIntersectingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
|
|
8
|
+
export declare const elementsAreInFrameBounds: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => boolean;
|
|
9
|
+
export declare const elementOverlapsWithFrame: (element: ExcalidrawElement, frame: ExcalidrawFrameElement) => boolean;
|
|
10
|
+
export declare const isCursorInFrame: (cursorCoords: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}, frame: NonDeleted<ExcalidrawFrameElement>) => boolean;
|
|
14
|
+
export declare const groupsAreAtLeastIntersectingTheFrame: (elements: readonly NonDeletedExcalidrawElement[], groupIds: readonly string[], frame: ExcalidrawFrameElement) => boolean;
|
|
15
|
+
export declare const groupsAreCompletelyOutOfFrame: (elements: readonly NonDeletedExcalidrawElement[], groupIds: readonly string[], frame: ExcalidrawFrameElement) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Returns a map of frameId to frame elements. Includes empty frames.
|
|
18
|
+
*/
|
|
19
|
+
export declare const groupByFrames: (elements: readonly ExcalidrawElement[]) => Map<string, ExcalidrawElement[]>;
|
|
20
|
+
export declare const getFrameElements: (allElements: ExcalidrawElementsIncludingDeleted, frameId: string) => ExcalidrawElement[];
|
|
21
|
+
export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
|
|
22
|
+
export declare const getElementsInNewFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement) => ExcalidrawElement[];
|
|
23
|
+
export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap?: Map<string, ExcalidrawElement>) => ExcalidrawFrameElement | null;
|
|
24
|
+
export declare const addElementsToFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToAdd: NonDeletedExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
|
|
25
|
+
export declare const removeElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToRemove: NonDeletedExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
|
|
26
|
+
export declare const removeAllElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
|
|
27
|
+
export declare const replaceAllElementsInFrame: (allElements: ExcalidrawElementsIncludingDeleted, nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
|
|
28
|
+
/** does not mutate elements, but returns new ones */
|
|
29
|
+
export declare const updateFrameMembershipOfSelectedElements: (allElements: ExcalidrawElementsIncludingDeleted, appState: AppState, app: AppClassProperties) => ExcalidrawElementsIncludingDeleted;
|
|
30
|
+
/**
|
|
31
|
+
* filters out elements that are inside groups that contain a frame element
|
|
32
|
+
* anywhere in the group tree
|
|
33
|
+
*/
|
|
34
|
+
export declare const omitGroupsContainingFrames: (allElements: ExcalidrawElementsIncludingDeleted, selectedElements?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
35
|
+
/**
|
|
36
|
+
* depending on the appState, return target frame, which is the frame the given element
|
|
37
|
+
* is going to be added to or remove from
|
|
38
|
+
*/
|
|
39
|
+
export declare const getTargetFrame: (element: ExcalidrawElement, appState: StaticCanvasAppState) => ExcalidrawFrameElement | null;
|
|
40
|
+
export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ExcalidrawElementsIncludingDeleted, appState: StaticCanvasAppState) => boolean;
|
package/types/ga.d.ts
CHANGED
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
* See GAPoint, GALine, GADirection and GATransform modules for common
|
|
17
17
|
* operations.
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
19
|
+
export type Point = NVector;
|
|
20
|
+
export type Direction = NVector;
|
|
21
|
+
export type Line = NVector;
|
|
22
|
+
export type Transform = NVector;
|
|
23
23
|
export declare const point: (x: number, y: number) => NVector;
|
|
24
24
|
export declare const origin: () => NVector;
|
|
25
25
|
export declare const direction: (x: number, y: number) => NVector;
|
|
26
26
|
export declare const offset: (x: number, y: number) => NVector;
|
|
27
|
-
|
|
27
|
+
type NVector = readonly [
|
|
28
28
|
number,
|
|
29
29
|
number,
|
|
30
30
|
number,
|
package/types/groups.d.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { GroupId, ExcalidrawElement, NonDeleted } from "./element/types";
|
|
2
|
-
import { AppState } from "./types";
|
|
3
|
-
|
|
1
|
+
import { GroupId, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
|
|
2
|
+
import { AppClassProperties, AppState, InteractiveCanvasAppState } from "./types";
|
|
3
|
+
import { Mutable } from "./utility-types";
|
|
4
|
+
export declare const selectGroup: (groupId: GroupId, appState: InteractiveCanvasAppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => Pick<InteractiveCanvasAppState, "selectedGroupIds" | "selectedElementIds" | "editingGroupId">;
|
|
5
|
+
export declare const selectGroupsForSelectedElements: {
|
|
6
|
+
(appState: Pick<AppState, "selectedElementIds" | "editingGroupId">, elements: readonly NonDeletedExcalidrawElement[], prevAppState: InteractiveCanvasAppState, app: AppClassProperties | null): Mutable<Pick<InteractiveCanvasAppState, "selectedGroupIds" | "editingGroupId" | "selectedElementIds">>;
|
|
7
|
+
clearCache(): void;
|
|
8
|
+
};
|
|
4
9
|
/**
|
|
5
10
|
* If the element's group is selected, don't render an individual
|
|
6
11
|
* selection border around it.
|
|
7
12
|
*/
|
|
8
|
-
export declare const isSelectedViaGroup: (appState:
|
|
9
|
-
export declare const getSelectedGroupForElement: (appState:
|
|
10
|
-
export declare const getSelectedGroupIds: (appState:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
export declare const selectGroupsForSelectedElements: (appState: AppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => AppState;
|
|
13
|
+
export declare const isSelectedViaGroup: (appState: InteractiveCanvasAppState, element: ExcalidrawElement) => boolean;
|
|
14
|
+
export declare const getSelectedGroupForElement: (appState: InteractiveCanvasAppState, element: ExcalidrawElement) => string | undefined;
|
|
15
|
+
export declare const getSelectedGroupIds: (appState: InteractiveCanvasAppState) => GroupId[];
|
|
16
|
+
export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: InteractiveCanvasAppState) => {
|
|
17
|
+
[groupId: string]: boolean;
|
|
18
|
+
};
|
|
16
19
|
export declare const editGroupForSelectedElement: (appState: AppState, element: NonDeleted<ExcalidrawElement>) => AppState;
|
|
17
20
|
export declare const isElementInGroup: (element: ExcalidrawElement, groupId: string) => boolean;
|
|
18
21
|
export declare const getElementsInGroup: (elements: readonly ExcalidrawElement[], groupId: string) => ExcalidrawElement[];
|
|
@@ -25,3 +28,4 @@ export declare const removeFromSelectedGroups: (groupIds: ExcalidrawElement["gro
|
|
|
25
28
|
[groupId: string]: boolean;
|
|
26
29
|
}) => string[];
|
|
27
30
|
export declare const getMaximumGroups: (elements: ExcalidrawElement[]) => ExcalidrawElement[][];
|
|
31
|
+
export declare const elementsAreInSameGroup: (elements: ExcalidrawElement[]) => boolean;
|
package/types/history.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ export interface HistoryEntry {
|
|
|
5
5
|
elements: ExcalidrawElement[];
|
|
6
6
|
}
|
|
7
7
|
declare const clearAppStatePropertiesForHistory: (appState: AppState) => {
|
|
8
|
-
selectedElementIds: {
|
|
9
|
-
[id: string]:
|
|
10
|
-
}
|
|
8
|
+
selectedElementIds: Readonly<{
|
|
9
|
+
[id: string]: true;
|
|
10
|
+
}>;
|
|
11
11
|
selectedGroupIds: {
|
|
12
12
|
[groupId: string]: boolean;
|
|
13
13
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LibraryItem } from "../types";
|
|
2
|
+
export type SvgCache = Map<LibraryItem["id"], SVGSVGElement>;
|
|
3
|
+
export declare const libraryItemSvgsCache: import("jotai").PrimitiveAtom<SvgCache> & {
|
|
4
|
+
init: SvgCache;
|
|
5
|
+
};
|
|
6
|
+
export declare const useLibraryItemSvg: (id: LibraryItem["id"] | null, elements: LibraryItem["elements"] | undefined, svgCache: SvgCache) => SVGSVGElement | undefined;
|
|
7
|
+
export declare const useLibraryCache: () => {
|
|
8
|
+
clearLibraryCache: () => void;
|
|
9
|
+
deleteItemsFromLibraryCache: (items: LibraryItem["id"][]) => void;
|
|
10
|
+
svgCache: SvgCache;
|
|
11
|
+
};
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare function useOutsideClick<T extends HTMLElement>(ref: React.RefObject<T>,
|
|
2
|
+
/** if performance is of concern, memoize the callback */
|
|
3
|
+
callback: (event: Event) => void,
|
|
4
|
+
/**
|
|
5
|
+
* Optional callback which is called on every click.
|
|
6
|
+
*
|
|
7
|
+
* Should return `true` if click should be considered as inside the container,
|
|
8
|
+
* and `false` if it falls outside and should call the `callback`.
|
|
9
|
+
*
|
|
10
|
+
* Returning `true` overrides the default behavior and `callback` won't be
|
|
11
|
+
* called.
|
|
12
|
+
*
|
|
13
|
+
* Returning `undefined` will fallback to the default behavior.
|
|
14
|
+
*/
|
|
15
|
+
isInside?: (event: Event & {
|
|
16
|
+
target: HTMLElement;
|
|
17
|
+
},
|
|
18
|
+
/** the element of the passed ref */
|
|
19
|
+
container: T) => boolean | undefined): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useScrollPosition: <T extends HTMLElement>(elementRef: import("react").RefObject<T>) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useStable: <T extends Record<string, any>>(value: T) => T;
|
package/types/i18n.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import fallbackLangData from "./locales/en.json";
|
|
2
|
+
import { NestedKeyOf } from "./utility-types";
|
|
1
3
|
export interface Language {
|
|
2
4
|
code: string;
|
|
3
5
|
label: string;
|
|
4
6
|
rtl?: boolean;
|
|
5
7
|
}
|
|
8
|
+
export type TranslationKeys = NestedKeyOf<typeof fallbackLangData>;
|
|
6
9
|
export declare const defaultLang: {
|
|
7
10
|
code: string;
|
|
8
11
|
label: string;
|
|
@@ -10,6 +13,12 @@ export declare const defaultLang: {
|
|
|
10
13
|
export declare const languages: Language[];
|
|
11
14
|
export declare const setLanguage: (lang: Language) => Promise<void>;
|
|
12
15
|
export declare const getLanguage: () => Language;
|
|
13
|
-
export declare const t: (path:
|
|
16
|
+
export declare const t: (path: NestedKeyOf<typeof fallbackLangData>, replacement?: {
|
|
14
17
|
[key: string]: string | number;
|
|
15
|
-
} | undefined) => string;
|
|
18
|
+
} | null | undefined, fallback?: string) => string;
|
|
19
|
+
export declare const useI18n: () => {
|
|
20
|
+
t: (path: NestedKeyOf<typeof fallbackLangData>, replacement?: {
|
|
21
|
+
[key: string]: string | number;
|
|
22
|
+
} | null | undefined, fallback?: string) => string;
|
|
23
|
+
langCode: string;
|
|
24
|
+
};
|