@excalidraw/element 0.18.0-4e471c107 → 0.18.0-b16b6f8fd
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 +160 -73
- package/dist/dev/index.js.map +3 -3
- package/dist/prod/index.js +11 -11
- package/dist/types/common/src/constants.d.ts +1 -0
- package/dist/types/element/src/align.d.ts +2 -1
- 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/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 +13 -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/Ellipsify.d.ts +4 -0
- package/dist/types/excalidraw/index.d.ts +1 -0
- package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
- package/dist/types/excalidraw/types.d.ts +1 -3
- 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 === "") {
|
|
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) => {
|
|
@@ -12797,6 +12849,7 @@ import {
|
|
|
12797
12849
|
arrayToMap as arrayToMap10,
|
|
12798
12850
|
arrayToObject,
|
|
12799
12851
|
assertNever as assertNever4,
|
|
12852
|
+
invariant as invariant8,
|
|
12800
12853
|
isDevEnv as isDevEnv7,
|
|
12801
12854
|
isShallowEqual as isShallowEqual2,
|
|
12802
12855
|
isTestEnv as isTestEnv8,
|
|
@@ -13185,8 +13238,9 @@ var Store = class {
|
|
|
13185
13238
|
constructor(app) {
|
|
13186
13239
|
this.app = app;
|
|
13187
13240
|
}
|
|
13188
|
-
//
|
|
13241
|
+
// for internal use by history
|
|
13189
13242
|
onDurableIncrementEmitter = new Emitter();
|
|
13243
|
+
// for public use as part of onIncrement API
|
|
13190
13244
|
onStoreIncrementEmitter = new Emitter();
|
|
13191
13245
|
scheduledMacroActions = /* @__PURE__ */ new Set();
|
|
13192
13246
|
scheduledMicroActions = [];
|
|
@@ -13762,8 +13816,8 @@ var getDefaultObservedAppState = () => {
|
|
|
13762
13816
|
viewBackgroundColor: COLOR_PALETTE2.white,
|
|
13763
13817
|
selectedElementIds: {},
|
|
13764
13818
|
selectedGroupIds: {},
|
|
13765
|
-
editingLinearElementId: null,
|
|
13766
13819
|
selectedLinearElementId: null,
|
|
13820
|
+
selectedLinearElementIsEditing: null,
|
|
13767
13821
|
croppingElementId: null,
|
|
13768
13822
|
activeLockedId: null,
|
|
13769
13823
|
lockedMultiSelections: {}
|
|
@@ -13779,10 +13833,8 @@ var getObservedAppState = (appState) => {
|
|
|
13779
13833
|
croppingElementId: appState.croppingElementId,
|
|
13780
13834
|
activeLockedId: appState.activeLockedId,
|
|
13781
13835
|
lockedMultiSelections: appState.lockedMultiSelections,
|
|
13782
|
-
|
|
13783
|
-
appState.
|
|
13784
|
-
null,
|
|
13785
|
-
selectedLinearElementId: appState.selectedLinearElement?.elementId ?? appState.selectedLinearElementId ?? null
|
|
13836
|
+
selectedLinearElementId: appState.selectedLinearElement?.elementId ?? appState.selectedLinearElementId ?? null,
|
|
13837
|
+
selectedLinearElementIsEditing: appState.selectedLinearElement?.isEditing ?? appState.selectedLinearElementIsEditing ?? null
|
|
13786
13838
|
};
|
|
13787
13839
|
Reflect.defineProperty(observedAppState, hiddenObservedAppStateProp, {
|
|
13788
13840
|
value: true,
|
|
@@ -14841,7 +14893,7 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14841
14893
|
selectedElementIds: addedSelectedElementIds = {},
|
|
14842
14894
|
selectedGroupIds: addedSelectedGroupIds = {},
|
|
14843
14895
|
selectedLinearElementId,
|
|
14844
|
-
|
|
14896
|
+
selectedLinearElementIsEditing,
|
|
14845
14897
|
...directlyApplicablePartial
|
|
14846
14898
|
} = this.delta.inserted;
|
|
14847
14899
|
const mergedSelectedElementIds = Delta.mergeObjects(
|
|
@@ -14854,27 +14906,39 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14854
14906
|
addedSelectedGroupIds,
|
|
14855
14907
|
removedSelectedGroupIds
|
|
14856
14908
|
);
|
|
14857
|
-
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
14868
|
-
|
|
14909
|
+
let selectedLinearElement = appState.selectedLinearElement;
|
|
14910
|
+
if (selectedLinearElementId === null) {
|
|
14911
|
+
selectedLinearElement = null;
|
|
14912
|
+
} else if (selectedLinearElementId && nextElements.has(selectedLinearElementId)) {
|
|
14913
|
+
selectedLinearElement = new LinearElementEditor(
|
|
14914
|
+
nextElements.get(
|
|
14915
|
+
selectedLinearElementId
|
|
14916
|
+
),
|
|
14917
|
+
nextElements,
|
|
14918
|
+
selectedLinearElementIsEditing === true
|
|
14919
|
+
// Can be unknown which is defaulted to false
|
|
14920
|
+
);
|
|
14921
|
+
}
|
|
14922
|
+
if (
|
|
14923
|
+
// Value being 'null' is equivaluent to unknown in this case because it only gets set
|
|
14924
|
+
// to null when 'selectedLinearElementId' is set to null
|
|
14925
|
+
selectedLinearElementIsEditing != null
|
|
14926
|
+
) {
|
|
14927
|
+
invariant8(
|
|
14928
|
+
selectedLinearElement,
|
|
14929
|
+
`selectedLinearElement is null when selectedLinearElementIsEditing is set to ${selectedLinearElementIsEditing}`
|
|
14930
|
+
);
|
|
14931
|
+
selectedLinearElement = {
|
|
14932
|
+
...selectedLinearElement,
|
|
14933
|
+
isEditing: selectedLinearElementIsEditing
|
|
14934
|
+
};
|
|
14935
|
+
}
|
|
14869
14936
|
const nextAppState = {
|
|
14870
14937
|
...appState,
|
|
14871
14938
|
...directlyApplicablePartial,
|
|
14872
14939
|
selectedElementIds: mergedSelectedElementIds,
|
|
14873
14940
|
selectedGroupIds: mergedSelectedGroupIds,
|
|
14874
|
-
selectedLinearElement
|
|
14875
|
-
// otherwise assign what we had before
|
|
14876
|
-
editingLinearElement: typeof editingLinearElementId !== "undefined" ? editingLinearElement : appState.editingLinearElement
|
|
14877
|
-
// otherwise assign what we had before
|
|
14941
|
+
selectedLinearElement
|
|
14878
14942
|
};
|
|
14879
14943
|
const constainsVisibleChanges = this.filterInvisibleChanges(
|
|
14880
14944
|
appState,
|
|
@@ -14964,8 +15028,7 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14964
15028
|
nextAppState[key] = null;
|
|
14965
15029
|
}
|
|
14966
15030
|
break;
|
|
14967
|
-
case "selectedLinearElementId":
|
|
14968
|
-
case "editingLinearElementId":
|
|
15031
|
+
case "selectedLinearElementId": {
|
|
14969
15032
|
const appStateKey = _AppStateDelta.convertToAppStateKey(key);
|
|
14970
15033
|
const linearElement = nextAppState[appStateKey];
|
|
14971
15034
|
if (!linearElement) {
|
|
@@ -14979,6 +15042,15 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14979
15042
|
}
|
|
14980
15043
|
}
|
|
14981
15044
|
break;
|
|
15045
|
+
}
|
|
15046
|
+
case "selectedLinearElementIsEditing": {
|
|
15047
|
+
const prevIsEditing = prevAppState.selectedLinearElement?.isEditing ?? false;
|
|
15048
|
+
const nextIsEditing = nextAppState.selectedLinearElement?.isEditing ?? false;
|
|
15049
|
+
if (prevIsEditing !== nextIsEditing) {
|
|
15050
|
+
visibleDifferenceFlag.value = true;
|
|
15051
|
+
}
|
|
15052
|
+
break;
|
|
15053
|
+
}
|
|
14982
15054
|
case "lockedMultiSelections": {
|
|
14983
15055
|
const prevLockedUnits = prevAppState[key] || {};
|
|
14984
15056
|
const nextLockedUnits = nextAppState[key] || {};
|
|
@@ -15011,8 +15083,6 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
15011
15083
|
switch (key) {
|
|
15012
15084
|
case "selectedLinearElementId":
|
|
15013
15085
|
return "selectedLinearElement";
|
|
15014
|
-
case "editingLinearElementId":
|
|
15015
|
-
return "editingLinearElement";
|
|
15016
15086
|
}
|
|
15017
15087
|
}
|
|
15018
15088
|
static filterSelectedElements(selectedElementIds, elements, visibleDifferenceFlag) {
|
|
@@ -15053,8 +15123,8 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
15053
15123
|
editingGroupId,
|
|
15054
15124
|
selectedGroupIds,
|
|
15055
15125
|
selectedElementIds,
|
|
15056
|
-
editingLinearElementId,
|
|
15057
15126
|
selectedLinearElementId,
|
|
15127
|
+
selectedLinearElementIsEditing,
|
|
15058
15128
|
croppingElementId,
|
|
15059
15129
|
lockedMultiSelections,
|
|
15060
15130
|
activeLockedId,
|
|
@@ -15273,8 +15343,8 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15273
15343
|
inverse() {
|
|
15274
15344
|
const inverseInternal = (deltas) => {
|
|
15275
15345
|
const inversedDeltas = {};
|
|
15276
|
-
for (const [id,
|
|
15277
|
-
inversedDeltas[id] = Delta.create(
|
|
15346
|
+
for (const [id, { inserted, deleted }] of Object.entries(deltas)) {
|
|
15347
|
+
inversedDeltas[id] = Delta.create({ ...inserted }, { ...deleted });
|
|
15278
15348
|
}
|
|
15279
15349
|
return inversedDeltas;
|
|
15280
15350
|
};
|
|
@@ -15554,13 +15624,25 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15554
15624
|
nextAffectedElements
|
|
15555
15625
|
);
|
|
15556
15626
|
for (const [id, delta] of Object.entries(added)) {
|
|
15557
|
-
this.added[id] =
|
|
15627
|
+
this.added[id] = {
|
|
15628
|
+
// merge with the existing delta, if exists
|
|
15629
|
+
...this.added[id],
|
|
15630
|
+
...delta
|
|
15631
|
+
};
|
|
15558
15632
|
}
|
|
15559
15633
|
for (const [id, delta] of Object.entries(removed)) {
|
|
15560
|
-
this.removed[id] =
|
|
15634
|
+
this.removed[id] = {
|
|
15635
|
+
// merge with the existing delta, if exists
|
|
15636
|
+
...this.removed[id],
|
|
15637
|
+
...delta
|
|
15638
|
+
};
|
|
15561
15639
|
}
|
|
15562
15640
|
for (const [id, delta] of Object.entries(updated)) {
|
|
15563
|
-
this.updated[id] =
|
|
15641
|
+
this.updated[id] = {
|
|
15642
|
+
// merge with the existing delta, if exists
|
|
15643
|
+
...this.updated[id],
|
|
15644
|
+
...delta
|
|
15645
|
+
};
|
|
15564
15646
|
}
|
|
15565
15647
|
return nextAffectedElements;
|
|
15566
15648
|
}
|
|
@@ -15688,10 +15770,14 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15688
15770
|
|
|
15689
15771
|
// src/distribute.ts
|
|
15690
15772
|
init_define_import_meta_env();
|
|
15691
|
-
var distributeElements = (selectedElements, elementsMap, distribution) => {
|
|
15773
|
+
var distributeElements = (selectedElements, elementsMap, distribution, appState) => {
|
|
15692
15774
|
const [start, mid, end, extent] = distribution.axis === "x" ? ["minX", "midX", "maxX", "width"] : ["minY", "midY", "maxY", "height"];
|
|
15693
15775
|
const bounds = getCommonBoundingBox(selectedElements);
|
|
15694
|
-
const groups =
|
|
15776
|
+
const groups = getSelectedElementsByGroup(
|
|
15777
|
+
selectedElements,
|
|
15778
|
+
elementsMap,
|
|
15779
|
+
appState
|
|
15780
|
+
).map((group) => [group, getCommonBoundingBox(group)]).sort((a2, b2) => a2[1][mid] - b2[1][mid]);
|
|
15695
15781
|
let span = 0;
|
|
15696
15782
|
for (const group of groups) {
|
|
15697
15783
|
span += group[1][extent];
|
|
@@ -16683,7 +16769,7 @@ var embeddableURLValidator = (url, validateEmbeddable) => {
|
|
|
16683
16769
|
|
|
16684
16770
|
// src/flowchart.ts
|
|
16685
16771
|
init_define_import_meta_env();
|
|
16686
|
-
import { KEYS as KEYS3, invariant as
|
|
16772
|
+
import { KEYS as KEYS3, invariant as invariant9, toBrandedType as toBrandedType2 } from "@excalidraw/common";
|
|
16687
16773
|
import { pointFrom as pointFrom13 } from "@excalidraw/math";
|
|
16688
16774
|
var VERTICAL_OFFSET = 100;
|
|
16689
16775
|
var HORIZONTAL_OFFSET = 100;
|
|
@@ -16713,7 +16799,7 @@ var getNodeRelatives = (type, node, elementsMap, direction) => {
|
|
|
16713
16799
|
if (!relative) {
|
|
16714
16800
|
return acc;
|
|
16715
16801
|
}
|
|
16716
|
-
|
|
16802
|
+
invariant9(
|
|
16717
16803
|
isBindableElement(relative),
|
|
16718
16804
|
"not an ExcalidrawBindableElement"
|
|
16719
16805
|
);
|
|
@@ -16829,7 +16915,7 @@ var addNewNode = (element, appState, direction, scene) => {
|
|
|
16829
16915
|
fillStyle: element.fillStyle,
|
|
16830
16916
|
strokeStyle: element.strokeStyle
|
|
16831
16917
|
});
|
|
16832
|
-
|
|
16918
|
+
invariant9(
|
|
16833
16919
|
isFlowchartNodeElement(nextNode),
|
|
16834
16920
|
"not an ExcalidrawFlowchartNodeElement"
|
|
16835
16921
|
);
|
|
@@ -16887,7 +16973,7 @@ var addNewNodes = (startNode, appState, direction, scene, numberOfNodes) => {
|
|
|
16887
16973
|
fillStyle: startNode.fillStyle,
|
|
16888
16974
|
strokeStyle: startNode.strokeStyle
|
|
16889
16975
|
});
|
|
16890
|
-
|
|
16976
|
+
invariant9(
|
|
16891
16977
|
isFlowchartNodeElement(nextNode),
|
|
16892
16978
|
"not an ExcalidrawFlowchartNodeElement"
|
|
16893
16979
|
);
|
|
@@ -17113,7 +17199,7 @@ var FlowChartCreator = class {
|
|
|
17113
17199
|
}
|
|
17114
17200
|
if (startNode.frameId) {
|
|
17115
17201
|
const frame = elementsMap.get(startNode.frameId);
|
|
17116
|
-
|
|
17202
|
+
invariant9(
|
|
17117
17203
|
frame && isFrameElement(frame),
|
|
17118
17204
|
"not an ExcalidrawFrameElement"
|
|
17119
17205
|
);
|
|
@@ -18403,7 +18489,7 @@ var getTransformHandles = (element, zoom, elementsMap, pointerType = "mouse", om
|
|
|
18403
18489
|
);
|
|
18404
18490
|
};
|
|
18405
18491
|
var shouldShowBoundingBox = (elements, appState) => {
|
|
18406
|
-
if (appState.
|
|
18492
|
+
if (appState.selectedLinearElement?.isEditing) {
|
|
18407
18493
|
return false;
|
|
18408
18494
|
}
|
|
18409
18495
|
if (elements.length > 1) {
|
|
@@ -19151,6 +19237,7 @@ export {
|
|
|
19151
19237
|
getRootElements,
|
|
19152
19238
|
getSceneVersion,
|
|
19153
19239
|
getSelectedElements,
|
|
19240
|
+
getSelectedElementsByGroup,
|
|
19154
19241
|
getSelectedGroupForElement,
|
|
19155
19242
|
getSelectedGroupIdForElement,
|
|
19156
19243
|
getSelectedGroupIds,
|