@mx-sose-front/mx-sose-graph 1.2.4 → 1.2.6

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 CHANGED
@@ -9586,116 +9586,126 @@ const useGraphStore = defineStore("graph", () => {
9586
9586
  const endDragShape = async (source) => {
9587
9587
  if (!isDragging.value)
9588
9588
  return;
9589
- const changedIds = commitDrag(
9590
- shapes.value,
9591
- [...draggingIds.value],
9592
- dragGhost,
9593
- currentDiagramId.value || shapes.value[0].diagramId,
9594
- updateShape,
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
- pendingNestedIds,
9623
- addShape
9624
- });
9625
- if (nestResult.cancelled) {
9596
+ dragBase.value
9597
+ );
9598
+ if (!changedIds.length) {
9626
9599
  cleanupAfterDrag();
9627
9600
  return;
9628
9601
  }
9629
- ownerPayload = nestResult.ownerPayload;
9630
- clonedIds = nestResult.clonedIds;
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
- updateShape,
9637
- 1,
9638
- 1
9610
+ containerForFinalize,
9611
+ updateShape
9639
9612
  );
9640
- }
9641
- for (const id of changedIds) {
9642
- const node = shapeMap.value.get(id) ?? null;
9643
- if (node?.shapeType === "pin") {
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
- child,
9673
- updateShape
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
- const affectedIds = collectAffectedShapeIds$1(shapes.value, changedIds, clonedIds);
9678
- const payloads = buildDragEndPayloads(affectedIds, shapes.value);
9679
- const onNestDone = createOnNestDoneCallback({
9680
- shapesRef: shapes,
9681
- ownerPayload,
9682
- updateShape
9683
- });
9684
- adjustCanvasToFitAllShapes();
9685
- if (dragBaseCanvasSize.value) {
9686
- const currentDiagram = shapes.value.find((s2) => s2.shapeType === "diagram");
9687
- if (currentDiagram) {
9688
- const currentWidth = currentDiagram.bounds.width;
9689
- const currentHeight = currentDiagram.bounds.height;
9690
- const { width: baseWidth, height: baseHeight } = dragBaseCanvasSize.value;
9691
- if (currentWidth !== baseWidth || currentHeight !== baseHeight) {
9692
- const diagramPayload = _.cloneDeep(currentDiagram);
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
+ console.log("1. endDragShape start");
9653
+ await EdgeUtils.updateRelatedEdgesAsync(shapes.value, changedIds, (shape) => {
9654
+ updateShape(shape.id, shape);
9655
+ }, edgesByNodeId.value, shapeMap.value);
9656
+ console.log("1. endDragShape start");
9657
+ autoExpandMovedCompartmentsAfterDrag(shapes.value, changedIds, updateShape);
9658
+ const allReparentIds = [...changedIds, ...clonedIds];
9659
+ const prevMapForComparents = { ...prevParentById };
9660
+ for (const cid of clonedIds) {
9661
+ prevMapForComparents[cid] = null;
9662
+ }
9663
+ syncShowComparentsByReparent(
9664
+ shapes.value,
9665
+ allReparentIds,
9666
+ prevMapForComparents,
9667
+ (id, u2) => updateShapeRaw(id, u2)
9668
+ );
9669
+ const shapeId = ownerPayload?.shapeId;
9670
+ if (shapeId != null) {
9671
+ const child = shapeMap.value.get(shapeId) ?? null;
9672
+ if (child) {
9673
+ expandParentByChild({
9674
+ shapes: shapes.value,
9675
+ child,
9676
+ updateShape
9677
+ });
9678
+ }
9679
+ }
9680
+ const affectedIds = collectAffectedShapeIds$1(shapes.value, changedIds, clonedIds);
9681
+ const payloads = buildDragEndPayloads(affectedIds, shapes.value);
9682
+ const onNestDone = createOnNestDoneCallback({
9683
+ shapesRef: shapes,
9684
+ ownerPayload,
9685
+ updateShape
9686
+ });
9687
+ adjustCanvasToFitAllShapes();
9688
+ if (dragBaseCanvasSize.value) {
9689
+ const currentDiagram = shapes.value.find((s2) => s2.shapeType === "diagram");
9690
+ if (currentDiagram) {
9691
+ const currentWidth = currentDiagram.bounds.width;
9692
+ const currentHeight = currentDiagram.bounds.height;
9693
+ const { width: baseWidth, height: baseHeight } = dragBaseCanvasSize.value;
9694
+ if (currentWidth !== baseWidth || currentHeight !== baseHeight) {
9695
+ const diagramPayload = _.cloneDeep(currentDiagram);
9696
+ payloads.push(diagramPayload);
9697
+ }
9698
+ }
9699
+ }
9700
+ eventBus.emit("shape-drag-end", payloads, ownerPayload, onNestDone);
9701
+ console.log("3. emit done");
9702
+ cleanupAfterDrag();
9703
+ console.log("4. cleanupAfterDrag done");
9704
+ } catch (e) {
9705
+ console.error("endDragShape 执行失败:", e);
9706
+ } finally {
9707
+ cleanupAfterDrag();
9696
9708
  }
9697
- eventBus.emit("shape-drag-end", payloads, ownerPayload, onNestDone);
9698
- cleanupAfterDrag();
9699
9709
  };
9700
9710
  const endResizeShape = async (id) => {
9701
9711
  await EdgeUtils.updateRelatedEdgesAsync(shapes.value, [id], (shape) => {