@dwelle/excalidraw 0.5.0-ff7b5f2db → 0.5.0-ffade30
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/CHANGELOG.md +2385 -0
- package/dist/dev/{chunk-56C7N44U.js → chunk-CB6O5JO7.js} +16177 -10984
- package/dist/dev/chunk-CB6O5JO7.js.map +7 -0
- package/dist/dev/{chunk-DGCWVQGA.js → chunk-JB4JDZ66.js} +15 -4
- package/dist/dev/chunk-JB4JDZ66.js.map +7 -0
- package/dist/dev/chunk-QXVP5PAI.js +7 -0
- package/dist/dev/chunk-QXVP5PAI.js.map +7 -0
- package/dist/dev/data/{image-BLSI3C2P.js → image-JTJWA4BG.js} +3 -3
- package/dist/dev/index.css +143 -68
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +3978 -6519
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-AAITTNRF.js → en-PIB5PD3P.js} +2 -2
- package/dist/dev/subset-shared.chunk.js +1 -1
- package/dist/dev/subset-worker.chunk.js +1 -1
- package/dist/prod/chunk-JEM5OQGK.js +33 -0
- package/dist/prod/chunk-JH36RZFS.js +7 -0
- package/dist/prod/{chunk-OV23WS6X.js → chunk-KC3NX2DX.js} +4 -4
- package/dist/prod/data/image-UJJWHTZ6.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +22 -21
- package/dist/prod/locales/{en-YOZMX4VX.js → en-RKTHI3YA.js} +1 -1
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/common/src/colors.d.ts +1 -0
- package/dist/types/common/src/constants.d.ts +11 -1
- package/dist/types/{excalidraw → common/src}/emitter.d.ts +1 -1
- package/dist/types/common/src/font-metadata.d.ts +4 -2
- package/dist/types/common/src/index.d.ts +1 -0
- package/dist/types/common/src/utility-types.d.ts +5 -0
- package/dist/types/common/src/utils.d.ts +22 -5
- package/dist/types/{excalidraw/scene → element/src}/Scene.d.ts +11 -14
- package/dist/types/element/src/ShapeCache.d.ts +1 -1
- package/dist/types/element/src/align.d.ts +3 -3
- package/dist/types/element/src/binding.d.ts +19 -11
- package/dist/types/element/src/bounds.d.ts +7 -2
- package/dist/types/element/src/collision.d.ts +1 -1
- package/dist/types/{excalidraw/change.d.ts → element/src/delta.d.ts} +40 -35
- package/dist/types/element/src/dragElements.d.ts +3 -2
- package/dist/types/element/src/duplicate.d.ts +10 -13
- package/dist/types/element/src/elbowArrow.d.ts +1 -1
- package/dist/types/element/src/flowchart.d.ts +3 -2
- package/dist/types/element/src/fractionalIndex.d.ts +2 -2
- package/dist/types/element/src/frame.d.ts +5 -4
- package/dist/types/element/src/heading.d.ts +0 -1
- package/dist/types/element/src/index.d.ts +45 -2
- package/dist/types/element/src/linearElementEditor.d.ts +19 -31
- package/dist/types/element/src/mutateElement.d.ts +10 -2
- package/dist/types/element/src/newElement.d.ts +4 -3
- package/dist/types/element/src/resizeElements.d.ts +4 -4
- package/dist/types/element/src/selection.d.ts +11 -5
- package/dist/types/element/src/shapes.d.ts +5 -1
- package/dist/types/element/src/sizeHelpers.d.ts +1 -1
- package/dist/types/element/src/store.d.ts +227 -0
- package/dist/types/element/src/textElement.d.ts +5 -3
- package/dist/types/element/src/transformHandles.d.ts +4 -4
- package/dist/types/element/src/typeChecks.d.ts +15 -1
- package/dist/types/element/src/types.d.ts +14 -1
- package/dist/types/element/src/zindex.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +42 -45
- package/dist/types/excalidraw/actions/actionAlign.d.ts +8 -8
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +28 -30
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +438 -275
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +86 -92
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +14 -15
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +40 -43
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +14 -15
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +43 -47
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +14 -15
- package/dist/types/excalidraw/actions/actionExport.d.ts +219 -228
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +73 -36
- package/dist/types/excalidraw/actions/actionFlip.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionFrame.d.ts +100 -104
- package/dist/types/excalidraw/actions/actionGroup.d.ts +34 -36
- package/dist/types/excalidraw/actions/actionHistory.d.ts +1 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +506 -14
- package/dist/types/excalidraw/actions/actionLink.d.ts +14 -15
- package/dist/types/excalidraw/actions/actionMenu.d.ts +42 -45
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +27 -29
- package/dist/types/excalidraw/actions/actionProperties.d.ts +207 -214
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +16 -17
- package/dist/types/excalidraw/actions/actionStyles.d.ts +18 -19
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +16 -17
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +16 -17
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +16 -189
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +16 -18
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +16 -18
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +16 -18
- package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
- package/dist/types/excalidraw/actions/types.d.ts +4 -3
- package/dist/types/excalidraw/animated-trail.d.ts +7 -1
- package/dist/types/excalidraw/appState.d.ts +40 -30
- package/dist/types/excalidraw/components/App.d.ts +30 -12
- package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +5 -1
- package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/HotkeyLabel.d.ts +1 -2
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -3
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -3
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -2
- package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +2 -2
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +23 -0
- package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +4 -3
- package/dist/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
- package/dist/types/excalidraw/components/Range.d.ts +3 -3
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Position.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -11
- package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
- package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -1
- package/dist/types/excalidraw/components/icons.d.ts +4 -0
- package/dist/types/excalidraw/components/shapes.d.ts +1 -1
- package/dist/types/excalidraw/data/blob.d.ts +1 -1
- package/dist/types/excalidraw/data/transform.d.ts +1 -1
- package/dist/types/excalidraw/editor-jotai.d.ts +6 -6
- package/dist/types/excalidraw/eraser/index.d.ts +14 -0
- package/dist/types/excalidraw/fonts/Fonts.d.ts +1 -1
- package/dist/types/excalidraw/history.d.ts +14 -22
- package/dist/types/excalidraw/hooks/useEmitter.d.ts +1 -1
- package/dist/types/excalidraw/index.d.ts +9 -9
- package/dist/types/excalidraw/lasso/index.d.ts +16 -0
- package/dist/types/excalidraw/lasso/utils.d.ts +12 -0
- package/dist/types/excalidraw/renderer/helpers.d.ts +6 -1
- package/dist/types/excalidraw/scene/Renderer.d.ts +1 -1
- package/dist/types/excalidraw/scene/export.d.ts +1 -1
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/scrollbars.d.ts +2 -3
- package/dist/types/excalidraw/scene/types.d.ts +2 -0
- package/dist/types/excalidraw/snapping.d.ts +2 -2
- package/dist/types/excalidraw/types.d.ts +30 -7
- package/dist/types/excalidraw/visualdebug.d.ts +1 -1
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +3 -1
- package/dist/types/math/src/curve.d.ts +2 -0
- package/dist/types/math/src/point.d.ts +1 -1
- package/dist/types/math/src/polygon.d.ts +1 -0
- package/dist/types/math/src/segment.d.ts +1 -1
- package/dist/types/math/src/types.d.ts +1 -0
- package/dist/types/math/src/vector.d.ts +4 -0
- package/dist/types/utils/src/bbox.d.ts +1 -1
- package/dist/types/utils/src/index.d.ts +1 -1
- package/dist/types/utils/src/withinBounds.d.ts +1 -1
- package/history.ts +186 -0
- package/package.json +9 -4
- package/dist/dev/chunk-56C7N44U.js.map +0 -7
- package/dist/dev/chunk-DGCWVQGA.js.map +0 -7
- package/dist/dev/chunk-HQHB2BE4.js +0 -7
- package/dist/dev/chunk-HQHB2BE4.js.map +0 -7
- package/dist/prod/chunk-BUJ2ENHZ.js +0 -31
- package/dist/prod/chunk-C3FOHAIA.js +0 -7
- package/dist/prod/data/image-MI7OQWUS.js +0 -1
- package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
- package/dist/types/excalidraw/store.d.ts +0 -129
- /package/dist/dev/data/{image-BLSI3C2P.js.map → image-JTJWA4BG.js.map} +0 -0
- /package/dist/dev/locales/{en-AAITTNRF.js.map → en-PIB5PD3P.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExcalidrawElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
2
|
-
import type Scene from "
|
|
2
|
+
import type { Scene } from "@excalidraw/element";
|
|
3
3
|
import type { AppState } from "../types";
|
|
4
4
|
export declare class Renderer {
|
|
5
5
|
private scene;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Bounds } from "@excalidraw/element
|
|
1
|
+
import type { Bounds } from "@excalidraw/element";
|
|
2
2
|
import type { ExcalidrawFrameLikeElement, NonDeletedExcalidrawElement, Theme } from "@excalidraw/element/types";
|
|
3
3
|
import type { AppState, BinaryFiles } from "../types";
|
|
4
4
|
export type ExportToCanvasData = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { isSomeElementSelected, getElementsWithinSelection,
|
|
1
|
+
export { isSomeElementSelected, getElementsWithinSelection, getSelectedElements, getTargetElements, } from "@excalidraw/element";
|
|
2
2
|
export { calculateScrollCenter } from "./scroll";
|
|
3
|
-
export { hasBackground, hasStrokeWidth, hasStrokeStyle, canHaveArrowheads, canChangeRoundness, } from "@excalidraw/element
|
|
3
|
+
export { hasBackground, hasStrokeWidth, hasStrokeStyle, canHaveArrowheads, canChangeRoundness, } from "@excalidraw/element";
|
|
4
4
|
export { getNormalizedZoom, getNormalizedGridSize, getNormalizedGridStep, } from "./normalize";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { ExcalidrawElement } from "@excalidraw/element/types";
|
|
2
1
|
import type { InteractiveCanvasAppState } from "../types";
|
|
3
|
-
import type { ScrollBars } from "./types";
|
|
2
|
+
import type { RenderableElementsMap, ScrollBars } from "./types";
|
|
4
3
|
export declare const SCROLLBAR_MARGIN = 4;
|
|
5
4
|
export declare const SCROLLBAR_WIDTH = 6;
|
|
6
5
|
export declare const SCROLLBAR_COLOR = "rgba(0,0,0,0.3)";
|
|
7
|
-
export declare const getScrollBars: (elements:
|
|
6
|
+
export declare const getScrollBars: (elements: RenderableElementsMap, viewportWidth: number, viewportHeight: number, appState: InteractiveCanvasAppState) => ScrollBars;
|
|
8
7
|
export declare const isOverScrollBars: (scrollBars: ScrollBars, x: number, y: number) => {
|
|
9
8
|
isOverEither: boolean;
|
|
10
9
|
isOverHorizontal: boolean;
|
|
@@ -101,12 +101,14 @@ export type ScrollBars = {
|
|
|
101
101
|
y: number;
|
|
102
102
|
width: number;
|
|
103
103
|
height: number;
|
|
104
|
+
deltaMultiplier: number;
|
|
104
105
|
} | null;
|
|
105
106
|
vertical: {
|
|
106
107
|
x: number;
|
|
107
108
|
y: number;
|
|
108
109
|
width: number;
|
|
109
110
|
height: number;
|
|
111
|
+
deltaMultiplier: number;
|
|
110
112
|
} | null;
|
|
111
113
|
};
|
|
112
114
|
export type ElementShape = Drawable | Drawable[] | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type GlobalPoint } from "@excalidraw/math";
|
|
2
2
|
import type { InclusiveRange } from "@excalidraw/math";
|
|
3
|
-
import type { Bounds } from "@excalidraw/element
|
|
4
|
-
import type { MaybeTransformHandleType } from "@excalidraw/element
|
|
3
|
+
import type { Bounds } from "@excalidraw/element";
|
|
4
|
+
import type { MaybeTransformHandleType } from "@excalidraw/element";
|
|
5
5
|
import type { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
6
6
|
import type { AppClassProperties, AppState, KeyboardModifiersObject } from "./types";
|
|
7
7
|
export declare const getSnapDistance: (zoomValue: number) => number;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES } from "@excalidraw/common";
|
|
2
|
-
import type { SuggestedBinding } from "@excalidraw/element
|
|
3
|
-
import type { LinearElementEditor } from "@excalidraw/element
|
|
4
|
-
import type { MaybeTransformHandleType } from "@excalidraw/element
|
|
2
|
+
import type { SuggestedBinding } from "@excalidraw/element";
|
|
3
|
+
import type { LinearElementEditor } from "@excalidraw/element";
|
|
4
|
+
import type { MaybeTransformHandleType } from "@excalidraw/element";
|
|
5
5
|
import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement } from "@excalidraw/element/types";
|
|
6
6
|
import type { Merge, MaybePromise, ValueOf, MakeBrand } from "@excalidraw/common/utility-types";
|
|
7
|
+
import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
|
|
7
8
|
import type { Action } from "./actions/types";
|
|
8
9
|
import type { Spreadsheet } from "./charts";
|
|
9
10
|
import type { ClipboardData } from "./clipboard";
|
|
@@ -12,7 +13,6 @@ import type Library from "./data/library";
|
|
|
12
13
|
import type { FileSystemHandle } from "./data/filesystem";
|
|
13
14
|
import type { ContextMenuItems } from "./components/ContextMenu";
|
|
14
15
|
import type { SnapLine } from "./snapping";
|
|
15
|
-
import type { CaptureUpdateActionType } from "./store";
|
|
16
16
|
import type { ImportedDataState } from "./data/types";
|
|
17
17
|
import type { Language } from "./i18n";
|
|
18
18
|
import type { isOverScrollBars } from "./scene/scrollbars";
|
|
@@ -84,7 +84,7 @@ export type BinaryFileData = {
|
|
|
84
84
|
};
|
|
85
85
|
export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
|
|
86
86
|
export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
|
|
87
|
-
export type ToolType = "selection" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser";
|
|
87
|
+
export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser";
|
|
88
88
|
export type ElementOrToolType = ExcalidrawElementType | ToolType | "custom";
|
|
89
89
|
export type ActiveTool = {
|
|
90
90
|
type: ToolType;
|
|
@@ -144,6 +144,7 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
144
144
|
isCropping: AppState["isCropping"];
|
|
145
145
|
croppingElementId: AppState["croppingElementId"];
|
|
146
146
|
searchMatches: AppState["searchMatches"];
|
|
147
|
+
activeLockedId: AppState["activeLockedId"];
|
|
147
148
|
}>;
|
|
148
149
|
export type ObservedAppState = ObservedStandaloneAppState & ObservedElementsAppState;
|
|
149
150
|
export type ObservedStandaloneAppState = {
|
|
@@ -157,6 +158,8 @@ export type ObservedElementsAppState = {
|
|
|
157
158
|
editingLinearElementId: LinearElementEditor["elementId"] | null;
|
|
158
159
|
selectedLinearElementId: LinearElementEditor["elementId"] | null;
|
|
159
160
|
croppingElementId: AppState["croppingElementId"];
|
|
161
|
+
lockedMultiSelections: AppState["lockedMultiSelections"];
|
|
162
|
+
activeLockedId: AppState["activeLockedId"];
|
|
160
163
|
};
|
|
161
164
|
export interface AppState {
|
|
162
165
|
contextMenu: {
|
|
@@ -215,6 +218,7 @@ export interface AppState {
|
|
|
215
218
|
*/
|
|
216
219
|
lastActiveTool: ActiveTool | null;
|
|
217
220
|
locked: boolean;
|
|
221
|
+
fromSelection: boolean;
|
|
218
222
|
} & ActiveTool;
|
|
219
223
|
penMode: boolean;
|
|
220
224
|
penDetected: boolean;
|
|
@@ -338,9 +342,18 @@ export interface AppState {
|
|
|
338
342
|
/** image cropping */
|
|
339
343
|
isCropping: boolean;
|
|
340
344
|
croppingElementId: ExcalidrawElement["id"] | null;
|
|
341
|
-
|
|
345
|
+
/** null if no search matches found / search closed */
|
|
346
|
+
searchMatches: Readonly<{
|
|
347
|
+
focusedId: ExcalidrawElement["id"] | null;
|
|
348
|
+
matches: readonly SearchMatch[];
|
|
349
|
+
}> | null;
|
|
350
|
+
/** the locked element/group that's active and shows unlock popup */
|
|
351
|
+
activeLockedId: string | null;
|
|
352
|
+
lockedMultiSelections: {
|
|
353
|
+
[groupId: string]: true;
|
|
354
|
+
};
|
|
342
355
|
}
|
|
343
|
-
type SearchMatch = {
|
|
356
|
+
export type SearchMatch = {
|
|
344
357
|
id: string;
|
|
345
358
|
focus: boolean;
|
|
346
359
|
matchedLines: {
|
|
@@ -348,6 +361,7 @@ type SearchMatch = {
|
|
|
348
361
|
offsetY: number;
|
|
349
362
|
width: number;
|
|
350
363
|
height: number;
|
|
364
|
+
showOnCanvas: boolean;
|
|
351
365
|
}[];
|
|
352
366
|
};
|
|
353
367
|
export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
|
|
@@ -404,6 +418,7 @@ export interface ExcalidrawProps {
|
|
|
404
418
|
id?: string | null;
|
|
405
419
|
className?: string;
|
|
406
420
|
onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles, id?: string | null) => void;
|
|
421
|
+
onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
|
|
407
422
|
initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
|
|
408
423
|
excalidrawAPI?: (api: ExcalidrawImperativeAPI) => void;
|
|
409
424
|
onHomeButtonClick?: () => void;
|
|
@@ -464,6 +479,7 @@ export interface ExcalidrawProps {
|
|
|
464
479
|
renderEmbeddable?: (element: NonDeleted<ExcalidrawEmbeddableElement>, appState: AppState) => JSX.Element | null;
|
|
465
480
|
aiEnabled?: boolean;
|
|
466
481
|
showDeprecatedFonts?: boolean;
|
|
482
|
+
renderScrollbars?: boolean;
|
|
467
483
|
interactive?: boolean;
|
|
468
484
|
ui?: boolean;
|
|
469
485
|
activeTool?: {
|
|
@@ -557,6 +573,7 @@ export type AppClassProperties = {
|
|
|
557
573
|
visibleElements: App["visibleElements"];
|
|
558
574
|
excalidrawContainerValue: App["excalidrawContainerValue"];
|
|
559
575
|
onPointerUpEmitter: App["onPointerUpEmitter"];
|
|
576
|
+
updateEditorAtom: App["updateEditorAtom"];
|
|
560
577
|
};
|
|
561
578
|
export type PointerDownState = Readonly<{
|
|
562
579
|
origin: Readonly<{
|
|
@@ -600,6 +617,10 @@ export type PointerDownState = Readonly<{
|
|
|
600
617
|
x: number;
|
|
601
618
|
y: number;
|
|
602
619
|
} | null;
|
|
620
|
+
origin: {
|
|
621
|
+
x: number;
|
|
622
|
+
y: number;
|
|
623
|
+
};
|
|
603
624
|
};
|
|
604
625
|
eventListeners: {
|
|
605
626
|
onMove: null | ReturnType<typeof throttleRAF>;
|
|
@@ -614,6 +635,7 @@ export type PointerDownState = Readonly<{
|
|
|
614
635
|
export type UnsubscribeCallback = () => void;
|
|
615
636
|
export interface ExcalidrawImperativeAPI {
|
|
616
637
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
638
|
+
mutateElement: InstanceType<typeof App>["mutateElement"];
|
|
617
639
|
updateLibrary: InstanceType<typeof Library>["updateLibrary"];
|
|
618
640
|
resetScene: InstanceType<typeof App>["resetScene"];
|
|
619
641
|
getSceneElementsIncludingDeleted: InstanceType<typeof App>["getSceneElementsIncludingDeleted"];
|
|
@@ -642,6 +664,7 @@ export interface ExcalidrawImperativeAPI {
|
|
|
642
664
|
updateFrameRendering: InstanceType<typeof App>["updateFrameRendering"];
|
|
643
665
|
app: InstanceType<typeof App>;
|
|
644
666
|
onChange: (callback: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void) => UnsubscribeCallback;
|
|
667
|
+
onIncrement: (callback: (event: DurableIncrement | EphemeralIncrement) => void) => UnsubscribeCallback;
|
|
645
668
|
onPointerDown: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: React.PointerEvent<HTMLElement>) => void) => UnsubscribeCallback;
|
|
646
669
|
onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
|
|
647
670
|
onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
|
|
2
2
|
import type { Curve } from "@excalidraw/math";
|
|
3
3
|
import type { LineSegment } from "@excalidraw/utils";
|
|
4
|
-
import type { Bounds } from "@excalidraw/element
|
|
4
|
+
import type { Bounds } from "@excalidraw/element";
|
|
5
5
|
declare global {
|
|
6
6
|
interface Window {
|
|
7
7
|
visualDebug?: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExcalidrawElement, ExcalidrawTextElement } from "@excalidraw/element/types";
|
|
2
2
|
import type App from "../components/App";
|
|
3
|
+
type SubmitHandler = () => void;
|
|
3
4
|
export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, }: {
|
|
4
5
|
id: ExcalidrawElement["id"];
|
|
5
6
|
/**
|
|
@@ -19,4 +20,5 @@ export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords,
|
|
|
19
20
|
excalidrawContainer: HTMLDivElement | null;
|
|
20
21
|
app: App;
|
|
21
22
|
autoSelect?: boolean | undefined;
|
|
22
|
-
}) =>
|
|
23
|
+
}) => SubmitHandler;
|
|
24
|
+
export {};
|
|
@@ -8,6 +8,7 @@ import type { Curve, GlobalPoint, LineSegment, LocalPoint } from "./types";
|
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
10
|
export declare function curve<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point, c: Point, d: Point): Curve<Point>;
|
|
11
|
+
export declare const bezierEquation: <Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, t: number) => Point;
|
|
11
12
|
/**
|
|
12
13
|
* Computes the intersection between a cubic spline and a line segment.
|
|
13
14
|
*/
|
|
@@ -38,3 +39,4 @@ export declare function curvePointDistance<Point extends GlobalPoint | LocalPoin
|
|
|
38
39
|
* Determines if the parameter is a Curve
|
|
39
40
|
*/
|
|
40
41
|
export declare function isCurve<P extends GlobalPoint | LocalPoint>(v: unknown): v is Curve<P>;
|
|
42
|
+
export declare function curveTangent<Point extends GlobalPoint | LocalPoint>([p0, p1, p2, p3]: Curve<Point>, t: number): import("./types").Vector;
|
|
@@ -43,7 +43,7 @@ export declare function isPoint(p: unknown): p is LocalPoint | GlobalPoint;
|
|
|
43
43
|
* @param b Point The second point to compare
|
|
44
44
|
* @returns TRUE if the points are sufficiently close to each other
|
|
45
45
|
*/
|
|
46
|
-
export declare function pointsEqual<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point): boolean;
|
|
46
|
+
export declare function pointsEqual<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point, tolerance?: number): boolean;
|
|
47
47
|
/**
|
|
48
48
|
* Rotate a point by [angle] radians.
|
|
49
49
|
*
|
|
@@ -2,4 +2,5 @@ import type { GlobalPoint, LocalPoint, Polygon } from "./types";
|
|
|
2
2
|
export declare function polygon<Point extends GlobalPoint | LocalPoint>(...points: Point[]): Polygon<Point>;
|
|
3
3
|
export declare function polygonFromPoints<Point extends GlobalPoint | LocalPoint>(points: Point[]): Polygon<Point>;
|
|
4
4
|
export declare const polygonIncludesPoint: <Point extends GlobalPoint | LocalPoint>(point: Point, polygon: Polygon<Point>) => boolean;
|
|
5
|
+
export declare const polygonIncludesPointNonZero: <Point extends [number, number]>(point: Point, polygon: Point[]) => boolean;
|
|
5
6
|
export declare const pointOnPolygon: <Point extends GlobalPoint | LocalPoint>(p: Point, poly: Polygon<Point>, threshold?: number) => boolean;
|
|
@@ -36,4 +36,4 @@ export declare const distanceToLineSegment: <Point extends GlobalPoint | LocalPo
|
|
|
36
36
|
* @param s
|
|
37
37
|
* @returns
|
|
38
38
|
*/
|
|
39
|
-
export declare function lineSegmentIntersectionPoints<Point extends GlobalPoint | LocalPoint>(l: LineSegment<Point>, s: LineSegment<Point
|
|
39
|
+
export declare function lineSegmentIntersectionPoints<Point extends GlobalPoint | LocalPoint>(l: LineSegment<Point>, s: LineSegment<Point>, threshold?: number): Point | null;
|
|
@@ -86,3 +86,7 @@ export declare function vectorMagnitude(v: Vector): number;
|
|
|
86
86
|
* @returns The new normalized vector
|
|
87
87
|
*/
|
|
88
88
|
export declare const vectorNormalize: (v: Vector) => Vector;
|
|
89
|
+
/**
|
|
90
|
+
* Calculate the right-hand normal of the vector.
|
|
91
|
+
*/
|
|
92
|
+
export declare const vectorNormal: (v: Vector) => Vector;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
|
|
2
|
-
import type { Bounds } from "@excalidraw/element
|
|
2
|
+
import type { Bounds } from "@excalidraw/element";
|
|
3
3
|
export type LineSegment<P extends LocalPoint | GlobalPoint> = [P, P];
|
|
4
4
|
export declare function getBBox<P extends LocalPoint | GlobalPoint>(line: LineSegment<P>): Bounds;
|
|
5
5
|
export declare function doBBoxesIntersect(a: Bounds, b: Bounds): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Bounds } from "@excalidraw/element
|
|
1
|
+
import type { Bounds } from "@excalidraw/element";
|
|
2
2
|
import type { ExcalidrawElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
3
3
|
type Element = NonDeletedExcalidrawElement;
|
|
4
4
|
type Elements = readonly NonDeletedExcalidrawElement[];
|
package/history.ts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { Emitter } from "@excalidraw/common";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
CaptureUpdateAction,
|
|
5
|
+
StoreChange,
|
|
6
|
+
StoreDelta,
|
|
7
|
+
type Store,
|
|
8
|
+
} from "@excalidraw/element";
|
|
9
|
+
|
|
10
|
+
import type { SceneElementsMap } from "@excalidraw/element/types";
|
|
11
|
+
|
|
12
|
+
import type { AppState } from "./types";
|
|
13
|
+
|
|
14
|
+
class HistoryEntry extends StoreDelta {}
|
|
15
|
+
|
|
16
|
+
export class HistoryChangedEvent {
|
|
17
|
+
constructor(
|
|
18
|
+
public readonly isUndoStackEmpty: boolean = true,
|
|
19
|
+
public readonly isRedoStackEmpty: boolean = true,
|
|
20
|
+
) {}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class History {
|
|
24
|
+
public readonly onHistoryChangedEmitter = new Emitter<
|
|
25
|
+
[HistoryChangedEvent]
|
|
26
|
+
>();
|
|
27
|
+
|
|
28
|
+
public readonly undoStack: HistoryEntry[] = [];
|
|
29
|
+
public readonly redoStack: HistoryEntry[] = [];
|
|
30
|
+
|
|
31
|
+
public get isUndoStackEmpty() {
|
|
32
|
+
return this.undoStack.length === 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public get isRedoStackEmpty() {
|
|
36
|
+
return this.redoStack.length === 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
constructor(private readonly store: Store) {}
|
|
40
|
+
|
|
41
|
+
public clear() {
|
|
42
|
+
this.undoStack.length = 0;
|
|
43
|
+
this.redoStack.length = 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Record a non-empty local durable increment, which will go into the undo stack..
|
|
48
|
+
* Do not re-record history entries, which were already pushed to undo / redo stack, as part of history action.
|
|
49
|
+
*/
|
|
50
|
+
public record(delta: StoreDelta) {
|
|
51
|
+
if (delta.isEmpty() || delta instanceof HistoryEntry) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// construct history entry, so once it's emitted, it's not recorded again
|
|
56
|
+
const entry = HistoryEntry.inverse(delta);
|
|
57
|
+
|
|
58
|
+
this.undoStack.push(entry);
|
|
59
|
+
|
|
60
|
+
if (!entry.elements.isEmpty()) {
|
|
61
|
+
// don't reset redo stack on local appState changes,
|
|
62
|
+
// as a simple click (unselect) could lead to losing all the redo entries
|
|
63
|
+
// only reset on non empty elements changes!
|
|
64
|
+
this.redoStack.length = 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
this.onHistoryChangedEmitter.trigger(
|
|
68
|
+
new HistoryChangedEvent(this.isUndoStackEmpty, this.isRedoStackEmpty),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public undo(elements: SceneElementsMap, appState: AppState) {
|
|
73
|
+
return this.perform(
|
|
74
|
+
elements,
|
|
75
|
+
appState,
|
|
76
|
+
() => History.pop(this.undoStack),
|
|
77
|
+
(entry: HistoryEntry) => History.push(this.redoStack, entry, elements),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public redo(elements: SceneElementsMap, appState: AppState) {
|
|
82
|
+
return this.perform(
|
|
83
|
+
elements,
|
|
84
|
+
appState,
|
|
85
|
+
() => History.pop(this.redoStack),
|
|
86
|
+
(entry: HistoryEntry) => History.push(this.undoStack, entry, elements),
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private perform(
|
|
91
|
+
elements: SceneElementsMap,
|
|
92
|
+
appState: AppState,
|
|
93
|
+
pop: () => HistoryEntry | null,
|
|
94
|
+
push: (entry: HistoryEntry) => void,
|
|
95
|
+
): [SceneElementsMap, AppState] | void {
|
|
96
|
+
try {
|
|
97
|
+
let historyEntry = pop();
|
|
98
|
+
|
|
99
|
+
if (historyEntry === null) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const action = CaptureUpdateAction.IMMEDIATELY;
|
|
104
|
+
|
|
105
|
+
let prevSnapshot = this.store.snapshot;
|
|
106
|
+
|
|
107
|
+
let nextElements = elements;
|
|
108
|
+
let nextAppState = appState;
|
|
109
|
+
let containsVisibleChange = false;
|
|
110
|
+
|
|
111
|
+
// iterate through the history entries in case they result in no visible changes
|
|
112
|
+
while (historyEntry) {
|
|
113
|
+
try {
|
|
114
|
+
[nextElements, nextAppState, containsVisibleChange] =
|
|
115
|
+
StoreDelta.applyTo(
|
|
116
|
+
historyEntry,
|
|
117
|
+
nextElements,
|
|
118
|
+
nextAppState,
|
|
119
|
+
prevSnapshot,
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const nextSnapshot = prevSnapshot.maybeClone(
|
|
123
|
+
action,
|
|
124
|
+
nextElements,
|
|
125
|
+
nextAppState,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
// schedule immediate capture, so that it's emitted for the sync purposes
|
|
129
|
+
this.store.scheduleMicroAction({
|
|
130
|
+
action,
|
|
131
|
+
change: StoreChange.create(prevSnapshot, nextSnapshot),
|
|
132
|
+
delta: historyEntry,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
prevSnapshot = nextSnapshot;
|
|
136
|
+
} finally {
|
|
137
|
+
// make sure to always push, even if the delta is corrupted
|
|
138
|
+
push(historyEntry);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (containsVisibleChange) {
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
historyEntry = pop();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return [nextElements, nextAppState];
|
|
149
|
+
} finally {
|
|
150
|
+
// trigger the history change event before returning completely
|
|
151
|
+
// also trigger it just once, no need doing so on each entry
|
|
152
|
+
this.onHistoryChangedEmitter.trigger(
|
|
153
|
+
new HistoryChangedEvent(this.isUndoStackEmpty, this.isRedoStackEmpty),
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private static pop(stack: HistoryEntry[]): HistoryEntry | null {
|
|
159
|
+
if (!stack.length) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const entry = stack.pop();
|
|
164
|
+
|
|
165
|
+
if (entry !== undefined) {
|
|
166
|
+
return entry;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private static push(
|
|
173
|
+
stack: HistoryEntry[],
|
|
174
|
+
entry: HistoryEntry,
|
|
175
|
+
prevElements: SceneElementsMap,
|
|
176
|
+
) {
|
|
177
|
+
const inversedEntry = HistoryEntry.inverse(entry);
|
|
178
|
+
const updatedEntry = HistoryEntry.applyLatestChanges(
|
|
179
|
+
inversedEntry,
|
|
180
|
+
prevElements,
|
|
181
|
+
"inserted",
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
return stack.push(updatedEntry);
|
|
185
|
+
}
|
|
186
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dwelle/excalidraw",
|
|
3
|
-
"version": "0.5.0-
|
|
3
|
+
"version": "0.5.0-ffade30",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/types/excalidraw/index.d.ts",
|
|
6
6
|
"main": "./dist/prod/index.js",
|
|
@@ -70,11 +70,13 @@
|
|
|
70
70
|
"@excalidraw/mermaid-to-excalidraw": "1.1.2",
|
|
71
71
|
"@excalidraw/random-username": "1.1.0",
|
|
72
72
|
"@radix-ui/react-popover": "1.1.6",
|
|
73
|
-
"@radix-ui/react-tabs": "1.
|
|
73
|
+
"@radix-ui/react-tabs": "1.1.3",
|
|
74
74
|
"browser-fs-access": "0.29.1",
|
|
75
75
|
"canvas-roundrect-polyfill": "0.0.1",
|
|
76
76
|
"clsx": "1.1.1",
|
|
77
77
|
"cross-env": "7.0.3",
|
|
78
|
+
"es6-promise-pool": "2.5.0",
|
|
79
|
+
"fractional-indexing": "3.2.0",
|
|
78
80
|
"fuzzy": "0.1.3",
|
|
79
81
|
"image-blob-reduce": "3.0.1",
|
|
80
82
|
"jotai": "2.11.0",
|
|
@@ -82,11 +84,14 @@
|
|
|
82
84
|
"lodash.throttle": "4.1.1",
|
|
83
85
|
"lodash.debounce": "4.0.8",
|
|
84
86
|
"nanoid": "3.3.3",
|
|
87
|
+
"open-color": "1.9.1",
|
|
85
88
|
"pako": "2.0.3",
|
|
89
|
+
"perfect-freehand": "1.2.0",
|
|
86
90
|
"pica": "7.1.1",
|
|
87
91
|
"png-chunk-text": "1.0.0",
|
|
88
92
|
"png-chunks-encode": "1.0.0",
|
|
89
93
|
"png-chunks-extract": "1.0.0",
|
|
94
|
+
"points-on-curve": "1.0.1",
|
|
90
95
|
"pwacompat": "2.0.17",
|
|
91
96
|
"roughjs": "4.6.4",
|
|
92
97
|
"sass": "1.51.0",
|
|
@@ -118,7 +123,7 @@
|
|
|
118
123
|
"homepage": "https://github.com/excalidraw/excalidraw/tree/master/src/packages/excalidraw",
|
|
119
124
|
"repository": "https://github.com/dwelle/excalidraw",
|
|
120
125
|
"scripts": {
|
|
121
|
-
"gen:types": "
|
|
122
|
-
"build:esm": "
|
|
126
|
+
"gen:types": "rimraf types && tsc",
|
|
127
|
+
"build:esm": "rimraf dist && node ../../scripts/buildPackage.js && yarn gen:types"
|
|
123
128
|
}
|
|
124
129
|
}
|