@toclocoinc/lattice-grid 1.20.0 → 1.21.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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  dependencies, no build step required. Optional adapters for React, Vue, Svelte
5
5
  and Web Components ship alongside it.
6
6
 
7
- Version 1.20.0 · [latticegrid.dev](https://www.latticegrid.dev) · TOCLOCO Inc
7
+ Version 1.21.0 · [latticegrid.dev](https://www.latticegrid.dev) · TOCLOCO Inc
8
8
 
9
9
  ---
10
10
 
package/docs/API.html CHANGED
@@ -4811,6 +4811,7 @@ grid.destroy();
4811
4811
  <tbody>
4812
4812
  <tr><td class="name">headers</td><td class="type">boolean</td><td class="desc"><small>(optional)</small></td></tr>
4813
4813
  <tr><td class="name">rows</td><td class="type">'visible' | 'all' | 'selected' | 'range'</td><td class="desc"><small>(optional)</small></td></tr>
4814
+ <tr><td class="name">sanitise</td><td class="type">boolean</td><td class="desc">Apply the CSV/Excel formula-injection guard to copied cells: prefix a field beginning with `=`, `+`, `-`, `@`, a tab or a CR with an apostrophe so a spreadsheet treats it as text. **Off by default** (unlike CSV/Excel export, which default it on), because the clipboard most often round-trips back into a grid or cell range where the apostrophe would corrupt the value. Turn it on when your users paste the clipboard into Excel or Google Sheets. <small>(optional)</small></td></tr>
4814
4815
  </tbody>
4815
4816
  </table>
4816
4817
  </div>
@@ -437,7 +437,7 @@
437
437
  <div class="shell">
438
438
  <aside class="rail">
439
439
  <p class="rail__brand">Lattice Grid</p>
440
- <p class="rail__sub">Developer guide · v1.20.0</p>
440
+ <p class="rail__sub">Developer guide · v1.21.0</p>
441
441
  <nav>
442
442
  <div class="rail__group">
443
443
  <span class="rail__label">Start here</span>
@@ -4864,6 +4864,29 @@ grid.export.clipboard({ rows: 'range' }); <span class="cmt">// copy the
4864
4864
  grid.export.clipboard({ headers: true, rows: 'selected' });
4865
4865
 
4866
4866
  grid.edit.pasteInto(text); <span class="cmt">// Excel's tiling rules</span></code></pre>
4867
+ </div>
4868
+ <h3 id="clipboard-formula-guard">Guarding against formula injection on paste</h3>
4869
+ <p class="lead-in">
4870
+ By default a copied range round-trips verbatim, so a value beginning <code>=</code>,
4871
+ <code>+</code>, <code>-</code> or <code>@</code> is carried unchanged &mdash; the right thing
4872
+ when the paste target is another grid or cell range. When the paste target is a spreadsheet,
4873
+ pass <code>sanitise: true</code> and a leading formula character is neutralised with an
4874
+ apostrophe, so the value cannot be executed as a formula in Excel or Sheets.
4875
+ </p>
4876
+ <div class="example">
4877
+ <p class="example__label">Opt in per copy</p>
4878
+ <pre data-run="js" data-expect="default:=1+1 guarded:'=1+1" data-covers="config:sanitise"><code><span class="kw">const</span> { buildClipboardText } = <span class="kw">await</span> import('../packages/core/src/export/index.js');
4879
+
4880
+ <span class="cmt">// An explicit cell matrix; the formula guard applies to data fields.</span>
4881
+ <span class="kw">const</span> cells = [['=1+1']];
4882
+
4883
+ <span class="cmt">// Off by default: the value round-trips exactly as copied.</span>
4884
+ <span class="kw">const</span> plain = buildClipboardText({}, { rows: 'range', cells });
4885
+
4886
+ <span class="cmt">// sanitise:true prefixes an apostrophe so a spreadsheet stores it as text.</span>
4887
+ <span class="kw">const</span> guarded = buildClipboardText({}, { rows: 'range', cells, sanitise: <span class="kw">true</span> });
4888
+
4889
+ <span class="kw">return</span> `default:${plain} guarded:${guarded}`;</code></pre>
4867
4890
  </div>
4868
4891
  <div class="why">
4869
4892
  <p>Pasting follows the spreadsheet convention: one cell into a range fills the range, one row
package/lattice-grid.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Lattice Grid 1.20.0, type declarations
2
+ * Lattice Grid 1.21.0, type declarations
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
@@ -2679,6 +2679,15 @@ export interface ExcelExportOptions extends Omit<CsvExportOptions, 'delimiter' |
2679
2679
  export interface ClipboardOptions {
2680
2680
  headers?: boolean;
2681
2681
  rows?: 'visible' | 'all' | 'selected' | 'range';
2682
+ /**
2683
+ * Apply the CSV/Excel formula-injection guard to copied cells: prefix a field
2684
+ * beginning with `=`, `+`, `-`, `@`, a tab or a CR with an apostrophe so a
2685
+ * spreadsheet treats it as text. **Off by default** (unlike CSV/Excel export,
2686
+ * which default it on), because the clipboard most often round-trips back into
2687
+ * a grid or cell range where the apostrophe would corrupt the value. Turn it
2688
+ * on when your users paste the clipboard into Excel or Google Sheets.
2689
+ */
2690
+ sanitise?: boolean;
2682
2691
  }
2683
2692
 
2684
2693
  // ---------------------------------------------------------------------------