feat(M02): 새 구조물 조합 두 단추 — 「새 항목」 → 상세 칸 [새로 만들기] [복사 생성] · 복사 생성 = 탭 + 목록 → 지금 층 · 고른 폴더 · 새 키 · 새 번호

39-5 H4 — 나무 copyIn(붙여넣기 길 · 새 열 하나면 그 열 고름) · folder 손잡이 · ItemPick buildTwoWay(빈 카드도 씀).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016PSXsvyDxjNmufteN5bqmt
This commit is contained in:
2026-10-04 17:37:46 +09:00
co-authored by Claude Opus 5.5
parent af92f0553e
commit 364d22ff6f
4 changed files with 135 additions and 8 deletions
@@ -107,6 +107,14 @@ export interface TreePanelHandle {
select: (colId: string | null) => void;
/** 「새 항목」 — 고른 폴더 안(없으면 맨 위)에 항목 추가 창 */
newItem: () => void;
/** 고른 폴더(하나) — 없으면 맨 위(`[]`) · 새 항목 · 복사 생성이 들어갈 자리 */
folder: () => string[];
/** 복사 생성(39-5) — 다른 곳(`from`) 항목 키 하나를 이 층 `dest` 에 새 키로 붙이고 그 열을 고름 */
copyIn: (
from: { layer: Layer; owner: string | null },
key: string,
dest: string[],
) => Promise<void>;
/** 표 머리에서 온 나무 고침(이름 바꾸기 · PLAN 31-1) — 메뉴 고침과 같은 길(저장 물음 · 막힘 안내 · 다시 그림) */
editFromTable: (body: TreeEdit, colId: string | null) => Promise<void>;
}
@@ -417,8 +425,9 @@ export function createTreePanel(opt: TreePanelOptions): TreePanelHandle {
// 새 항목은 그 열을 고름 · 지운 항목이면 고름 풀림 · 나머지는 지금 고른 열 그대로
const gone = note?.지운항목 ?? [];
const made = note?.열;
const col =
typeof made === "string" ? made : keepCol && !gone.includes(keepCol) ? keepCol : null;
// 붙여넣기로 새 열이 하나면(복사 생성) 그 열
const one = typeof made === "string" ? made : made?.length === 1 ? made[0] : null;
const col = one ?? (keepCol && !gone.includes(keepCol) ? keepCol : null);
activeCol = col;
const parent = note?.경로 ? note.경로.slice(0, -1) : [];
parent.forEach((_, i) => open.add(folderIdOf(parent.slice(0, i + 1))));
@@ -643,13 +652,36 @@ export function createTreePanel(opt: TreePanelOptions): TreePanelHandle {
});
/** 상세 제목 줄 「새 항목」(30-5) — 나무 「항목 추가」와 같은 창 · 고른 폴더(하나)가 있으면 그 안 · 아니면 맨 위 */
const newItem = (): void => {
const folder = (): string[] => {
const at = anchor && picked.has(anchor) ? targets.get(anchor) : undefined;
void addItem(at?.kind === "folder" ? at.path : []);
return at?.kind === "folder" ? at.path : [];
};
const newItem = (): void => void addItem(folder());
const copyIn = async (
from: { layer: Layer; owner: string | null },
key: string,
dest: string[],
): Promise<void> => {
const run = api.paste;
if (!run || !opt.canEdit || !(await ready())) return;
await apply(() =>
run(opt.layer, owner, { kind: clipKind, from, refs: [{ 경로: [], 키: key }] }, dest),
);
};
const editFromTable = async (body: TreeEdit, colId: string | null): Promise<void> => {
if (opt.canEdit && (await ready())) await edit(body, colId);
};
return { root, search: search.root, add: tools, refresh, select, newItem, editFromTable };
return {
root,
search: search.root,
add: tools,
refresh,
select,
newItem,
folder,
copyIn,
editFromTable,
};
}