diff --git a/A00_Common/formula_doc_options.ts b/A00_Common/formula_doc_options.ts index 129dfd2c1..6a33a6095 100644 --- a/A00_Common/formula_doc_options.ts +++ b/A00_Common/formula_doc_options.ts @@ -29,6 +29,20 @@ export function nameMachines(list: string[], redraw: () => void): void { }); } +let asked = false; +/** 글 값이 기계 원문번호면 「이름 규격 (원문번호)」(838-3 · 요구 859) — 이름이 아직 없으면 한 번 받아 `redraw` · 아니면 null */ +export function machineText(x: unknown, redraw: () => void): string | null { + if (typeof x !== "string" || !MACHINE.test(x)) return null; + if (!(x in names) && !asked) { + asked = true; + void cfMachineNames().then((got) => { + names = { ...names, ...got }; + redraw(); + }); + } + return optionText(x); +} + export function buildOptions( doc: FormulaDoc | null, given: Record, diff --git a/A00_Common/line_stack_edit.ts b/A00_Common/line_stack_edit.ts index f19048374..78d7a15d4 100644 --- a/A00_Common/line_stack_edit.ts +++ b/A00_Common/line_stack_edit.ts @@ -320,7 +320,9 @@ function qtyBox( ); f.dataset.qty = String(i); const val = v ? (h.answer.값 ?? {})[text] : undefined; - const tag = v ? sourceTag(h, text, v.연결) : null; + // 838-3 공식 · 표 값 묶음에 이미 보이는 기호 = 줄 쪽 표 칩 걷음(묶음에서 고름) · 묶음에 없으면 줄에서 고름 + const inBlock = h.items.some((it) => it.줄.some((l) => l.꼴 === "공식" && l.기호.includes(text))); + const tag = v && !inBlock ? sourceTag(h, text, v.연결) : null; if (tag && isNum(val)) tag.title = `${eqText(val)}${shownUnit(v?.단위) ? ` ${shownUnit(v?.단위)}` : ""} — ${tag.title || tag.textContent}`; return el("span", { className: "lstk-qty", children: tag ? [f, tag] : [f] }); diff --git a/A00_Common/line_stack_out.ts b/A00_Common/line_stack_out.ts index 8b20d646e..e1b0642b7 100644 --- a/A00_Common/line_stack_out.ts +++ b/A00_Common/line_stack_out.ts @@ -22,6 +22,7 @@ import { offLine, type Values, } from "../common_util/common_util_formula_doc_view"; +import { machineText } from "./formula_doc_options"; import { reach } from "./formula_doc_render"; import { kindOf, @@ -59,6 +60,8 @@ export interface OutHooks { miss: () => void; /** 836-1 기계 덮음(맨 위 문서 칸) — 펼친 기계 식에 얹음(계산기와 같음) */ cover?: Cover; + /** 838-3 기계 이름을 받은 뒤 다시 그림 */ + redraw?: () => void; } const COST_SHOW: Record = { 노무비: "노무비", 재료비: "재료비", 경비: "경 비" }; @@ -180,7 +183,9 @@ function rows( flush(); const res = isNum(v) ? katexNode(`${valTex(v)}\\ ${unit(id) ? `\\text{${unit(id)}}` : ""}`) - : missing(a, id); + : typeof v === "string" // 글 값(기계 원문번호 등 · 838-3) = 그 글 · 기계면 이름 + ? el("span", { text: machineText(v, () => h.redraw?.()) ?? v }) + : missing(a, id); // 기호식 = 값식 = 결과 — 같은 꼴이 이어지면 한 번만(만약이 수 하나를 탄 줄) const n = nodeOf(t)!; const sym = tex(n, { side: "sym", vals, alias }); @@ -222,7 +227,11 @@ function rows( head, ...expr, " = ", - isNum(v) ? `${eqText(v)} ${unit(id)}` : typeof v === "string" ? v : missing(a, id), + isNum(v) + ? `${eqText(v)} ${unit(id)}` + : typeof v === "string" + ? (machineText(v, () => h.redraw?.()) ?? v) + : missing(a, id), ], }); pack.push(cell); diff --git a/A00_Common/line_stack_rows.ts b/A00_Common/line_stack_rows.ts index 061f8d62b..3011151b8 100644 --- a/A00_Common/line_stack_rows.ts +++ b/A00_Common/line_stack_rows.ts @@ -24,6 +24,7 @@ import { } from "../common_util/common_util_formula_doc"; import { isNum } from "../common_util/common_util_formula_doc_calc"; import { decide, hasIf, tryParse } from "../common_util/common_util_formula_doc_view"; +import { machineText } from "./formula_doc_options"; import { dropSyms, freshId, @@ -157,6 +158,8 @@ export function buildBlock( const realText = (t: string): string => aliasText(t, alias, true); const valText = (id: string): string => { const v = vals[id]; + const mach = machineText(v, () => h.change(() => undefined)); // 838-3 기계 원문번호 = 이름 + if (mach) return mach; if (isNum(v) || typeof v === "string") return `${eqText(v)} ${shownUnit(vars.get(id)?.단위)}`.trim(); if (v && typeof v === "object") diff --git a/A00_Common/line_stack_screen.ts b/A00_Common/line_stack_screen.ts index e362764a3..c34a30e8c 100644 --- a/A00_Common/line_stack_screen.ts +++ b/A00_Common/line_stack_screen.ts @@ -381,6 +381,7 @@ export function createStackScreen(opt: StackScreenOptions) { }, miss: ask, pair: (loc) => pair(loc, "right"), + redraw: () => draw(), }) : el("p", { className: "ui-text ui-text--muted", text: lt("Empty") }), );