mock: クラスターを選んでキーを足すと、そのクラスターに新しい行を作る(T-30 単位6)

これまではクラスターを1つのノードとして扱い、その右隣(親の中)に足していた。
クラスターの中に新しい行を作り、その左端に置く。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XsamNKrWY3obJwR746oQRq
This commit is contained in:
2026-10-23 08:18:22 +09:00
co-authored by Claude Opus 5.5
parent f64d632136
commit e5678d79e6
3 changed files with 29 additions and 3 deletions
+8 -2
View File
@@ -128,7 +128,13 @@ export function usePhyCommands(options: Options) {
function keyAdd() {
const chosen = options.node(options.selected.value.at(-1) || "");
const parent = chosen ? options.selectedContainer(chosen.id) : insertionParent();
// A selected cluster receives a new row inside it, like an empty selection inside the focus.
const parent =
chosen?.type === "cluster"
? chosen.id
: chosen
? options.selectedContainer(chosen.id)
: insertionParent();
const keys = nodesInContainer(parent).flatMap((node) =>
node.type === "key" ? [{ id: node.id, x: node.transform.x, y: node.transform.y, ...node.size }] : [],
);
@@ -137,7 +143,7 @@ export function usePhyCommands(options: Options) {
const { x, y } =
chosen?.type === "key"
? rowEndPosition(keys, chosen.id)!
: chosen
: chosen && chosen.type !== "cluster"
? { x: snap(chosen.transform.x + 1), y: snap(chosen.transform.y) }
: (newRowPosition(keys) ?? { x: snap(center.x), y: snap(center.y) });
let id = "";