Spaces:
Running
Running
Fix ungrouping, make it smooth.
Browse files
lynxkite-app/web/src/workspace/Workspace.tsx
CHANGED
@@ -371,6 +371,7 @@ function LynxKiteFlow() {
|
|
371 |
width: 0,
|
372 |
height: 0,
|
373 |
data: { title: "Group", params: {} },
|
|
|
374 |
};
|
375 |
let top = Number.POSITIVE_INFINITY;
|
376 |
let left = Number.POSITIVE_INFINITY;
|
@@ -420,7 +421,9 @@ function LynxKiteFlow() {
|
|
420 |
}
|
421 |
function ungroupSelection() {
|
422 |
const groups = Object.fromEntries(
|
423 |
-
nodes
|
|
|
|
|
424 |
);
|
425 |
setNodes(
|
426 |
nodes
|
@@ -433,15 +436,12 @@ function LynxKiteFlow() {
|
|
433 |
position: { x: n.position.x + g.position.x, y: n.position.y + g.position.y },
|
434 |
parentId: undefined,
|
435 |
extent: undefined,
|
|
|
436 |
};
|
437 |
}),
|
438 |
);
|
439 |
getYjsDoc(state).transact(() => {
|
440 |
const wnodes = state.workspace.nodes!;
|
441 |
-
for (const groupId in groups) {
|
442 |
-
const groupIdx = wnodes.findIndex((n) => n.id === groupId);
|
443 |
-
wnodes.splice(groupIdx, 1);
|
444 |
-
}
|
445 |
for (const node of state.workspace.nodes!) {
|
446 |
const g = groups[node.parentId as string];
|
447 |
if (!g) continue;
|
@@ -450,6 +450,10 @@ function LynxKiteFlow() {
|
|
450 |
node.parentId = undefined;
|
451 |
node.extent = undefined;
|
452 |
}
|
|
|
|
|
|
|
|
|
453 |
});
|
454 |
}
|
455 |
const areMultipleNodesSelected = nodes.filter((n) => n.selected).length > 1;
|
|
|
371 |
width: 0,
|
372 |
height: 0,
|
373 |
data: { title: "Group", params: {} },
|
374 |
+
selected: true,
|
375 |
};
|
376 |
let top = Number.POSITIVE_INFINITY;
|
377 |
let left = Number.POSITIVE_INFINITY;
|
|
|
421 |
}
|
422 |
function ungroupSelection() {
|
423 |
const groups = Object.fromEntries(
|
424 |
+
nodes
|
425 |
+
.filter((n) => n.selected && n.type === "node_group" && !n.parentId)
|
426 |
+
.map((n) => [n.id, n]),
|
427 |
);
|
428 |
setNodes(
|
429 |
nodes
|
|
|
436 |
position: { x: n.position.x + g.position.x, y: n.position.y + g.position.y },
|
437 |
parentId: undefined,
|
438 |
extent: undefined,
|
439 |
+
selected: true,
|
440 |
};
|
441 |
}),
|
442 |
);
|
443 |
getYjsDoc(state).transact(() => {
|
444 |
const wnodes = state.workspace.nodes!;
|
|
|
|
|
|
|
|
|
445 |
for (const node of state.workspace.nodes!) {
|
446 |
const g = groups[node.parentId as string];
|
447 |
if (!g) continue;
|
|
|
450 |
node.parentId = undefined;
|
451 |
node.extent = undefined;
|
452 |
}
|
453 |
+
for (const groupId in groups) {
|
454 |
+
const groupIdx = wnodes.findIndex((n) => n.id === groupId);
|
455 |
+
wnodes.splice(groupIdx, 1);
|
456 |
+
}
|
457 |
});
|
458 |
}
|
459 |
const areMultipleNodesSelected = nodes.filter((n) => n.selected).length > 1;
|