@excalidraw/excalidraw 0.18.0-6fc8502 → 0.18.0-864353b
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-X3RYHLJU.js → chunk-7YMZV3TY.js} +14 -4
- package/dist/dev/chunk-7YMZV3TY.js.map +7 -0
- package/dist/dev/chunk-BBNNHA7I.js +7 -0
- package/dist/dev/chunk-BBNNHA7I.js.map +7 -0
- package/dist/dev/{chunk-KYBDXI6F.js → chunk-LL55DS44.js} +15037 -10099
- package/dist/dev/chunk-LL55DS44.js.map +7 -0
- package/dist/dev/data/{image-NKFINVKH.js → image-OFYK7EOY.js} +3 -3
- package/dist/dev/index.css +100 -22
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +3531 -6486
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-CKWC2GMK.js → en-KIY5SGI3.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-F44EGBV2.js +33 -0
- package/dist/prod/{chunk-IUH5AXLB.js → chunk-OUULIERA.js} +4 -4
- package/dist/prod/chunk-UH6Q3EIV.js +7 -0
- package/dist/prod/data/image-CUOH64HE.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +18 -17
- package/dist/prod/locales/{en-SBO6ZHT2.js → en-GCLCIHXH.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 +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 -4
- 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 -12
- package/dist/types/element/src/bounds.d.ts +2 -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/index.d.ts +45 -2
- package/dist/types/element/src/linearElementEditor.d.ts +20 -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 +2 -2
- 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 +39 -45
- package/dist/types/excalidraw/actions/actionAlign.d.ts +8 -8
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +26 -30
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +262 -288
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +81 -92
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +13 -15
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +38 -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 +13 -15
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +41 -46
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +13 -15
- package/dist/types/excalidraw/actions/actionExport.d.ts +210 -228
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +72 -36
- package/dist/types/excalidraw/actions/actionFlip.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionFrame.d.ts +96 -104
- package/dist/types/excalidraw/actions/actionGroup.d.ts +32 -36
- package/dist/types/excalidraw/actions/actionHistory.d.ts +1 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +505 -14
- package/dist/types/excalidraw/actions/actionLink.d.ts +13 -15
- package/dist/types/excalidraw/actions/actionMenu.d.ts +39 -45
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +25 -29
- package/dist/types/excalidraw/actions/actionProperties.d.ts +192 -214
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +15 -17
- package/dist/types/excalidraw/actions/actionStyles.d.ts +17 -19
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +15 -17
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +15 -17
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +15 -190
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +15 -17
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +15 -17
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +15 -17
- package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
- package/dist/types/excalidraw/actions/types.d.ts +4 -3
- package/dist/types/excalidraw/appState.d.ts +38 -29
- package/dist/types/excalidraw/components/App.d.ts +24 -11
- 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/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 +1 -1
- 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 +3 -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 +1 -0
- package/dist/types/excalidraw/lasso/utils.d.ts +1 -2
- package/dist/types/excalidraw/renderer/helpers.d.ts +7 -2
- package/dist/types/excalidraw/scene/Renderer.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 +28 -6
- package/dist/types/excalidraw/visualdebug.d.ts +1 -1
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +3 -1
- package/dist/types/math/src/angle.d.ts +2 -0
- 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/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 +68 -94
- package/package.json +3 -3
- package/dist/dev/chunk-H7XJ5UVD.js +0 -7
- package/dist/dev/chunk-H7XJ5UVD.js.map +0 -7
- package/dist/dev/chunk-KYBDXI6F.js.map +0 -7
- package/dist/dev/chunk-X3RYHLJU.js.map +0 -7
- package/dist/prod/chunk-CAN5RS4P.js +0 -31
- package/dist/prod/chunk-KJYFYP64.js +0 -7
- package/dist/prod/data/image-5XD47O4X.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-NKFINVKH.js.map → image-OFYK7EOY.js.map} +0 -0
- /package/dist/dev/locales/{en-CKWC2GMK.js.map → en-KIY5SGI3.js.map} +0 -0
|
@@ -15,3 +15,5 @@ export declare function radiansToDegrees(degrees: Radians): Degrees;
|
|
|
15
15
|
* @returns TRUE if the provided angle is a right angle
|
|
16
16
|
*/
|
|
17
17
|
export declare function isRightAngleRads(rads: Radians): boolean;
|
|
18
|
+
export declare function radiansBetweenAngles(a: Radians, min: Radians, max: Radians): boolean;
|
|
19
|
+
export declare function radiansDifference(a: Radians, b: Radians): Radians;
|
|
@@ -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
|
*
|
|
@@ -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
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Emitter } from "@excalidraw/common";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
CaptureUpdateAction,
|
|
5
|
+
StoreChange,
|
|
6
|
+
StoreDelta,
|
|
7
|
+
type Store,
|
|
8
|
+
} from "@excalidraw/element";
|
|
2
9
|
|
|
3
|
-
import {
|
|
10
|
+
import type { SceneElementsMap } from "@excalidraw/element/types";
|
|
4
11
|
|
|
5
|
-
import type { AppStateChange, ElementsChange } from "./change";
|
|
6
|
-
import type { Snapshot } from "./store";
|
|
7
12
|
import type { AppState } from "./types";
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
class HistoryEntry extends StoreDelta {}
|
|
10
15
|
|
|
11
16
|
export class HistoryChangedEvent {
|
|
12
17
|
constructor(
|
|
@@ -20,8 +25,8 @@ export class History {
|
|
|
20
25
|
[HistoryChangedEvent]
|
|
21
26
|
>();
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
public readonly undoStack: HistoryEntry[] = [];
|
|
29
|
+
public readonly redoStack: HistoryEntry[] = [];
|
|
25
30
|
|
|
26
31
|
public get isUndoStackEmpty() {
|
|
27
32
|
return this.undoStack.length === 0;
|
|
@@ -31,60 +36,52 @@ export class History {
|
|
|
31
36
|
return this.redoStack.length === 0;
|
|
32
37
|
}
|
|
33
38
|
|
|
39
|
+
constructor(private readonly store: Store) {}
|
|
40
|
+
|
|
34
41
|
public clear() {
|
|
35
42
|
this.undoStack.length = 0;
|
|
36
43
|
this.redoStack.length = 0;
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
/**
|
|
40
|
-
* Record a local
|
|
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.
|
|
41
49
|
*/
|
|
42
|
-
public record(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const entry = HistoryEntry.create(appStateChange, elementsChange);
|
|
50
|
+
public record(delta: StoreDelta) {
|
|
51
|
+
if (delta.isEmpty() || delta instanceof HistoryEntry) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.undoStack.push(entry.inverse());
|
|
55
|
+
// construct history entry, so once it's emitted, it's not recorded again
|
|
56
|
+
const entry = HistoryEntry.inverse(delta);
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
// don't reset redo stack on local appState changes,
|
|
54
|
-
// as a simple click (unselect) could lead to losing all the redo entries
|
|
55
|
-
// only reset on non empty elements changes!
|
|
56
|
-
this.redoStack.length = 0;
|
|
57
|
-
}
|
|
58
|
+
this.undoStack.push(entry);
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
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;
|
|
62
65
|
}
|
|
66
|
+
|
|
67
|
+
this.onHistoryChangedEmitter.trigger(
|
|
68
|
+
new HistoryChangedEvent(this.isUndoStackEmpty, this.isRedoStackEmpty),
|
|
69
|
+
);
|
|
63
70
|
}
|
|
64
71
|
|
|
65
|
-
public undo(
|
|
66
|
-
elements: SceneElementsMap,
|
|
67
|
-
appState: AppState,
|
|
68
|
-
snapshot: Readonly<Snapshot>,
|
|
69
|
-
) {
|
|
72
|
+
public undo(elements: SceneElementsMap, appState: AppState) {
|
|
70
73
|
return this.perform(
|
|
71
74
|
elements,
|
|
72
75
|
appState,
|
|
73
|
-
snapshot,
|
|
74
76
|
() => History.pop(this.undoStack),
|
|
75
77
|
(entry: HistoryEntry) => History.push(this.redoStack, entry, elements),
|
|
76
78
|
);
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
public redo(
|
|
80
|
-
elements: SceneElementsMap,
|
|
81
|
-
appState: AppState,
|
|
82
|
-
snapshot: Readonly<Snapshot>,
|
|
83
|
-
) {
|
|
81
|
+
public redo(elements: SceneElementsMap, appState: AppState) {
|
|
84
82
|
return this.perform(
|
|
85
83
|
elements,
|
|
86
84
|
appState,
|
|
87
|
-
snapshot,
|
|
88
85
|
() => History.pop(this.redoStack),
|
|
89
86
|
(entry: HistoryEntry) => History.push(this.undoStack, entry, elements),
|
|
90
87
|
);
|
|
@@ -93,7 +90,6 @@ export class History {
|
|
|
93
90
|
private perform(
|
|
94
91
|
elements: SceneElementsMap,
|
|
95
92
|
appState: AppState,
|
|
96
|
-
snapshot: Readonly<Snapshot>,
|
|
97
93
|
pop: () => HistoryEntry | null,
|
|
98
94
|
push: (entry: HistoryEntry) => void,
|
|
99
95
|
): [SceneElementsMap, AppState] | void {
|
|
@@ -104,6 +100,10 @@ export class History {
|
|
|
104
100
|
return;
|
|
105
101
|
}
|
|
106
102
|
|
|
103
|
+
const action = CaptureUpdateAction.IMMEDIATELY;
|
|
104
|
+
|
|
105
|
+
let prevSnapshot = this.store.snapshot;
|
|
106
|
+
|
|
107
107
|
let nextElements = elements;
|
|
108
108
|
let nextAppState = appState;
|
|
109
109
|
let containsVisibleChange = false;
|
|
@@ -112,9 +112,29 @@ export class History {
|
|
|
112
112
|
while (historyEntry) {
|
|
113
113
|
try {
|
|
114
114
|
[nextElements, nextAppState, containsVisibleChange] =
|
|
115
|
-
|
|
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;
|
|
116
136
|
} finally {
|
|
117
|
-
// make sure to always push
|
|
137
|
+
// make sure to always push, even if the delta is corrupted
|
|
118
138
|
push(historyEntry);
|
|
119
139
|
}
|
|
120
140
|
|
|
@@ -135,7 +155,7 @@ export class History {
|
|
|
135
155
|
}
|
|
136
156
|
}
|
|
137
157
|
|
|
138
|
-
private static pop(stack:
|
|
158
|
+
private static pop(stack: HistoryEntry[]): HistoryEntry | null {
|
|
139
159
|
if (!stack.length) {
|
|
140
160
|
return null;
|
|
141
161
|
}
|
|
@@ -150,63 +170,17 @@ export class History {
|
|
|
150
170
|
}
|
|
151
171
|
|
|
152
172
|
private static push(
|
|
153
|
-
stack:
|
|
173
|
+
stack: HistoryEntry[],
|
|
154
174
|
entry: HistoryEntry,
|
|
155
175
|
prevElements: SceneElementsMap,
|
|
156
176
|
) {
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
export class HistoryEntry {
|
|
163
|
-
private constructor(
|
|
164
|
-
public readonly appStateChange: AppStateChange,
|
|
165
|
-
public readonly elementsChange: ElementsChange,
|
|
166
|
-
) {}
|
|
167
|
-
|
|
168
|
-
public static create(
|
|
169
|
-
appStateChange: AppStateChange,
|
|
170
|
-
elementsChange: ElementsChange,
|
|
171
|
-
) {
|
|
172
|
-
return new HistoryEntry(appStateChange, elementsChange);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
public inverse(): HistoryEntry {
|
|
176
|
-
return new HistoryEntry(
|
|
177
|
-
this.appStateChange.inverse(),
|
|
178
|
-
this.elementsChange.inverse(),
|
|
177
|
+
const inversedEntry = HistoryEntry.inverse(entry);
|
|
178
|
+
const updatedEntry = HistoryEntry.applyLatestChanges(
|
|
179
|
+
inversedEntry,
|
|
180
|
+
prevElements,
|
|
181
|
+
"inserted",
|
|
179
182
|
);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
public applyTo(
|
|
183
|
-
elements: SceneElementsMap,
|
|
184
|
-
appState: AppState,
|
|
185
|
-
snapshot: Readonly<Snapshot>,
|
|
186
|
-
): [SceneElementsMap, AppState, boolean] {
|
|
187
|
-
const [nextElements, elementsContainVisibleChange] =
|
|
188
|
-
this.elementsChange.applyTo(elements, snapshot.elements);
|
|
189
183
|
|
|
190
|
-
|
|
191
|
-
this.appStateChange.applyTo(appState, nextElements);
|
|
192
|
-
|
|
193
|
-
const appliedVisibleChanges =
|
|
194
|
-
elementsContainVisibleChange || appStateContainsVisibleChange;
|
|
195
|
-
|
|
196
|
-
return [nextElements, nextAppState, appliedVisibleChanges];
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Apply latest (remote) changes to the history entry, creates new instance of `HistoryEntry`.
|
|
201
|
-
*/
|
|
202
|
-
public applyLatestChanges(elements: SceneElementsMap): HistoryEntry {
|
|
203
|
-
const updatedElementsChange =
|
|
204
|
-
this.elementsChange.applyLatestChanges(elements);
|
|
205
|
-
|
|
206
|
-
return HistoryEntry.create(this.appStateChange, updatedElementsChange);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
public isEmpty(): boolean {
|
|
210
|
-
return this.appStateChange.isEmpty() && this.elementsChange.isEmpty();
|
|
184
|
+
return stack.push(updatedEntry);
|
|
211
185
|
}
|
|
212
186
|
}
|
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-864353b",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/types/excalidraw/index.d.ts",
|
|
6
6
|
"main": "./dist/prod/index.js",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"bugs": "https://github.com/excalidraw/excalidraw/issues",
|
|
130
130
|
"homepage": "https://github.com/excalidraw/excalidraw/tree/master/packages/excalidraw",
|
|
131
131
|
"scripts": {
|
|
132
|
-
"gen:types": "
|
|
133
|
-
"build:esm": "
|
|
132
|
+
"gen:types": "rimraf types && tsc",
|
|
133
|
+
"build:esm": "rimraf dist && node ../../scripts/buildPackage.js && yarn gen:types"
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// <define:import.meta.env>
|
|
2
|
-
var define_import_meta_env_default = { VITE_APP_BACKEND_V2_GET_URL: "https://json-dev.excalidraw.com/api/v2/", VITE_APP_BACKEND_V2_POST_URL: "https://json-dev.excalidraw.com/api/v2/post/", VITE_APP_LIBRARY_URL: "https://libraries.excalidraw.com", VITE_APP_LIBRARY_BACKEND: "https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries", VITE_APP_WS_SERVER_URL: "http://localhost:3002", VITE_APP_PLUS_LP: "https://plus.excalidraw.com", VITE_APP_PLUS_APP: "http://localhost:3000", VITE_APP_AI_BACKEND: "http://localhost:3015", VITE_APP_FIREBASE_CONFIG: '{"apiKey":"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8","authDomain":"excalidraw-oss-dev.firebaseapp.com","projectId":"excalidraw-oss-dev","storageBucket":"excalidraw-oss-dev.appspot.com","messagingSenderId":"664559512677","appId":"1:664559512677:web:a385181f2928d328a7aa8c"}', VITE_APP_DEV_DISABLE_LIVE_RELOAD: "", VITE_APP_ENABLE_TRACKING: "true", FAST_REFRESH: "false", VITE_APP_PORT: "3000", VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX: "", VITE_APP_COLLAPSE_OVERLAY: "true", VITE_APP_ENABLE_ESLINT: "true", VITE_APP_ENABLE_PWA: "false", VITE_APP_PLUS_EXPORT_PUBLIC_KEY: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\nHQIDAQAB", VITE_APP_DISABLE_PREVENT_UNLOAD: "", PKG_NAME: "@excalidraw/excalidraw", PKG_VERSION: "0.18.0-6fc8502", DEV: true };
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
define_import_meta_env_default
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=chunk-H7XJ5UVD.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["<define:import.meta.env>"],
|
|
4
|
-
"sourcesContent": [""],
|
|
5
|
-
"mappings": ";AAAA,uCAAC,6BAA8B,2CAA0C,8BAA+B,gDAA+C,sBAAuB,oCAAmC,0BAA2B,gFAA+E,wBAAyB,yBAAwB,kBAAmB,+BAA8B,mBAAoB,yBAAwB,qBAAsB,yBAAwB,0BAA2B,mRAA0S,kCAAmC,IAAG,0BAA2B,QAAO,cAAe,SAAQ,eAAgB,QAAO,mDAAoD,IAAG,2BAA4B,QAAO,wBAAyB,QAAO,qBAAsB,SAAQ,iCAAkC,wZAAuZ,iCAAkC,IAAG,UAAW,0BAAyB,aAAc,kBAAiB,KAAM,KAAI;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|