@excalidraw/excalidraw 0.18.0-864353b → 0.18.0-9036812b6
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/{chunk-BBNNHA7I.js → chunk-CP5DND7P.js} +2 -2
- package/dist/dev/{chunk-BBNNHA7I.js.map → chunk-CP5DND7P.js.map} +1 -1
- package/dist/dev/chunk-FRLWKCNE.js +5668 -0
- package/dist/dev/chunk-FRLWKCNE.js.map +7 -0
- package/dist/dev/{chunk-7YMZV3TY.js → chunk-QF5FRM6O.js} +2 -2
- package/dist/dev/{chunk-7YMZV3TY.js.map → chunk-QF5FRM6O.js.map} +2 -2
- package/dist/dev/data/{image-OFYK7EOY.js → image-T2LJEHDP.js} +3 -3
- package/dist/dev/index.css +4 -0
- package/dist/dev/index.css.map +2 -2
- package/dist/dev/index.js +6280 -4106
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-KIY5SGI3.js → en-SMAPCEOQ.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-UH6Q3EIV.js → chunk-A66AFZZU.js} +1 -1
- package/dist/prod/{chunk-OUULIERA.js → chunk-I4UNSFV6.js} +3 -3
- package/dist/prod/chunk-YZO7PSYQ.js +4 -0
- package/dist/prod/data/image-53OPA26C.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +25 -18
- package/dist/prod/locales/{en-GCLCIHXH.js → en-TYY6KWIJ.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/constants.d.ts +12 -2
- package/dist/types/common/src/utils.d.ts +3 -5
- package/dist/types/element/src/Scene.d.ts +1 -1
- package/dist/types/element/src/align.d.ts +2 -1
- package/dist/types/element/src/binding.d.ts +10 -7
- package/dist/types/element/src/bounds.d.ts +11 -3
- package/dist/types/element/src/collision.d.ts +18 -12
- package/dist/types/element/src/cropElement.d.ts +1 -1
- package/dist/types/element/src/delta.d.ts +37 -8
- package/dist/types/element/src/distance.d.ts +2 -2
- package/dist/types/element/src/distribute.d.ts +2 -1
- package/dist/types/element/src/fractionalIndex.d.ts +8 -2
- package/dist/types/element/src/frame.d.ts +2 -2
- package/dist/types/element/src/groups.d.ts +1 -0
- package/dist/types/element/src/index.d.ts +1 -3
- package/dist/types/element/src/linearElementEditor.d.ts +5 -7
- package/dist/types/element/src/mutateElement.d.ts +1 -1
- package/dist/types/element/src/resizeElements.d.ts +1 -0
- package/dist/types/element/src/selection.d.ts +1 -1
- package/dist/types/element/src/shape.d.ts +42 -0
- package/dist/types/element/src/store.d.ts +13 -8
- package/dist/types/element/src/transformHandles.d.ts +4 -4
- package/dist/types/element/src/typeChecks.d.ts +4 -0
- package/dist/types/element/src/types.d.ts +1 -1
- package/dist/types/element/src/utils.d.ts +16 -6
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +9 -15
- package/dist/types/excalidraw/actions/actionAlign.d.ts +8 -8
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +6 -10
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +129 -155
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +25 -36
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +3 -5
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +14 -20
- 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 +2 -4
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +8 -12
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +3 -5
- package/dist/types/excalidraw/actions/actionExport.d.ts +112 -130
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +9 -12
- package/dist/types/excalidraw/actions/actionFlip.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionFrame.d.ts +62 -70
- package/dist/types/excalidraw/actions/actionGroup.d.ts +12 -16
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +84 -55
- package/dist/types/excalidraw/actions/actionLink.d.ts +4 -6
- package/dist/types/excalidraw/actions/actionMenu.d.ts +10 -16
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +6 -10
- package/dist/types/excalidraw/actions/actionProperties.d.ts +49 -79
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +6 -8
- package/dist/types/excalidraw/actions/actionStyles.d.ts +7 -9
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +5 -7
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +5 -7
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +4 -6
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +5 -7
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +5 -7
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +5 -7
- package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
- package/dist/types/excalidraw/appState.d.ts +20 -20
- package/dist/types/excalidraw/components/Actions.d.ts +0 -4
- package/dist/types/excalidraw/components/App.d.ts +14 -16
- package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +11 -1
- 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/reconcile.d.ts +1 -0
- package/dist/types/excalidraw/eraser/index.d.ts +0 -2
- package/dist/types/excalidraw/history.d.ts +21 -5
- package/dist/types/excalidraw/index.d.ts +1 -0
- package/dist/types/excalidraw/lasso/utils.d.ts +2 -1
- package/dist/types/excalidraw/renderer/helpers.d.ts +3 -3
- package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
- package/dist/types/excalidraw/scene/Renderer.d.ts +0 -1
- package/dist/types/excalidraw/types.d.ts +6 -8
- package/dist/types/math/src/constants.d.ts +3 -0
- package/dist/types/math/src/curve.d.ts +32 -0
- package/dist/types/math/src/index.d.ts +1 -0
- package/dist/types/math/src/rectangle.d.ts +2 -0
- package/dist/types/math/src/vector.d.ts +4 -2
- package/history.ts +108 -45
- package/package.json +12 -9
- package/dist/dev/chunk-LL55DS44.js +0 -23677
- package/dist/dev/chunk-LL55DS44.js.map +0 -7
- package/dist/prod/chunk-F44EGBV2.js +0 -33
- package/dist/prod/data/image-CUOH64HE.js +0 -1
- package/dist/types/element/src/Shape.d.ts +0 -17
- package/dist/types/element/src/ShapeCache.d.ts +0 -25
- package/dist/types/element/src/shapes.d.ts +0 -27
- package/dist/types/excalidraw/visualdebug.d.ts +0 -41
- package/dist/types/utils/src/collision.d.ts +0 -8
- /package/dist/dev/data/{image-OFYK7EOY.js.map → image-T2LJEHDP.js.map} +0 -0
- /package/dist/dev/locales/{en-KIY5SGI3.js.map → en-SMAPCEOQ.js.map} +0 -0
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import { Emitter } from "@excalidraw/common";
|
|
2
|
-
import { StoreDelta
|
|
2
|
+
import { StoreDelta } from "@excalidraw/element";
|
|
3
|
+
import type { StoreSnapshot, Store } from "@excalidraw/element";
|
|
3
4
|
import type { SceneElementsMap } from "@excalidraw/element/types";
|
|
4
5
|
import type { AppState } from "./types";
|
|
5
|
-
declare class
|
|
6
|
+
export declare class HistoryDelta extends StoreDelta {
|
|
7
|
+
/**
|
|
8
|
+
* Apply the delta to the passed elements and appState, does not modify the snapshot.
|
|
9
|
+
*/
|
|
10
|
+
applyTo(elements: SceneElementsMap, appState: AppState, snapshot: StoreSnapshot): [SceneElementsMap, AppState, boolean];
|
|
11
|
+
/**
|
|
12
|
+
* Overriding once to avoid type casting everywhere.
|
|
13
|
+
*/
|
|
14
|
+
static calculate(prevSnapshot: StoreSnapshot, nextSnapshot: StoreSnapshot): HistoryDelta;
|
|
15
|
+
/**
|
|
16
|
+
* Overriding once to avoid type casting everywhere.
|
|
17
|
+
*/
|
|
18
|
+
static inverse(delta: StoreDelta): HistoryDelta;
|
|
19
|
+
/**
|
|
20
|
+
* Overriding once to avoid type casting everywhere.
|
|
21
|
+
*/
|
|
22
|
+
static applyLatestChanges(delta: StoreDelta, prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): HistoryDelta;
|
|
6
23
|
}
|
|
7
24
|
export declare class HistoryChangedEvent {
|
|
8
25
|
readonly isUndoStackEmpty: boolean;
|
|
@@ -12,8 +29,8 @@ export declare class HistoryChangedEvent {
|
|
|
12
29
|
export declare class History {
|
|
13
30
|
private readonly store;
|
|
14
31
|
readonly onHistoryChangedEmitter: Emitter<[HistoryChangedEvent]>;
|
|
15
|
-
readonly undoStack:
|
|
16
|
-
readonly redoStack:
|
|
32
|
+
readonly undoStack: HistoryDelta[];
|
|
33
|
+
readonly redoStack: HistoryDelta[];
|
|
17
34
|
get isUndoStackEmpty(): boolean;
|
|
18
35
|
get isRedoStackEmpty(): boolean;
|
|
19
36
|
constructor(store: Store);
|
|
@@ -29,4 +46,3 @@ export declare class History {
|
|
|
29
46
|
private static pop;
|
|
30
47
|
private static push;
|
|
31
48
|
}
|
|
32
|
-
export {};
|
|
@@ -29,6 +29,7 @@ export { Sidebar } from "./components/Sidebar/Sidebar";
|
|
|
29
29
|
export { Button } from "./components/Button";
|
|
30
30
|
export { Footer };
|
|
31
31
|
export { MainMenu };
|
|
32
|
+
export { Ellipsify } from "./components/Ellipsify";
|
|
32
33
|
export { useDevice } from "./components/App";
|
|
33
34
|
export { WelcomeScreen };
|
|
34
35
|
export { LiveCollaborationTrigger };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ElementsSegmentsMap, GlobalPoint } from "@excalidraw/math/types";
|
|
2
|
-
import type { ExcalidrawElement } from "@excalidraw/element/types";
|
|
2
|
+
import type { ElementsMap, ExcalidrawElement } from "@excalidraw/element/types";
|
|
3
3
|
export declare const getLassoSelectedElementIds: (input: {
|
|
4
4
|
lassoPath: GlobalPoint[];
|
|
5
5
|
elements: readonly ExcalidrawElement[];
|
|
6
|
+
elementsMap: ElementsMap;
|
|
6
7
|
elementsSegments: ElementsSegmentsMap;
|
|
7
8
|
intersectedElements: Set<ExcalidrawElement["id"]>;
|
|
8
9
|
enclosedElements: Set<ExcalidrawElement["id"]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExcalidrawDiamondElement, ExcalidrawRectanguloidElement } from "@excalidraw/element/types";
|
|
1
|
+
import type { ElementsMap, ExcalidrawDiamondElement, ExcalidrawRectanguloidElement } from "@excalidraw/element/types";
|
|
2
2
|
import type { StaticCanvasRenderConfig } from "../scene/types";
|
|
3
3
|
import type { AppState, StaticCanvasAppState } from "../types";
|
|
4
4
|
export declare const fillCircle: (context: CanvasRenderingContext2D, cx: number, cy: number, radius: number, stroke: boolean, fill?: boolean) => void;
|
|
@@ -12,7 +12,7 @@ export declare const bootstrapCanvas: ({ canvas, scale, normalizedWidth, normali
|
|
|
12
12
|
isExporting?: boolean | undefined;
|
|
13
13
|
viewBackgroundColor?: string | null | undefined;
|
|
14
14
|
}) => CanvasRenderingContext2D;
|
|
15
|
-
export declare const drawHighlightForRectWithRotation: (context: CanvasRenderingContext2D, element: ExcalidrawRectanguloidElement, padding: number) => void;
|
|
15
|
+
export declare const drawHighlightForRectWithRotation: (context: CanvasRenderingContext2D, element: ExcalidrawRectanguloidElement, elementsMap: ElementsMap, padding: number) => void;
|
|
16
16
|
export declare const strokeEllipseWithRotation: (context: CanvasRenderingContext2D, width: number, height: number, cx: number, cy: number, angle: number) => void;
|
|
17
17
|
export declare const strokeRectWithRotation: (context: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, cx: number, cy: number, angle: number, fill?: boolean, radius?: number) => void;
|
|
18
|
-
export declare const drawHighlightForDiamondWithRotation: (context: CanvasRenderingContext2D, padding: number, element: ExcalidrawDiamondElement) => void;
|
|
18
|
+
export declare const drawHighlightForDiamondWithRotation: (context: CanvasRenderingContext2D, padding: number, element: ExcalidrawDiamondElement, elementsMap: ElementsMap) => void;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExcalidrawFrameLikeElement } from "@excalidraw/element/types";
|
|
2
|
+
import type { StaticCanvasRenderConfig, StaticSceneRenderConfig } from "../scene/types";
|
|
3
|
+
import type { StaticCanvasAppState } from "../types";
|
|
4
|
+
export declare const frameClip: (frame: ExcalidrawFrameLikeElement, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState) => void;
|
|
2
5
|
/** throttled to animation framerate */
|
|
3
6
|
export declare const renderStaticSceneThrottled: {
|
|
4
7
|
(config: StaticSceneRenderConfig): void;
|
|
@@ -16,7 +16,6 @@ export declare class Renderer {
|
|
|
16
16
|
/** note: first render of newElement will always bust the cache
|
|
17
17
|
* (we'd have to prefilter elements outside of this function) */
|
|
18
18
|
newElementId: ExcalidrawElement["id"] | undefined;
|
|
19
|
-
pendingImageElementId: AppState["pendingImageElementId"];
|
|
20
19
|
sceneNonce: ReturnType<InstanceType<typeof Scene>["getSceneNonce"]>;
|
|
21
20
|
}) => {
|
|
22
21
|
elementsMap: Map<string, NonDeletedExcalidrawElement> & import("@excalidraw/common/utility-types").MakeBrand<"NonDeletedElementsMap"> & import("@excalidraw/common/utility-types").MakeBrand<"RenderableElementsMap">;
|
|
@@ -2,7 +2,7 @@ import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES } from "@
|
|
|
2
2
|
import type { SuggestedBinding } from "@excalidraw/element";
|
|
3
3
|
import type { LinearElementEditor } from "@excalidraw/element";
|
|
4
4
|
import type { MaybeTransformHandleType } from "@excalidraw/element";
|
|
5
|
-
import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId,
|
|
5
|
+
import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, 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
7
|
import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
|
|
8
8
|
import type { Action } from "./actions/types";
|
|
@@ -113,7 +113,6 @@ type _CommonCanvasAppState = {
|
|
|
113
113
|
offsetLeft: AppState["offsetLeft"];
|
|
114
114
|
offsetTop: AppState["offsetTop"];
|
|
115
115
|
theme: AppState["theme"];
|
|
116
|
-
pendingImageElementId: AppState["pendingImageElementId"];
|
|
117
116
|
};
|
|
118
117
|
export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
119
118
|
shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
|
|
@@ -130,7 +129,6 @@ export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
130
129
|
}>;
|
|
131
130
|
export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
132
131
|
activeEmbeddable: AppState["activeEmbeddable"];
|
|
133
|
-
editingLinearElement: AppState["editingLinearElement"];
|
|
134
132
|
selectionElement: AppState["selectionElement"];
|
|
135
133
|
selectedGroupIds: AppState["selectedGroupIds"];
|
|
136
134
|
selectedLinearElement: AppState["selectedLinearElement"];
|
|
@@ -157,8 +155,10 @@ export type ObservedElementsAppState = {
|
|
|
157
155
|
editingGroupId: AppState["editingGroupId"];
|
|
158
156
|
selectedElementIds: AppState["selectedElementIds"];
|
|
159
157
|
selectedGroupIds: AppState["selectedGroupIds"];
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
selectedLinearElement: {
|
|
159
|
+
elementId: LinearElementEditor["elementId"];
|
|
160
|
+
isEditing: boolean;
|
|
161
|
+
} | null;
|
|
162
162
|
croppingElementId: AppState["croppingElementId"];
|
|
163
163
|
lockedMultiSelections: AppState["lockedMultiSelections"];
|
|
164
164
|
activeLockedId: AppState["activeLockedId"];
|
|
@@ -212,7 +212,6 @@ export interface AppState {
|
|
|
212
212
|
* set when a new text is created or when an existing text is being edited
|
|
213
213
|
*/
|
|
214
214
|
editingTextElement: NonDeletedExcalidrawElement | null;
|
|
215
|
-
editingLinearElement: LinearElementEditor | null;
|
|
216
215
|
activeTool: {
|
|
217
216
|
/**
|
|
218
217
|
* indicates a previous tool we should revert back to if we deselect the
|
|
@@ -327,8 +326,6 @@ export interface AppState {
|
|
|
327
326
|
shown: true;
|
|
328
327
|
data: Spreadsheet;
|
|
329
328
|
};
|
|
330
|
-
/** imageElement waiting to be placed on canvas */
|
|
331
|
-
pendingImageElementId: ExcalidrawImageElement["id"] | null;
|
|
332
329
|
showHyperlinkPopup: false | "info" | "editor";
|
|
333
330
|
selectedLinearElement: LinearElementEditor | null;
|
|
334
331
|
snapLines: readonly SnapLine[];
|
|
@@ -625,6 +622,7 @@ export interface ExcalidrawImperativeAPI {
|
|
|
625
622
|
updateLibrary: InstanceType<typeof Library>["updateLibrary"];
|
|
626
623
|
resetScene: InstanceType<typeof App>["resetScene"];
|
|
627
624
|
getSceneElementsIncludingDeleted: InstanceType<typeof App>["getSceneElementsIncludingDeleted"];
|
|
625
|
+
getSceneElementsMapIncludingDeleted: InstanceType<typeof App>["getSceneElementsMapIncludingDeleted"];
|
|
628
626
|
history: {
|
|
629
627
|
clear: InstanceType<typeof App>["resetHistory"];
|
|
630
628
|
};
|
|
@@ -40,3 +40,35 @@ export declare function curvePointDistance<Point extends GlobalPoint | LocalPoin
|
|
|
40
40
|
*/
|
|
41
41
|
export declare function isCurve<P extends GlobalPoint | LocalPoint>(v: unknown): v is Curve<P>;
|
|
42
42
|
export declare function curveTangent<Point extends GlobalPoint | LocalPoint>([p0, p1, p2, p3]: Curve<Point>, t: number): import("./types").Vector;
|
|
43
|
+
export declare function curveCatmullRomQuadraticApproxPoints(points: GlobalPoint[], tension?: number): [GlobalPoint, GlobalPoint][] | undefined;
|
|
44
|
+
export declare function curveCatmullRomCubicApproxPoints<Point extends GlobalPoint | LocalPoint>(points: Point[], tension?: number): Curve<Point>[] | undefined;
|
|
45
|
+
export declare function curveOffsetPoints([p0, p1, p2, p3]: Curve<GlobalPoint>, offset: number, steps?: number): GlobalPoint[];
|
|
46
|
+
export declare function offsetPointsForQuadraticBezier(p0: GlobalPoint, p1: GlobalPoint, p2: GlobalPoint, offsetDist: number, steps?: number): GlobalPoint[];
|
|
47
|
+
/**
|
|
48
|
+
* Implementation based on Legendre-Gauss quadrature for more accurate arc
|
|
49
|
+
* length calculation.
|
|
50
|
+
*
|
|
51
|
+
* Reference: https://pomax.github.io/bezierinfo/#arclength
|
|
52
|
+
*
|
|
53
|
+
* @param c The curve to calculate the length of
|
|
54
|
+
* @returns The approximated length of the curve
|
|
55
|
+
*/
|
|
56
|
+
export declare function curveLength<P extends GlobalPoint | LocalPoint>(c: Curve<P>): number;
|
|
57
|
+
/**
|
|
58
|
+
* Calculates the curve length from t=0 to t=parameter using the same
|
|
59
|
+
* Legendre-Gauss quadrature method used in curveLength
|
|
60
|
+
*
|
|
61
|
+
* @param c The curve to calculate the partial length for
|
|
62
|
+
* @param t The parameter value (0 to 1) to calculate length up to
|
|
63
|
+
* @returns The length of the curve from beginning to parameter t
|
|
64
|
+
*/
|
|
65
|
+
export declare function curveLengthAtParameter<P extends GlobalPoint | LocalPoint>(c: Curve<P>, t: number): number;
|
|
66
|
+
/**
|
|
67
|
+
* Calculates the point at a specific percentage of a curve's total length
|
|
68
|
+
* using binary search for improved efficiency and accuracy.
|
|
69
|
+
*
|
|
70
|
+
* @param c The curve to calculate point on
|
|
71
|
+
* @param percent A value between 0 and 1 representing the percentage of the curve's length
|
|
72
|
+
* @returns The point at the specified percentage of curve length
|
|
73
|
+
*/
|
|
74
|
+
export declare function curvePointAtLength<P extends GlobalPoint | LocalPoint>(c: Curve<P>, percent: number): P;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { GlobalPoint, LineSegment, LocalPoint, Rectangle } from "./types";
|
|
2
2
|
export declare function rectangle<P extends GlobalPoint | LocalPoint>(topLeft: P, bottomRight: P): Rectangle<P>;
|
|
3
|
+
export declare function rectangleFromNumberSequence<Point extends LocalPoint | GlobalPoint>(minX: number, minY: number, maxX: number, maxY: number): Rectangle<Point>;
|
|
3
4
|
export declare function rectangleIntersectLineSegment<Point extends LocalPoint | GlobalPoint>(r: Rectangle<Point>, l: LineSegment<Point>): Point[];
|
|
5
|
+
export declare function rectangleIntersectRectangle<Point extends LocalPoint | GlobalPoint>(rectangle1: Rectangle<Point>, rectangle2: Rectangle<Point>): boolean;
|
|
@@ -12,9 +12,11 @@ export declare function vector(x: number, y: number, originX?: number, originY?:
|
|
|
12
12
|
*
|
|
13
13
|
* @param p The point to turn into a vector
|
|
14
14
|
* @param origin The origin point in a given coordiante system
|
|
15
|
-
* @
|
|
15
|
+
* @param threshold The threshold to consider the vector as 'undefined'
|
|
16
|
+
* @param defaultValue The default value to return if the vector is 'undefined'
|
|
17
|
+
* @returns The created vector from the point and the origin or default
|
|
16
18
|
*/
|
|
17
|
-
export declare function vectorFromPoint<Point extends GlobalPoint | LocalPoint>(p: Point, origin?: Point): Vector;
|
|
19
|
+
export declare function vectorFromPoint<Point extends GlobalPoint | LocalPoint>(p: Point, origin?: Point, threshold?: number, defaultValue?: Vector): Vector;
|
|
18
20
|
/**
|
|
19
21
|
* Cross product is a binary operation on two vectors in 2D space.
|
|
20
22
|
* It results in a vector that is perpendicular to both vectors.
|
package/history.ts
CHANGED
|
@@ -4,14 +4,81 @@ import {
|
|
|
4
4
|
CaptureUpdateAction,
|
|
5
5
|
StoreChange,
|
|
6
6
|
StoreDelta,
|
|
7
|
-
type Store,
|
|
8
7
|
} from "@excalidraw/element";
|
|
9
8
|
|
|
9
|
+
import type { StoreSnapshot, Store } from "@excalidraw/element";
|
|
10
|
+
|
|
10
11
|
import type { SceneElementsMap } from "@excalidraw/element/types";
|
|
11
12
|
|
|
12
13
|
import type { AppState } from "./types";
|
|
13
14
|
|
|
14
|
-
class
|
|
15
|
+
export class HistoryDelta extends StoreDelta {
|
|
16
|
+
/**
|
|
17
|
+
* Apply the delta to the passed elements and appState, does not modify the snapshot.
|
|
18
|
+
*/
|
|
19
|
+
public applyTo(
|
|
20
|
+
elements: SceneElementsMap,
|
|
21
|
+
appState: AppState,
|
|
22
|
+
snapshot: StoreSnapshot,
|
|
23
|
+
): [SceneElementsMap, AppState, boolean] {
|
|
24
|
+
const [nextElements, elementsContainVisibleChange] = this.elements.applyTo(
|
|
25
|
+
elements,
|
|
26
|
+
// used to fallback into local snapshot in case we couldn't apply the delta
|
|
27
|
+
// due to a missing (force deleted) elements in the scene
|
|
28
|
+
snapshot.elements,
|
|
29
|
+
// we don't want to apply the `version` and `versionNonce` properties for history
|
|
30
|
+
// as we always need to end up with a new version due to collaboration,
|
|
31
|
+
// approaching each undo / redo as a new user action
|
|
32
|
+
{
|
|
33
|
+
excludedProperties: new Set(["version", "versionNonce"]),
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const [nextAppState, appStateContainsVisibleChange] = this.appState.applyTo(
|
|
38
|
+
appState,
|
|
39
|
+
nextElements,
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const appliedVisibleChanges =
|
|
43
|
+
elementsContainVisibleChange || appStateContainsVisibleChange;
|
|
44
|
+
|
|
45
|
+
return [nextElements, nextAppState, appliedVisibleChanges];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Overriding once to avoid type casting everywhere.
|
|
50
|
+
*/
|
|
51
|
+
public static override calculate(
|
|
52
|
+
prevSnapshot: StoreSnapshot,
|
|
53
|
+
nextSnapshot: StoreSnapshot,
|
|
54
|
+
) {
|
|
55
|
+
return super.calculate(prevSnapshot, nextSnapshot) as HistoryDelta;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Overriding once to avoid type casting everywhere.
|
|
60
|
+
*/
|
|
61
|
+
public static override inverse(delta: StoreDelta): HistoryDelta {
|
|
62
|
+
return super.inverse(delta) as HistoryDelta;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Overriding once to avoid type casting everywhere.
|
|
67
|
+
*/
|
|
68
|
+
public static override applyLatestChanges(
|
|
69
|
+
delta: StoreDelta,
|
|
70
|
+
prevElements: SceneElementsMap,
|
|
71
|
+
nextElements: SceneElementsMap,
|
|
72
|
+
modifierOptions?: "deleted" | "inserted",
|
|
73
|
+
) {
|
|
74
|
+
return super.applyLatestChanges(
|
|
75
|
+
delta,
|
|
76
|
+
prevElements,
|
|
77
|
+
nextElements,
|
|
78
|
+
modifierOptions,
|
|
79
|
+
) as HistoryDelta;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
15
82
|
|
|
16
83
|
export class HistoryChangedEvent {
|
|
17
84
|
constructor(
|
|
@@ -25,8 +92,8 @@ export class History {
|
|
|
25
92
|
[HistoryChangedEvent]
|
|
26
93
|
>();
|
|
27
94
|
|
|
28
|
-
public readonly undoStack:
|
|
29
|
-
public readonly redoStack:
|
|
95
|
+
public readonly undoStack: HistoryDelta[] = [];
|
|
96
|
+
public readonly redoStack: HistoryDelta[] = [];
|
|
30
97
|
|
|
31
98
|
public get isUndoStackEmpty() {
|
|
32
99
|
return this.undoStack.length === 0;
|
|
@@ -48,16 +115,16 @@ export class History {
|
|
|
48
115
|
* Do not re-record history entries, which were already pushed to undo / redo stack, as part of history action.
|
|
49
116
|
*/
|
|
50
117
|
public record(delta: StoreDelta) {
|
|
51
|
-
if (delta.isEmpty() || delta instanceof
|
|
118
|
+
if (delta.isEmpty() || delta instanceof HistoryDelta) {
|
|
52
119
|
return;
|
|
53
120
|
}
|
|
54
121
|
|
|
55
122
|
// construct history entry, so once it's emitted, it's not recorded again
|
|
56
|
-
const
|
|
123
|
+
const historyDelta = HistoryDelta.inverse(delta);
|
|
57
124
|
|
|
58
|
-
this.undoStack.push(
|
|
125
|
+
this.undoStack.push(historyDelta);
|
|
59
126
|
|
|
60
|
-
if (!
|
|
127
|
+
if (!historyDelta.elements.isEmpty()) {
|
|
61
128
|
// don't reset redo stack on local appState changes,
|
|
62
129
|
// as a simple click (unselect) could lead to losing all the redo entries
|
|
63
130
|
// only reset on non empty elements changes!
|
|
@@ -74,7 +141,7 @@ export class History {
|
|
|
74
141
|
elements,
|
|
75
142
|
appState,
|
|
76
143
|
() => History.pop(this.undoStack),
|
|
77
|
-
(entry:
|
|
144
|
+
(entry: HistoryDelta) => History.push(this.redoStack, entry),
|
|
78
145
|
);
|
|
79
146
|
}
|
|
80
147
|
|
|
@@ -83,20 +150,20 @@ export class History {
|
|
|
83
150
|
elements,
|
|
84
151
|
appState,
|
|
85
152
|
() => History.pop(this.redoStack),
|
|
86
|
-
(entry:
|
|
153
|
+
(entry: HistoryDelta) => History.push(this.undoStack, entry),
|
|
87
154
|
);
|
|
88
155
|
}
|
|
89
156
|
|
|
90
157
|
private perform(
|
|
91
158
|
elements: SceneElementsMap,
|
|
92
159
|
appState: AppState,
|
|
93
|
-
pop: () =>
|
|
94
|
-
push: (entry:
|
|
160
|
+
pop: () => HistoryDelta | null,
|
|
161
|
+
push: (entry: HistoryDelta) => void,
|
|
95
162
|
): [SceneElementsMap, AppState] | void {
|
|
96
163
|
try {
|
|
97
|
-
let
|
|
164
|
+
let historyDelta = pop();
|
|
98
165
|
|
|
99
|
-
if (
|
|
166
|
+
if (historyDelta === null) {
|
|
100
167
|
return;
|
|
101
168
|
}
|
|
102
169
|
|
|
@@ -108,41 +175,47 @@ export class History {
|
|
|
108
175
|
let nextAppState = appState;
|
|
109
176
|
let containsVisibleChange = false;
|
|
110
177
|
|
|
111
|
-
// iterate through the history entries in case they result in no visible changes
|
|
112
|
-
while (
|
|
178
|
+
// iterate through the history entries in case ;they result in no visible changes
|
|
179
|
+
while (historyDelta) {
|
|
113
180
|
try {
|
|
114
181
|
[nextElements, nextAppState, containsVisibleChange] =
|
|
115
|
-
|
|
116
|
-
historyEntry,
|
|
117
|
-
nextElements,
|
|
118
|
-
nextAppState,
|
|
119
|
-
prevSnapshot,
|
|
120
|
-
);
|
|
182
|
+
historyDelta.applyTo(nextElements, nextAppState, prevSnapshot);
|
|
121
183
|
|
|
184
|
+
const prevElements = prevSnapshot.elements;
|
|
122
185
|
const nextSnapshot = prevSnapshot.maybeClone(
|
|
123
186
|
action,
|
|
124
187
|
nextElements,
|
|
125
188
|
nextAppState,
|
|
126
189
|
);
|
|
127
190
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
191
|
+
const change = StoreChange.create(prevSnapshot, nextSnapshot);
|
|
192
|
+
const delta = HistoryDelta.applyLatestChanges(
|
|
193
|
+
historyDelta,
|
|
194
|
+
prevElements,
|
|
195
|
+
nextElements,
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
if (!delta.isEmpty()) {
|
|
199
|
+
// schedule immediate capture, so that it's emitted for the sync purposes
|
|
200
|
+
this.store.scheduleMicroAction({
|
|
201
|
+
action,
|
|
202
|
+
change,
|
|
203
|
+
delta,
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
historyDelta = delta;
|
|
207
|
+
}
|
|
134
208
|
|
|
135
209
|
prevSnapshot = nextSnapshot;
|
|
136
210
|
} finally {
|
|
137
|
-
|
|
138
|
-
push(historyEntry);
|
|
211
|
+
push(historyDelta);
|
|
139
212
|
}
|
|
140
213
|
|
|
141
214
|
if (containsVisibleChange) {
|
|
142
215
|
break;
|
|
143
216
|
}
|
|
144
217
|
|
|
145
|
-
|
|
218
|
+
historyDelta = pop();
|
|
146
219
|
}
|
|
147
220
|
|
|
148
221
|
return [nextElements, nextAppState];
|
|
@@ -155,7 +228,7 @@ export class History {
|
|
|
155
228
|
}
|
|
156
229
|
}
|
|
157
230
|
|
|
158
|
-
private static pop(stack:
|
|
231
|
+
private static pop(stack: HistoryDelta[]): HistoryDelta | null {
|
|
159
232
|
if (!stack.length) {
|
|
160
233
|
return null;
|
|
161
234
|
}
|
|
@@ -169,18 +242,8 @@ export class History {
|
|
|
169
242
|
return null;
|
|
170
243
|
}
|
|
171
244
|
|
|
172
|
-
private static push(
|
|
173
|
-
|
|
174
|
-
|
|
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);
|
|
245
|
+
private static push(stack: HistoryDelta[], entry: HistoryDelta) {
|
|
246
|
+
const inversedEntry = HistoryDelta.inverse(entry);
|
|
247
|
+
return stack.push(inversedEntry);
|
|
185
248
|
}
|
|
186
249
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@excalidraw/excalidraw",
|
|
3
|
-
"version": "0.18.0-
|
|
3
|
+
"version": "0.18.0-9036812b6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/types/excalidraw/index.d.ts",
|
|
6
6
|
"main": "./dist/prod/index.js",
|
|
@@ -66,12 +66,22 @@
|
|
|
66
66
|
"last 1 safari version"
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
|
+
"repository": "https://github.com/excalidraw/excalidraw",
|
|
70
|
+
"bugs": "https://github.com/excalidraw/excalidraw/issues",
|
|
71
|
+
"homepage": "https://github.com/excalidraw/excalidraw/tree/master/packages/excalidraw",
|
|
72
|
+
"scripts": {
|
|
73
|
+
"gen:types": "rimraf types && tsc",
|
|
74
|
+
"build:esm": "rimraf dist && node ../../scripts/buildPackage.js && yarn gen:types"
|
|
75
|
+
},
|
|
69
76
|
"peerDependencies": {
|
|
70
77
|
"react": "^17.0.2 || ^18.2.0 || ^19.0.0",
|
|
71
78
|
"react-dom": "^17.0.2 || ^18.2.0 || ^19.0.0"
|
|
72
79
|
},
|
|
73
80
|
"dependencies": {
|
|
74
81
|
"@braintree/sanitize-url": "6.0.2",
|
|
82
|
+
"@excalidraw/common": "0.18.0-9036812b6",
|
|
83
|
+
"@excalidraw/element": "0.18.0-9036812b6",
|
|
84
|
+
"@excalidraw/math": "0.18.0-9036812b6",
|
|
75
85
|
"@excalidraw/laser-pointer": "1.3.1",
|
|
76
86
|
"@excalidraw/mermaid-to-excalidraw": "1.1.2",
|
|
77
87
|
"@excalidraw/random-username": "1.1.0",
|
|
@@ -124,12 +134,5 @@
|
|
|
124
134
|
"harfbuzzjs": "0.3.6",
|
|
125
135
|
"jest-diff": "29.7.0",
|
|
126
136
|
"typescript": "4.9.4"
|
|
127
|
-
},
|
|
128
|
-
"repository": "https://github.com/excalidraw/excalidraw",
|
|
129
|
-
"bugs": "https://github.com/excalidraw/excalidraw/issues",
|
|
130
|
-
"homepage": "https://github.com/excalidraw/excalidraw/tree/master/packages/excalidraw",
|
|
131
|
-
"scripts": {
|
|
132
|
-
"gen:types": "rimraf types && tsc",
|
|
133
|
-
"build:esm": "rimraf dist && node ../../scripts/buildPackage.js && yarn gen:types"
|
|
134
137
|
}
|
|
135
|
-
}
|
|
138
|
+
}
|