fix(m02): 셀 밀기 · 당기기에 이름 따라감 · 카드 도면 저장도 표 없는 연결표 줄 뺌(114-2)

- 칸 삽입 · 삭제 창(밀기 · 당기기) — 띠 안에 통째로 든 이름정의 범위를 같이 옮김 · 되돌리기 한 걸음
- 연결표 맞춤 몸을 fitLinks 로 떼어 도면 상세 · 카드 도면 저장이 같이 씀
- 시험 — 밀기 여섯 갈래 · 카드 저장 줄 빼기

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MgChuAcyBqUkhHMTXomQC7
This commit is contained in:
2026-10-08 18:28:48 +09:00
co-authored by Claude Opus 5.5
parent f44789c33c
commit ad511175bf
5 changed files with 133 additions and 24 deletions
@@ -401,20 +401,29 @@ export function createAreaToDrawing(opt: AreaToDrawingOptions): AreaToDrawing {
withLinks: (doc) => {
waiting = false;
const { 지운연결: _dropped, ...doc_ } = doc;
doc = doc_;
const old = new Map((doc.연결표 ?? []).map((row) => [row.연결, row]));
const rows: TableLink[] = [];
for (const [sheet, entities] of sheetsOf(doc)) {
for (const e of entities) {
if (!isTable(e)) continue;
const id = linkOf(e);
const row = id ? (old.get(id) ?? fresh.get(id)) : undefined;
if (!id || !row || rows.some((r) => r.연결 === id)) continue;
rows.push({ ...row, 장: sheet, 값: latest.get(id) ?? row.값 });
}
}
// 기록이 없던 도면은 칸을 안 만듦(옛 문서 그대로)
return rows.length || doc.연결표 ? { ...doc, 연결표: rows } : doc;
return fitLinks(doc_, fresh, latest);
},
};
}
/** 도면 저장 문서 `연결표` 를 도면에 남은 표에 맞춤 — 표 없는 줄은 뺌 · 줄 `장` = 표가 놓인 장 ·
* `fresh` = 새로 놓은 표 줄 · `latest` = [업데이트]로 바뀐 값(도면 상세) · 카드 도면 저장도 이 몸(114-2) */
export function fitLinks(
doc: StructureDoc,
fresh: ReadonlyMap<string, TableLink> = new Map(),
latest: ReadonlyMap<string, Record<string, string>> = new Map(),
): StructureDoc {
const old = new Map((doc.연결표 ?? []).map((row) => [row.연결, row]));
const rows: TableLink[] = [];
for (const [sheet, entities] of sheetsOf(doc)) {
for (const e of entities) {
if (!isTable(e)) continue;
const id = linkOf(e);
const row = id ? (old.get(id) ?? fresh.get(id)) : undefined;
if (!id || !row || rows.some((r) => r.연결 === id)) continue;
rows.push({ ...row, 장: sheet, 값: latest.get(id) ?? row.값 });
}
}
// 기록이 없던 도면은 칸을 안 만듦(옛 문서 그대로)
return rows.length || doc.연결표 ? { ...doc, 연결표: rows } : doc;
}
@@ -10,6 +10,7 @@
* ========================================================================== */
import type { StructureDoc } from "./M02_MasterTemplete_Api_Fetch";
import { fitLinks } from "./M02_MasterTemplete_AreaToDrawing";
import type { SaveControl } from "./M02_MasterTemplete_CardShell";
import {
mountStructureSheets,
@@ -130,10 +131,14 @@ export function mountDrawingCard(host: HTMLElement, opt: DrawingCardOptions): Dr
let version = opt.version ?? "";
/** 전체 편집기 [저장]과 같은 길 — 읽은 문서에 `도면` · `더한장`(모든 장)을 갈아 끼워 그 항목 파일에
* (실패는 던짐) · CAD Ctrl+S 가 넘기는 지금 탭 장은 안 씀 — 2장 보다 저장해도 1장 그대로(105-3) */
* (실패는 던짐) · CAD Ctrl+S 가 넘기는 지금 탭 장은 안 씀 — 2장 보다 저장해도 1장 그대로(105-3) ·
* 도면에서 지운 표의 연결표 줄은 뺌(114-2 · 도면 상세 저장과 같은 몸) */
async function doSave(): Promise<void> {
if (!write) return;
const next = { ...doc, ...((await handle.getDoc()) as Pick<StructureDoc, "도면" | "더한장">) };
const next = fitLinks({
...doc,
...((await handle.getDoc()) as Pick<StructureDoc, "도면" | "더한장">),
});
version = (await write("structure", opt.column, version, next)).판;
doc = next;
}