@zsviczian/excalidraw 0.17.6-2 → 0.17.6-21

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 (138) hide show
  1. package/dist/excalidraw.development.js +13000 -1495
  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 +425 -347
  5. package/dist/styles.production.css +3 -2
  6. package/package.json +2 -3
  7. package/types/excalidraw/actions/actionAddToLibrary.d.ts +24 -0
  8. package/types/excalidraw/actions/actionBoundText.d.ts +16 -0
  9. package/types/excalidraw/actions/actionCanvas.d.ts +112 -0
  10. package/types/excalidraw/actions/actionClipboard.d.ts +48 -0
  11. package/types/excalidraw/actions/actionCropEditor.d.ts +222 -0
  12. package/types/excalidraw/actions/actionDeleteSelected.d.ts +24 -0
  13. package/types/excalidraw/actions/actionElementLink.d.ts +244 -0
  14. package/types/excalidraw/actions/actionElementLock.d.ts +16 -0
  15. package/types/excalidraw/actions/actionExport.d.ts +69 -0
  16. package/types/excalidraw/actions/actionFinalize.d.ts +16 -0
  17. package/types/excalidraw/actions/actionFrame.d.ts +32 -0
  18. package/types/excalidraw/actions/actionGroup.d.ts +16 -0
  19. package/types/excalidraw/actions/actionLinearEditor.d.ts +8 -0
  20. package/types/excalidraw/actions/actionLink.d.ts +9 -1
  21. package/types/excalidraw/actions/actionMenu.d.ts +21 -0
  22. package/types/excalidraw/actions/actionNavigate.d.ts +16 -0
  23. package/types/excalidraw/actions/actionProperties.d.ts +120 -0
  24. package/types/excalidraw/actions/actionSelectAll.d.ts +8 -0
  25. package/types/excalidraw/actions/actionStyles.d.ts +8 -0
  26. package/types/excalidraw/actions/actionToggleGridMode.d.ts +8 -0
  27. package/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +8 -0
  28. package/types/excalidraw/actions/actionToggleSearchMenu.d.ts +13 -0
  29. package/types/excalidraw/actions/actionToggleStats.d.ts +8 -0
  30. package/types/excalidraw/actions/actionToggleViewMode.d.ts +8 -0
  31. package/types/excalidraw/actions/actionToggleZenMode.d.ts +8 -0
  32. package/types/excalidraw/actions/index.d.ts +1 -0
  33. package/types/excalidraw/actions/types.d.ts +1 -1
  34. package/types/excalidraw/change.d.ts +2 -2
  35. package/types/excalidraw/clipboard.d.ts +27 -5
  36. package/types/excalidraw/components/App.d.ts +20 -5
  37. package/types/excalidraw/components/ElementLinkDialog.d.ts +11 -0
  38. package/types/excalidraw/components/LayerUI.d.ts +2 -1
  39. package/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +1 -7
  40. package/types/excalidraw/components/TTDDialog/MermaidToExcalidrawLib.d.ts +9 -0
  41. package/types/excalidraw/components/TTDDialog/common.d.ts +2 -2
  42. package/types/excalidraw/components/hyperlink/Hyperlink.d.ts +1 -1
  43. package/types/excalidraw/components/hyperlink/helpers.d.ts +1 -0
  44. package/types/excalidraw/components/icons.d.ts +2 -0
  45. package/types/excalidraw/constants.d.ts +5 -1
  46. package/types/excalidraw/data/blob.d.ts +4 -0
  47. package/types/excalidraw/data/encode.d.ts +6 -5
  48. package/types/excalidraw/data/image.d.ts +2 -2
  49. package/types/excalidraw/dist/excalidraw.production.min.d.ts +3 -1
  50. package/types/excalidraw/element/binding.d.ts +1 -1
  51. package/types/excalidraw/element/cropElement.d.ts +14 -0
  52. package/types/excalidraw/element/elementLink.d.ts +13 -0
  53. package/types/excalidraw/element/embeddable.d.ts +8 -0
  54. package/types/excalidraw/element/image.d.ts +1 -1
  55. package/types/excalidraw/element/newElement.d.ts +1 -0
  56. package/types/excalidraw/element/textElement.d.ts +14 -4
  57. package/types/excalidraw/element/textWrapping.d.ts +13 -0
  58. package/types/excalidraw/element/transformHandles.d.ts +1 -1
  59. package/types/excalidraw/element/types.d.ts +10 -0
  60. package/types/excalidraw/errors.d.ts +7 -0
  61. package/types/excalidraw/fonts/{woff2/Cascadia → Cascadia}/index.d.ts +1 -1
  62. package/types/excalidraw/fonts/ComicShanns/index.d.ts +2 -0
  63. package/types/excalidraw/fonts/{woff2/Emoji → Emoji}/index.d.ts +1 -1
  64. package/types/excalidraw/fonts/ExcalidrawFontFace.d.ts +2 -8
  65. package/types/excalidraw/fonts/{woff2/Excalifont → Excalifont}/index.d.ts +1 -1
  66. package/types/excalidraw/fonts/Fonts.d.ts +117 -0
  67. package/types/excalidraw/fonts/{woff2/Helvetica → Helvetica}/index.d.ts +1 -1
  68. package/types/excalidraw/fonts/{woff2/Liberation → Liberation}/index.d.ts +1 -1
  69. package/types/excalidraw/fonts/{woff2/Lilita → Lilita}/index.d.ts +1 -1
  70. package/types/excalidraw/fonts/{woff2/Nunito → Nunito}/index.d.ts +1 -1
  71. package/types/excalidraw/fonts/{woff2/Virgil → Virgil}/index.d.ts +1 -1
  72. package/types/excalidraw/fonts/{woff2/Xiaolai → Xiaolai}/index.d.ts +1 -1
  73. package/types/excalidraw/fonts/index.d.ts +1 -87
  74. package/types/excalidraw/index.d.ts +2 -1
  75. package/types/excalidraw/keys.d.ts +107 -0
  76. package/types/excalidraw/obsidianUtils.d.ts +5 -3
  77. package/types/excalidraw/renderer/renderElement.d.ts +3 -2
  78. package/types/excalidraw/scene/Scene.d.ts +1 -0
  79. package/types/excalidraw/scene/comparisons.d.ts +1 -0
  80. package/types/excalidraw/scene/export.d.ts +1 -0
  81. package/types/excalidraw/scene/types.d.ts +7 -0
  82. package/types/excalidraw/types.d.ts +24 -2
  83. package/types/math/utils.d.ts +1 -0
  84. package/types/math/vector.d.ts +4 -0
  85. package/types/utils/export.d.ts +5 -3
  86. package/dist/excalidraw-assets/CascadiaCode-Regular.woff2 +0 -0
  87. package/dist/excalidraw-assets/ComicShanns-Regular.woff2 +0 -0
  88. package/dist/excalidraw-assets/Excalifont-Regular.woff2 +0 -0
  89. package/dist/excalidraw-assets/LiberationSans-Regular.woff2 +0 -0
  90. package/dist/excalidraw-assets/Lilita-Regular-i7dPIFZ9Zz-WBtRtedDbYE98RXi4EwSsbg.woff2 +0 -0
  91. package/dist/excalidraw-assets/Lilita-Regular-i7dPIFZ9Zz-WBtRtedDbYEF8RXi4EwQ.woff2 +0 -0
  92. package/dist/excalidraw-assets/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTA3j6zbXWjgevT5.woff2 +0 -0
  93. package/dist/excalidraw-assets/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTQ3j6zbXWjgeg.woff2 +0 -0
  94. package/dist/excalidraw-assets/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTk3j6zbXWjgevT5.woff2 +0 -0
  95. package/dist/excalidraw-assets/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTo3j6zbXWjgevT5.woff2 +0 -0
  96. package/dist/excalidraw-assets/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTs3j6zbXWjgevT5.woff2 +0 -0
  97. package/dist/excalidraw-assets/Virgil-Regular.woff2 +0 -0
  98. package/dist/excalidraw-assets-dev/CascadiaCode-Regular.woff2 +0 -0
  99. package/dist/excalidraw-assets-dev/ComicShanns-Regular.woff2 +0 -0
  100. package/dist/excalidraw-assets-dev/Excalifont-Regular.woff2 +0 -0
  101. package/dist/excalidraw-assets-dev/LiberationSans-Regular.woff2 +0 -0
  102. package/dist/excalidraw-assets-dev/Lilita-Regular-i7dPIFZ9Zz-WBtRtedDbYE98RXi4EwSsbg.woff2 +0 -0
  103. package/dist/excalidraw-assets-dev/Lilita-Regular-i7dPIFZ9Zz-WBtRtedDbYEF8RXi4EwQ.woff2 +0 -0
  104. package/dist/excalidraw-assets-dev/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTA3j6zbXWjgevT5.woff2 +0 -0
  105. package/dist/excalidraw-assets-dev/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTQ3j6zbXWjgeg.woff2 +0 -0
  106. package/dist/excalidraw-assets-dev/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTk3j6zbXWjgevT5.woff2 +0 -0
  107. package/dist/excalidraw-assets-dev/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTo3j6zbXWjgevT5.woff2 +0 -0
  108. package/dist/excalidraw-assets-dev/Nunito-Regular-XRXI3I6Li01BKofiOc5wtlZ2di8HDIkhdTs3j6zbXWjgevT5.woff2 +0 -0
  109. package/dist/excalidraw-assets-dev/Virgil-Regular.woff2 +0 -0
  110. package/types/excalidraw/components/MagicSettings.d.ts +0 -8
  111. package/types/excalidraw/components/Stats.d.ts +0 -11
  112. package/types/excalidraw/data/magic.d.ts +0 -23
  113. package/types/excalidraw/fonts/ExcalidrawFont.d.ts +0 -37
  114. package/types/excalidraw/fonts/wasm/hb-subset.bindings.d.ts +0 -45
  115. package/types/excalidraw/fonts/wasm/hb-subset.loader.d.ts +0 -5
  116. package/types/excalidraw/fonts/wasm/hb-subset.wasm.d.ts +0 -2
  117. package/types/excalidraw/fonts/wasm/woff2.bindings.d.ts +0 -31
  118. package/types/excalidraw/fonts/wasm/woff2.loader.d.ts +0 -6
  119. package/types/excalidraw/fonts/wasm/woff2.wasm.d.ts +0 -2
  120. package/types/excalidraw/fonts/woff2/Comic/index.d.ts +0 -2
  121. package/types/excalidraw/ga.d.ts +0 -63
  122. package/types/excalidraw/gadirections.d.ts +0 -8
  123. package/types/excalidraw/galines.d.ts +0 -22
  124. package/types/excalidraw/gapoints.d.ts +0 -7
  125. package/types/excalidraw/gatransforms.d.ts +0 -10
  126. package/types/excalidraw/math.d.ts +0 -79
  127. package/types/excalidraw/scene/Fonts.d.ts +0 -19
  128. package/types/utils/geometry/geometry.d.ts +0 -89
  129. /package/types/excalidraw/fonts/{metadata.d.ts → FontMetadata.d.ts} +0 -0
  130. /package/types/excalidraw/{fonts/wasm/hb-subset-bindings.d.ts → subset/harfbuzz/harfbuzz-bindings.d.ts} +0 -0
  131. /package/types/excalidraw/{fonts/wasm/hb-subset-loader.d.ts → subset/harfbuzz/harfbuzz-loader.d.ts} +0 -0
  132. /package/types/excalidraw/{fonts/wasm/hb-subset-wasm.d.ts → subset/harfbuzz/harfbuzz-wasm.d.ts} +0 -0
  133. /package/types/excalidraw/{fonts/subset → subset}/subset-main.d.ts +0 -0
  134. /package/types/excalidraw/{fonts/subset → subset}/subset-shared.chunk.d.ts +0 -0
  135. /package/types/excalidraw/{fonts/subset → subset}/subset-worker.chunk.d.ts +0 -0
  136. /package/types/excalidraw/{fonts/wasm → subset/woff2}/woff2-bindings.d.ts +0 -0
  137. /package/types/excalidraw/{fonts/wasm → subset/woff2}/woff2-loader.d.ts +0 -0
  138. /package/types/excalidraw/{fonts/wasm → subset/woff2}/woff2-wasm.d.ts +0 -0
@@ -0,0 +1,117 @@
1
+ import { ExcalidrawFontFace } from "./ExcalidrawFontFace";
2
+ import { type FontMetadata } from "./FontMetadata";
3
+ import type { ExcalidrawElement, ExcalidrawTextElement, FontFamilyValues } from "../element/types";
4
+ import type Scene from "../scene/Scene";
5
+ export declare class Fonts {
6
+ static readonly loadedFontsCache: Set<string>;
7
+ private static _registered;
8
+ private static _initialized;
9
+ static get registered(): Map<number, {
10
+ metadata: FontMetadata;
11
+ fontFaces: ExcalidrawFontFace[];
12
+ }>;
13
+ get registered(): Map<number, {
14
+ metadata: FontMetadata;
15
+ fontFaces: ExcalidrawFontFace[];
16
+ }>;
17
+ private readonly scene;
18
+ constructor(scene: Scene);
19
+ /**
20
+ * Get all the font families for the given scene.
21
+ */
22
+ getSceneFamilies: () => number[];
23
+ /**
24
+ * if we load a (new) font, it's likely that text elements using it have
25
+ * already been rendered using a fallback font. Thus, we want invalidate
26
+ * their shapes and rerender. See #637.
27
+ *
28
+ * Invalidates text elements and rerenders scene, provided that at least one
29
+ * of the supplied fontFaces has not already been processed.
30
+ */
31
+ onLoaded: (fontFaces: readonly FontFace[]) => void;
32
+ /**
33
+ * Load font faces for a given scene and trigger scene update.
34
+ *
35
+ * FontFaceSet loadingdone event we listen on may not always
36
+ * fire (looking at you Safari), so on init we manually load all
37
+ * fonts and rerender scene text elements once done.
38
+ *
39
+ * For Safari we make sure to check against each loaded font face
40
+ * with the unique characters per family in the scene,
41
+ * otherwise fonts might remain unloaded.
42
+ */
43
+ loadSceneFonts: () => Promise<FontFace[]>;
44
+ /**
45
+ * Load font faces for passed elements - use when the scene is unavailable (i.e. export).
46
+ *
47
+ * For Safari we make sure to check against each loaded font face,
48
+ * with the unique characters per family in the elements
49
+ * otherwise fonts might remain unloaded.
50
+ */
51
+ static loadElementsFonts: (elements: readonly ExcalidrawElement[]) => Promise<FontFace[]>;
52
+ /**
53
+ * Load all registered font faces.
54
+ */
55
+ static loadAllFonts: () => Promise<FontFace[]>;
56
+ /**
57
+ * Generate CSS @font-face declarations for the given elements.
58
+ */
59
+ static generateFontFaceDeclarations(elements: readonly ExcalidrawElement[]): Promise<string[]>;
60
+ static loadFontFaces(fontFamilies: Array<ExcalidrawTextElement["fontFamily"]>, charsPerFamily?: Record<number, Set<string>>): Promise<FontFace[]>;
61
+ private static fontFacesLoader;
62
+ private static fontFacesStylesGenerator;
63
+ /**
64
+ * Register a new font.
65
+ *
66
+ * @param family font family
67
+ * @param metadata font metadata
68
+ * @param fontFacesDecriptors font faces descriptors
69
+ */
70
+ static register(//zsviczian made public
71
+ this: Fonts | {
72
+ registered: Map<number, {
73
+ metadata: FontMetadata;
74
+ fontFaces: ExcalidrawFontFace[];
75
+ }>;
76
+ }, family: string, metadata: FontMetadata, ...fontFacesDecriptors: ExcalidrawFontFaceDescriptor[]): Map<number, {
77
+ metadata: FontMetadata;
78
+ fontFaces: ExcalidrawFontFace[];
79
+ }> | Map<number, {
80
+ metadata: FontMetadata;
81
+ fontFaces: ExcalidrawFontFace[];
82
+ }>;
83
+ /**
84
+ * WARN: should be called just once on init, even across multiple instances.
85
+ */
86
+ private static init;
87
+ /**
88
+ * Get all the unique font families for the given elements.
89
+ */
90
+ static getUniqueFamilies(elements: ReadonlyArray<ExcalidrawElement>): Array<ExcalidrawTextElement["fontFamily"]>;
91
+ /**
92
+ * Get all the unique characters per font family for the given scene.
93
+ */
94
+ private static getCharsPerFamily;
95
+ /**
96
+ * Get characters for a given family.
97
+ */
98
+ private static getCharacters;
99
+ /**
100
+ * Get all registered font families.
101
+ */
102
+ private static getAllFamilies;
103
+ }
104
+ /**
105
+ * Calculates vertical offset for a text with alphabetic baseline.
106
+ */
107
+ export declare const getVerticalOffset: (fontFamily: ExcalidrawTextElement["fontFamily"], fontSize: ExcalidrawTextElement["fontSize"], lineHeightPx: number) => number;
108
+ /**
109
+ * Gets line height forr a selected family.
110
+ */
111
+ export declare const getLineHeight: (fontFamily: FontFamilyValues) => number & {
112
+ _brand: "unitlessLineHeight";
113
+ };
114
+ export interface ExcalidrawFontFaceDescriptor {
115
+ uri: string;
116
+ descriptors?: FontFaceDescriptors;
117
+ }
@@ -1,2 +1,2 @@
1
- import { type ExcalidrawFontFaceDescriptor } from "../..";
1
+ import { type ExcalidrawFontFaceDescriptor } from "../Fonts";
2
2
  export declare const HelveticaFontFaces: ExcalidrawFontFaceDescriptor[];
@@ -1,2 +1,2 @@
1
- import { type ExcalidrawFontFaceDescriptor } from "../..";
1
+ import { type ExcalidrawFontFaceDescriptor } from "../Fonts";
2
2
  export declare const LiberationFontFaces: ExcalidrawFontFaceDescriptor[];
@@ -1,2 +1,2 @@
1
- import { type ExcalidrawFontFaceDescriptor } from "../..";
1
+ import { type ExcalidrawFontFaceDescriptor } from "../Fonts";
2
2
  export declare const LilitaFontFaces: ExcalidrawFontFaceDescriptor[];
@@ -1,2 +1,2 @@
1
- import { type ExcalidrawFontFaceDescriptor } from "../..";
1
+ import { type ExcalidrawFontFaceDescriptor } from "../Fonts";
2
2
  export declare const NunitoFontFaces: ExcalidrawFontFaceDescriptor[];
@@ -1,2 +1,2 @@
1
- import { type ExcalidrawFontFaceDescriptor } from "../..";
1
+ import { type ExcalidrawFontFaceDescriptor } from "../Fonts";
2
2
  export declare const VirgilFontFaces: ExcalidrawFontFaceDescriptor[];
@@ -1,4 +1,4 @@
1
- import { type ExcalidrawFontFaceDescriptor } from "../..";
1
+ import { type ExcalidrawFontFaceDescriptor } from "../Fonts";
2
2
  /**
3
3
  * The original font was modified with the following changes:
4
4
  * - removed non-CJK codepoints
@@ -1,87 +1 @@
1
- import type Scene from "../scene/Scene";
2
- import type { ExcalidrawElement, ExcalidrawTextElement, FontFamilyValues } from "../element/types";
3
- import { type FontMetadata } from "./metadata";
4
- import { type IExcalidrawFontFace } from "./ExcalidrawFontFace";
5
- export declare class Fonts {
6
- static readonly loadedFontsCache: Set<string>;
7
- private static _registered;
8
- private static _initialized;
9
- static get registered(): Map<number, {
10
- metadata: FontMetadata;
11
- fontFaces: IExcalidrawFontFace[];
12
- }>;
13
- get registered(): Map<number, {
14
- metadata: FontMetadata;
15
- fontFaces: IExcalidrawFontFace[];
16
- }>;
17
- private readonly scene;
18
- constructor({ scene }: {
19
- scene: Scene;
20
- });
21
- /**
22
- * if we load a (new) font, it's likely that text elements using it have
23
- * already been rendered using a fallback font. Thus, we want invalidate
24
- * their shapes and rerender. See #637.
25
- *
26
- * Invalidates text elements and rerenders scene, provided that at least one
27
- * of the supplied fontFaces has not already been processed.
28
- */
29
- onLoaded: (fontFaces: readonly FontFace[]) => void;
30
- /**
31
- * Load font faces for a given scene and trigger scene update.
32
- */
33
- loadSceneFonts: () => Promise<FontFace[]>;
34
- /**
35
- * Load all registered font faces.
36
- */
37
- static loadAllFonts: () => Promise<FontFace[]>;
38
- /**
39
- * Load font faces for passed elements - use when the scene is unavailable (i.e. export).
40
- */
41
- static loadElementsFonts: (elements: readonly ExcalidrawElement[]) => Promise<FontFace[]>;
42
- static loadFontFaces(fontFamilies: Array<ExcalidrawTextElement["fontFamily"]>): Promise<FontFace[]>;
43
- /**
44
- * WARN: should be called just once on init, even across multiple instances.
45
- */
46
- private static init;
47
- /**
48
- * Gets all the font families for the given scene.
49
- */
50
- getSceneFamilies: () => number[];
51
- private static getAllFamilies;
52
- static getElementsFamilies(elements: ReadonlyArray<ExcalidrawElement>): Array<ExcalidrawTextElement["fontFamily"]>;
53
- }
54
- /**
55
- * Register a new font.
56
- *
57
- * @param family font family
58
- * @param metadata font metadata
59
- * @param fontFacesDecriptors font faces descriptors
60
- */
61
- export declare function register(//zsviczian (changed from private to export)
62
- this: Fonts | {
63
- registered: Map<number, {
64
- metadata: FontMetadata;
65
- fontFaces: IExcalidrawFontFace[];
66
- }>;
67
- }, family: string, metadata: FontMetadata, ...fontFacesDecriptors: ExcalidrawFontFaceDescriptor[]): Map<number, {
68
- metadata: FontMetadata;
69
- fontFaces: IExcalidrawFontFace[];
70
- }> | Map<number, {
71
- metadata: FontMetadata;
72
- fontFaces: IExcalidrawFontFace[];
73
- }>;
74
- /**
75
- * Calculates vertical offset for a text with alphabetic baseline.
76
- */
77
- export declare const getVerticalOffset: (fontFamily: ExcalidrawTextElement["fontFamily"], fontSize: ExcalidrawTextElement["fontSize"], lineHeightPx: number) => number;
78
- /**
79
- * Gets line height forr a selected family.
80
- */
81
- export declare const getLineHeight: (fontFamily: FontFamilyValues) => number & {
82
- _brand: "unitlessLineHeight";
83
- };
84
- export interface ExcalidrawFontFaceDescriptor {
85
- uri: string;
86
- descriptors?: FontFaceDescriptors;
87
- }
1
+ export * from "./Fonts";
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import "./css/app.scss";
3
3
  import "./css/styles.scss";
4
- import "./fonts/css/fonts.css";
4
+ import "./fonts/fonts.css";
5
5
  import type { ExcalidrawProps } from "./types";
6
6
  import Footer from "./components/footer/FooterCenter";
7
7
  import MainMenu from "./components/main-menu/MainMenu";
@@ -60,3 +60,4 @@ export { getCommonBounds, getVisibleSceneBounds } from "./element/bounds";
60
60
  export { elementsOverlappingBBox, isElementInsideBBox, elementPartiallyOverlapsWithOrContainsBBox, } from "../utils/withinBounds";
61
61
  export { DiagramToCodePlugin } from "./components/DiagramToCodePlugin/DiagramToCodePlugin";
62
62
  export { getDataURL } from "./data/blob";
63
+ export { isElementLink } from "./element/elementLink";
@@ -1,3 +1,4 @@
1
+ import type { ValueOf } from "./utility-types";
1
2
  export declare const CODES: {
2
3
  readonly EQUAL: "Equal";
3
4
  readonly MINUS: "Minus";
@@ -18,6 +19,7 @@ export declare const CODES: {
18
19
  readonly H: "KeyH";
19
20
  readonly V: "KeyV";
20
21
  readonly Z: "KeyZ";
22
+ readonly Y: "KeyY";
21
23
  readonly R: "KeyR";
22
24
  readonly S: "KeyS";
23
25
  };
@@ -76,6 +78,111 @@ export declare const KEYS: {
76
78
  readonly 9: "9";
77
79
  };
78
80
  export type Key = keyof typeof KEYS;
81
+ export declare const KeyCodeMap: Map<ValueOf<{
82
+ readonly ARROW_DOWN: "ArrowDown";
83
+ readonly ARROW_LEFT: "ArrowLeft";
84
+ readonly ARROW_RIGHT: "ArrowRight";
85
+ readonly ARROW_UP: "ArrowUp";
86
+ readonly PAGE_UP: "PageUp";
87
+ readonly PAGE_DOWN: "PageDown";
88
+ readonly BACKSPACE: "Backspace";
89
+ readonly ALT: "Alt";
90
+ readonly CTRL_OR_CMD: "metaKey" | "ctrlKey";
91
+ readonly DELETE: "Delete";
92
+ readonly ENTER: "Enter";
93
+ readonly ESCAPE: "Escape";
94
+ readonly QUESTION_MARK: "?";
95
+ readonly SPACE: " ";
96
+ readonly TAB: "Tab";
97
+ readonly CHEVRON_LEFT: "<";
98
+ readonly CHEVRON_RIGHT: ">";
99
+ readonly PERIOD: ".";
100
+ readonly COMMA: ",";
101
+ readonly SUBTRACT: "-";
102
+ readonly SLASH: "/";
103
+ readonly A: "a";
104
+ readonly C: "c";
105
+ readonly D: "d";
106
+ readonly E: "e";
107
+ readonly F: "f";
108
+ readonly G: "g";
109
+ readonly H: "h";
110
+ readonly I: "i";
111
+ readonly L: "l";
112
+ readonly O: "o";
113
+ readonly P: "p";
114
+ readonly Q: "q";
115
+ readonly R: "r";
116
+ readonly S: "s";
117
+ readonly T: "t";
118
+ readonly V: "v";
119
+ readonly X: "x";
120
+ readonly Y: "y";
121
+ readonly Z: "z";
122
+ readonly K: "k";
123
+ readonly W: "w";
124
+ readonly 0: "0";
125
+ readonly 1: "1";
126
+ readonly 2: "2";
127
+ readonly 3: "3";
128
+ readonly 4: "4";
129
+ readonly 5: "5";
130
+ readonly 6: "6";
131
+ readonly 7: "7";
132
+ readonly 8: "8";
133
+ readonly 9: "9";
134
+ }>, ValueOf<{
135
+ readonly EQUAL: "Equal";
136
+ readonly MINUS: "Minus";
137
+ readonly NUM_ADD: "NumpadAdd";
138
+ readonly NUM_SUBTRACT: "NumpadSubtract";
139
+ readonly NUM_ZERO: "Numpad0";
140
+ readonly BRACKET_RIGHT: "BracketRight";
141
+ readonly BRACKET_LEFT: "BracketLeft";
142
+ readonly ONE: "Digit1";
143
+ readonly TWO: "Digit2";
144
+ readonly THREE: "Digit3";
145
+ readonly NINE: "Digit9";
146
+ readonly QUOTE: "Quote";
147
+ readonly ZERO: "Digit0";
148
+ readonly SLASH: "Slash";
149
+ readonly C: "KeyC";
150
+ readonly D: "KeyD";
151
+ readonly H: "KeyH";
152
+ readonly V: "KeyV";
153
+ readonly Z: "KeyZ";
154
+ readonly Y: "KeyY";
155
+ readonly R: "KeyR";
156
+ readonly S: "KeyS";
157
+ }>>;
158
+ export declare const isLatinChar: (key: string) => boolean;
159
+ /**
160
+ * Used to match key events for any keyboard layout, especially on Windows and Linux,
161
+ * where non-latin character with modified (CMD) is not substituted with latin-based alternative.
162
+ *
163
+ * Uses `event.key` when it's latin, otherwise fallbacks to `event.code` (if mapping exists).
164
+ *
165
+ * Example of pressing "z" on different layouts, with the chosen key or code highlighted in []:
166
+ *
167
+ * Layout | Code | Key | Comment
168
+ * --------------------- | ----- | --- | -------
169
+ * U.S. | KeyZ | [z] |
170
+ * Czech | KeyY | [z] |
171
+ * Turkish | KeyN | [z] |
172
+ * French | KeyW | [z] |
173
+ * Macedonian | [KeyZ] | з | z with cmd; з is Cyrillic equivalent of z
174
+ * Russian | [KeyZ] | я | z with cmd
175
+ * Serbian | [KeyZ] | ѕ | z with cmd
176
+ * Greek | [KeyZ] | ζ | z with cmd; also ζ is Greek equivalent of z
177
+ * Hebrew | [KeyZ] | ז | z with cmd; also ז is Hebrew equivalent of z
178
+ * Pinyin - Simplified | KeyZ | [z] | due to IME
179
+ * Cangije - Traditional | [KeyZ] | 重 | z with cmd
180
+ * Japanese | [KeyZ] | つ | z with cmd
181
+ * 2-Set Korean | [KeyZ] | ㅋ | z with cmd
182
+ *
183
+ * More details in https://github.com/excalidraw/excalidraw/pull/5944
184
+ */
185
+ export declare const matchKey: (event: KeyboardEvent | React.KeyboardEvent<Element>, key: ValueOf<typeof KEYS>) => boolean;
79
186
  export declare const isArrowKey: (key: string) => boolean;
80
187
  export declare const shouldResizeFromCenter: (event: MouseEvent | KeyboardEvent) => boolean;
81
188
  export declare const shouldMaintainAspectRatio: (event: MouseEvent | KeyboardEvent) => boolean;
@@ -1,8 +1,9 @@
1
1
  import { NonDeletedExcalidrawElement } from "./element/types";
2
- import type { FontMetadata } from "./fonts/metadata";
2
+ import type { FontMetadata } from "./fonts/FontMetadata";
3
+ import { AppState } from "./types";
3
4
  export declare let hostPlugin: any;
4
5
  export declare function destroyObsidianUtils(): void;
5
- export declare function initializeObsidianUtils(obsidianPlugin: any): void;
6
+ export declare function initializeObsidianUtils(): void;
6
7
  export declare function getAreaLimit(): any;
7
8
  export declare function getWidthHeightLimit(): any;
8
9
  export declare function allowDoubleTapEraser(): any;
@@ -17,5 +18,6 @@ export declare function registerLocalFont(fontMetrics: FontMetadata & {
17
18
  export declare function getFontFamilies(): string[];
18
19
  export declare function registerFontsInCSS(): Promise<void>;
19
20
  export declare function getCSSFontDefinition(fontFamily: number): Promise<string>;
20
- export declare function loadSceneFonts(elements: NonDeletedExcalidrawElement[]): Promise<void>;
21
+ export declare function loadSceneFonts(elements: NonDeletedExcalidrawElement[]): Promise<FontFace[]>;
21
22
  export declare function fetchFontFromVault(url: string | URL): Promise<ArrayBuffer | undefined>;
23
+ export declare function isTouchInPenMode(appState: AppState, event: React.PointerEvent<HTMLElement> | MouseEvent): boolean;
@@ -1,9 +1,9 @@
1
- import type { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawFrameLikeElement, NonDeletedSceneElementsMap } from "../element/types";
1
+ import type { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawImageElement, ExcalidrawFrameLikeElement, NonDeletedSceneElementsMap } from "../element/types";
2
2
  import type { RoughCanvas } from "roughjs/bin/canvas";
3
3
  import type { StaticCanvasRenderConfig, RenderableElementsMap, InteractiveCanvasRenderConfig } from "../scene/types";
4
4
  import type { AppState, StaticCanvasAppState, InteractiveCanvasAppState, ElementsPendingErasure, PendingExcalidrawElements } from "../types";
5
5
  export declare const IMAGE_INVERT_FILTER = "invert(100%) hue-rotate(180deg) saturate(1.25)";
6
- export declare const getRenderOpacity: (element: ExcalidrawElement, containingFrame: ExcalidrawFrameLikeElement | null, elementsPendingErasure: ElementsPendingErasure, pendingNodes: Readonly<PendingExcalidrawElements> | null) => number;
6
+ export declare const getRenderOpacity: (element: ExcalidrawElement, containingFrame: ExcalidrawFrameLikeElement | null, elementsPendingErasure: ElementsPendingErasure, pendingNodes: Readonly<PendingExcalidrawElements> | null, globalAlpha?: number) => number;
7
7
  export interface ExcalidrawElementWithCanvas {
8
8
  element: ExcalidrawElement | ExcalidrawTextElement;
9
9
  canvas: HTMLCanvasElement;
@@ -14,6 +14,7 @@ export interface ExcalidrawElementWithCanvas {
14
14
  canvasOffsetX: number;
15
15
  canvasOffsetY: number;
16
16
  boundTextElementVersion: number | null;
17
+ imageCrop: ExcalidrawImageElement["crop"] | null;
17
18
  containingFrameOpacity: number;
18
19
  boundTextCanvas: HTMLCanvasElement;
19
20
  }
@@ -74,5 +74,6 @@ declare class Scene {
74
74
  getContainerElement: (element: (ExcalidrawElement & {
75
75
  containerId: ExcalidrawElement["id"] | null;
76
76
  }) | null) => import("../element/types").ExcalidrawSelectionElement | import("../element/types").ExcalidrawRectangleElement | import("../element/types").ExcalidrawDiamondElement | import("../element/types").ExcalidrawEllipseElement | import("../element/types").ExcalidrawTextElement | import("../element/types").ExcalidrawLinearElement | import("../element/types").ExcalidrawFreeDrawElement | import("../element/types").ExcalidrawImageElement | import("../element/types").ExcalidrawFrameElement | import("../element/types").ExcalidrawMagicFrameElement | import("../element/types").ExcalidrawIframeElement | import("../element/types").ExcalidrawEmbeddableElement | null;
77
+ getElementsFromId: (id: string) => ExcalidrawElement[];
77
78
  }
78
79
  export default Scene;
@@ -289,6 +289,7 @@ export declare const getElementAtPosition: (elements: readonly NonDeletedExcalid
289
289
  fileId: import("../element/types").FileId | null;
290
290
  status: "pending" | "saved" | "error";
291
291
  scale: [number, number];
292
+ crop: import("../element/types").ImageCrop | null;
292
293
  }> & {
293
294
  isDeleted: boolean;
294
295
  }) | (Readonly<{
@@ -25,5 +25,6 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
25
25
  renderEmbeddables?: boolean;
26
26
  exportingFrame?: ExcalidrawFrameLikeElement | null;
27
27
  skipInliningFonts?: true;
28
+ reuseImages?: boolean;
28
29
  }) => Promise<SVGSVGElement>;
29
30
  export declare const getExportSize: (elements: readonly NonDeletedExcalidrawElement[], exportPadding: number, scale: number) => [number, number];
@@ -26,6 +26,13 @@ export type SVGRenderConfig = {
26
26
  canvasBackgroundColor: AppState["viewBackgroundColor"];
27
27
  frameColor?: AppState["frameColor"];
28
28
  embedsValidationStatus: EmbedsValidationStatus;
29
+ /**
30
+ * whether to attempt to reuse images as much as possible through symbols
31
+ * (reduces SVG size, but may be incompoatible with some SVG renderers)
32
+ *
33
+ * @default true
34
+ */
35
+ reuseImages: boolean;
29
36
  };
30
37
  export type InteractiveCanvasRenderConfig = {
31
38
  remoteSelectedElementIds: Map<ExcalidrawElement["id"], SocketId[]>;
@@ -77,6 +77,11 @@ export type BinaryFileData = {
77
77
  * Epoch timestamp in milliseconds.
78
78
  */
79
79
  lastRetrieved?: number;
80
+ /**
81
+ * indicates the version of the file. This can be used to determine whether
82
+ * the file dataURL has changed e.g. as part of restore due to schema update.
83
+ */
84
+ version?: number;
80
85
  };
81
86
  export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
82
87
  export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
@@ -102,6 +107,7 @@ type _CommonCanvasAppState = {
102
107
  width: AppState["width"];
103
108
  height: AppState["height"];
104
109
  viewModeEnabled: AppState["viewModeEnabled"];
110
+ openDialog: AppState["openDialog"];
105
111
  editingGroupId: AppState["editingGroupId"];
106
112
  selectedElementIds: AppState["selectedElementIds"];
107
113
  frameToHighlight: AppState["frameToHighlight"];
@@ -123,6 +129,8 @@ export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
123
129
  gridColor: AppState["gridColor"];
124
130
  frameColor: AppState["frameColor"];
125
131
  currentHoveredFontFamily: AppState["currentHoveredFontFamily"];
132
+ hoveredElementIds: AppState["hoveredElementIds"];
133
+ croppingElementId: AppState["croppingElementId"];
126
134
  }>;
127
135
  export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
128
136
  activeEmbeddable: AppState["activeEmbeddable"];
@@ -141,6 +149,8 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
141
149
  editingTextElement: AppState["editingTextElement"];
142
150
  gridColor: AppState["gridColor"];
143
151
  highlightSearchResult: AppState["highlightSearchResult"];
152
+ isCropping: AppState["isCropping"];
153
+ croppingElementId: AppState["croppingElementId"];
144
154
  searchMatches: AppState["searchMatches"];
145
155
  }>;
146
156
  export type ObservedAppState = ObservedStandaloneAppState & ObservedElementsAppState;
@@ -154,6 +164,7 @@ export type ObservedElementsAppState = {
154
164
  selectedGroupIds: AppState["selectedGroupIds"];
155
165
  editingLinearElementId: LinearElementEditor["elementId"] | null;
156
166
  selectedLinearElementId: LinearElementEditor["elementId"] | null;
167
+ croppingElementId: AppState["croppingElementId"];
157
168
  };
158
169
  export interface AppState {
159
170
  contextMenu: {
@@ -256,6 +267,9 @@ export interface AppState {
256
267
  tab: "text-to-diagram" | "mermaid";
257
268
  } | {
258
269
  name: "commandPalette";
270
+ } | {
271
+ name: "elementLinkSelector";
272
+ sourceElementId: ExcalidrawElement["id"];
259
273
  };
260
274
  /**
261
275
  * Reflects user preference for whether the default sidebar should be docked.
@@ -269,6 +283,9 @@ export interface AppState {
269
283
  selectedElementIds: Readonly<{
270
284
  [id: string]: true;
271
285
  }>;
286
+ hoveredElementIds: Readonly<{
287
+ [id: string]: true;
288
+ }>;
272
289
  previousSelectedElementIds: {
273
290
  [id: string]: true;
274
291
  };
@@ -358,6 +375,9 @@ export interface AppState {
358
375
  userToFollow: UserToFollow | null;
359
376
  /** the socket ids of the users following the current user */
360
377
  followedBy: Set<SocketId>;
378
+ /** image cropping */
379
+ isCropping: boolean;
380
+ croppingElementId: ExcalidrawElement["id"] | null;
361
381
  searchMatches: readonly SearchMatch[];
362
382
  }
363
383
  type SearchMatch = {
@@ -450,7 +470,7 @@ export interface ExcalidrawProps {
450
470
  handleKeyboardGlobally?: boolean;
451
471
  onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
452
472
  autoFocus?: boolean;
453
- onBeforeTextEdit?: (textElement: ExcalidrawTextElement) => string;
473
+ onBeforeTextEdit?: (textElement: ExcalidrawTextElement, isExistingElement: boolean) => string;
454
474
  onBeforeTextSubmit?: (textElement: ExcalidrawTextElement, nextText: string, //wrapped
455
475
  nextOriginalText: string, isDeleted: boolean) => {
456
476
  updatedNextOriginalText: string;
@@ -459,6 +479,7 @@ export interface ExcalidrawProps {
459
479
  generateIdForFile?: (file: File) => string | Promise<string>;
460
480
  onThemeChange?: (newTheme: string) => void;
461
481
  onViewModeChange?: (isViewModeEnabled: boolean) => void;
482
+ generateLinkForSelection?: (id: string, type: "element" | "group") => string;
462
483
  onLinkOpen?: (element: NonDeletedExcalidrawElement, event: CustomEvent<{
463
484
  nativeEvent: MouseEvent | React.PointerEvent<HTMLCanvasElement>;
464
485
  }>) => void;
@@ -475,8 +496,8 @@ export interface ExcalidrawProps {
475
496
  renderMermaid?: boolean;
476
497
  onContextMenu?: (element: readonly NonDeletedExcalidrawElement[], appState: AppState, onClose: (callback?: () => void) => void) => JSX.Element | null;
477
498
  aiEnabled?: boolean;
478
- obsidianHostPlugin: WeakRef<any>;
479
499
  showDeprecatedFonts?: boolean;
500
+ insertLinkAction?: (linkVal: string) => void;
480
501
  }
481
502
  export type SceneData = {
482
503
  elements?: ImportedDataState["elements"];
@@ -631,6 +652,7 @@ export interface ExcalidrawImperativeAPI {
631
652
  clear: InstanceType<typeof App>["resetHistory"];
632
653
  };
633
654
  zoomToFit: InstanceType<typeof App>["zoomToFit"];
655
+ getColorAtScenePoint: InstanceType<typeof App>["getColorAtScenePoint"];
634
656
  startLineEditor: InstanceType<typeof App>["startLineEditor"];
635
657
  getSceneElements: InstanceType<typeof App>["getSceneElements"];
636
658
  getAppState: () => InstanceType<typeof App>["state"];
@@ -4,3 +4,4 @@ export declare const round: (value: number, precision: number, func?: "round" |
4
4
  export declare const roundToStep: (value: number, step: number, func?: "round" | "floor" | "ceil") => number;
5
5
  export declare const average: (a: number, b: number) => number;
6
6
  export declare const isFiniteNumber: (value: any) => value is number;
7
+ export declare const isCloseTo: (a: number, b: number, precision?: number) => boolean;
@@ -86,3 +86,7 @@ export declare function vectorMagnitude(v: Vector): number;
86
86
  * @returns The new normalized vector
87
87
  */
88
88
  export declare const vectorNormalize: (v: Vector) => Vector;
89
+ /**
90
+ * Project the first vector onto the second vector
91
+ */
92
+ export declare const vectorProjection: (a: Vector, b: Vector) => Vector;
@@ -22,10 +22,11 @@ export declare const exportToBlob: (opts: ExportOpts & {
22
22
  quality?: number;
23
23
  exportPadding?: number;
24
24
  }) => Promise<Blob>;
25
- export declare const exportToSvg: ({ elements, appState, files, exportPadding, renderEmbeddables, exportingFrame, skipInliningFonts, }: Omit<ExportOpts, "getDimensions"> & {
25
+ export declare const exportToSvg: ({ elements, appState, files, exportPadding, renderEmbeddables, exportingFrame, skipInliningFonts, reuseImages, }: Omit<ExportOpts, "getDimensions"> & {
26
26
  exportPadding?: number | undefined;
27
27
  renderEmbeddables?: boolean | undefined;
28
28
  skipInliningFonts?: true | undefined;
29
+ reuseImages?: boolean | undefined;
29
30
  }) => Promise<SVGSVGElement>;
30
31
  export declare const exportToClipboard: (opts: ExportOpts & {
31
32
  mimeType?: string;
@@ -36,9 +37,10 @@ export { getCommonBoundingBox } from "../excalidraw/element/bounds";
36
37
  export { getMaximumGroups } from "../excalidraw/groups";
37
38
  export { intersectElementWithLine } from "../excalidraw/element/binding";
38
39
  export { determineFocusDistance } from "../excalidraw/element/binding";
39
- export { measureText, wrapText } from "../excalidraw/element/textElement";
40
+ export { measureText } from "../excalidraw/element/textElement";
41
+ export { wrapText } from "../excalidraw/element/textWrapping";
40
42
  export { getLineHeight } from "../excalidraw/fonts/index";
41
43
  export { getFontString, getFontFamilyString } from "../excalidraw/utils";
42
44
  export { getBoundTextMaxWidth } from "../excalidraw/element/textElement";
43
- export { mermaidToExcalidraw } from "../excalidraw/components/TTDDialog/MermaidToExcalidraw";
45
+ export { mermaidToExcalidraw } from "../excalidraw/components/TTDDialog/MermaidToExcalidrawLib";
44
46
  export { destroyObsidianUtils, registerLocalFont, getFontFamilies, registerFontsInCSS, getCSSFontDefinition, loadSceneFonts, } from "../excalidraw/obsidianUtils";