diff --git a/A00_Common/spreadsheet/spreadsheet_editor.ts b/A00_Common/spreadsheet/spreadsheet_editor.ts index fc4de019..3ede2592 100644 --- a/A00_Common/spreadsheet/spreadsheet_editor.ts +++ b/A00_Common/spreadsheet/spreadsheet_editor.ts @@ -13,7 +13,7 @@ import { moveFormula } from "./spreadsheet_refshift"; import { colName, parseA1, parseRange, rangeToA1, toA1 } from "./spreadsheet_address"; import { funcHelp, suggestFunctions, type FuncHelp } from "./spreadsheet_func_help"; import { defineName, resolveName } from "./spreadsheet_names"; -import { tokenize } from "./spreadsheet_parser"; +import { parseFormula, tokenize } from "./spreadsheet_parser"; import { cellsOf, move, selectCell } from "./spreadsheet_selection"; import { checkValue, findValidation } from "./spreadsheet_validation"; import type { Cell, CellAddress, CellStyle, Sheet } from "./spreadsheet_types"; @@ -356,9 +356,19 @@ export function createEditor(ctx: SpreadsheetContext): Editor { focus(); } - /** 칸에 적음 — 유효성(sub4) 「막음」 을 어기면 안 적고 false(편집 그대로 · 엑셀처럼 다시 치게) */ + /** 칸에 적음 — 식이 틀렸거나(인자 수 등) 유효성(sub4) 「막음」 을 어기면 안 적고 false(편집 그대로 · 엑셀처럼 다시 치게) */ function write(cells: CellAddress[], value: string, from: CellAddress): boolean { if (!st) return true; + const parsed = value.length > 1 && value[0] === "=" ? parseFormula(value) : null; + if (parsed && !parsed.ok) { + showToast(parsed.message, "error"); + const node = src(); + const at = Math.min(parsed.at + 1, node.value.length); + st.mode = "edit"; // 방향키가 글자 사이를 움직이게 + st.point = null; + node.setSelectionRange(at, at); + return false; + } const sheet = sheetOf(st.sheet); const out: Record = {}; const warn = new Set();