@excalidraw/excalidraw 0.14.2-dd4c333 → 0.14.2-e4d8ba2

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/excalidraw.development.js +40 -30
  3. package/dist/excalidraw.production.min.js +1 -1
  4. package/package.json +2 -2
  5. package/types/actions/actionAddToLibrary.d.ts +2 -1
  6. package/types/actions/actionBoundText.d.ts +114 -10
  7. package/types/actions/actionCanvas.d.ts +115 -9
  8. package/types/actions/actionClipboard.d.ts +3 -3
  9. package/types/actions/actionDeleteSelected.d.ts +3 -3
  10. package/types/actions/actionExport.d.ts +8 -8
  11. package/types/actions/actionFinalize.d.ts +2 -2
  12. package/types/actions/actionLinearEditor.d.ts +2 -1
  13. package/types/actions/actionMenu.d.ts +3 -3
  14. package/types/actions/actionProperties.d.ts +14 -14
  15. package/types/actions/actionStyles.d.ts +1 -1
  16. package/types/actions/actionToggleGridMode.d.ts +1 -1
  17. package/types/actions/actionToggleLock.d.ts +1 -1
  18. package/types/actions/actionToggleStats.d.ts +1 -1
  19. package/types/actions/actionToggleViewMode.d.ts +1 -1
  20. package/types/actions/actionToggleZenMode.d.ts +1 -1
  21. package/types/components/App.d.ts +12 -1
  22. package/types/components/BraveMeasureTextError.d.ts +2 -0
  23. package/types/components/ButtonIconSelect.d.ts +11 -3
  24. package/types/components/ErrorDialog.d.ts +3 -2
  25. package/types/components/icons.d.ts +1 -0
  26. package/types/constants.d.ts +1 -0
  27. package/types/element/Hyperlink.d.ts +1 -1
  28. package/types/element/linearElementEditor.d.ts +1 -1
  29. package/types/element/newElement.d.ts +3 -1
  30. package/types/element/textElement.d.ts +25 -6
  31. package/types/element/types.d.ts +9 -1
  32. package/types/renderer/renderElement.d.ts +2 -2
  33. package/types/types.d.ts +2 -2
  34. package/types/utils.d.ts +20 -1
@@ -20,7 +20,7 @@ export declare const actionChangeBackgroundColor: {
20
20
  export declare const actionChangeFillStyle: {
21
21
  name: "changeFillStyle";
22
22
  trackEvent: false;
23
- perform: (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, value: any) => {
23
+ perform: (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, value: any, app: import("../../src/types").AppClassProperties) => {
24
24
  elements: ExcalidrawElement[];
25
25
  appState: {
26
26
  currentItemFillStyle: any;
@@ -31,7 +31,7 @@ export declare const actionChangeFillStyle: {
31
31
  } | null;
32
32
  showWelcomeScreen: boolean;
33
33
  isLoading: boolean;
34
- errorMessage: string | null;
34
+ errorMessage: import("react").ReactNode;
35
35
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
36
36
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
37
37
  multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
@@ -145,7 +145,7 @@ export declare const actionChangeStrokeWidth: {
145
145
  } | null;
146
146
  showWelcomeScreen: boolean;
147
147
  isLoading: boolean;
148
- errorMessage: string | null;
148
+ errorMessage: import("react").ReactNode;
149
149
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
150
150
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
151
151
  multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
@@ -259,7 +259,7 @@ export declare const actionChangeSloppiness: {
259
259
  } | null;
260
260
  showWelcomeScreen: boolean;
261
261
  isLoading: boolean;
262
- errorMessage: string | null;
262
+ errorMessage: import("react").ReactNode;
263
263
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
264
264
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
265
265
  multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
@@ -373,7 +373,7 @@ export declare const actionChangeStrokeStyle: {
373
373
  } | null;
374
374
  showWelcomeScreen: boolean;
375
375
  isLoading: boolean;
376
- errorMessage: string | null;
376
+ errorMessage: import("react").ReactNode;
377
377
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
378
378
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
379
379
  multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
@@ -487,7 +487,7 @@ export declare const actionChangeOpacity: {
487
487
  } | null;
488
488
  showWelcomeScreen: boolean;
489
489
  isLoading: boolean;
490
- errorMessage: string | null;
490
+ errorMessage: import("react").ReactNode;
491
491
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
492
492
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
493
493
  multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
@@ -601,7 +601,7 @@ export declare const actionChangeFontSize: {
601
601
  } | null;
602
602
  showWelcomeScreen: boolean;
603
603
  isLoading: boolean;
604
- errorMessage: string | null;
604
+ errorMessage: import("react").ReactNode;
605
605
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
606
606
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
607
607
  multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
@@ -715,7 +715,7 @@ export declare const actionDecreaseFontSize: {
715
715
  } | null;
716
716
  showWelcomeScreen: boolean;
717
717
  isLoading: boolean;
718
- errorMessage: string | null;
718
+ errorMessage: import("react").ReactNode;
719
719
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
720
720
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
721
721
  multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
@@ -829,7 +829,7 @@ export declare const actionIncreaseFontSize: {
829
829
  } | null;
830
830
  showWelcomeScreen: boolean;
831
831
  isLoading: boolean;
832
- errorMessage: string | null;
832
+ errorMessage: import("react").ReactNode;
833
833
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
834
834
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
835
835
  multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
@@ -943,7 +943,7 @@ export declare const actionChangeFontFamily: {
943
943
  } | null;
944
944
  showWelcomeScreen: boolean;
945
945
  isLoading: boolean;
946
- errorMessage: string | null;
946
+ errorMessage: import("react").ReactNode;
947
947
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
948
948
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
949
949
  multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
@@ -1057,7 +1057,7 @@ export declare const actionChangeTextAlign: {
1057
1057
  } | null;
1058
1058
  showWelcomeScreen: boolean;
1059
1059
  isLoading: boolean;
1060
- errorMessage: string | null;
1060
+ errorMessage: import("react").ReactNode;
1061
1061
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
1062
1062
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
1063
1063
  multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
@@ -1172,7 +1172,7 @@ export declare const actionChangeVerticalAlign: {
1172
1172
  } | null;
1173
1173
  showWelcomeScreen: boolean;
1174
1174
  isLoading: boolean;
1175
- errorMessage: string | null;
1175
+ errorMessage: import("react").ReactNode;
1176
1176
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
1177
1177
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
1178
1178
  multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
@@ -1287,7 +1287,7 @@ export declare const actionChangeRoundness: {
1287
1287
  } | null;
1288
1288
  showWelcomeScreen: boolean;
1289
1289
  isLoading: boolean;
1290
- errorMessage: string | null;
1290
+ errorMessage: import("react").ReactNode;
1291
1291
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
1292
1292
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
1293
1293
  multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
@@ -1403,7 +1403,7 @@ export declare const actionChangeArrowhead: {
1403
1403
  } | null;
1404
1404
  showWelcomeScreen: boolean;
1405
1405
  isLoading: boolean;
1406
- errorMessage: string | null;
1406
+ errorMessage: import("react").ReactNode;
1407
1407
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
1408
1408
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
1409
1409
  multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
@@ -17,7 +17,7 @@ export declare const actionCopyStyles: {
17
17
  } | null;
18
18
  showWelcomeScreen: boolean;
19
19
  isLoading: boolean;
20
- errorMessage: string | null;
20
+ errorMessage: import("react").ReactNode;
21
21
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
22
22
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
23
23
  multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
@@ -17,7 +17,7 @@ export declare const actionToggleGridMode: {
17
17
  } | null;
18
18
  showWelcomeScreen: boolean;
19
19
  isLoading: boolean;
20
- errorMessage: string | null;
20
+ errorMessage: import("react").ReactNode;
21
21
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
22
22
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
23
23
  multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
@@ -16,7 +16,7 @@ export declare const actionToggleLock: {
16
16
  } | null;
17
17
  showWelcomeScreen: boolean;
18
18
  isLoading: boolean;
19
- errorMessage: string | null;
19
+ errorMessage: import("react").ReactNode;
20
20
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
21
21
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
22
22
  multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
@@ -15,7 +15,7 @@ export declare const actionToggleStats: {
15
15
  } | null;
16
16
  showWelcomeScreen: boolean;
17
17
  isLoading: boolean;
18
- errorMessage: string | null;
18
+ errorMessage: import("react").ReactNode;
19
19
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
20
20
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
21
21
  multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
@@ -16,7 +16,7 @@ export declare const actionToggleViewMode: {
16
16
  } | null;
17
17
  showWelcomeScreen: boolean;
18
18
  isLoading: boolean;
19
- errorMessage: string | null;
19
+ errorMessage: import("react").ReactNode;
20
20
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
21
21
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
22
22
  multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
@@ -16,7 +16,7 @@ export declare const actionToggleZenMode: {
16
16
  } | null;
17
17
  showWelcomeScreen: boolean;
18
18
  isLoading: boolean;
19
- errorMessage: string | null;
19
+ errorMessage: import("react").ReactNode;
20
20
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
21
21
  resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
22
22
  multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
@@ -93,7 +93,18 @@ declare class App extends React.Component<AppProps, AppState> {
93
93
  toggleLock: (source?: "keyboard" | "ui") => void;
94
94
  togglePenMode: () => void;
95
95
  onHandToolToggle: () => void;
96
- scrollToContent: (target?: ExcalidrawElement | readonly ExcalidrawElement[]) => void;
96
+ /**
97
+ * Zooms on canvas viewport center
98
+ */
99
+ zoomCanvas: (value: number) => void;
100
+ private cancelInProgresAnimation;
101
+ scrollToContent: (target?: ExcalidrawElement | readonly ExcalidrawElement[], opts?: {
102
+ fitToContent?: boolean;
103
+ animate?: boolean;
104
+ duration?: number;
105
+ }) => void;
106
+ /** use when changing scrollX/scrollY/zoom based on user interaction */
107
+ private translateCanvas;
97
108
  setToast: (toast: {
98
109
  message: string;
99
110
  closable?: boolean;
@@ -0,0 +1,2 @@
1
+ declare const BraveMeasureTextError: () => JSX.Element;
2
+ export default BraveMeasureTextError;
@@ -1,11 +1,19 @@
1
- export declare const ButtonIconSelect: <T extends Object>({ options, value, onChange, group, }: {
1
+ export declare const ButtonIconSelect: <T extends Object>(props: {
2
2
  options: {
3
3
  value: T;
4
4
  text: string;
5
5
  icon: JSX.Element;
6
6
  testId?: string | undefined;
7
+ /** if not supplied, defaults to value identity check */
8
+ active?: boolean | undefined;
7
9
  }[];
8
10
  value: T | null;
9
- onChange: (value: T) => void;
11
+ type?: "button" | "radio" | undefined;
12
+ } & ({
13
+ type?: "radio" | undefined;
10
14
  group: string;
11
- }) => JSX.Element;
15
+ onChange: (value: T) => void;
16
+ } | {
17
+ type: "button";
18
+ onClick: (value: T, event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
19
+ })) => JSX.Element;
@@ -1,4 +1,5 @@
1
- export declare const ErrorDialog: ({ message, onClose, }: {
2
- message: string;
1
+ import React from "react";
2
+ export declare const ErrorDialog: ({ children, onClose, }: {
3
+ children?: React.ReactNode;
3
4
  onClose?: (() => void) | undefined;
4
5
  }) => JSX.Element;
@@ -87,6 +87,7 @@ export declare const GroupIcon: React.MemoExoticComponent<({ theme }: {
87
87
  export declare const UngroupIcon: React.MemoExoticComponent<({ theme }: {
88
88
  theme: Theme;
89
89
  }) => JSX.Element>;
90
+ export declare const FillZigZagIcon: JSX.Element;
90
91
  export declare const FillHachureIcon: JSX.Element;
91
92
  export declare const FillCrossHatchIcon: JSX.Element;
92
93
  export declare const FillSolidIcon: JSX.Element;
@@ -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: string | null;
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: string | null;
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,14 +12,16 @@ 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;
18
19
  y: number;
19
20
  width: number;
20
21
  height: number;
22
+ baseline: number;
21
23
  text: string;
22
- };
24
+ } | undefined;
23
25
  export declare const updateTextElement: (textElement: ExcalidrawTextElement, { text, isDeleted, originalText, }: {
24
26
  text: string;
25
27
  isDeleted?: boolean | undefined;
@@ -1,25 +1,39 @@
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;
13
+ baseline: number;
12
14
  };
13
- export declare const getApproxLineHeight: (font: FontString) => number;
15
+ export declare const measureBaseline: (text: string, font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"], wrapInContainer?: boolean) => number;
16
+ /**
17
+ * To get unitless line-height (if unknown) we can calculate it by dividing
18
+ * height-per-line by fontSize.
19
+ */
20
+ export declare const detectLineHeight: (textElement: ExcalidrawTextElement) => number & {
21
+ _brand: "unitlessLineHeight";
22
+ };
23
+ /**
24
+ * We calculate the line height from the font size and the unitless line height,
25
+ * aligning with the W3C spec.
26
+ */
27
+ export declare const getLineHeightInPx: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
28
+ export declare const getApproxMinLineHeight: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
14
29
  export declare const getTextWidth: (text: string, font: FontString) => number;
15
- export declare const getTextHeight: (text: string, font: FontString) => number;
30
+ export declare const getTextHeight: (text: string, fontSize: number, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
16
31
  export declare const wrapText: (text: string, font: FontString, maxWidth: number) => string;
17
32
  export declare const charWidth: {
18
33
  calculate: (char: string, font: FontString) => number;
19
34
  getCache: (font: FontString) => number[];
20
35
  };
21
- export declare const getApproxMinLineWidth: (font: FontString) => number;
22
- export declare const getApproxMinLineHeight: (font: FontString) => number;
36
+ export declare const getApproxMinLineWidth: (font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
23
37
  export declare const getMinCharWidth: (font: FontString) => number;
24
38
  export declare const getMaxCharWidth: (font: FontString) => number;
25
39
  export declare const getApproxCharsToFitInWidth: (font: FontString, width: number) => number;
@@ -47,10 +61,15 @@ export declare const getBoundTextElementPosition: (container: ExcalidrawElement,
47
61
  y: number;
48
62
  } | undefined;
49
63
  export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
64
+ export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
50
65
  export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], appState: AppState, x: number, y: number) => ExcalidrawTextContainer | null;
51
66
  declare const VALID_CONTAINER_TYPES: Set<string>;
52
67
  export declare const isValidTextContainer: (element: ExcalidrawElement) => boolean;
53
68
  export declare const computeContainerDimensionForBoundText: (dimension: number, containerType: ExtractSetType<typeof VALID_CONTAINER_TYPES>) => number;
54
69
  export declare const getMaxContainerWidth: (container: ExcalidrawElement) => number;
55
70
  export declare const getMaxContainerHeight: (container: ExcalidrawElement) => number;
71
+ export declare const isMeasureTextSupported: () => boolean;
72
+ export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
73
+ _brand: "unitlessLineHeight";
74
+ };
56
75
  export {};
@@ -2,7 +2,7 @@ import { Point } from "../types";
2
2
  import { FONT_FAMILY, ROUNDNESS, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "../constants";
3
3
  import { MarkNonNullable, ValueOf } from "../utility-types";
4
4
  export declare type ChartType = "bar" | "line";
5
- export declare type FillStyle = "hachure" | "cross-hatch" | "solid";
5
+ export declare type FillStyle = "hachure" | "cross-hatch" | "solid" | "zigzag";
6
6
  export declare type FontFamilyKeys = keyof typeof FONT_FAMILY;
7
7
  export declare type FontFamilyValues = typeof FONT_FAMILY[FontFamilyKeys];
8
8
  export declare type Theme = typeof THEME[keyof typeof THEME];
@@ -100,10 +100,18 @@ export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
100
100
  fontSize: number;
101
101
  fontFamily: FontFamilyValues;
102
102
  text: string;
103
+ baseline: number;
103
104
  textAlign: TextAlign;
104
105
  verticalAlign: VerticalAlign;
105
106
  containerId: ExcalidrawGenericElement["id"] | null;
106
107
  originalText: string;
108
+ /**
109
+ * Unitless line height (aligned to W3C). To get line height in px, multiply
110
+ * with font size (using `getLineHeightInPx` helper).
111
+ */
112
+ lineHeight: number & {
113
+ _brand: "unitlessLineHeight";
114
+ };
107
115
  }>;
108
116
  export declare type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement;
109
117
  export declare type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawImageElement | ExcalidrawArrowElement;
@@ -3,12 +3,12 @@ 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, Zoom } from "../types";
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
- canvasZoom: Zoom["value"];
11
+ scale: number;
12
12
  canvasOffsetX: number;
13
13
  canvasOffsetY: number;
14
14
  boundTextElementVersion: number | null;
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: string | null;
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
  }>;