@mx-sose-front/mx-sose-graph 1.2.3 → 1.2.5
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/index.esm.js +103 -97
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -2
- package/src/store/graphStore.ts +125 -119
package/dist/index.esm.js
CHANGED
|
@@ -9586,116 +9586,122 @@ const useGraphStore = defineStore("graph", () => {
|
|
|
9586
9586
|
const endDragShape = async (source) => {
|
|
9587
9587
|
if (!isDragging.value)
|
|
9588
9588
|
return;
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
dragBase.value
|
|
9596
|
-
);
|
|
9597
|
-
if (!changedIds.length) {
|
|
9598
|
-
cleanupAfterDrag();
|
|
9599
|
-
return;
|
|
9600
|
-
}
|
|
9601
|
-
const prevParentById = buildPrevParentMap(shapes.value, changedIds);
|
|
9602
|
-
const containerForFinalize = hoverContainerId.value && hoverNestable.value ? hoverContainerId.value : null;
|
|
9603
|
-
const didReparent = finalizeAfterTransform(
|
|
9604
|
-
shapes.value,
|
|
9605
|
-
changedIds,
|
|
9606
|
-
dragGhost,
|
|
9607
|
-
draggingIds.value,
|
|
9608
|
-
currentDiagramId.value,
|
|
9609
|
-
containerForFinalize,
|
|
9610
|
-
updateShape
|
|
9611
|
-
);
|
|
9612
|
-
let ownerPayload = null;
|
|
9613
|
-
let clonedIds = [];
|
|
9614
|
-
if (source !== "pinDrop") {
|
|
9615
|
-
const nestResult = await applyReparentAndClone({
|
|
9616
|
-
shapes: shapes.value,
|
|
9617
|
-
changedIds,
|
|
9618
|
-
prevParentById,
|
|
9619
|
-
source,
|
|
9620
|
-
dragBase: dragBase.value,
|
|
9589
|
+
try {
|
|
9590
|
+
const changedIds = commitDrag(
|
|
9591
|
+
shapes.value,
|
|
9592
|
+
[...draggingIds.value],
|
|
9593
|
+
dragGhost,
|
|
9594
|
+
currentDiagramId.value || shapes.value[0].diagramId,
|
|
9621
9595
|
updateShape,
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
if (nestResult.cancelled) {
|
|
9596
|
+
dragBase.value
|
|
9597
|
+
);
|
|
9598
|
+
if (!changedIds.length) {
|
|
9626
9599
|
cleanupAfterDrag();
|
|
9627
9600
|
return;
|
|
9628
9601
|
}
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
if (didReparent) {
|
|
9633
|
-
normalizeZOrder(
|
|
9602
|
+
const prevParentById = buildPrevParentMap(shapes.value, changedIds);
|
|
9603
|
+
const containerForFinalize = hoverContainerId.value && hoverNestable.value ? hoverContainerId.value : null;
|
|
9604
|
+
const didReparent = finalizeAfterTransform(
|
|
9634
9605
|
shapes.value,
|
|
9606
|
+
changedIds,
|
|
9607
|
+
dragGhost,
|
|
9608
|
+
draggingIds.value,
|
|
9635
9609
|
currentDiagramId.value,
|
|
9636
|
-
|
|
9637
|
-
|
|
9638
|
-
1
|
|
9610
|
+
containerForFinalize,
|
|
9611
|
+
updateShape
|
|
9639
9612
|
);
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
const prevPid = prevParentById[id];
|
|
9645
|
-
const nowPid = node.parenShapeId ?? null;
|
|
9646
|
-
if ((!nowPid || nowPid === "") && prevPid) {
|
|
9647
|
-
updateShape(id, { parenShapeId: prevPid });
|
|
9648
|
-
}
|
|
9649
|
-
}
|
|
9650
|
-
}
|
|
9651
|
-
await EdgeUtils.updateRelatedEdgesAsync(shapes.value, changedIds, (shape) => {
|
|
9652
|
-
updateShape(shape.id, shape);
|
|
9653
|
-
}, edgesByNodeId.value, shapeMap.value);
|
|
9654
|
-
autoExpandMovedCompartmentsAfterDrag(shapes.value, changedIds, updateShape);
|
|
9655
|
-
const allReparentIds = [...changedIds, ...clonedIds];
|
|
9656
|
-
const prevMapForComparents = { ...prevParentById };
|
|
9657
|
-
for (const cid of clonedIds) {
|
|
9658
|
-
prevMapForComparents[cid] = null;
|
|
9659
|
-
}
|
|
9660
|
-
syncShowComparentsByReparent(
|
|
9661
|
-
shapes.value,
|
|
9662
|
-
allReparentIds,
|
|
9663
|
-
prevMapForComparents,
|
|
9664
|
-
(id, u2) => updateShapeRaw(id, u2)
|
|
9665
|
-
);
|
|
9666
|
-
const shapeId = ownerPayload?.shapeId;
|
|
9667
|
-
if (shapeId != null) {
|
|
9668
|
-
const child = shapeMap.value.get(shapeId) ?? null;
|
|
9669
|
-
if (child) {
|
|
9670
|
-
expandParentByChild({
|
|
9613
|
+
let ownerPayload = null;
|
|
9614
|
+
let clonedIds = [];
|
|
9615
|
+
if (source !== "pinDrop") {
|
|
9616
|
+
const nestResult = await applyReparentAndClone({
|
|
9671
9617
|
shapes: shapes.value,
|
|
9672
|
-
|
|
9673
|
-
|
|
9618
|
+
changedIds,
|
|
9619
|
+
prevParentById,
|
|
9620
|
+
source,
|
|
9621
|
+
dragBase: dragBase.value,
|
|
9622
|
+
updateShape,
|
|
9623
|
+
pendingNestedIds,
|
|
9624
|
+
addShape
|
|
9674
9625
|
});
|
|
9626
|
+
if (nestResult.cancelled) {
|
|
9627
|
+
cleanupAfterDrag();
|
|
9628
|
+
return;
|
|
9629
|
+
}
|
|
9630
|
+
ownerPayload = nestResult.ownerPayload;
|
|
9631
|
+
clonedIds = nestResult.clonedIds;
|
|
9675
9632
|
}
|
|
9676
|
-
|
|
9677
|
-
|
|
9678
|
-
|
|
9679
|
-
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
payloads.push(diagramPayload);
|
|
9633
|
+
if (didReparent) {
|
|
9634
|
+
normalizeZOrder(
|
|
9635
|
+
shapes.value,
|
|
9636
|
+
currentDiagramId.value,
|
|
9637
|
+
updateShape,
|
|
9638
|
+
1,
|
|
9639
|
+
1
|
|
9640
|
+
);
|
|
9641
|
+
}
|
|
9642
|
+
for (const id of changedIds) {
|
|
9643
|
+
const node = shapeMap.value.get(id) ?? null;
|
|
9644
|
+
if (node?.shapeType === "pin") {
|
|
9645
|
+
const prevPid = prevParentById[id];
|
|
9646
|
+
const nowPid = node.parenShapeId ?? null;
|
|
9647
|
+
if ((!nowPid || nowPid === "") && prevPid) {
|
|
9648
|
+
updateShape(id, { parenShapeId: prevPid });
|
|
9649
|
+
}
|
|
9694
9650
|
}
|
|
9695
9651
|
}
|
|
9652
|
+
await EdgeUtils.updateRelatedEdgesAsync(shapes.value, changedIds, (shape) => {
|
|
9653
|
+
updateShape(shape.id, shape);
|
|
9654
|
+
}, edgesByNodeId.value, shapeMap.value);
|
|
9655
|
+
autoExpandMovedCompartmentsAfterDrag(shapes.value, changedIds, updateShape);
|
|
9656
|
+
const allReparentIds = [...changedIds, ...clonedIds];
|
|
9657
|
+
const prevMapForComparents = { ...prevParentById };
|
|
9658
|
+
for (const cid of clonedIds) {
|
|
9659
|
+
prevMapForComparents[cid] = null;
|
|
9660
|
+
}
|
|
9661
|
+
syncShowComparentsByReparent(
|
|
9662
|
+
shapes.value,
|
|
9663
|
+
allReparentIds,
|
|
9664
|
+
prevMapForComparents,
|
|
9665
|
+
(id, u2) => updateShapeRaw(id, u2)
|
|
9666
|
+
);
|
|
9667
|
+
const shapeId = ownerPayload?.shapeId;
|
|
9668
|
+
if (shapeId != null) {
|
|
9669
|
+
const child = shapeMap.value.get(shapeId) ?? null;
|
|
9670
|
+
if (child) {
|
|
9671
|
+
expandParentByChild({
|
|
9672
|
+
shapes: shapes.value,
|
|
9673
|
+
child,
|
|
9674
|
+
updateShape
|
|
9675
|
+
});
|
|
9676
|
+
}
|
|
9677
|
+
}
|
|
9678
|
+
const affectedIds = collectAffectedShapeIds$1(shapes.value, changedIds, clonedIds);
|
|
9679
|
+
const payloads = buildDragEndPayloads(affectedIds, shapes.value);
|
|
9680
|
+
const onNestDone = createOnNestDoneCallback({
|
|
9681
|
+
shapesRef: shapes,
|
|
9682
|
+
ownerPayload,
|
|
9683
|
+
updateShape
|
|
9684
|
+
});
|
|
9685
|
+
adjustCanvasToFitAllShapes();
|
|
9686
|
+
if (dragBaseCanvasSize.value) {
|
|
9687
|
+
const currentDiagram = shapes.value.find((s2) => s2.shapeType === "diagram");
|
|
9688
|
+
if (currentDiagram) {
|
|
9689
|
+
const currentWidth = currentDiagram.bounds.width;
|
|
9690
|
+
const currentHeight = currentDiagram.bounds.height;
|
|
9691
|
+
const { width: baseWidth, height: baseHeight } = dragBaseCanvasSize.value;
|
|
9692
|
+
if (currentWidth !== baseWidth || currentHeight !== baseHeight) {
|
|
9693
|
+
const diagramPayload = _.cloneDeep(currentDiagram);
|
|
9694
|
+
payloads.push(diagramPayload);
|
|
9695
|
+
}
|
|
9696
|
+
}
|
|
9697
|
+
}
|
|
9698
|
+
eventBus.emit("shape-drag-end", payloads, ownerPayload, onNestDone);
|
|
9699
|
+
cleanupAfterDrag();
|
|
9700
|
+
} catch (e) {
|
|
9701
|
+
console.error("endDragShape 执行失败:", e);
|
|
9702
|
+
} finally {
|
|
9703
|
+
cleanupAfterDrag();
|
|
9696
9704
|
}
|
|
9697
|
-
eventBus.emit("shape-drag-end", payloads, ownerPayload, onNestDone);
|
|
9698
|
-
cleanupAfterDrag();
|
|
9699
9705
|
};
|
|
9700
9706
|
const endResizeShape = async (id) => {
|
|
9701
9707
|
await EdgeUtils.updateRelatedEdgesAsync(shapes.value, [id], (shape) => {
|