logisheets-formula-editor 1.15.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -13410,7 +13410,9 @@ function kd(s) {
13410
13410
  [!0, !0],
13411
13411
  [!1, !0],
13412
13412
  [!0, !1]
13413
- ][(o + 1) % 4], h = n.map((c) => `${l ? "$" : ""}${c.col}${a ? "$" : ""}${c.row}`).join(":");
13413
+ ][(o + 1) % 4], h = n.map(
13414
+ (c) => `${l ? "$" : ""}${c.col}${a ? "$" : ""}${c.row}`
13415
+ ).join(":");
13414
13416
  return t + h;
13415
13417
  }
13416
13418
  let Un = null, Ni = null;
@@ -13751,6 +13753,8 @@ function Nd(s, e) {
13751
13753
  ]);
13752
13754
  }, w = en.of([
13753
13755
  {
13756
+ // Deleting the opener of an empty pair (e.g. the `(` of an
13757
+ // autocompleted `SUM()`) also removes its closer.
13754
13758
  key: "Backspace",
13755
13759
  run: (b) => {
13756
13760
  const { state: k } = b, { from: S, to: D } = k.selection.main;
package/dist/inline.js CHANGED
@@ -46,10 +46,15 @@ function Ne(U) {
46
46
  }
47
47
  function G() {
48
48
  if (q(), !a) return;
49
- const e = Ee(k, a, X(), {
50
- originX: w.x,
51
- originY: w.y
52
- });
49
+ const e = Ee(
50
+ k,
51
+ a,
52
+ X(),
53
+ {
54
+ originX: w.x,
55
+ originY: w.y
56
+ }
57
+ );
53
58
  for (const i of e) {
54
59
  const o = document.createElement("div");
55
60
  o.style.cssText = `position:absolute;pointer-events:none;opacity:0.3;z-index:0;left:${i.x}px;top:${i.y}px;width:${i.width}px;height:${i.height}px;background-color:${se(i.colorIndex)};`, T.appendChild(o), M.push(o);
@@ -73,7 +78,10 @@ function Ne(U) {
73
78
  f.startPos,
74
79
  f.startPos + f.text.length,
75
80
  e
76
- ) : c.insertText(e), f = { text: e, startPos: (f == null ? void 0 : f.startPos) ?? i };
81
+ ) : c.insertText(e), f = {
82
+ text: e,
83
+ startPos: (f == null ? void 0 : f.startPos) ?? i
84
+ };
77
85
  }
78
86
  function D(e, i) {
79
87
  if (!t) return;
@@ -90,7 +98,12 @@ function Ne(U) {
90
98
  }
91
99
  async function ge(e, i) {
92
100
  if (!t) return;
93
- const o = y(), l = P ?? { row: t.row, col: t.col }, u = { sheetIdx: o, rowIdx: l.row, colIdx: l.col, direction: e }, x = W.getWorkbook(), d = i ? await x.getDataBoundary(u) : await x.getNextVisibleCell(u);
101
+ const o = y(), l = P ?? { row: t.row, col: t.col }, u = {
102
+ sheetIdx: o,
103
+ rowIdx: l.row,
104
+ colIdx: l.col,
105
+ direction: e
106
+ }, x = W.getWorkbook(), d = i ? await x.getDataBoundary(u) : await x.getNextVisibleCell(u);
94
107
  if (!d || ve(d)) return;
95
108
  const { x: S, y: Q } = d;
96
109
  P = { row: Q, col: S };
@@ -138,7 +151,13 @@ function Ne(U) {
138
151
  defaultWidth: 100,
139
152
  defaultHeight: 25
140
153
  });
141
- h = o, t = { sheetName: X(), sheetIdx: u, row: e, col: i, position: x }, g = !0, E == null || E(!0), r = document.createElement("div"), r.className = "logisheets-inline-cell-editor", r.style.cssText = "position:absolute;display:flex;align-items:center;box-sizing:border-box;z-index:1000;background:#fff;overflow:hidden;border:1px solid #4a90d9;box-shadow:0 1px 4px rgba(0,0,0,0.18);", T.appendChild(r);
154
+ h = o, t = {
155
+ sheetName: X(),
156
+ sheetIdx: u,
157
+ row: e,
158
+ col: i,
159
+ position: x
160
+ }, g = !0, E == null || E(!0), r = document.createElement("div"), r.className = "logisheets-inline-cell-editor", r.style.cssText = "position:absolute;display:flex;align-items:center;box-sizing:border-box;z-index:1000;background:#fff;overflow:hidden;border:1px solid #4a90d9;box-shadow:0 1px 4px rgba(0,0,0,0.18);", T.appendChild(r);
142
161
  const d = document.createElement("div");
143
162
  d.style.width = "100%", d.style.boxSizing = "border-box", r.appendChild(d), K(), V(o), c = me(d, {
144
163
  getDisplayUnits: B.getDisplayUnits,
@@ -1,5 +1,11 @@
1
1
  import { EditorView } from '@codemirror/view';
2
2
  import { FormulaEditorProps } from './types';
3
+ /**
4
+ * Imperative API exposed through `ref` — a subset of the core's
5
+ * `FormulaEditorHandle` (no `updateOptions` / `destroy`; props and unmount
6
+ * cover those). Positions are UTF-16 offsets into the whole text, leading '='
7
+ * included. Calls before mount or after unmount are no-ops.
8
+ */
3
9
  export interface FormulaEditorRef {
4
10
  focus: () => void;
5
11
  blur: () => void;
@@ -13,5 +19,9 @@ export interface FormulaEditorRef {
13
19
  getCursorPosition: () => number;
14
20
  getView: () => EditorView | null;
15
21
  }
22
+ /**
23
+ * React formula editor. Renders a `<div>` host and mounts the core editor into
24
+ * it once; see `FormulaEditorProps` for which props are live.
25
+ */
16
26
  export declare const FormulaEditor: import('react').ForwardRefExoticComponent<FormulaEditorProps & import('react').RefAttributes<FormulaEditorRef>>;
17
27
  //# sourceMappingURL=FormulaEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormulaEditor.d.ts","sourceRoot":"","sources":["../../../src/lib/FormulaEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAA;AAEhD,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAE/C,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,QAAQ,EAAE,MAAM,MAAM,CAAA;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,6CAA6C;IAC7C,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,uEAAuE;IACvE,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9D,kCAAkC;IAClC,iBAAiB,EAAE,MAAM,MAAM,CAAA;IAC/B,OAAO,EAAE,MAAM,UAAU,GAAG,IAAI,CAAA;CACnC;AAED,eAAO,MAAM,aAAa,iHAgEzB,CAAA"}
1
+ {"version":3,"file":"FormulaEditor.d.ts","sourceRoot":"","sources":["../../../src/lib/FormulaEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAA;AAEhD,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,QAAQ,EAAE,MAAM,MAAM,CAAA;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,6CAA6C;IAC7C,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,uEAAuE;IACvE,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9D,kCAAkC;IAClC,iBAAiB,EAAE,MAAM,MAAM,CAAA;IAC/B,OAAO,EAAE,MAAM,UAAU,GAAG,IAAI,CAAA;CACnC;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,iHAgEzB,CAAA"}
@@ -9,6 +9,17 @@
9
9
  * const editor = createFormulaEditor(el, { getDisplayUnits, ... })
10
10
  *
11
11
  * The React `<FormulaEditor>` (the package root) is a thin wrapper over this.
12
+ *
13
+ * Main exports: `createFormulaEditor` + its option / handle types, the
14
+ * bundled `builtinFormulaFunctions`, the wire types shared with the engine
15
+ * (`FormulaDisplayInfo`, `TokenUnit`, `CellRef`, ...) and small utils.
16
+ *
17
+ * The editor never tokenizes on its own: the host must supply
18
+ * `getDisplayUnits` (usually via `createEngineFormulaSource` from `./engine`).
19
+ * Without a `formulaFunctions` list, autocomplete and signature help are
20
+ * silent — pass `builtinFormulaFunctions` for the default set. Hosts in this
21
+ * repo: the root app's edit bar (via the React root) and the `/inline`
22
+ * in-cell controller used alongside `logisheets-engine`.
12
23
  */
13
24
  export { createFormulaEditor } from './editor';
14
25
  export type { FormulaEditorHandle, FormulaEditorOptions } from './editor';
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/lib/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAA;AAC5C,YAAY,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,MAAM,UAAU,CAAA;AAGvE,OAAO,EAAC,uBAAuB,EAAC,MAAM,aAAa,CAAA;AAEnD,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/lib/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAA;AAC5C,YAAY,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,MAAM,UAAU,CAAA;AAGvE,OAAO,EAAC,uBAAuB,EAAC,MAAM,aAAa,CAAA;AAEnD,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
@@ -3,18 +3,35 @@ import { FormulaEditorConfig, FormulaFunction, GetDisplayUnitsFunc } from './typ
3
3
  /**
4
4
  * Options for {@link createFormulaEditor}. These mirror the React component's
5
5
  * props minus the React-only bits — the React `style` prop maps to `style`
6
- * here (applied to the host element).
6
+ * here (applied to the host element) — plus the core-only `onArrowKey`.
7
+ *
8
+ * Text need not be a formula: plain text is edited without highlighting,
9
+ * autocomplete or point mode. Callbacks receive the full document text,
10
+ * including any leading '='.
7
11
  */
8
12
  export interface FormulaEditorOptions {
9
- /** Initial value (with leading '='). */
13
+ /**
14
+ * Initial value; later changes pushed via `updateOptions({value})` are
15
+ * written into the document (controlled mode).
16
+ */
10
17
  value?: string;
11
18
  /** Initial value when `value` is not given. */
12
19
  defaultValue?: string;
13
20
  /** Where to place the cursor on creation (default: 'end'). */
14
21
  initialCursorPosition?: 'start' | 'end';
22
+ /**
23
+ * Fires on every document change — typing, `setValue`, `insertText`,
24
+ * `replaceRange` and controlled `value` updates alike.
25
+ */
15
26
  onChange?: (value: string) => void;
27
+ /** Fires when the editable content loses focus; typical commit point. */
16
28
  onBlur?: (value: string) => void;
29
+ /**
30
+ * Plain Enter while no autocomplete list is open (Enter accepts the
31
+ * completion instead). Enter never inserts a newline; Alt+Enter does.
32
+ */
17
33
  onSubmit?: (value: string) => void;
34
+ /** Escape. The editor does not revert the text itself. */
18
35
  onCancel?: () => void;
19
36
  /**
20
37
  * Point-mode: called on an arrow / Ctrl+Arrow key while the caret sits where
@@ -30,40 +47,84 @@ export interface FormulaEditorOptions {
30
47
  }) => boolean;
31
48
  /** Fetch token / cell-ref info from the host (required). */
32
49
  getDisplayUnits: GetDisplayUnitsFunc;
33
- /** Functions offered by autocomplete + signature help. */
50
+ /**
51
+ * Functions offered by autocomplete + signature help. Defaults to an EMPTY
52
+ * list (no suggestions) — pass `builtinFormulaFunctions` for the bundled
53
+ * set.
54
+ */
34
55
  formulaFunctions?: FormulaFunction[];
35
- /** Current sheet name (for local cell-ref coloring). */
56
+ /**
57
+ * Current sheet name (for local cell-ref coloring). Defaults to '', so
58
+ * only refs with no sheet prefix count as local.
59
+ */
36
60
  sheetName?: string;
61
+ /** Merged over the defaults; see `updateOptions` for live changes. */
37
62
  config?: FormulaEditorConfig;
38
- /** Extra class(es) added to the host element. */
63
+ /**
64
+ * Extra class(es) added to the host element. Applied at creation and on
65
+ * a config-triggered rebuild only; classes are never removed.
66
+ */
39
67
  className?: string;
40
- /** Extra inline styles merged onto the host element. */
68
+ /** Extra inline styles merged onto the host element (same timing). */
41
69
  style?: Partial<CSSStyleDeclaration>;
42
70
  }
43
- /** Imperative handle returned by {@link createFormulaEditor}. */
71
+ /**
72
+ * Imperative handle returned by {@link createFormulaEditor}.
73
+ *
74
+ * Positions are 0-based UTF-16 code-unit offsets (JS string indices) into the
75
+ * whole document, leading '=' included. Every text-changing method fires
76
+ * `onChange`. After `destroy()` the methods are no-ops (`getValue()` returns
77
+ * '', `getView()` null).
78
+ */
44
79
  export interface FormulaEditorHandle {
80
+ /** Focus without scrolling the page to the editor. */
45
81
  focus(): void;
46
82
  blur(): void;
47
83
  getValue(): string;
84
+ /** Replace the whole document. */
48
85
  setValue(value: string): void;
49
- /** Insert text at the current cursor position. */
86
+ /** Insert text at the caret and move the caret after it. */
50
87
  insertText(text: string): void;
51
- /** Replace a range — useful for swapping a previously-inserted ref. */
88
+ /**
89
+ * Replace `[from, to)` and put the caret after the new text — useful for
90
+ * swapping a previously-inserted ref.
91
+ */
52
92
  replaceRange(from: number, to: number, text: string): void;
53
93
  getCursorPosition(): number;
94
+ /**
95
+ * The underlying CodeMirror view, for advanced use. A config change
96
+ * replaces it, so don't hold on to it across `updateOptions`.
97
+ */
54
98
  getView(): EditorView | null;
55
99
  /**
56
100
  * Update live options without recreating the editor. Callback / function-
57
101
  * list / sheet-name changes apply immediately; a changed `config` rebuilds
58
102
  * the view (preserving text + cursor); a changed controlled `value` is
59
103
  * dispatched into the document.
104
+ *
105
+ * Callbacks can be cleared by passing the key with `undefined`;
106
+ * `getDisplayUnits` / `formulaFunctions` cannot (falsy is ignored). The
107
+ * rebuild on a config change drops undo history, and when it happens any
108
+ * `value` in the same call is ignored. A new `sheetName` takes effect at
109
+ * the next highlight refresh, not immediately. Do not call after
110
+ * `destroy()` — a config change would mount a fresh view.
60
111
  */
61
112
  updateOptions(opts: Partial<FormulaEditorOptions>): void;
113
+ /**
114
+ * Tear down the view, pending refresh timer and blur listener. Must be
115
+ * called when the host element goes away. The host element keeps the
116
+ * classes / inline styles the editor added.
117
+ */
62
118
  destroy(): void;
63
119
  }
64
120
  /**
65
121
  * Create a formula editor mounted into `parent`. Returns an imperative handle;
66
122
  * call `destroy()` when done.
123
+ *
124
+ * The CodeMirror view is appended to `parent`, which also gets the
125
+ * `formula-editor` class and sizing / border styles. `getDisplayUnits` is
126
+ * called immediately when the initial text is a formula. Does not throw on a failing
127
+ * host callback: `getDisplayUnits` errors are logged to the console.
67
128
  */
68
129
  export declare function createFormulaEditor(parent: HTMLElement, options: FormulaEditorOptions): FormulaEditorHandle;
69
130
  //# sourceMappingURL=editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../src/lib/editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EACH,UAAU,EAQb,MAAM,kBAAkB,CAAA;AAUzB,OAAO,KAAK,EAER,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACtB,MAAM,SAAS,CAAA;AA0YhB;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACjC,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,8DAA8D;IAC9D,qBAAqB,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;IACvC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,CACT,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EAC3C,SAAS,EAAE;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,OAA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,QAAQ,IAAI,MAAM,CAAA;IAClB,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,4DAA4D;IAC5D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1D,iBAAiB,IAAI,MAAM,CAAA;IAC3B;;;OAGG;IACH,OAAO,IAAI,UAAU,GAAG,IAAI,CAAA;IAC5B;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAA;IACxD;;;;OAIG;IACH,OAAO,IAAI,IAAI,CAAA;CAClB;AAcD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,oBAAoB,GAC9B,mBAAmB,CAsgBrB"}
@@ -1,6 +1,16 @@
1
1
  import { CellRef, FormulaFunction, GetDisplayUnitsFunc } from './types';
2
- /** The slice of a workbook client the source needs. */
2
+ /**
3
+ * The slice of a workbook client the source needs. Only
4
+ * `getDisplayUnitsOfFormula` is used by {@link createEngineFormulaSource}; the
5
+ * two navigation methods are for the `/inline` controller's point mode. All
6
+ * indices are 0-based.
7
+ */
3
8
  export interface FormulaWorkbook {
9
+ /**
10
+ * Lex a formula body (no leading '='). Resolves to a
11
+ * {@link FormulaDisplayInfo} on success or an error-message object
12
+ * otherwise; the source tells them apart by the `tokenUnits` key.
13
+ */
4
14
  getDisplayUnitsOfFormula(formula: string): Promise<unknown>;
5
15
  /**
6
16
  * Point-mode arrow move: the next visible cell in a direction (skips hidden
@@ -24,9 +34,17 @@ export interface FormulaWorkbook {
24
34
  }
25
35
  /** The slice of an engine `DataService` the source needs. */
26
36
  export interface EngineFormulaServices {
37
+ /** Called per request, not cached, so a swapped workbook is picked up. */
27
38
  getWorkbook(): FormulaWorkbook;
39
+ /**
40
+ * Whether a formula (text as typed, including the leading '=') parses.
41
+ * Expected to resolve `false` rather than reject on an engine error.
42
+ */
28
43
  checkFormula(formula: string): Promise<boolean>;
29
- /** Sheet name for a given index — used to build cross-sheet references. */
44
+ /**
45
+ * Sheet name for a 0-based sheet index — used by `/inline` to qualify
46
+ * cross-sheet references. Not used by {@link createEngineFormulaSource}.
47
+ */
30
48
  getSheetNameByIdx(idx: number): string;
31
49
  }
32
50
  export interface EngineFormulaSourceOptions {
@@ -41,7 +59,11 @@ export interface EngineFormulaSourceOptions {
41
59
  */
42
60
  onCellRefs?: (cellRefs: readonly CellRef[]) => void;
43
61
  }
44
- /** Props the editor consumes, derived from the engine. */
62
+ /**
63
+ * Props derived from the engine. The editor itself consumes
64
+ * `getDisplayUnits` + `formulaFunctions`; `checkFormula` is for the host's
65
+ * commit path — the editor never validates on its own.
66
+ */
45
67
  export interface EngineFormulaSource {
46
68
  getDisplayUnits: GetDisplayUnitsFunc;
47
69
  checkFormula: (formula: string) => Promise<boolean>;
@@ -50,6 +72,12 @@ export interface EngineFormulaSource {
50
72
  /**
51
73
  * Build the editor's data props from an engine `DataService`. Spread the result
52
74
  * into `createFormulaEditor` / `<FormulaEditor>`.
75
+ *
76
+ * The returned `getDisplayUnits` never rejects: an engine error, a thrown
77
+ * call, or an unlexable formula all resolve `undefined` (no highlighting) and report
78
+ * an empty ref list to `onCellRefs`, so an overlay clears instead of showing
79
+ * stale highlights. `checkFormula` is passed through unchanged. Holds no
80
+ * resources — nothing to dispose.
53
81
  */
54
82
  export declare function createEngineFormulaSource(services: EngineFormulaServices, options?: EngineFormulaSourceOptions): EngineFormulaSource;
55
83
  //# sourceMappingURL=engine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/lib/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,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AED,MAAM,WAAW,0BAA0B;IACvC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAA;IACpC;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,KAAK,IAAI,CAAA;CACtD;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAChC,eAAe,EAAE,mBAAmB,CAAA;IACpC,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IACnD,gBAAgB,EAAE,eAAe,EAAE,CAAA;CACtC;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACrC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,GAAE,0BAA+B,GACzC,mBAAmB,CA8BrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/lib/functions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AAG5C,eAAO,MAAM,uBAAuB,EAAE,eAAe,EACxB,CAAA"}
1
+ {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/lib/functions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AAG5C,eAAO,MAAM,uBAAuB,EAAE,eAAe,EACxB,CAAA"}
@@ -8,6 +8,18 @@
8
8
  * This root entry includes the React `<FormulaEditor>` component. For a
9
9
  * framework-agnostic (vanilla / Vue / Svelte / Angular) build with no React
10
10
  * dependency, import from `logisheets-formula-editor/core` instead.
11
+ *
12
+ * Main exports: `FormulaEditor` / `FormulaEditorRef` (React), everything from
13
+ * `./core` (`createFormulaEditor`, types, utils, `builtinFormulaFunctions`)
14
+ * and from `./engine` (`createEngineFormulaSource`). The in-cell editor
15
+ * controller is NOT re-exported here — it needs the `logisheets-engine` peer
16
+ * at runtime, so it lives only at the `logisheets-formula-editor/inline`
17
+ * subpath.
18
+ *
19
+ * Consumers in this repo: the root app's edit bar
20
+ * (src/components/content/edit-bar.tsx) mounts `<FormulaEditor>` wired with
21
+ * `createEngineFormulaSource`; the app's grid uses `/inline` for in-cell
22
+ * editing (src/components/spreadsheet-view/inline-cell-editor.tsx).
11
23
  */
12
24
  export { FormulaEditor } from './FormulaEditor';
13
25
  export type { FormulaEditorRef } from './FormulaEditor';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAC7C,YAAY,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAA;AAGrD,cAAc,QAAQ,CAAA;AAGtB,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAC7C,YAAY,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAA;AAGrD,cAAc,QAAQ,CAAA;AAItB,cAAc,UAAU,CAAA"}
@@ -29,7 +29,12 @@ export interface FormulaEditEntry {
29
29
  * committing, and sheet tabs / other canvases know not to steal focus.
30
30
  */
31
31
  export interface FormulaCoordinator {
32
+ /** Called when an edit enters formula mode (text starts with '='). */
32
33
  setActive(entry: FormulaEditEntry): void;
34
+ /**
35
+ * Called when that edit leaves formula mode or finishes. Implementations
36
+ * should ignore an entry that is no longer the active one.
37
+ */
33
38
  clear(entry: FormulaEditEntry): void;
34
39
  getActive(): FormulaEditEntry | null;
35
40
  isFormulaEditing(): boolean;
@@ -43,7 +48,11 @@ export interface InlineCellEditorOptions {
43
48
  /** Emits startEdit / selectionChange / invalidFormula for this view
44
49
  * (an engine `Session`, or the `Engine` itself for the main view). */
45
50
  eventSource: Pick<Session, 'on' | 'off'>;
46
- /** Engine data service — `getWorkbook()` + `checkFormula()`. */
51
+ /**
52
+ * Engine data service — `getWorkbook()` (display units + point-mode
53
+ * navigation), `checkFormula()`, and `getSheetNameByIdx()` for qualifying
54
+ * cross-sheet refs.
55
+ */
47
56
  dataService: EngineFormulaServices;
48
57
  /** Stable id of the view that owns this editor (cross-view routing). */
49
58
  viewId: string;
@@ -52,7 +61,9 @@ export interface InlineCellEditorOptions {
52
61
  /** Current sheet name (read fresh; used for local cell-ref coloring). */
53
62
  getSheetName: () => string;
54
63
  /** Commit a cell value (the host's input/ops layer). The return value is
55
- * awaited but otherwise ignored, so `void`/any Promise is fine. */
64
+ * awaited but otherwise ignored, so `void`/any Promise is fine. `text` is
65
+ * trimmed; a formula has already passed `checkFormula`. A rejection
66
+ * propagates and leaves the editor open. */
56
67
  inputCell: (sheetIdx: number, row: number, col: number, text: string) => unknown;
57
68
  /** Move the view's selection (e.g. after committing). */
58
69
  setSelection: (data: SelectedData) => void;
@@ -79,13 +90,23 @@ export interface InlineCellEditorOptions {
79
90
  onEditRefused?: (sheetIdx: number, row: number, col: number) => void;
80
91
  /** Autocomplete / signature functions. Default: bundled built-ins. */
81
92
  formulaFunctions?: FormulaFunction[];
82
- /** Maps a reference index to a CSS color. Default: built-in palette. */
93
+ /**
94
+ * Maps a reference index to a CSS color for the grid overlays. Default:
95
+ * built-in palette. The in-editor text highlight always uses the built-in
96
+ * palette, so a custom mapping makes the two disagree.
97
+ */
83
98
  getHighlightColor?: (index: number) => string;
84
99
  /** Base editor config (merged over the in-cell defaults). */
85
100
  editorConfig?: FormulaEditorConfig;
86
- /** Called when a committed formula fails validation. */
101
+ /**
102
+ * Called when a committed formula fails validation (the editor stays
103
+ * open), and on the event source's `invalidFormula` event.
104
+ */
87
105
  onInvalidFormula?: () => void;
88
- /** Reports whether an editor is open (so the canvas can avoid stealing focus). */
106
+ /**
107
+ * Reports whether an editor is open (so the canvas can avoid stealing
108
+ * focus). `false` is also reported by `destroy()`, open editor or not.
109
+ */
89
110
  onEditingChange?: (editing: boolean) => void;
90
111
  /** Bumped after commits / selection moves so dependents re-read content. */
91
112
  onContentChanged?: () => void;
@@ -101,13 +122,29 @@ export interface InlineCellEditorOptions {
101
122
  shift: boolean;
102
123
  }) => boolean;
103
124
  }
125
+ /** Handle returned by {@link createInlineCellEditor}. */
104
126
  export interface InlineCellEditorHandle {
105
127
  /** Call on every grid change/render: repositions the editor and repaints
106
128
  * highlights (parks the editor off-screen if its cell scrolled away). */
107
129
  setGrid(grid: Grid | null): void;
108
130
  isEditing(): boolean;
131
+ /** Editing and the text starts with '=' (i.e. point mode is on). */
109
132
  isEditingFormula(): boolean;
133
+ /**
134
+ * Unsubscribe from the event source and close any open edit WITHOUT
135
+ * committing it. Call when the view is torn down.
136
+ */
110
137
  destroy(): void;
111
138
  }
139
+ /**
140
+ * Wire an in-cell formula editor to one engine view. Subscribes to
141
+ * `eventSource` immediately; nothing is mounted until a `startEdit` arrives.
142
+ *
143
+ * The host must keep the grid current via `setGrid` — `startEdit` is ignored
144
+ * while no grid is known, and positions / highlights go stale otherwise.
145
+ * Commit runs on Enter, on blur of a plain-text edit, or when the selection
146
+ * moves to another cell; a formula edit is not committed on blur (point mode)
147
+ * and a failing `checkFormula` keeps it open. Escape cancels.
148
+ */
112
149
  export declare function createInlineCellEditor(options: InlineCellEditorOptions): InlineCellEditorHandle;
113
150
  //# sourceMappingURL=inline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../../src/lib/inline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAA4B,KAAK,qBAAqB,EAAC,MAAM,UAAU,CAAA;AAG9E,OAAO,EAAkB,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAAC,MAAM,SAAS,CAAA;AAUvF,OAAO,KAAK,EAC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* Types for the Formula Editor
3
3
  *
4
- * These match the backend API types from logisheets-web
4
+ * The wire types (`TokenType`, `TokenUnit`, `CellRef`, `FormulaDisplayInfo`)
5
+ * mirror logisheets-web's generated bindings for the Rust
6
+ * `lexer4fmt::FormulaDisplayInfo` (crates/controller/lexer4fmt/src/fmt.rs);
7
+ * they are redeclared here so the package has no logisheets-web dependency.
5
8
  */
6
9
  /**
7
10
  * Token types returned by the backend lexer.
@@ -14,14 +17,23 @@ export type TokenType = 'funcName' | 'funcArg' | 'cellReference' | 'errorConstan
14
17
  */
15
18
  export interface TokenUnit {
16
19
  tokenType: TokenType;
17
- /** Start index in the formula string (0-based, excludes leading '=') */
20
+ /**
21
+ * Start offset into the formula body (the text after the leading '=').
22
+ * 0-based UTF-8 BYTE offset, not a JS string index — it only matches the
23
+ * string index for ASCII text; the editor converts before use.
24
+ */
18
25
  start: number;
19
- /** End index in the formula string (exclusive) */
26
+ /** End offset, exclusive; same basis as `start`. */
20
27
  end: number;
21
28
  }
22
29
  /**
23
30
  * Cell reference info parsed by the backend.
24
31
  * Used for highlighting cell references with colors.
32
+ *
33
+ * `row*` / `col*` are 0-based indices (A1 is row 0, col 0); `*2` is set only
34
+ * for a range. A missing row or column means that part was not written (e.g.
35
+ * a whole-column `A:A`). Sheet / workbook names are as written, without the
36
+ * surrounding quotes; `sheet2` is set only for a 3D `Sheet1:Sheet2!` ref.
25
37
  */
26
38
  export interface CellRef {
27
39
  workbook?: string;
@@ -35,6 +47,9 @@ export interface CellRef {
35
47
  /**
36
48
  * The complete display info returned by the backend for a formula.
37
49
  * This is what the editor receives from `getDisplayUnitsOfFormula`.
50
+ *
51
+ * Invariant: `cellRefs[i]` belongs to the i-th `cellReference` token in
52
+ * `tokenUnits` (same order), which is how highlight colors stay paired.
38
53
  */
39
54
  export interface FormulaDisplayInfo {
40
55
  cellRefs: readonly CellRef[];
@@ -42,19 +57,28 @@ export interface FormulaDisplayInfo {
42
57
  }
43
58
  /**
44
59
  * Function to fetch formula display info from backend.
45
- * The editor calls this whenever the text changes.
60
+ * The editor calls this on creation and ~100 ms after the last edit
61
+ * (debounced), only while the text is a formula (see `isFormula`).
62
+ *
63
+ * A rejection is caught and logged, and the previous highlighting is kept;
64
+ * resolving `undefined` clears it. Responses are applied in completion order,
65
+ * so an implementation should not let a slow call outlive a newer one.
46
66
  *
47
67
  * @param formula - The formula text (with leading '=' stripped)
48
68
  * @returns Promise resolving to FormulaDisplayInfo or undefined if not a formula
49
69
  */
50
70
  export type GetDisplayUnitsFunc = (formula: string) => Promise<FormulaDisplayInfo | undefined>;
51
71
  /**
52
- * A formula function definition for autocomplete.
72
+ * A formula function definition for autocomplete and signature help.
73
+ * Names are matched case-insensitively against the typed function name.
53
74
  */
54
75
  export interface FormulaFunction {
55
76
  /** Function name, e.g. "SUM" */
56
77
  name: string;
57
- /** Description of what the function does */
78
+ /**
79
+ * Description of what the function does — shown verbatim, so pass
80
+ * already-localized text (the editor does no i18n lookup).
81
+ */
58
82
  description: string;
59
83
  /** Function arguments */
60
84
  args: FormulaArg[];
@@ -71,7 +95,10 @@ export interface FormulaFunction {
71
95
  export interface FormulaArg {
72
96
  argName: string;
73
97
  description: string;
74
- /** If true, this argument can repeat */
98
+ /**
99
+ * If true, this argument and the ones after it repeat (signature help
100
+ * shows `name, name1, name2, ...`).
101
+ */
75
102
  startRepeated?: boolean;
76
103
  }
77
104
  /**
@@ -121,6 +148,11 @@ export interface FormulaEditorConfig {
121
148
  }
122
149
  /**
123
150
  * Props for the FormulaEditor component.
151
+ *
152
+ * Every prop except `defaultValue`, `initialCursorPosition`, `className` and
153
+ * `style` is re-synced on each render; those four are read once at mount.
154
+ * Point-mode arrow handling (`onArrowKey`) is only exposed by the vanilla
155
+ * `createFormulaEditor`.
124
156
  */
125
157
  export interface FormulaEditorProps {
126
158
  /** Current value (controlled) */
@@ -129,11 +161,18 @@ export interface FormulaEditorProps {
129
161
  defaultValue?: string;
130
162
  /** Initial cursor position: 'start' or 'end' (default: 'end') */
131
163
  initialCursorPosition?: 'start' | 'end';
132
- /** Called when value changes */
164
+ /**
165
+ * Called when value changes — including programmatic `setValue` /
166
+ * controlled `value` updates, not just typing.
167
+ */
133
168
  onChange?: (value: string) => void;
134
169
  /** Called when editor loses focus - use this to commit the value */
135
170
  onBlur?: (value: string) => void;
136
- /** Called when Enter is pressed (without modifier keys) */
171
+ /**
172
+ * Called when Enter is pressed (without modifier keys) while no
173
+ * autocomplete list is open — Enter accepts the completion instead.
174
+ * Alt+Enter inserts a newline.
175
+ */
137
176
  onSubmit?: (value: string) => void;
138
177
  /** Called when Escape is pressed */
139
178
  onCancel?: () => void;
@@ -141,7 +180,10 @@ export interface FormulaEditorProps {
141
180
  getDisplayUnits: GetDisplayUnitsFunc;
142
181
  /** List of available formula functions for autocomplete */
143
182
  formulaFunctions?: FormulaFunction[];
144
- /** Current sheet name (for determining if cell refs are local) */
183
+ /**
184
+ * Current sheet name, compared against `CellRef.sheet1` to decide which
185
+ * refs are local (only local refs get a colored background).
186
+ */
145
187
  sheetName?: string;
146
188
  /** Configuration options */
147
189
  config?: FormulaEditorConfig;
@@ -155,5 +197,6 @@ export interface FormulaEditorProps {
155
197
  * Returns a different color for each reference index to distinguish them.
156
198
  */
157
199
  export declare const CELL_REF_COLORS: string[];
200
+ /** Palette color for the `index`-th reference; wraps after six. */
158
201
  export declare function getCellRefColor(index: number): string;
159
202
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,MAAM,SAAS,GACf,UAAU,GACV,SAAS,GACT,eAAe,GACf,eAAe,GACf,aAAa,GACb,OAAO,CAAA;AAEb;;;GAGG;AACH,MAAM,WAAW,SAAS;IACtB,SAAS,EAAE,SAAS,CAAA;IACpB,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAA;IACb,kDAAkD;IAClD,GAAG,EAA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ED,mEAAmE;AACnE,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD"}
@@ -14,6 +14,10 @@ export interface DisplayUnit {
14
14
  * Convert formula display info to display units for rendering.
15
15
  * The offset accounts for the leading '=' being stripped before sending to backend.
16
16
  *
17
+ * Treats token offsets as string indices, so it is only correct for ASCII
18
+ * formulas — the backend emits UTF-8 byte offsets (see `TokenUnit`). The
19
+ * CodeMirror editor does not use this; it converts offsets itself.
20
+ *
17
21
  * @param formula - The full formula string (including leading '=')
18
22
  * @param displayInfo - Token info from backend
19
23
  * @returns Array of display units for rendering
@@ -25,14 +29,18 @@ export declare function convertToDisplayUnits(formula: string, displayInfo: Form
25
29
  */
26
30
  export declare function isLocalCellRef(cellRef: CellRef, currentSheet: string): boolean;
27
31
  /**
28
- * Simple fuzzy match using longest common subsequence.
32
+ * Case-insensitive subsequence match: every query char must appear in
33
+ * `target` in order (greedy, first occurrence). `indices` are the matched
34
+ * positions in `target`; an empty query matches everything.
29
35
  */
30
36
  export declare function fuzzyMatch(query: string, target: string): {
31
37
  matched: boolean;
32
38
  indices: number[];
33
39
  };
34
40
  /**
35
- * Check if text starts with '=' indicating a formula.
41
+ * Whether the text is a formula: starts with '=' after trimming, or is an
42
+ * array formula `{=...}`. Note the editor strips the '=' only when it is the
43
+ * very first character, so ` =A1` or `{=A1}` reach `getDisplayUnits` as-is.
36
44
  */
37
45
  export declare function isFormula(text: string): boolean;
38
46
  /**
@@ -48,9 +56,14 @@ export declare function isFormula(text: string): boolean;
48
56
  * R1C1, structured refs, …) so the caller can leave it untouched.
49
57
  */
50
58
  export declare function cycleReferenceAbsolute(text: string): string | null;
59
+ /**
60
+ * Width in CSS pixels of `text` rendered in `font` (a CSS font shorthand).
61
+ * Falls back to 8 px per char when no 2D context is available.
62
+ */
51
63
  export declare function measureText(text: string, font: string): number;
52
64
  /**
53
- * Generate a simple UUID.
65
+ * Generate a v4-shaped UUID from `Math.random` — fine for DOM ids, not
66
+ * cryptographically unique.
54
67
  */
55
68
  export declare function simpleUuid(): string;
56
69
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAE,kBAAkB,EAAE,OAAO,EAAC,MAAM,SAAS,CAAA;AAEnE;;GAEG;AACH,eAAO,MAAM,GAAG,OAAO,CAAA;AAEvB;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,OAAO,CAAA;CACpC;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACjC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,kBAAkB,GAChC,WAAW,EAAE,CAqCf;AAqBD;;;GAGG;AACH,wBAAgB,cAAc,CAC1B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,GACrB,OAAO,CAcT;AAED;;GAEG;AACH,wBAAgB,UAAU,CACtB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACf;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAC,CAqBvC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQ/C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkClE;AAQD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAS9D;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAMnC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAE,kBAAkB,EAAE,OAAO,EAAC,MAAM,SAAS,CAAA;AAEnE;;GAEG;AACH,eAAO,MAAM,GAAG,OAAO,CAAA;AAEvB;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,OAAO,CAAA;CACpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACjC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,kBAAkB,GAChC,WAAW,EAAE,CAqCf;AAqBD;;;GAGG;AACH,wBAAgB,cAAc,CAC1B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,GACrB,OAAO,CAcT;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACtB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACf;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAC,CAqBvC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQ/C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoClE;AAOD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAS9D;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAMnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "logisheets-formula-editor",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "description": "Excel-style formula editor for spreadsheets — syntax highlighting, per-reference cell-ref coloring, and function autocomplete, built on CodeMirror 6. Ships a React component and a framework-agnostic core.",
5
5
  "author": "Jeremy He",
6
6
  "license": "MIT",