@dwelle/excalidraw 0.4.0-e3bee83 → 0.4.0-e587816

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 (220) hide show
  1. package/CHANGELOG.md +525 -0
  2. package/README.md +18 -1820
  3. package/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.js → vendor-d415b28e9024dee4bb1b.js} +2 -2
  4. package/dist/excalidraw-assets-dev/{vendor-e6df8519da951026ff69.js → vendor-a14cd58fa2db417e42b2.js} +6 -6
  5. package/dist/excalidraw.development.js +3071 -1566
  6. package/dist/excalidraw.production.min.js +1 -1
  7. package/dist/excalidraw.production.min.js.LICENSE.txt +20 -0
  8. package/main.js +1 -8
  9. package/package.json +9 -4
  10. package/types/actions/actionAddToLibrary.d.ts +103 -55
  11. package/types/actions/actionAlign.d.ts +33 -28
  12. package/types/actions/actionBoundText.d.ts +175 -22
  13. package/types/actions/actionCanvas.d.ts +680 -170
  14. package/types/actions/actionClipboard.d.ts +174 -100
  15. package/types/actions/actionDeleteSelected.d.ts +102 -60
  16. package/types/actions/actionDistribute.d.ts +11 -12
  17. package/types/actions/actionDuplicateSelection.d.ts +3 -4
  18. package/types/actions/actionElementLock.d.ts +271 -0
  19. package/types/actions/actionExport.d.ts +363 -221
  20. package/types/actions/actionFinalize.d.ts +70 -42
  21. package/types/actions/actionFlip.d.ts +8 -11
  22. package/types/actions/actionFrame.d.ts +423 -0
  23. package/types/actions/actionGroup.d.ts +250 -13
  24. package/types/actions/actionHistory.d.ts +1 -1
  25. package/types/actions/actionLinearEditor.d.ts +37 -21
  26. package/types/actions/actionMenu.d.ts +108 -62
  27. package/types/actions/actionNavigate.d.ts +1 -1
  28. package/types/actions/actionProperties.d.ts +465 -256
  29. package/types/actions/actionSelectAll.d.ts +123 -4
  30. package/types/actions/actionStyles.d.ts +39 -24
  31. package/types/actions/actionToggleGridMode.d.ts +37 -22
  32. package/types/actions/{actionToggleLock.d.ts → actionToggleObjectsSnapMode.d.ts} +49 -32
  33. package/types/actions/actionToggleStats.d.ts +37 -22
  34. package/types/actions/actionToggleViewMode.d.ts +37 -22
  35. package/types/actions/actionToggleZenMode.d.ts +37 -22
  36. package/types/actions/actionZindex.d.ts +12 -12
  37. package/types/actions/index.d.ts +2 -1
  38. package/types/actions/manager.d.ts +1 -1
  39. package/types/actions/shortcuts.d.ts +2 -1
  40. package/types/actions/types.d.ts +11 -9
  41. package/types/appState.d.ts +18 -18
  42. package/types/charts.d.ts +2 -2
  43. package/types/clients.d.ts +5 -6
  44. package/types/clipboard.d.ts +8 -7
  45. package/types/colors.d.ts +60 -5
  46. package/types/components/Actions.d.ts +7 -12
  47. package/types/components/ActiveConfirmDialog.d.ts +4 -0
  48. package/types/components/App.d.ts +93 -35
  49. package/types/components/Avatar.d.ts +1 -2
  50. package/types/components/BraveMeasureTextError.d.ts +2 -0
  51. package/types/components/Button.d.ts +3 -2
  52. package/types/components/ButtonIconSelect.d.ts +11 -3
  53. package/types/components/Card.d.ts +0 -1
  54. package/types/components/ColorPicker/ColorInput.d.ts +9 -0
  55. package/types/components/ColorPicker/ColorPicker.d.ts +19 -0
  56. package/types/components/ColorPicker/CustomColorList.d.ts +8 -0
  57. package/types/components/ColorPicker/HotkeyLabel.d.ts +8 -0
  58. package/types/components/ColorPicker/Picker.d.ts +18 -0
  59. package/types/components/ColorPicker/PickerColorList.d.ts +10 -0
  60. package/types/components/ColorPicker/PickerHeading.d.ts +5 -0
  61. package/types/components/ColorPicker/ShadeList.d.ts +8 -0
  62. package/types/components/ColorPicker/TopPicks.d.ts +9 -0
  63. package/types/components/ColorPicker/colorPickerUtils.d.ts +21 -0
  64. package/types/components/ColorPicker/keyboardNavHandlers.d.ts +20 -0
  65. package/types/components/ContextMenu.d.ts +3 -3
  66. package/types/components/DefaultSidebar.d.ts +29 -0
  67. package/types/components/Dialog.d.ts +3 -4
  68. package/types/components/ErrorDialog.d.ts +3 -2
  69. package/types/components/ExcalidrawLogo.d.ts +15 -0
  70. package/types/components/EyeDropper.d.ts +28 -0
  71. package/types/components/FilledButton.d.ts +17 -0
  72. package/types/components/FixedSideContainer.d.ts +1 -1
  73. package/types/components/HandButton.d.ts +10 -0
  74. package/types/components/HelpButton.d.ts +1 -2
  75. package/types/components/HintViewer.d.ts +4 -5
  76. package/types/components/HomeButton.d.ts +1 -1
  77. package/types/components/ImageExportDialog.d.ts +8 -13
  78. package/types/components/Island.d.ts +1 -1
  79. package/types/components/JSONExportDialog.d.ts +5 -5
  80. package/types/components/LaserTool/LaserPathManager.d.ts +28 -0
  81. package/types/components/LaserTool/LaserPointerButton.d.ts +10 -0
  82. package/types/components/LaserTool/LaserTool.d.ts +7 -0
  83. package/types/components/LayerUI.d.ts +9 -15
  84. package/types/components/LibraryMenu.d.ts +13 -14
  85. package/types/components/LibraryMenuBrowseButton.d.ts +2 -2
  86. package/types/components/LibraryMenuControlButtons.d.ts +9 -0
  87. package/types/components/LibraryMenuHeaderContent.d.ts +10 -28
  88. package/types/components/LibraryMenuItems.d.ts +6 -7
  89. package/types/components/LibraryMenuSection.d.ts +22 -0
  90. package/types/components/LibraryUnit.d.ts +6 -3
  91. package/types/components/LoadingMessage.d.ts +0 -1
  92. package/types/components/LockButton.d.ts +1 -2
  93. package/types/components/MobileMenu.d.ts +8 -11
  94. package/types/components/OverwriteConfirm/OverwriteConfirm.d.ts +17 -0
  95. package/types/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +17 -0
  96. package/types/components/OverwriteConfirm/OverwriteConfirmState.d.ts +22 -0
  97. package/types/components/PasteChartDialog.d.ts +4 -5
  98. package/types/components/PenModeButton.d.ts +1 -1
  99. package/types/components/Popover.d.ts +1 -1
  100. package/types/components/ProjectName.d.ts +2 -1
  101. package/types/components/PublishLibrary.d.ts +2 -2
  102. package/types/components/RadioGroup.d.ts +12 -0
  103. package/types/components/Section.d.ts +1 -1
  104. package/types/components/Sidebar/Sidebar.d.ts +66 -63
  105. package/types/components/Sidebar/SidebarHeader.d.ts +6 -19
  106. package/types/components/Sidebar/SidebarTab.d.ts +8 -0
  107. package/types/components/Sidebar/SidebarTabTrigger.d.ts +9 -0
  108. package/types/components/Sidebar/SidebarTabTriggers.d.ts +6 -0
  109. package/types/components/Sidebar/SidebarTabs.d.ts +6 -0
  110. package/types/components/Sidebar/SidebarTrigger.d.ts +6 -0
  111. package/types/components/Sidebar/common.d.ts +24 -7
  112. package/types/components/Spinner.d.ts +2 -1
  113. package/types/components/Stack.d.ts +4 -3
  114. package/types/components/Stats.d.ts +3 -3
  115. package/types/components/Switch.d.ts +9 -0
  116. package/types/components/ToolButton.d.ts +6 -5
  117. package/types/components/Tooltip.d.ts +1 -1
  118. package/types/components/Trans.d.ts +9 -0
  119. package/types/components/canvases/InteractiveCanvas.d.ts +27 -0
  120. package/types/components/canvases/StaticCanvas.d.ts +18 -0
  121. package/types/components/canvases/index.d.ts +3 -0
  122. package/types/components/dropdownMenu/DropdownMenu.d.ts +15 -9
  123. package/types/components/dropdownMenu/DropdownMenuContent.d.ts +7 -3
  124. package/types/components/dropdownMenu/DropdownMenuItem.d.ts +4 -4
  125. package/types/components/dropdownMenu/DropdownMenuItemCustom.d.ts +2 -1
  126. package/types/components/dropdownMenu/DropdownMenuItemLink.d.ts +4 -2
  127. package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +3 -2
  128. package/types/components/dropdownMenu/common.d.ts +6 -0
  129. package/types/components/footer/Footer.d.ts +4 -5
  130. package/types/components/hoc/withInternalFallback.d.ts +4 -0
  131. package/types/components/icons.d.ts +16 -1
  132. package/types/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -1
  133. package/types/components/main-menu/MainMenu.d.ts +22 -13
  134. package/types/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -1
  135. package/types/components/welcome-screen/WelcomeScreen.d.ts +2 -3
  136. package/types/constants.d.ts +94 -10
  137. package/types/context/tunnels.d.ts +19 -0
  138. package/types/context/ui-appState.d.ts +4 -0
  139. package/types/cursor.d.ts +5 -0
  140. package/types/data/blob.d.ts +5 -3
  141. package/types/data/encode.d.ts +1 -1
  142. package/types/data/filesystem.d.ts +2 -1
  143. package/types/data/library.d.ts +3 -45
  144. package/types/data/restore.d.ts +10 -4
  145. package/types/data/transform.d.ts +73 -0
  146. package/types/data/types.d.ts +3 -5
  147. package/types/data/url.d.ts +7 -0
  148. package/types/element/Hyperlink.d.ts +48 -29
  149. package/types/element/binding.d.ts +4 -3
  150. package/types/element/bounds.d.ts +40 -10
  151. package/types/element/collision.d.ts +7 -7
  152. package/types/element/dragElements.d.ts +12 -2
  153. package/types/element/embeddable.d.ts +153 -0
  154. package/types/element/image.d.ts +11 -1
  155. package/types/element/index.d.ts +3 -2
  156. package/types/element/linearElementEditor.d.ts +43 -27
  157. package/types/element/mutateElement.d.ts +3 -2
  158. package/types/element/newElement.d.ts +48 -15
  159. package/types/element/resizeElements.d.ts +3 -2
  160. package/types/element/resizeTest.d.ts +2 -1
  161. package/types/element/showSelectedShapeActions.d.ts +2 -2
  162. package/types/element/sizeHelpers.d.ts +8 -1
  163. package/types/element/sortElements.d.ts +2 -0
  164. package/types/element/textElement.d.ts +43 -17
  165. package/types/element/textWysiwyg.d.ts +1 -1
  166. package/types/element/transformHandles.d.ts +16 -8
  167. package/types/element/typeChecks.d.ts +5 -2
  168. package/types/element/types.d.ts +59 -35
  169. package/types/emitter.d.ts +1 -2
  170. package/types/errors.d.ts +1 -1
  171. package/types/frame.d.ts +46 -0
  172. package/types/ga.d.ts +5 -5
  173. package/types/groups.d.ts +15 -11
  174. package/types/history.d.ts +3 -3
  175. package/types/hooks/useCreatePortalContainer.d.ts +4 -0
  176. package/types/hooks/useLibraryItemSvg.d.ts +11 -0
  177. package/types/hooks/useOutsideClick.d.ts +19 -2
  178. package/types/hooks/useScrollPosition.d.ts +1 -0
  179. package/types/hooks/useStable.d.ts +1 -0
  180. package/types/hooks/useTransition.d.ts +2 -0
  181. package/types/i18n.d.ts +11 -2
  182. package/types/jotai.d.ts +20 -108
  183. package/types/keys.d.ts +5 -4
  184. package/types/math.d.ts +5 -0
  185. package/types/packages/bbox.d.ts +11 -0
  186. package/types/packages/excalidraw/example/App.d.ts +7 -1
  187. package/types/packages/excalidraw/example/initialData.d.ts +182 -64
  188. package/types/packages/excalidraw/index.d.ts +11 -4
  189. package/types/packages/excalidraw/main.d.ts +3 -1
  190. package/types/packages/excalidraw/webpack.dev.config.d.ts +5 -2
  191. package/types/packages/excalidraw/webpack.prod.config.d.ts +3 -0
  192. package/types/packages/utils.d.ts +11 -2
  193. package/types/packages/withinBounds.d.ts +19 -0
  194. package/types/renderer/renderElement.d.ts +12 -22
  195. package/types/renderer/renderScene.d.ts +19 -27
  196. package/types/renderer/renderSnaps.d.ts +2 -0
  197. package/types/renderer/roundRect.d.ts +1 -1
  198. package/types/scene/Renderer.d.ts +25 -0
  199. package/types/scene/Scene.d.ts +27 -5
  200. package/types/scene/Shape.d.ts +12 -0
  201. package/types/scene/ShapeCache.d.ts +20 -0
  202. package/types/scene/comparisons.d.ts +0 -1
  203. package/types/scene/export.d.ts +50 -11
  204. package/types/scene/index.d.ts +1 -1
  205. package/types/scene/scroll.d.ts +1 -1
  206. package/types/scene/scrollbars.d.ts +2 -6
  207. package/types/scene/selection.d.ts +27 -6
  208. package/types/scene/types.d.ts +70 -34
  209. package/types/snapping.d.ts +108 -0
  210. package/types/types.d.ts +200 -84
  211. package/types/utility-types.d.ts +24 -0
  212. package/types/utils.d.ts +73 -29
  213. package/types/zindex.d.ts +4 -4
  214. package/types/components/ColorPicker.d.ts +0 -14
  215. package/types/components/LibraryButton.d.ts +0 -8
  216. package/types/components/SingleLibraryItem.d.ts +0 -10
  217. package/types/components/hoc/withUpstreamOverride.d.ts +0 -10
  218. /package/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.js.LICENSE.txt → vendor-d415b28e9024dee4bb1b.js.LICENSE.txt} +0 -0
  219. /package/types/packages/excalidraw/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.d.ts → vendor-d415b28e9024dee4bb1b.d.ts} +0 -0
  220. /package/types/packages/excalidraw/dist/excalidraw-assets-dev/{vendor-e6df8519da951026ff69.d.ts → vendor-a14cd58fa2db417e42b2.d.ts} +0 -0
@@ -1,16 +1,24 @@
1
- import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer } from "../element/types";
1
+ import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement } from "../element/types";
2
2
  import { AppState } from "../types";
3
- declare type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "boundElements" | "seed" | "version" | "versionNonce" | "link">;
3
+ import { MarkOptional, Mutable } from "../utility-types";
4
+ export type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity">;
4
5
  export declare const newElement: (opts: {
5
6
  type: ExcalidrawGenericElement["type"];
6
7
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawGenericElement>;
8
+ export declare const newEmbeddableElement: (opts: {
9
+ type: "embeddable";
10
+ validated: ExcalidrawEmbeddableElement["validated"];
11
+ } & ElementConstructorOpts) => NonDeleted<ExcalidrawEmbeddableElement>;
12
+ export declare const newFrameElement: (opts: ElementConstructorOpts) => NonDeleted<ExcalidrawFrameElement>;
7
13
  export declare const newTextElement: (opts: {
8
14
  text: string;
9
- fontSize: number;
10
- fontFamily: FontFamilyValues;
11
- textAlign: TextAlign;
12
- verticalAlign: VerticalAlign;
13
- containerId?: ExcalidrawTextContainer["id"];
15
+ fontSize?: number;
16
+ fontFamily?: FontFamilyValues;
17
+ textAlign?: TextAlign;
18
+ verticalAlign?: VerticalAlign;
19
+ containerId?: ExcalidrawTextContainer["id"] | null;
20
+ lineHeight?: ExcalidrawTextElement["lineHeight"];
21
+ strokeWidth?: ExcalidrawTextElement["strokeWidth"];
14
22
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
15
23
  export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, text?: string) => {
16
24
  x: number;
@@ -19,9 +27,7 @@ export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement,
19
27
  height: number;
20
28
  baseline: number;
21
29
  text: string;
22
- };
23
- export declare const getMaxContainerWidth: (container: ExcalidrawElement) => number;
24
- export declare const getMaxContainerHeight: (container: ExcalidrawElement) => number;
30
+ } | undefined;
25
31
  export declare const updateTextElement: (textElement: ExcalidrawTextElement, { text, isDeleted, originalText, }: {
26
32
  text: string;
27
33
  isDeleted?: boolean | undefined;
@@ -34,8 +40,8 @@ export declare const newFreeDrawElement: (opts: {
34
40
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawFreeDrawElement>;
35
41
  export declare const newLinearElement: (opts: {
36
42
  type: ExcalidrawLinearElement["type"];
37
- startArrowhead: Arrowhead | null;
38
- endArrowhead: Arrowhead | null;
43
+ startArrowhead?: Arrowhead | null;
44
+ endArrowhead?: Arrowhead | null;
39
45
  points?: ExcalidrawLinearElement["points"];
40
46
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawLinearElement>;
41
47
  export declare const newImageElement: (opts: {
@@ -44,7 +50,21 @@ export declare const newImageElement: (opts: {
44
50
  fileId?: ExcalidrawImageElement["fileId"];
45
51
  scale?: ExcalidrawImageElement["scale"];
46
52
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawImageElement>;
47
- export declare const deepCopyElement: (val: any, depth?: number) => any;
53
+ /**
54
+ * Clones ExcalidrawElement data structure. Does not regenerate id, nonce, or
55
+ * any value. The purpose is to to break object references for immutability
56
+ * reasons, whenever we want to keep the original element, but ensure it's not
57
+ * mutated.
58
+ *
59
+ * Only clones plain objects and arrays. Doesn't clone Date, RegExp, Map, Set,
60
+ * Typed arrays and other non-null objects.
61
+ */
62
+ export declare const deepCopyElement: <T extends ExcalidrawElement>(val: T) => Mutable<T>;
63
+ /**
64
+ * utility wrapper to generate new id. In test env it reuses the old + postfix
65
+ * for test assertions.
66
+ */
67
+ export declare const regenerateId: (previousId: string | null) => string;
48
68
  /**
49
69
  * Duplicate an element, often used in the alt-drag operation.
50
70
  * Note that this method has gotten a bit complicated since the
@@ -59,5 +79,18 @@ export declare const deepCopyElement: (val: any, depth?: number) => any;
59
79
  * @param element Element to duplicate
60
80
  * @param overrides Any element properties to override
61
81
  */
62
- export declare const duplicateElement: <TElement extends Mutable<ExcalidrawElement>>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement, overrides?: Partial<TElement> | undefined) => TElement;
63
- export {};
82
+ export declare const duplicateElement: <TElement extends ExcalidrawElement>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement, overrides?: Partial<TElement> | undefined) => Readonly<TElement>;
83
+ /**
84
+ * Clones elements, regenerating their ids (including bindings) and group ids.
85
+ *
86
+ * If bindings don't exist in the elements array, they are removed. Therefore,
87
+ * it's advised to supply the whole elements array, or sets of elements that
88
+ * are encapsulated (such as library items), if the purpose is to retain
89
+ * bindings to the cloned elements intact.
90
+ *
91
+ * NOTE by default does not randomize or regenerate anything except the id.
92
+ */
93
+ export declare const duplicateElements: (elements: readonly ExcalidrawElement[], opts?: {
94
+ /** NOTE also updates version flags and `updated` */
95
+ randomizeSeed: boolean;
96
+ }) => ExcalidrawElement[];
@@ -1,8 +1,9 @@
1
1
  import { ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
2
2
  import { MaybeTransformHandleType, TransformHandleDirection } from "./transformHandles";
3
- import { PointerDownState } from "../types";
3
+ import { AppState, PointerDownState } from "../types";
4
4
  export declare const normalizeAngle: (angle: number) => number;
5
- export declare const transformElements: (pointerDownState: PointerDownState, transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], resizeArrowDirection: "origin" | "end", shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
5
+ export declare const transformElements: (pointerDownState: PointerDownState, transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], resizeArrowDirection: "origin" | "end", shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number, appState: AppState) => boolean;
6
6
  export declare const resizeSingleElement: (originalElements: PointerDownState["originalElements"], shouldMaintainAspectRatio: boolean, element: NonDeletedExcalidrawElement, transformHandleDirection: TransformHandleDirection, shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
7
+ export declare const resizeMultipleElements: (pointerDownState: PointerDownState, selectedElements: readonly NonDeletedExcalidrawElement[], transformHandleType: "nw" | "ne" | "sw" | "se", shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
7
8
  export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
8
9
  export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
@@ -1,12 +1,13 @@
1
1
  import { ExcalidrawElement, PointerType, NonDeletedExcalidrawElement } from "./types";
2
2
  import { MaybeTransformHandleType } from "./transformHandles";
3
3
  import { AppState, Zoom } from "../types";
4
+ import { Bounds } from "./bounds";
4
5
  export declare const resizeTest: (element: NonDeletedExcalidrawElement, appState: AppState, x: number, y: number, zoom: Zoom, pointerType: PointerType) => MaybeTransformHandleType;
5
6
  export declare const getElementWithTransformHandleType: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType) => {
6
7
  element: NonDeletedExcalidrawElement;
7
8
  transformHandleType: MaybeTransformHandleType;
8
9
  } | null;
9
- export declare const getTransformHandleTypeFromCoords: ([x1, y1, x2, y2]: readonly [number, number, number, number], scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType) => MaybeTransformHandleType;
10
+ export declare const getTransformHandleTypeFromCoords: ([x1, y1, x2, y2]: Bounds, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType) => MaybeTransformHandleType;
10
11
  export declare const getCursorForResizingElement: (resizingElement: {
11
12
  element?: ExcalidrawElement;
12
13
  transformHandleType: MaybeTransformHandleType;
@@ -1,3 +1,3 @@
1
- import { AppState } from "../types";
2
1
  import { NonDeletedExcalidrawElement } from "./types";
3
- export declare const showSelectedShapeActions: (appState: AppState, elements: readonly NonDeletedExcalidrawElement[]) => boolean;
2
+ import { UIAppState } from "../types";
3
+ export declare const showSelectedShapeActions: (appState: UIAppState, elements: readonly NonDeletedExcalidrawElement[]) => boolean;
@@ -1,6 +1,13 @@
1
1
  import { ExcalidrawElement } from "./types";
2
- import { AppState } from "../types";
2
+ import { AppState, Zoom } from "../types";
3
3
  export declare const isInvisiblySmallElement: (element: ExcalidrawElement) => boolean;
4
+ export declare const isElementInViewport: (element: ExcalidrawElement, width: number, height: number, viewTransformations: {
5
+ zoom: Zoom;
6
+ offsetLeft: number;
7
+ offsetTop: number;
8
+ scrollX: number;
9
+ scrollY: number;
10
+ }) => boolean;
4
11
  /**
5
12
  * Makes a perfect shape or diagonal/horizontal/vertical line
6
13
  */
@@ -0,0 +1,2 @@
1
+ import { ExcalidrawElement } from "./types";
2
+ export declare const normalizeElementOrder: (elements: readonly ExcalidrawElement[]) => readonly ExcalidrawElement[];
@@ -1,30 +1,44 @@
1
- import { ExcalidrawElement, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontString, NonDeletedExcalidrawElement } from "./types";
1
+ import { ExcalidrawElement, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./types";
2
2
  import { MaybeTransformHandleType } from "./transformHandles";
3
3
  import { AppState } from "../types";
4
+ import { ExtractSetType } from "../utility-types";
4
5
  export declare const normalizeText: (text: string) => string;
6
+ export declare const splitIntoLines: (text: string) => string[];
5
7
  export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null) => void;
6
8
  export declare const bindTextToShapeAfterDuplication: (sceneElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
7
- export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, transformHandleType: MaybeTransformHandleType) => void;
8
- export declare const measureText: (text: string, font: FontString, maxWidth?: number | null) => {
9
- width: number;
10
- height: number;
11
- baseline: number;
12
- container: HTMLDivElement;
13
- } | {
9
+ export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean) => void;
10
+ export declare const computeBoundTextPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
11
+ x: number;
12
+ y: number;
13
+ };
14
+ export declare const measureText: (text: string, font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => {
14
15
  width: number;
15
16
  height: number;
16
17
  baseline: number;
17
- container?: undefined;
18
18
  };
19
- export declare const getApproxLineHeight: (font: FontString) => number;
19
+ export declare const measureBaseline: (text: string, font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"], wrapInContainer?: boolean) => number;
20
+ /**
21
+ * To get unitless line-height (if unknown) we can calculate it by dividing
22
+ * height-per-line by fontSize.
23
+ */
24
+ export declare const detectLineHeight: (textElement: ExcalidrawTextElement) => number & {
25
+ _brand: "unitlessLineHeight";
26
+ };
27
+ /**
28
+ * We calculate the line height from the font size and the unitless line height,
29
+ * aligning with the W3C spec.
30
+ */
31
+ export declare const getLineHeightInPx: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
32
+ export declare const getApproxMinLineHeight: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
20
33
  export declare const getTextWidth: (text: string, font: FontString) => number;
34
+ export declare const getTextHeight: (text: string, fontSize: number, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
35
+ export declare const parseTokens: (text: string) => string[];
21
36
  export declare const wrapText: (text: string, font: FontString, maxWidth: number) => string;
22
37
  export declare const charWidth: {
23
38
  calculate: (char: string, font: FontString) => number;
24
39
  getCache: (font: FontString) => number[];
25
40
  };
26
- export declare const getApproxMinLineWidth: (font: FontString) => number;
27
- export declare const getApproxMinLineHeight: (font: FontString) => number;
41
+ export declare const getApproxMinLineWidth: (font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
28
42
  export declare const getMinCharWidth: (font: FontString) => number;
29
43
  export declare const getMaxCharWidth: (font: FontString) => number;
30
44
  export declare const getApproxCharsToFitInWidth: (font: FontString, width: number) => number;
@@ -33,14 +47,14 @@ export declare const getBoundTextElement: (element: ExcalidrawElement | null) =>
33
47
  export declare const getContainerElement: (element: (ExcalidrawElement & {
34
48
  containerId: ExcalidrawElement["id"] | null;
35
49
  }) | null) => ExcalidrawElement | null;
36
- export declare const getContainerDims: (element: ExcalidrawElement) => {
37
- width: number;
38
- height: number;
39
- };
40
50
  export declare const getContainerCenter: (container: ExcalidrawElement, appState: AppState) => {
41
51
  x: number;
42
52
  y: number;
43
53
  };
54
+ export declare const getContainerCoords: (container: NonDeletedExcalidrawElement) => {
55
+ x: number;
56
+ y: number;
57
+ };
44
58
  export declare const getTextElementAngle: (textElement: ExcalidrawTextElement) => number;
45
59
  export declare const getBoundTextElementOffset: (boundTextElement: ExcalidrawTextElement | null) => number;
46
60
  export declare const getBoundTextElementPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
@@ -48,5 +62,17 @@ export declare const getBoundTextElementPosition: (container: ExcalidrawElement,
48
62
  y: number;
49
63
  } | undefined;
50
64
  export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
65
+ export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
51
66
  export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], appState: AppState, x: number, y: number) => ExcalidrawTextContainer | null;
52
- export declare const isValidTextContainer: (element: ExcalidrawElement) => boolean;
67
+ declare const VALID_CONTAINER_TYPES: Set<string>;
68
+ export declare const isValidTextContainer: (element: {
69
+ type: ExcalidrawElement["type"];
70
+ }) => boolean;
71
+ export declare const computeContainerDimensionForBoundText: (dimension: number, containerType: ExtractSetType<typeof VALID_CONTAINER_TYPES>) => number;
72
+ export declare const getBoundTextMaxWidth: (container: ExcalidrawElement, boundTextElement?: ExcalidrawTextElement | null) => number;
73
+ export declare const getBoundTextMaxHeight: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => number;
74
+ export declare const isMeasureTextSupported: () => boolean;
75
+ export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
76
+ _brand: "unitlessLineHeight";
77
+ };
78
+ export {};
@@ -15,7 +15,7 @@ export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords,
15
15
  }) => void;
16
16
  getViewportCoords: (x: number, y: number) => [number, number];
17
17
  element: ExcalidrawTextElement;
18
- canvas: HTMLCanvasElement | null;
18
+ canvas: HTMLCanvasElement;
19
19
  excalidrawContainer: HTMLDivElement | null;
20
20
  app: App;
21
21
  }) => void;
@@ -1,23 +1,31 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
2
- import { AppState, Zoom } from "../types";
3
- export declare type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
4
- export declare type TransformHandleType = TransformHandleDirection | "rotation";
5
- export declare type TransformHandle = [number, number, number, number];
6
- export declare type TransformHandles = Partial<{
2
+ import { Bounds } from "./bounds";
3
+ import { InteractiveCanvasAppState, Zoom } from "../types";
4
+ export type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
5
+ export type TransformHandleType = TransformHandleDirection | "rotation";
6
+ export type TransformHandle = Bounds;
7
+ export type TransformHandles = Partial<{
7
8
  [T in TransformHandleType]: TransformHandle;
8
9
  }>;
9
- export declare type MaybeTransformHandleType = TransformHandleType | false;
10
+ export type MaybeTransformHandleType = TransformHandleType | false;
10
11
  export declare const OMIT_SIDES_FOR_MULTIPLE_ELEMENTS: {
11
12
  e: boolean;
12
13
  s: boolean;
13
14
  n: boolean;
14
15
  w: boolean;
15
16
  };
17
+ export declare const OMIT_SIDES_FOR_FRAME: {
18
+ e: boolean;
19
+ s: boolean;
20
+ n: boolean;
21
+ w: boolean;
22
+ rotation: boolean;
23
+ };
16
24
  export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [number, number, number, number, number, number], angle: number, zoom: Zoom, pointerType: PointerType, omitSides?: {
17
25
  s?: boolean | undefined;
18
26
  e?: boolean | undefined;
19
- n?: boolean | undefined;
20
27
  w?: boolean | undefined;
28
+ n?: boolean | undefined;
21
29
  nw?: boolean | undefined;
22
30
  ne?: boolean | undefined;
23
31
  sw?: boolean | undefined;
@@ -25,4 +33,4 @@ export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [
25
33
  rotation?: boolean | undefined;
26
34
  }, margin?: number) => TransformHandles;
27
35
  export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoom, pointerType?: PointerType) => TransformHandles;
28
- export declare const shouldShowBoundingBox: (elements: NonDeletedExcalidrawElement[], appState: AppState) => boolean;
36
+ export declare const shouldShowBoundingBox: (elements: readonly NonDeletedExcalidrawElement[], appState: InteractiveCanvasAppState) => boolean;
@@ -1,9 +1,12 @@
1
1
  import { AppState } from "../types";
2
- import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawGenericElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, RoundnessType } from "./types";
2
+ import { MarkNonNullable } from "../utility-types";
3
+ import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawEmbeddableElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawGenericElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType } from "./types";
3
4
  export declare const isGenericElement: (element: ExcalidrawElement | null) => element is ExcalidrawGenericElement;
4
5
  export declare const isInitializedImageElement: (element: ExcalidrawElement | null) => element is InitializedExcalidrawImageElement;
5
6
  export declare const isImageElement: (element: ExcalidrawElement | null) => element is ExcalidrawImageElement;
7
+ export declare const isEmbeddableElement: (element: ExcalidrawElement | null | undefined) => element is ExcalidrawEmbeddableElement;
6
8
  export declare const isTextElement: (element: ExcalidrawElement | null) => element is ExcalidrawTextElement;
9
+ export declare const isFrameElement: (element: ExcalidrawElement | null) => element is ExcalidrawFrameElement;
7
10
  export declare const isFreeDrawElement: (element?: ExcalidrawElement | null) => element is ExcalidrawFreeDrawElement;
8
11
  export declare const isFreeDrawElementType: (elementType: ExcalidrawElement["type"]) => boolean;
9
12
  export declare const isLinearElement: (element?: ExcalidrawElement | null) => element is ExcalidrawLinearElement;
@@ -14,7 +17,7 @@ export declare const isBindingElementType: (elementType: AppState["activeTool"][
14
17
  export declare const isBindableElement: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawBindableElement;
15
18
  export declare const isTextBindableContainer: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawTextContainer;
16
19
  export declare const isExcalidrawElement: (element: any) => boolean;
17
- export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is ExcalidrawBindableElement;
20
+ export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is MarkNonNullable<ExcalidrawBindableElement, "boundElements">;
18
21
  export declare const isBoundToContainer: (element: ExcalidrawElement | null) => element is ExcalidrawTextElementWithContainer;
19
22
  export declare const isUsingAdaptiveRadius: (type: string) => boolean;
20
23
  export declare const isUsingProportionalRadius: (type: string) => boolean;
@@ -1,22 +1,23 @@
1
1
  import { Point } from "../types";
2
2
  import { FONT_FAMILY, ROUNDNESS, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "../constants";
3
- export declare type ChartType = "bar" | "line";
4
- export declare type FillStyle = "hachure" | "cross-hatch" | "solid";
5
- export declare type FontFamilyKeys = keyof typeof FONT_FAMILY;
6
- export declare type FontFamilyValues = typeof FONT_FAMILY[FontFamilyKeys];
7
- export declare type Theme = typeof THEME[keyof typeof THEME];
8
- export declare type FontString = string & {
3
+ import { MarkNonNullable, ValueOf } from "../utility-types";
4
+ export type ChartType = "bar" | "line";
5
+ export type FillStyle = "hachure" | "cross-hatch" | "solid" | "zigzag";
6
+ export type FontFamilyKeys = keyof typeof FONT_FAMILY;
7
+ export type FontFamilyValues = typeof FONT_FAMILY[FontFamilyKeys];
8
+ export type Theme = typeof THEME[keyof typeof THEME];
9
+ export type FontString = string & {
9
10
  _brand: "fontString";
10
11
  };
11
- export declare type GroupId = string;
12
- export declare type PointerType = "mouse" | "pen" | "touch";
13
- export declare type StrokeRoundness = "round" | "sharp";
14
- export declare type RoundnessType = ValueOf<typeof ROUNDNESS>;
15
- export declare type StrokeStyle = "solid" | "dashed" | "dotted";
16
- export declare type TextAlign = typeof TEXT_ALIGN[keyof typeof TEXT_ALIGN];
17
- declare type VerticalAlignKeys = keyof typeof VERTICAL_ALIGN;
18
- export declare type VerticalAlign = typeof VERTICAL_ALIGN[VerticalAlignKeys];
19
- declare type _ExcalidrawElementBase = Readonly<{
12
+ export type GroupId = string;
13
+ export type PointerType = "mouse" | "pen" | "touch";
14
+ export type StrokeRoundness = "round" | "sharp";
15
+ export type RoundnessType = ValueOf<typeof ROUNDNESS>;
16
+ export type StrokeStyle = "solid" | "dashed" | "dotted";
17
+ export type TextAlign = typeof TEXT_ALIGN[keyof typeof TEXT_ALIGN];
18
+ type VerticalAlignKeys = keyof typeof VERTICAL_ALIGN;
19
+ export type VerticalAlign = typeof VERTICAL_ALIGN[VerticalAlignKeys];
20
+ type _ExcalidrawElementBase = Readonly<{
20
21
  id: string;
21
22
  x: number;
22
23
  y: number;
@@ -48,6 +49,7 @@ declare type _ExcalidrawElementBase = Readonly<{
48
49
  /** List of groups the element belongs to.
49
50
  Ordered from deepest to shallowest. */
50
51
  groupIds: readonly GroupId[];
52
+ frameId: string | null;
51
53
  /** other elements that are bound to this element */
52
54
  boundElements: readonly Readonly<{
53
55
  id: ExcalidrawLinearElement["id"];
@@ -59,19 +61,30 @@ declare type _ExcalidrawElementBase = Readonly<{
59
61
  locked: boolean;
60
62
  customData?: Record<string, any>;
61
63
  }>;
62
- export declare type ExcalidrawSelectionElement = _ExcalidrawElementBase & {
64
+ export type ExcalidrawSelectionElement = _ExcalidrawElementBase & {
63
65
  type: "selection";
64
66
  };
65
- export declare type ExcalidrawRectangleElement = _ExcalidrawElementBase & {
67
+ export type ExcalidrawRectangleElement = _ExcalidrawElementBase & {
66
68
  type: "rectangle";
67
69
  };
68
- export declare type ExcalidrawDiamondElement = _ExcalidrawElementBase & {
70
+ export type ExcalidrawDiamondElement = _ExcalidrawElementBase & {
69
71
  type: "diamond";
70
72
  };
71
- export declare type ExcalidrawEllipseElement = _ExcalidrawElementBase & {
73
+ export type ExcalidrawEllipseElement = _ExcalidrawElementBase & {
72
74
  type: "ellipse";
73
75
  };
74
- export declare type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
76
+ export type ExcalidrawEmbeddableElement = _ExcalidrawElementBase & Readonly<{
77
+ type: "embeddable";
78
+ /**
79
+ * indicates whether the embeddable src (url) has been validated for rendering.
80
+ * null value indicates that the validation is pending. We reset the
81
+ * value on each restore (or url change) so that we can guarantee
82
+ * the validation came from a trusted source (the editor). Also because we
83
+ * may not have access to host-app supplied url validator during restore.
84
+ */
85
+ validated: boolean | null;
86
+ }>;
87
+ export type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
75
88
  type: "image";
76
89
  fileId: FileId | null;
77
90
  /** whether respective file is persisted */
@@ -79,22 +92,26 @@ export declare type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
79
92
  /** X and Y scale factors <-1, 1>, used for image axis flipping */
80
93
  scale: [number, number];
81
94
  }>;
82
- export declare type InitializedExcalidrawImageElement = MarkNonNullable<ExcalidrawImageElement, "fileId">;
95
+ export type InitializedExcalidrawImageElement = MarkNonNullable<ExcalidrawImageElement, "fileId">;
96
+ export type ExcalidrawFrameElement = _ExcalidrawElementBase & {
97
+ type: "frame";
98
+ name: string | null;
99
+ };
83
100
  /**
84
101
  * These are elements that don't have any additional properties.
85
102
  */
86
- export declare type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
103
+ export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
87
104
  /**
88
105
  * ExcalidrawElement should be JSON serializable and (eventually) contain
89
106
  * no computed data. The list of all ExcalidrawElements should be shareable
90
107
  * between peers and contain no state local to the peer.
91
108
  */
92
- export declare type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement;
93
- export declare type NonDeleted<TElement extends ExcalidrawElement> = TElement & {
109
+ export type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement | ExcalidrawFrameElement | ExcalidrawEmbeddableElement;
110
+ export type NonDeleted<TElement extends ExcalidrawElement> = TElement & {
94
111
  isDeleted: boolean;
95
112
  };
96
- export declare type NonDeletedExcalidrawElement = NonDeleted<ExcalidrawElement>;
97
- export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
113
+ export type NonDeletedExcalidrawElement = NonDeleted<ExcalidrawElement>;
114
+ export type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
98
115
  type: "text";
99
116
  fontSize: number;
100
117
  fontFamily: FontFamilyValues;
@@ -104,19 +121,26 @@ export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
104
121
  verticalAlign: VerticalAlign;
105
122
  containerId: ExcalidrawGenericElement["id"] | null;
106
123
  originalText: string;
124
+ /**
125
+ * Unitless line height (aligned to W3C). To get line height in px, multiply
126
+ * with font size (using `getLineHeightInPx` helper).
127
+ */
128
+ lineHeight: number & {
129
+ _brand: "unitlessLineHeight";
130
+ };
107
131
  }>;
108
- export declare type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement;
109
- export declare type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawImageElement | ExcalidrawArrowElement;
110
- export declare type ExcalidrawTextElementWithContainer = {
132
+ export type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement | ExcalidrawEmbeddableElement | ExcalidrawFrameElement;
133
+ export type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawArrowElement;
134
+ export type ExcalidrawTextElementWithContainer = {
111
135
  containerId: ExcalidrawTextContainer["id"];
112
136
  } & ExcalidrawTextElement;
113
- export declare type PointBinding = {
137
+ export type PointBinding = {
114
138
  elementId: ExcalidrawBindableElement["id"];
115
139
  focus: number;
116
140
  gap: number;
117
141
  };
118
- export declare type Arrowhead = "arrow" | "bar" | "dot" | "triangle";
119
- export declare type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
142
+ export type Arrowhead = "arrow" | "bar" | "dot" | "triangle";
143
+ export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
120
144
  type: "line" | "arrow";
121
145
  points: readonly Point[];
122
146
  lastCommittedPoint: Point | null;
@@ -125,17 +149,17 @@ export declare type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<
125
149
  startArrowhead: Arrowhead | null;
126
150
  endArrowhead: Arrowhead | null;
127
151
  }>;
128
- export declare type ExcalidrawArrowElement = ExcalidrawLinearElement & Readonly<{
152
+ export type ExcalidrawArrowElement = ExcalidrawLinearElement & Readonly<{
129
153
  type: "arrow";
130
154
  }>;
131
- export declare type ExcalidrawFreeDrawElement = _ExcalidrawElementBase & Readonly<{
155
+ export type ExcalidrawFreeDrawElement = _ExcalidrawElementBase & Readonly<{
132
156
  type: "freedraw";
133
157
  points: readonly Point[];
134
158
  pressures: readonly number[];
135
159
  simulatePressure: boolean;
136
160
  lastCommittedPoint: Point | null;
137
161
  }>;
138
- export declare type FileId = string & {
162
+ export type FileId = string & {
139
163
  _brand: "FileId";
140
164
  };
141
165
  export {};
@@ -1,4 +1,4 @@
1
- declare type Subscriber<T extends any[]> = (...payload: T) => void;
1
+ type Subscriber<T extends any[]> = (...payload: T) => void;
2
2
  export declare class Emitter<T extends any[] = []> {
3
3
  subscribers: Subscriber<T>[];
4
4
  value: T | undefined;
@@ -13,7 +13,6 @@ export declare class Emitter<T extends any[] = []> {
13
13
  * @returns unsubscribe function
14
14
  */
15
15
  on(...handlers: Subscriber<T>[] | Subscriber<T>[][]): () => void;
16
- once(...handlers: Subscriber<T>[] | Subscriber<T>[][]): () => void;
17
16
  off(...handlers: Subscriber<T>[] | Subscriber<T>[][]): void;
18
17
  trigger(...payload: T): any[];
19
18
  destroy(): void;
package/types/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare type CANVAS_ERROR_NAMES = "CANVAS_ERROR" | "CANVAS_POSSIBLY_TOO_BIG";
1
+ type CANVAS_ERROR_NAMES = "CANVAS_ERROR" | "CANVAS_POSSIBLY_TOO_BIG";
2
2
  export declare class CanvasError extends Error {
3
3
  constructor(message?: string, name?: CANVAS_ERROR_NAMES);
4
4
  }
@@ -0,0 +1,46 @@
1
+ import { ExcalidrawElement, ExcalidrawFrameElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
2
+ import { AppClassProperties, AppState, StaticCanvasAppState } from "./types";
3
+ import { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
4
+ export declare const bindElementsToFramesAfterDuplication: (nextElements: ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
5
+ export declare function isElementIntersectingFrame(element: ExcalidrawElement, frame: ExcalidrawFrameElement): boolean;
6
+ export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
7
+ export declare const isElementContainingFrame: (elements: readonly ExcalidrawElement[], element: ExcalidrawElement, frame: ExcalidrawFrameElement) => boolean;
8
+ export declare const getElementsIntersectingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
9
+ export declare const elementsAreInFrameBounds: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => boolean;
10
+ export declare const elementOverlapsWithFrame: (element: ExcalidrawElement, frame: ExcalidrawFrameElement) => boolean;
11
+ export declare const isCursorInFrame: (cursorCoords: {
12
+ x: number;
13
+ y: number;
14
+ }, frame: NonDeleted<ExcalidrawFrameElement>) => boolean;
15
+ export declare const groupsAreAtLeastIntersectingTheFrame: (elements: readonly NonDeletedExcalidrawElement[], groupIds: readonly string[], frame: ExcalidrawFrameElement) => boolean;
16
+ export declare const groupsAreCompletelyOutOfFrame: (elements: readonly NonDeletedExcalidrawElement[], groupIds: readonly string[], frame: ExcalidrawFrameElement) => boolean;
17
+ /**
18
+ * Returns a map of frameId to frame elements. Includes empty frames.
19
+ */
20
+ export declare const groupByFrames: (elements: readonly ExcalidrawElement[]) => Map<string, ExcalidrawElement[]>;
21
+ export declare const getFrameElements: (allElements: ExcalidrawElementsIncludingDeleted, frameId: string) => ExcalidrawElement[];
22
+ export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
23
+ export declare const getElementsInNewFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement) => ExcalidrawElement[];
24
+ export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap?: Map<string, ExcalidrawElement>) => ExcalidrawFrameElement | null;
25
+ /**
26
+ * Retains (or repairs for target frame) the ordering invriant where children
27
+ * elements come right before the parent frame:
28
+ * [el, el, child, child, frame, el]
29
+ */
30
+ export declare const addElementsToFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToAdd: NonDeletedExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
31
+ export declare const removeElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToRemove: NonDeletedExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
32
+ export declare const removeAllElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
33
+ export declare const replaceAllElementsInFrame: (allElements: ExcalidrawElementsIncludingDeleted, nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
34
+ /** does not mutate elements, but returns new ones */
35
+ export declare const updateFrameMembershipOfSelectedElements: (allElements: ExcalidrawElementsIncludingDeleted, appState: AppState, app: AppClassProperties) => ExcalidrawElementsIncludingDeleted;
36
+ /**
37
+ * filters out elements that are inside groups that contain a frame element
38
+ * anywhere in the group tree
39
+ */
40
+ export declare const omitGroupsContainingFrames: (allElements: ExcalidrawElementsIncludingDeleted, selectedElements?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
41
+ /**
42
+ * depending on the appState, return target frame, which is the frame the given element
43
+ * is going to be added to or remove from
44
+ */
45
+ export declare const getTargetFrame: (element: ExcalidrawElement, appState: StaticCanvasAppState) => ExcalidrawFrameElement | null;
46
+ export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ExcalidrawElementsIncludingDeleted, appState: StaticCanvasAppState) => boolean;
package/types/ga.d.ts CHANGED
@@ -16,15 +16,15 @@
16
16
  * See GAPoint, GALine, GADirection and GATransform modules for common
17
17
  * operations.
18
18
  */
19
- export declare type Point = NVector;
20
- export declare type Direction = NVector;
21
- export declare type Line = NVector;
22
- export declare type Transform = NVector;
19
+ export type Point = NVector;
20
+ export type Direction = NVector;
21
+ export type Line = NVector;
22
+ export type Transform = NVector;
23
23
  export declare const point: (x: number, y: number) => NVector;
24
24
  export declare const origin: () => NVector;
25
25
  export declare const direction: (x: number, y: number) => NVector;
26
26
  export declare const offset: (x: number, y: number) => NVector;
27
- declare type NVector = readonly [
27
+ type NVector = readonly [
28
28
  number,
29
29
  number,
30
30
  number,