@dwelle/excalidraw 0.3.47 → 0.3.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dwelle/excalidraw",
3
- "version": "0.3.47",
3
+ "version": "0.3.48",
4
4
  "main": "main.js",
5
5
  "types": "types/packages/excalidraw/index.d.ts",
6
6
  "files": [
@@ -7,7 +7,7 @@ export declare const actionChangeViewBackgroundColor: {
7
7
  appState: any;
8
8
  commitToHistory: boolean;
9
9
  };
10
- PanelComponent: ({ appState, updateData }: import("react").PropsWithChildren<import("./types").PanelComponentProps>) => JSX.Element;
10
+ PanelComponent: ({ elements, appState, updateData }: import("react").PropsWithChildren<import("./types").PanelComponentProps>) => JSX.Element;
11
11
  } & {
12
12
  keyTest?: undefined;
13
13
  };
@@ -955,6 +955,100 @@ export declare const actionChangeTextAlign: {
955
955
  } & {
956
956
  keyTest?: undefined;
957
957
  };
958
+ export declare const actionChangeVerticalAlign: {
959
+ name: "changeVerticalAlign";
960
+ perform: (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, value: any) => {
961
+ elements: ExcalidrawElement[];
962
+ appState: {
963
+ isLoading: boolean;
964
+ errorMessage: string | null;
965
+ draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
966
+ resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
967
+ multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
968
+ selectionElement: import("../element/types").NonDeletedExcalidrawElement | null;
969
+ isBindingEnabled: boolean;
970
+ startBoundElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawBindableElement> | null;
971
+ suggestedBindings: import("../element/binding").SuggestedBinding[];
972
+ editingElement: import("../element/types").NonDeletedExcalidrawElement | null;
973
+ editingLinearElement: import("../element/linearElementEditor").LinearElementEditor | null;
974
+ elementType: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw";
975
+ elementLocked: boolean;
976
+ penMode: boolean;
977
+ penDetected: boolean;
978
+ exportBackground: boolean;
979
+ exportEmbedScene: boolean;
980
+ exportWithDarkMode: boolean;
981
+ exportScale: number;
982
+ currentItemStrokeColor: string;
983
+ currentItemBackgroundColor: string;
984
+ currentItemFillStyle: import("../element/types").FillStyle;
985
+ currentItemStrokeWidth: number;
986
+ currentItemStrokeStyle: import("../element/types").StrokeStyle;
987
+ currentItemRoughness: number;
988
+ currentItemOpacity: number;
989
+ currentItemFontFamily: number;
990
+ currentItemFontSize: number;
991
+ currentItemTextAlign: TextAlign;
992
+ currentItemStrokeSharpness: import("../element/types").StrokeSharpness;
993
+ currentItemStartArrowhead: Arrowhead | null;
994
+ currentItemEndArrowhead: Arrowhead | null;
995
+ currentItemLinearStrokeSharpness: import("../element/types").StrokeSharpness;
996
+ viewBackgroundColor: string;
997
+ scrollX: number;
998
+ scrollY: number;
999
+ cursorButton: "up" | "down";
1000
+ scrolledOutside: boolean;
1001
+ name: string;
1002
+ isResizing: boolean;
1003
+ isRotating: boolean;
1004
+ zoom: Readonly<{
1005
+ value: import("../../src/types").NormalizedZoomValue;
1006
+ }>;
1007
+ openMenu: "canvas" | "shape" | null;
1008
+ openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
1009
+ lastPointerDownWith: import("../element/types").PointerType;
1010
+ selectedElementIds: {
1011
+ [id: string]: boolean;
1012
+ };
1013
+ previousSelectedElementIds: {
1014
+ [id: string]: boolean;
1015
+ };
1016
+ shouldCacheIgnoreZoom: boolean;
1017
+ showHelpDialog: boolean;
1018
+ toastMessage: string | null;
1019
+ zenModeEnabled: boolean;
1020
+ theme: string;
1021
+ gridSize: number | null;
1022
+ viewModeEnabled: boolean;
1023
+ selectedGroupIds: {
1024
+ [groupId: string]: boolean;
1025
+ };
1026
+ editingGroupId: string | null;
1027
+ width: number;
1028
+ height: number;
1029
+ offsetTop: number;
1030
+ offsetLeft: number;
1031
+ isLibraryOpen: boolean;
1032
+ fileHandle: import("browser-fs-access").FileSystemHandle | null;
1033
+ collaborators: Map<string, import("../../src/types").Collaborator>;
1034
+ showStats: boolean;
1035
+ currentChartType: import("../element/types").ChartType;
1036
+ pasteDialog: {
1037
+ shown: false;
1038
+ data: null;
1039
+ } | {
1040
+ shown: true;
1041
+ data: import("../charts").Spreadsheet;
1042
+ };
1043
+ pendingImageElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawImageElement> | null;
1044
+ showHyperlinkPopup: false | "info" | "editor";
1045
+ };
1046
+ commitToHistory: true;
1047
+ };
1048
+ PanelComponent: ({ elements, appState, updateData }: import("react").PropsWithChildren<import("./types").PanelComponentProps>) => JSX.Element;
1049
+ } & {
1050
+ keyTest?: undefined;
1051
+ };
958
1052
  export declare const actionChangeSharpness: {
959
1053
  name: "changeSharpness";
960
1054
  perform: (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, value: any) => {
@@ -2,7 +2,7 @@ export { actionDeleteSelected } from "./actionDeleteSelected";
2
2
  export { actionBringForward, actionBringToFront, actionSendBackward, actionSendToBack, } from "./actionZindex";
3
3
  export { actionSelectAll } from "./actionSelectAll";
4
4
  export { actionDuplicateSelection } from "./actionDuplicateSelection";
5
- export { actionChangeStrokeColor, actionChangeBackgroundColor, actionChangeStrokeWidth, actionChangeFillStyle, actionChangeSloppiness, actionChangeOpacity, actionChangeFontSize, actionChangeFontFamily, actionChangeTextAlign, } from "./actionProperties";
5
+ export { actionChangeStrokeColor, actionChangeBackgroundColor, actionChangeStrokeWidth, actionChangeFillStyle, actionChangeSloppiness, actionChangeOpacity, actionChangeFontSize, actionChangeFontFamily, actionChangeTextAlign, actionChangeVerticalAlign, } from "./actionProperties";
6
6
  export { actionChangeViewBackgroundColor, actionClearCanvas, actionZoomIn, actionZoomOut, actionResetZoom, actionZoomToFit, actionToggleTheme, } from "./actionCanvas";
7
7
  export { actionFinalize } from "./actionFinalize";
8
8
  export { actionChangeProjectName, actionChangeExportBackground, actionSaveToActiveFile, actionSaveFileToDisk, actionLoadScene, } from "./actionExport";
@@ -14,7 +14,7 @@ export declare type ActionResult = {
14
14
  declare type ActionFn = (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, formData: any, app: AppClassProperties) => ActionResult | Promise<ActionResult>;
15
15
  export declare type UpdaterFn = (res: ActionResult) => void;
16
16
  export declare type ActionFilterFn = (action: Action) => void;
17
- export declare type ActionName = "copy" | "cut" | "paste" | "copyAsPng" | "copyAsSvg" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyStyles" | "selectAll" | "pasteStyles" | "gridMode" | "zenMode" | "stats" | "changeStrokeColor" | "changeBackgroundColor" | "changeFillStyle" | "changeStrokeWidth" | "changeStrokeShape" | "changeSloppiness" | "changeStrokeStyle" | "changeArrowhead" | "changeOpacity" | "changeFontSize" | "toggleCanvasMenu" | "toggleEditMenu" | "undo" | "redo" | "finalize" | "changeProjectName" | "changeExportBackground" | "changeExportEmbedScene" | "changeExportScale" | "saveToActiveFile" | "saveFileToDisk" | "loadScene" | "duplicateSelection" | "deleteSelectedElements" | "changeViewBackgroundColor" | "clearCanvas" | "zoomIn" | "zoomOut" | "resetZoom" | "zoomToFit" | "zoomToSelection" | "changeFontFamily" | "changeTextAlign" | "toggleFullScreen" | "toggleShortcuts" | "group" | "ungroup" | "goToCollaborator" | "addToLibrary" | "changeSharpness" | "alignTop" | "alignBottom" | "alignLeft" | "alignRight" | "alignVerticallyCentered" | "alignHorizontallyCentered" | "distributeHorizontally" | "distributeVertically" | "flipHorizontal" | "flipVertical" | "viewMode" | "exportWithDarkMode" | "toggleTheme" | "increaseFontSize" | "decreaseFontSize" | "unbindText" | "hyperlink";
17
+ export declare type ActionName = "copy" | "cut" | "paste" | "copyAsPng" | "copyAsSvg" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyStyles" | "selectAll" | "pasteStyles" | "gridMode" | "zenMode" | "stats" | "changeStrokeColor" | "changeBackgroundColor" | "changeFillStyle" | "changeStrokeWidth" | "changeStrokeShape" | "changeSloppiness" | "changeStrokeStyle" | "changeArrowhead" | "changeOpacity" | "changeFontSize" | "toggleCanvasMenu" | "toggleEditMenu" | "undo" | "redo" | "finalize" | "changeProjectName" | "changeExportBackground" | "changeExportEmbedScene" | "changeExportScale" | "saveToActiveFile" | "saveFileToDisk" | "loadScene" | "duplicateSelection" | "deleteSelectedElements" | "changeViewBackgroundColor" | "clearCanvas" | "zoomIn" | "zoomOut" | "resetZoom" | "zoomToFit" | "zoomToSelection" | "changeFontFamily" | "changeTextAlign" | "changeVerticalAlign" | "toggleFullScreen" | "toggleShortcuts" | "group" | "ungroup" | "goToCollaborator" | "addToLibrary" | "changeSharpness" | "alignTop" | "alignBottom" | "alignLeft" | "alignRight" | "alignVerticallyCentered" | "alignHorizontallyCentered" | "distributeHorizontally" | "distributeVertically" | "flipHorizontal" | "flipVertical" | "viewMode" | "exportWithDarkMode" | "toggleTheme" | "increaseFontSize" | "decreaseFontSize" | "unbindText" | "hyperlink";
18
18
  export declare type PanelComponentProps = {
19
19
  elements: readonly ExcalidrawElement[];
20
20
  appState: AppState;
@@ -13,7 +13,7 @@ export declare const probablySupportsClipboardWriteText: boolean;
13
13
  export declare const probablySupportsClipboardBlob: boolean;
14
14
  export declare const copyToClipboard: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles) => Promise<void>;
15
15
  /**
16
- * Attemps to parse clipboard. Prefers system clipboard.
16
+ * Attempts to parse clipboard. Prefers system clipboard.
17
17
  */
18
18
  export declare const parseClipboard: (event: ClipboardEvent | null) => Promise<ClipboardData>;
19
19
  export declare const copyBlobToClipboardAsPng: (blob: Blob) => Promise<void>;
@@ -1,10 +1,15 @@
1
1
  /// <reference types="react" />
2
2
  import "./ColorPicker.scss";
3
- export declare const ColorPicker: ({ type, color, onChange, label, isActive, setActive, }: {
3
+ import { ExcalidrawElement } from "../element/types";
4
+ import { AppState } from "../types";
5
+ export declare const getCustomColors: (elements: readonly ExcalidrawElement[], type: "elementBackground" | "elementStroke") => string[];
6
+ export declare const ColorPicker: ({ type, color, onChange, label, isActive, setActive, elements, appState, }: {
4
7
  type: "canvasBackground" | "elementBackground" | "elementStroke";
5
8
  color: string | null;
6
9
  onChange: (color: string) => void;
7
10
  label: string;
8
11
  isActive: boolean;
9
12
  setActive: (active: boolean) => void;
13
+ elements: readonly ExcalidrawElement[];
14
+ appState: AppState;
10
15
  }) => JSX.Element;
@@ -164,6 +164,15 @@ export declare const TextAlignCenterIcon: React.MemoExoticComponent<({ theme }:
164
164
  export declare const TextAlignRightIcon: React.MemoExoticComponent<({ theme }: {
165
165
  theme: Theme;
166
166
  }) => JSX.Element>;
167
+ export declare const TextAlignTopIcon: React.MemoExoticComponent<({ theme }: {
168
+ theme: Theme;
169
+ }) => JSX.Element>;
170
+ export declare const TextAlignBottomIcon: React.MemoExoticComponent<({ theme }: {
171
+ theme: Theme;
172
+ }) => JSX.Element>;
173
+ export declare const TextAlignMiddleIcon: React.MemoExoticComponent<({ theme }: {
174
+ theme: Theme;
175
+ }) => JSX.Element>;
167
176
  export declare const publishIcon: JSX.Element;
168
177
  export declare const editIcon: JSX.Element;
169
178
  export declare const home: JSX.Element;
@@ -134,3 +134,8 @@ export declare const VERSIONS: {
134
134
  readonly excalidrawLibrary: 2;
135
135
  };
136
136
  export declare const BOUND_TEXT_PADDING = 5;
137
+ export declare const VERTICAL_ALIGN: {
138
+ TOP: string;
139
+ MIDDLE: string;
140
+ BOTTOM: string;
141
+ };
@@ -4,6 +4,6 @@ import { PointerDownState } from "../types";
4
4
  export declare const normalizeAngle: (angle: number) => number;
5
5
  export declare const transformElements: (pointerDownState: PointerDownState, transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], resizeArrowDirection: "origin" | "end", shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
6
6
  export declare const reshapeSingleTwoPointElement: (element: NonDeleted<ExcalidrawLinearElement>, resizeArrowDirection: "origin" | "end", shouldRotateWithDiscreteAngle: boolean, pointerX: number, pointerY: number) => void;
7
- export declare const resizeSingleElement: (stateAtResizeStart: NonDeletedExcalidrawElement, shouldMaintainAspectRatio: boolean, element: NonDeletedExcalidrawElement, transformHandleDirection: TransformHandleDirection, shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
7
+ export declare const resizeSingleElement: (originalElements: PointerDownState["originalElements"], shouldMaintainAspectRatio: boolean, element: NonDeletedExcalidrawElement, transformHandleDirection: TransformHandleDirection, shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
8
8
  export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
9
9
  export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
@@ -20,7 +20,7 @@ export declare const getApproxMinLineHeight: (font: FontString) => number;
20
20
  export declare const getMinCharWidth: (font: FontString) => number;
21
21
  export declare const getMaxCharWidth: (font: FontString) => number;
22
22
  export declare const getApproxCharsToFitInWidth: (font: FontString, width: number) => number;
23
- export declare const getBoundTextElementId: (container: ExcalidrawElement | null) => string | undefined;
23
+ export declare const getBoundTextElementId: (container: ExcalidrawElement | null) => string | null;
24
24
  export declare const getBoundTextElement: (element: ExcalidrawElement | null) => ExcalidrawTextElementWithContainer | null;
25
25
  export declare const getContainerElement: (element: (ExcalidrawElement & {
26
26
  containerId: ExcalidrawElement["id"] | null;
@@ -1,4 +1,4 @@
1
- import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawGenericElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer } from "./types";
1
+ import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawGenericElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer } from "./types";
2
2
  export declare const isGenericElement: (element: ExcalidrawElement | null) => element is ExcalidrawGenericElement;
3
3
  export declare const isInitializedImageElement: (element: ExcalidrawElement | null) => element is InitializedExcalidrawImageElement;
4
4
  export declare const isImageElement: (element: ExcalidrawElement | null) => element is ExcalidrawImageElement;
@@ -10,7 +10,7 @@ export declare const isLinearElementType: (elementType: ExcalidrawElement["type"
10
10
  export declare const isBindingElement: (element?: ExcalidrawElement | null | undefined) => element is ExcalidrawLinearElement;
11
11
  export declare const isBindingElementType: (elementType: ExcalidrawElement["type"]) => boolean;
12
12
  export declare const isBindableElement: (element: ExcalidrawElement | null) => element is ExcalidrawBindableElement;
13
- export declare const isTextBindableContainer: (element: ExcalidrawElement | null) => boolean;
13
+ export declare const isTextBindableContainer: (element: ExcalidrawElement | null) => element is ExcalidrawTextContainer;
14
14
  export declare const isExcalidrawElement: (element: any) => boolean;
15
15
  export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is ExcalidrawBindableElement;
16
16
  export declare const isBoundToContainer: (element: ExcalidrawElement | null) => element is ExcalidrawTextElementWithContainer;
@@ -1,5 +1,5 @@
1
1
  import { Point } from "../types";
2
- import { FONT_FAMILY, THEME } from "../constants";
2
+ import { FONT_FAMILY, THEME, VERTICAL_ALIGN } from "../constants";
3
3
  export declare type ChartType = "bar" | "line";
4
4
  export declare type FillStyle = "hachure" | "cross-hatch" | "solid";
5
5
  export declare type FontFamilyKeys = keyof typeof FONT_FAMILY;
@@ -13,7 +13,8 @@ export declare type PointerType = "mouse" | "pen" | "touch";
13
13
  export declare type StrokeSharpness = "round" | "sharp";
14
14
  export declare type StrokeStyle = "solid" | "dashed" | "dotted";
15
15
  export declare type TextAlign = "left" | "center" | "right";
16
- export declare type VerticalAlign = "top" | "middle";
16
+ declare type VerticalAlignKeys = keyof typeof VERTICAL_ALIGN;
17
+ export declare type VerticalAlign = typeof VERTICAL_ALIGN[VerticalAlignKeys];
17
18
  declare type _ExcalidrawElementBase = Readonly<{
18
19
  id: string;
19
20
  x: number;
@@ -99,8 +100,9 @@ export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
99
100
  originalText: string;
100
101
  }>;
101
102
  export declare type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement;
103
+ export declare type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawImageElement;
102
104
  export declare type ExcalidrawTextElementWithContainer = {
103
- containerId: ExcalidrawGenericElement["id"];
105
+ containerId: ExcalidrawTextContainer["id"];
104
106
  } & ExcalidrawTextElement;
105
107
  export declare type PointBinding = {
106
108
  elementId: ExcalidrawBindableElement["id"];
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * This maps to a standard formula `a * x + b * y + c`.
6
6
  *
7
- * `(-b, a)` correponds to a 2D vector parallel to the line. The lines
7
+ * `(-b, a)` corresponds to a 2D vector parallel to the line. The lines
8
8
  * have a natural orientation, corresponding to that vector.
9
9
  *
10
10
  * The magnitude ("norm") of the line is `sqrt(a ^ 2 + b ^ 2)`.
@@ -1,4 +1,4 @@
1
- import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
1
+ import { ExcalidrawElement, ExcalidrawTextContainer, NonDeletedExcalidrawElement } from "../element/types";
2
2
  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;
@@ -8,4 +8,4 @@ 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;
10
10
  export declare const getElementsAtPosition: (elements: readonly NonDeletedExcalidrawElement[], isAtPositionFn: (element: NonDeletedExcalidrawElement) => boolean) => NonDeletedExcalidrawElement[];
11
- export declare const getElementContainingPosition: (elements: readonly ExcalidrawElement[], x: number, y: number) => ExcalidrawElement | null;
11
+ export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], x: number, y: number) => ExcalidrawTextContainer | null;
@@ -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, canChangeSharpness, getElementAtPosition, getElementContainingPosition, hasText, getElementsAtPosition, } from "./comparisons";
4
+ export { hasBackground, hasStrokeWidth, hasStrokeStyle, canHaveArrowheads, canChangeSharpness, getElementAtPosition, getTextBindableContainerAtPosition, hasText, getElementsAtPosition, } from "./comparisons";
5
5
  export { getNormalizedZoom } from "./zoom";