@excalidraw/element 0.18.0-6d75c4b34 → 0.18.0-7b8a5f54c
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 +269 -145
- package/dist/dev/index.js.map +3 -3
- package/dist/prod/index.js +9 -9
- package/dist/types/common/src/constants.d.ts +1 -0
- package/dist/types/element/src/Scene.d.ts +6 -2
- package/dist/types/element/src/align.d.ts +2 -1
- package/dist/types/element/src/delta.d.ts +16 -4
- package/dist/types/element/src/distribute.d.ts +2 -1
- package/dist/types/element/src/groups.d.ts +1 -0
- package/dist/types/element/src/linearElementEditor.d.ts +2 -1
- package/dist/types/element/src/store.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +0 -3
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +0 -2
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +0 -13
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +3 -8
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +3 -6
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +0 -2
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionExport.d.ts +0 -9
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionFrame.d.ts +0 -4
- package/dist/types/excalidraw/actions/actionGroup.d.ts +0 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +33 -3
- package/dist/types/excalidraw/actions/actionLink.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +0 -3
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +0 -2
- package/dist/types/excalidraw/actions/actionProperties.d.ts +0 -15
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionStyles.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +0 -1
- package/dist/types/excalidraw/components/Actions.d.ts +0 -4
- package/dist/types/excalidraw/components/App.d.ts +4 -3
- package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
- 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 +2 -1
- package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
- package/dist/types/excalidraw/types.d.ts +5 -4
- package/package.json +3 -3
package/dist/dev/index.js
CHANGED
|
@@ -3825,9 +3825,6 @@ var getTextWidth = (text, font) => {
|
|
|
3825
3825
|
return width;
|
|
3826
3826
|
};
|
|
3827
3827
|
var getTextHeight = (text, fontSize, lineHeight) => {
|
|
3828
|
-
if (text.trim() === "") {
|
|
3829
|
-
return 0;
|
|
3830
|
-
}
|
|
3831
3828
|
const lineCount = splitIntoLines(text).length;
|
|
3832
3829
|
return getLineHeightInPx(fontSize, lineHeight) * lineCount;
|
|
3833
3830
|
};
|
|
@@ -8130,7 +8127,8 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8130
8127
|
segmentMidPointHoveredCoords;
|
|
8131
8128
|
elbowed;
|
|
8132
8129
|
customLineAngle;
|
|
8133
|
-
|
|
8130
|
+
isEditing;
|
|
8131
|
+
constructor(element, elementsMap, isEditing = false) {
|
|
8134
8132
|
this.elementId = element.id;
|
|
8135
8133
|
if (!pointsEqual6(element.points[0], pointFrom8(0, 0))) {
|
|
8136
8134
|
console.error("Linear element is not normalized", Error().stack);
|
|
@@ -8161,6 +8159,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8161
8159
|
this.segmentMidPointHoveredCoords = null;
|
|
8162
8160
|
this.elbowed = isElbowArrow(element) && element.elbowed;
|
|
8163
8161
|
this.customLineAngle = null;
|
|
8162
|
+
this.isEditing = isEditing;
|
|
8164
8163
|
}
|
|
8165
8164
|
// ---------------------------------------------------------------------------
|
|
8166
8165
|
// static methods
|
|
@@ -8178,11 +8177,11 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8178
8177
|
return null;
|
|
8179
8178
|
}
|
|
8180
8179
|
static handleBoxSelection(event, appState, setState, elementsMap) {
|
|
8181
|
-
if (!appState.
|
|
8180
|
+
if (!appState.selectedLinearElement?.isEditing || !appState.selectionElement) {
|
|
8182
8181
|
return false;
|
|
8183
8182
|
}
|
|
8184
|
-
const {
|
|
8185
|
-
const { selectedPointsIndices, elementId } =
|
|
8183
|
+
const { selectedLinearElement } = appState;
|
|
8184
|
+
const { selectedPointsIndices, elementId } = selectedLinearElement;
|
|
8186
8185
|
const element = _LinearElementEditor.getElement(elementId, elementsMap);
|
|
8187
8186
|
if (!element) {
|
|
8188
8187
|
return false;
|
|
@@ -8204,8 +8203,8 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8204
8203
|
return true;
|
|
8205
8204
|
});
|
|
8206
8205
|
setState({
|
|
8207
|
-
|
|
8208
|
-
...
|
|
8206
|
+
selectedLinearElement: {
|
|
8207
|
+
...selectedLinearElement,
|
|
8209
8208
|
selectedPointsIndices: nextSelectedPoints.length ? nextSelectedPoints : null
|
|
8210
8209
|
}
|
|
8211
8210
|
});
|
|
@@ -8359,7 +8358,6 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8359
8358
|
};
|
|
8360
8359
|
return {
|
|
8361
8360
|
...app.state,
|
|
8362
|
-
editingLinearElement: app.state.editingLinearElement ? newLinearElementEditor : null,
|
|
8363
8361
|
selectedLinearElement: newLinearElementEditor,
|
|
8364
8362
|
suggestedBindings
|
|
8365
8363
|
};
|
|
@@ -8443,7 +8441,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8443
8441
|
}
|
|
8444
8442
|
static getEditorMidPoints = (element, elementsMap, appState) => {
|
|
8445
8443
|
const boundText = getBoundTextElement(element, elementsMap);
|
|
8446
|
-
if (!isElbowArrow(element) && !appState.
|
|
8444
|
+
if (!isElbowArrow(element) && !appState.selectedLinearElement?.isEditing && element.points.length > 2 && !boundText) {
|
|
8447
8445
|
return [];
|
|
8448
8446
|
}
|
|
8449
8447
|
const points = _LinearElementEditor.getPointsGlobalCoordinates(
|
|
@@ -8493,7 +8491,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8493
8491
|
element,
|
|
8494
8492
|
elementsMap
|
|
8495
8493
|
);
|
|
8496
|
-
if (points.length >= 3 && !appState.
|
|
8494
|
+
if (points.length >= 3 && !appState.selectedLinearElement?.isEditing && !isElbowArrow(element)) {
|
|
8497
8495
|
return null;
|
|
8498
8496
|
}
|
|
8499
8497
|
const threshold = (_LinearElementEditor.POINT_HANDLE_SIZE + 1) / appState.zoom.value;
|
|
@@ -8633,7 +8631,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8633
8631
|
segmentMidpoint,
|
|
8634
8632
|
elementsMap
|
|
8635
8633
|
);
|
|
8636
|
-
} else if (event.altKey && appState.
|
|
8634
|
+
} else if (event.altKey && appState.selectedLinearElement?.isEditing) {
|
|
8637
8635
|
if (linearElementEditor.lastUncommittedPoint == null) {
|
|
8638
8636
|
scene.mutateElement(element, {
|
|
8639
8637
|
points: [
|
|
@@ -8743,14 +8741,14 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8743
8741
|
}
|
|
8744
8742
|
static handlePointerMove(event, scenePointerX, scenePointerY, app) {
|
|
8745
8743
|
const appState = app.state;
|
|
8746
|
-
if (!appState.
|
|
8744
|
+
if (!appState.selectedLinearElement?.isEditing) {
|
|
8747
8745
|
return null;
|
|
8748
8746
|
}
|
|
8749
|
-
const { elementId, lastUncommittedPoint } = appState.
|
|
8747
|
+
const { elementId, lastUncommittedPoint } = appState.selectedLinearElement;
|
|
8750
8748
|
const elementsMap = app.scene.getNonDeletedElementsMap();
|
|
8751
8749
|
const element = _LinearElementEditor.getElement(elementId, elementsMap);
|
|
8752
8750
|
if (!element) {
|
|
8753
|
-
return appState.
|
|
8751
|
+
return appState.selectedLinearElement;
|
|
8754
8752
|
}
|
|
8755
8753
|
const { points } = element;
|
|
8756
8754
|
const lastPoint = points[points.length - 1];
|
|
@@ -8758,10 +8756,10 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8758
8756
|
if (lastPoint === lastUncommittedPoint) {
|
|
8759
8757
|
_LinearElementEditor.deletePoints(element, app, [points.length - 1]);
|
|
8760
8758
|
}
|
|
8761
|
-
return {
|
|
8762
|
-
...appState.
|
|
8759
|
+
return appState.selectedLinearElement?.lastUncommittedPoint ? {
|
|
8760
|
+
...appState.selectedLinearElement,
|
|
8763
8761
|
lastUncommittedPoint: null
|
|
8764
|
-
};
|
|
8762
|
+
} : appState.selectedLinearElement;
|
|
8765
8763
|
}
|
|
8766
8764
|
let newPoint;
|
|
8767
8765
|
if (shouldRotateWithDiscreteAngle(event) && points.length >= 2) {
|
|
@@ -8781,8 +8779,8 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8781
8779
|
newPoint = _LinearElementEditor.createPointAt(
|
|
8782
8780
|
element,
|
|
8783
8781
|
elementsMap,
|
|
8784
|
-
scenePointerX - appState.
|
|
8785
|
-
scenePointerY - appState.
|
|
8782
|
+
scenePointerX - appState.selectedLinearElement.pointerOffset.x,
|
|
8783
|
+
scenePointerY - appState.selectedLinearElement.pointerOffset.y,
|
|
8786
8784
|
event[KEYS2.CTRL_OR_CMD] || isElbowArrow(element) ? null : app.getEffectiveGridSize()
|
|
8787
8785
|
);
|
|
8788
8786
|
}
|
|
@@ -8803,7 +8801,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8803
8801
|
_LinearElementEditor.addPoints(element, app.scene, [newPoint]);
|
|
8804
8802
|
}
|
|
8805
8803
|
return {
|
|
8806
|
-
...appState.
|
|
8804
|
+
...appState.selectedLinearElement,
|
|
8807
8805
|
lastUncommittedPoint: element.points[element.points.length - 1]
|
|
8808
8806
|
};
|
|
8809
8807
|
}
|
|
@@ -8909,11 +8907,11 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8909
8907
|
// ---------------------------------------------------------------------------
|
|
8910
8908
|
static duplicateSelectedPoints(appState, scene) {
|
|
8911
8909
|
invariant6(
|
|
8912
|
-
appState.
|
|
8910
|
+
appState.selectedLinearElement?.isEditing,
|
|
8913
8911
|
"Not currently editing a linear element"
|
|
8914
8912
|
);
|
|
8915
8913
|
const elementsMap = scene.getNonDeletedElementsMap();
|
|
8916
|
-
const { selectedPointsIndices, elementId } = appState.
|
|
8914
|
+
const { selectedPointsIndices, elementId } = appState.selectedLinearElement;
|
|
8917
8915
|
const element = _LinearElementEditor.getElement(elementId, elementsMap);
|
|
8918
8916
|
invariant6(
|
|
8919
8917
|
element,
|
|
@@ -8960,14 +8958,14 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8960
8958
|
}
|
|
8961
8959
|
return {
|
|
8962
8960
|
...appState,
|
|
8963
|
-
|
|
8964
|
-
...appState.
|
|
8961
|
+
selectedLinearElement: {
|
|
8962
|
+
...appState.selectedLinearElement,
|
|
8965
8963
|
selectedPointsIndices: nextSelectedIndices
|
|
8966
8964
|
}
|
|
8967
8965
|
};
|
|
8968
8966
|
}
|
|
8969
8967
|
static deletePoints(element, app, pointIndices) {
|
|
8970
|
-
const isUncommittedPoint = app.state.
|
|
8968
|
+
const isUncommittedPoint = app.state.selectedLinearElement?.isEditing && app.state.selectedLinearElement?.lastUncommittedPoint === element.points[element.points.length - 1];
|
|
8971
8969
|
const nextPoints = element.points.filter((_, idx) => {
|
|
8972
8970
|
return !pointIndices.includes(idx);
|
|
8973
8971
|
});
|
|
@@ -9076,7 +9074,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9076
9074
|
pointFrom8(origin.x, origin.y),
|
|
9077
9075
|
pointFrom8(pointerCoords.x, pointerCoords.y)
|
|
9078
9076
|
);
|
|
9079
|
-
if (!appState.
|
|
9077
|
+
if (!appState.selectedLinearElement?.isEditing && dist < DRAGGING_THRESHOLD / appState.zoom.value) {
|
|
9080
9078
|
return false;
|
|
9081
9079
|
}
|
|
9082
9080
|
return true;
|
|
@@ -9829,6 +9827,55 @@ var getNewGroupIdsForDuplication = (groupIds, editingGroupId, mapper) => {
|
|
|
9829
9827
|
}
|
|
9830
9828
|
return copy;
|
|
9831
9829
|
};
|
|
9830
|
+
var getSelectedElementsByGroup = (selectedElements, elementsMap, appState) => {
|
|
9831
|
+
const selectedGroupIds = getSelectedGroupIds(appState);
|
|
9832
|
+
const unboundElements = selectedElements.filter(
|
|
9833
|
+
(element) => !isBoundToContainer(element)
|
|
9834
|
+
);
|
|
9835
|
+
const groups = /* @__PURE__ */ new Map();
|
|
9836
|
+
const elements = /* @__PURE__ */ new Map();
|
|
9837
|
+
const addToElementsMap = (element) => {
|
|
9838
|
+
const currentElementMembers = elements.get(element.id) || [];
|
|
9839
|
+
const boundTextElement = getBoundTextElement(element, elementsMap);
|
|
9840
|
+
if (boundTextElement) {
|
|
9841
|
+
currentElementMembers.push(boundTextElement);
|
|
9842
|
+
}
|
|
9843
|
+
elements.set(element.id, [...currentElementMembers, element]);
|
|
9844
|
+
};
|
|
9845
|
+
const addToGroupsMap = (element, groupId) => {
|
|
9846
|
+
const currentGroupMembers = groups.get(groupId) || [];
|
|
9847
|
+
const boundTextElement = getBoundTextElement(element, elementsMap);
|
|
9848
|
+
if (boundTextElement) {
|
|
9849
|
+
currentGroupMembers.push(boundTextElement);
|
|
9850
|
+
}
|
|
9851
|
+
groups.set(groupId, [...currentGroupMembers, element]);
|
|
9852
|
+
};
|
|
9853
|
+
const handleSingleSelectedGroupCase = (element, selectedGroupId) => {
|
|
9854
|
+
const indexOfSelectedGroupId = element.groupIds.indexOf(selectedGroupId, 0);
|
|
9855
|
+
const nestedGroupCount = element.groupIds.slice(
|
|
9856
|
+
0,
|
|
9857
|
+
indexOfSelectedGroupId
|
|
9858
|
+
).length;
|
|
9859
|
+
return nestedGroupCount > 0 ? addToGroupsMap(element, element.groupIds[indexOfSelectedGroupId - 1]) : addToElementsMap(element);
|
|
9860
|
+
};
|
|
9861
|
+
const isAllInSameGroup = selectedElements.every(
|
|
9862
|
+
(element) => isSelectedViaGroup(appState, element)
|
|
9863
|
+
);
|
|
9864
|
+
unboundElements.forEach((element) => {
|
|
9865
|
+
const selectedGroupId = getSelectedGroupIdForElement(
|
|
9866
|
+
element,
|
|
9867
|
+
appState.selectedGroupIds
|
|
9868
|
+
);
|
|
9869
|
+
if (!selectedGroupId) {
|
|
9870
|
+
addToElementsMap(element);
|
|
9871
|
+
} else if (selectedGroupIds.length === 1 && isAllInSameGroup) {
|
|
9872
|
+
handleSingleSelectedGroupCase(element, selectedGroupId);
|
|
9873
|
+
} else {
|
|
9874
|
+
addToGroupsMap(element, selectedGroupId);
|
|
9875
|
+
}
|
|
9876
|
+
});
|
|
9877
|
+
return Array.from(groups.values()).concat(Array.from(elements.values()));
|
|
9878
|
+
};
|
|
9832
9879
|
|
|
9833
9880
|
// src/selection.ts
|
|
9834
9881
|
var excludeElementsInFramesFromSelection = (selectedElements) => {
|
|
@@ -10516,6 +10563,11 @@ var getCanvasPadding = (element) => {
|
|
|
10516
10563
|
return element.strokeWidth * 12;
|
|
10517
10564
|
case "text":
|
|
10518
10565
|
return element.fontSize / 2;
|
|
10566
|
+
case "arrow":
|
|
10567
|
+
if (element.endArrowhead || element.endArrowhead) {
|
|
10568
|
+
return 40;
|
|
10569
|
+
}
|
|
10570
|
+
return 20;
|
|
10519
10571
|
default:
|
|
10520
10572
|
return 20;
|
|
10521
10573
|
}
|
|
@@ -12745,11 +12797,11 @@ var getNormalizedDimensions = (element) => {
|
|
|
12745
12797
|
|
|
12746
12798
|
// src/align.ts
|
|
12747
12799
|
init_define_import_meta_env();
|
|
12748
|
-
var alignElements = (selectedElements, alignment, scene) => {
|
|
12749
|
-
const
|
|
12750
|
-
const groups = getMaximumGroups(
|
|
12800
|
+
var alignElements = (selectedElements, alignment, scene, appState) => {
|
|
12801
|
+
const groups = getSelectedElementsByGroup(
|
|
12751
12802
|
selectedElements,
|
|
12752
|
-
|
|
12803
|
+
scene.getNonDeletedElementsMap(),
|
|
12804
|
+
appState
|
|
12753
12805
|
);
|
|
12754
12806
|
const selectionBoundingBox = getCommonBoundingBox(selectedElements);
|
|
12755
12807
|
return groups.flatMap((group) => {
|
|
@@ -13185,8 +13237,9 @@ var Store = class {
|
|
|
13185
13237
|
constructor(app) {
|
|
13186
13238
|
this.app = app;
|
|
13187
13239
|
}
|
|
13188
|
-
//
|
|
13240
|
+
// for internal use by history
|
|
13189
13241
|
onDurableIncrementEmitter = new Emitter();
|
|
13242
|
+
// for public use as part of onIncrement API
|
|
13190
13243
|
onStoreIncrementEmitter = new Emitter();
|
|
13191
13244
|
scheduledMacroActions = /* @__PURE__ */ new Set();
|
|
13192
13245
|
scheduledMicroActions = [];
|
|
@@ -13480,10 +13533,20 @@ var StoreDelta = class {
|
|
|
13480
13533
|
*/
|
|
13481
13534
|
static load({
|
|
13482
13535
|
id,
|
|
13483
|
-
elements: { added, removed, updated }
|
|
13536
|
+
elements: { added, removed, updated },
|
|
13537
|
+
appState: { delta: appStateDelta }
|
|
13484
13538
|
}) {
|
|
13485
13539
|
const elements = ElementsDelta.create(added, removed, updated);
|
|
13486
|
-
|
|
13540
|
+
const appState = AppStateDelta.create(appStateDelta);
|
|
13541
|
+
return new this(id, elements, appState);
|
|
13542
|
+
}
|
|
13543
|
+
/**
|
|
13544
|
+
* Squash the passed delta into the current instance.
|
|
13545
|
+
*/
|
|
13546
|
+
squash(delta) {
|
|
13547
|
+
this.elements.squash(delta.elements);
|
|
13548
|
+
this.appState.squash(delta.appState);
|
|
13549
|
+
return this;
|
|
13487
13550
|
}
|
|
13488
13551
|
/**
|
|
13489
13552
|
* Inverse store delta, creates new instance of `StoreDelta`.
|
|
@@ -13494,9 +13557,7 @@ var StoreDelta = class {
|
|
|
13494
13557
|
/**
|
|
13495
13558
|
* Apply the delta to the passed elements and appState, does not modify the snapshot.
|
|
13496
13559
|
*/
|
|
13497
|
-
static applyTo(delta, elements, appState, options
|
|
13498
|
-
excludedProperties: /* @__PURE__ */ new Set()
|
|
13499
|
-
}) {
|
|
13560
|
+
static applyTo(delta, elements, appState, options) {
|
|
13500
13561
|
const [nextElements, elementsContainVisibleChange] = delta.elements.applyTo(
|
|
13501
13562
|
elements,
|
|
13502
13563
|
StoreSnapshot.empty().elements,
|
|
@@ -13762,8 +13823,7 @@ var getDefaultObservedAppState = () => {
|
|
|
13762
13823
|
viewBackgroundColor: COLOR_PALETTE2.white,
|
|
13763
13824
|
selectedElementIds: {},
|
|
13764
13825
|
selectedGroupIds: {},
|
|
13765
|
-
|
|
13766
|
-
selectedLinearElementId: null,
|
|
13826
|
+
selectedLinearElement: null,
|
|
13767
13827
|
croppingElementId: null,
|
|
13768
13828
|
activeLockedId: null,
|
|
13769
13829
|
lockedMultiSelections: {}
|
|
@@ -13779,10 +13839,10 @@ var getObservedAppState = (appState) => {
|
|
|
13779
13839
|
croppingElementId: appState.croppingElementId,
|
|
13780
13840
|
activeLockedId: appState.activeLockedId,
|
|
13781
13841
|
lockedMultiSelections: appState.lockedMultiSelections,
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13842
|
+
selectedLinearElement: appState.selectedLinearElement ? {
|
|
13843
|
+
elementId: appState.selectedLinearElement.elementId,
|
|
13844
|
+
isEditing: !!appState.selectedLinearElement.isEditing
|
|
13845
|
+
} : null
|
|
13786
13846
|
};
|
|
13787
13847
|
Reflect.defineProperty(observedAppState, hiddenObservedAppStateProp, {
|
|
13788
13848
|
value: true,
|
|
@@ -14346,9 +14406,9 @@ var Scene = class {
|
|
|
14346
14406
|
getFramesIncludingDeleted() {
|
|
14347
14407
|
return this.frames;
|
|
14348
14408
|
}
|
|
14349
|
-
constructor(elements = null) {
|
|
14409
|
+
constructor(elements = null, options) {
|
|
14350
14410
|
if (elements) {
|
|
14351
|
-
this.replaceAllElements(elements);
|
|
14411
|
+
this.replaceAllElements(elements, options);
|
|
14352
14412
|
}
|
|
14353
14413
|
}
|
|
14354
14414
|
getSelectedElements(opts) {
|
|
@@ -14413,10 +14473,12 @@ var Scene = class {
|
|
|
14413
14473
|
}
|
|
14414
14474
|
return didChange;
|
|
14415
14475
|
}
|
|
14416
|
-
replaceAllElements(nextElements) {
|
|
14476
|
+
replaceAllElements(nextElements, options) {
|
|
14417
14477
|
const _nextElements = toArray(nextElements);
|
|
14418
14478
|
const nextFrameLikes = [];
|
|
14419
|
-
|
|
14479
|
+
if (!options?.skipValidation) {
|
|
14480
|
+
validateIndicesThrottled(_nextElements);
|
|
14481
|
+
}
|
|
14420
14482
|
this.elements = syncInvalidIndices2(_nextElements);
|
|
14421
14483
|
this.elementsMap.clear();
|
|
14422
14484
|
this.elements.forEach((element) => {
|
|
@@ -14586,6 +14648,15 @@ var Delta = class _Delta {
|
|
|
14586
14648
|
static isEmpty(delta) {
|
|
14587
14649
|
return !Object.keys(delta.deleted).length && !Object.keys(delta.inserted).length;
|
|
14588
14650
|
}
|
|
14651
|
+
/**
|
|
14652
|
+
* Merges two deltas into a new one.
|
|
14653
|
+
*/
|
|
14654
|
+
static merge(delta1, delta2) {
|
|
14655
|
+
return _Delta.create(
|
|
14656
|
+
{ ...delta1.deleted, ...delta2.deleted },
|
|
14657
|
+
{ ...delta1.inserted, ...delta2.inserted }
|
|
14658
|
+
);
|
|
14659
|
+
}
|
|
14589
14660
|
/**
|
|
14590
14661
|
* Merges deleted and inserted object partials.
|
|
14591
14662
|
*/
|
|
@@ -14810,6 +14881,9 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14810
14881
|
constructor(delta) {
|
|
14811
14882
|
this.delta = delta;
|
|
14812
14883
|
}
|
|
14884
|
+
static create(delta) {
|
|
14885
|
+
return new _AppStateDelta(delta);
|
|
14886
|
+
}
|
|
14813
14887
|
static calculate(prevAppState, nextAppState) {
|
|
14814
14888
|
const delta = Delta.calculate(
|
|
14815
14889
|
prevAppState,
|
|
@@ -14831,50 +14905,45 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14831
14905
|
const inversedDelta = Delta.create(this.delta.inserted, this.delta.deleted);
|
|
14832
14906
|
return new _AppStateDelta(inversedDelta);
|
|
14833
14907
|
}
|
|
14908
|
+
squash(delta) {
|
|
14909
|
+
this.delta = Delta.merge(this.delta, delta.delta);
|
|
14910
|
+
return this;
|
|
14911
|
+
}
|
|
14834
14912
|
applyTo(appState, nextElements) {
|
|
14835
14913
|
try {
|
|
14836
14914
|
const {
|
|
14837
|
-
selectedElementIds:
|
|
14838
|
-
selectedGroupIds:
|
|
14915
|
+
selectedElementIds: deletedSelectedElementIds = {},
|
|
14916
|
+
selectedGroupIds: deletedSelectedGroupIds = {}
|
|
14839
14917
|
} = this.delta.deleted;
|
|
14840
14918
|
const {
|
|
14841
|
-
selectedElementIds:
|
|
14842
|
-
selectedGroupIds:
|
|
14843
|
-
|
|
14844
|
-
editingLinearElementId,
|
|
14919
|
+
selectedElementIds: insertedSelectedElementIds = {},
|
|
14920
|
+
selectedGroupIds: insertedSelectedGroupIds = {},
|
|
14921
|
+
selectedLinearElement: insertedSelectedLinearElement,
|
|
14845
14922
|
...directlyApplicablePartial
|
|
14846
14923
|
} = this.delta.inserted;
|
|
14847
14924
|
const mergedSelectedElementIds = Delta.mergeObjects(
|
|
14848
14925
|
appState.selectedElementIds,
|
|
14849
|
-
|
|
14850
|
-
|
|
14926
|
+
insertedSelectedElementIds,
|
|
14927
|
+
deletedSelectedElementIds
|
|
14851
14928
|
);
|
|
14852
14929
|
const mergedSelectedGroupIds = Delta.mergeObjects(
|
|
14853
14930
|
appState.selectedGroupIds,
|
|
14854
|
-
|
|
14855
|
-
|
|
14931
|
+
insertedSelectedGroupIds,
|
|
14932
|
+
deletedSelectedGroupIds
|
|
14856
14933
|
);
|
|
14857
|
-
const selectedLinearElement =
|
|
14934
|
+
const selectedLinearElement = insertedSelectedLinearElement && nextElements.has(insertedSelectedLinearElement.elementId) ? new LinearElementEditor(
|
|
14858
14935
|
nextElements.get(
|
|
14859
|
-
|
|
14936
|
+
insertedSelectedLinearElement.elementId
|
|
14860
14937
|
),
|
|
14861
|
-
nextElements
|
|
14862
|
-
|
|
14863
|
-
const editingLinearElement = editingLinearElementId && nextElements.has(editingLinearElementId) ? new LinearElementEditor(
|
|
14864
|
-
nextElements.get(
|
|
14865
|
-
editingLinearElementId
|
|
14866
|
-
),
|
|
14867
|
-
nextElements
|
|
14938
|
+
nextElements,
|
|
14939
|
+
insertedSelectedLinearElement.isEditing
|
|
14868
14940
|
) : null;
|
|
14869
14941
|
const nextAppState = {
|
|
14870
14942
|
...appState,
|
|
14871
14943
|
...directlyApplicablePartial,
|
|
14872
14944
|
selectedElementIds: mergedSelectedElementIds,
|
|
14873
14945
|
selectedGroupIds: mergedSelectedGroupIds,
|
|
14874
|
-
selectedLinearElement: typeof
|
|
14875
|
-
// otherwise assign what we had before
|
|
14876
|
-
editingLinearElement: typeof editingLinearElementId !== "undefined" ? editingLinearElement : appState.editingLinearElement
|
|
14877
|
-
// otherwise assign what we had before
|
|
14946
|
+
selectedLinearElement: typeof insertedSelectedLinearElement !== "undefined" ? selectedLinearElement : appState.selectedLinearElement
|
|
14878
14947
|
};
|
|
14879
14948
|
const constainsVisibleChanges = this.filterInvisibleChanges(
|
|
14880
14949
|
appState,
|
|
@@ -14964,57 +15033,44 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14964
15033
|
nextAppState[key] = null;
|
|
14965
15034
|
}
|
|
14966
15035
|
break;
|
|
14967
|
-
case "
|
|
14968
|
-
|
|
14969
|
-
|
|
14970
|
-
const linearElement = nextAppState[appStateKey];
|
|
14971
|
-
if (!linearElement) {
|
|
15036
|
+
case "selectedLinearElement":
|
|
15037
|
+
const nextLinearElement = nextAppState[key];
|
|
15038
|
+
if (!nextLinearElement) {
|
|
14972
15039
|
visibleDifferenceFlag.value = true;
|
|
14973
15040
|
} else {
|
|
14974
|
-
const element = nextElements.get(
|
|
15041
|
+
const element = nextElements.get(nextLinearElement.elementId);
|
|
14975
15042
|
if (element && !element.isDeleted) {
|
|
14976
15043
|
visibleDifferenceFlag.value = true;
|
|
14977
15044
|
} else {
|
|
14978
|
-
nextAppState[
|
|
15045
|
+
nextAppState[key] = null;
|
|
14979
15046
|
}
|
|
14980
15047
|
}
|
|
14981
15048
|
break;
|
|
14982
|
-
case "lockedMultiSelections":
|
|
15049
|
+
case "lockedMultiSelections":
|
|
14983
15050
|
const prevLockedUnits = prevAppState[key] || {};
|
|
14984
15051
|
const nextLockedUnits = nextAppState[key] || {};
|
|
14985
15052
|
if (!isShallowEqual2(prevLockedUnits, nextLockedUnits)) {
|
|
14986
15053
|
visibleDifferenceFlag.value = true;
|
|
14987
15054
|
}
|
|
14988
15055
|
break;
|
|
14989
|
-
|
|
14990
|
-
case "activeLockedId": {
|
|
15056
|
+
case "activeLockedId":
|
|
14991
15057
|
const prevHitLockedId = prevAppState[key] || null;
|
|
14992
15058
|
const nextHitLockedId = nextAppState[key] || null;
|
|
14993
15059
|
if (prevHitLockedId !== nextHitLockedId) {
|
|
14994
15060
|
visibleDifferenceFlag.value = true;
|
|
14995
15061
|
}
|
|
14996
15062
|
break;
|
|
14997
|
-
|
|
14998
|
-
default: {
|
|
15063
|
+
default:
|
|
14999
15064
|
assertNever4(
|
|
15000
15065
|
key,
|
|
15001
15066
|
`Unknown ObservedElementsAppState's key "${key}"`,
|
|
15002
15067
|
true
|
|
15003
15068
|
);
|
|
15004
|
-
}
|
|
15005
15069
|
}
|
|
15006
15070
|
}
|
|
15007
15071
|
}
|
|
15008
15072
|
return visibleDifferenceFlag.value;
|
|
15009
15073
|
}
|
|
15010
|
-
static convertToAppStateKey(key) {
|
|
15011
|
-
switch (key) {
|
|
15012
|
-
case "selectedLinearElementId":
|
|
15013
|
-
return "selectedLinearElement";
|
|
15014
|
-
case "editingLinearElementId":
|
|
15015
|
-
return "editingLinearElement";
|
|
15016
|
-
}
|
|
15017
|
-
}
|
|
15018
15074
|
static filterSelectedElements(selectedElementIds, elements, visibleDifferenceFlag) {
|
|
15019
15075
|
const ids = Object.keys(selectedElementIds);
|
|
15020
15076
|
if (!ids.length) {
|
|
@@ -15053,8 +15109,7 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
15053
15109
|
editingGroupId,
|
|
15054
15110
|
selectedGroupIds,
|
|
15055
15111
|
selectedElementIds,
|
|
15056
|
-
|
|
15057
|
-
selectedLinearElementId,
|
|
15112
|
+
selectedLinearElement,
|
|
15058
15113
|
croppingElementId,
|
|
15059
15114
|
lockedMultiSelections,
|
|
15060
15115
|
activeLockedId,
|
|
@@ -15208,7 +15263,7 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15208
15263
|
for (const prevElement of prevElements.values()) {
|
|
15209
15264
|
const nextElement = nextElements.get(prevElement.id);
|
|
15210
15265
|
if (!nextElement) {
|
|
15211
|
-
const deleted = { ...prevElement
|
|
15266
|
+
const deleted = { ...prevElement };
|
|
15212
15267
|
const inserted = {
|
|
15213
15268
|
isDeleted: true,
|
|
15214
15269
|
version: prevElement.version + 1,
|
|
@@ -15219,7 +15274,9 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15219
15274
|
inserted,
|
|
15220
15275
|
_ElementsDelta.stripIrrelevantProps
|
|
15221
15276
|
);
|
|
15222
|
-
|
|
15277
|
+
if (!prevElement.isDeleted) {
|
|
15278
|
+
removed[prevElement.id] = delta;
|
|
15279
|
+
}
|
|
15223
15280
|
}
|
|
15224
15281
|
}
|
|
15225
15282
|
for (const nextElement of nextElements.values()) {
|
|
@@ -15231,15 +15288,16 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15231
15288
|
versionNonce: randomInteger4()
|
|
15232
15289
|
};
|
|
15233
15290
|
const inserted = {
|
|
15234
|
-
...nextElement
|
|
15235
|
-
isDeleted: false
|
|
15291
|
+
...nextElement
|
|
15236
15292
|
};
|
|
15237
15293
|
const delta = Delta.create(
|
|
15238
15294
|
deleted,
|
|
15239
15295
|
inserted,
|
|
15240
15296
|
_ElementsDelta.stripIrrelevantProps
|
|
15241
15297
|
);
|
|
15242
|
-
|
|
15298
|
+
if (!nextElement.isDeleted) {
|
|
15299
|
+
added[nextElement.id] = delta;
|
|
15300
|
+
}
|
|
15243
15301
|
continue;
|
|
15244
15302
|
}
|
|
15245
15303
|
if (prevElement.versionNonce !== nextElement.versionNonce) {
|
|
@@ -15260,7 +15318,11 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15260
15318
|
}
|
|
15261
15319
|
continue;
|
|
15262
15320
|
}
|
|
15263
|
-
|
|
15321
|
+
const strippedDeleted = _ElementsDelta.stripVersionProps(delta.deleted);
|
|
15322
|
+
const strippedInserted = _ElementsDelta.stripVersionProps(
|
|
15323
|
+
delta.inserted
|
|
15324
|
+
);
|
|
15325
|
+
if (Delta.isInnerDifferent(strippedDeleted, strippedInserted, true)) {
|
|
15264
15326
|
updated[nextElement.id] = delta;
|
|
15265
15327
|
}
|
|
15266
15328
|
}
|
|
@@ -15273,8 +15335,8 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15273
15335
|
inverse() {
|
|
15274
15336
|
const inverseInternal = (deltas) => {
|
|
15275
15337
|
const inversedDeltas = {};
|
|
15276
|
-
for (const [id,
|
|
15277
|
-
inversedDeltas[id] = Delta.create(
|
|
15338
|
+
for (const [id, { inserted, deleted }] of Object.entries(deltas)) {
|
|
15339
|
+
inversedDeltas[id] = Delta.create({ ...inserted }, { ...deleted });
|
|
15278
15340
|
}
|
|
15279
15341
|
return inversedDeltas;
|
|
15280
15342
|
};
|
|
@@ -15338,7 +15400,13 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15338
15400
|
} else {
|
|
15339
15401
|
latestDelta = delta;
|
|
15340
15402
|
}
|
|
15341
|
-
|
|
15403
|
+
const strippedDeleted = _ElementsDelta.stripVersionProps(
|
|
15404
|
+
latestDelta.deleted
|
|
15405
|
+
);
|
|
15406
|
+
const strippedInserted = _ElementsDelta.stripVersionProps(
|
|
15407
|
+
latestDelta.inserted
|
|
15408
|
+
);
|
|
15409
|
+
if (Delta.isInnerDifferent(strippedDeleted, strippedInserted)) {
|
|
15342
15410
|
modifiedDeltas[id] = latestDelta;
|
|
15343
15411
|
}
|
|
15344
15412
|
}
|
|
@@ -15352,26 +15420,30 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15352
15420
|
// redistribute the deltas as `isDeleted` could have been updated
|
|
15353
15421
|
});
|
|
15354
15422
|
}
|
|
15355
|
-
applyTo(elements, snapshot = StoreSnapshot.empty().elements, options
|
|
15356
|
-
excludedProperties: /* @__PURE__ */ new Set()
|
|
15357
|
-
}) {
|
|
15423
|
+
applyTo(elements, snapshot = StoreSnapshot.empty().elements, options) {
|
|
15358
15424
|
let nextElements = new Map(elements);
|
|
15359
15425
|
let changedElements;
|
|
15360
15426
|
const flags = {
|
|
15361
15427
|
containsVisibleDifference: false,
|
|
15362
|
-
containsZindexDifference: false
|
|
15428
|
+
containsZindexDifference: false,
|
|
15429
|
+
applyDirection: void 0
|
|
15363
15430
|
};
|
|
15364
15431
|
try {
|
|
15365
15432
|
const applyDeltas = _ElementsDelta.createApplier(
|
|
15433
|
+
elements,
|
|
15366
15434
|
nextElements,
|
|
15367
15435
|
snapshot,
|
|
15368
|
-
|
|
15369
|
-
|
|
15436
|
+
flags,
|
|
15437
|
+
options
|
|
15370
15438
|
);
|
|
15371
15439
|
const addedElements = applyDeltas(this.added);
|
|
15372
15440
|
const removedElements = applyDeltas(this.removed);
|
|
15373
15441
|
const updatedElements = applyDeltas(this.updated);
|
|
15374
|
-
const affectedElements = this.resolveConflicts(
|
|
15442
|
+
const affectedElements = this.resolveConflicts(
|
|
15443
|
+
elements,
|
|
15444
|
+
nextElements,
|
|
15445
|
+
flags.applyDirection
|
|
15446
|
+
);
|
|
15375
15447
|
changedElements = new Map([
|
|
15376
15448
|
...addedElements,
|
|
15377
15449
|
...removedElements,
|
|
@@ -15391,9 +15463,7 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15391
15463
|
changedElements,
|
|
15392
15464
|
flags
|
|
15393
15465
|
);
|
|
15394
|
-
|
|
15395
|
-
_ElementsDelta.redrawTextBoundingBoxes(tempScene, changedElements);
|
|
15396
|
-
_ElementsDelta.redrawBoundArrows(tempScene, changedElements);
|
|
15466
|
+
_ElementsDelta.redrawElements(nextElements, changedElements);
|
|
15397
15467
|
} catch (e) {
|
|
15398
15468
|
console.error(
|
|
15399
15469
|
`Couldn't mutate elements after applying elements change`,
|
|
@@ -15406,7 +15476,35 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15406
15476
|
return [nextElements, flags.containsVisibleDifference];
|
|
15407
15477
|
}
|
|
15408
15478
|
}
|
|
15409
|
-
|
|
15479
|
+
squash(delta) {
|
|
15480
|
+
const { added, removed, updated } = delta;
|
|
15481
|
+
for (const [id, nextDelta] of Object.entries(added)) {
|
|
15482
|
+
const prevDelta = this.added[id];
|
|
15483
|
+
if (!prevDelta) {
|
|
15484
|
+
this.added[id] = nextDelta;
|
|
15485
|
+
} else {
|
|
15486
|
+
this.added[id] = Delta.merge(prevDelta, nextDelta);
|
|
15487
|
+
}
|
|
15488
|
+
}
|
|
15489
|
+
for (const [id, nextDelta] of Object.entries(removed)) {
|
|
15490
|
+
const prevDelta = this.removed[id];
|
|
15491
|
+
if (!prevDelta) {
|
|
15492
|
+
this.removed[id] = nextDelta;
|
|
15493
|
+
} else {
|
|
15494
|
+
this.removed[id] = Delta.merge(prevDelta, nextDelta);
|
|
15495
|
+
}
|
|
15496
|
+
}
|
|
15497
|
+
for (const [id, nextDelta] of Object.entries(updated)) {
|
|
15498
|
+
const prevDelta = this.updated[id];
|
|
15499
|
+
if (!prevDelta) {
|
|
15500
|
+
this.updated[id] = nextDelta;
|
|
15501
|
+
} else {
|
|
15502
|
+
this.updated[id] = Delta.merge(prevDelta, nextDelta);
|
|
15503
|
+
}
|
|
15504
|
+
}
|
|
15505
|
+
return this;
|
|
15506
|
+
}
|
|
15507
|
+
static createApplier = (prevElements, nextElements, snapshot, flags, options) => (deltas) => {
|
|
15410
15508
|
const getElement = _ElementsDelta.createGetter(
|
|
15411
15509
|
nextElements,
|
|
15412
15510
|
snapshot,
|
|
@@ -15415,14 +15513,20 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15415
15513
|
return Object.entries(deltas).reduce((acc, [id, delta]) => {
|
|
15416
15514
|
const element = getElement(id, delta.inserted);
|
|
15417
15515
|
if (element) {
|
|
15418
|
-
const
|
|
15516
|
+
const nextElement = _ElementsDelta.applyDelta(
|
|
15419
15517
|
element,
|
|
15420
15518
|
delta,
|
|
15421
|
-
|
|
15422
|
-
|
|
15519
|
+
flags,
|
|
15520
|
+
options
|
|
15423
15521
|
);
|
|
15424
|
-
nextElements.set(
|
|
15425
|
-
acc.set(
|
|
15522
|
+
nextElements.set(nextElement.id, nextElement);
|
|
15523
|
+
acc.set(nextElement.id, nextElement);
|
|
15524
|
+
if (!flags.applyDirection) {
|
|
15525
|
+
const prevElement = prevElements.get(id);
|
|
15526
|
+
if (prevElement) {
|
|
15527
|
+
flags.applyDirection = prevElement.version > nextElement.version ? "backward" : "forward";
|
|
15528
|
+
}
|
|
15529
|
+
}
|
|
15426
15530
|
}
|
|
15427
15531
|
return acc;
|
|
15428
15532
|
}, /* @__PURE__ */ new Map());
|
|
@@ -15447,13 +15551,13 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15447
15551
|
}
|
|
15448
15552
|
return element;
|
|
15449
15553
|
};
|
|
15450
|
-
static applyDelta(element, delta,
|
|
15554
|
+
static applyDelta(element, delta, flags, options) {
|
|
15451
15555
|
const directlyApplicablePartial = {};
|
|
15452
15556
|
for (const key of Object.keys(delta.inserted)) {
|
|
15453
15557
|
if (key === "boundElements") {
|
|
15454
15558
|
continue;
|
|
15455
15559
|
}
|
|
15456
|
-
if (options
|
|
15560
|
+
if (options?.excludedProperties?.has(key)) {
|
|
15457
15561
|
continue;
|
|
15458
15562
|
}
|
|
15459
15563
|
const value = delta.inserted[key];
|
|
@@ -15481,7 +15585,7 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15481
15585
|
if (!flags.containsZindexDifference) {
|
|
15482
15586
|
flags.containsZindexDifference = delta.deleted.index !== delta.inserted.index;
|
|
15483
15587
|
}
|
|
15484
|
-
return newElementWith(element, directlyApplicablePartial);
|
|
15588
|
+
return newElementWith(element, directlyApplicablePartial, true);
|
|
15485
15589
|
}
|
|
15486
15590
|
/**
|
|
15487
15591
|
* Check for visible changes regardless of whether they were removed, added or updated.
|
|
@@ -15506,25 +15610,31 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15506
15610
|
*
|
|
15507
15611
|
* @returns all elements affected by the conflict resolution
|
|
15508
15612
|
*/
|
|
15509
|
-
resolveConflicts(prevElements, nextElements) {
|
|
15613
|
+
resolveConflicts(prevElements, nextElements, applyDirection = "forward") {
|
|
15510
15614
|
const nextAffectedElements = /* @__PURE__ */ new Map();
|
|
15511
15615
|
const updater = (element, updates) => {
|
|
15512
15616
|
const nextElement = nextElements.get(element.id);
|
|
15513
15617
|
if (!nextElement) {
|
|
15514
15618
|
return;
|
|
15515
15619
|
}
|
|
15620
|
+
const prevElement = prevElements.get(element.id);
|
|
15621
|
+
const elementUpdates = updates;
|
|
15516
15622
|
let affectedElement;
|
|
15517
|
-
if (
|
|
15623
|
+
if (prevElement === nextElement) {
|
|
15518
15624
|
affectedElement = newElementWith(
|
|
15519
15625
|
nextElement,
|
|
15520
|
-
|
|
15626
|
+
{
|
|
15627
|
+
...elementUpdates,
|
|
15628
|
+
version: applyDirection === "forward" ? nextElement.version + 1 : nextElement.version - 1
|
|
15629
|
+
},
|
|
15630
|
+
true
|
|
15521
15631
|
);
|
|
15522
15632
|
} else {
|
|
15523
|
-
affectedElement = mutateElement(
|
|
15524
|
-
|
|
15525
|
-
|
|
15526
|
-
|
|
15527
|
-
);
|
|
15633
|
+
affectedElement = mutateElement(nextElement, nextElements, {
|
|
15634
|
+
...elementUpdates,
|
|
15635
|
+
// don't modify the version further, as we've already updated it
|
|
15636
|
+
version: nextElement.version
|
|
15637
|
+
});
|
|
15528
15638
|
}
|
|
15529
15639
|
nextAffectedElements.set(affectedElement.id, affectedElement);
|
|
15530
15640
|
nextElements.set(affectedElement.id, affectedElement);
|
|
@@ -15549,19 +15659,10 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15549
15659
|
const prevAffectedElements = new Map(
|
|
15550
15660
|
Array.from(prevElements).filter(([id]) => nextAffectedElements.has(id))
|
|
15551
15661
|
);
|
|
15552
|
-
|
|
15553
|
-
|
|
15554
|
-
nextAffectedElements
|
|
15662
|
+
this.squash(
|
|
15663
|
+
// technically we could do better here if perf. would become an issue
|
|
15664
|
+
_ElementsDelta.calculate(prevAffectedElements, nextAffectedElements)
|
|
15555
15665
|
);
|
|
15556
|
-
for (const [id, delta] of Object.entries(added)) {
|
|
15557
|
-
this.added[id] = delta;
|
|
15558
|
-
}
|
|
15559
|
-
for (const [id, delta] of Object.entries(removed)) {
|
|
15560
|
-
this.removed[id] = delta;
|
|
15561
|
-
}
|
|
15562
|
-
for (const [id, delta] of Object.entries(updated)) {
|
|
15563
|
-
this.updated[id] = delta;
|
|
15564
|
-
}
|
|
15565
15666
|
return nextAffectedElements;
|
|
15566
15667
|
}
|
|
15567
15668
|
/**
|
|
@@ -15596,6 +15697,20 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15596
15697
|
);
|
|
15597
15698
|
BindableElement.rebindAffected(nextElements, nextElement(), updater);
|
|
15598
15699
|
}
|
|
15700
|
+
static redrawElements(nextElements, changedElements) {
|
|
15701
|
+
try {
|
|
15702
|
+
const tempScene = new Scene(nextElements, { skipValidation: true });
|
|
15703
|
+
_ElementsDelta.redrawTextBoundingBoxes(tempScene, changedElements);
|
|
15704
|
+
_ElementsDelta.redrawBoundArrows(tempScene, changedElements);
|
|
15705
|
+
} catch (e) {
|
|
15706
|
+
console.error(`Couldn't redraw elements`, e);
|
|
15707
|
+
if (isTestEnv8() || isDevEnv7()) {
|
|
15708
|
+
throw e;
|
|
15709
|
+
}
|
|
15710
|
+
} finally {
|
|
15711
|
+
return nextElements;
|
|
15712
|
+
}
|
|
15713
|
+
}
|
|
15599
15714
|
static redrawTextBoundingBoxes(scene, changed) {
|
|
15600
15715
|
const elements = scene.getNonDeletedElementsMap();
|
|
15601
15716
|
const boxesToRedraw = /* @__PURE__ */ new Map();
|
|
@@ -15684,14 +15799,22 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15684
15799
|
const { id, updated, ...strippedPartial } = partial;
|
|
15685
15800
|
return strippedPartial;
|
|
15686
15801
|
}
|
|
15802
|
+
static stripVersionProps(partial) {
|
|
15803
|
+
const { version, versionNonce, ...strippedPartial } = partial;
|
|
15804
|
+
return strippedPartial;
|
|
15805
|
+
}
|
|
15687
15806
|
};
|
|
15688
15807
|
|
|
15689
15808
|
// src/distribute.ts
|
|
15690
15809
|
init_define_import_meta_env();
|
|
15691
|
-
var distributeElements = (selectedElements, elementsMap, distribution) => {
|
|
15810
|
+
var distributeElements = (selectedElements, elementsMap, distribution, appState) => {
|
|
15692
15811
|
const [start, mid, end, extent] = distribution.axis === "x" ? ["minX", "midX", "maxX", "width"] : ["minY", "midY", "maxY", "height"];
|
|
15693
15812
|
const bounds = getCommonBoundingBox(selectedElements);
|
|
15694
|
-
const groups =
|
|
15813
|
+
const groups = getSelectedElementsByGroup(
|
|
15814
|
+
selectedElements,
|
|
15815
|
+
elementsMap,
|
|
15816
|
+
appState
|
|
15817
|
+
).map((group) => [group, getCommonBoundingBox(group)]).sort((a2, b2) => a2[1][mid] - b2[1][mid]);
|
|
15695
15818
|
let span = 0;
|
|
15696
15819
|
for (const group of groups) {
|
|
15697
15820
|
span += group[1][extent];
|
|
@@ -18403,7 +18526,7 @@ var getTransformHandles = (element, zoom, elementsMap, pointerType = "mouse", om
|
|
|
18403
18526
|
);
|
|
18404
18527
|
};
|
|
18405
18528
|
var shouldShowBoundingBox = (elements, appState) => {
|
|
18406
|
-
if (appState.
|
|
18529
|
+
if (appState.selectedLinearElement?.isEditing) {
|
|
18407
18530
|
return false;
|
|
18408
18531
|
}
|
|
18409
18532
|
if (elements.length > 1) {
|
|
@@ -19151,6 +19274,7 @@ export {
|
|
|
19151
19274
|
getRootElements,
|
|
19152
19275
|
getSceneVersion,
|
|
19153
19276
|
getSelectedElements,
|
|
19277
|
+
getSelectedElementsByGroup,
|
|
19154
19278
|
getSelectedGroupForElement,
|
|
19155
19279
|
getSelectedGroupIdForElement,
|
|
19156
19280
|
getSelectedGroupIds,
|