@excalidraw/excalidraw 0.14.2-dd4c333 → 0.14.2-f8e65bb
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 +2 -0
- package/dist/excalidraw.development.js +37 -27
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +2 -2
- package/types/actions/actionAddToLibrary.d.ts +2 -1
- package/types/actions/actionBoundText.d.ts +2 -1
- package/types/actions/actionCanvas.d.ts +115 -9
- package/types/actions/actionClipboard.d.ts +3 -3
- package/types/actions/actionDeleteSelected.d.ts +3 -3
- package/types/actions/actionExport.d.ts +8 -8
- package/types/actions/actionFinalize.d.ts +2 -2
- package/types/actions/actionLinearEditor.d.ts +2 -1
- package/types/actions/actionMenu.d.ts +3 -3
- package/types/actions/actionProperties.d.ts +13 -13
- package/types/actions/actionStyles.d.ts +1 -1
- package/types/actions/actionToggleGridMode.d.ts +1 -1
- package/types/actions/actionToggleLock.d.ts +1 -1
- package/types/actions/actionToggleStats.d.ts +1 -1
- package/types/actions/actionToggleViewMode.d.ts +1 -1
- package/types/actions/actionToggleZenMode.d.ts +1 -1
- package/types/components/App.d.ts +12 -1
- package/types/components/BraveMeasureTextError.d.ts +2 -0
- package/types/components/ErrorDialog.d.ts +3 -2
- package/types/constants.d.ts +1 -0
- package/types/element/Hyperlink.d.ts +1 -1
- package/types/element/linearElementEditor.d.ts +1 -1
- package/types/element/newElement.d.ts +1 -0
- package/types/element/textElement.d.ts +23 -6
- package/types/element/types.d.ts +7 -0
- package/types/types.d.ts +2 -2
- package/types/utils.d.ts +20 -1
package/types/constants.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const isAndroid: boolean;
|
|
|
6
6
|
export declare const isFirefox: boolean;
|
|
7
7
|
export declare const isChrome: boolean;
|
|
8
8
|
export declare const isSafari: boolean;
|
|
9
|
+
export declare const isBrave: () => boolean;
|
|
9
10
|
export declare const APP_NAME = "Excalidraw";
|
|
10
11
|
export declare const DRAGGING_THRESHOLD = 10;
|
|
11
12
|
export declare const LINE_CONFIRM_THRESHOLD = 8;
|
|
@@ -25,7 +25,7 @@ export declare const actionLink: {
|
|
|
25
25
|
} | null;
|
|
26
26
|
showWelcomeScreen: boolean;
|
|
27
27
|
isLoading: boolean;
|
|
28
|
-
errorMessage:
|
|
28
|
+
errorMessage: import("react").ReactNode;
|
|
29
29
|
draggingElement: NonDeletedExcalidrawElement | null;
|
|
30
30
|
resizingElement: NonDeletedExcalidrawElement | null;
|
|
31
31
|
multiElement: import("./types").NonDeleted<import("./types").ExcalidrawLinearElement> | null;
|
|
@@ -130,7 +130,7 @@ export declare class LinearElementEditor {
|
|
|
130
130
|
} | null;
|
|
131
131
|
showWelcomeScreen: boolean;
|
|
132
132
|
isLoading: boolean;
|
|
133
|
-
errorMessage:
|
|
133
|
+
errorMessage: import("react").ReactNode;
|
|
134
134
|
draggingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
135
135
|
resizingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
136
136
|
multiElement: NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -12,6 +12,7 @@ export declare const newTextElement: (opts: {
|
|
|
12
12
|
textAlign: TextAlign;
|
|
13
13
|
verticalAlign: VerticalAlign;
|
|
14
14
|
containerId?: ExcalidrawTextContainer["id"];
|
|
15
|
+
lineHeight?: ExcalidrawTextElement["lineHeight"];
|
|
15
16
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
|
|
16
17
|
export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, text?: string) => {
|
|
17
18
|
x: number;
|
|
@@ -1,25 +1,37 @@
|
|
|
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
4
|
import { ExtractSetType } from "../utility-types";
|
|
5
5
|
export declare const normalizeText: (text: string) => string;
|
|
6
|
+
export declare const splitIntoLines: (text: string) => string[];
|
|
6
7
|
export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null) => void;
|
|
7
8
|
export declare const bindTextToShapeAfterDuplication: (sceneElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
|
|
8
9
|
export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, transformHandleType: MaybeTransformHandleType) => void;
|
|
9
|
-
export declare const measureText: (text: string, font: FontString) => {
|
|
10
|
+
export declare const measureText: (text: string, font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => {
|
|
10
11
|
width: number;
|
|
11
12
|
height: number;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* To get unitless line-height (if unknown) we can calculate it by dividing
|
|
16
|
+
* height-per-line by fontSize.
|
|
17
|
+
*/
|
|
18
|
+
export declare const detectLineHeight: (textElement: ExcalidrawTextElement) => number & {
|
|
19
|
+
_brand: "unitlessLineHeight";
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* We calculate the line height from the font size and the unitless line height,
|
|
23
|
+
* aligning with the W3C spec.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getLineHeightInPx: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
26
|
+
export declare const getApproxMinLineHeight: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
14
27
|
export declare const getTextWidth: (text: string, font: FontString) => number;
|
|
15
|
-
export declare const getTextHeight: (text: string,
|
|
28
|
+
export declare const getTextHeight: (text: string, fontSize: number, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
16
29
|
export declare const wrapText: (text: string, font: FontString, maxWidth: number) => string;
|
|
17
30
|
export declare const charWidth: {
|
|
18
31
|
calculate: (char: string, font: FontString) => number;
|
|
19
32
|
getCache: (font: FontString) => number[];
|
|
20
33
|
};
|
|
21
|
-
export declare const getApproxMinLineWidth: (font: FontString) => number;
|
|
22
|
-
export declare const getApproxMinLineHeight: (font: FontString) => number;
|
|
34
|
+
export declare const getApproxMinLineWidth: (font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
23
35
|
export declare const getMinCharWidth: (font: FontString) => number;
|
|
24
36
|
export declare const getMaxCharWidth: (font: FontString) => number;
|
|
25
37
|
export declare const getApproxCharsToFitInWidth: (font: FontString, width: number) => number;
|
|
@@ -47,10 +59,15 @@ export declare const getBoundTextElementPosition: (container: ExcalidrawElement,
|
|
|
47
59
|
y: number;
|
|
48
60
|
} | undefined;
|
|
49
61
|
export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
|
|
62
|
+
export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
|
|
50
63
|
export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], appState: AppState, x: number, y: number) => ExcalidrawTextContainer | null;
|
|
51
64
|
declare const VALID_CONTAINER_TYPES: Set<string>;
|
|
52
65
|
export declare const isValidTextContainer: (element: ExcalidrawElement) => boolean;
|
|
53
66
|
export declare const computeContainerDimensionForBoundText: (dimension: number, containerType: ExtractSetType<typeof VALID_CONTAINER_TYPES>) => number;
|
|
54
67
|
export declare const getMaxContainerWidth: (container: ExcalidrawElement) => number;
|
|
55
68
|
export declare const getMaxContainerHeight: (container: ExcalidrawElement) => number;
|
|
69
|
+
export declare const isMeasureTextSupported: () => boolean;
|
|
70
|
+
export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
|
|
71
|
+
_brand: "unitlessLineHeight";
|
|
72
|
+
};
|
|
56
73
|
export {};
|
package/types/element/types.d.ts
CHANGED
|
@@ -104,6 +104,13 @@ export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
|
|
|
104
104
|
verticalAlign: VerticalAlign;
|
|
105
105
|
containerId: ExcalidrawGenericElement["id"] | null;
|
|
106
106
|
originalText: string;
|
|
107
|
+
/**
|
|
108
|
+
* Unitless line height (aligned to W3C). To get line height in px, multiply
|
|
109
|
+
* with font size (using `getLineHeightInPx` helper).
|
|
110
|
+
*/
|
|
111
|
+
lineHeight: number & {
|
|
112
|
+
_brand: "unitlessLineHeight";
|
|
113
|
+
};
|
|
107
114
|
}>;
|
|
108
115
|
export declare type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement;
|
|
109
116
|
export declare type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawImageElement | ExcalidrawArrowElement;
|
package/types/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme, StrokeRoundness } from "./element/types";
|
|
3
2
|
import { SHAPES } from "./shapes";
|
|
4
3
|
import { Point as RoughPoint } from "roughjs/bin/geometry";
|
|
@@ -17,6 +16,7 @@ import type { FileSystemHandle } from "./data/filesystem";
|
|
|
17
16
|
import type { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
|
|
18
17
|
import { ContextMenuItems } from "./components/ContextMenu";
|
|
19
18
|
import { Merge, ForwardRef } from "./utility-types";
|
|
19
|
+
import React from "react";
|
|
20
20
|
export declare type Point = Readonly<RoughPoint>;
|
|
21
21
|
export declare type Collaborator = {
|
|
22
22
|
pointer?: {
|
|
@@ -71,7 +71,7 @@ export declare type AppState = {
|
|
|
71
71
|
} | null;
|
|
72
72
|
showWelcomeScreen: boolean;
|
|
73
73
|
isLoading: boolean;
|
|
74
|
-
errorMessage:
|
|
74
|
+
errorMessage: React.ReactNode;
|
|
75
75
|
draggingElement: NonDeletedExcalidrawElement | null;
|
|
76
76
|
resizingElement: NonDeletedExcalidrawElement | null;
|
|
77
77
|
multiElement: NonDeleted<ExcalidrawLinearElement> | null;
|
package/types/utils.d.ts
CHANGED
|
@@ -28,6 +28,26 @@ export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void, op
|
|
|
28
28
|
flush(): void;
|
|
29
29
|
cancel(): void;
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Compute new values based on the same ease function and trigger the
|
|
33
|
+
* callback through a requestAnimationFrame call
|
|
34
|
+
*
|
|
35
|
+
* use `opts` to define a duration and/or an easeFn
|
|
36
|
+
*
|
|
37
|
+
* for example:
|
|
38
|
+
* ```ts
|
|
39
|
+
* easeToValuesRAF([10, 20, 10], [0, 0, 0], (a, b, c) => setState(a,b, c))
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param fromValues The initial values, must be numeric
|
|
43
|
+
* @param toValues The destination values, must also be numeric
|
|
44
|
+
* @param callback The callback receiving the values
|
|
45
|
+
* @param opts default to 250ms duration and the easeOut function
|
|
46
|
+
*/
|
|
47
|
+
export declare const easeToValuesRAF: (fromValues: number[], toValues: number[], callback: (...values: number[]) => void, opts?: {
|
|
48
|
+
duration?: number | undefined;
|
|
49
|
+
easeFn?: ((value: number) => number) | undefined;
|
|
50
|
+
} | undefined) => () => void;
|
|
31
51
|
export declare const chunk: <T extends unknown>(array: readonly T[], size: number) => T[][];
|
|
32
52
|
export declare const selectNode: (node: Element) => void;
|
|
33
53
|
export declare const removeSelection: () => void;
|
|
@@ -128,7 +148,6 @@ export declare const arrayToMapWithIndex: <T extends {
|
|
|
128
148
|
id: string;
|
|
129
149
|
}>(elements: readonly T[]) => Map<string, [element: T, index: number]>;
|
|
130
150
|
export declare const isTestEnv: () => boolean;
|
|
131
|
-
export declare const isProdEnv: () => boolean;
|
|
132
151
|
export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) => CustomEvent<{
|
|
133
152
|
nativeEvent: T;
|
|
134
153
|
}>;
|