@zsviczian/excalidraw 0.11.0-obsidian-4 → 0.11.0-obsidian-7

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.
@@ -1,6 +1,7 @@
1
1
  import { AppState, NormalizedZoomValue } from "./types";
2
2
  export declare const getDefaultAppState: () => Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
3
3
  export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>) => {
4
+ elementType?: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser" | undefined;
4
5
  scrollX?: number | undefined;
5
6
  scrollY?: number | undefined;
6
7
  viewBackgroundColor?: string | undefined;
@@ -10,7 +11,6 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
10
11
  shouldCacheIgnoreZoom?: boolean | undefined;
11
12
  theme?: string | undefined;
12
13
  name?: string | undefined;
13
- elementType?: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | undefined;
14
14
  elementLocked?: boolean | undefined;
15
15
  exportBackground?: boolean | undefined;
16
16
  exportEmbedScene?: boolean | undefined;
@@ -57,3 +57,6 @@ export declare const clearAppStateForDatabase: (appState: Partial<AppState>) =>
57
57
  viewBackgroundColor?: string | undefined;
58
58
  gridSize?: number | null | undefined;
59
59
  };
60
+ export declare const isEraserActive: ({ elementType, }: {
61
+ elementType: AppState["elementType"];
62
+ }) => boolean;
@@ -6,15 +6,16 @@ export declare const SelectedShapeActions: ({ appState, elements, renderAction,
6
6
  appState: AppState;
7
7
  elements: readonly ExcalidrawElement[];
8
8
  renderAction: ActionManager["renderAction"];
9
- elementType: ExcalidrawElement["type"];
9
+ elementType: AppState["elementType"];
10
10
  }) => JSX.Element;
11
- export declare const ShapesSwitcher: ({ canvas, elementType, setAppState, onImageAction, }: {
11
+ export declare const ShapesSwitcher: ({ canvas, elementType, setAppState, onImageAction, appState, }: {
12
12
  canvas: HTMLCanvasElement | null;
13
- elementType: ExcalidrawElement["type"];
13
+ elementType: AppState["elementType"];
14
14
  setAppState: React.Component<any, AppState>["setState"];
15
15
  onImageAction: (data: {
16
16
  pointerType: PointerType | null;
17
17
  }) => void;
18
+ appState: AppState;
18
19
  }) => JSX.Element;
19
20
  export declare const ZoomActions: ({ renderAction, zoom, }: {
20
21
  renderAction: ActionManager["renderAction"];
@@ -4,10 +4,10 @@ import { ActionManager } from "../actions/manager";
4
4
  import { RestoredDataState } from "../data/restore";
5
5
  import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
6
6
  import History from "../history";
7
- import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData } from "../types";
7
+ import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, DeviceType } from "../types";
8
8
  import { ImportedDataState } from "../data/types";
9
9
  export declare let showFourthFont: boolean;
10
- export declare const useIsMobile: () => boolean;
10
+ export declare const useDeviceType: () => DeviceType;
11
11
  export declare const useExcalidrawContainer: () => {
12
12
  container: HTMLDivElement | null;
13
13
  id: string | null;
@@ -17,7 +17,7 @@ declare class App extends React.Component<AppProps, AppState> {
17
17
  rc: RoughCanvas | null;
18
18
  unmounted: boolean;
19
19
  actionManager: ActionManager;
20
- isMobile: boolean;
20
+ deviceType: DeviceType;
21
21
  detachIsMobileMqHandler?: () => void;
22
22
  private excalidrawContainerRef;
23
23
  static defaultProps: Partial<AppProps>;
@@ -35,6 +35,10 @@ declare class App extends React.Component<AppProps, AppState> {
35
35
  lastPointerDown: React.PointerEvent<HTMLCanvasElement> | null;
36
36
  lastPointerUp: React.PointerEvent<HTMLElement> | PointerEvent | null;
37
37
  contextMenuOpen: boolean;
38
+ lastScenePointer: {
39
+ x: number;
40
+ y: number;
41
+ } | null;
38
42
  constructor(props: AppProps);
39
43
  private renderCanvas;
40
44
  render(): JSX.Element;
@@ -81,6 +85,7 @@ declare class App extends React.Component<AppProps, AppState> {
81
85
  zoomToFit: (target?: readonly ExcalidrawElement[], maxZoom?: number, margin?: number) => void;
82
86
  updateContainerSize: (containers: NonDeletedExcalidrawElement[]) => void;
83
87
  restore: (data: ImportedDataState) => RestoredDataState;
88
+ setTrayMode: (trayModeEnabled: boolean) => void;
84
89
  clearToast: () => void;
85
90
  setToastMessage: (toastMessage: string) => void;
86
91
  restoreFileFromShare: () => Promise<void>;
@@ -117,6 +122,7 @@ declare class App extends React.Component<AppProps, AppState> {
117
122
  private getElementLinkAtPosition;
118
123
  private redirectToLink;
119
124
  private handleCanvasPointerMove;
125
+ private handleEraser;
120
126
  private handleTouchMove;
121
127
  private handleCanvasPointerDown;
122
128
  private handleCanvasPointerUp;
@@ -144,6 +150,7 @@ declare class App extends React.Component<AppProps, AppState> {
144
150
  private onPointerMoveFromPointerDownHandler;
145
151
  private handlePointerMoveOverScrollbars;
146
152
  private onPointerUpFromPointerDownHandler;
153
+ private eraseElements;
147
154
  private initializeImage;
148
155
  /**
149
156
  * inserts image into elements array and rerenders
@@ -178,4 +178,5 @@ export declare const TextAlignMiddleIcon: React.MemoExoticComponent<({ theme }:
178
178
  }) => JSX.Element>;
179
179
  export declare const publishIcon: JSX.Element;
180
180
  export declare const editIcon: JSX.Element;
181
+ export declare const eraser: JSX.Element;
181
182
  export {};
@@ -56,6 +56,8 @@ export declare const ENV: {
56
56
  };
57
57
  export declare const CLASSES: {
58
58
  SHAPE_ACTIONS_MENU: string;
59
+ SHAPE_ACTIONS_MOBILE_MENU: string;
60
+ MOBILE_TOOLBAR: string;
59
61
  };
60
62
  export declare const FONT_FAMILY: {
61
63
  Virgil: number;
@@ -2,7 +2,7 @@ import { ExcalidrawElement } from "../element/types";
2
2
  import { AppState, BinaryFiles, LibraryItem } from "../types";
3
3
  import { ImportedDataState } from "./types";
4
4
  declare type RestoredAppState = Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
5
- export declare const AllowedExcalidrawElementTypes: Record<ExcalidrawElement["type"], true>;
5
+ export declare const AllowedExcalidrawElementTypes: Record<AppState["elementType"], boolean>;
6
6
  export declare type RestoredDataState = {
7
7
  elements: ExcalidrawElement[];
8
8
  appState: RestoredAppState;
@@ -30,7 +30,7 @@ export declare const actionLink: {
30
30
  suggestedBindings: import("./binding").SuggestedBinding[];
31
31
  editingElement: NonDeletedExcalidrawElement | null;
32
32
  editingLinearElement: import("./linearElementEditor").LinearElementEditor | null;
33
- elementType: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw";
33
+ elementType: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
34
34
  elementLocked: boolean;
35
35
  penMode: boolean;
36
36
  penDetected: boolean;
@@ -1,6 +1,5 @@
1
- import { SHAPES } from "../shapes";
2
1
  import { NonDeletedExcalidrawElement } from "./types";
3
2
  import { AppState, PointerDownState } from "../types";
4
3
  export declare const dragSelectedElements: (pointerDownState: PointerDownState, selectedElements: NonDeletedExcalidrawElement[], pointerX: number, pointerY: number, lockDirection: boolean | undefined, distanceX: number | undefined, distanceY: number | undefined, appState: AppState) => void;
5
4
  export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
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;
5
+ export declare const dragNewElement: (draggingElement: NonDeletedExcalidrawElement, elementType: AppState["elementType"], originX: number, originY: number, x: number, y: number, width: number, height: number, shouldMaintainAspectRatio: boolean, shouldResizeFromCenter: boolean, widthAspectRatio?: number | null | undefined) => void;
@@ -96,7 +96,7 @@ export declare class LinearElementEditor {
96
96
  startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
97
97
  suggestedBindings: import("./binding").SuggestedBinding[];
98
98
  editingElement: import("./types").NonDeletedExcalidrawElement | null;
99
- elementType: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw";
99
+ elementType: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
100
100
  elementLocked: boolean;
101
101
  penMode: boolean;
102
102
  penDetected: boolean;
@@ -140,7 +140,7 @@ export declare class LinearElementEditor {
140
140
  };
141
141
  shouldCacheIgnoreZoom: boolean;
142
142
  showHelpDialog: boolean;
143
- toastMessage: string | null;
143
+ toastMessage: string | null; /** @returns whether point was dragged */
144
144
  zenModeEnabled: boolean;
145
145
  theme: string;
146
146
  gridSize: number | null;
@@ -1,3 +1,4 @@
1
+ import { AppState } from "../types";
1
2
  import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawGenericElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer } from "./types";
2
3
  export declare const isGenericElement: (element: ExcalidrawElement | null) => element is ExcalidrawGenericElement;
3
4
  export declare const isInitializedImageElement: (element: ExcalidrawElement | null) => element is InitializedExcalidrawImageElement;
@@ -6,9 +7,9 @@ export declare const isTextElement: (element: ExcalidrawElement | null) => eleme
6
7
  export declare const isFreeDrawElement: (element?: ExcalidrawElement | null | undefined) => element is ExcalidrawFreeDrawElement;
7
8
  export declare const isFreeDrawElementType: (elementType: ExcalidrawElement["type"]) => boolean;
8
9
  export declare const isLinearElement: (element?: ExcalidrawElement | null | undefined) => element is ExcalidrawLinearElement;
9
- export declare const isLinearElementType: (elementType: ExcalidrawElement["type"]) => boolean;
10
+ export declare const isLinearElementType: (elementType: AppState["elementType"]) => boolean;
10
11
  export declare const isBindingElement: (element?: ExcalidrawElement | null | undefined) => element is ExcalidrawLinearElement;
11
- export declare const isBindingElementType: (elementType: ExcalidrawElement["type"]) => boolean;
12
+ export declare const isBindingElementType: (elementType: AppState["elementType"]) => boolean;
12
13
  export declare const isBindableElement: (element: ExcalidrawElement | null) => element is ExcalidrawBindableElement;
13
14
  export declare const isTextBindableContainer: (element: ExcalidrawElement | null) => element is ExcalidrawTextContainer;
14
15
  export declare const isExcalidrawElement: (element: any) => boolean;
@@ -9,7 +9,11 @@ export default _default;
9
9
  export { getSceneVersion, isInvisiblySmallElement, getNonDeletedElements, } from "../../element";
10
10
  export { defaultLang, languages } from "../../i18n";
11
11
  export { restore, restoreAppState, restoreElements } from "../../data/restore";
12
- export { exportToCanvas, exportToBlob, exportToSvg, serializeAsJSON, loadLibraryFromBlob, loadFromBlob, getFreeDrawSvgPath, getCommonBoundingBox, getMaximumGroups, intersectElementWithLine, determineFocusDistance, } from "../../packages/utils";
12
+ export { exportToCanvas, exportToBlob, exportToSvg, serializeAsJSON, loadLibraryFromBlob, loadFromBlob, getFreeDrawSvgPath, getCommonBoundingBox, //zsviczian
13
+ getMaximumGroups, //zsviczian
14
+ intersectElementWithLine, //zsviczian
15
+ determineFocusDistance, //zsviczian
16
+ measureText, } from "../../packages/utils";
13
17
  export { isLinearElement } from "../../element/typeChecks";
14
18
  export { FONT_FAMILY, THEME } from "../../constants";
15
19
  export { mutateElement, newElementWith, bumpVersion, } from "../../element/mutateElement";
@@ -26,3 +26,4 @@ export { getCommonBoundingBox } from "../element/bounds";
26
26
  export { getMaximumGroups } from "../groups";
27
27
  export { intersectElementWithLine } from "../element/collision";
28
28
  export { determineFocusDistance } from "../element/collision";
29
+ export { measureText } from "../element/textElement";
package/types/types.d.ts CHANGED
@@ -53,7 +53,7 @@ export declare type AppState = {
53
53
  suggestedBindings: SuggestedBinding[];
54
54
  editingElement: NonDeletedExcalidrawElement | null;
55
55
  editingLinearElement: LinearElementEditor | null;
56
- elementType: typeof SHAPES[number]["value"];
56
+ elementType: typeof SHAPES[number]["value"] | "eraser";
57
57
  elementLocked: boolean;
58
58
  penMode: boolean;
59
59
  penDetected: boolean;
@@ -322,6 +322,9 @@ export declare type PointerDownState = Readonly<{
322
322
  boxSelection: {
323
323
  hasOccurred: boolean;
324
324
  };
325
+ elementIdsToErase: {
326
+ [key: ExcalidrawElement["id"]]: boolean;
327
+ };
325
328
  }>;
326
329
  export declare type ExcalidrawImperativeAPI = {
327
330
  updateScene: InstanceType<typeof App>["updateScene"];
@@ -350,5 +353,10 @@ export declare type ExcalidrawImperativeAPI = {
350
353
  sendToBack: (elements: readonly ExcalidrawElement[]) => void;
351
354
  bringToFront: (elements: readonly ExcalidrawElement[]) => void;
352
355
  restore: InstanceType<typeof App>["restore"];
356
+ setTrayMode: InstanceType<typeof App>["setTrayMode"];
357
+ };
358
+ export declare type DeviceType = {
359
+ isMobile: boolean;
360
+ isTouchScreen: boolean;
353
361
  };
354
362
  export {};
package/types/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EVENT } from "./constants";
2
2
  import { FontFamilyValues, FontString } from "./element/types";
3
- import { Zoom } from "./types";
3
+ import { AppState, Zoom } from "./types";
4
4
  export declare const setDateTimeForTests: (dateTime: string) => void;
5
5
  export declare const getDateTime: () => string;
6
6
  export declare const capitalizeString: (str: string) => string;
@@ -31,7 +31,8 @@ export declare const removeSelection: () => void;
31
31
  export declare const distance: (x: number, y: number) => number;
32
32
  export declare const resetCursor: (canvas: HTMLCanvasElement | null) => void;
33
33
  export declare const setCursor: (canvas: HTMLCanvasElement | null, cursor: string) => void;
34
- export declare const setCursorForShape: (canvas: HTMLCanvasElement | null, shape: string) => void;
34
+ export declare const setEraserCursor: (canvas: HTMLCanvasElement | null, theme: AppState["theme"]) => void;
35
+ export declare const setCursorForShape: (canvas: HTMLCanvasElement | null, appState: AppState) => void;
35
36
  export declare const isFullScreen: () => boolean;
36
37
  export declare const allowFullScreen: () => Promise<void>;
37
38
  export declare const exitFullScreen: () => Promise<void>;
@@ -116,3 +117,4 @@ export declare const isTestEnv: () => boolean;
116
117
  export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) => CustomEvent<{
117
118
  nativeEvent: T;
118
119
  }>;
120
+ export declare const updateObject: <T extends Record<string, any>>(obj: T, updates: Partial<T>) => T;