diff --git a/A00_Common/formula_doc.css b/A00_Common/formula_doc.css index a2c3a59ec..bf1c7fe75 100644 --- a/A00_Common/formula_doc.css +++ b/A00_Common/formula_doc.css @@ -346,6 +346,13 @@ cursor: text; } +/* 편집 중 줄 = 그 줄 너비 전부(빈 줄도 입력 칸이 보임 · 줄은 넘칠 때만 꺾임) */ +.fdoc__edit.fdoc-math, +.fdoc__edit.fdoc-math > .fdoc-math__view, +.fdoc__edit.fdoc-math > .fdoc-math__view > .fdoc-math__row { + flex: 1 1 auto; +} + .fdoc-math__view, .fdoc-math__row { display: inline-flex; diff --git a/A00_Common/formula_doc_screen.ts b/A00_Common/formula_doc_screen.ts index 35f67cb4d..1b398e9b3 100644 --- a/A00_Common/formula_doc_screen.ts +++ b/A00_Common/formula_doc_screen.ts @@ -195,7 +195,7 @@ export function createDocScreen(opt: DocScreenOptions) { const mine = ++seq; void call<{ 셈: DocAnswer; 연결: DocRecord; 부름?: Docs }>( "/preview", - cp ? { 문서: doc, 끊음: cut } : { 문서: doc, 입력: usable() }, + cp ? { 문서: doc, 끊음: cut } : { 문서: key ? doc : { ...doc, 키: "_새" }, 입력: usable() }, ctl.signal, ) .then((got) => { @@ -390,7 +390,9 @@ export function createDocScreen(opt: DocScreenOptions) { [head, grid, side, foot].forEach((x) => x.replaceChildren()); return; } - const edit = opt.admin && !!key; + // M01 저장 전 새 로직(키 없음)도 고침 — [수식 저장] · [고침 버림]은 키가 생긴 뒤(페이지 [저장] → 새 키로 이어 감) + // M02 저장 전 새 SK = 자리 표시(저장하면 M01 사본) — 읽기만 + const edit = opt.admin && (!!key || !cp); const vals = answer.값 ?? {}; const vars = new Map((doc.변수 ?? []).map((v) => [varId(v), v])); const lineSet = new Set((doc.식 ?? []).map((l) => String(l.기호 ?? "")).filter(Boolean)); @@ -403,7 +405,7 @@ export function createDocScreen(opt: DocScreenOptions) { const options = optionBar(); head.replaceChildren( ...(options.length ? [el("div", { className: "fdoc__options", children: options })] : []), - toolRow(edit), + toolRow(edit && !!key), ); const { cells, order } = buildLines({ admin: edit, @@ -597,6 +599,7 @@ export function createDocScreen(opt: DocScreenOptions) { const open = async (next: string): Promise => { if (next === key && doc) return; rows.reset(); + const was = key; key = next; doc = answer = null; given = {}; @@ -608,9 +611,10 @@ export function createDocScreen(opt: DocScreenOptions) { [cut, calls, mark, savedCut, version] = [{}, {}, undefined, "{}", ""]; draw(); if (!next) { - // 저장 전 새 로직 — 세 영역 빈 화면(저장하면 고칠 수 있음) + // 저장 전 새 로직 — 세 영역 빈 화면(누르면 입력 · 고친 것은 캐시 "" 열쇠) doc = blankDoc(); saved = JSON.stringify(doc); + keep(); // 옛 새 로직 고침(「""」 열쇠) 걷음 recalc(); return draw(); } @@ -619,7 +623,14 @@ export function createDocScreen(opt: DocScreenOptions) { const got = await call(cp ? "" : `?key=${encodeURIComponent(next)}`); if (mine !== seq || key !== next) return; take(got); - const draft = drafts()[next]; + const all = drafts(); + // 저장 전 새 로직에서 고친 문서 — 페이지 [저장]으로 생긴 새 키(빈 문서)로 이어 감 + if (!was && got.새 && all[""] && !all[next]) { + all[next] = { ...all[""], 키: next, 이름: got.문서.이름, 결과단위: got.문서.결과단위 }; + delete all[""]; + sessionStorage.setItem(opt.cache, JSON.stringify(all)); + } + const draft = all[next]; if (draft) doc = clone(draft); const kept = cp ? (drafts()[`${next}#끊음`] as unknown as Docs | undefined) : undefined; if (kept) cache.merge({ 문서: (cut = clone(kept)) });