@excalidraw/math 0.18.0-2b1c2a9 → 0.18.0-2c3dcc0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/index.js +8 -2
- package/dist/dev/index.js.map +2 -2
- package/dist/prod/index.js +1 -1
- package/dist/types/common/src/colors.d.ts +3 -0
- package/dist/types/common/src/constants.d.ts +56 -0
- package/dist/types/common/src/keys.d.ts +4 -0
- package/dist/types/common/src/random.d.ts +7 -0
- package/dist/types/common/src/utils.d.ts +12 -1
- package/dist/types/element/src/Scene.d.ts +1 -1
- package/dist/types/element/src/align.d.ts +4 -1
- package/dist/types/element/src/binding.d.ts +75 -7
- package/dist/types/element/src/bounds.d.ts +10 -2
- package/dist/types/element/src/collision.d.ts +21 -5
- package/dist/types/element/src/comparisons.d.ts +5 -3
- package/dist/types/element/src/cropElement.d.ts +36 -4
- package/dist/types/element/src/delta.d.ts +30 -2
- package/dist/types/element/src/distribute.d.ts +4 -1
- package/dist/types/element/src/dragElements.d.ts +8 -3
- package/dist/types/element/src/duplicate.d.ts +60 -0
- package/dist/types/element/src/elbowArrow.d.ts +5 -0
- package/dist/types/element/src/embeddable.d.ts +2 -1
- package/dist/types/element/src/flowchart.d.ts +6 -8
- package/dist/types/element/src/frame.d.ts +21 -3
- package/dist/types/element/src/groups.d.ts +1 -6
- package/dist/types/element/src/image.d.ts +5 -2
- package/dist/types/element/src/index.d.ts +3 -0
- package/dist/types/element/src/linearElementEditor.d.ts +4 -1
- package/dist/types/element/src/listMarker.d.ts +39 -0
- package/dist/types/element/src/mutateElement.d.ts +1 -1
- package/dist/types/element/src/newElement.d.ts +40 -3
- package/dist/types/element/src/renderElement.d.ts +31 -4
- package/dist/types/element/src/renderEnvironment.d.ts +66 -0
- package/dist/types/element/src/resizeElements.d.ts +15 -5
- package/dist/types/element/src/selection.d.ts +4 -10
- package/dist/types/element/src/shape.d.ts +17 -1
- package/dist/types/element/src/sizeHelpers.d.ts +6 -0
- package/dist/types/element/src/stickyNote.d.ts +191 -0
- package/dist/types/element/src/textElement.d.ts +10 -2
- package/dist/types/element/src/textMeasurements.d.ts +15 -11
- package/dist/types/element/src/textWrapping.d.ts +3 -2
- package/dist/types/element/src/transform.d.ts +30 -7
- package/dist/types/element/src/typeChecks.d.ts +3 -2
- package/dist/types/element/src/types.d.ts +28 -6
- package/dist/types/element/src/utils.d.ts +8 -1
- package/dist/types/element/src/zindex.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +48 -3
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +62 -208
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +121 -16
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +32 -2
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -546
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +32 -2
- package/dist/types/excalidraw/actions/actionExport.d.ts +39 -9
- package/dist/types/excalidraw/actions/actionFrame.d.ts +92 -479
- package/dist/types/excalidraw/actions/actionGroup.d.ts +34 -4
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +66 -2
- package/dist/types/excalidraw/actions/actionLink.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionProperties.d.ts +42 -8
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +17 -2
- package/dist/types/excalidraw/actions/actionStyles.d.ts +17 -2
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +452 -6
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +201 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +198 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +16 -1
- package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
- package/dist/types/excalidraw/actions/index.d.ts +3 -0
- package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +1 -1
- package/dist/types/excalidraw/appState.d.ts +26 -8
- package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
- package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
- package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
- package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
- package/dist/types/excalidraw/charts/index.d.ts +2 -1
- package/dist/types/excalidraw/components/Actions.d.ts +10 -2
- package/dist/types/excalidraw/components/App.arrowText.d.ts +5 -39
- package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
- package/dist/types/excalidraw/components/App.d.ts +129 -218
- package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
- package/dist/types/excalidraw/components/App.host.d.ts +102 -0
- package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
- package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
- package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
- package/dist/types/excalidraw/components/App.selectionTool.d.ts +94 -0
- package/dist/types/excalidraw/components/App.text.d.ts +194 -0
- package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
- package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +64 -4
- package/dist/types/excalidraw/components/App.wheel.d.ts +30 -0
- package/dist/types/excalidraw/components/App.wrap.d.ts +39 -0
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
- package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -1
- package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
- package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
- package/dist/types/excalidraw/components/IconButton.d.ts +2 -0
- package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
- package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
- package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
- package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
- package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
- package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
- package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
- package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
- package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
- package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
- package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
- package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
- package/dist/types/excalidraw/components/Tools.d.ts +7 -2
- package/dist/types/excalidraw/components/Tooltip.d.ts +26 -2
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
- package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -1
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +2 -0
- package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
- package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +13 -2
- package/dist/types/excalidraw/components/icons.d.ts +2 -0
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +3 -0
- package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +2 -2
- package/dist/types/excalidraw/data/blob.d.ts +46 -16
- package/dist/types/excalidraw/data/index.d.ts +3 -3
- package/dist/types/excalidraw/data/json.d.ts +23 -8
- package/dist/types/excalidraw/fonts/Fonts.d.ts +9 -6
- package/dist/types/excalidraw/history.d.ts +10 -4
- package/dist/types/excalidraw/mermaid.d.ts +7 -0
- package/dist/types/excalidraw/reactUtils.d.ts +1 -1
- package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
- package/dist/types/excalidraw/renderer/animation.d.ts +11 -4
- package/dist/types/excalidraw/renderer/helpers.d.ts +18 -0
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
- package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
- package/dist/types/excalidraw/scene/Renderer.d.ts +64 -3
- package/dist/types/excalidraw/scene/export.d.ts +343 -20
- package/dist/types/excalidraw/scene/index.d.ts +1 -1
- package/dist/types/excalidraw/scene/types.d.ts +26 -2
- package/dist/types/excalidraw/types.d.ts +191 -22
- package/dist/types/excalidraw/viewport.d.ts +29 -1
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +12 -1
- package/dist/types/utils/src/index.d.ts +3 -1
- package/dist/types/utils/src/shape.d.ts +2 -2
- package/package.json +2 -2
- package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +0 -31
- package/dist/types/utils/src/export.d.ts +0 -35
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface, StrokeWidthKey } from "@excalidraw/common";
|
|
2
2
|
import type { LinearElementEditor } from "@excalidraw/element";
|
|
3
|
-
import type { MaybeTransformHandleType } from "@excalidraw/element";
|
|
3
|
+
import type { ListMarkerAdvance, MaybeTransformHandleType } from "@excalidraw/element";
|
|
4
4
|
import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, ExcalidrawArrowElement, Arrowhead, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode, ExcalidrawTextElement, StrokeVariability } from "@excalidraw/element/types";
|
|
5
5
|
import type { Merge, MaybePromise, ValueOf, MakeBrand } from "@excalidraw/common/utility-types";
|
|
6
|
-
import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
|
|
6
|
+
import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement, RenderEnvironment, OnDuplicateData } from "@excalidraw/element";
|
|
7
7
|
import type { GlobalPoint } from "@excalidraw/math";
|
|
8
8
|
import type { Action } from "./actions/types";
|
|
9
9
|
import type { Spreadsheet } from "./charts";
|
|
@@ -85,7 +85,7 @@ export type BinaryFileData = {
|
|
|
85
85
|
};
|
|
86
86
|
export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
|
|
87
87
|
export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
|
|
88
|
-
export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser" | "autoshape" | "bucketfill";
|
|
88
|
+
export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "stickynote" | "embeddable" | "laser" | "autoshape" | "bucketfill";
|
|
89
89
|
export type ElementOrToolType = ExcalidrawElementType | ToolType | "custom";
|
|
90
90
|
export type ActiveTool = {
|
|
91
91
|
type: ToolType;
|
|
@@ -141,7 +141,7 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
141
141
|
isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
|
|
142
142
|
gridModeEnabled: AppState["gridModeEnabled"];
|
|
143
143
|
suggestedBinding: AppState["suggestedBinding"];
|
|
144
|
-
|
|
144
|
+
textToolHover: AppState["textToolHover"];
|
|
145
145
|
isRotating: AppState["isRotating"];
|
|
146
146
|
elementsToHighlight: AppState["elementsToHighlight"];
|
|
147
147
|
collaborators: AppState["collaborators"];
|
|
@@ -176,6 +176,11 @@ export type ObservedElementsAppState = {
|
|
|
176
176
|
activeLockedId: AppState["activeLockedId"];
|
|
177
177
|
};
|
|
178
178
|
export type BoxSelectionMode = "contain" | "overlap";
|
|
179
|
+
/**
|
|
180
|
+
* The pointing device the wheel mappings are tuned for. `auto` is reserved
|
|
181
|
+
* for detecting it from the wheel events; see `resolveInputDevice`.
|
|
182
|
+
*/
|
|
183
|
+
export type InputDevice = "auto" | "mouse" | "trackpad";
|
|
179
184
|
/**
|
|
180
185
|
* A box, in scene coordinates, that pan & zoom are constrained to.
|
|
181
186
|
*
|
|
@@ -255,6 +260,16 @@ export interface AppState {
|
|
|
255
260
|
bindingPreference: "enabled" | "disabled";
|
|
256
261
|
/** user preference whether arrow snap to midpoints while binding */
|
|
257
262
|
isMidpointSnappingEnabled: boolean;
|
|
263
|
+
/** user preference whether to show contextual hints above the toolbar */
|
|
264
|
+
showHints: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* user preference for what the wheel does: with a `trackpad` a plain wheel
|
|
267
|
+
* pans; with a `mouse` a plain wheel zooms. Ctrl/cmd+wheel (how a pinch is
|
|
268
|
+
* delivered) zooms with either device. Shift+wheel pans horizontally;
|
|
269
|
+
* ctrl/cmd+shift+wheel pans vertically. `auto` resolves to `trackpad` until
|
|
270
|
+
* device detection exists — see `resolveInputDevice`
|
|
271
|
+
*/
|
|
272
|
+
inputDevice: InputDevice;
|
|
258
273
|
/**
|
|
259
274
|
* The bindable element the UI highlights for the user when an arrow is
|
|
260
275
|
* dragged or otherwise its endpoint being close to said element.
|
|
@@ -264,11 +279,20 @@ export interface AppState {
|
|
|
264
279
|
midPoint?: GlobalPoint;
|
|
265
280
|
} | null;
|
|
266
281
|
/**
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
282
|
+
* What a text-tool click at the hovered position would act on — the text
|
|
283
|
+
* it would edit, the empty container it would label, or the arrow anchor
|
|
284
|
+
* (a free endpoint, or the midpoint for a label) it would attach text to.
|
|
285
|
+
* `null` when the click would create free text, or the tool isn't active.
|
|
286
|
+
* Drives the hover affordance only.
|
|
270
287
|
*/
|
|
271
|
-
|
|
288
|
+
textToolHover: {
|
|
289
|
+
type: "text";
|
|
290
|
+
elementId: ExcalidrawElement["id"];
|
|
291
|
+
} | {
|
|
292
|
+
type: "container";
|
|
293
|
+
elementId: ExcalidrawElement["id"];
|
|
294
|
+
} | {
|
|
295
|
+
type: "arrow";
|
|
272
296
|
elementId: ExcalidrawArrowElement["id"];
|
|
273
297
|
anchor: "start" | "end" | "label";
|
|
274
298
|
} | null;
|
|
@@ -283,6 +307,10 @@ export interface AppState {
|
|
|
283
307
|
* frame-like element whose name is currently being edited
|
|
284
308
|
*/
|
|
285
309
|
editingFrame: ExcalidrawFrameLikeElement["id"] | null;
|
|
310
|
+
/**
|
|
311
|
+
* Elements the UI highlights with a bounding-box outline — those that
|
|
312
|
+
* would get added to a frame being dragged/resized.
|
|
313
|
+
*/
|
|
286
314
|
elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
|
|
287
315
|
/**
|
|
288
316
|
* set when a new text is created or when an existing text is being edited
|
|
@@ -308,6 +336,8 @@ export interface AppState {
|
|
|
308
336
|
exportWithDarkMode: boolean;
|
|
309
337
|
exportScale: number;
|
|
310
338
|
currentItemStrokeColor: string;
|
|
339
|
+
currentItemStickynoteStrokeColor: string;
|
|
340
|
+
currentItemStickynoteBackgroundColor: string;
|
|
311
341
|
currentItemBackgroundColor: string;
|
|
312
342
|
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
313
343
|
currentItemStrokeWidthKey: StrokeWidthKey;
|
|
@@ -382,6 +412,7 @@ export interface AppState {
|
|
|
382
412
|
duration?: number;
|
|
383
413
|
} | null;
|
|
384
414
|
zenModeEnabled: boolean;
|
|
415
|
+
minimapEnabled: boolean;
|
|
385
416
|
theme: Theme;
|
|
386
417
|
/** grid cell px size */
|
|
387
418
|
gridSize: number;
|
|
@@ -438,7 +469,13 @@ export interface AppState {
|
|
|
438
469
|
* even though both drive `currentItemBackgroundColor` (its defaults and
|
|
439
470
|
* use case differ — no transparent) */
|
|
440
471
|
bucketFill: readonly string[] | null;
|
|
472
|
+
/** sticky notes are their own color domain (own defaults, own picks) */
|
|
473
|
+
stickyNoteStroke: readonly string[] | null;
|
|
474
|
+
stickyNoteBackground: readonly string[] | null;
|
|
441
475
|
};
|
|
476
|
+
/** user-customized font-picker top picks (pinned via drag & drop from the
|
|
477
|
+
* font picker popup). `null` means no customization (defaults are used) */
|
|
478
|
+
fontTopPicks: readonly FontFamilyValues[] | null;
|
|
442
479
|
}
|
|
443
480
|
export type SearchMatch = {
|
|
444
481
|
id: string;
|
|
@@ -451,7 +488,7 @@ export type SearchMatch = {
|
|
|
451
488
|
showOnCanvas: boolean;
|
|
452
489
|
}[];
|
|
453
490
|
};
|
|
454
|
-
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "
|
|
491
|
+
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "textToolHover" | "frameToHighlight" | "elementsToHighlight">;
|
|
455
492
|
export type NormalizedZoomValue = number & {
|
|
456
493
|
_brand: "normalizedZoom";
|
|
457
494
|
};
|
|
@@ -613,23 +650,62 @@ export type InteractionConfig = {
|
|
|
613
650
|
export type UIConfig = {
|
|
614
651
|
/**
|
|
615
652
|
* Default UI controls that stay enabled while the rest of Excalidraw's
|
|
616
|
-
* default UI is hidden. Opt-in: anything omitted or `false` is
|
|
653
|
+
* default UI is hidden. Opt-in: anything omitted or `false` is
|
|
654
|
+
* disabled.
|
|
617
655
|
*/
|
|
618
656
|
enabled: {
|
|
619
657
|
/**
|
|
620
|
-
* The zoom
|
|
658
|
+
* The zoom controls (zoom out, the zoom level resetting it, zoom in).
|
|
621
659
|
*
|
|
622
660
|
* @default false
|
|
623
661
|
*/
|
|
624
662
|
zoom?: boolean;
|
|
625
663
|
/**
|
|
626
|
-
* The button shown when the viewport is scrolled away from all
|
|
664
|
+
* The button shown when the viewport is scrolled away from all
|
|
665
|
+
* content.
|
|
627
666
|
*
|
|
628
667
|
* @default false
|
|
629
668
|
*/
|
|
630
669
|
scrollBackToContent?: boolean;
|
|
631
670
|
};
|
|
671
|
+
} | {
|
|
672
|
+
/**
|
|
673
|
+
* Default UI controls that are removed while the rest of Excalidraw's
|
|
674
|
+
* default UI is rendered. Opt-out: anything omitted or `false` stays.
|
|
675
|
+
*/
|
|
676
|
+
disabled: {
|
|
677
|
+
/**
|
|
678
|
+
* The minimap, and every way to toggle it (its footer button, the
|
|
679
|
+
* Preferences menu item, and the command palette and context menu
|
|
680
|
+
* entries). Without the minimap toggle next to them, the zoom
|
|
681
|
+
* controls are the zoom out / zoom level / zoom in buttons instead of
|
|
682
|
+
* the zoom menu.
|
|
683
|
+
*
|
|
684
|
+
* @default false
|
|
685
|
+
*/
|
|
686
|
+
minimap?: boolean;
|
|
687
|
+
};
|
|
632
688
|
};
|
|
689
|
+
/** A default UI control that `UIConfig` can keep or remove. */
|
|
690
|
+
export type UIControl = keyof Extract<UIConfig, {
|
|
691
|
+
enabled: unknown;
|
|
692
|
+
}>["enabled"] | keyof Extract<UIConfig, {
|
|
693
|
+
disabled: unknown;
|
|
694
|
+
}>["disabled"];
|
|
695
|
+
/** Supported visual changes. Geometry, content, bindings and styles are not overridable. */
|
|
696
|
+
export type ElementRenderOverride = Readonly<{
|
|
697
|
+
/** Absolute render opacity (0–100, clamped). Omitted: use element.opacity. */
|
|
698
|
+
opacity?: number;
|
|
699
|
+
/** Translation in scene units. Bound labels inherit their container's offset and ignore this field. */
|
|
700
|
+
offset?: Readonly<{
|
|
701
|
+
x: number;
|
|
702
|
+
y: number;
|
|
703
|
+
}>;
|
|
704
|
+
}>;
|
|
705
|
+
/** see {@link ExcalidrawImperativeAPI.setElementRenderOverrides} for details */
|
|
706
|
+
export type ElementRenderOverrides = ReadonlyMap<ExcalidrawElement["id"], ElementRenderOverride>;
|
|
707
|
+
/** The translation part of a snapshot: only the entries that carry an offset. */
|
|
708
|
+
export type ElementRenderOffsets = ReadonlyMap<ExcalidrawElement["id"], NonNullable<ElementRenderOverride["offset"]>>;
|
|
633
709
|
export interface ExcalidrawProps {
|
|
634
710
|
className?: string;
|
|
635
711
|
/**
|
|
@@ -642,6 +718,30 @@ export interface ExcalidrawProps {
|
|
|
642
718
|
* @default document
|
|
643
719
|
*/
|
|
644
720
|
ownerDocument?: Document;
|
|
721
|
+
/**
|
|
722
|
+
* Host environment used by the renderer and export pipeline to create
|
|
723
|
+
* canvases and images. Supply a custom implementation to redirect canvas
|
|
724
|
+
* creation and image decoding to e.g. a host canvas pool, an
|
|
725
|
+
* `OffscreenCanvas`, or a non-DOM image decoder. When omitted, canvas and
|
|
726
|
+
* image creation fall back to `ownerDocument` / `ownerWindow`.
|
|
727
|
+
*
|
|
728
|
+
* The value must be referentially stable -- every render cache (element
|
|
729
|
+
* canvases, text metrics, char widths, link icons) is keyed by this
|
|
730
|
+
* object's identity, so a new identity is a full cache miss. Passing an
|
|
731
|
+
* inline object literal mints a fresh identity on every React render,
|
|
732
|
+
* which silently re-rasterizes every element on every frame; hoist it to a
|
|
733
|
+
* module constant or memoize it (e.g. `useMemo`) instead.
|
|
734
|
+
*
|
|
735
|
+
* Only `createCanvas` and `createImage` are required. `createPath` (used to
|
|
736
|
+
* fill freedraw strokes) falls back to the global `Path2D`, which every
|
|
737
|
+
* browser has -- a non-browser host without one must supply it. Pass
|
|
738
|
+
* `document` (the owner document) for SVG exports to be built in it rather
|
|
739
|
+
* than in the global `document`, and `textMetrics` to measure the editor's
|
|
740
|
+
* text with your own provider.
|
|
741
|
+
*
|
|
742
|
+
* @default { createCanvas: () => ownerDocument.createElement("canvas"), createImage: () => new ownerWindow.Image(), createPath: (d) => new ownerWindow.Path2D(d), document: ownerDocument }
|
|
743
|
+
*/
|
|
744
|
+
renderEnvironment?: RenderEnvironment;
|
|
645
745
|
onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
|
|
646
746
|
onThemeChange?: (theme: Theme | "system") => void;
|
|
647
747
|
/**
|
|
@@ -687,11 +787,27 @@ export interface ExcalidrawProps {
|
|
|
687
787
|
*
|
|
688
788
|
* Returned elements will be used in place of the next elements
|
|
689
789
|
* (you should return all elements, including deleted, and not mutate
|
|
690
|
-
* the element if changes are made)
|
|
790
|
+
* the element if changes are made).
|
|
791
|
+
*
|
|
792
|
+
* The duplicates are the elements in `nextElements` which are not in
|
|
793
|
+
* `prevElements` (see also `data.duplicateElements`). When pasting or
|
|
794
|
+
* inserting onto a frame, their `frameId` is already set. To change a
|
|
795
|
+
* duplicate, return a new object with the same `id`. It is shallow-merged
|
|
796
|
+
* into the duplicate (omitted properties are kept), and your changes are
|
|
797
|
+
* part of the duplication itself (same undo entry, same durable increment).
|
|
798
|
+
*
|
|
799
|
+
* To prevent an element from being duplicated, omit its duplicate from the
|
|
800
|
+
* returned array. References to it from the remaining duplicates are
|
|
801
|
+
* cleared, and a bound text isn't duplicated without its container. To
|
|
802
|
+
* prevent the duplication as a whole, return `false`. If no duplicate
|
|
803
|
+
* remains, the duplication is cancelled and the returned elements are
|
|
804
|
+
* ignored (alt-drag then moves the original elements instead).
|
|
691
805
|
*/
|
|
692
806
|
onDuplicate?: (nextElements: readonly ExcalidrawElement[],
|
|
693
807
|
/** excludes the duplicated elements */
|
|
694
|
-
prevElements: readonly ExcalidrawElement[]
|
|
808
|
+
prevElements: readonly ExcalidrawElement[],
|
|
809
|
+
/** lookups covering just the elements taking part in the duplication */
|
|
810
|
+
data: OnDuplicateData) => ExcalidrawElement[] | void | false;
|
|
695
811
|
renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
696
812
|
renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
697
813
|
langCode?: Language["code"];
|
|
@@ -724,10 +840,12 @@ export interface ExcalidrawProps {
|
|
|
724
840
|
* `false`.
|
|
725
841
|
*
|
|
726
842
|
* Pass a config object to keep specific default controls rendered while the
|
|
727
|
-
* rest of the default UI is hidden
|
|
843
|
+
* rest of the default UI is hidden, or to remove specific controls from the
|
|
844
|
+
* otherwise full default UI (see `UIConfig`):
|
|
728
845
|
*
|
|
729
846
|
* ```tsx
|
|
730
847
|
* <Excalidraw ui={{ enabled: { zoom: true } }} />
|
|
848
|
+
* <Excalidraw ui={{ disabled: { minimap: true } }} />
|
|
731
849
|
* ```
|
|
732
850
|
*
|
|
733
851
|
* NOTE: this is WIP and what default UI is/is not rendered when ui=false
|
|
@@ -831,7 +949,8 @@ export interface ExcalidrawProps {
|
|
|
831
949
|
}) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
|
|
832
950
|
}
|
|
833
951
|
export type SceneData = {
|
|
834
|
-
|
|
952
|
+
/** Expects normalized elements; restore imported data before updating the scene. */
|
|
953
|
+
elements?: readonly ExcalidrawElement[] | null;
|
|
835
954
|
appState?: ImportedDataState["appState"];
|
|
836
955
|
collaborators?: Map<SocketId, Collaborator>;
|
|
837
956
|
captureUpdate?: CaptureUpdateActionType;
|
|
@@ -893,6 +1012,7 @@ export type AppClassProperties = {
|
|
|
893
1012
|
state: AppState;
|
|
894
1013
|
readonly ownerDocument: Document;
|
|
895
1014
|
readonly ownerWindow: Window & typeof globalThis;
|
|
1015
|
+
renderEnvironment: RenderEnvironment;
|
|
896
1016
|
api: App["api"];
|
|
897
1017
|
sessionExportThemeOverride: App["sessionExportThemeOverride"];
|
|
898
1018
|
interactiveCanvas: HTMLCanvasElement | null;
|
|
@@ -909,11 +1029,12 @@ export type AppClassProperties = {
|
|
|
909
1029
|
scene: App["scene"];
|
|
910
1030
|
syncActionResult: App["syncActionResult"];
|
|
911
1031
|
fonts: App["fonts"];
|
|
912
|
-
|
|
1032
|
+
clipboard: App["clipboard"];
|
|
913
1033
|
id: App["id"];
|
|
914
1034
|
onInsertElements: App["onInsertElements"];
|
|
915
1035
|
onExportImage: App["onExportImage"];
|
|
916
1036
|
viewport: App["viewport"];
|
|
1037
|
+
wheel: App["wheel"];
|
|
917
1038
|
addFiles: App["addFiles"];
|
|
918
1039
|
addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
|
|
919
1040
|
togglePenMode: App["togglePenMode"];
|
|
@@ -927,8 +1048,16 @@ export type AppClassProperties = {
|
|
|
927
1048
|
flowchart: App["flowchart"];
|
|
928
1049
|
drawShape: App["drawShape"];
|
|
929
1050
|
arrowText: App["arrowText"];
|
|
1051
|
+
text: App["text"];
|
|
1052
|
+
textTool: App["textTool"];
|
|
930
1053
|
cursor: App["cursor"];
|
|
931
1054
|
bucketFill: App["bucketFill"];
|
|
1055
|
+
duplicate: App["duplicate"];
|
|
1056
|
+
toolDrag: App["toolDrag"];
|
|
1057
|
+
activeResizeHandle: App["activeResizeHandle"];
|
|
1058
|
+
selectionTool: App["selectionTool"];
|
|
1059
|
+
wrap: App["wrap"];
|
|
1060
|
+
modifiers: App["modifiers"];
|
|
932
1061
|
isToolLocked: App["isToolLocked"];
|
|
933
1062
|
getEffectiveGridSize: App["getEffectiveGridSize"];
|
|
934
1063
|
setPlugins: App["setPlugins"];
|
|
@@ -948,6 +1077,7 @@ export type AppClassProperties = {
|
|
|
948
1077
|
setAppState: App["setAppState"];
|
|
949
1078
|
isInteractionEnabled: App["isInteractionEnabled"];
|
|
950
1079
|
isNavigationEnabled: App["isNavigationEnabled"];
|
|
1080
|
+
isUIControlEnabled: App["isUIControlEnabled"];
|
|
951
1081
|
};
|
|
952
1082
|
export type PointerDownState = Readonly<{
|
|
953
1083
|
origin: Readonly<{
|
|
@@ -981,7 +1111,10 @@ export type PointerDownState = Readonly<{
|
|
|
981
1111
|
element: NonDeleted<ExcalidrawElement> | null;
|
|
982
1112
|
allHitElements: NonDeleted<ExcalidrawElement>[];
|
|
983
1113
|
wasAddedToSelection: boolean;
|
|
1114
|
+
cycleTarget: NonDeleted<ExcalidrawElement> | null;
|
|
984
1115
|
hasBeenDuplicated: boolean;
|
|
1116
|
+
advancedListMarkers: readonly ListMarkerAdvance[];
|
|
1117
|
+
editedTextId: ExcalidrawTextElement["id"] | null;
|
|
985
1118
|
hasHitCommonBoundingBoxOfSelectedElements: boolean;
|
|
986
1119
|
arrowLabel: boolean;
|
|
987
1120
|
};
|
|
@@ -996,6 +1129,10 @@ export type PointerDownState = Readonly<{
|
|
|
996
1129
|
x: number;
|
|
997
1130
|
y: number;
|
|
998
1131
|
};
|
|
1132
|
+
lastOffset: {
|
|
1133
|
+
x: number;
|
|
1134
|
+
y: number;
|
|
1135
|
+
};
|
|
999
1136
|
blockDragging: boolean;
|
|
1000
1137
|
};
|
|
1001
1138
|
eventListeners: {
|
|
@@ -1031,12 +1168,43 @@ export interface ExcalidrawImperativeAPI {
|
|
|
1031
1168
|
history: {
|
|
1032
1169
|
clear: InstanceType<typeof App>["resetHistory"];
|
|
1033
1170
|
};
|
|
1171
|
+
/**
|
|
1172
|
+
* Selects elements (or their ids — one or many), adds them to or removes
|
|
1173
|
+
* them from the selection, or clears it — as the editor does: an element is
|
|
1174
|
+
* selected with its group (unless `deep`), a frame and its children aren't
|
|
1175
|
+
* selected at the same time, and locked elements are skipped (unless
|
|
1176
|
+
* `includeLocked`). Text editing and cropping end, and the link popup of a
|
|
1177
|
+
* lone selected element shows. Missing and deleted elements are skipped.
|
|
1178
|
+
*
|
|
1179
|
+
* By default the change is recorded for undo along with the next undoable
|
|
1180
|
+
* change — pass `captureUpdate` as for `updateScene()` otherwise. Like
|
|
1181
|
+
* `updateScene()`, it applies on the next render: read it back through
|
|
1182
|
+
* `onChange()` or `getAppState()` after that. Works in view mode too, where
|
|
1183
|
+
* the selection shows without transform handles.
|
|
1184
|
+
*/
|
|
1185
|
+
selection: Pick<InstanceType<typeof App>["selection"], "select" | "add" | "remove" | "clear">;
|
|
1034
1186
|
getSceneElements: InstanceType<typeof App>["getSceneElements"];
|
|
1035
1187
|
getAppState: () => InstanceType<typeof App>["state"];
|
|
1036
1188
|
getFiles: () => InstanceType<typeof App>["files"];
|
|
1037
1189
|
getName: InstanceType<typeof App>["getName"];
|
|
1038
1190
|
setViewport: InstanceType<typeof App>["viewport"]["setViewport"];
|
|
1039
1191
|
getViewportOffsets: InstanceType<typeof App>["viewport"]["getOffsets"];
|
|
1192
|
+
/**
|
|
1193
|
+
* Atomically replaces all transient visual overrides. Values are copied;
|
|
1194
|
+
* omitted IDs/fields use document values, except for inherited label offsets.
|
|
1195
|
+
* null clears the snapshot.
|
|
1196
|
+
* Repaints without document changes, history entries or onChange events;
|
|
1197
|
+
* an equivalent snapshot may still repaint (clearing an already clear
|
|
1198
|
+
* snapshot does not), so submit only when something changed.
|
|
1199
|
+
* Finite opacity is clamped to 0–100; non-finite values reject the snapshot.
|
|
1200
|
+
* Unknown/deleted IDs are ignored when rendering. Reset/unmount clears it.
|
|
1201
|
+
* Bound labels inherit their container's offset; offsets targeting them are
|
|
1202
|
+
* ignored. Label opacity remains independent. Target frame children explicitly.
|
|
1203
|
+
* Frame opacity still multiplies child opacity. Decorations follow their owner.
|
|
1204
|
+
* Exports and interactive geometry (hit tests, selection, editing) use document
|
|
1205
|
+
* values, including while authoring an animation preview in edit mode.
|
|
1206
|
+
*/
|
|
1207
|
+
setElementRenderOverrides: InstanceType<typeof App>["setElementRenderOverrides"];
|
|
1040
1208
|
registerAction: (action: Action) => void;
|
|
1041
1209
|
refresh: InstanceType<typeof App>["refresh"];
|
|
1042
1210
|
setToast: InstanceType<typeof App>["setToast"];
|
|
@@ -1199,9 +1367,10 @@ export type ViewportOffsets = Offsets & {
|
|
|
1199
1367
|
/**
|
|
1200
1368
|
* Value of the `data-viewport-ui-name` attribute, identifying a
|
|
1201
1369
|
* conditionally-rendered surface (marked with `data-viewport-ui`) so that
|
|
1202
|
-
*
|
|
1203
|
-
*
|
|
1204
|
-
*
|
|
1205
|
-
*
|
|
1370
|
+
* it can be measured on its own, and so that `getViewportOffsets` can
|
|
1371
|
+
* reserve space for it while it's hidden (see the `reserve` option).
|
|
1372
|
+
* Whenever a named surface is rendered, its measured footprint is
|
|
1373
|
+
* remembered; reserving uses that remembered footprint, or an approximate
|
|
1374
|
+
* default if the surface hasn't been rendered yet.
|
|
1206
1375
|
*/
|
|
1207
|
-
export type ViewportUIName = "sidebar" | "stylesPanel";
|
|
1376
|
+
export type ViewportUIName = "sidebar" | "stylesPanel" | "stats";
|
|
@@ -108,11 +108,20 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, m
|
|
|
108
108
|
boxSelectionMode: import("./types").BoxSelectionMode;
|
|
109
109
|
bindingPreference: "enabled" | "disabled";
|
|
110
110
|
isMidpointSnappingEnabled: boolean;
|
|
111
|
+
showHints: boolean;
|
|
112
|
+
inputDevice: import("./types").InputDevice;
|
|
111
113
|
suggestedBinding: {
|
|
112
114
|
element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
|
|
113
115
|
midPoint?: import("@excalidraw/math").GlobalPoint;
|
|
114
116
|
} | null;
|
|
115
|
-
|
|
117
|
+
textToolHover: {
|
|
118
|
+
type: "text";
|
|
119
|
+
elementId: ExcalidrawElement["id"];
|
|
120
|
+
} | {
|
|
121
|
+
type: "container";
|
|
122
|
+
elementId: ExcalidrawElement["id"];
|
|
123
|
+
} | {
|
|
124
|
+
type: "arrow";
|
|
116
125
|
elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
|
|
117
126
|
anchor: "start" | "end" | "label";
|
|
118
127
|
} | null;
|
|
@@ -142,6 +151,8 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, m
|
|
|
142
151
|
exportWithDarkMode: boolean;
|
|
143
152
|
exportScale: number;
|
|
144
153
|
currentItemStrokeColor: string;
|
|
154
|
+
currentItemStickynoteStrokeColor: string;
|
|
155
|
+
currentItemStickynoteBackgroundColor: string;
|
|
145
156
|
currentItemBackgroundColor: string;
|
|
146
157
|
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
147
158
|
currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
|
|
@@ -206,6 +217,7 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, m
|
|
|
206
217
|
duration?: number;
|
|
207
218
|
} | null;
|
|
208
219
|
zenModeEnabled: boolean;
|
|
220
|
+
minimapEnabled: boolean;
|
|
209
221
|
theme: import("@excalidraw/element/types").Theme;
|
|
210
222
|
gridSize: number;
|
|
211
223
|
gridStep: number;
|
|
@@ -248,7 +260,10 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, m
|
|
|
248
260
|
elementStroke: readonly string[] | null;
|
|
249
261
|
elementBackground: readonly string[] | null;
|
|
250
262
|
bucketFill: readonly string[] | null;
|
|
263
|
+
stickyNoteStroke: readonly string[] | null;
|
|
264
|
+
stickyNoteBackground: readonly string[] | null;
|
|
251
265
|
};
|
|
266
|
+
fontTopPicks: readonly import("@excalidraw/element/types").FontFamilyValues[] | null;
|
|
252
267
|
};
|
|
253
268
|
captureUpdate: "EVENTUALLY";
|
|
254
269
|
};
|
|
@@ -268,6 +283,19 @@ export declare const centerScrollOn: ({ scenePoint, viewportDimensions, zoom, of
|
|
|
268
283
|
scrollX: number;
|
|
269
284
|
scrollY: number;
|
|
270
285
|
};
|
|
286
|
+
/**
|
|
287
|
+
* The scroll that brings `bounds` into the viewport — less `offsets` (screen
|
|
288
|
+
* px: UI covering its edges, room to leave) — by the least movement, keeping
|
|
289
|
+
* the zoom; `null` when they're in view already. Along an axis where they
|
|
290
|
+
* don't fit, their start (left / top) is brought in instead, or, with
|
|
291
|
+
* `tooLarge: "leave"`, that axis keeps its scroll.
|
|
292
|
+
*/
|
|
293
|
+
export declare const scrollBoundsIntoView: ({ bounds: [x1, y1, x2, y2], appState: { scrollX, scrollY, zoom, width, height }, offsets, tooLarge, }: {
|
|
294
|
+
bounds: Bounds;
|
|
295
|
+
appState: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height">;
|
|
296
|
+
offsets?: Offsets;
|
|
297
|
+
tooLarge?: "alignStart" | "leave";
|
|
298
|
+
}) => Pick<AppState, "scrollX" | "scrollY"> | null;
|
|
271
299
|
export declare const getScrollToContentState: (elements: readonly ExcalidrawElement[], appState: AppState) => {
|
|
272
300
|
scrollX: number;
|
|
273
301
|
scrollY: number;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { ExcalidrawTextElement } from "@excalidraw/element/types";
|
|
2
2
|
import type App from "../components/App";
|
|
3
|
+
/**
|
|
4
|
+
* How much further than the browser's caret reveal the canvas pans, in
|
|
5
|
+
* screen px: text typed past the viewport's edge comes back with this much
|
|
6
|
+
* room to spare, instead of flush against the edge.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CARET_FOLLOW_PADDING = 5;
|
|
3
9
|
type SubmitHandler = () => void;
|
|
4
|
-
export declare const textWysiwyg: ({ onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, initialCaretSceneCoords, }: {
|
|
10
|
+
export declare const textWysiwyg: ({ onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, initialCaretSceneCoords, initialSelection, }: {
|
|
5
11
|
/**
|
|
6
12
|
* textWysiwyg only deals with `originalText`
|
|
7
13
|
*
|
|
@@ -23,5 +29,10 @@ export declare const textWysiwyg: ({ onChange, onSubmit, getViewportCoords, elem
|
|
|
23
29
|
x: number;
|
|
24
30
|
y: number;
|
|
25
31
|
} | null;
|
|
32
|
+
/** range of `originalText` to select (takes precedence over the caret) */
|
|
33
|
+
initialSelection?: {
|
|
34
|
+
start: number;
|
|
35
|
+
end: number;
|
|
36
|
+
} | null;
|
|
26
37
|
}) => SubmitHandler;
|
|
27
38
|
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { exportScene, exportToClipboard, MIME_TYPES, } from "@excalidraw/excalidraw/scene/export";
|
|
2
|
+
export type { ExportSceneData, ExportSceneConfig, ExportSceneOptions, } from "@excalidraw/excalidraw/scene/export";
|
|
2
3
|
export { elementsOverlappingBBox } from "@excalidraw/element";
|
|
3
4
|
export { getCommonBounds } from "@excalidraw/element";
|
|
5
|
+
export type { RenderEnvironment } from "@excalidraw/element";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
|
|
2
|
-
import type { ElementsMap, ExcalidrawBindableElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawEmbeddableElement, ExcalidrawFrameLikeElement, ExcalidrawFreeDrawElement, ExcalidrawIframeElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawRectangleElement, ExcalidrawSelectionElement, ExcalidrawTextElement } from "@excalidraw/element/types";
|
|
2
|
+
import type { ElementsMap, ExcalidrawBindableElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawEmbeddableElement, ExcalidrawFrameLikeElement, ExcalidrawFreeDrawElement, ExcalidrawIframeElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawRectangleElement, ExcalidrawSelectionElement, ExcalidrawStickyNoteElement, ExcalidrawTextElement } from "@excalidraw/element/types";
|
|
3
3
|
import type { Curve, LineSegment, Polygon, Radians } from "@excalidraw/math";
|
|
4
4
|
import type { Drawable, Op } from "roughjs/bin/core";
|
|
5
5
|
export type Polyline<Point extends GlobalPoint | LocalPoint> = LineSegment<Point>[];
|
|
@@ -29,7 +29,7 @@ export type GeometricShape<Point extends GlobalPoint | LocalPoint> = {
|
|
|
29
29
|
type: "polycurve";
|
|
30
30
|
data: Polycurve<Point>;
|
|
31
31
|
};
|
|
32
|
-
type RectangularElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement | ExcalidrawImageElement | ExcalidrawIframeElement | ExcalidrawTextElement | ExcalidrawSelectionElement;
|
|
32
|
+
type RectangularElement = ExcalidrawRectangleElement | ExcalidrawStickyNoteElement | ExcalidrawDiamondElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement | ExcalidrawImageElement | ExcalidrawIframeElement | ExcalidrawTextElement | ExcalidrawSelectionElement;
|
|
33
33
|
export declare const getPolygonShape: <Point extends GlobalPoint | LocalPoint>(element: RectangularElement) => GeometricShape<Point>;
|
|
34
34
|
export declare const getSelectionBoxShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawElement, elementsMap: ElementsMap, padding?: number) => GeometricShape<Point>;
|
|
35
35
|
export declare const getEllipseShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawEllipseElement) => GeometricShape<Point>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@excalidraw/math",
|
|
3
|
-
"version": "0.18.0-
|
|
3
|
+
"version": "0.18.0-2c3dcc0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/types/math/src/index.d.ts",
|
|
6
6
|
"main": "./dist/prod/index.js",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@excalidraw/common": "0.18.0-
|
|
64
|
+
"@excalidraw/common": "0.18.0-2c3dcc0"
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
type DragOrigin = {
|
|
2
|
-
kind: "swatch";
|
|
3
|
-
} | {
|
|
4
|
-
kind: "pick";
|
|
5
|
-
index: number;
|
|
6
|
-
};
|
|
7
|
-
export type TopPicksDragState = {
|
|
8
|
-
color: string;
|
|
9
|
-
origin: DragOrigin;
|
|
10
|
-
/** hovered strip slot — the slot to replace (swatch drags) or the final
|
|
11
|
-
* position (pick reorders). null while the pointer is outside the strip */
|
|
12
|
-
overIndex: number | null;
|
|
13
|
-
/** index of an already-pinned identical color that blocks the drop */
|
|
14
|
-
duplicateIndex: number | null;
|
|
15
|
-
/** signed distance between strip slot centers (for reorder preview) */
|
|
16
|
-
slotSpan: number;
|
|
17
|
-
} | null;
|
|
18
|
-
export type ColorPickerDnD = {
|
|
19
|
-
dragState: TopPicksDragState;
|
|
20
|
-
startSwatchDrag: (event: React.PointerEvent, color: string | null) => void;
|
|
21
|
-
startPickDrag: (event: React.PointerEvent, index: number, color: string) => void;
|
|
22
|
-
setStripEl: (el: HTMLDivElement | null) => void;
|
|
23
|
-
};
|
|
24
|
-
export declare const ColorPickerDnDContext: import("react").Context<ColorPickerDnD | null>;
|
|
25
|
-
export declare const useColorPickerDnD: () => ColorPickerDnD | null;
|
|
26
|
-
export declare const useTopPicksDnD: ({ enabled, picks, onPicksChange, }: {
|
|
27
|
-
enabled: boolean;
|
|
28
|
-
picks: readonly string[];
|
|
29
|
-
onPicksChange: (picks: string[]) => void;
|
|
30
|
-
}) => ColorPickerDnD;
|
|
31
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { MIME_TYPES } from "@excalidraw/common";
|
|
2
|
-
import type { ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
3
|
-
import type { AppState, BinaryFiles } from "@excalidraw/excalidraw/types";
|
|
4
|
-
export { MIME_TYPES };
|
|
5
|
-
type ExportOpts = {
|
|
6
|
-
elements: readonly NonDeletedExcalidrawElement[];
|
|
7
|
-
appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
|
|
8
|
-
files: BinaryFiles | null;
|
|
9
|
-
maxWidthOrHeight?: number;
|
|
10
|
-
exportingFrame?: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
11
|
-
getDimensions?: (width: number, height: number) => {
|
|
12
|
-
width: number;
|
|
13
|
-
height: number;
|
|
14
|
-
scale?: number;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export declare const exportToCanvas: ({ elements, appState, files, maxWidthOrHeight, getDimensions, exportPadding, exportingFrame, }: ExportOpts & {
|
|
18
|
-
exportPadding?: number;
|
|
19
|
-
}) => Promise<HTMLCanvasElement>;
|
|
20
|
-
export declare const exportToBlob: (opts: ExportOpts & {
|
|
21
|
-
mimeType?: string;
|
|
22
|
-
quality?: number;
|
|
23
|
-
exportPadding?: number;
|
|
24
|
-
}) => Promise<Blob>;
|
|
25
|
-
export declare const exportToSvg: ({ elements, appState, files, exportPadding, renderEmbeddables, exportingFrame, skipInliningFonts, reuseImages, }: Omit<ExportOpts, "getDimensions"> & {
|
|
26
|
-
exportPadding?: number;
|
|
27
|
-
renderEmbeddables?: boolean;
|
|
28
|
-
skipInliningFonts?: true;
|
|
29
|
-
reuseImages?: boolean;
|
|
30
|
-
}) => Promise<SVGSVGElement>;
|
|
31
|
-
export declare const exportToClipboard: (opts: ExportOpts & {
|
|
32
|
-
mimeType?: string;
|
|
33
|
-
quality?: number;
|
|
34
|
-
type: "png" | "svg" | "json";
|
|
35
|
-
}) => Promise<void>;
|