@excalidraw/excalidraw 0.18.0-c4c0649 → 0.18.0-c6f8ef9
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-CP5DND7P.js +7 -0
- package/dist/dev/chunk-CP5DND7P.js.map +7 -0
- package/dist/dev/chunk-CRKRRBMD.js +5677 -0
- package/dist/dev/chunk-CRKRRBMD.js.map +7 -0
- package/dist/dev/{chunk-JCUIYZXF.js → chunk-QF5FRM6O.js} +6 -2
- package/dist/dev/chunk-QF5FRM6O.js.map +7 -0
- package/dist/dev/data/{image-SLEZBMLG.js → image-IWGLHPIX.js} +3 -3
- package/dist/dev/index.css +51 -20
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +6874 -4280
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-ZDTPSZNL.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-A66AFZZU.js +7 -0
- package/dist/prod/chunk-HHV2PJKY.js +4 -0
- package/dist/prod/{chunk-GCFVWREF.js → chunk-I4UNSFV6.js} +4 -4
- package/dist/prod/data/image-4SM4COIL.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +25 -18
- package/dist/prod/locales/{en-MHZ26NAR.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 +19 -3
- package/dist/types/common/src/utils.d.ts +3 -5
- package/dist/types/element/src/Scene.d.ts +7 -3
- 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 +42 -9
- 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 +14 -23
- package/dist/types/element/src/mutateElement.d.ts +1 -1
- package/dist/types/element/src/newElement.d.ts +2 -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/sizeHelpers.d.ts +2 -1
- package/dist/types/element/src/store.d.ts +19 -9
- 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 +8 -3
- package/dist/types/element/src/utils.d.ts +16 -6
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +21 -15
- package/dist/types/excalidraw/actions/actionAlign.d.ts +8 -8
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +14 -10
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +180 -154
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +50 -36
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +7 -5
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +27 -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 +6 -4
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +29 -26
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +7 -5
- package/dist/types/excalidraw/actions/actionExport.d.ts +147 -129
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +65 -20
- package/dist/types/excalidraw/actions/actionFlip.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionFrame.d.ts +78 -70
- package/dist/types/excalidraw/actions/actionGroup.d.ts +20 -16
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +533 -7
- package/dist/types/excalidraw/actions/actionLink.d.ts +8 -6
- package/dist/types/excalidraw/actions/actionMenu.d.ts +22 -16
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +14 -10
- package/dist/types/excalidraw/actions/actionProperties.d.ts +119 -81
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +10 -8
- package/dist/types/excalidraw/actions/actionStyles.d.ts +11 -9
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +9 -7
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +9 -7
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +8 -6
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +9 -7
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +9 -7
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +9 -7
- package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
- package/dist/types/excalidraw/actions/types.d.ts +2 -1
- package/dist/types/excalidraw/appState.d.ts +29 -20
- package/dist/types/excalidraw/components/Actions.d.ts +0 -4
- package/dist/types/excalidraw/components/App.d.ts +15 -16
- package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
- package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
- package/dist/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +11 -1
- package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +1 -0
- package/dist/types/excalidraw/components/icons.d.ts +2 -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/reconcile.d.ts +1 -0
- package/dist/types/excalidraw/data/restore.d.ts +6 -1
- 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 +2 -1
- package/dist/types/excalidraw/lasso/index.d.ts +1 -0
- package/dist/types/excalidraw/lasso/utils.d.ts +2 -1
- package/dist/types/excalidraw/renderer/helpers.d.ts +4 -4
- 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 +15 -8
- package/dist/types/math/src/angle.d.ts +2 -0
- 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/point.d.ts +1 -1
- package/dist/types/math/src/rectangle.d.ts +2 -0
- package/dist/types/math/src/vector.d.ts +4 -2
- package/history.ts +107 -44
- package/package.json +12 -9
- package/dist/dev/chunk-HNRFOURL.js +0 -23482
- package/dist/dev/chunk-HNRFOURL.js.map +0 -7
- package/dist/dev/chunk-JCUIYZXF.js.map +0 -7
- package/dist/dev/chunk-VKWYDXFZ.js +0 -7
- package/dist/dev/chunk-VKWYDXFZ.js.map +0 -7
- package/dist/prod/chunk-G6SRO7HP.js +0 -7
- package/dist/prod/chunk-M3D5LUUK.js +0 -33
- package/dist/prod/data/image-PMKVN4IF.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 -23
- package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
- package/dist/types/excalidraw/visualdebug.d.ts +0 -41
- package/dist/types/utils/src/collision.d.ts +0 -8
- /package/dist/dev/data/{image-SLEZBMLG.js.map → image-IWGLHPIX.js.map} +0 -0
- /package/dist/dev/locales/{en-ZDTPSZNL.js.map → en-SMAPCEOQ.js.map} +0 -0
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
|
|
|
@@ -109,40 +176,46 @@ export class History {
|
|
|
109
176
|
let containsVisibleChange = false;
|
|
110
177
|
|
|
111
178
|
// iterate through the history entries in case they result in no visible changes
|
|
112
|
-
while (
|
|
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-c6f8ef9",
|
|
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-c6f8ef9",
|
|
83
|
+
"@excalidraw/element": "0.18.0-c6f8ef9",
|
|
84
|
+
"@excalidraw/math": "0.18.0-c6f8ef9",
|
|
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
|
+
}
|