@excalidraw/element 0.18.0-c65b684e9 → 0.18.0-dda3affcb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/index.js +60 -84
- package/dist/dev/index.js.map +3 -3
- package/dist/prod/index.js +11 -11
- package/dist/types/element/src/delta.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +0 -13
- package/dist/types/excalidraw/data/reconcile.d.ts +1 -0
- package/dist/types/excalidraw/data/restore.d.ts +6 -1
- package/dist/types/excalidraw/index.d.ts +1 -1
- package/dist/types/excalidraw/types.d.ts +4 -2
- package/package.json +3 -3
package/dist/dev/index.js
CHANGED
|
@@ -12849,7 +12849,6 @@ import {
|
|
|
12849
12849
|
arrayToMap as arrayToMap10,
|
|
12850
12850
|
arrayToObject,
|
|
12851
12851
|
assertNever as assertNever4,
|
|
12852
|
-
invariant as invariant8,
|
|
12853
12852
|
isDevEnv as isDevEnv7,
|
|
12854
12853
|
isShallowEqual as isShallowEqual2,
|
|
12855
12854
|
isTestEnv as isTestEnv8,
|
|
@@ -13816,8 +13815,7 @@ var getDefaultObservedAppState = () => {
|
|
|
13816
13815
|
viewBackgroundColor: COLOR_PALETTE2.white,
|
|
13817
13816
|
selectedElementIds: {},
|
|
13818
13817
|
selectedGroupIds: {},
|
|
13819
|
-
|
|
13820
|
-
selectedLinearElementIsEditing: null,
|
|
13818
|
+
selectedLinearElement: null,
|
|
13821
13819
|
croppingElementId: null,
|
|
13822
13820
|
activeLockedId: null,
|
|
13823
13821
|
lockedMultiSelections: {}
|
|
@@ -13833,8 +13831,10 @@ var getObservedAppState = (appState) => {
|
|
|
13833
13831
|
croppingElementId: appState.croppingElementId,
|
|
13834
13832
|
activeLockedId: appState.activeLockedId,
|
|
13835
13833
|
lockedMultiSelections: appState.lockedMultiSelections,
|
|
13836
|
-
|
|
13837
|
-
|
|
13834
|
+
selectedLinearElement: appState.selectedLinearElement ? {
|
|
13835
|
+
elementId: appState.selectedLinearElement.elementId,
|
|
13836
|
+
isEditing: !!appState.selectedLinearElement.isEditing
|
|
13837
|
+
} : null
|
|
13838
13838
|
};
|
|
13839
13839
|
Reflect.defineProperty(observedAppState, hiddenObservedAppStateProp, {
|
|
13840
13840
|
value: true,
|
|
@@ -14899,59 +14899,38 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14899
14899
|
applyTo(appState, nextElements) {
|
|
14900
14900
|
try {
|
|
14901
14901
|
const {
|
|
14902
|
-
selectedElementIds:
|
|
14903
|
-
selectedGroupIds:
|
|
14902
|
+
selectedElementIds: deletedSelectedElementIds = {},
|
|
14903
|
+
selectedGroupIds: deletedSelectedGroupIds = {}
|
|
14904
14904
|
} = this.delta.deleted;
|
|
14905
14905
|
const {
|
|
14906
|
-
selectedElementIds:
|
|
14907
|
-
selectedGroupIds:
|
|
14908
|
-
|
|
14909
|
-
selectedLinearElementIsEditing,
|
|
14906
|
+
selectedElementIds: insertedSelectedElementIds = {},
|
|
14907
|
+
selectedGroupIds: insertedSelectedGroupIds = {},
|
|
14908
|
+
selectedLinearElement: insertedSelectedLinearElement,
|
|
14910
14909
|
...directlyApplicablePartial
|
|
14911
14910
|
} = this.delta.inserted;
|
|
14912
14911
|
const mergedSelectedElementIds = Delta.mergeObjects(
|
|
14913
14912
|
appState.selectedElementIds,
|
|
14914
|
-
|
|
14915
|
-
|
|
14913
|
+
insertedSelectedElementIds,
|
|
14914
|
+
deletedSelectedElementIds
|
|
14916
14915
|
);
|
|
14917
14916
|
const mergedSelectedGroupIds = Delta.mergeObjects(
|
|
14918
14917
|
appState.selectedGroupIds,
|
|
14919
|
-
|
|
14920
|
-
|
|
14918
|
+
insertedSelectedGroupIds,
|
|
14919
|
+
deletedSelectedGroupIds
|
|
14921
14920
|
);
|
|
14922
|
-
|
|
14923
|
-
|
|
14924
|
-
|
|
14925
|
-
|
|
14926
|
-
|
|
14927
|
-
|
|
14928
|
-
|
|
14929
|
-
),
|
|
14930
|
-
nextElements,
|
|
14931
|
-
selectedLinearElementIsEditing === true
|
|
14932
|
-
// Can be unknown which is defaulted to false
|
|
14933
|
-
);
|
|
14934
|
-
}
|
|
14935
|
-
if (
|
|
14936
|
-
// Value being 'null' is equivaluent to unknown in this case because it only gets set
|
|
14937
|
-
// to null when 'selectedLinearElementId' is set to null
|
|
14938
|
-
selectedLinearElementIsEditing != null
|
|
14939
|
-
) {
|
|
14940
|
-
invariant8(
|
|
14941
|
-
selectedLinearElement,
|
|
14942
|
-
`selectedLinearElement is null when selectedLinearElementIsEditing is set to ${selectedLinearElementIsEditing}`
|
|
14943
|
-
);
|
|
14944
|
-
selectedLinearElement = {
|
|
14945
|
-
...selectedLinearElement,
|
|
14946
|
-
isEditing: selectedLinearElementIsEditing
|
|
14947
|
-
};
|
|
14948
|
-
}
|
|
14921
|
+
const selectedLinearElement = insertedSelectedLinearElement && nextElements.has(insertedSelectedLinearElement.elementId) ? new LinearElementEditor(
|
|
14922
|
+
nextElements.get(
|
|
14923
|
+
insertedSelectedLinearElement.elementId
|
|
14924
|
+
),
|
|
14925
|
+
nextElements,
|
|
14926
|
+
insertedSelectedLinearElement.isEditing
|
|
14927
|
+
) : null;
|
|
14949
14928
|
const nextAppState = {
|
|
14950
14929
|
...appState,
|
|
14951
14930
|
...directlyApplicablePartial,
|
|
14952
14931
|
selectedElementIds: mergedSelectedElementIds,
|
|
14953
14932
|
selectedGroupIds: mergedSelectedGroupIds,
|
|
14954
|
-
selectedLinearElement
|
|
14933
|
+
selectedLinearElement: typeof insertedSelectedLinearElement !== "undefined" ? selectedLinearElement : appState.selectedLinearElement
|
|
14955
14934
|
};
|
|
14956
14935
|
const constainsVisibleChanges = this.filterInvisibleChanges(
|
|
14957
14936
|
appState,
|
|
@@ -15041,63 +15020,44 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
15041
15020
|
nextAppState[key] = null;
|
|
15042
15021
|
}
|
|
15043
15022
|
break;
|
|
15044
|
-
case "
|
|
15045
|
-
const
|
|
15046
|
-
|
|
15047
|
-
if (!linearElement) {
|
|
15023
|
+
case "selectedLinearElement":
|
|
15024
|
+
const nextLinearElement = nextAppState[key];
|
|
15025
|
+
if (!nextLinearElement) {
|
|
15048
15026
|
visibleDifferenceFlag.value = true;
|
|
15049
15027
|
} else {
|
|
15050
|
-
const element = nextElements.get(
|
|
15028
|
+
const element = nextElements.get(nextLinearElement.elementId);
|
|
15051
15029
|
if (element && !element.isDeleted) {
|
|
15052
15030
|
visibleDifferenceFlag.value = true;
|
|
15053
15031
|
} else {
|
|
15054
|
-
nextAppState[
|
|
15032
|
+
nextAppState[key] = null;
|
|
15055
15033
|
}
|
|
15056
15034
|
}
|
|
15057
15035
|
break;
|
|
15058
|
-
|
|
15059
|
-
case "selectedLinearElementIsEditing": {
|
|
15060
|
-
const prevIsEditing = prevAppState.selectedLinearElement?.isEditing ?? false;
|
|
15061
|
-
const nextIsEditing = nextAppState.selectedLinearElement?.isEditing ?? false;
|
|
15062
|
-
if (prevIsEditing !== nextIsEditing) {
|
|
15063
|
-
visibleDifferenceFlag.value = true;
|
|
15064
|
-
}
|
|
15065
|
-
break;
|
|
15066
|
-
}
|
|
15067
|
-
case "lockedMultiSelections": {
|
|
15036
|
+
case "lockedMultiSelections":
|
|
15068
15037
|
const prevLockedUnits = prevAppState[key] || {};
|
|
15069
15038
|
const nextLockedUnits = nextAppState[key] || {};
|
|
15070
15039
|
if (!isShallowEqual2(prevLockedUnits, nextLockedUnits)) {
|
|
15071
15040
|
visibleDifferenceFlag.value = true;
|
|
15072
15041
|
}
|
|
15073
15042
|
break;
|
|
15074
|
-
|
|
15075
|
-
case "activeLockedId": {
|
|
15043
|
+
case "activeLockedId":
|
|
15076
15044
|
const prevHitLockedId = prevAppState[key] || null;
|
|
15077
15045
|
const nextHitLockedId = nextAppState[key] || null;
|
|
15078
15046
|
if (prevHitLockedId !== nextHitLockedId) {
|
|
15079
15047
|
visibleDifferenceFlag.value = true;
|
|
15080
15048
|
}
|
|
15081
15049
|
break;
|
|
15082
|
-
|
|
15083
|
-
default: {
|
|
15050
|
+
default:
|
|
15084
15051
|
assertNever4(
|
|
15085
15052
|
key,
|
|
15086
15053
|
`Unknown ObservedElementsAppState's key "${key}"`,
|
|
15087
15054
|
true
|
|
15088
15055
|
);
|
|
15089
|
-
}
|
|
15090
15056
|
}
|
|
15091
15057
|
}
|
|
15092
15058
|
}
|
|
15093
15059
|
return visibleDifferenceFlag.value;
|
|
15094
15060
|
}
|
|
15095
|
-
static convertToAppStateKey(key) {
|
|
15096
|
-
switch (key) {
|
|
15097
|
-
case "selectedLinearElementId":
|
|
15098
|
-
return "selectedLinearElement";
|
|
15099
|
-
}
|
|
15100
|
-
}
|
|
15101
15061
|
static filterSelectedElements(selectedElementIds, elements, visibleDifferenceFlag) {
|
|
15102
15062
|
const ids = Object.keys(selectedElementIds);
|
|
15103
15063
|
if (!ids.length) {
|
|
@@ -15136,8 +15096,7 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
15136
15096
|
editingGroupId,
|
|
15137
15097
|
selectedGroupIds,
|
|
15138
15098
|
selectedElementIds,
|
|
15139
|
-
|
|
15140
|
-
selectedLinearElementIsEditing,
|
|
15099
|
+
selectedLinearElement,
|
|
15141
15100
|
croppingElementId,
|
|
15142
15101
|
lockedMultiSelections,
|
|
15143
15102
|
activeLockedId,
|
|
@@ -15291,7 +15250,7 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15291
15250
|
for (const prevElement of prevElements.values()) {
|
|
15292
15251
|
const nextElement = nextElements.get(prevElement.id);
|
|
15293
15252
|
if (!nextElement) {
|
|
15294
|
-
const deleted = { ...prevElement
|
|
15253
|
+
const deleted = { ...prevElement };
|
|
15295
15254
|
const inserted = {
|
|
15296
15255
|
isDeleted: true,
|
|
15297
15256
|
version: prevElement.version + 1,
|
|
@@ -15302,7 +15261,9 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15302
15261
|
inserted,
|
|
15303
15262
|
_ElementsDelta.stripIrrelevantProps
|
|
15304
15263
|
);
|
|
15305
|
-
|
|
15264
|
+
if (!prevElement.isDeleted) {
|
|
15265
|
+
removed[prevElement.id] = delta;
|
|
15266
|
+
}
|
|
15306
15267
|
}
|
|
15307
15268
|
}
|
|
15308
15269
|
for (const nextElement of nextElements.values()) {
|
|
@@ -15314,15 +15275,16 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15314
15275
|
versionNonce: randomInteger4()
|
|
15315
15276
|
};
|
|
15316
15277
|
const inserted = {
|
|
15317
|
-
...nextElement
|
|
15318
|
-
isDeleted: false
|
|
15278
|
+
...nextElement
|
|
15319
15279
|
};
|
|
15320
15280
|
const delta = Delta.create(
|
|
15321
15281
|
deleted,
|
|
15322
15282
|
inserted,
|
|
15323
15283
|
_ElementsDelta.stripIrrelevantProps
|
|
15324
15284
|
);
|
|
15325
|
-
|
|
15285
|
+
if (!nextElement.isDeleted) {
|
|
15286
|
+
added[nextElement.id] = delta;
|
|
15287
|
+
}
|
|
15326
15288
|
continue;
|
|
15327
15289
|
}
|
|
15328
15290
|
if (prevElement.versionNonce !== nextElement.versionNonce) {
|
|
@@ -15343,7 +15305,11 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15343
15305
|
}
|
|
15344
15306
|
continue;
|
|
15345
15307
|
}
|
|
15346
|
-
|
|
15308
|
+
const strippedDeleted = _ElementsDelta.stripVersionProps(delta.deleted);
|
|
15309
|
+
const strippedInserted = _ElementsDelta.stripVersionProps(
|
|
15310
|
+
delta.inserted
|
|
15311
|
+
);
|
|
15312
|
+
if (Delta.isInnerDifferent(strippedDeleted, strippedInserted, true)) {
|
|
15347
15313
|
updated[nextElement.id] = delta;
|
|
15348
15314
|
}
|
|
15349
15315
|
}
|
|
@@ -15421,7 +15387,13 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15421
15387
|
} else {
|
|
15422
15388
|
latestDelta = delta;
|
|
15423
15389
|
}
|
|
15424
|
-
|
|
15390
|
+
const strippedDeleted = _ElementsDelta.stripVersionProps(
|
|
15391
|
+
latestDelta.deleted
|
|
15392
|
+
);
|
|
15393
|
+
const strippedInserted = _ElementsDelta.stripVersionProps(
|
|
15394
|
+
latestDelta.inserted
|
|
15395
|
+
);
|
|
15396
|
+
if (Delta.isInnerDifferent(strippedDeleted, strippedInserted)) {
|
|
15425
15397
|
modifiedDeltas[id] = latestDelta;
|
|
15426
15398
|
}
|
|
15427
15399
|
}
|
|
@@ -15786,6 +15758,10 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15786
15758
|
const { id, updated, ...strippedPartial } = partial;
|
|
15787
15759
|
return strippedPartial;
|
|
15788
15760
|
}
|
|
15761
|
+
static stripVersionProps(partial) {
|
|
15762
|
+
const { version, versionNonce, ...strippedPartial } = partial;
|
|
15763
|
+
return strippedPartial;
|
|
15764
|
+
}
|
|
15789
15765
|
};
|
|
15790
15766
|
|
|
15791
15767
|
// src/distribute.ts
|
|
@@ -16789,7 +16765,7 @@ var embeddableURLValidator = (url, validateEmbeddable) => {
|
|
|
16789
16765
|
|
|
16790
16766
|
// src/flowchart.ts
|
|
16791
16767
|
init_define_import_meta_env();
|
|
16792
|
-
import { KEYS as KEYS3, invariant as
|
|
16768
|
+
import { KEYS as KEYS3, invariant as invariant8, toBrandedType as toBrandedType2 } from "@excalidraw/common";
|
|
16793
16769
|
import { pointFrom as pointFrom13 } from "@excalidraw/math";
|
|
16794
16770
|
var VERTICAL_OFFSET = 100;
|
|
16795
16771
|
var HORIZONTAL_OFFSET = 100;
|
|
@@ -16819,7 +16795,7 @@ var getNodeRelatives = (type, node, elementsMap, direction) => {
|
|
|
16819
16795
|
if (!relative) {
|
|
16820
16796
|
return acc;
|
|
16821
16797
|
}
|
|
16822
|
-
|
|
16798
|
+
invariant8(
|
|
16823
16799
|
isBindableElement(relative),
|
|
16824
16800
|
"not an ExcalidrawBindableElement"
|
|
16825
16801
|
);
|
|
@@ -16935,7 +16911,7 @@ var addNewNode = (element, appState, direction, scene) => {
|
|
|
16935
16911
|
fillStyle: element.fillStyle,
|
|
16936
16912
|
strokeStyle: element.strokeStyle
|
|
16937
16913
|
});
|
|
16938
|
-
|
|
16914
|
+
invariant8(
|
|
16939
16915
|
isFlowchartNodeElement(nextNode),
|
|
16940
16916
|
"not an ExcalidrawFlowchartNodeElement"
|
|
16941
16917
|
);
|
|
@@ -16993,7 +16969,7 @@ var addNewNodes = (startNode, appState, direction, scene, numberOfNodes) => {
|
|
|
16993
16969
|
fillStyle: startNode.fillStyle,
|
|
16994
16970
|
strokeStyle: startNode.strokeStyle
|
|
16995
16971
|
});
|
|
16996
|
-
|
|
16972
|
+
invariant8(
|
|
16997
16973
|
isFlowchartNodeElement(nextNode),
|
|
16998
16974
|
"not an ExcalidrawFlowchartNodeElement"
|
|
16999
16975
|
);
|
|
@@ -17219,7 +17195,7 @@ var FlowChartCreator = class {
|
|
|
17219
17195
|
}
|
|
17220
17196
|
if (startNode.frameId) {
|
|
17221
17197
|
const frame = elementsMap.get(startNode.frameId);
|
|
17222
|
-
|
|
17198
|
+
invariant8(
|
|
17223
17199
|
frame && isFrameElement(frame),
|
|
17224
17200
|
"not an ExcalidrawFrameElement"
|
|
17225
17201
|
);
|