@myoc/element 0.19.521 → 0.19.522

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 (153) hide show
  1. package/dist/dev/index.js +3049 -1222
  2. package/dist/dev/index.js.map +4 -4
  3. package/dist/prod/index.js +17 -17
  4. package/dist/types/common/src/colors.d.ts +14 -0
  5. package/dist/types/common/src/constants.d.ts +3 -0
  6. package/dist/types/common/src/keys.d.ts +2 -0
  7. package/dist/types/common/src/points.d.ts +1 -1
  8. package/dist/types/common/src/utils.d.ts +1 -1
  9. package/dist/types/element/src/Scene.d.ts +1 -1
  10. package/dist/types/element/src/align.d.ts +2 -2
  11. package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
  12. package/dist/types/element/src/arrows/focus.d.ts +5 -2
  13. package/dist/types/element/src/binding.d.ts +17 -8
  14. package/dist/types/element/src/bounds.d.ts +5 -9
  15. package/dist/types/element/src/bucketFill.d.ts +110 -0
  16. package/dist/types/element/src/collision.d.ts +1 -1
  17. package/dist/types/element/src/comparisons.d.ts +4 -4
  18. package/dist/types/element/src/convertToShape.d.ts +23 -0
  19. package/dist/types/element/src/distribute.d.ts +2 -2
  20. package/dist/types/element/src/dragElements.d.ts +27 -0
  21. package/dist/types/element/src/duplicate.d.ts +3 -3
  22. package/dist/types/element/src/embeddable.d.ts +2 -2
  23. package/dist/types/element/src/flowchart.d.ts +7 -7
  24. package/dist/types/element/src/fractionalIndex.d.ts +2 -2
  25. package/dist/types/element/src/frame.d.ts +4 -4
  26. package/dist/types/element/src/groups.d.ts +9 -9
  27. package/dist/types/element/src/index.d.ts +4 -1
  28. package/dist/types/element/src/linearElementEditor.d.ts +17 -10
  29. package/dist/types/element/src/newElement.d.ts +13 -0
  30. package/dist/types/element/src/renderElement.d.ts +0 -3
  31. package/dist/types/element/src/resizeElements.d.ts +2 -2
  32. package/dist/types/element/src/selection.d.ts +5 -5
  33. package/dist/types/element/src/shape.d.ts +12 -0
  34. package/dist/types/element/src/sortElements.d.ts +10 -0
  35. package/dist/types/element/src/textElement.d.ts +12 -9
  36. package/dist/types/element/src/transform.d.ts +2 -2
  37. package/dist/types/element/src/typeChecks.d.ts +25 -25
  38. package/dist/types/element/src/types.d.ts +2 -1
  39. package/dist/types/element/src/zindex.d.ts +2 -2
  40. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  41. package/dist/types/excalidraw/actions/actionBoundText.d.ts +24 -8
  42. package/dist/types/excalidraw/actions/actionCanvas.d.ts +128 -961
  43. package/dist/types/excalidraw/actions/actionClipboard.d.ts +24 -8
  44. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +12 -4
  45. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +38 -13
  46. package/dist/types/excalidraw/actions/actionDeselect.d.ts +9 -4
  47. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
  48. package/dist/types/excalidraw/actions/actionElementLink.d.ts +12 -4
  49. package/dist/types/excalidraw/actions/actionElementLock.d.ts +25 -9
  50. package/dist/types/excalidraw/actions/actionExport.d.ts +26 -10
  51. package/dist/types/excalidraw/actions/actionFrame.d.ts +47 -205
  52. package/dist/types/excalidraw/actions/actionGroup.d.ts +39 -23
  53. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +15 -6
  54. package/dist/types/excalidraw/actions/actionLink.d.ts +13 -5
  55. package/dist/types/excalidraw/actions/actionMenu.d.ts +12 -4
  56. package/dist/types/excalidraw/actions/actionProperties.d.ts +43 -24
  57. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +17 -9
  58. package/dist/types/excalidraw/actions/actionStyles.d.ts +12 -4
  59. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +1 -1
  60. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +14 -6
  61. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +16 -9
  62. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +13 -5
  63. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +13 -5
  64. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +16 -9
  65. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +13 -5
  66. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +14 -6
  67. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +13 -5
  68. package/dist/types/excalidraw/actions/index.d.ts +1 -2
  69. package/dist/types/excalidraw/actions/manager.d.ts +1 -0
  70. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  71. package/dist/types/excalidraw/actions/types.d.ts +8 -4
  72. package/dist/types/excalidraw/appState.d.ts +10 -5
  73. package/dist/types/excalidraw/components/Actions.d.ts +17 -12
  74. package/dist/types/excalidraw/components/App.arrowText.d.ts +72 -0
  75. package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
  76. package/dist/types/excalidraw/components/App.cursor.d.ts +30 -0
  77. package/dist/types/excalidraw/components/App.d.ts +384 -60
  78. package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
  79. package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
  80. package/dist/types/excalidraw/components/App.viewport.d.ts +73 -0
  81. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -3
  82. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
  83. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +3 -1
  84. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -2
  85. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
  86. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
  87. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -1
  88. package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +31 -0
  89. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +1 -1
  90. package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
  91. package/dist/types/excalidraw/components/{ToolButton.d.ts → IconButton.d.ts} +16 -19
  92. package/dist/types/excalidraw/components/Island.d.ts +7 -0
  93. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
  94. package/dist/types/excalidraw/components/LayerUI.d.ts +5 -2
  95. package/dist/types/excalidraw/components/LockButton.d.ts +9 -0
  96. package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
  97. package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
  98. package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
  99. package/dist/types/excalidraw/components/Popover.d.ts +1 -3
  100. package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
  101. package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
  102. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
  103. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
  104. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
  105. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
  106. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
  107. package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
  108. package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
  109. package/dist/types/excalidraw/components/ToolPopover.d.ts +3 -6
  110. package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
  111. package/dist/types/excalidraw/components/Tools.d.ts +146 -0
  112. package/dist/types/excalidraw/components/UserList.d.ts +3 -2
  113. package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
  114. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -0
  115. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  116. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -2
  117. package/dist/types/excalidraw/components/icons.d.ts +4 -1
  118. package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
  119. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
  120. package/dist/types/excalidraw/context/tunnels.d.ts +0 -1
  121. package/dist/types/excalidraw/data/blob.d.ts +14 -6
  122. package/dist/types/excalidraw/data/index.d.ts +4 -4
  123. package/dist/types/excalidraw/data/json.d.ts +20 -12
  124. package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
  125. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  126. package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
  127. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +10 -3
  128. package/dist/types/excalidraw/scene/Renderer.d.ts +11 -11
  129. package/dist/types/excalidraw/scene/export.d.ts +3 -3
  130. package/dist/types/excalidraw/scene/index.d.ts +1 -1
  131. package/dist/types/excalidraw/scene/types.d.ts +4 -3
  132. package/dist/types/excalidraw/snapping.d.ts +7 -7
  133. package/dist/types/excalidraw/types.d.ts +423 -27
  134. package/dist/types/excalidraw/viewport.d.ts +283 -0
  135. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +2 -3
  136. package/dist/types/laser-pointer/src/state.d.ts +1 -0
  137. package/dist/types/math/src/index.d.ts +1 -0
  138. package/dist/types/math/src/pca.d.ts +79 -0
  139. package/dist/types/math/src/polygon.d.ts +25 -1
  140. package/dist/types/utils/src/export.d.ts +3 -3
  141. package/package.json +4 -4
  142. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -180
  143. package/dist/types/excalidraw/actions/actionSmartZoom.d.ts +0 -16
  144. package/dist/types/excalidraw/components/DefaultSidebar.d.ts +0 -27
  145. package/dist/types/excalidraw/components/ElementCanvasButtons.d.ts +0 -7
  146. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
  147. package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
  148. package/dist/types/excalidraw/components/MagicButton.d.ts +0 -10
  149. package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -12
  150. package/dist/types/excalidraw/cursor.d.ts +0 -5
  151. package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
  152. package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
  153. package/dist/types/excalidraw/scroll.d.ts +0 -46
@@ -0,0 +1,283 @@
1
+ import type { SceneBounds } from "@excalidraw/element";
2
+ import type { Bounds } from "@excalidraw/common";
3
+ import type { ExcalidrawElement } from "@excalidraw/element/types";
4
+ import type { AppState, NormalizedZoomValue, Offsets, PointerCoords, ScrollConstraints, ViewportOffsets, Zoom } from "./types";
5
+ /** default rubberband overscroll give for scroll locks, in viewport px */
6
+ export declare const DEFAULT_OVERSCROLL = 150;
7
+ type ZoomOptions = {
8
+ viewportX: number;
9
+ viewportY: number;
10
+ nextZoom: NormalizedZoomValue;
11
+ };
12
+ export type AnimationOptions = {
13
+ duration?: number;
14
+ };
15
+ export type SetViewportRect = {
16
+ x: number;
17
+ y: number;
18
+ width?: number;
19
+ height?: number;
20
+ };
21
+ export type SetViewportOptions = {
22
+ /**
23
+ * what to show in the viewport: an explicit scene-coordinate box/rect,
24
+ * element(s), or an element id / element-link URL.
25
+ *
26
+ * IMPORTANT: if supplying ExcalidrawElement(s), only non-deleted elements
27
+ * that actually exist on the canvas are considered. If you want to navigate
28
+ * to elements that's not on canvas yet, supply their bounds by using
29
+ * `getCommonBounds` (see {@link getCommonBounds}).
30
+ */
31
+ target: Bounds | SetViewportRect | ExcalidrawElement | readonly ExcalidrawElement[] | string;
32
+ /**
33
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/object-fit
34
+ *
35
+ * - `scale-down` - zoom out so the target fits the viewport, never zooming past 100%
36
+ * - `contain` - zoom the target so it fills the viewport (may exceed 100%)
37
+ * - `none` - keep the current zoom, only center the target in the viewport
38
+ */
39
+ fit?: "scale-down" | "contain" | "none";
40
+ lock?: {
41
+ /** constraints panning to the target box */
42
+ scroll?: ScrollConstraints["lockScroll"];
43
+ /** makes the resolved zoom the minimum zoom */
44
+ zoom?: ScrollConstraints["lockZoom"];
45
+ /**
46
+ * Rubberband give past the lock, in viewport px (zoom-independent): how
47
+ * far the user can pan beyond the constraint before snapping back.
48
+ * `true` (default) uses {@link DEFAULT_OVERSCROLL}, `false` disables
49
+ * (rigid lock), a number sets the give explicitly.
50
+ */
51
+ overscroll?: boolean | number;
52
+ };
53
+ animation?: AnimationOptions | boolean;
54
+ /**
55
+ * CSS-style per-side viewport insets, in viewport pixels
56
+ * (zoom-independent) — static values, editor-UI-derived (`ui`), or a
57
+ * combination. See {@link ViewportOffsets}.
58
+ */
59
+ offsets?: ViewportOffsets;
60
+ };
61
+ type Viewport = Pick<AppState, "scrollX" | "scrollY" | "zoom">;
62
+ /**
63
+ * Clamps a proposed scroll/zoom against the active lock (`scrollConstraints`).
64
+ * Returns the input scroll/zoom unchanged when there is no lock.
65
+ * `overscroll` (screen px, zoom-independent) is rubberband give past the
66
+ * resting clamp — pass 0 for a hard clamp.
67
+ */
68
+ export declare const constrainScrollState: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">, overscroll?: number) => Viewport;
69
+ /**
70
+ * Resolves a focal-point zoom against the active scroll constraints while
71
+ * preserving the current rubberband displacement in screen pixels. This lets
72
+ * zoom and scroll-constraint snap-back compose without either visually
73
+ * cancelling the other.
74
+ */
75
+ export declare const getViewportForZoomWithScrollConstraints: (opts: ZoomOptions, state: AppState) => Viewport;
76
+ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, minZoom, maxZoom, steppedZoom, }: {
77
+ bounds: SceneBounds;
78
+ canvasOffsets?: Offsets;
79
+ appState: Readonly<AppState>;
80
+ fit?: SetViewportOptions["fit"];
81
+ minZoom?: number;
82
+ maxZoom?: number;
83
+ steppedZoom?: boolean;
84
+ }) => {
85
+ appState: {
86
+ scrollX: number;
87
+ scrollY: number;
88
+ zoom: {
89
+ value: NormalizedZoomValue;
90
+ };
91
+ contextMenu: {
92
+ items: import("./components/ContextMenu").ContextMenuItems;
93
+ top: number;
94
+ left: number;
95
+ } | null;
96
+ showWelcomeScreen: boolean;
97
+ isLoading: boolean;
98
+ myocSimplifiedMode: boolean;
99
+ dontResizeLimitMBs: number;
100
+ hideMainMenus: boolean;
101
+ wheelZoomsOnDefault?: boolean;
102
+ arrangeConfiguration: {
103
+ algorithm: import("@excalidraw/element/types").ArrangeAlgorithms;
104
+ gap: number;
105
+ };
106
+ normaliseConfiguration: {
107
+ mode: import("./types").NormaliseMode;
108
+ metric: import("./types").NormaliseMetric;
109
+ };
110
+ errorMessage: React.ReactNode;
111
+ activeEmbeddable: {
112
+ element: import("@excalidraw/element/types").NonDeletedExcalidrawElement;
113
+ state: "hover" | "active";
114
+ } | null;
115
+ newElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
116
+ resizingElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
117
+ multiElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
118
+ selectionElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
119
+ isBindingEnabled: boolean;
120
+ boxSelectionMode: import("./types").BoxSelectionMode;
121
+ bindingPreference: "enabled" | "disabled";
122
+ isMidpointSnappingEnabled: boolean;
123
+ suggestedBinding: {
124
+ element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
125
+ midPoint?: import("@excalidraw/math").GlobalPoint;
126
+ } | null;
127
+ hoveredArrowTextAnchor: {
128
+ elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
129
+ anchor: "start" | "end" | "label";
130
+ } | null;
131
+ frameToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
132
+ frameRendering: {
133
+ enabled: boolean;
134
+ name: boolean;
135
+ outline: boolean;
136
+ clip: boolean;
137
+ };
138
+ editingFrame: import("@excalidraw/element/types").ExcalidrawFrameLikeElement["id"] | null;
139
+ elementsToHighlight: readonly import("@excalidraw/element/types").NonDeletedExcalidrawElement[] | null;
140
+ editingTextElement: import("@excalidraw/element/types").ExcalidrawTextElement | null;
141
+ activeTool: {
142
+ lastActiveTool: import("./types").ActiveTool | null;
143
+ locked: boolean;
144
+ fromSelection: boolean;
145
+ } & import("./types").ActiveTool;
146
+ preferredSelectionTool: {
147
+ type: "selection" | "lasso";
148
+ initialized: boolean;
149
+ };
150
+ penMode: boolean;
151
+ penDetected: boolean;
152
+ exportBackground: boolean;
153
+ exportEmbedScene: boolean;
154
+ exportWithDarkMode: boolean;
155
+ exportScale: number;
156
+ currentItemStrokeColor: string;
157
+ currentItemBackgroundColor: string;
158
+ currentItemFillStyle: ExcalidrawElement["fillStyle"];
159
+ currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
160
+ currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
161
+ currentItemRoughness: number;
162
+ currentItemStrokeVariability: import("@excalidraw/element/types").StrokeVariability;
163
+ currentItemOpacity: number;
164
+ currentItemFontFamily: import("@excalidraw/element/types").FontFamilyValues;
165
+ currentItemFontSize: number;
166
+ currentItemTextAlign: import("@excalidraw/element/types").TextAlign;
167
+ currentItemStartArrowhead: import("@excalidraw/element/types").Arrowhead | null;
168
+ currentItemEndArrowhead: import("@excalidraw/element/types").Arrowhead | null;
169
+ currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
170
+ currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
171
+ currentItemArrowType: "sharp" | "round" | "elbow";
172
+ viewBackgroundColor: string;
173
+ scrollConstraints: ScrollConstraints | null;
174
+ cursorButton: "up" | "down";
175
+ scrolledOutside: boolean;
176
+ name: string | null;
177
+ isResizing: boolean;
178
+ isRotating: boolean;
179
+ openMenu: "canvas" | null;
180
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
181
+ openSidebar: {
182
+ name: import("./types").SidebarName;
183
+ tab?: import("./types").SidebarTabName;
184
+ } | null;
185
+ openDialog: null | {
186
+ name: "imageExport" | "help" | "jsonExport";
187
+ } | {
188
+ name: "settings";
189
+ } | {
190
+ name: "elementLinkSelector";
191
+ sourceElementId: ExcalidrawElement["id"];
192
+ } | {
193
+ name: "charts";
194
+ data: import("./charts").Spreadsheet;
195
+ rawText: string;
196
+ };
197
+ defaultSidebarDockedPreference: boolean;
198
+ lastPointerDownWith: import("@excalidraw/element/types").PointerType;
199
+ selectedElementIds: Readonly<{
200
+ [id: string]: true;
201
+ }>;
202
+ hoveredElementIds: Readonly<{
203
+ [id: string]: true;
204
+ }>;
205
+ previousSelectedElementIds: {
206
+ [id: string]: true;
207
+ };
208
+ selectedElementsAreBeingDragged: boolean;
209
+ shouldCacheIgnoreZoom: boolean;
210
+ toast: {
211
+ message: React.ReactNode;
212
+ closable?: boolean;
213
+ duration?: number;
214
+ } | null;
215
+ zenModeEnabled: boolean;
216
+ theme: import("@excalidraw/element/types").Theme;
217
+ gridSize: number;
218
+ gridStep: number;
219
+ gridModeEnabled: boolean;
220
+ viewModeEnabled: boolean;
221
+ viewModeOnly: boolean;
222
+ selectedGroupIds: {
223
+ [groupId: string]: boolean;
224
+ };
225
+ editingGroupId: import("@excalidraw/element/types").GroupId | null;
226
+ width: number;
227
+ height: number;
228
+ offsetTop: number;
229
+ offsetLeft: number;
230
+ fileHandle: FileSystemFileHandle | null;
231
+ collaborators: Map<import("./types").SocketId, import("./types").Collaborator>;
232
+ stats: {
233
+ open: boolean;
234
+ panels: number;
235
+ };
236
+ showHyperlinkPopup: false | "info" | "editor";
237
+ selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
238
+ snapLines: readonly import("./snapping").SnapLine[];
239
+ originSnapOffset: {
240
+ x: number;
241
+ y: number;
242
+ } | null;
243
+ objectsSnapModeEnabled: boolean;
244
+ isCropping: boolean;
245
+ croppingElementId: ExcalidrawElement["id"] | null;
246
+ searchMatches: Readonly<{
247
+ focusedId: ExcalidrawElement["id"] | null;
248
+ matches: readonly import("./types").SearchMatch[];
249
+ }> | null;
250
+ activeLockedId: string | null;
251
+ lockedMultiSelections: {
252
+ [groupId: string]: true;
253
+ };
254
+ bindMode: import("@excalidraw/element/types").BindMode;
255
+ colorTopPicks: {
256
+ elementStroke: readonly string[] | null;
257
+ elementBackground: readonly string[] | null;
258
+ bucketFill: readonly string[] | null;
259
+ };
260
+ };
261
+ captureUpdate: "EVENTUALLY";
262
+ };
263
+ export declare const getClosestElementBounds: (elements: readonly ExcalidrawElement[], from: {
264
+ x: number;
265
+ y: number;
266
+ }) => Bounds;
267
+ export declare const centerScrollOn: ({ scenePoint, viewportDimensions, zoom, offsets, }: {
268
+ scenePoint: PointerCoords;
269
+ viewportDimensions: {
270
+ height: number;
271
+ width: number;
272
+ };
273
+ zoom: Zoom;
274
+ offsets?: Offsets;
275
+ }) => {
276
+ scrollX: number;
277
+ scrollY: number;
278
+ };
279
+ export declare const getScrollToContentState: (elements: readonly ExcalidrawElement[], appState: AppState) => {
280
+ scrollX: number;
281
+ scrollY: number;
282
+ };
283
+ export {};
@@ -1,8 +1,7 @@
1
- import type { ExcalidrawElement, ExcalidrawTextElement } from "@excalidraw/element/types";
1
+ import type { ExcalidrawTextElement } from "@excalidraw/element/types";
2
2
  import type App from "../components/App";
3
3
  type SubmitHandler = () => void;
4
- export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, initialCaretSceneCoords, }: {
5
- id: ExcalidrawElement["id"];
4
+ export declare const textWysiwyg: ({ onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, initialCaretSceneCoords, }: {
6
5
  /**
7
6
  * textWysiwyg only deals with `originalText`
8
7
  *
@@ -6,6 +6,7 @@ export type SizeMappingDetails = {
6
6
  totalLength: number;
7
7
  };
8
8
  export type LaserPointerOptions = {
9
+ /** @default 2 */
9
10
  size: number;
10
11
  streamline: number;
11
12
  simplify: number;
@@ -2,6 +2,7 @@ export * from "./angle";
2
2
  export * from "./curve";
3
3
  export * from "./ellipse";
4
4
  export * from "./line";
5
+ export * from "./pca";
5
6
  export * from "./point";
6
7
  export * from "./polygon";
7
8
  export * from "./range";
@@ -0,0 +1,79 @@
1
+ import type { GlobalPoint, LocalPoint, Vector } from "./types";
2
+ /**
3
+ * The principal axes of a point set, i.e. the eigen decomposition of its
4
+ * 2x2 covariance matrix.
5
+ *
6
+ * The axes are orthonormal and ordered by variance, so `major` is the
7
+ * direction along which the points spread the most. Together with `centroid`
8
+ * they define a canonical frame: expressing the points in it removes
9
+ * translation and rotation, and dividing by `sqrt(majorVariance)` removes
10
+ * scale.
11
+ */
12
+ export type PrincipalAxes<Point extends GlobalPoint | LocalPoint> = {
13
+ centroid: Point;
14
+ /** Unit vector along the direction of largest variance. */
15
+ major: Vector;
16
+ /** Unit vector along the direction of smallest variance, normal to major. */
17
+ minor: Vector;
18
+ /** Variance along `major` (the larger eigenvalue, λ₁). */
19
+ majorVariance: number;
20
+ /** Variance along `minor` (the smaller eigenvalue, λ₂). */
21
+ minorVariance: number;
22
+ };
23
+ /**
24
+ * A point expressed in a principal axes frame: `u` along the major axis,
25
+ * `v` along the minor axis, both relative to the centroid.
26
+ */
27
+ export type PrincipalCoords = [u: number, v: number];
28
+ /**
29
+ * Compute the centroid of a point set.
30
+ */
31
+ export declare function centroid<Point extends GlobalPoint | LocalPoint>(points: readonly Point[]): Point;
32
+ /**
33
+ * Principal component analysis of a 2D point set.
34
+ *
35
+ * Computes the centroid and the eigen decomposition of the covariance matrix
36
+ * [[μ20, μ11], [μ11, μ02]].
37
+ *
38
+ * @param points At least two points; fewer leaves the axes degenerate.
39
+ * @returns The centroid, the orthonormal axes and their variances.
40
+ */
41
+ export declare function principalAxes<Point extends GlobalPoint | LocalPoint>(points: readonly Point[]): PrincipalAxes<Point>;
42
+ /**
43
+ * Express points in the frame of the given principal axes, making the point
44
+ * cloud rotation, scale and translation invariant.
45
+ */
46
+ export declare function principalCoords<Point extends GlobalPoint | LocalPoint>(points: readonly Point[], axes: PrincipalAxes<Point>, scale?: number): PrincipalCoords[];
47
+ /**
48
+ * Flip the major axis so that it points toward the denser end of the point
49
+ * cloud, resolving the 180° sign ambiguity of the eigenvector.
50
+ *
51
+ * @returns The axes with `major`/`minor` flipped if needed. Variances are
52
+ * unchanged, as they are invariant to axis sign.
53
+ */
54
+ export declare function orientPrincipalAxes<Point extends GlobalPoint | LocalPoint>(points: readonly Point[], axes: PrincipalAxes<Point>): PrincipalAxes<Point>;
55
+ /**
56
+ * Ratio of the minor to the major variance in [0, 1]
57
+ *
58
+ * @returns 0 is a perfectly straight stroke, 1 is a stroke with no preferred
59
+ * direction.
60
+ */
61
+ export declare function elongation<Point extends GlobalPoint | LocalPoint>(axes: PrincipalAxes<Point>): number;
62
+ /**
63
+ * The `order`-th standardized moment of a sample in a rotation and scale
64
+ * invariant way (sandardizing by sigma).
65
+ *
66
+ * @returns 0 for a degenerate (zero variance) sample.
67
+ */
68
+ export declare function standardizedMoment(values: readonly number[], order: number): number;
69
+ /**
70
+ * Third standardized moment: how lopsided a sample is.
71
+ *
72
+ */
73
+ export declare function skewness(values: readonly number[]): number;
74
+ /**
75
+ * Fourth standardized moment: how the mass is split between the tails and the
76
+ * middle of a sample. Not excess kurtosis, a normal sample gives 3.
77
+ *
78
+ */
79
+ export declare function kurtosis(values: readonly number[]): number;
@@ -3,4 +3,28 @@ export declare function polygon<Point extends GlobalPoint | LocalPoint>(...point
3
3
  export declare function polygonFromPoints<Point extends GlobalPoint | LocalPoint>(points: Point[]): Polygon<Point>;
4
4
  export declare const polygonIncludesPoint: <Point extends LocalPoint | GlobalPoint>(point: Point, polygon: Polygon<Point>) => boolean;
5
5
  export declare const polygonIncludesPointNonZero: <Point extends [number, number]>(point: Point, polygon: Point[]) => boolean;
6
- export declare const pointOnPolygon: <Point extends LocalPoint | GlobalPoint>(p: Point, poly: Polygon<Point>, threshold?: number) => boolean;
6
+ export declare function polygonIsClosed<Point extends LocalPoint | GlobalPoint>(polygon: readonly Point[], tolerance?: number): boolean;
7
+ /**
8
+ * The signed area of a polygon via the shoelace formula. Positive when the
9
+ * vertices wind counter-clockwise in a y-down coordinate system.
10
+ *
11
+ * The polygon may be given open or closed; a closing vertex
12
+ */
13
+ export declare function polygonSignedArea<Point extends LocalPoint | GlobalPoint>(polygon: readonly Point[], tolerance?: number): number;
14
+ export declare function polygonArea<Point extends LocalPoint | GlobalPoint>(polygon: readonly Point[], tolerance?: number): number;
15
+ /**
16
+ * The convex hull of a point set via Andrew's monotone chain.
17
+ *
18
+ * @returns The hull vertices in counter-clockwise order (y-down), without a
19
+ * repeated closing vertex.
20
+ */
21
+ export declare function convexHull<Point extends LocalPoint | GlobalPoint>(points: readonly Point[]): Point[];
22
+ /**
23
+ * Drop the points of a convex polygon that only contribute a shallow turn,
24
+ * merging each run of near-collinear points into one.
25
+ *
26
+ * @param polygon A convex polygon, as returned by `convexHull`.
27
+ * @param angleThreshold Minimum accumulated turn (radians) for a vertex to be
28
+ * kept.
29
+ */
30
+ export declare function simplifyConvexPolygon<Point extends LocalPoint | GlobalPoint>(polygon: readonly Point[], angleThreshold: number): Point[];
@@ -1,13 +1,13 @@
1
1
  import { MIME_TYPES } from "@excalidraw/common";
2
- import type { ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted } from "@excalidraw/element/types";
2
+ import type { ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
3
3
  import type { AppState, BinaryFiles } from "@excalidraw/excalidraw/types";
4
4
  export { MIME_TYPES };
5
5
  type ExportOpts = {
6
- elements: readonly NonDeleted<ExcalidrawElement>[];
6
+ elements: readonly NonDeletedExcalidrawElement[];
7
7
  appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
8
8
  files: BinaryFiles | null;
9
9
  maxWidthOrHeight?: number;
10
- exportingFrame?: ExcalidrawFrameLikeElement | null;
10
+ exportingFrame?: NonDeleted<ExcalidrawFrameLikeElement> | null;
11
11
  getDimensions?: (width: number, height: number) => {
12
12
  width: number;
13
13
  height: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myoc/element",
3
- "version": "0.19.521",
3
+ "version": "0.19.522",
4
4
  "type": "module",
5
5
  "types": "./dist/types/element/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -64,9 +64,9 @@
64
64
  "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
65
65
  },
66
66
  "dependencies": {
67
- "@excalidraw/common": "npm:@myoc/common@0.19.521",
68
- "@excalidraw/fractional-indexing": "npm:@myoc/fractional-indexing@0.19.521",
69
- "@excalidraw/math": "npm:@myoc/math@0.19.521",
67
+ "@excalidraw/common": "npm:@myoc/common@0.19.522",
68
+ "@excalidraw/fractional-indexing": "npm:@myoc/fractional-indexing@0.19.522",
69
+ "@excalidraw/math": "npm:@myoc/math@0.19.522",
70
70
  "thumbhash": "0.1.1"
71
71
  }
72
72
  }
@@ -1,180 +0,0 @@
1
- export declare const actionSetEmbeddableAsActiveTool: {
2
- name: "setEmbeddableAsActiveTool";
3
- trackEvent: {
4
- category: "toolbar";
5
- };
6
- target: string;
7
- label: string;
8
- perform: (elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[], appState: Readonly<import("../types").AppState>, _: unknown, app: import("../types").AppClassProperties) => {
9
- elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[];
10
- appState: {
11
- activeTool: {
12
- lastActiveTool: import("../types").ActiveTool | null;
13
- locked: boolean;
14
- fromSelection: boolean;
15
- } & import("../types").ActiveTool;
16
- contextMenu: {
17
- items: import("../components/ContextMenu").ContextMenuItems;
18
- top: number;
19
- left: number;
20
- } | null;
21
- showWelcomeScreen: boolean;
22
- isLoading: boolean;
23
- myocSimplifiedMode: boolean;
24
- dontResizeLimitMBs: number;
25
- hideMainMenus: boolean;
26
- wheelZoomsOnDefault?: boolean;
27
- arrangeConfiguration: {
28
- algorithm: import("@excalidraw/element/types").ArrangeAlgorithms;
29
- gap: number;
30
- };
31
- normaliseConfiguration: {
32
- mode: import("../types").NormaliseMode;
33
- metric: import("../types").NormaliseMetric;
34
- };
35
- errorMessage: React.ReactNode;
36
- activeEmbeddable: {
37
- element: import("@excalidraw/element/types").NonDeletedExcalidrawElement;
38
- state: "hover" | "active";
39
- } | null;
40
- newElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
41
- resizingElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
42
- multiElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
43
- selectionElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
44
- isBindingEnabled: boolean;
45
- boxSelectionMode: import("../types").BoxSelectionMode;
46
- bindingPreference: "enabled" | "disabled";
47
- isMidpointSnappingEnabled: boolean;
48
- suggestedBinding: {
49
- element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
50
- midPoint?: import("@excalidraw/math").GlobalPoint;
51
- } | null;
52
- frameToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
53
- frameRendering: {
54
- enabled: boolean;
55
- name: boolean;
56
- outline: boolean;
57
- clip: boolean;
58
- };
59
- editingFrame: string | null;
60
- elementsToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawElement>[] | null;
61
- editingTextElement: import("@excalidraw/element/types").ExcalidrawTextElement | null;
62
- preferredSelectionTool: {
63
- type: "selection" | "lasso";
64
- initialized: boolean;
65
- };
66
- penMode: boolean;
67
- penDetected: boolean;
68
- exportBackground: boolean;
69
- exportEmbedScene: boolean;
70
- exportWithDarkMode: boolean;
71
- exportScale: number;
72
- currentItemStrokeColor: string;
73
- currentItemBackgroundColor: string;
74
- currentItemFillStyle: import("@excalidraw/element/types").ExcalidrawElement["fillStyle"];
75
- currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
76
- currentItemStrokeStyle: import("@excalidraw/element/types").ExcalidrawElement["strokeStyle"];
77
- currentItemRoughness: number;
78
- currentItemStrokeVariability: import("@excalidraw/element/types").StrokeVariability;
79
- currentItemOpacity: number;
80
- currentItemFontFamily: import("@excalidraw/element/types").FontFamilyValues;
81
- currentItemFontSize: number;
82
- currentItemTextAlign: import("@excalidraw/element/types").TextAlign;
83
- currentItemStartArrowhead: import("@excalidraw/element/types").Arrowhead | null;
84
- currentItemEndArrowhead: import("@excalidraw/element/types").Arrowhead | null;
85
- currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
86
- currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
87
- currentItemArrowType: "sharp" | "round" | "elbow";
88
- viewBackgroundColor: string;
89
- scrollX: number;
90
- scrollY: number;
91
- cursorButton: "up" | "down";
92
- scrolledOutside: boolean;
93
- name: string | null;
94
- isResizing: boolean;
95
- isRotating: boolean;
96
- zoom: import("../types").Zoom;
97
- openMenu: "canvas" | null;
98
- openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
99
- openSidebar: {
100
- name: import("../types").SidebarName;
101
- tab?: import("../types").SidebarTabName;
102
- } | null;
103
- openDialog: null | {
104
- name: "imageExport" | "help" | "jsonExport";
105
- } | {
106
- name: "settings";
107
- } | {
108
- name: "elementLinkSelector";
109
- sourceElementId: import("@excalidraw/element/types").ExcalidrawElement["id"];
110
- } | {
111
- name: "charts";
112
- data: import("../charts").Spreadsheet;
113
- rawText: string;
114
- };
115
- defaultSidebarDockedPreference: boolean;
116
- lastPointerDownWith: import("@excalidraw/element/types").PointerType;
117
- selectedElementIds: Readonly<{
118
- [id: string]: true;
119
- }>;
120
- hoveredElementIds: Readonly<{
121
- [id: string]: true;
122
- }>;
123
- previousSelectedElementIds: {
124
- [id: string]: true;
125
- };
126
- selectedElementsAreBeingDragged: boolean;
127
- shouldCacheIgnoreZoom: boolean;
128
- toast: {
129
- message: React.ReactNode;
130
- closable?: boolean;
131
- duration?: number;
132
- } | null;
133
- zenModeEnabled: boolean;
134
- theme: import("@excalidraw/element/types").Theme;
135
- gridSize: number;
136
- gridStep: number;
137
- gridModeEnabled: boolean;
138
- viewModeEnabled: boolean;
139
- viewModeOnly: boolean;
140
- selectedGroupIds: {
141
- [groupId: string]: boolean;
142
- };
143
- editingGroupId: import("@excalidraw/element/types").GroupId | null;
144
- width: number;
145
- height: number;
146
- offsetTop: number;
147
- offsetLeft: number;
148
- fileHandle: FileSystemFileHandle | null;
149
- collaborators: Map<import("../types").SocketId, import("../types").Collaborator>;
150
- stats: {
151
- open: boolean;
152
- panels: number;
153
- };
154
- showHyperlinkPopup: false | "info" | "editor";
155
- selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
156
- snapLines: readonly import("../snapping").SnapLine[];
157
- originSnapOffset: {
158
- x: number;
159
- y: number;
160
- } | null;
161
- objectsSnapModeEnabled: boolean;
162
- userToFollow: import("../types").UserToFollow | null;
163
- followedBy: Set<import("../types").SocketId>;
164
- isCropping: boolean;
165
- croppingElementId: import("@excalidraw/element/types").ExcalidrawElement["id"] | null;
166
- searchMatches: Readonly<{
167
- focusedId: import("@excalidraw/element/types").ExcalidrawElement["id"] | null;
168
- matches: readonly import("../types").SearchMatch[];
169
- }> | null;
170
- activeLockedId: string | null;
171
- lockedMultiSelections: {
172
- [groupId: string]: true;
173
- };
174
- bindMode: import("@excalidraw/element/types").BindMode;
175
- };
176
- captureUpdate: "EVENTUALLY";
177
- };
178
- } & {
179
- keyTest?: undefined;
180
- };
@@ -1,16 +0,0 @@
1
- export declare const actionSmartZoom: {
2
- name: "smartZoom";
3
- label: string;
4
- trackEvent: {
5
- category: "toolbar";
6
- };
7
- icon: import("react/jsx-runtime").JSX.Element;
8
- viewMode: true;
9
- perform: (elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[], appState: Readonly<import("../types").AppState>, _: unknown, app: import("../types").AppClassProperties) => {
10
- captureUpdate: "NEVER";
11
- };
12
- keyTest: (event: import("react").KeyboardEvent<Element> | KeyboardEvent) => boolean;
13
- PanelComponent: ({ data, updateData }: import("./types").PanelComponentProps) => import("react/jsx-runtime").JSX.Element;
14
- } & {
15
- keyTest?: ((event: import("react").KeyboardEvent<Element> | KeyboardEvent) => boolean) | undefined;
16
- };