@nous-excalidraw/math 0.18.4-beta.4 → 0.18.5-beta.5

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.
@@ -317,6 +317,7 @@ export declare const TOOL_TYPE: {
317
317
  readonly lasso: "lasso";
318
318
  readonly rectangle: "rectangle";
319
319
  readonly diamond: "diamond";
320
+ readonly triangle: "triangle";
320
321
  readonly ellipse: "ellipse";
321
322
  readonly arrow: "arrow";
322
323
  readonly line: "line";
@@ -0,0 +1,22 @@
1
+ /** Target screen font sizes at 100% zoom (matches FONT_SIZES). */
2
+ export declare const FONT_SIZE_SCREEN: {
3
+ readonly sm: 16;
4
+ readonly md: 20;
5
+ readonly lg: 28;
6
+ readonly xl: 36;
7
+ };
8
+ export declare const getSceneFontSizeForZoom: (screenFontSize: number, zoom: number) => number;
9
+ export declare const getFontSizePresetsForZoom: (zoom: number) => {
10
+ sm: number;
11
+ md: number;
12
+ lg: number;
13
+ xl: number;
14
+ };
15
+ /** When zoom changes, scale scene fontSize to keep the same screen size. */
16
+ export declare const scaleFontSizeForZoomChange: (fontSize: number, fromZoom: number, toZoom: number) => number;
17
+ /**
18
+ * Normalize fontSize when entering a low-zoom canvas.
19
+ * Legacy values (FONT_SIZES range) stored at low zoom were scene coords and
20
+ * render tiny; treat them as intended screen pixels instead.
21
+ */
22
+ export declare const normalizeSceneFontSizeForZoom: (fontSize: number, fromZoom: number, toZoom: number) => number;
@@ -2,6 +2,8 @@ export * from "./binary-heap";
2
2
  export * from "./bounds";
3
3
  export * from "./colors";
4
4
  export * from "./constants";
5
+ export * from "./strokeWidth";
6
+ export * from "./fontSize";
5
7
  export * from "./font-metadata";
6
8
  export * from "./queue";
7
9
  export * from "./keys";
@@ -0,0 +1,14 @@
1
+ /** Target screen pixel stroke widths at 100% zoom. */
2
+ export declare const STROKE_WIDTH_SCREEN: {
3
+ readonly thin: 2;
4
+ readonly bold: 3;
5
+ readonly extraBold: 4;
6
+ };
7
+ export declare const getSceneStrokeWidthForZoom: (screenWidth: number, zoom: number) => number;
8
+ export declare const getStrokeWidthPresetsForZoom: (zoom: number) => {
9
+ thin: number;
10
+ bold: number;
11
+ extraBold: number;
12
+ };
13
+ /** When zoom changes from `fromZoom` to `toZoom`, scale scene strokeWidth to keep the same screen thickness. */
14
+ export declare const scaleStrokeWidthForZoomChange: (strokeWidth: number, fromZoom: number, toZoom: number) => number;
@@ -70,7 +70,7 @@ export declare class Scene {
70
70
  getElementIndex(elementId: string): number;
71
71
  getContainerElement: (element: (ExcalidrawElement & {
72
72
  containerId: ExcalidrawElement["id"] | null;
73
- }) | null) => import("@nous-excalidraw/element/types").ExcalidrawLinearElement | import("@nous-excalidraw/element/types").ExcalidrawSelectionElement | import("@nous-excalidraw/element/types").ExcalidrawRectangleElement | import("@nous-excalidraw/element/types").ExcalidrawDiamondElement | import("@nous-excalidraw/element/types").ExcalidrawEllipseElement | import("@nous-excalidraw/element/types").ExcalidrawEmbeddableElement | import("@nous-excalidraw/element/types").ExcalidrawIframeElement | import("@nous-excalidraw/element/types").ExcalidrawImageElement | import("@nous-excalidraw/element/types").ExcalidrawFrameElement | import("@nous-excalidraw/element/types").ExcalidrawMagicFrameElement | import("@nous-excalidraw/element/types").ExcalidrawTextElement | import("@nous-excalidraw/element/types").ExcalidrawFreeDrawElement | null;
73
+ }) | null) => import("@nous-excalidraw/element/types").ExcalidrawLinearElement | import("@nous-excalidraw/element/types").ExcalidrawSelectionElement | import("@nous-excalidraw/element/types").ExcalidrawRectangleElement | import("@nous-excalidraw/element/types").ExcalidrawDiamondElement | import("@nous-excalidraw/element/types").ExcalidrawTriangleElement | import("@nous-excalidraw/element/types").ExcalidrawEllipseElement | import("@nous-excalidraw/element/types").ExcalidrawEmbeddableElement | import("@nous-excalidraw/element/types").ExcalidrawIframeElement | import("@nous-excalidraw/element/types").ExcalidrawImageElement | import("@nous-excalidraw/element/types").ExcalidrawFrameElement | import("@nous-excalidraw/element/types").ExcalidrawMagicFrameElement | import("@nous-excalidraw/element/types").ExcalidrawTextElement | import("@nous-excalidraw/element/types").ExcalidrawFreeDrawElement | null;
74
74
  getElementsFromId: (id: string) => ExcalidrawElement[];
75
75
  mutateElement<TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, options?: {
76
76
  informMutation: boolean;
@@ -36,6 +36,7 @@ export declare const getElementLineSegments: (element: ExcalidrawElement, elemen
36
36
  */
37
37
  export declare const getRectangleBoxAbsoluteCoords: (boxSceneCoords: RectangleBox) => number[];
38
38
  export declare const getDiamondPoints: (element: ExcalidrawElement) => number[];
39
+ export declare const getTrianglePoints: (element: ExcalidrawElement) => number[];
39
40
  export declare const getCubicBezierCurveBound: (p0: GlobalPoint, p1: GlobalPoint, p2: GlobalPoint, p3: GlobalPoint) => Bounds;
40
41
  export declare const getMinMaxXYFromCurvePathOps: (ops: Op[], transformXY?: (p: GlobalPoint) => GlobalPoint) => Bounds;
41
42
  export declare const getBoundsFromPoints: <P extends GlobalPoint | LocalPoint>(points: readonly P[], padding?: number) => Bounds;
@@ -43,6 +44,10 @@ export declare const getBoundsFromPoints: <P extends GlobalPoint | LocalPoint>(p
43
44
  export declare const getArrowheadSize: (arrowhead: Arrowhead) => number;
44
45
  /** @returns number in degrees */
45
46
  export declare const getArrowheadAngle: (arrowhead: Arrowhead) => Degrees;
47
+ /** Scale arrowhead to stay visible when strokeWidth is zoom-compensated. */
48
+ export declare const getScaledArrowheadSize: (arrowhead: Arrowhead, strokeWidth: ExcalidrawLinearElement["strokeWidth"]) => number;
49
+ /** Canvas padding for arrows/lines so scaled arrowheads aren't clipped. */
50
+ export declare const getArrowCanvasPadding: (element: ExcalidrawLinearElement) => number;
46
51
  export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead, offsetMultiplier?: number) => number[] | null;
47
52
  export declare const getElementBounds: (element: ExcalidrawElement, elementsMap: ElementsMap, nonRotated?: boolean) => Bounds;
48
53
  export declare const getCommonBounds: (elements: ElementsMapOrArray, elementsMap?: ElementsMap) => Bounds;
@@ -1,8 +1,8 @@
1
1
  import type { ElementOrToolType } from "@nous-excalidraw/excalidraw/types";
2
- export declare const hasBackground: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw";
3
- export declare const hasStrokeColor: (type: ElementOrToolType) => type is "line" | "arrow" | "text" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "freedraw";
4
- export declare const hasStrokeWidth: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw";
5
- export declare const hasStrokeStyle: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe";
6
- export declare const canChangeRoundness: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "embeddable" | "iframe" | "image";
2
+ export declare const hasBackground: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "triangle" | "ellipse" | "embeddable" | "iframe" | "freedraw";
3
+ export declare const hasStrokeColor: (type: ElementOrToolType) => type is "line" | "arrow" | "text" | "rectangle" | "diamond" | "triangle" | "ellipse" | "embeddable" | "freedraw";
4
+ export declare const hasStrokeWidth: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "triangle" | "ellipse" | "embeddable" | "iframe" | "freedraw";
5
+ export declare const hasStrokeStyle: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "triangle" | "ellipse" | "embeddable" | "iframe";
6
+ export declare const canChangeRoundness: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "triangle" | "embeddable" | "iframe" | "image";
7
7
  export declare const toolIsArrow: (type: ElementOrToolType) => type is "arrow";
8
8
  export declare const canHaveArrowheads: (type: ElementOrToolType) => type is "arrow";
@@ -31,8 +31,8 @@ export declare const getFrameLikeElements: (allElements: ExcalidrawElementsInclu
31
31
  */
32
32
  export declare const getRootElements: (allElements: ExcalidrawElementsIncludingDeleted) => ExcalidrawElement[];
33
33
  export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, appState: AppState, elementsMap: ElementsMap) => ExcalidrawElement[];
34
- export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
35
- export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
34
+ export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawTriangleElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
35
+ export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawTriangleElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
36
36
  export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap: ElementsMap) => ExcalidrawFrameLikeElement | null;
37
37
  /** */
38
38
  export declare const filterElementsEligibleAsFrameChildren: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
@@ -37,7 +37,7 @@ export declare const hasBoundTextElement: (element: ExcalidrawElement | null) =>
37
37
  export declare const isBoundToContainer: (element: ExcalidrawElement | null) => element is ExcalidrawTextElementWithContainer;
38
38
  export declare const isArrowBoundToElement: (element: ExcalidrawArrowElement) => boolean;
39
39
  export declare const isUsingAdaptiveRadius: (type: string) => type is "rectangle" | "embeddable" | "iframe" | "image";
40
- export declare const isUsingProportionalRadius: (type: string) => type is "line" | "arrow" | "diamond";
40
+ export declare const isUsingProportionalRadius: (type: string) => type is "line" | "arrow" | "diamond" | "triangle";
41
41
  export declare const canApplyRoundnessTypeToElement: (roundnessType: RoundnessType, element: ExcalidrawElement) => boolean;
42
42
  export declare const getDefaultRoundnessTypeForElement: (element: ExcalidrawElement) => {
43
43
  type: 2;
@@ -79,6 +79,9 @@ export type ExcalidrawRectangleElement = _ExcalidrawElementBase & {
79
79
  export type ExcalidrawDiamondElement = _ExcalidrawElementBase & {
80
80
  type: "diamond";
81
81
  };
82
+ export type ExcalidrawTriangleElement = _ExcalidrawElementBase & {
83
+ type: "triangle";
84
+ };
82
85
  export type ExcalidrawEllipseElement = _ExcalidrawElementBase & {
83
86
  type: "ellipse";
84
87
  };
@@ -149,8 +152,8 @@ export type ExcalidrawFrameLikeElement = ExcalidrawFrameElement | ExcalidrawMagi
149
152
  /**
150
153
  * These are elements that don't have any additional properties.
151
154
  */
152
- export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
153
- export type ExcalidrawFlowchartNodeElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
155
+ export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawTriangleElement | ExcalidrawEllipseElement;
156
+ export type ExcalidrawFlowchartNodeElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawTriangleElement | ExcalidrawEllipseElement;
154
157
  export type ExcalidrawRectanguloidElement = ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawTextElement | ExcalidrawFreeDrawElement | ExcalidrawIframeLikeElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement | ExcalidrawSelectionElement;
155
158
  /**
156
159
  * ExcalidrawElement should be JSON serializable and (eventually) contain
@@ -191,8 +194,8 @@ export type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
191
194
  _brand: "unitlessLineHeight";
192
195
  };
193
196
  }>;
194
- export type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement | ExcalidrawIframeElement | ExcalidrawEmbeddableElement | ExcalidrawFrameElement | ExcalidrawMagicFrameElement;
195
- export type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawArrowElement;
197
+ export type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawTriangleElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement | ExcalidrawIframeElement | ExcalidrawEmbeddableElement | ExcalidrawFrameElement | ExcalidrawMagicFrameElement;
198
+ export type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawTriangleElement | ExcalidrawEllipseElement | ExcalidrawArrowElement;
196
199
  export type ExcalidrawTextElementWithContainer = {
197
200
  containerId: ExcalidrawTextContainer["id"];
198
201
  } & ExcalidrawTextElement;
@@ -288,7 +291,7 @@ export type SceneElementsMap = Map<ExcalidrawElement["id"], Ordered<ExcalidrawEl
288
291
  export type NonDeletedSceneElementsMap = Map<ExcalidrawElement["id"], Ordered<NonDeletedExcalidrawElement>> & MakeBrand<"NonDeletedSceneElementsMap">;
289
292
  export type ElementsMapOrArray = readonly ExcalidrawElement[] | Readonly<ElementsMap>;
290
293
  export type ExcalidrawLinearElementSubType = "line" | "sharpArrow" | "curvedArrow" | "elbowArrow";
291
- export type ConvertibleGenericTypes = "rectangle" | "diamond" | "ellipse";
294
+ export type ConvertibleGenericTypes = "rectangle" | "diamond" | "triangle" | "ellipse";
292
295
  export type ConvertibleLinearTypes = ExcalidrawLinearElementSubType;
293
296
  export type ConvertibleTypes = ConvertibleGenericTypes | ConvertibleLinearTypes;
294
297
  export {};
@@ -1,7 +1,7 @@
1
1
  import { type GlobalPoint } from "@nous-excalidraw/math";
2
2
  import type { Curve, LineSegment } from "@nous-excalidraw/math";
3
3
  import type { AppState, Zoom } from "@nous-excalidraw/excalidraw/types";
4
- import type { ElementsMap, ExcalidrawArrowElement, ExcalidrawBindableElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawLinearElement, ExcalidrawRectanguloidElement } from "./types";
4
+ import type { ElementsMap, ExcalidrawArrowElement, ExcalidrawBindableElement, ExcalidrawDiamondElement, ExcalidrawTriangleElement, ExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawLinearElement, ExcalidrawRectanguloidElement } from "./types";
5
5
  /**
6
6
  * Returns the **rotated** components of freedraw, line or arrow elements.
7
7
  *
@@ -28,6 +28,8 @@ export declare function getDiamondBaseCorners(element: ExcalidrawDiamondElement,
28
28
  * @returns Tuple of line **unrotated** segments (0) and curves (1)
29
29
  */
30
30
  export declare function deconstructDiamondElement(element: ExcalidrawDiamondElement, offset?: number): [LineSegment<GlobalPoint>[], Curve<GlobalPoint>[]];
31
+ export declare function getTriangleBaseCorners(element: ExcalidrawTriangleElement, offset?: number): Curve<GlobalPoint>[];
32
+ export declare function deconstructTriangleElement(element: ExcalidrawTriangleElement, offset?: number): [LineSegment<GlobalPoint>[], Curve<GlobalPoint>[]];
31
33
  export declare const isPathALoop: (points: ExcalidrawLinearElement["points"],
32
34
  /** supply if you want the loop detection to account for current zoom */
33
35
  zoomValue?: Zoom["value"]) => boolean;
@@ -192,6 +192,8 @@ export declare const actionZoomIn: {
192
192
  zoom: {
193
193
  value: import("../types").NormalizedZoomValue;
194
194
  };
195
+ currentItemStrokeWidth: number;
196
+ currentItemFontSize: number;
195
197
  contextMenu: {
196
198
  items: import("../components/ContextMenu").ContextMenuItems;
197
199
  top: number;
@@ -247,12 +249,10 @@ export declare const actionZoomIn: {
247
249
  currentItemStrokeColor: string;
248
250
  currentItemBackgroundColor: string;
249
251
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
250
- currentItemStrokeWidth: number;
251
252
  currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
252
253
  currentItemRoughness: number;
253
254
  currentItemOpacity: number;
254
255
  currentItemFontFamily: import("@nous-excalidraw/element/types").FontFamilyValues;
255
- currentItemFontSize: number;
256
256
  currentItemTextAlign: import("@nous-excalidraw/element/types").TextAlign;
257
257
  currentItemStartArrowhead: import("@nous-excalidraw/element/types").Arrowhead | null;
258
258
  currentItemEndArrowhead: import("@nous-excalidraw/element/types").Arrowhead | null;
@@ -370,6 +370,8 @@ export declare const actionZoomOut: {
370
370
  zoom: {
371
371
  value: import("../types").NormalizedZoomValue;
372
372
  };
373
+ currentItemStrokeWidth: number;
374
+ currentItemFontSize: number;
373
375
  contextMenu: {
374
376
  items: import("../components/ContextMenu").ContextMenuItems;
375
377
  top: number;
@@ -425,12 +427,10 @@ export declare const actionZoomOut: {
425
427
  currentItemStrokeColor: string;
426
428
  currentItemBackgroundColor: string;
427
429
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
428
- currentItemStrokeWidth: number;
429
430
  currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
430
431
  currentItemRoughness: number;
431
432
  currentItemOpacity: number;
432
433
  currentItemFontFamily: import("@nous-excalidraw/element/types").FontFamilyValues;
433
- currentItemFontSize: number;
434
434
  currentItemTextAlign: import("@nous-excalidraw/element/types").TextAlign;
435
435
  currentItemStartArrowhead: import("@nous-excalidraw/element/types").Arrowhead | null;
436
436
  currentItemEndArrowhead: import("@nous-excalidraw/element/types").Arrowhead | null;
@@ -548,6 +548,8 @@ export declare const actionResetZoom: {
548
548
  zoom: {
549
549
  value: import("../types").NormalizedZoomValue;
550
550
  };
551
+ currentItemStrokeWidth: number;
552
+ currentItemFontSize: number;
551
553
  contextMenu: {
552
554
  items: import("../components/ContextMenu").ContextMenuItems;
553
555
  top: number;
@@ -603,12 +605,10 @@ export declare const actionResetZoom: {
603
605
  currentItemStrokeColor: string;
604
606
  currentItemBackgroundColor: string;
605
607
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
606
- currentItemStrokeWidth: number;
607
608
  currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
608
609
  currentItemRoughness: number;
609
610
  currentItemOpacity: number;
610
611
  currentItemFontFamily: import("@nous-excalidraw/element/types").FontFamilyValues;
611
- currentItemFontSize: number;
612
612
  currentItemTextAlign: import("@nous-excalidraw/element/types").TextAlign;
613
613
  currentItemStartArrowhead: import("@nous-excalidraw/element/types").Arrowhead | null;
614
614
  currentItemEndArrowhead: import("@nous-excalidraw/element/types").Arrowhead | null;
@@ -884,6 +884,40 @@ export declare const actionWrapSelectionInFrame: {
884
884
  link: string | null;
885
885
  locked: boolean;
886
886
  customData?: Record<string, any>;
887
+ }> & {
888
+ type: "triangle";
889
+ } & {
890
+ index: import("@nous-excalidraw/element/types").FractionalIndex;
891
+ }) | (Readonly<{
892
+ id: string;
893
+ x: number;
894
+ y: number;
895
+ strokeColor: string;
896
+ backgroundColor: string;
897
+ fillStyle: import("@nous-excalidraw/element/types").FillStyle;
898
+ strokeWidth: number;
899
+ strokeStyle: import("@nous-excalidraw/element/types").StrokeStyle;
900
+ roundness: null | {
901
+ type: import("@nous-excalidraw/element/types").RoundnessType;
902
+ value?: number;
903
+ };
904
+ roughness: number;
905
+ opacity: number;
906
+ width: number;
907
+ height: number;
908
+ angle: import("@nous-excalidraw/math").Radians;
909
+ seed: number;
910
+ version: number;
911
+ versionNonce: number;
912
+ index: import("@nous-excalidraw/element/types").FractionalIndex | null;
913
+ isDeleted: boolean;
914
+ groupIds: readonly import("@nous-excalidraw/element/types").GroupId[];
915
+ frameId: string | null;
916
+ boundElements: readonly import("@nous-excalidraw/element/types").BoundElement[] | null;
917
+ updated: number;
918
+ link: string | null;
919
+ locked: boolean;
920
+ customData?: Record<string, any>;
887
921
  }> & {
888
922
  type: "ellipse";
889
923
  } & {
@@ -389,6 +389,40 @@ export declare const actionTogglePolygon: {
389
389
  link: string | null;
390
390
  locked: boolean;
391
391
  customData?: Record<string, any>;
392
+ }> & {
393
+ type: "triangle";
394
+ } & {
395
+ index: import("@nous-excalidraw/element/types").FractionalIndex;
396
+ }) | (Readonly<{
397
+ id: string;
398
+ x: number;
399
+ y: number;
400
+ strokeColor: string;
401
+ backgroundColor: string;
402
+ fillStyle: import("@nous-excalidraw/element/types").FillStyle;
403
+ strokeWidth: number;
404
+ strokeStyle: import("@nous-excalidraw/element/types").StrokeStyle;
405
+ roundness: null | {
406
+ type: import("@nous-excalidraw/element/types").RoundnessType;
407
+ value?: number;
408
+ };
409
+ roughness: number;
410
+ opacity: number;
411
+ width: number;
412
+ height: number;
413
+ angle: import("@nous-excalidraw/math").Radians;
414
+ seed: number;
415
+ version: number;
416
+ versionNonce: number;
417
+ index: import("@nous-excalidraw/element/types").FractionalIndex | null;
418
+ isDeleted: boolean;
419
+ groupIds: readonly import("@nous-excalidraw/element/types").GroupId[];
420
+ frameId: string | null;
421
+ boundElements: readonly import("@nous-excalidraw/element/types").BoundElement[] | null;
422
+ updated: number;
423
+ link: string | null;
424
+ locked: boolean;
425
+ customData?: Record<string, any>;
392
426
  }> & {
393
427
  type: "ellipse";
394
428
  } & {
@@ -482,6 +482,12 @@ declare class App extends React.Component<AppProps, AppState> {
482
482
  private getTextElementAtPosition;
483
483
  private isHittingTextAutoResizeHandle;
484
484
  private handleTextAutoResizeHandlePointerDown;
485
+ /**
486
+ * When a frame wins z-order at a point, its full interior still hits — so
487
+ * images/embeds below it in the stack never surface. Prefer the topmost
488
+ * descendant in the same hit stack that passes a real geometry hit.
489
+ */
490
+ private getTopFrameDescendantHitUnderPoint;
485
491
  private getElementAtPosition;
486
492
  private getElementsAtPosition;
487
493
  getElementHitThreshold(element: ExcalidrawElement): number;
@@ -25,6 +25,7 @@ export declare const SelectionIcon: import("react/jsx-runtime").JSX.Element;
25
25
  export declare const LassoIcon: import("react/jsx-runtime").JSX.Element;
26
26
  export declare const RectangleIcon: import("react/jsx-runtime").JSX.Element;
27
27
  export declare const DiamondIcon: import("react/jsx-runtime").JSX.Element;
28
+ export declare const TriangleIcon: import("react/jsx-runtime").JSX.Element;
28
29
  export declare const EllipseIcon: import("react/jsx-runtime").JSX.Element;
29
30
  export declare const ArrowIcon: import("react/jsx-runtime").JSX.Element;
30
31
  export declare const LineIcon: import("react/jsx-runtime").JSX.Element;
@@ -27,6 +27,13 @@ export declare const SHAPES: readonly [{
27
27
  readonly numericKey: "3";
28
28
  readonly fillable: true;
29
29
  readonly toolbar: true;
30
+ }, {
31
+ readonly icon: import("react/jsx-runtime").JSX.Element;
32
+ readonly value: "triangle";
33
+ readonly key: "g";
34
+ readonly numericKey: null;
35
+ readonly fillable: true;
36
+ readonly toolbar: true;
30
37
  }, {
31
38
  readonly icon: import("react/jsx-runtime").JSX.Element;
32
39
  readonly value: "ellipse";
@@ -112,6 +119,13 @@ export declare const getToolbarTools: (app: AppClassProperties) => readonly [{
112
119
  readonly numericKey: "3";
113
120
  readonly fillable: true;
114
121
  readonly toolbar: true;
122
+ }, {
123
+ readonly icon: import("react/jsx-runtime").JSX.Element;
124
+ readonly value: "triangle";
125
+ readonly key: "g";
126
+ readonly numericKey: null;
127
+ readonly fillable: true;
128
+ readonly toolbar: true;
115
129
  }, {
116
130
  readonly icon: import("react/jsx-runtime").JSX.Element;
117
131
  readonly value: "ellipse";
@@ -203,6 +217,13 @@ export declare const getToolbarTools: (app: AppClassProperties) => readonly [{
203
217
  readonly numericKey: "3";
204
218
  readonly fillable: true;
205
219
  readonly toolbar: true;
220
+ } | {
221
+ readonly icon: import("react/jsx-runtime").JSX.Element;
222
+ readonly value: "triangle";
223
+ readonly key: "g";
224
+ readonly numericKey: null;
225
+ readonly fillable: true;
226
+ readonly toolbar: true;
206
227
  } | {
207
228
  readonly icon: import("react/jsx-runtime").JSX.Element;
208
229
  readonly value: "ellipse";
@@ -260,4 +281,4 @@ export declare const getToolbarTools: (app: AppClassProperties) => readonly [{
260
281
  readonly fillable: false;
261
282
  readonly toolbar: false;
262
283
  })[]];
263
- export declare const findShapeByKey: (key: string, app: AppClassProperties) => "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "lasso" | "eraser" | "hand" | "laser" | null;
284
+ export declare const findShapeByKey: (key: string, app: AppClassProperties) => "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "triangle" | "ellipse" | "image" | "freedraw" | "lasso" | "eraser" | "hand" | "laser" | null;
@@ -127,6 +127,7 @@ export type ElementShapes = {
127
127
  rectangle: Drawable;
128
128
  ellipse: Drawable;
129
129
  diamond: Drawable;
130
+ triangle: Drawable;
130
131
  iframe: Drawable;
131
132
  embeddable: Drawable;
132
133
  freedraw: (Drawable | SVGPathString)[];
@@ -9,4 +9,6 @@ export declare const getStateForZoom: ({ viewportX, viewportY, nextZoom, }: {
9
9
  zoom: {
10
10
  value: NormalizedZoomValue;
11
11
  };
12
+ currentItemStrokeWidth: number;
13
+ currentItemFontSize: number;
12
14
  };
@@ -107,5 +107,5 @@ export declare const getSnapLinesAtPointer: (elements: readonly ExcalidrawElemen
107
107
  };
108
108
  snapLines: PointerSnapLine[];
109
109
  };
110
- export declare const isActiveToolNonLinearSnappable: (activeToolType: AppState["activeTool"]["type"]) => activeToolType is "text" | "rectangle" | "diamond" | "ellipse" | "image" | "frame" | "magicframe";
110
+ export declare const isActiveToolNonLinearSnappable: (activeToolType: AppState["activeTool"]["type"]) => activeToolType is "text" | "rectangle" | "diamond" | "triangle" | "ellipse" | "image" | "frame" | "magicframe";
111
111
  export {};
@@ -84,7 +84,7 @@ export type BinaryFileData = {
84
84
  };
85
85
  export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
86
86
  export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
87
- export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser";
87
+ export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "triangle" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser";
88
88
  export type ElementOrToolType = ExcalidrawElementType | ToolType | "custom";
89
89
  export type ActiveTool = {
90
90
  type: ToolType;
@@ -1,5 +1,5 @@
1
1
  import { type GlobalPoint, type LocalPoint } from "@nous-excalidraw/math";
2
- import type { ElementsMap, ExcalidrawBindableElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawEmbeddableElement, ExcalidrawFrameLikeElement, ExcalidrawFreeDrawElement, ExcalidrawIframeElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawRectangleElement, ExcalidrawSelectionElement, ExcalidrawTextElement } from "@nous-excalidraw/element/types";
2
+ import type { ElementsMap, ExcalidrawBindableElement, ExcalidrawDiamondElement, ExcalidrawTriangleElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawEmbeddableElement, ExcalidrawFrameLikeElement, ExcalidrawFreeDrawElement, ExcalidrawIframeElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawRectangleElement, ExcalidrawSelectionElement, ExcalidrawTextElement } from "@nous-excalidraw/element/types";
3
3
  import type { Curve, LineSegment, Polygon, Radians } from "@nous-excalidraw/math";
4
4
  import type { Drawable, Op } from "roughjs/bin/core";
5
5
  export type Polyline<Point extends GlobalPoint | LocalPoint> = LineSegment<Point>[];
@@ -29,7 +29,7 @@ export type GeometricShape<Point extends GlobalPoint | LocalPoint> = {
29
29
  type: "polycurve";
30
30
  data: Polycurve<Point>;
31
31
  };
32
- type RectangularElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement | ExcalidrawImageElement | ExcalidrawIframeElement | ExcalidrawTextElement | ExcalidrawSelectionElement;
32
+ type RectangularElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawTriangleElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement | ExcalidrawImageElement | ExcalidrawIframeElement | ExcalidrawTextElement | ExcalidrawSelectionElement;
33
33
  export declare const getPolygonShape: <Point extends GlobalPoint | LocalPoint>(element: RectangularElement) => GeometricShape<Point>;
34
34
  export declare const getSelectionBoxShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawElement, elementsMap: ElementsMap, padding?: number) => GeometricShape<Point>;
35
35
  export declare const getEllipseShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawEllipseElement) => GeometricShape<Point>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nous-excalidraw/math",
3
- "version": "0.18.4-beta.4",
3
+ "version": "0.18.5-beta.5",
4
4
  "type": "module",
5
5
  "types": "./dist/types/math/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -61,6 +61,6 @@
61
61
  "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
62
62
  },
63
63
  "dependencies": {
64
- "@nous-excalidraw/common": "0.18.4-beta.4"
64
+ "@nous-excalidraw/common": "0.18.5-beta.5"
65
65
  }
66
66
  }
@@ -1,5 +0,0 @@
1
- import type { Theme } from "@nous-excalidraw/element/types";
2
- export declare const LoadingMessage: React.FC<{
3
- delay?: number;
4
- theme?: Theme;
5
- }>;