@zsviczian/excalidraw 0.17.6-3 → 0.17.6-31

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 (148) hide show
  1. package/dist/excalidraw.development.js +13100 -1540
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/dist/excalidraw.production.min.js.LICENSE.txt +21 -1
  4. package/dist/styles.development.css +490 -376
  5. package/dist/styles.production.css +10 -8
  6. package/package.json +5 -4
  7. package/types/excalidraw/actions/actionAddToLibrary.d.ts +27 -3
  8. package/types/excalidraw/actions/actionAlign.d.ts +7 -6
  9. package/types/excalidraw/actions/actionBoundText.d.ts +18 -2
  10. package/types/excalidraw/actions/actionCanvas.d.ts +126 -14
  11. package/types/excalidraw/actions/actionClipboard.d.ts +61 -9
  12. package/types/excalidraw/actions/actionCropEditor.d.ts +222 -0
  13. package/types/excalidraw/actions/actionDeleteSelected.d.ts +34 -6
  14. package/types/excalidraw/actions/actionElementLink.d.ts +244 -0
  15. package/types/excalidraw/actions/actionElementLock.d.ts +18 -2
  16. package/types/excalidraw/actions/actionExport.d.ts +77 -8
  17. package/types/excalidraw/actions/actionFinalize.d.ts +18 -2
  18. package/types/excalidraw/actions/actionFrame.d.ts +533 -4
  19. package/types/excalidraw/actions/actionGroup.d.ts +18 -2
  20. package/types/excalidraw/actions/actionLinearEditor.d.ts +9 -1
  21. package/types/excalidraw/actions/actionLink.d.ts +10 -2
  22. package/types/excalidraw/actions/actionMenu.d.ts +23 -2
  23. package/types/excalidraw/actions/actionNavigate.d.ts +18 -2
  24. package/types/excalidraw/actions/actionProperties.d.ts +135 -15
  25. package/types/excalidraw/actions/actionSelectAll.d.ts +9 -1
  26. package/types/excalidraw/actions/actionStyles.d.ts +9 -1
  27. package/types/excalidraw/actions/actionToggleGridMode.d.ts +9 -1
  28. package/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +9 -1
  29. package/types/excalidraw/actions/actionToggleSearchMenu.d.ts +14 -1
  30. package/types/excalidraw/actions/actionToggleStats.d.ts +9 -1
  31. package/types/excalidraw/actions/actionToggleViewMode.d.ts +9 -1
  32. package/types/excalidraw/actions/actionToggleZenMode.d.ts +9 -1
  33. package/types/excalidraw/actions/index.d.ts +1 -0
  34. package/types/excalidraw/actions/shortcuts.d.ts +1 -1
  35. package/types/excalidraw/actions/types.d.ts +1 -1
  36. package/types/excalidraw/align.d.ts +2 -1
  37. package/types/excalidraw/change.d.ts +2 -2
  38. package/types/excalidraw/clipboard.d.ts +27 -5
  39. package/types/excalidraw/components/Actions.d.ts +2 -1
  40. package/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
  41. package/types/excalidraw/components/App.d.ts +21 -5
  42. package/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  43. package/types/excalidraw/components/ElementLinkDialog.d.ts +11 -0
  44. package/types/excalidraw/components/EyeDropper.d.ts +1 -1
  45. package/types/excalidraw/components/IconPicker.d.ts +2 -2
  46. package/types/excalidraw/components/LayerUI.d.ts +2 -1
  47. package/types/excalidraw/components/LibraryMenu.d.ts +1 -1
  48. package/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  49. package/types/excalidraw/components/Range.d.ts +8 -0
  50. package/types/excalidraw/components/SearchMenu.d.ts +1 -1
  51. package/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
  52. package/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
  53. package/types/excalidraw/components/Stats/utils.d.ts +1 -1
  54. package/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +1 -7
  55. package/types/excalidraw/components/TTDDialog/MermaidToExcalidrawLib.d.ts +10 -0
  56. package/types/excalidraw/components/TTDDialog/common.d.ts +2 -2
  57. package/types/excalidraw/components/hyperlink/Hyperlink.d.ts +1 -1
  58. package/types/excalidraw/components/hyperlink/helpers.d.ts +1 -0
  59. package/types/excalidraw/components/icons.d.ts +11 -0
  60. package/types/excalidraw/constants.d.ts +5 -1
  61. package/types/excalidraw/context/tunnels.d.ts +2 -1
  62. package/types/excalidraw/data/blob.d.ts +4 -0
  63. package/types/excalidraw/data/encode.d.ts +6 -5
  64. package/types/excalidraw/data/filesystem.d.ts +2 -1
  65. package/types/excalidraw/data/image.d.ts +0 -6
  66. package/types/excalidraw/data/library.d.ts +9 -3
  67. package/types/excalidraw/data/url.d.ts +0 -1
  68. package/types/excalidraw/dist/excalidraw.production.min.d.ts +3 -1
  69. package/types/excalidraw/editor-jotai.d.ts +56 -0
  70. package/types/excalidraw/element/binding.d.ts +10 -7
  71. package/types/excalidraw/element/cropElement.d.ts +19 -0
  72. package/types/excalidraw/element/elbowArrow.d.ts +16 -0
  73. package/types/excalidraw/element/elementLink.d.ts +13 -0
  74. package/types/excalidraw/element/embeddable.d.ts +9 -1
  75. package/types/excalidraw/element/flowchart.d.ts +1 -1
  76. package/types/excalidraw/element/heading.d.ts +5 -1
  77. package/types/excalidraw/element/image.d.ts +1 -1
  78. package/types/excalidraw/element/linearElementEditor.d.ts +9 -10
  79. package/types/excalidraw/element/mutateElement.d.ts +3 -1
  80. package/types/excalidraw/element/newElement.d.ts +9 -7
  81. package/types/excalidraw/element/resizeElements.d.ts +27 -5
  82. package/types/excalidraw/element/textElement.d.ts +14 -4
  83. package/types/excalidraw/element/textWrapping.d.ts +13 -0
  84. package/types/excalidraw/element/transformHandles.d.ts +1 -1
  85. package/types/excalidraw/element/types.d.ts +33 -1
  86. package/types/excalidraw/errors.d.ts +7 -0
  87. package/types/excalidraw/fonts/{woff2/Cascadia → Cascadia}/index.d.ts +1 -1
  88. package/types/excalidraw/fonts/ComicShanns/index.d.ts +2 -0
  89. package/types/excalidraw/fonts/{woff2/Emoji → Emoji}/index.d.ts +1 -1
  90. package/types/excalidraw/fonts/ExcalidrawFontFace.d.ts +2 -8
  91. package/types/excalidraw/fonts/{woff2/Excalifont → Excalifont}/index.d.ts +1 -1
  92. package/types/excalidraw/fonts/Fonts.d.ts +100 -0
  93. package/types/excalidraw/fonts/{woff2/Helvetica → Helvetica}/index.d.ts +1 -1
  94. package/types/excalidraw/fonts/{woff2/Liberation → Liberation}/index.d.ts +1 -1
  95. package/types/excalidraw/fonts/{woff2/Lilita → Lilita}/index.d.ts +1 -1
  96. package/types/excalidraw/fonts/{woff2/Nunito → Nunito}/index.d.ts +1 -1
  97. package/types/excalidraw/fonts/{woff2/Virgil → Virgil}/index.d.ts +1 -1
  98. package/types/excalidraw/fonts/{woff2/Xiaolai → Xiaolai}/index.d.ts +1 -1
  99. package/types/excalidraw/fonts/index.d.ts +1 -87
  100. package/types/excalidraw/frame.d.ts +11 -5
  101. package/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  102. package/types/excalidraw/index.d.ts +4 -3
  103. package/types/excalidraw/keys.d.ts +107 -0
  104. package/types/excalidraw/obsidianUtils.d.ts +9 -4
  105. package/types/excalidraw/renderer/renderElement.d.ts +3 -2
  106. package/types/excalidraw/scene/Scene.d.ts +1 -0
  107. package/types/excalidraw/scene/comparisons.d.ts +1 -0
  108. package/types/excalidraw/scene/export.d.ts +8 -0
  109. package/types/excalidraw/scene/types.d.ts +7 -0
  110. package/types/excalidraw/types.d.ts +25 -1
  111. package/types/excalidraw/utils.d.ts +7 -1
  112. package/types/excalidraw/visualdebug.d.ts +8 -1
  113. package/types/math/line.d.ts +19 -0
  114. package/types/math/point.d.ts +10 -0
  115. package/types/math/utils.d.ts +1 -0
  116. package/types/math/vector.d.ts +4 -0
  117. package/types/utils/export.d.ts +6 -4
  118. package/types/excalidraw/components/MagicSettings.d.ts +0 -8
  119. package/types/excalidraw/components/Stats.d.ts +0 -11
  120. package/types/excalidraw/data/magic.d.ts +0 -23
  121. package/types/excalidraw/element/routing.d.ts +0 -12
  122. package/types/excalidraw/fonts/ExcalidrawFont.d.ts +0 -37
  123. package/types/excalidraw/fonts/wasm/hb-subset.bindings.d.ts +0 -45
  124. package/types/excalidraw/fonts/wasm/hb-subset.loader.d.ts +0 -5
  125. package/types/excalidraw/fonts/wasm/hb-subset.wasm.d.ts +0 -2
  126. package/types/excalidraw/fonts/wasm/woff2.bindings.d.ts +0 -31
  127. package/types/excalidraw/fonts/wasm/woff2.loader.d.ts +0 -6
  128. package/types/excalidraw/fonts/wasm/woff2.wasm.d.ts +0 -2
  129. package/types/excalidraw/fonts/woff2/Comic/index.d.ts +0 -2
  130. package/types/excalidraw/ga.d.ts +0 -63
  131. package/types/excalidraw/gadirections.d.ts +0 -8
  132. package/types/excalidraw/galines.d.ts +0 -22
  133. package/types/excalidraw/gapoints.d.ts +0 -7
  134. package/types/excalidraw/gatransforms.d.ts +0 -10
  135. package/types/excalidraw/jotai.d.ts +0 -34
  136. package/types/excalidraw/math.d.ts +0 -79
  137. package/types/excalidraw/scene/Fonts.d.ts +0 -19
  138. package/types/utils/geometry/geometry.d.ts +0 -89
  139. /package/types/excalidraw/fonts/{metadata.d.ts → FontMetadata.d.ts} +0 -0
  140. /package/types/excalidraw/{fonts/wasm/hb-subset-bindings.d.ts → subset/harfbuzz/harfbuzz-bindings.d.ts} +0 -0
  141. /package/types/excalidraw/{fonts/wasm/hb-subset-loader.d.ts → subset/harfbuzz/harfbuzz-loader.d.ts} +0 -0
  142. /package/types/excalidraw/{fonts/wasm/hb-subset-wasm.d.ts → subset/harfbuzz/harfbuzz-wasm.d.ts} +0 -0
  143. /package/types/excalidraw/{fonts/subset → subset}/subset-main.d.ts +0 -0
  144. /package/types/excalidraw/{fonts/subset → subset}/subset-shared.chunk.d.ts +0 -0
  145. /package/types/excalidraw/{fonts/subset → subset}/subset-worker.chunk.d.ts +0 -0
  146. /package/types/excalidraw/{fonts/wasm → subset/woff2}/woff2-bindings.d.ts +0 -0
  147. /package/types/excalidraw/{fonts/wasm → subset/woff2}/woff2-loader.d.ts +0 -0
  148. /package/types/excalidraw/{fonts/wasm → subset/woff2}/woff2-wasm.d.ts +0 -0
@@ -164,7 +164,6 @@ export declare const IMAGE_MIME_TYPES: {
164
164
  readonly avif: "image/avif";
165
165
  readonly jfif: "image/jfif";
166
166
  };
167
- export declare const ALLOWED_PASTE_MIME_TYPES: readonly ["text/plain", "text/html"];
168
167
  export declare const MIME_TYPES: {
169
168
  readonly svg: "image/svg+xml";
170
169
  readonly png: "image/png";
@@ -175,6 +174,8 @@ export declare const MIME_TYPES: {
175
174
  readonly ico: "image/x-icon";
176
175
  readonly avif: "image/avif";
177
176
  readonly jfif: "image/jfif";
177
+ readonly text: "text/plain";
178
+ readonly html: "text/html";
178
179
  readonly json: "application/json";
179
180
  readonly excalidraw: "application/vnd.excalidraw+json";
180
181
  readonly excalidrawlib: "application/vnd.excalidrawlib+json";
@@ -182,6 +183,7 @@ export declare const MIME_TYPES: {
182
183
  readonly "excalidraw.png": "image/png";
183
184
  readonly binary: "application/octet-stream";
184
185
  };
186
+ export declare const ALLOWED_PASTE_MIME_TYPES: readonly ["text/plain", "text/html", ...("image/svg+xml" | "image/png" | "image/jpeg" | "image/gif" | "image/webp" | "image/bmp" | "image/x-icon" | "image/avif" | "image/jfif")[]];
185
187
  export declare const EXPORT_IMAGE_TYPES: {
186
188
  readonly png: "png";
187
189
  readonly svg: "svg";
@@ -320,3 +322,5 @@ export declare const MIN_WIDTH_OR_HEIGHT = 1;
320
322
  export declare const ARROW_TYPE: {
321
323
  [T in AppState["currentItemArrowType"]]: T;
322
324
  };
325
+ export declare const DEFAULT_REDUCED_GLOBAL_ALPHA = 0.3;
326
+ export declare const ELEMENT_LINK_KEY = "element";
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import tunnel from "tunnel-rat";
3
+ import { createIsolation } from "jotai-scope";
3
4
  export type Tunnel = ReturnType<typeof tunnel>;
4
5
  type TunnelsContextValue = {
5
6
  MainMenuTunnel: Tunnel;
@@ -12,7 +13,7 @@ type TunnelsContextValue = {
12
13
  DefaultSidebarTabTriggersTunnel: Tunnel;
13
14
  OverwriteConfirmDialogTunnel: Tunnel;
14
15
  TTDDialogTriggerTunnel: Tunnel;
15
- jotaiScope: symbol;
16
+ tunnelsJotai: ReturnType<typeof createIsolation>;
16
17
  };
17
18
  export declare const TunnelsContext: React.Context<TunnelsContextValue>;
18
19
  export declare const useTunnels: () => TunnelsContextValue;
@@ -8,6 +8,7 @@ export declare const getMimeType: (blob: Blob | string) => string;
8
8
  export declare const getFileHandleType: (handle: FileSystemHandle | null) => string | null;
9
9
  export declare const isImageFileHandleType: (type: string | null) => type is "png" | "svg";
10
10
  export declare const isImageFileHandle: (handle: FileSystemHandle | null) => boolean;
11
+ export declare const isSupportedImageFileType: (type: string | null | undefined) => boolean;
11
12
  export declare const isSupportedImageFile: (blob: Blob | null | undefined) => blob is Blob & {
12
13
  type: ValueOf<typeof IMAGE_MIME_TYPES>;
13
14
  };
@@ -25,8 +26,11 @@ export declare const canvasToBlob: (canvas: HTMLCanvasElement | Promise<HTMLCanv
25
26
  /** generates SHA-1 digest from supplied file (if not supported, falls back
26
27
  to a 40-char base64 random id) */
27
28
  export declare const generateIdFromFile: (file: File) => Promise<FileId>;
29
+ /** async. For sync variant, use getDataURL_sync */
28
30
  export declare const getDataURL: (file: Blob | File) => Promise<DataURL>;
31
+ export declare const getDataURL_sync: (data: string | Uint8Array | ArrayBuffer, mimeType: ValueOf<typeof MIME_TYPES>) => DataURL;
29
32
  export declare const dataURLToFile: (dataURL: DataURL, filename?: string) => File;
33
+ export declare const dataURLToString: (dataURL: DataURL) => string;
30
34
  export declare const resizeImageFile: (file: File, opts: {
31
35
  /** undefined indicates auto */
32
36
  outputType?: (typeof MIME_TYPES)["jpg"];
@@ -1,11 +1,12 @@
1
- export declare const toByteString: (data: string | Uint8Array | ArrayBuffer) => Promise<string>;
1
+ export declare const toByteString: (data: string | Uint8Array | ArrayBuffer) => string;
2
2
  /**
3
3
  * @param isByteString set to true if already byte string to prevent bloat
4
4
  * due to reencoding
5
5
  */
6
- export declare const stringToBase64: (str: string, isByteString?: boolean) => Promise<string>;
7
- export declare const base64ToString: (base64: string, isByteString?: boolean) => Promise<string>;
6
+ export declare const stringToBase64: (str: string, isByteString?: boolean) => string;
7
+ export declare const base64ToString: (base64: string, isByteString?: boolean) => string;
8
8
  export declare const base64ToArrayBuffer: (base64: string) => ArrayBuffer;
9
+ export declare const base64urlToString: (str: string) => string;
9
10
  type EncodedData = {
10
11
  encoded: string;
11
12
  encoding: "bstring";
@@ -21,8 +22,8 @@ export declare const encode: ({ text, compress, }: {
21
22
  text: string;
22
23
  /** defaults to `true`. If compression fails, falls back to bstring alone. */
23
24
  compress?: boolean | undefined;
24
- }) => Promise<EncodedData>;
25
- export declare const decode: (data: EncodedData) => Promise<string>;
25
+ }) => EncodedData;
26
+ export declare const decode: (data: EncodedData) => string;
26
27
  /**
27
28
  * The returned buffer has following format:
28
29
  * `[]` refers to a buffers wrapper (see `concatBuffers`)
@@ -12,9 +12,10 @@ export declare const fileSave: (blob: Blob | Promise<Blob>, opts: {
12
12
  name: string;
13
13
  /** file extension */
14
14
  extension: FILE_EXTENSION;
15
+ mimeTypes?: string[];
15
16
  description: string;
16
17
  /** existing FileSystemHandle */
17
18
  fileHandle?: FileSystemHandle | null;
18
19
  }) => Promise<FileSystemHandle | null>;
19
- export type { FileSystemHandle };
20
20
  export { nativeFileSystemSupported };
21
+ export type { FileSystemHandle };
@@ -7,9 +7,3 @@ export declare const encodePngMetadata: ({ blob, metadata, }: {
7
7
  metadata: string;
8
8
  }) => Promise<Blob>;
9
9
  export declare const decodePngMetadata: (blob: Blob) => Promise<string>;
10
- export declare const encodeSvgMetadata: ({ text }: {
11
- text: string;
12
- }) => Promise<string>;
13
- export declare const decodeSvgMetadata: ({ svg }: {
14
- svg: string;
15
- }) => Promise<string>;
@@ -37,7 +37,7 @@ export interface LibraryMigrationAdapter {
37
37
  /** clears entire storage afterwards */
38
38
  clear(): MaybePromise<void>;
39
39
  }
40
- export declare const libraryItemsAtom: import("jotai").PrimitiveAtom<{
40
+ export declare const libraryItemsAtom: import("jotai/vanilla/atom").PrimitiveAtom<{
41
41
  status: "loading" | "loaded";
42
42
  /** indicates whether library is initialized with library items (has gone
43
43
  * through at least one update). Used in UI. Specific to this atom only. */
@@ -83,6 +83,7 @@ declare class Library {
83
83
  }
84
84
  export default Library;
85
85
  export declare const distributeLibraryItemsOnSquareGrid: (libraryItems: LibraryItems) => ExcalidrawElement[];
86
+ export declare const validateLibraryUrl: (libraryUrl: string, validator?: string[] | ((libraryUrl: string) => boolean)) => true;
86
87
  export declare const parseLibraryTokensFromUrl: () => {
87
88
  libraryUrl: string;
88
89
  idToken: string | null;
@@ -90,9 +91,14 @@ export declare const parseLibraryTokensFromUrl: () => {
90
91
  export declare const getLibraryItemsHash: (items: LibraryItems) => number;
91
92
  export declare const useHandleLibrary: (opts: {
92
93
  excalidrawAPI: ExcalidrawImperativeAPI | null;
94
+ /**
95
+ * Return `true` if the library install url should be allowed.
96
+ * If not supplied, only the excalidraw.com base domain is allowed.
97
+ */
98
+ validateLibraryUrl?: ((libraryUrl: string) => boolean) | undefined;
93
99
  } & ({
94
100
  /** @deprecated we recommend using `opts.adapter` instead */
95
- getInitialLibraryItems?: () => MaybePromise<LibraryItemsSource>;
101
+ getInitialLibraryItems?: (() => MaybePromise<LibraryItemsSource>) | undefined;
96
102
  } | {
97
103
  adapter: LibraryPersistenceAdapter;
98
104
  /**
@@ -102,5 +108,5 @@ export declare const useHandleLibrary: (opts: {
102
108
  *
103
109
  * Can be a different LibraryPersistenceAdapter.
104
110
  */
105
- migrationAdapter?: LibraryMigrationAdapter;
111
+ migrationAdapter?: LibraryMigrationAdapter | undefined;
106
112
  })) => void;
@@ -1,4 +1,3 @@
1
- export declare const sanitizeHTMLAttribute: (html: string) => string;
2
1
  export declare const normalizeLink: (link: string) => string;
3
2
  export declare const isLocalLink: (link: string | null) => boolean;
4
3
  /**
@@ -1 +1,3 @@
1
- export const ExcalidrawLib: {};
1
+ declare const _exports: any;
2
+ export = _exports;
3
+ export const ExcalidrawLib: any;
@@ -0,0 +1,56 @@
1
+ import { atom, createStore, type PrimitiveAtom } from "jotai";
2
+ import { createIsolation } from "jotai-scope";
3
+ export { atom, PrimitiveAtom };
4
+ export declare const useAtom: typeof import("jotai").useAtom, useSetAtom: typeof import("jotai").useSetAtom, useAtomValue: typeof import("jotai").useAtomValue, useStore: (options?: {
5
+ store?: {
6
+ get: <Value>(atom: import("jotai").Atom<Value>) => Value;
7
+ set: <Value_1, Args extends unknown[], Result>(atom: import("jotai").WritableAtom<Value_1, Args, Result>, ...args: Args) => Result;
8
+ sub: (atom: import("jotai").Atom<unknown>, listener: () => void) => () => void;
9
+ } | ({
10
+ get: <Value_2>(atom: import("jotai").Atom<Value_2>) => Value_2;
11
+ set: <Value_1_1, Args_1 extends unknown[], Result_1>(atom: import("jotai").WritableAtom<Value_1_1, Args_1, Result_1>, ...args: Args_1) => Result_1;
12
+ sub: (atom: import("jotai").Atom<unknown>, listener: () => void) => () => void;
13
+ } & {
14
+ dev4_get_internal_weak_map: () => WeakMap<import("jotai").Atom<unknown>, {
15
+ readonly d: Map<import("jotai").Atom<unknown>, number>;
16
+ readonly p: Set<import("jotai").Atom<unknown>>;
17
+ n: number;
18
+ m?: {
19
+ readonly l: Set<() => void>;
20
+ readonly d: Set<import("jotai").Atom<unknown>>;
21
+ readonly t: Set<import("jotai").Atom<unknown>>;
22
+ u?: (() => void) | undefined;
23
+ } | undefined;
24
+ v?: unknown;
25
+ e?: unknown;
26
+ }>;
27
+ dev4_get_mounted_atoms: () => Set<import("jotai").Atom<unknown>>;
28
+ dev4_restore_atoms: (values: Iterable<readonly [import("jotai").Atom<unknown>, unknown]>) => void;
29
+ }) | undefined;
30
+ } | undefined) => {
31
+ get: <Value_3>(atom: import("jotai").Atom<Value_3>) => Value_3;
32
+ set: <Value_1_2, Args_2 extends unknown[], Result_2>(atom: import("jotai").WritableAtom<Value_1_2, Args_2, Result_2>, ...args: Args_2) => Result_2;
33
+ sub: (atom: import("jotai").Atom<unknown>, listener: () => void) => () => void;
34
+ } | ({
35
+ get: <Value_4>(atom: import("jotai").Atom<Value_4>) => Value_4;
36
+ set: <Value_1_3, Args_3 extends unknown[], Result_3>(atom: import("jotai").WritableAtom<Value_1_3, Args_3, Result_3>, ...args: Args_3) => Result_3;
37
+ sub: (atom: import("jotai").Atom<unknown>, listener: () => void) => () => void;
38
+ } & {
39
+ dev4_get_internal_weak_map: () => WeakMap<import("jotai").Atom<unknown>, {
40
+ readonly d: Map<import("jotai").Atom<unknown>, number>;
41
+ readonly p: Set<import("jotai").Atom<unknown>>;
42
+ n: number;
43
+ m?: {
44
+ readonly l: Set<() => void>;
45
+ readonly d: Set<import("jotai").Atom<unknown>>;
46
+ readonly t: Set<import("jotai").Atom<unknown>>;
47
+ u?: (() => void) | undefined;
48
+ } | undefined;
49
+ v?: unknown;
50
+ e?: unknown;
51
+ }>;
52
+ dev4_get_mounted_atoms: () => Set<import("jotai").Atom<unknown>>;
53
+ dev4_restore_atoms: (values: Iterable<readonly [import("jotai").Atom<unknown>, unknown]>) => void;
54
+ });
55
+ export declare const EditorJotaiProvider: ReturnType<typeof createIsolation>["Provider"];
56
+ export declare const editorJotaiStore: ReturnType<typeof createStore>;
@@ -15,9 +15,11 @@ export type SuggestedPointBinding = [
15
15
  export declare const shouldEnableBindingForPointerEvent: (event: React.PointerEvent<HTMLElement>) => boolean;
16
16
  export declare const isBindingEnabled: (appState: AppState) => boolean;
17
17
  export declare const FIXED_BINDING_DISTANCE = 5;
18
+ export declare const BINDING_HIGHLIGHT_THICKNESS = 10;
19
+ export declare const BINDING_HIGHLIGHT_OFFSET = 4;
18
20
  export declare const bindOrUnbindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, startBindingElement: ExcalidrawBindableElement | null | "keep", endBindingElement: ExcalidrawBindableElement | null | "keep", elementsMap: NonDeletedSceneElementsMap, scene: Scene) => void;
19
- export declare const bindOrUnbindLinearElements: (selectedElements: NonDeleted<ExcalidrawLinearElement>[], elementsMap: NonDeletedSceneElementsMap, elements: readonly NonDeletedExcalidrawElement[], scene: Scene, isBindingEnabled: boolean, draggingPoints: readonly number[] | null) => void;
20
- export declare const getSuggestedBindingsForArrows: (selectedElements: NonDeleted<ExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap) => SuggestedBinding[];
21
+ export declare const bindOrUnbindLinearElements: (selectedElements: NonDeleted<ExcalidrawLinearElement>[], elementsMap: NonDeletedSceneElementsMap, elements: readonly NonDeletedExcalidrawElement[], scene: Scene, isBindingEnabled: boolean, draggingPoints: readonly number[] | null, zoom?: AppState["zoom"]) => void;
22
+ export declare const getSuggestedBindingsForArrows: (selectedElements: NonDeleted<ExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => SuggestedBinding[];
21
23
  export declare const maybeBindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, appState: AppState, pointerCoords: {
22
24
  x: number;
23
25
  y: number;
@@ -27,16 +29,16 @@ export declare const isLinearElementSimpleAndAlreadyBound: (linearElement: NonDe
27
29
  export declare const getHoveredElementForBinding: (pointerCoords: {
28
30
  x: number;
29
31
  y: number;
30
- }, elements: readonly NonDeletedExcalidrawElement[], elementsMap: NonDeletedSceneElementsMap, fullShape?: boolean) => NonDeleted<ExcalidrawBindableElement> | null;
32
+ }, elements: readonly NonDeletedExcalidrawElement[], elementsMap: NonDeletedSceneElementsMap, zoom?: AppState["zoom"], fullShape?: boolean, considerAllElements?: boolean) => NonDeleted<ExcalidrawBindableElement> | null;
31
33
  export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap, options?: {
32
34
  simultaneouslyUpdated?: readonly ExcalidrawElement[];
33
- oldSize?: {
35
+ newSize?: {
34
36
  width: number;
35
37
  height: number;
36
38
  };
37
39
  changedElements?: Map<string, OrderedExcalidrawElement>;
38
40
  }) => void;
39
- export declare const getHeadingForElbowArrowSnap: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined | null, aabb: Bounds | undefined | null, elementsMap: ElementsMap, origPoint: GlobalPoint) => Heading;
41
+ export declare const getHeadingForElbowArrowSnap: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined | null, aabb: Bounds | undefined | null, elementsMap: ElementsMap, origPoint: GlobalPoint, zoom?: AppState["zoom"]) => Heading;
40
42
  export declare const bindPointToSnapToElementOutline: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined, elementsMap: ElementsMap) => GlobalPoint;
41
43
  export declare const avoidRectangularCorner: (element: ExcalidrawBindableElement, p: GlobalPoint) => GlobalPoint;
42
44
  export declare const snapToMid: (element: ExcalidrawBindableElement, p: GlobalPoint, tolerance?: number) => GlobalPoint;
@@ -48,8 +50,8 @@ export declare const fixBindingsAfterDeletion: (sceneElements: readonly Excalidr
48
50
  export declare const bindingBorderTest: (element: NonDeleted<ExcalidrawBindableElement>, { x, y }: {
49
51
  x: number;
50
52
  y: number;
51
- }, elementsMap: NonDeletedSceneElementsMap, fullShape?: boolean) => boolean;
52
- export declare const maxBindingGap: (element: ExcalidrawElement, elementWidth: number, elementHeight: number) => number;
53
+ }, elementsMap: NonDeletedSceneElementsMap, zoom?: AppState["zoom"], fullShape?: boolean) => boolean;
54
+ export declare const maxBindingGap: (element: ExcalidrawElement, elementWidth: number, elementHeight: number, zoom?: AppState["zoom"]) => number;
53
55
  export declare const distanceToBindableElement: (element: ExcalidrawBindableElement, point: GlobalPoint, elementsMap: ElementsMap) => number;
54
56
  export declare const determineFocusDistance: (element: ExcalidrawBindableElement, a: GlobalPoint, b: GlobalPoint, elementsMap: ElementsMap) => number;
55
57
  export declare const intersectElementWithLine: (element: ExcalidrawBindableElement, a: GlobalPoint, b: GlobalPoint, gap: number | undefined, elementsMap: ElementsMap) => GlobalPoint[] | undefined;
@@ -95,5 +97,6 @@ export declare class BindableElement {
95
97
  static rebindAffected: (elements: ElementsMap, bindableElement: ExcalidrawElement | undefined, updateElementWith: (affected: ExcalidrawElement, updates: ElementUpdate<ExcalidrawElement>) => void) => void;
96
98
  }
97
99
  export declare const getGlobalFixedPointForBindableElement: (fixedPointRatio: [number, number], element: ExcalidrawBindableElement) => GlobalPoint;
100
+ export declare const getGlobalFixedPoints: (arrow: ExcalidrawElbowArrowElement, elementsMap: ElementsMap) => [GlobalPoint, GlobalPoint];
98
101
  export declare const getArrowLocalFixedPoints: (arrow: ExcalidrawElbowArrowElement, elementsMap: ElementsMap) => LocalPoint[];
99
102
  export declare const normalizeFixedPoint: <T extends FixedPoint | null>(fixedPoint: T) => T extends null ? null : FixedPoint;
@@ -0,0 +1,19 @@
1
+ import type { TransformHandleType } from "./transformHandles";
2
+ import type { ElementsMap, ExcalidrawImageElement, ImageCrop } from "./types";
3
+ export declare const MINIMAL_CROP_SIZE = 10;
4
+ export declare const cropElement: (element: ExcalidrawImageElement, transformHandle: TransformHandleType, naturalWidth: number, naturalHeight: number, pointerX: number, pointerY: number, widthAspectRatio?: number) => {
5
+ x: number;
6
+ y: number;
7
+ width: number;
8
+ height: number;
9
+ crop: ImageCrop | null;
10
+ };
11
+ export declare const getUncroppedImageElement: (element: ExcalidrawImageElement, elementsMap: ElementsMap) => ExcalidrawImageElement;
12
+ export declare const getUncroppedWidthAndHeight: (element: ExcalidrawImageElement) => {
13
+ width: number;
14
+ height: number;
15
+ };
16
+ export declare const getFlipAdjustedCropPosition: (element: ExcalidrawImageElement, natural?: boolean) => {
17
+ x: number;
18
+ y: number;
19
+ } | null;
@@ -0,0 +1,16 @@
1
+ import { type LocalPoint } from "../../math";
2
+ import { type ElementUpdate } from "./mutateElement";
3
+ import { type ExcalidrawElbowArrowElement, type NonDeletedSceneElementsMap, type SceneElementsMap } from "./types";
4
+ import type { FixedPointBinding, FixedSegment } from "./types";
5
+ export declare const BASE_PADDING = 40;
6
+ /**
7
+ *
8
+ */
9
+ export declare const updateElbowArrowPoints: (arrow: Readonly<ExcalidrawElbowArrowElement>, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap, updates: {
10
+ points?: readonly LocalPoint[];
11
+ fixedSegments?: FixedSegment[] | null;
12
+ startBinding?: FixedPointBinding | null;
13
+ endBinding?: FixedPointBinding | null;
14
+ }, options?: {
15
+ isDragging?: boolean;
16
+ }) => ElementUpdate<ExcalidrawElbowArrowElement>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Create and link between shapes.
3
+ */
4
+ import type { AppProps, AppState } from "../types";
5
+ import type { ExcalidrawElement } from "./types";
6
+ export declare const defaultGetElementLinkFromSelection: Exclude<AppProps["generateLinkForSelection"], undefined>;
7
+ export declare const getLinkIdAndTypeFromSelection: (selectedElements: ExcalidrawElement[], appState: AppState) => {
8
+ id: string;
9
+ type: "element" | "group";
10
+ } | null;
11
+ export declare const canCreateLinkFromElements: (selectedElements: ExcalidrawElement[]) => boolean;
12
+ export declare const isElementLink: (url: string) => boolean;
13
+ export declare const parseElementLinkFromURL: (url: string) => string | null;
@@ -88,18 +88,24 @@ export declare const actionSetEmbeddableAsActiveTool: {
88
88
  tab?: string | undefined;
89
89
  } | null;
90
90
  openDialog: {
91
- name: "imageExport" | "help" | "jsonExport";
91
+ name: "help" | "imageExport" | "jsonExport";
92
92
  } | {
93
93
  name: "ttd";
94
94
  tab: "mermaid" | "text-to-diagram";
95
95
  } | {
96
96
  name: "commandPalette";
97
+ } | {
98
+ name: "elementLinkSelector";
99
+ sourceElementId: string;
97
100
  } | null;
98
101
  defaultSidebarDockedPreference: boolean;
99
102
  lastPointerDownWith: import("./types").PointerType;
100
103
  selectedElementIds: Readonly<{
101
104
  [id: string]: true;
102
105
  }>;
106
+ hoveredElementIds: Readonly<{
107
+ [id: string]: true;
108
+ }>;
103
109
  previousSelectedElementIds: {
104
110
  [id: string]: true;
105
111
  };
@@ -200,6 +206,8 @@ export declare const actionSetEmbeddableAsActiveTool: {
200
206
  objectsSnapModeEnabled: boolean;
201
207
  userToFollow: import("../types").UserToFollow | null;
202
208
  followedBy: Set<import("../types").SocketId>;
209
+ isCropping: boolean;
210
+ croppingElementId: string | null;
203
211
  searchMatches: readonly {
204
212
  id: string;
205
213
  focus: boolean;
@@ -1,4 +1,4 @@
1
- import type { ElementsMap, ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawFlowchartNodeElement } from "./types";
1
+ import { type ElementsMap, type ExcalidrawBindableElement, type ExcalidrawElement, type ExcalidrawFlowchartNodeElement } from "./types";
2
2
  import type { AppState, PendingExcalidrawElements } from "../types";
3
3
  type LinkDirection = "up" | "right" | "down" | "left";
4
4
  export declare const getLinkDirectionFromKey: (key: string) => LinkDirection;
@@ -7,6 +7,10 @@ export declare const HEADING_UP: Heading;
7
7
  export type Heading = [1, 0] | [0, 1] | [-1, 0] | [0, -1];
8
8
  export declare const headingForDiamond: <Point extends GlobalPoint | LocalPoint>(a: Point, b: Point) => Heading;
9
9
  export declare const vectorToHeading: (vec: Vector) => Heading;
10
+ export declare const headingForPoint: <P extends GlobalPoint | LocalPoint>(p: P, o: P) => Heading;
11
+ export declare const headingForPointIsHorizontal: <P extends GlobalPoint | LocalPoint>(p: P, o: P) => boolean;
10
12
  export declare const compareHeading: (a: Heading, b: Heading) => boolean;
11
- export declare const headingForPointFromElement: <Point extends GlobalPoint | LocalPoint>(element: Readonly<ExcalidrawBindableElement>, aabb: readonly [minX: number, minY: number, maxX: number, maxY: number], p: Readonly<LocalPoint | GlobalPoint>) => Heading;
13
+ export declare const headingIsHorizontal: (a: Heading) => boolean;
14
+ export declare const headingIsVertical: (a: Heading) => boolean;
15
+ export declare const headingForPointFromElement: <Point extends GlobalPoint | LocalPoint>(element: Readonly<ExcalidrawBindableElement>, aabb: readonly [minX: number, minY: number, maxX: number, maxY: number], p: Readonly<Point>) => Heading;
12
16
  export declare const flipHeading: (h: Heading) => Heading;
@@ -29,4 +29,4 @@ export declare const updateImageCache: ({ fileIds, files, imageCache, }: {
29
29
  }>;
30
30
  export declare const getInitializedImageElements: (elements: readonly ExcalidrawElement[]) => InitializedExcalidrawImageElement[];
31
31
  export declare const isHTMLSVGElement: (node: Node | null) => node is SVGElement;
32
- export declare const normalizeSVG: (SVGString: string) => Promise<string>;
32
+ export declare const normalizeSVG: (SVGString: string) => string;
@@ -1,6 +1,6 @@
1
- import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, OrderedExcalidrawElement, SceneElementsMap } from "./types";
1
+ import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, SceneElementsMap, ExcalidrawElbowArrowElement } from "./types";
2
2
  import type { Bounds } from "./bounds";
3
- import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize } from "../types";
3
+ import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize, Zoom } from "../types";
4
4
  import type { Store } from "../store";
5
5
  import type Scene from "../scene/Scene";
6
6
  import { type GlobalPoint, type LocalPoint } from "../../math";
@@ -48,7 +48,7 @@ export declare class LinearElementEditor {
48
48
  * @param id the `elementId` from the instance of this class (so that we can
49
49
  * statically guarantee this method returns an ExcalidrawLinearElement)
50
50
  */
51
- static getElement(id: InstanceType<typeof LinearElementEditor>["elementId"], elementsMap: ElementsMap): NonDeleted<ExcalidrawLinearElement> | null;
51
+ static getElement<T extends ExcalidrawLinearElement>(id: InstanceType<typeof LinearElementEditor>["elementId"], elementsMap: ElementsMap): T | null;
52
52
  static handleBoxSelection(event: PointerEvent, appState: AppState, setState: React.Component<any, AppState>["setState"], elementsMap: NonDeletedSceneElementsMap): false | undefined;
53
53
  /** @returns whether point was dragged */
54
54
  static handlePointDragging(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, maybeSuggestBinding: (element: NonDeleted<ExcalidrawLinearElement>, pointSceneCoords: {
@@ -62,7 +62,7 @@ export declare class LinearElementEditor {
62
62
  x: number;
63
63
  y: number;
64
64
  }, appState: AppState, elementsMap: ElementsMap) => GlobalPoint | null;
65
- static isSegmentTooShort(element: NonDeleted<ExcalidrawLinearElement>, startPoint: GlobalPoint | LocalPoint, endPoint: GlobalPoint | LocalPoint, zoom: AppState["zoom"]): boolean;
65
+ static isSegmentTooShort<P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, startPoint: P, endPoint: P, index: number, zoom: Zoom): boolean;
66
66
  static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: GlobalPoint, endPoint: GlobalPoint, endPointIndex: number, elementsMap: ElementsMap): GlobalPoint;
67
67
  static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: GlobalPoint, elementsMap: ElementsMap): number;
68
68
  static handlePointerDown(event: React.PointerEvent<HTMLElement>, app: AppClassProperties, store: Store, scenePointer: {
@@ -96,20 +96,17 @@ export declare class LinearElementEditor {
96
96
  };
97
97
  static normalizePoints(element: NonDeleted<ExcalidrawLinearElement>): void;
98
98
  static duplicateSelectedPoints(appState: AppState, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap): AppState;
99
- static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, pointIndices: readonly number[], elementsMap: NonDeletedSceneElementsMap | SceneElementsMap): void;
99
+ static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, pointIndices: readonly number[]): void;
100
100
  static addPoints(element: NonDeleted<ExcalidrawLinearElement>, targetPoints: {
101
101
  point: LocalPoint;
102
- }[], elementsMap: NonDeletedSceneElementsMap | SceneElementsMap): void;
102
+ }[]): void;
103
103
  static movePoints(element: NonDeleted<ExcalidrawLinearElement>, targetPoints: {
104
104
  index: number;
105
105
  point: LocalPoint;
106
106
  isDragging?: boolean;
107
- }[], elementsMap: NonDeletedSceneElementsMap | SceneElementsMap, otherUpdates?: {
107
+ }[], otherUpdates?: {
108
108
  startBinding?: PointBinding | null;
109
109
  endBinding?: PointBinding | null;
110
- }, options?: {
111
- changedElements?: Map<string, OrderedExcalidrawElement>;
112
- isDragging?: boolean;
113
110
  }): void;
114
111
  static shouldAddMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState, elementsMap: ElementsMap): boolean;
115
112
  static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, app: AppClassProperties, snapToGrid: boolean, elementsMap: ElementsMap): {
@@ -124,5 +121,7 @@ export declare class LinearElementEditor {
124
121
  };
125
122
  static getMinMaxXYWithBoundText: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, elementBounds: Bounds, boundTextElement: ExcalidrawTextElementWithContainer) => [number, number, number, number, number, number];
126
123
  static getElementAbsoluteCoords: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
124
+ static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number, elementsMap: ElementsMap): LinearElementEditor;
125
+ static deleteFixedSegment(element: ExcalidrawElbowArrowElement, index: number): void;
127
126
  }
128
127
  export {};
@@ -1,7 +1,9 @@
1
1
  import type { ExcalidrawElement } from "./types";
2
2
  import type { Mutable } from "../utility-types";
3
3
  export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce" | "updated">;
4
- export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
4
+ export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean, options?: {
5
+ isDragging?: boolean;
6
+ }) => TElement;
5
7
  export declare const newElementWith: <TElement extends ExcalidrawElement>(element: TElement, updates: ElementUpdate<TElement>, force?: boolean) => TElement;
6
8
  /**
7
9
  * Mutates element, bumping `version`, `versionNonce`, and `updated`.
@@ -1,4 +1,4 @@
1
- import type { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement } from "./types";
1
+ import type { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement, FixedSegment, ExcalidrawElbowArrowElement } from "./types";
2
2
  import type { AppState } from "../types";
3
3
  import type { MarkOptional, Mutable } from "../utility-types";
4
4
  export type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "index" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity" | "customData">;
@@ -46,18 +46,20 @@ export declare const newLinearElement: (opts: {
46
46
  type: ExcalidrawLinearElement["type"];
47
47
  points?: ExcalidrawLinearElement["points"];
48
48
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawLinearElement>;
49
- export declare const newArrowElement: (opts: {
49
+ export declare const newArrowElement: <T extends boolean>(opts: {
50
50
  type: ExcalidrawArrowElement["type"];
51
- startArrowhead?: Arrowhead | null;
52
- endArrowhead?: Arrowhead | null;
53
- points?: ExcalidrawArrowElement["points"];
54
- elbowed?: boolean;
55
- } & ElementConstructorOpts) => NonDeleted<ExcalidrawArrowElement>;
51
+ startArrowhead?: Arrowhead | null | undefined;
52
+ endArrowhead?: Arrowhead | null | undefined;
53
+ points?: readonly import("../../math").LocalPoint[] | undefined;
54
+ elbowed?: T | undefined;
55
+ fixedSegments?: FixedSegment[] | null | undefined;
56
+ } & Omit<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "angle" | "link" | "width" | "height" | "backgroundColor" | "strokeColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData"> & Partial<Pick<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "angle" | "link" | "width" | "height" | "backgroundColor" | "strokeColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData">>) => T extends true ? NonDeleted<ExcalidrawElbowArrowElement> : NonDeleted<ExcalidrawArrowElement>;
56
57
  export declare const newImageElement: (opts: {
57
58
  type: ExcalidrawImageElement["type"];
58
59
  status?: ExcalidrawImageElement["status"];
59
60
  fileId?: ExcalidrawImageElement["fileId"];
60
61
  scale?: ExcalidrawImageElement["scale"];
62
+ crop?: ExcalidrawImageElement["crop"];
61
63
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawImageElement>;
62
64
  /**
63
65
  * Clones ExcalidrawElement data structure. Does not regenerate id, nonce, or
@@ -1,16 +1,38 @@
1
- import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ElementsMap, NonDeletedSceneElementsMap, SceneElementsMap } from "./types";
1
+ import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawElement, ElementsMap, SceneElementsMap } from "./types";
2
+ import type { BoundingBox } from "./bounds";
2
3
  import type { MaybeTransformHandleType, TransformHandleDirection } from "./transformHandles";
3
4
  import type { PointerDownState } from "../types";
4
- export declare const transformElements: (originalElements: PointerDownState["originalElements"], transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: SceneElementsMap, shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
5
+ import type Scene from "../scene/Scene";
6
+ import { type LocalPoint } from "../../math";
7
+ export declare const transformElements: (originalElements: PointerDownState["originalElements"], transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: SceneElementsMap, scene: Scene, shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
5
8
  export declare const rescalePointsInElement: (element: NonDeletedExcalidrawElement, width: number, height: number, normalizePoints: boolean) => {
6
- points: import("../../math").LocalPoint[];
9
+ points: LocalPoint[];
7
10
  } | {
8
11
  points?: undefined;
9
12
  };
10
13
  export declare const measureFontSizeFromWidth: (element: NonDeleted<ExcalidrawTextElement>, elementsMap: ElementsMap, nextWidth: number) => {
11
14
  size: number;
12
15
  } | null;
13
- export declare const resizeSingleElement: (originalElements: PointerDownState["originalElements"], shouldMaintainAspectRatio: boolean, element: NonDeletedExcalidrawElement, elementsMap: SceneElementsMap, transformHandleDirection: TransformHandleDirection, shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
14
- export declare const resizeMultipleElements: (originalElements: PointerDownState["originalElements"], selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: NonDeletedSceneElementsMap | SceneElementsMap, transformHandleType: TransformHandleDirection, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number) => void;
15
16
  export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, x: number, y: number) => [number, number];
16
17
  export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
18
+ export declare const resizeSingleElement: (nextWidth: number, nextHeight: number, latestElement: ExcalidrawElement, origElement: ExcalidrawElement, elementsMap: ElementsMap, originalElementsMap: ElementsMap, handleDirection: TransformHandleDirection, { shouldInformMutation, shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
19
+ shouldMaintainAspectRatio?: boolean | undefined;
20
+ shouldResizeFromCenter?: boolean | undefined;
21
+ shouldInformMutation?: boolean | undefined;
22
+ }) => void;
23
+ export declare const getNextSingleWidthAndHeightFromPointer: (latestElement: ExcalidrawElement, origElement: ExcalidrawElement, elementsMap: ElementsMap, originalElementsMap: ElementsMap, handleDirection: TransformHandleDirection, pointerX: number, pointerY: number, { shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
24
+ shouldMaintainAspectRatio?: boolean | undefined;
25
+ shouldResizeFromCenter?: boolean | undefined;
26
+ }) => {
27
+ nextWidth: number;
28
+ nextHeight: number;
29
+ };
30
+ export declare const resizeMultipleElements: (selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: ElementsMap, handleDirection: TransformHandleDirection, scene: Scene, originalElementsMap: ElementsMap, { shouldMaintainAspectRatio, shouldResizeFromCenter, flipByX, flipByY, nextHeight, nextWidth, originalBoundingBox, }?: {
31
+ nextWidth?: number | undefined;
32
+ nextHeight?: number | undefined;
33
+ shouldMaintainAspectRatio?: boolean | undefined;
34
+ shouldResizeFromCenter?: boolean | undefined;
35
+ flipByX?: boolean | undefined;
36
+ flipByY?: boolean | undefined;
37
+ originalBoundingBox?: BoundingBox | undefined;
38
+ }) => void;
@@ -2,8 +2,6 @@ import type { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawT
2
2
  import type { MaybeTransformHandleType } from "./transformHandles";
3
3
  import type { AppState } from "../types";
4
4
  import type { ExtractSetType } from "../utility-types";
5
- export declare const containsCJK: (text: string) => boolean;
6
- export declare const containsEmoji: (text: string) => boolean;
7
5
  export declare const normalizeText: (text: string) => string;
8
6
  export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, elementsMap: ElementsMap, informMutation?: boolean) => void;
9
7
  export declare const bindTextToShapeAfterDuplication: (newElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
@@ -29,10 +27,22 @@ export declare const detectLineHeight: (textElement: ExcalidrawTextElement) => n
29
27
  */
30
28
  export declare const getLineHeightInPx: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
31
29
  export declare const getApproxMinLineHeight: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
30
+ /**
31
+ * @param forceAdvanceWidth use to force retrieve the "advance width" ~ `metrics.width`, instead of the actual boundind box width.
32
+ *
33
+ * > The advance width is the distance between the glyph's initial pen position and the next glyph's initial pen position.
34
+ *
35
+ * We need to use the advance width as that's the closest thing to the browser wrapping algo, hence using it for:
36
+ * - text wrapping
37
+ * - wysiwyg editor (+padding)
38
+ *
39
+ * Everything else should be based on the actual bounding box width.
40
+ *
41
+ * `Math.ceil` of the final width adds additional buffer which stabilizes slight wrapping incosistencies.
42
+ */
43
+ export declare const getLineWidth: (text: string, font: FontString, forceAdvanceWidth?: true) => number;
32
44
  export declare const getTextWidth: (text: string, font: FontString, forceAdvanceWidth?: true) => number;
33
45
  export declare const getTextHeight: (text: string, fontSize: number, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
34
- export declare const parseTokens: (line: string) => string[];
35
- export declare const wrapText: (text: string, font: FontString, maxWidth: number) => string;
36
46
  export declare const charWidth: {
37
47
  calculate: (char: string, font: FontString) => number;
38
48
  getCache: (font: FontString) => number[];
@@ -0,0 +1,13 @@
1
+ import type { FontString } from "./types";
2
+ /**
3
+ * Test if a given text contains any CJK characters (including symbols, punctuation, etc,).
4
+ */
5
+ export declare const containsCJK: (text: string) => boolean;
6
+ /**
7
+ * Breaks the line into the tokens based on the found line break opporutnities.
8
+ */
9
+ export declare const parseTokens: (line: string) => string[];
10
+ /**
11
+ * Wraps the original text into the lines based on the given width.
12
+ */
13
+ export declare const wrapText: (text: string, font: FontString, maxWidth: number) => string;
@@ -40,7 +40,7 @@ export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [
40
40
  sw?: boolean | undefined;
41
41
  se?: boolean | undefined;
42
42
  rotation?: boolean | undefined;
43
- }, margin?: number) => TransformHandles;
43
+ }, margin?: number, spacing?: number) => TransformHandles;
44
44
  export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoom, elementsMap: ElementsMap, pointerType?: PointerType, omitSides?: {
45
45
  e?: boolean | undefined;
46
46
  s?: boolean | undefined;