@dwelle/excalidraw 0.3.29 → 0.3.30

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.29",
3
+ "version": "0.3.30",
4
4
  "main": "main.js",
5
5
  "types": "types/packages/excalidraw/index.d.ts",
6
6
  "files": [
@@ -134,3 +134,4 @@ export declare const VERSIONS: {
134
134
  readonly excalidraw: 2;
135
135
  readonly excalidrawLibrary: 2;
136
136
  };
137
+ export declare const PADDING = 30;
@@ -1,7 +1,6 @@
1
1
  import { SHAPES } from "../shapes";
2
- import Scene from "../scene/Scene";
3
2
  import { NonDeletedExcalidrawElement } from "./types";
4
3
  import { PointerDownState } from "../types";
5
- export declare const dragSelectedElements: (pointerDownState: PointerDownState, selectedElements: NonDeletedExcalidrawElement[], pointerX: number, pointerY: number, scene: Scene, lockDirection?: boolean, distanceX?: number, distanceY?: number) => void;
4
+ export declare const dragSelectedElements: (pointerDownState: PointerDownState, selectedElements: NonDeletedExcalidrawElement[], pointerX: number, pointerY: number, lockDirection?: boolean, distanceX?: number, distanceY?: number) => void;
6
5
  export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
7
6
  export declare const dragNewElement: (draggingElement: NonDeletedExcalidrawElement, elementType: typeof SHAPES[number]["value"], originX: number, originY: number, x: number, y: number, width: number, height: number, shouldMaintainAspectRatio: boolean, shouldResizeFromCenter: boolean, widthAspectRatio?: number | null | undefined) => void;
@@ -1,4 +1,4 @@
1
- import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues } from "../element/types";
1
+ import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawRectangleElement } from "../element/types";
2
2
  import { AppState } from "../types";
3
3
  declare type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "boundElements" | "seed" | "version" | "versionNonce">;
4
4
  export declare const newElement: (opts: {
@@ -10,11 +10,13 @@ export declare const newTextElement: (opts: {
10
10
  fontFamily: FontFamilyValues;
11
11
  textAlign: TextAlign;
12
12
  verticalAlign: VerticalAlign;
13
+ containerId?: ExcalidrawRectangleElement["id"];
13
14
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
14
- export declare const updateTextElement: (element: ExcalidrawTextElement, { text, isDeleted }: {
15
+ export declare const updateTextElement: (element: ExcalidrawTextElement, { text, isDeleted, originalText, }: {
15
16
  text: string;
16
17
  isDeleted?: boolean | undefined;
17
- }) => ExcalidrawTextElement;
18
+ originalText: string;
19
+ }, updateDimensions: boolean) => ExcalidrawTextElement;
18
20
  export declare const newFreeDrawElement: (opts: {
19
21
  type: "freedraw";
20
22
  points?: ExcalidrawFreeDrawElement["points"];
@@ -1,2 +1,23 @@
1
- import { ExcalidrawTextElement } from "./types";
1
+ import { ExcalidrawElement, ExcalidrawTextElement, FontString, NonDeletedExcalidrawElement } from "./types";
2
+ import { MaybeTransformHandleType } from "./transformHandles";
2
3
  export declare const redrawTextBoundingBox: (element: ExcalidrawTextElement) => void;
4
+ export declare const bindTextToShapeAfterDuplication: (sceneElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
5
+ export declare const handleBindTextResize: (elements: readonly NonDeletedExcalidrawElement[], transformHandleType: MaybeTransformHandleType) => void;
6
+ export declare const measureText: (text: string, font: FontString, maxWidth?: number | null | undefined) => {
7
+ width: number;
8
+ height: number;
9
+ baseline: number;
10
+ };
11
+ export declare const getApproxLineHeight: (font: FontString) => number;
12
+ export declare const wrapText: (text: string, font: FontString, containerWidth: number) => string;
13
+ export declare const charWidth: {
14
+ calculate: (char: string, font: FontString) => number;
15
+ updateCache: (char: string, font: FontString) => void;
16
+ clearCacheforFont: (font: FontString) => void;
17
+ getCache: (font: FontString) => number[];
18
+ };
19
+ export declare const getApproxMinLineWidth: (font: FontString) => number;
20
+ export declare const getApproxMinLineHeight: (font: FontString) => number;
21
+ export declare const getMinCharWidth: (font: FontString) => number;
22
+ export declare const getApproxCharsToFitInWidth: (font: FontString, width: number) => number;
23
+ export declare const getBoundTextElementId: (container: ExcalidrawElement | null) => string | undefined;
@@ -7,6 +7,7 @@ export declare const textWysiwyg: ({ id, appState, onChange, onSubmit, getViewpo
7
7
  onSubmit: (data: {
8
8
  text: string;
9
9
  viaKeyboard: boolean;
10
+ originalText: string;
10
11
  }) => void;
11
12
  getViewportCoords: (x: number, y: number) => [number, number];
12
13
  element: ExcalidrawElement;
@@ -1,4 +1,4 @@
1
- import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawGenericElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement } from "./types";
1
+ import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawGenericElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer } 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,4 +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
14
  export declare const isExcalidrawElement: (element: any) => boolean;
15
+ export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is ExcalidrawBindableElement;
16
+ export declare const isBoundToContainer: (element: ExcalidrawElement | null) => element is ExcalidrawTextElementWithContainer;
@@ -94,8 +94,13 @@ export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
94
94
  baseline: number;
95
95
  textAlign: TextAlign;
96
96
  verticalAlign: VerticalAlign;
97
+ containerId: ExcalidrawGenericElement["id"] | null;
98
+ originalText: string;
97
99
  }>;
98
100
  export declare type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement;
101
+ export declare type ExcalidrawTextElementWithContainer = {
102
+ containerId: ExcalidrawGenericElement["id"];
103
+ } & ExcalidrawTextElement;
99
104
  export declare type PointBinding = {
100
105
  elementId: ExcalidrawBindableElement["id"];
101
106
  focus: number;
@@ -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 getElementContainingPosition: (elements: readonly ExcalidrawElement[], x: number, y: number, excludedType?: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | undefined) => ExcalidrawElement | null;
@@ -7,5 +7,5 @@ export declare const isSomeElementSelected: (elements: readonly NonDeletedExcali
7
7
  * elements. If elements don't share the same value, returns `null`.
8
8
  */
9
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) => NonDeletedExcalidrawElement[];
10
+ export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, includeBoundTextElement?: boolean) => NonDeletedExcalidrawElement[];
11
11
  export declare const getTargetElements: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => NonDeletedExcalidrawElement[];
package/types/utils.d.ts CHANGED
@@ -14,11 +14,6 @@ export declare const getFontString: ({ fontSize, fontFamily, }: {
14
14
  fontSize: number;
15
15
  fontFamily: FontFamilyValues;
16
16
  }) => FontString;
17
- export declare const measureText: (text: string, font: FontString) => {
18
- width: number;
19
- height: number;
20
- baseline: number;
21
- };
22
17
  export declare const debounce: <T extends any[]>(fn: (...args: T) => void, timeout: number) => {
23
18
  (...args: T): void;
24
19
  flush(): void;