diff --git a/ui_template/sheet/ui_template_sheet.css b/ui_template/sheet/ui_template_sheet.css index 2390fd79..8255b423 100644 --- a/ui_template/sheet/ui_template_sheet.css +++ b/ui_template/sheet/ui_template_sheet.css @@ -171,7 +171,7 @@ .ui-sheet__resize { position: absolute; top: 0; - right: -3px; + right: 0; z-index: 3; width: 6px; height: 100%; diff --git a/ui_template/sheet/ui_template_sheet.ts b/ui_template/sheet/ui_template_sheet.ts index 33c55e15..6545381b 100644 --- a/ui_template/sheet/ui_template_sheet.ts +++ b/ui_template/sheet/ui_template_sheet.ts @@ -169,7 +169,10 @@ export function createSheet(host: HTMLElement, input: SheetDoc, opts: SheetOptio if (key === "s:formula") return col.식 ?? ""; if (key === "s:desc") return col.설명 ?? ""; if (key === "s:price") return col.일위대가 ?? ""; - const raw = state.doc.줄.find((r) => `d:${r.id}` === key)?.값[col.id]; + const row = state.doc.줄.find((r) => `d:${r.id}` === key); + const formula = row?.식?.[col.id] ?? col.식; + if (formula) return `=${formula}`; + const raw = row?.값[col.id]; return raw === null || raw === undefined ? "" : String(raw); }; const write = (key: string, col: SheetColumn, text: string): void => { diff --git a/ui_template/sheet/ui_template_sheet_ops.ts b/ui_template/sheet/ui_template_sheet_ops.ts index ebf1e309..e9f1d59e 100644 --- a/ui_template/sheet/ui_template_sheet_ops.ts +++ b/ui_template/sheet/ui_template_sheet_ops.ts @@ -27,11 +27,10 @@ export function orderedRows(doc: SheetDoc): SheetRow[] { export const isCalcColumn = (col: SheetColumn): boolean => !!col.식; export const isBoundColumn = (col: SheetColumn): boolean => !!col.바인딩; -/** 본문 칸을 고칠 수 있나 — master 는 계산 열 밖 전부 · project 는 손 열만(+ 사용자가 더한 줄의 글 열). */ +/** 본문 칸을 고칠 수 있나 — master 는 전부(계산 칸은 `=` 식으로) · project 는 손 열만(+ 사용자가 더한 줄의 글 열). */ export function cellEditable(mode: SheetMode, col: SheetColumn, row: SheetRow): boolean { - if (row.식?.[col.id] || isCalcColumn(col)) return false; if (mode === "master") return true; - if (isBoundColumn(col)) return false; + if (isBoundColumn(col) || isCalcColumn(col)) return false; return !!col.손 || (!!row.손 && col.꼴 === "글"); } @@ -85,12 +84,21 @@ export function deleteColumn(doc: SheetDoc, id: string): void { if (doc.보기?.열너비) delete doc.보기.열너비[id]; } -/** 칸에 친 글 → 저장 값. 수 열은 수 꼴이면 수 · 빈 글은 칸을 비움. */ +/** 칸에 친 글 → 저장 값. `=` 로 시작하면 그 칸만의 식(`줄.식`) · 수 열은 수 꼴이면 수 · 빈 글은 칸을 비움. */ export function setCell(doc: SheetDoc, rowId: string, col: SheetColumn, text: string): void { const row = doc.줄.find((r) => r.id === rowId); if (!row) return; const trimmed = text.trim(); - if (trimmed === "") { + if (row.식) { + delete row.식[col.id]; + if (!Object.keys(row.식).length) delete row.식; + } + if (trimmed.startsWith("=") && trimmed.slice(1).trim() !== (col.식 ?? "")) { + delete row.값[col.id]; + (row.식 ??= {})[col.id] = trimmed.slice(1).trim(); + return; + } + if (trimmed === "" || trimmed.startsWith("=")) { delete row.값[col.id]; return; } diff --git a/ui_template/sheet/ui_template_sheet_render.ts b/ui_template/sheet/ui_template_sheet_render.ts index 816130f8..25f9ddb0 100644 --- a/ui_template/sheet/ui_template_sheet_render.ts +++ b/ui_template/sheet/ui_template_sheet_render.ts @@ -22,7 +22,7 @@ import type { SheetColumn, SheetDoc, SheetResult, SheetRow } from "./ui_template export const KEY_UNIT = "s:unit"; const MASTER_ROWS = ["s:formula", "s:desc", "s:price"] as const; -const GUTTER = 48; +const GUTTER = 64; const DEFAULT_WIDTH = { 수: 72, 글: 96 }; const PAGE_ROWS = 50; diff --git a/ui_template/sheet/ui_template_sheet_text.ts b/ui_template/sheet/ui_template_sheet_text.ts index d830c843..37ac1a63 100644 --- a/ui_template/sheet/ui_template_sheet_text.ts +++ b/ui_template/sheet/ui_template_sheet_text.ts @@ -23,8 +23,8 @@ const TEXT = { Page: ["쪽", "page"], Error: ["#오류", "#ERR"], Hint: [ - "칸을 누르고 바로 치거나 Enter · F2 로 고침 · 화살표 · Tab 으로 옮김 · Delete 로 비움", - "Type or press Enter / F2 to edit · arrows / Tab to move · Delete to clear", + "칸을 누르고 바로 치거나 Enter · F2 로 고침 · = 로 시작하면 그 칸만 식 · 화살표 · Tab 으로 옮김 · Delete 로 비움", + "Type or press Enter / F2 to edit · start with = for a cell formula · arrows / Tab to move · Delete to clear", ], } as const;