@dwelle/excalidraw 0.3.40 → 0.3.44

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": "@dwelle/excalidraw",
3
- "version": "0.3.40",
3
+ "version": "0.3.44",
4
4
  "main": "main.js",
5
5
  "types": "types/packages/excalidraw/index.d.ts",
6
6
  "files": [
@@ -32,6 +32,7 @@ export declare const actionClearCanvas: {
32
32
  shown: true;
33
33
  data: import("../charts").Spreadsheet;
34
34
  };
35
+ elementType: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "freedraw";
35
36
  scrollX: number;
36
37
  scrollY: number;
37
38
  viewBackgroundColor: string;
@@ -51,7 +52,6 @@ export declare const actionClearCanvas: {
51
52
  suggestedBindings: import("../element/binding").SuggestedBinding[];
52
53
  editingElement: import("../element/types").NonDeletedExcalidrawElement | null;
53
54
  editingLinearElement: import("../element/linearElementEditor").LinearElementEditor | null;
54
- elementType: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw";
55
55
  exportWithDarkMode: boolean;
56
56
  exportScale: number;
57
57
  currentItemStrokeColor: string;
@@ -104,11 +104,10 @@ declare class App extends React.Component<AppProps, AppState> {
104
104
  private handleCanvasDoubleClick;
105
105
  private getElementLinkAtPosition;
106
106
  private redirectToLink;
107
- private attachLinkListener;
108
- private detachLinkListener;
109
107
  private handleCanvasPointerMove;
110
108
  private handleTouchMove;
111
109
  private handleCanvasPointerDown;
110
+ private handleCanvasPointerUp;
112
111
  private maybeOpenContextMenuAfterPointerDownOnTouchDevices;
113
112
  private maybeCleanupAfterMissingPointerUp;
114
113
  private handleCanvasPanUsingWheelOrSpaceDrag;
@@ -17,10 +17,10 @@ export declare const CURSOR_TYPE: {
17
17
  AUTO: string;
18
18
  };
19
19
  export declare const POINTER_BUTTON: {
20
- MAIN: number;
21
- WHEEL: number;
22
- SECONDARY: number;
23
- TOUCH: number;
20
+ readonly MAIN: 0;
21
+ readonly WHEEL: 1;
22
+ readonly SECONDARY: 2;
23
+ readonly TOUCH: -1;
24
24
  };
25
25
  export declare enum EVENT {
26
26
  COPY = "copy",
@@ -1,13 +1,14 @@
1
1
  /// <reference types="react" />
2
- import { AppState } from "../types";
2
+ import { AppState, ExcalidrawProps } from "../types";
3
3
  import { NonDeletedExcalidrawElement } from "./types";
4
4
  import { Bounds } from "./bounds";
5
5
  import "./Hyperlink.scss";
6
6
  export declare const EXTERNAL_LINK_IMG: HTMLImageElement;
7
- export declare const Hyperlink: ({ element, appState, setAppState, }: {
7
+ export declare const Hyperlink: ({ element, appState, setAppState, onLinkOpen, }: {
8
8
  element: NonDeletedExcalidrawElement;
9
9
  appState: AppState;
10
10
  setAppState: React.Component<any, AppState>["setState"];
11
+ onLinkOpen: ExcalidrawProps["onLinkOpen"];
11
12
  }) => JSX.Element | null;
12
13
  export declare const normalizeLink: (link: string) => string;
13
14
  export declare const isLocalLink: (link: string | null) => boolean;
@@ -110,7 +111,7 @@ export declare const actionLink: {
110
111
  };
111
112
  export declare const getContextMenuLabel: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => "labels.link.edit" | "labels.link.create";
112
113
  export declare const getLinkHandleFromCoords: ([x1, y1, x2, y2]: Bounds, angle: number, appState: AppState) => [x: number, y: number, width: number, height: number];
113
- export declare const isPointHittingLinkIcon: (element: NonDeletedExcalidrawElement, appState: AppState, [x, y]: readonly [number, number]) => boolean;
114
+ export declare const isPointHittingLinkIcon: (element: NonDeletedExcalidrawElement, appState: AppState, [x, y]: readonly [number, number], isMobile: boolean) => boolean;
114
115
  export declare const showHyperlinkTooltip: (element: NonDeletedExcalidrawElement, appState: AppState) => void;
115
116
  export declare const hideHyperlinkToolip: () => void;
116
117
  export declare const shouldHideLinkPopup: (element: NonDeletedExcalidrawElement, appState: AppState, [clientX, clientY]: readonly [number, number]) => Boolean;
@@ -141,7 +141,7 @@ export declare class LinearElementEditor {
141
141
  shouldCacheIgnoreZoom: boolean;
142
142
  showHelpDialog: boolean;
143
143
  toastMessage: string | null;
144
- zenModeEnabled: boolean; /** @returns whether point was dragged */
144
+ zenModeEnabled: boolean;
145
145
  theme: string;
146
146
  gridSize: number | null;
147
147
  viewModeEnabled: boolean;
package/types/keys.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export declare const isDarwin: boolean;
2
2
  export declare const isWindows: boolean;
3
+ export declare const isAndroid: boolean;
3
4
  export declare const CODES: {
4
5
  readonly EQUAL: "Equal";
5
6
  readonly MINUS: "Minus";
package/types/types.d.ts CHANGED
@@ -6,7 +6,7 @@ import { LinearElementEditor } from "./element/linearElementEditor";
6
6
  import { SuggestedBinding } from "./element/binding";
7
7
  import { ImportedDataState } from "./data/types";
8
8
  import type App from "./components/App";
9
- import type { ResolvablePromise } from "./utils";
9
+ import type { ResolvablePromise, throttleRAF } from "./utils";
10
10
  import { Spreadsheet } from "./charts";
11
11
  import { Language } from "./i18n";
12
12
  import { ClipboardData } from "./clipboard";
@@ -210,6 +210,7 @@ export interface ExcalidrawProps {
210
210
  onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
211
211
  autoFocus?: boolean;
212
212
  generateIdForFile?: (file: File) => string | Promise<string>;
213
+ onLinkOpen?: (link: string, event: MouseEvent) => void;
213
214
  }
214
215
  export declare type SceneData = {
215
216
  elements?: ImportedDataState["elements"];
@@ -306,7 +307,7 @@ export declare type PointerDownState = Readonly<{
306
307
  } | null;
307
308
  };
308
309
  eventListeners: {
309
- onMove: null | ((event: PointerEvent) => void);
310
+ onMove: null | ReturnType<typeof throttleRAF>;
310
311
  onUp: null | ((event: PointerEvent) => void);
311
312
  onKeyDown: null | ((event: KeyboardEvent) => void);
312
313
  onKeyUp: null | ((event: KeyboardEvent) => void);
package/types/utils.d.ts CHANGED
@@ -19,6 +19,11 @@ export declare const debounce: <T extends any[]>(fn: (...args: T) => void, timeo
19
19
  flush(): void;
20
20
  cancel(): void;
21
21
  };
22
+ export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void) => {
23
+ (...args: T): void;
24
+ flush(): void;
25
+ cancel(): void;
26
+ };
22
27
  export declare const chunk: <T extends unknown>(array: readonly T[], size: number) => T[][];
23
28
  export declare const selectNode: (node: Element) => void;
24
29
  export declare const removeSelection: () => void;
@@ -82,6 +87,15 @@ export declare const resolvablePromise: <T>() => ResolvablePromise<T>;
82
87
  * @param func handler taking at most single parameter (event).
83
88
  */
84
89
  export declare const withBatchedUpdates: <TFunction extends ((event: any) => void) | (() => void)>(func: Parameters<TFunction>["length"] extends 0 | 1 ? TFunction : never) => TFunction;
90
+ /**
91
+ * barches React state updates and throttles the calls to a single call per
92
+ * animation frame
93
+ */
94
+ export declare const withBatchedUpdatesThrottled: <TFunction extends ((event: any) => void) | (() => void)>(func: Parameters<TFunction>["length"] extends 0 | 1 ? TFunction : never) => {
95
+ (...args: Parameters<TFunction>): void;
96
+ flush(): void;
97
+ cancel(): void;
98
+ };
85
99
  export declare const nFormatter: (num: number, digits: number) => string;
86
100
  export declare const getVersion: () => string;
87
101
  export declare const supportsEmoji: () => boolean;