@zsviczian/excalidraw 0.18.0-7 → 0.18.0-8

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": "@zsviczian/excalidraw",
3
- "version": "0.18.0-7",
3
+ "version": "0.18.0-8",
4
4
  "main": "main.js",
5
5
  "module": "./dist/prod/index.js",
6
6
  "types": "types/excalidraw/index.d.ts",
@@ -251,4 +251,7 @@ export declare const safelyParseJSON: (json: string) => Record<string, any> | nu
251
251
  export declare const escapeDoubleQuotes: (str: string) => string;
252
252
  export declare const castArray: <T>(value: T | T[]) => T[];
253
253
  export declare const elementCenterPoint: (element: ExcalidrawElement, xOffset?: number, yOffset?: number) => GlobalPoint;
254
+ /** hack for Array.isArray type guard not working with readonly value[] */
255
+ export declare const isReadonlyArray: (value?: any) => value is readonly any[];
256
+ export declare const sizeOf: (value: readonly number[] | Readonly<Map<any, any>> | Record<any, any>) => number;
254
257
  export {};
@@ -45,8 +45,7 @@ export declare const snapToMid: (element: ExcalidrawBindableElement, p: GlobalPo
45
45
  export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap) => {
46
46
  fixedPoint: FixedPoint;
47
47
  };
48
- export declare const fixDuplicatedBindingsAfterDuplication: (newElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicatedElementsMap: NonDeletedSceneElementsMap) => void;
49
- export declare const fixReversedBindings: (originalElements: Map<string, ExcalidrawElement>, elementsWithClones: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
48
+ export declare const fixDuplicatedBindingsAfterDuplication: (duplicatedElements: ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicateElementsMap: NonDeletedSceneElementsMap) => void;
50
49
  export declare const fixBindingsAfterDeletion: (sceneElements: readonly ExcalidrawElement[], deletedElements: readonly ExcalidrawElement[]) => void;
51
50
  export declare const bindingBorderTest: (element: NonDeleted<ExcalidrawBindableElement>, { x, y }: {
52
51
  x: number;
@@ -1,6 +1,6 @@
1
1
  import type { Degrees, GlobalPoint, LineSegment } from "@excalidraw/math";
2
2
  import type { AppState } from "@excalidraw/excalidraw/types";
3
- import type { ExcalidrawElement, ExcalidrawLinearElement, Arrowhead, ExcalidrawFreeDrawElement, NonDeleted, ElementsMap } from "./types";
3
+ import type { ExcalidrawElement, ExcalidrawLinearElement, Arrowhead, ExcalidrawFreeDrawElement, NonDeleted, ElementsMap, ElementsMapOrArray } from "./types";
4
4
  import type { Drawable, Op } from "roughjs/bin/core";
5
5
  export type RectangleBox = {
6
6
  x: number;
@@ -51,7 +51,7 @@ export declare const getArrowheadSize: (arrowhead: Arrowhead) => number;
51
51
  export declare const getArrowheadAngle: (arrowhead: Arrowhead) => Degrees;
52
52
  export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead) => number[] | null;
53
53
  export declare const getElementBounds: (element: ExcalidrawElement, elementsMap: ElementsMap) => Bounds;
54
- export declare const getCommonBounds: (elements: readonly ExcalidrawElement[], elementsMap?: ElementsMap) => Bounds;
54
+ export declare const getCommonBounds: (elements: ElementsMapOrArray, elementsMap?: ElementsMap) => Bounds;
55
55
  export declare const getDraggedElementsBounds: (elements: ExcalidrawElement[], dragOffset: {
56
56
  x: number;
57
57
  y: number;
@@ -13,13 +13,16 @@ import type { ExcalidrawElement, GroupId } from "./types";
13
13
  * multiple elements at once, share this map
14
14
  * amongst all of them
15
15
  * @param element Element to duplicate
16
- * @param overrides Any element properties to override
17
16
  */
18
- export declare const duplicateElement: <TElement extends ExcalidrawElement>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement, overrides?: Partial<TElement> | undefined, randomizeSeed?: boolean) => Readonly<TElement>;
17
+ export declare const duplicateElement: <TElement extends ExcalidrawElement>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement, randomizeSeed?: boolean) => Readonly<TElement>;
19
18
  export declare const duplicateElements: (opts: {
20
19
  elements: readonly ExcalidrawElement[];
21
20
  randomizeSeed?: boolean | undefined;
22
- overrides?: ((originalElement: ExcalidrawElement) => Partial<ExcalidrawElement>) | undefined;
21
+ overrides?: ((data: {
22
+ duplicateElement: ExcalidrawElement;
23
+ origElement: ExcalidrawElement;
24
+ origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>;
25
+ }) => Partial<ExcalidrawElement>) | undefined;
23
26
  } & ({
24
27
  /**
25
28
  * Duplicates all elements in array.
@@ -42,17 +45,11 @@ export declare const duplicateElements: (opts: {
42
45
  editingGroupId: AppState["editingGroupId"];
43
46
  selectedGroupIds: AppState["selectedGroupIds"];
44
47
  };
45
- /**
46
- * If true, duplicated elements are inserted _before_ specified
47
- * elements. Case: alt-dragging elements to duplicate them.
48
- *
49
- * TODO: remove this once (if) we stop replacing the original element
50
- * with the duplicated one in the scene array.
51
- */
52
- reverseOrder: boolean;
53
48
  })) => {
54
- newElements: ExcalidrawElement[];
55
- elementsWithClones: ExcalidrawElement[];
49
+ duplicatedElements: ExcalidrawElement[];
50
+ duplicateElementsMap: Map<string, ExcalidrawElement>;
51
+ elementsWithDuplicates: ExcalidrawElement[];
52
+ origIdToDuplicateId: Map<string, string>;
56
53
  };
57
54
  /**
58
55
  * Clones ExcalidrawElement data structure. Does not regenerate id, nonce, or
@@ -2,7 +2,7 @@ import type { ExcalidrawElementsIncludingDeleted } from "@excalidraw/excalidraw/
2
2
  import type { AppClassProperties, AppState, StaticCanvasAppState } from "@excalidraw/excalidraw/types";
3
3
  import type { ReadonlySetLike } from "@excalidraw/common/utility-types";
4
4
  import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./types";
5
- export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
5
+ export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[], origElements: readonly ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
6
6
  export declare function isElementIntersectingFrame(element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap): boolean;
7
7
  export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => ExcalidrawElement[];
8
8
  export declare const isElementContainingFrame: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => boolean;
@@ -1,4 +1,5 @@
1
1
  import type { AppState, InteractiveCanvasAppState } from "@excalidraw/excalidraw/types";
2
+ import { LinearElementEditor } from "./linearElementEditor";
2
3
  import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, NonDeletedExcalidrawElement } from "./types";
3
4
  /**
4
5
  * Frames and their containing elements are not to be selected at the same time.
@@ -30,3 +31,13 @@ export declare const getTargetElements: (elements: ElementsMapOrArray, appState:
30
31
  export declare const makeNextSelectedElementIds: (nextSelectedElementIds: AppState["selectedElementIds"], prevState: Pick<AppState, "selectedElementIds">) => Readonly<{
31
32
  [id: string]: true;
32
33
  }>;
34
+ export declare const getSelectionStateForElements: (targetElements: readonly ExcalidrawElement[], allElements: readonly NonDeletedExcalidrawElement[], appState: AppState) => {
35
+ editingGroupId: string | null;
36
+ selectedElementIds: Readonly<{
37
+ [id: string]: true;
38
+ }>;
39
+ selectedGroupIds: {
40
+ [groupId: string]: boolean;
41
+ };
42
+ selectedLinearElement: LinearElementEditor | null;
43
+ };
@@ -149,6 +149,10 @@ declare class App extends React.Component<AppProps, AppState> {
149
149
  x: number;
150
150
  y: number;
151
151
  } | null;
152
+ origin: {
153
+ x: number;
154
+ y: number;
155
+ };
152
156
  };
153
157
  eventListeners: {
154
158
  onMove: {
@@ -214,6 +218,10 @@ declare class App extends React.Component<AppProps, AppState> {
214
218
  x: number;
215
219
  y: number;
216
220
  } | null;
221
+ origin: {
222
+ x: number;
223
+ y: number;
224
+ };
217
225
  };
218
226
  eventListeners: {
219
227
  onMove: {
@@ -14,6 +14,7 @@ type InteractiveCanvasProps = {
14
14
  selectionNonce: number | undefined;
15
15
  scale: number;
16
16
  appState: InteractiveCanvasAppState;
17
+ renderScrollbars: boolean;
17
18
  device: Device;
18
19
  renderInteractiveSceneCallback: (data: RenderInteractiveSceneCallback) => void;
19
20
  handleCanvasRef: (canvas: HTMLCanvasElement | null) => void;
@@ -1,10 +1,9 @@
1
- import type { ExcalidrawElement } from "@excalidraw/element/types";
2
1
  import type { InteractiveCanvasAppState } from "../types";
3
- import type { ScrollBars } from "./types";
2
+ import type { RenderableElementsMap, ScrollBars } from "./types";
4
3
  export declare const SCROLLBAR_MARGIN = 4;
5
4
  export declare const SCROLLBAR_WIDTH = 6;
6
5
  export declare const SCROLLBAR_COLOR = "rgba(128,128,128,0.3)";
7
- export declare const getScrollBars: (elements: readonly ExcalidrawElement[], viewportWidth: number, viewportHeight: number, appState: InteractiveCanvasAppState) => ScrollBars;
6
+ export declare const getScrollBars: (elements: RenderableElementsMap, viewportWidth: number, viewportHeight: number, appState: InteractiveCanvasAppState) => ScrollBars;
8
7
  export declare const isOverScrollBars: (scrollBars: ScrollBars, x: number, y: number) => {
9
8
  isOverEither: boolean;
10
9
  isOverHorizontal: boolean;
@@ -518,6 +518,7 @@ export interface ExcalidrawProps {
518
518
  aiEnabled?: boolean;
519
519
  showDeprecatedFonts?: boolean;
520
520
  insertLinkAction?: (linkVal: string) => void;
521
+ renderScrollbars?: boolean;
521
522
  }
522
523
  export type SceneData = {
523
524
  elements?: ImportedDataState["elements"];
@@ -647,6 +648,10 @@ export type PointerDownState = Readonly<{
647
648
  x: number;
648
649
  y: number;
649
650
  } | null;
651
+ origin: {
652
+ x: number;
653
+ y: number;
654
+ };
650
655
  };
651
656
  eventListeners: {
652
657
  onMove: null | ReturnType<typeof throttleRAF>;