@dwelle/excalidraw 0.4.0-e80989b → 0.4.0-eadd4b9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +458 -0
- package/README.md +16 -1424
- package/dist/excalidraw.development.js +1829 -500
- package/dist/excalidraw.production.min.js +1 -1
- package/dist/excalidraw.production.min.js.LICENSE.txt +20 -0
- package/package.json +3 -3
- package/types/actions/actionAddToLibrary.d.ts +68 -34
- package/types/actions/actionAlign.d.ts +12 -18
- package/types/actions/actionBoundText.d.ts +158 -19
- package/types/actions/actionCanvas.d.ts +430 -118
- package/types/actions/actionClipboard.d.ts +132 -59
- package/types/actions/actionDeleteSelected.d.ts +72 -41
- package/types/actions/actionDistribute.d.ts +2 -6
- package/types/actions/actionDuplicateSelection.d.ts +2 -4
- package/types/actions/actionElementLock.d.ts +254 -0
- package/types/actions/actionExport.d.ts +215 -131
- package/types/actions/actionFinalize.d.ts +47 -27
- package/types/actions/actionFlip.d.ts +2 -4
- package/types/actions/actionFrame.d.ts +397 -0
- package/types/actions/actionGroup.d.ts +6 -10
- package/types/actions/actionHistory.d.ts +1 -1
- package/types/actions/actionLinearEditor.d.ts +25 -13
- package/types/actions/actionMenu.d.ts +73 -46
- package/types/actions/actionNavigate.d.ts +2 -3
- package/types/actions/actionProperties.d.ts +315 -198
- package/types/actions/actionStyles.d.ts +23 -12
- package/types/actions/actionToggleGridMode.d.ts +25 -12
- package/types/actions/actionToggleStats.d.ts +24 -12
- package/types/actions/actionToggleViewMode.d.ts +25 -12
- package/types/actions/actionToggleZenMode.d.ts +25 -12
- package/types/actions/actionZindex.d.ts +8 -16
- package/types/actions/index.d.ts +1 -1
- package/types/actions/manager.d.ts +3 -2
- package/types/actions/shortcuts.d.ts +2 -1
- package/types/actions/types.d.ts +13 -11
- package/types/appState.d.ts +16 -12
- package/types/charts.d.ts +2 -2
- package/types/clients.d.ts +5 -6
- package/types/clipboard.d.ts +2 -2
- package/types/colors.d.ts +60 -5
- package/types/components/Actions.d.ts +5 -5
- package/types/components/ActiveConfirmDialog.d.ts +4 -0
- package/types/components/App.d.ts +52 -68
- package/types/components/Avatar.d.ts +1 -2
- package/types/components/BraveMeasureTextError.d.ts +2 -0
- package/types/components/Button.d.ts +17 -0
- package/types/components/ButtonIconSelect.d.ts +11 -3
- package/types/components/Card.d.ts +7 -0
- package/types/components/ColorPicker/ColorInput.d.ts +7 -0
- package/types/components/ColorPicker/ColorPicker.d.ts +19 -0
- package/types/components/ColorPicker/CustomColorList.d.ts +8 -0
- package/types/components/ColorPicker/HotkeyLabel.d.ts +8 -0
- package/types/components/ColorPicker/Picker.d.ts +18 -0
- package/types/components/ColorPicker/PickerColorList.d.ts +10 -0
- package/types/components/ColorPicker/PickerHeading.d.ts +5 -0
- package/types/components/ColorPicker/ShadeList.d.ts +8 -0
- package/types/components/ColorPicker/TopPicks.d.ts +9 -0
- package/types/components/ColorPicker/colorPickerUtils.d.ts +21 -0
- package/types/components/ColorPicker/keyboardNavHandlers.d.ts +21 -0
- package/types/components/ContextMenu.d.ts +9 -22
- package/types/components/DefaultSidebar.d.ts +30 -0
- package/types/components/Dialog.d.ts +2 -4
- package/types/components/ErrorDialog.d.ts +3 -2
- package/types/components/EyeDropper.d.ts +18 -0
- package/types/components/FilledButton.d.ts +16 -0
- package/types/components/FixedSideContainer.d.ts +1 -1
- package/types/components/HandButton.d.ts +10 -0
- package/types/components/HelpButton.d.ts +1 -2
- package/types/components/HintViewer.d.ts +2 -2
- package/types/components/HomeButton.d.ts +1 -1
- package/types/components/ImageExportDialog.d.ts +8 -13
- package/types/components/Island.d.ts +1 -1
- package/types/components/JSONExportDialog.d.ts +6 -4
- package/types/components/LayerUI.d.ts +7 -15
- package/types/components/LibraryMenu.d.ts +13 -14
- package/types/components/LibraryMenuBrowseButton.d.ts +2 -2
- package/types/components/LibraryMenuControlButtons.d.ts +9 -0
- package/types/components/LibraryMenuHeaderContent.d.ts +11 -5
- package/types/components/LibraryMenuItems.d.ts +6 -7
- package/types/components/LibraryMenuSection.d.ts +22 -0
- package/types/components/LibraryUnit.d.ts +7 -3
- package/types/components/LockButton.d.ts +1 -2
- package/types/components/MobileMenu.d.ts +8 -11
- package/types/components/PasteChartDialog.d.ts +4 -5
- package/types/components/PenModeButton.d.ts +1 -1
- package/types/components/Popover.d.ts +1 -1
- package/types/components/ProjectName.d.ts +2 -1
- package/types/components/PublishLibrary.d.ts +2 -2
- package/types/components/RadioGroup.d.ts +12 -0
- package/types/components/Sidebar/Sidebar.d.ts +66 -63
- package/types/components/Sidebar/SidebarHeader.d.ts +6 -19
- package/types/components/Sidebar/SidebarTab.d.ts +9 -0
- package/types/components/Sidebar/SidebarTabTrigger.d.ts +10 -0
- package/types/components/Sidebar/SidebarTabTriggers.d.ts +7 -0
- package/types/components/Sidebar/SidebarTabs.d.ts +7 -0
- package/types/components/Sidebar/SidebarTrigger.d.ts +6 -0
- package/types/components/Sidebar/common.d.ts +24 -7
- package/types/components/Spinner.d.ts +2 -1
- package/types/components/Stack.d.ts +4 -3
- package/types/components/Stats.d.ts +3 -3
- package/types/components/Switch.d.ts +9 -0
- package/types/components/ToolButton.d.ts +6 -5
- package/types/components/Tooltip.d.ts +1 -1
- package/types/components/Trans.d.ts +8 -0
- package/types/components/UserList.d.ts +0 -2
- package/types/components/dropdownMenu/DropdownMenu.d.ts +67 -0
- package/types/components/dropdownMenu/DropdownMenuContent.d.ts +15 -0
- package/types/components/dropdownMenu/DropdownMenuGroup.d.ts +11 -0
- package/types/components/dropdownMenu/DropdownMenuItem.d.ts +12 -0
- package/types/components/dropdownMenu/DropdownMenuItemContent.d.ts +6 -0
- package/types/components/dropdownMenu/DropdownMenuItemCustom.d.ts +6 -0
- package/types/components/dropdownMenu/DropdownMenuItemLink.d.ts +13 -0
- package/types/components/dropdownMenu/DropdownMenuSeparator.d.ts +5 -0
- package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +11 -0
- package/types/components/dropdownMenu/common.d.ts +6 -0
- package/types/components/dropdownMenu/dropdownMenuUtils.d.ts +3 -0
- package/types/components/footer/Footer.d.ts +12 -0
- package/types/components/footer/FooterCenter.d.ts +8 -0
- package/types/components/hoc/withInternalFallback.d.ts +4 -0
- package/types/components/icons.d.ts +13 -2
- package/types/components/live-collaboration/LiveCollaborationTrigger.d.ts +10 -0
- package/types/components/main-menu/DefaultItems.d.ts +47 -0
- package/types/components/main-menu/MainMenu.d.ts +61 -0
- package/types/components/welcome-screen/WelcomeScreen.Center.d.ts +58 -0
- package/types/components/welcome-screen/WelcomeScreen.Hints.d.ts +19 -0
- package/types/components/welcome-screen/WelcomeScreen.d.ts +85 -0
- package/types/constants.d.ts +73 -16
- package/types/context/tunnels.d.ts +18 -0
- package/types/context/ui-appState.d.ts +4 -0
- package/types/data/blob.d.ts +3 -2
- package/types/data/encode.d.ts +1 -1
- package/types/data/filesystem.d.ts +2 -1
- package/types/data/index.d.ts +1 -1
- package/types/data/library.d.ts +3 -45
- package/types/data/restore.d.ts +10 -4
- package/types/data/types.d.ts +3 -5
- package/types/element/Hyperlink.d.ts +27 -18
- package/types/element/binding.d.ts +3 -3
- package/types/element/bounds.d.ts +32 -7
- package/types/element/collision.d.ts +7 -7
- package/types/element/dragElements.d.ts +2 -1
- package/types/element/image.d.ts +11 -1
- package/types/element/index.d.ts +3 -2
- package/types/element/linearElementEditor.d.ts +24 -13
- package/types/element/mutateElement.d.ts +2 -1
- package/types/element/newElement.d.ts +37 -11
- package/types/element/resizeElements.d.ts +1 -0
- package/types/element/showSelectedShapeActions.d.ts +2 -2
- package/types/element/sortElements.d.ts +2 -0
- package/types/element/textElement.d.ts +40 -5
- package/types/element/textWysiwyg.d.ts +6 -1
- package/types/element/transformHandles.d.ts +12 -5
- package/types/element/typeChecks.d.ts +12 -2
- package/types/element/types.d.ts +53 -36
- package/types/emitter.d.ts +1 -1
- package/types/errors.d.ts +1 -1
- package/types/frame.d.ts +40 -0
- package/types/ga.d.ts +5 -5
- package/types/groups.d.ts +4 -0
- package/types/hooks/useCreatePortalContainer.d.ts +4 -0
- package/types/hooks/useLibraryItemSvg.d.ts +11 -0
- package/types/hooks/useOutsideClick.d.ts +19 -1
- package/types/hooks/useScrollPosition.d.ts +2 -0
- package/types/hooks/useTransition.d.ts +2 -0
- package/types/i18n.d.ts +7 -1
- package/types/jotai.d.ts +20 -108
- package/types/keys.d.ts +4 -4
- package/types/math.d.ts +4 -1
- package/types/packages/excalidraw/example/App.d.ts +7 -1
- package/types/packages/excalidraw/example/CustomFooter.d.ts +5 -0
- package/types/packages/excalidraw/example/MobileFooter.d.ts +5 -0
- package/types/packages/excalidraw/example/initialData.d.ts +6 -0
- package/types/packages/excalidraw/index.d.ts +17 -3
- package/types/packages/utils.d.ts +26 -25
- package/types/renderer/renderElement.d.ts +7 -5
- package/types/renderer/renderScene.d.ts +13 -6
- package/types/renderer/roundRect.d.ts +1 -1
- package/types/scene/Scene.d.ts +12 -5
- package/types/scene/comparisons.d.ts +1 -1
- package/types/scene/export.d.ts +157 -10
- package/types/scene/index.d.ts +1 -1
- package/types/scene/selection.d.ts +15 -5
- package/types/scene/types.d.ts +13 -5
- package/types/types.d.ts +126 -77
- package/types/utility-types.d.ts +22 -0
- package/types/utils.d.ts +40 -9
- package/types/zindex.d.ts +4 -4
- package/types/actions/actionToggleLock.d.ts +0 -116
- package/types/components/ActiveFile.d.ts +0 -7
- package/types/components/ClearCanvas.d.ts +0 -4
- package/types/components/CollabButton.d.ts +0 -6
- package/types/components/ColorPicker.d.ts +0 -14
- package/types/components/Footer.d.ts +0 -10
- package/types/components/LibraryButton.d.ts +0 -8
- package/types/components/MenuItem.d.ts +0 -11
- package/types/components/MenuUtils.d.ts +0 -1
- package/types/components/SingleLibraryItem.d.ts +0 -10
- package/types/components/WelcomeScreen.d.ts +0 -10
- package/types/components/WelcomeScreenDecor.d.ts +0 -6
- package/types/components/hoc/withUpstreamOverride.d.ts +0 -10
|
@@ -2,18 +2,32 @@ import React from "react";
|
|
|
2
2
|
import "../../css/app.scss";
|
|
3
3
|
import "../../css/styles.scss";
|
|
4
4
|
import { ExcalidrawAPIRefValue, ExcalidrawProps } from "../../types";
|
|
5
|
-
|
|
5
|
+
import Footer from "../../components/footer/FooterCenter";
|
|
6
|
+
import MainMenu from "../../components/main-menu/MainMenu";
|
|
7
|
+
import WelcomeScreen from "../../components/welcome-screen/WelcomeScreen";
|
|
8
|
+
import LiveCollaborationTrigger from "../../components/live-collaboration/LiveCollaborationTrigger";
|
|
9
|
+
type PublicExcalidrawProps = Omit<ExcalidrawProps, "forwardedRef">;
|
|
6
10
|
export declare const Excalidraw: React.MemoExoticComponent<React.ForwardRefExoticComponent<PublicExcalidrawProps & React.RefAttributes<ExcalidrawAPIRefValue>>>;
|
|
7
11
|
export { getSceneVersion, isInvisiblySmallElement, getNonDeletedElements, } from "../../element";
|
|
8
|
-
export { defaultLang, languages } from "../../i18n";
|
|
12
|
+
export { defaultLang, useI18n, languages } from "../../i18n";
|
|
9
13
|
export { restore, restoreAppState, restoreElements, restoreLibraryItems, } from "../../data/restore";
|
|
10
|
-
export {
|
|
14
|
+
export { exportToBlob, exportToSvg, serializeAsJSON, serializeLibraryAsJSON, loadLibraryFromBlob, loadFromBlob, loadSceneOrLibraryFromBlob, getFreeDrawSvgPath, exportToClipboard, mergeLibraryItems, } from "../../packages/utils";
|
|
11
15
|
export { isLinearElement } from "../../element/typeChecks";
|
|
12
16
|
export { FONT_FAMILY, THEME, MIME_TYPES } from "../../constants";
|
|
13
17
|
export { mutateElement, newElementWith, bumpVersion, } from "../../element/mutateElement";
|
|
14
18
|
export { parseLibraryTokensFromUrl, useHandleLibrary, } from "../../data/library";
|
|
15
19
|
export { sceneCoordsToViewportCoords, viewportCoordsToSceneCoords, } from "../../utils";
|
|
16
20
|
export { Sidebar } from "../../components/Sidebar/Sidebar";
|
|
21
|
+
export { Button } from "../../components/Button";
|
|
22
|
+
export { Footer };
|
|
23
|
+
export { MainMenu };
|
|
24
|
+
export { useDevice } from "../../components/App";
|
|
25
|
+
export { WelcomeScreen };
|
|
26
|
+
export { LiveCollaborationTrigger };
|
|
27
|
+
export { DefaultSidebar } from "../../components/DefaultSidebar";
|
|
17
28
|
export { getDefaultAppState, cleanAppStateForExport, clearAppStateForLocalStorage, } from "../../appState";
|
|
18
29
|
export { jotaiScope, jotaiStore } from "../../jotai";
|
|
19
30
|
export { libraryItemsAtom } from "../../data/library";
|
|
31
|
+
export { exportToCanvas } from "../../scene/export";
|
|
32
|
+
export * as icons from "../../components/icons";
|
|
33
|
+
export * as actions from "../../actions/index";
|
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ExcalidrawElement, NonDeleted } from "../element/types";
|
|
1
|
+
import { ExportToCanvasConfig, ExportToCanvasData } from "../scene/export";
|
|
3
2
|
import { MIME_TYPES } from "../constants";
|
|
4
3
|
export { MIME_TYPES };
|
|
5
|
-
|
|
6
|
-
elements: readonly NonDeleted<ExcalidrawElement>[];
|
|
7
|
-
appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
|
|
8
|
-
files: BinaryFiles | null;
|
|
9
|
-
maxWidthOrHeight?: number;
|
|
10
|
-
getDimensions?: (width: number, height: number) => {
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
scale?: number;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare const exportToCanvas: ({ elements, appState, files, maxWidthOrHeight, getDimensions, exportPadding, }: ExportOpts & {
|
|
17
|
-
exportPadding?: number | undefined;
|
|
18
|
-
}) => Promise<HTMLCanvasElement>;
|
|
19
|
-
export declare const exportToBlob: (opts: ExportOpts & {
|
|
4
|
+
type ExportToBlobConfig = ExportToCanvasConfig & {
|
|
20
5
|
mimeType?: string;
|
|
21
6
|
quality?: number;
|
|
22
|
-
|
|
7
|
+
};
|
|
8
|
+
type ExportToSvgConfig = Pick<ExportToCanvasConfig, "canvasBackgroundColor" | "padding" | "theme">;
|
|
9
|
+
export declare const exportToBlob: ({ data, config, }: {
|
|
10
|
+
data: ExportToCanvasData;
|
|
11
|
+
config?: ExportToBlobConfig | undefined;
|
|
23
12
|
}) => Promise<Blob>;
|
|
24
|
-
export declare const exportToSvg: ({
|
|
25
|
-
|
|
13
|
+
export declare const exportToSvg: ({ data, config, }: {
|
|
14
|
+
data: ExportToCanvasData;
|
|
15
|
+
config?: ExportToSvgConfig | undefined;
|
|
26
16
|
}) => Promise<SVGSVGElement>;
|
|
27
|
-
export declare const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
17
|
+
export declare const exportToCanvas: ({ data, config, }: {
|
|
18
|
+
data: ExportToCanvasData;
|
|
19
|
+
config?: ExportToCanvasConfig | undefined;
|
|
20
|
+
}) => Promise<HTMLCanvasElement>;
|
|
21
|
+
export declare const exportToClipboard: ({ type, data, config, }: {
|
|
22
|
+
data: ExportToCanvasData;
|
|
23
|
+
} & ({
|
|
24
|
+
type: "png";
|
|
25
|
+
config?: ExportToBlobConfig | undefined;
|
|
26
|
+
} | {
|
|
27
|
+
type: "svg";
|
|
28
|
+
config?: ExportToSvgConfig | undefined;
|
|
29
|
+
} | {
|
|
30
|
+
type: "json";
|
|
31
|
+
config?: undefined;
|
|
32
|
+
})) => Promise<void>;
|
|
32
33
|
export { serializeAsJSON, serializeLibraryAsJSON } from "../data/json";
|
|
33
34
|
export { loadFromBlob, loadSceneOrLibraryFromBlob, loadLibraryFromBlob, } from "../data/blob";
|
|
34
35
|
export { getFreeDrawSvgPath } from "../renderer/renderElement";
|
|
@@ -3,19 +3,21 @@ import { RoughCanvas } from "roughjs/bin/canvas";
|
|
|
3
3
|
import { Drawable, Options } from "roughjs/bin/core";
|
|
4
4
|
import { RoughSVG } from "roughjs/bin/svg";
|
|
5
5
|
import { RenderConfig } from "../scene/types";
|
|
6
|
-
import { AppState, BinaryFiles
|
|
6
|
+
import { AppState, BinaryFiles } from "../types";
|
|
7
7
|
export interface ExcalidrawElementWithCanvas {
|
|
8
8
|
element: ExcalidrawElement | ExcalidrawTextElement;
|
|
9
9
|
canvas: HTMLCanvasElement;
|
|
10
10
|
theme: RenderConfig["theme"];
|
|
11
|
-
|
|
11
|
+
scale: number;
|
|
12
|
+
zoomValue: RenderConfig["zoom"]["value"];
|
|
12
13
|
canvasOffsetX: number;
|
|
13
14
|
canvasOffsetY: number;
|
|
14
15
|
boundTextElementVersion: number | null;
|
|
16
|
+
containingFrameOpacity: number;
|
|
15
17
|
}
|
|
16
18
|
export declare const DEFAULT_LINK_SIZE = 14;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
type ElementShape = Drawable | Drawable[] | null;
|
|
20
|
+
type ElementShapes = {
|
|
19
21
|
freedraw: Drawable | null;
|
|
20
22
|
arrow: Drawable[];
|
|
21
23
|
line: Drawable[];
|
|
@@ -28,7 +30,7 @@ export declare const invalidateShapeForElement: (element: ExcalidrawElement) =>
|
|
|
28
30
|
export declare const clearRenderCache: () => void;
|
|
29
31
|
export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
|
|
30
32
|
export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: RenderConfig, appState: AppState) => void;
|
|
31
|
-
export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, exportWithDarkMode?: boolean) => void;
|
|
33
|
+
export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, exportWithDarkMode?: boolean, exportingFrameId?: string | null) => void;
|
|
32
34
|
export declare let pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
|
|
33
35
|
export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
|
|
34
36
|
export declare function getFreeDrawPath2D(element: ExcalidrawFreeDrawElement): Path2D | undefined;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { RoughCanvas } from "roughjs/bin/canvas";
|
|
2
2
|
import { RoughSVG } from "roughjs/bin/svg";
|
|
3
|
-
import { AppState, BinaryFiles } from "../types";
|
|
4
|
-
import { NonDeletedExcalidrawElement } from "../element/types";
|
|
3
|
+
import { AppState, BinaryFiles, Zoom } from "../types";
|
|
4
|
+
import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
|
|
5
5
|
import { RenderConfig } from "../scene/types";
|
|
6
|
+
import "canvas-roundrect-polyfill";
|
|
6
7
|
export declare const DEFAULT_SPACING = 2;
|
|
7
|
-
export declare const _renderScene: ({ elements, appState,
|
|
8
|
+
export declare const _renderScene: ({ elements, appState, rc, canvas, renderConfig, }: {
|
|
8
9
|
elements: readonly NonDeletedExcalidrawElement[];
|
|
9
10
|
appState: AppState;
|
|
10
|
-
scale: number;
|
|
11
11
|
rc: RoughCanvas;
|
|
12
12
|
canvas: HTMLCanvasElement;
|
|
13
13
|
renderConfig: RenderConfig;
|
|
@@ -22,7 +22,6 @@ export declare const _renderScene: ({ elements, appState, scale, rc, canvas, ren
|
|
|
22
22
|
export declare const renderScene: <T extends boolean = false>(config: {
|
|
23
23
|
elements: readonly NonDeletedExcalidrawElement[];
|
|
24
24
|
appState: AppState;
|
|
25
|
-
scale: number;
|
|
26
25
|
rc: RoughCanvas;
|
|
27
26
|
canvas: HTMLCanvasElement;
|
|
28
27
|
renderConfig: RenderConfig;
|
|
@@ -34,8 +33,16 @@ export declare const renderScene: <T extends boolean = false>(config: {
|
|
|
34
33
|
atLeastOneVisibleElement: boolean;
|
|
35
34
|
scrollBars: import("../scene/types").ScrollBars | undefined;
|
|
36
35
|
};
|
|
37
|
-
export declare const
|
|
36
|
+
export declare const isVisibleElement: (element: ExcalidrawElement, canvasWidth: number, canvasHeight: number, viewTransformations: {
|
|
37
|
+
zoom: Zoom;
|
|
38
|
+
offsetLeft: number;
|
|
39
|
+
offsetTop: number;
|
|
40
|
+
scrollX: number;
|
|
41
|
+
scrollY: number;
|
|
42
|
+
}) => boolean;
|
|
43
|
+
export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, { offsetX, offsetY, exportWithDarkMode, exportingFrameId, }?: {
|
|
38
44
|
offsetX?: number | undefined;
|
|
39
45
|
offsetY?: number | undefined;
|
|
40
46
|
exportWithDarkMode?: boolean | undefined;
|
|
47
|
+
exportingFrameId?: string | null | undefined;
|
|
41
48
|
}) => void;
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
* @param {Number} height The height of the rectangle
|
|
9
9
|
* @param {Number} radius The corner radius
|
|
10
10
|
*/
|
|
11
|
-
export declare const roundRect: (context: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number) => void;
|
|
11
|
+
export declare const roundRect: (context: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number, strokeColor?: string) => void;
|
package/types/scene/Scene.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "../element/types";
|
|
1
|
+
import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameElement } from "../element/types";
|
|
2
2
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
type ElementIdKey = InstanceType<typeof LinearElementEditor>["elementId"];
|
|
4
|
+
type ElementKey = ExcalidrawElement | ElementIdKey;
|
|
5
|
+
type SceneStateCallback = () => void;
|
|
6
|
+
type SceneStateCallbackRemover = () => void;
|
|
7
|
+
export type ExcalidrawElementsIncludingDeleted = readonly ExcalidrawElement[];
|
|
7
8
|
declare class Scene {
|
|
8
9
|
private static sceneMapByElement;
|
|
9
10
|
private static sceneMapById;
|
|
@@ -12,9 +13,13 @@ declare class Scene {
|
|
|
12
13
|
private callbacks;
|
|
13
14
|
private nonDeletedElements;
|
|
14
15
|
private elements;
|
|
16
|
+
private nonDeletedFrames;
|
|
17
|
+
private frames;
|
|
15
18
|
private elementsMap;
|
|
16
19
|
getElementsIncludingDeleted(): readonly ExcalidrawElement[];
|
|
17
20
|
getNonDeletedElements(): readonly NonDeletedExcalidrawElement[];
|
|
21
|
+
getFramesIncludingDeleted(): readonly ExcalidrawFrameElement[];
|
|
22
|
+
getNonDeletedFrames(): readonly NonDeleted<ExcalidrawFrameElement>[];
|
|
18
23
|
getElement<T extends ExcalidrawElement>(id: T["id"]): T | null;
|
|
19
24
|
getNonDeletedElement(id: ExcalidrawElement["id"]): NonDeleted<ExcalidrawElement> | null;
|
|
20
25
|
/**
|
|
@@ -35,6 +40,8 @@ declare class Scene {
|
|
|
35
40
|
addCallback(cb: SceneStateCallback): SceneStateCallbackRemover;
|
|
36
41
|
destroy(): void;
|
|
37
42
|
insertElementAtIndex(element: ExcalidrawElement, index: number): void;
|
|
43
|
+
insertElementsAtIndex(elements: ExcalidrawElement[], index: number): void;
|
|
44
|
+
addNewElement: (element: ExcalidrawElement) => void;
|
|
38
45
|
getElementIndex(elementId: string): number;
|
|
39
46
|
}
|
|
40
47
|
export default Scene;
|
|
@@ -3,7 +3,7 @@ export declare const hasBackground: (type: string) => boolean;
|
|
|
3
3
|
export declare const hasStrokeColor: (type: string) => boolean;
|
|
4
4
|
export declare const hasStrokeWidth: (type: string) => boolean;
|
|
5
5
|
export declare const hasStrokeStyle: (type: string) => boolean;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const canChangeRoundness: (type: string) => boolean;
|
|
7
7
|
export declare const hasText: (type: string) => boolean;
|
|
8
8
|
export declare const canHaveArrowheads: (type: string) => boolean;
|
|
9
9
|
export declare const getElementAtPosition: (elements: readonly NonDeletedExcalidrawElement[], isAtPositionFn: (element: NonDeletedExcalidrawElement) => boolean) => NonDeletedExcalidrawElement | null;
|
package/types/scene/export.d.ts
CHANGED
|
@@ -1,13 +1,157 @@
|
|
|
1
|
-
import { NonDeletedExcalidrawElement } from "../element/types";
|
|
1
|
+
import { NonDeletedExcalidrawElement, Theme } from "../element/types";
|
|
2
2
|
import { AppState, BinaryFiles } from "../types";
|
|
3
|
+
import { serializeAsJSON } from "../data/json";
|
|
3
4
|
export declare const SVG_EXPORT_TAG = "<!-- svg-source:excalidraw -->";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export type ExportToCanvasData = {
|
|
6
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
7
|
+
appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
|
|
8
|
+
files: BinaryFiles | null;
|
|
9
|
+
};
|
|
10
|
+
export type ExportToCanvasConfig = {
|
|
11
|
+
theme?: Theme;
|
|
12
|
+
/**
|
|
13
|
+
* Canvas background. Valid values are:
|
|
14
|
+
*
|
|
15
|
+
* - `undefined` - the background of "appState.viewBackgroundColor" is used.
|
|
16
|
+
* - `false` - no background is used (set to "transparent").
|
|
17
|
+
* - `string` - should be a valid CSS color.
|
|
18
|
+
*
|
|
19
|
+
* @default undefined
|
|
20
|
+
*/
|
|
21
|
+
canvasBackgroundColor?: string | false;
|
|
22
|
+
/**
|
|
23
|
+
* Canvas padding in pixels. Affected by scale. Ignored if `fit` is set to
|
|
24
|
+
* `cover`.
|
|
25
|
+
*
|
|
26
|
+
* @default 10
|
|
27
|
+
*/
|
|
28
|
+
padding?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Makes sure the canvas content fits into a frame of width/height no larger
|
|
31
|
+
* than this value, while maintaining the aspect ratio.
|
|
32
|
+
*
|
|
33
|
+
* Final dimensions can get smaller/larger if used in conjunction with
|
|
34
|
+
* `scale`.
|
|
35
|
+
*/
|
|
36
|
+
maxWidthOrHeight?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Scale the canvas content to be excatly this many pixels wide/tall.
|
|
39
|
+
*
|
|
40
|
+
* Cannot be used in conjunction with `maxWidthOrHeight`.
|
|
41
|
+
*
|
|
42
|
+
* Final dimensions can get smaller/larger if used in conjunction with
|
|
43
|
+
* `scale`.
|
|
44
|
+
*/
|
|
45
|
+
widthOrHeight?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Width of the frame. Supply `x` or `y` if you want to ofsset the canvas
|
|
48
|
+
* content.
|
|
49
|
+
*
|
|
50
|
+
* If `width` omitted but `height` supplied, `width` is calculated from the
|
|
51
|
+
* the content's bounding box to preserve the aspect ratio.
|
|
52
|
+
*
|
|
53
|
+
* Defaults to the content bounding box width when both `width` and `height`
|
|
54
|
+
* are omitted.
|
|
55
|
+
*/
|
|
56
|
+
width?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Height of the frame.
|
|
59
|
+
*
|
|
60
|
+
* If `height` omitted but `width` supplied, `height` is calculated from the
|
|
61
|
+
* content's bounding box to preserve the aspect ratio.
|
|
62
|
+
*
|
|
63
|
+
* Defaults to the content bounding box height when both `width` and `height`
|
|
64
|
+
* are omitted.
|
|
65
|
+
*/
|
|
66
|
+
height?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Left canvas offset. By default the coordinate is relative to the canvas.
|
|
69
|
+
* You can switch to content coordinates by setting `origin` to `content`.
|
|
70
|
+
*
|
|
71
|
+
* Defaults to the `x` postion of the content bounding box.
|
|
72
|
+
*/
|
|
73
|
+
x?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Top canvas offset. By default the coordinate is relative to the canvas.
|
|
76
|
+
* You can switch to content coordinates by setting `origin` to `content`.
|
|
77
|
+
*
|
|
78
|
+
* Defaults to the `y` postion of the content bounding box.
|
|
79
|
+
*/
|
|
80
|
+
y?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Indicates the coordinate system of the `x` and `y` values.
|
|
83
|
+
*
|
|
84
|
+
* - `canvas` - `x` and `y` are relative to the canvas [0, 0] position.
|
|
85
|
+
* - `content` - `x` and `y` are relative to the content bounding box.
|
|
86
|
+
*
|
|
87
|
+
* @default "canvas"
|
|
88
|
+
*/
|
|
89
|
+
origin?: "canvas" | "content";
|
|
90
|
+
/**
|
|
91
|
+
* If dimensions specified and `x` and `y` are not specified, this indicates
|
|
92
|
+
* how the canvas should be scaled.
|
|
93
|
+
*
|
|
94
|
+
* Behavior aligns with the `object-fit` CSS property.
|
|
95
|
+
*
|
|
96
|
+
* - `none` - no scaling.
|
|
97
|
+
* - `contain` - scale to fit the frame.
|
|
98
|
+
* - `cover` - scale to fill the frame while maintaining aspect ratio. If
|
|
99
|
+
* content overflows, it will be cropped.
|
|
100
|
+
*
|
|
101
|
+
* @default "contain" unless `x` or `y` are specified, in which case "none"
|
|
102
|
+
* is used (forced).
|
|
103
|
+
*/
|
|
104
|
+
fit?: "none" | "contain" | "cover";
|
|
105
|
+
/**
|
|
106
|
+
* When either `x` or `y` are not specified, indicates how the canvas should
|
|
107
|
+
* be aligned on the respective axis.
|
|
108
|
+
*
|
|
109
|
+
* - `none` - canvas aligned to top left.
|
|
110
|
+
* - `center` - canvas is centered on the axis which is not specified
|
|
111
|
+
* (or both).
|
|
112
|
+
*
|
|
113
|
+
* @default "center"
|
|
114
|
+
*/
|
|
115
|
+
position?: "center" | "none";
|
|
116
|
+
/**
|
|
117
|
+
* A multiplier to increase/decrease the frame dimensions
|
|
118
|
+
* (content resolution).
|
|
119
|
+
*
|
|
120
|
+
* For example, if your canvas is 300x150 and you set scale to 2, the
|
|
121
|
+
* resulting size will be 600x300.
|
|
122
|
+
*
|
|
123
|
+
* @default 1
|
|
124
|
+
*/
|
|
125
|
+
scale?: number;
|
|
126
|
+
/**
|
|
127
|
+
* If you need to suply your own canvas, e.g. in test environments or in
|
|
128
|
+
* Node.js.
|
|
129
|
+
*
|
|
130
|
+
* Do not set `canvas.width/height` or modify the canvas context as that's
|
|
131
|
+
* handled by Excalidraw.
|
|
132
|
+
*
|
|
133
|
+
* Defaults to `document.createElement("canvas")`.
|
|
134
|
+
*/
|
|
135
|
+
createCanvas?: () => HTMLCanvasElement;
|
|
136
|
+
/**
|
|
137
|
+
* If you want to supply `width`/`height` dynamically (or derive from the
|
|
138
|
+
* content bounding box), you can use this function.
|
|
139
|
+
*
|
|
140
|
+
* Ignored if `maxWidthOrHeight`, `width`, or `height` is set.
|
|
141
|
+
*/
|
|
142
|
+
getDimensions?: (width: number, height: number) => {
|
|
143
|
+
width: number;
|
|
144
|
+
height: number;
|
|
145
|
+
scale?: number;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* This API is usually used as a precursor to searializing to Blob or PNG,
|
|
150
|
+
* but can also be used to create a canvas for other purposes.
|
|
151
|
+
*/
|
|
152
|
+
export declare const exportToCanvas: ({ data, config, }: {
|
|
153
|
+
data: ExportToCanvasData;
|
|
154
|
+
config?: ExportToCanvasConfig | undefined;
|
|
11
155
|
}) => Promise<HTMLCanvasElement>;
|
|
12
156
|
export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElement[], appState: {
|
|
13
157
|
exportBackground: boolean;
|
|
@@ -16,5 +160,8 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
|
|
|
16
160
|
viewBackgroundColor: string;
|
|
17
161
|
exportWithDarkMode?: boolean;
|
|
18
162
|
exportEmbedScene?: boolean;
|
|
19
|
-
|
|
20
|
-
|
|
163
|
+
renderFrame?: boolean;
|
|
164
|
+
}, files: BinaryFiles | null, opts?: {
|
|
165
|
+
serializeAsJSON?: () => string;
|
|
166
|
+
}) => Promise<SVGSVGElement>;
|
|
167
|
+
export declare const getExportSize: (elements: readonly NonDeletedExcalidrawElement[], padding: number, scale: number) => [number, number];
|
package/types/scene/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { isOverScrollBars } from "./scrollbars";
|
|
2
2
|
export { isSomeElementSelected, getElementsWithinSelection, getCommonAttributeOfSelectedElements, getSelectedElements, getTargetElements, } from "./selection";
|
|
3
3
|
export { calculateScrollCenter } from "./scroll";
|
|
4
|
-
export { hasBackground, hasStrokeWidth, hasStrokeStyle, canHaveArrowheads,
|
|
4
|
+
export { hasBackground, hasStrokeWidth, hasStrokeStyle, canHaveArrowheads, canChangeRoundness, getElementAtPosition, hasText, getElementsAtPosition, } from "./comparisons";
|
|
5
5
|
export { getNormalizedZoom } from "./zoom";
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
|
|
2
2
|
import { AppState } from "../types";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Frames and their containing elements are not to be selected at the same time.
|
|
5
|
+
* Given an array of selected elements, if there are frames and their containing elements
|
|
6
|
+
* we only keep the frames.
|
|
7
|
+
* @param selectedElements
|
|
8
|
+
*/
|
|
9
|
+
export declare const excludeElementsInFramesFromSelection: <T extends ExcalidrawElement>(selectedElements: readonly T[]) => T[];
|
|
10
|
+
export declare const getElementsWithinSelection: (elements: readonly NonDeletedExcalidrawElement[], selection: NonDeletedExcalidrawElement, excludeElementsInFrames?: boolean) => NonDeletedExcalidrawElement[];
|
|
11
|
+
export declare const isSomeElementSelected: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">) => boolean;
|
|
5
12
|
/**
|
|
6
13
|
* Returns common attribute (picked by `getAttribute` callback) of selected
|
|
7
14
|
* elements. If elements don't share the same value, returns `null`.
|
|
8
15
|
*/
|
|
9
|
-
export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: AppState, getAttribute: (element: ExcalidrawElement) => T) => T | null;
|
|
10
|
-
export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState,
|
|
11
|
-
|
|
16
|
+
export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, getAttribute: (element: ExcalidrawElement) => T) => T | null;
|
|
17
|
+
export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, opts?: {
|
|
18
|
+
includeBoundTextElement?: boolean;
|
|
19
|
+
includeElementsInFrames?: boolean;
|
|
20
|
+
}) => ExcalidrawElement[];
|
|
21
|
+
export declare const getTargetElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds" | "editingElement">) => ExcalidrawElement[];
|
package/types/scene/types.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { ExcalidrawTextElement } from "../element/types";
|
|
2
2
|
import { AppClassProperties, AppState } from "../types";
|
|
3
|
-
export
|
|
3
|
+
export type RenderConfig = {
|
|
4
4
|
scrollX: AppState["scrollX"];
|
|
5
5
|
scrollY: AppState["scrollY"];
|
|
6
6
|
/** null indicates transparent bg */
|
|
7
|
-
|
|
7
|
+
canvasBackgroundColor: AppState["viewBackgroundColor"] | null;
|
|
8
8
|
zoom: AppState["zoom"];
|
|
9
9
|
shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
|
|
10
10
|
theme: AppState["theme"];
|
|
11
|
+
/**
|
|
12
|
+
* canvas scale factor. Not related to zoom. In browsers, it's the
|
|
13
|
+
* devicePixelRatio. For export, it's the `appState.exportScale`
|
|
14
|
+
* (user setting) or whatever scale you want to use when exporting elsewhere.
|
|
15
|
+
*
|
|
16
|
+
* Bigger the scale, the more pixels (=quality).
|
|
17
|
+
*/
|
|
18
|
+
canvasScale: number;
|
|
11
19
|
remotePointerViewportCoords: {
|
|
12
20
|
[id: string]: {
|
|
13
21
|
x: number;
|
|
@@ -35,15 +43,15 @@ export declare type RenderConfig = {
|
|
|
35
43
|
isExporting: boolean;
|
|
36
44
|
selectionColor?: string;
|
|
37
45
|
};
|
|
38
|
-
export
|
|
46
|
+
export type SceneScroll = {
|
|
39
47
|
scrollX: number;
|
|
40
48
|
scrollY: number;
|
|
41
49
|
};
|
|
42
50
|
export interface Scene {
|
|
43
51
|
elements: ExcalidrawTextElement[];
|
|
44
52
|
}
|
|
45
|
-
export
|
|
46
|
-
export
|
|
53
|
+
export type ExportType = "png" | "clipboard" | "clipboard-svg" | "backend" | "svg";
|
|
54
|
+
export type ScrollBars = {
|
|
47
55
|
horizontal: {
|
|
48
56
|
x: number;
|
|
49
57
|
y: number;
|