@pixerate/editor 0.22.0 → 0.24.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.
Files changed (188) hide show
  1. package/README.md +175 -2
  2. package/THIRD_PARTY_NOTICES.md +139 -0
  3. package/dist/agent/index.cjs +87 -111
  4. package/dist/agent/index.cjs.map +1 -1
  5. package/dist/agent/index.d.cts +70 -211
  6. package/dist/agent/index.d.ts +70 -211
  7. package/dist/agent/index.js +78 -102
  8. package/dist/agent/index.js.map +1 -1
  9. package/dist/arrangeShortcuts-B8O3f8-P.d.cts +184 -0
  10. package/dist/arrangeShortcuts-sLlD2rSX.d.ts +184 -0
  11. package/dist/canvas/index.cjs +2075 -86
  12. package/dist/canvas/index.cjs.map +1 -1
  13. package/dist/canvas/index.d.cts +608 -186
  14. package/dist/canvas/index.d.ts +608 -186
  15. package/dist/canvas/index.js +2060 -71
  16. package/dist/canvas/index.js.map +1 -1
  17. package/dist/chunk-26BVFKHU.cjs +453 -0
  18. package/dist/chunk-26BVFKHU.cjs.map +1 -0
  19. package/dist/chunk-2H7ZHPEJ.js +762 -0
  20. package/dist/chunk-2H7ZHPEJ.js.map +1 -0
  21. package/dist/{chunk-DENSCKFC.js → chunk-3CN2WD3X.js} +1730 -189
  22. package/dist/chunk-3CN2WD3X.js.map +1 -0
  23. package/dist/{chunk-JJDLPEWL.js → chunk-3LV6RRPH.js} +2 -2
  24. package/dist/{chunk-MJZBNWG7.js → chunk-5S3Z4PPF.js} +78 -557
  25. package/dist/chunk-5S3Z4PPF.js.map +1 -0
  26. package/dist/chunk-664LQYFJ.js +115 -0
  27. package/dist/chunk-664LQYFJ.js.map +1 -0
  28. package/dist/chunk-7DWMJCAT.js +453 -0
  29. package/dist/chunk-7DWMJCAT.js.map +1 -0
  30. package/dist/chunk-ARRTP33I.js +101 -0
  31. package/dist/chunk-ARRTP33I.js.map +1 -0
  32. package/dist/chunk-CPOKFNBG.cjs +101 -0
  33. package/dist/chunk-CPOKFNBG.cjs.map +1 -0
  34. package/dist/{chunk-AA4ZEVCC.cjs → chunk-D27YFC46.cjs} +101 -580
  35. package/dist/chunk-D27YFC46.cjs.map +1 -0
  36. package/dist/chunk-D6FH2YAX.cjs +131 -0
  37. package/dist/chunk-D6FH2YAX.cjs.map +1 -0
  38. package/dist/{chunk-4SUNJZWB.cjs → chunk-FD4LPFAE.cjs} +48 -200
  39. package/dist/chunk-FD4LPFAE.cjs.map +1 -0
  40. package/dist/chunk-FODNLX5N.js +749 -0
  41. package/dist/chunk-FODNLX5N.js.map +1 -0
  42. package/dist/{chunk-OYXSKQFR.js → chunk-FPENXAEJ.js} +35 -187
  43. package/dist/chunk-FPENXAEJ.js.map +1 -0
  44. package/dist/chunk-G2I4QJOT.cjs +762 -0
  45. package/dist/chunk-G2I4QJOT.cjs.map +1 -0
  46. package/dist/chunk-HLIMTC6N.js +1 -0
  47. package/dist/chunk-HLIMTC6N.js.map +1 -0
  48. package/dist/{chunk-QGHGJ56O.js → chunk-ITBSKI26.js} +1483 -19
  49. package/dist/chunk-ITBSKI26.js.map +1 -0
  50. package/dist/{chunk-6M3BCTBD.cjs → chunk-MA2F5KHF.cjs} +470 -242
  51. package/dist/chunk-MA2F5KHF.cjs.map +1 -0
  52. package/dist/{chunk-SAZRENEZ.cjs → chunk-MCSJFWAO.cjs} +1733 -192
  53. package/dist/chunk-MCSJFWAO.cjs.map +1 -0
  54. package/dist/chunk-MKA3AHLV.cjs +256 -0
  55. package/dist/chunk-MKA3AHLV.cjs.map +1 -0
  56. package/dist/chunk-OLZJXL4R.cjs +749 -0
  57. package/dist/chunk-OLZJXL4R.cjs.map +1 -0
  58. package/dist/chunk-OXSV64JX.js +689 -0
  59. package/dist/chunk-OXSV64JX.js.map +1 -0
  60. package/dist/chunk-P3RQ5UJE.cjs +689 -0
  61. package/dist/chunk-P3RQ5UJE.cjs.map +1 -0
  62. package/dist/chunk-P6ODPZ4W.js +256 -0
  63. package/dist/chunk-P6ODPZ4W.js.map +1 -0
  64. package/dist/chunk-PGNZKFQS.js +685 -0
  65. package/dist/chunk-PGNZKFQS.js.map +1 -0
  66. package/dist/chunk-PL4JB3BF.cjs +1 -0
  67. package/dist/chunk-PL4JB3BF.cjs.map +1 -0
  68. package/dist/{chunk-GVSMRPHB.cjs → chunk-SBCZ6RN5.cjs} +1568 -104
  69. package/dist/chunk-SBCZ6RN5.cjs.map +1 -0
  70. package/dist/{chunk-CL37JGFW.cjs → chunk-SML64VJG.cjs} +4 -4
  71. package/dist/{chunk-CL37JGFW.cjs.map → chunk-SML64VJG.cjs.map} +1 -1
  72. package/dist/chunk-TNNJXF46.cjs +115 -0
  73. package/dist/chunk-TNNJXF46.cjs.map +1 -0
  74. package/dist/chunk-U5HZSFCS.js +131 -0
  75. package/dist/chunk-U5HZSFCS.js.map +1 -0
  76. package/dist/{chunk-RU52I7QO.js → chunk-U5KWZU4X.js} +388 -160
  77. package/dist/chunk-U5KWZU4X.js.map +1 -0
  78. package/dist/chunk-XNORY7M6.cjs +685 -0
  79. package/dist/chunk-XNORY7M6.cjs.map +1 -0
  80. package/dist/commands/index.cjs +860 -0
  81. package/dist/commands/index.cjs.map +1 -0
  82. package/dist/commands/index.d.cts +244 -0
  83. package/dist/commands/index.d.ts +244 -0
  84. package/dist/commands/index.js +860 -0
  85. package/dist/commands/index.js.map +1 -0
  86. package/dist/comment-store-BEMgVlAA.d.cts +135 -0
  87. package/dist/comment-store-BEMgVlAA.d.ts +135 -0
  88. package/dist/compare/index.cjs +15 -0
  89. package/dist/compare/index.cjs.map +1 -0
  90. package/dist/compare/index.d.cts +58 -0
  91. package/dist/compare/index.d.ts +58 -0
  92. package/dist/compare/index.js +15 -0
  93. package/dist/compare/index.js.map +1 -0
  94. package/dist/{controller-B7GIybc4.d.cts → controller-BhLLAoi8.d.cts} +119 -5
  95. package/dist/{controller-B7GIybc4.d.ts → controller-BhLLAoi8.d.ts} +119 -5
  96. package/dist/documents-BQjzJNe2.d.ts +76 -0
  97. package/dist/documents-KRTPhvst.d.cts +76 -0
  98. package/dist/extensions/index.cjs +53 -5
  99. package/dist/extensions/index.cjs.map +1 -1
  100. package/dist/extensions/index.d.cts +7 -3
  101. package/dist/extensions/index.d.ts +7 -3
  102. package/dist/extensions/index.js +52 -4
  103. package/dist/generation/index.cjs +1373 -0
  104. package/dist/generation/index.cjs.map +1 -0
  105. package/dist/generation/index.d.cts +554 -0
  106. package/dist/generation/index.d.ts +554 -0
  107. package/dist/generation/index.js +1373 -0
  108. package/dist/generation/index.js.map +1 -0
  109. package/dist/grammar/index.cjs +48 -3
  110. package/dist/grammar/index.cjs.map +1 -1
  111. package/dist/grammar/index.d.cts +322 -100
  112. package/dist/grammar/index.d.ts +322 -100
  113. package/dist/grammar/index.js +54 -9
  114. package/dist/history/index.cjs +12 -2
  115. package/dist/history/index.cjs.map +1 -1
  116. package/dist/history/index.d.cts +211 -7
  117. package/dist/history/index.d.ts +211 -7
  118. package/dist/history/index.js +13 -3
  119. package/dist/image-editor/index.cjs +2244 -38
  120. package/dist/image-editor/index.cjs.map +1 -1
  121. package/dist/image-editor/index.d.cts +742 -4
  122. package/dist/image-editor/index.d.ts +742 -4
  123. package/dist/image-editor/index.js +2222 -16
  124. package/dist/image-editor/index.js.map +1 -1
  125. package/dist/{index-CCr_z9kF.d.cts → index-BhJBSm2d.d.cts} +370 -4
  126. package/dist/{index-Ck6ajwXh.d.ts → index-fJrlkJCd.d.ts} +370 -4
  127. package/dist/index.cjs +193 -98
  128. package/dist/index.cjs.map +1 -1
  129. package/dist/index.d.cts +17 -48
  130. package/dist/index.d.ts +17 -48
  131. package/dist/index.js +198 -103
  132. package/dist/index.js.map +1 -1
  133. package/dist/migrate-iTlm3a8h.d.cts +112 -0
  134. package/dist/migrate-iTlm3a8h.d.ts +112 -0
  135. package/dist/persistence/index.cjs +676 -0
  136. package/dist/persistence/index.cjs.map +1 -0
  137. package/dist/persistence/index.d.cts +347 -0
  138. package/dist/persistence/index.d.ts +347 -0
  139. package/dist/persistence/index.js +676 -0
  140. package/dist/persistence/index.js.map +1 -0
  141. package/dist/registry-BDe-vlv3.d.ts +171 -0
  142. package/dist/registry-D32LpIc4.d.cts +354 -0
  143. package/dist/registry-DnzpgY27.d.cts +171 -0
  144. package/dist/registry-evKTP4ls.d.ts +354 -0
  145. package/dist/schema-DYDGdYL9.d.cts +41 -0
  146. package/dist/schema-DYDGdYL9.d.ts +41 -0
  147. package/dist/serializers/index.cjs +4 -3
  148. package/dist/serializers/index.cjs.map +1 -1
  149. package/dist/serializers/index.d.cts +2 -1
  150. package/dist/serializers/index.d.ts +2 -1
  151. package/dist/serializers/index.js +3 -2
  152. package/dist/sourcemap-C8AH3MBQ.d.cts +91 -0
  153. package/dist/sourcemap-DA1Evhrv.d.ts +91 -0
  154. package/dist/spreadsheet/index.cjs +53 -3
  155. package/dist/spreadsheet/index.cjs.map +1 -1
  156. package/dist/spreadsheet/index.d.cts +247 -18
  157. package/dist/spreadsheet/index.d.ts +247 -18
  158. package/dist/spreadsheet/index.js +58 -8
  159. package/dist/{tokens-CyLZmIei.d.cts → tokens-D7yXvUU6.d.cts} +15 -2
  160. package/dist/{tokens-CyLZmIei.d.ts → tokens-D7yXvUU6.d.ts} +15 -2
  161. package/dist/{track-changes-BSF58RK0.d.cts → track-changes-BK5sVf4_.d.cts} +18 -136
  162. package/dist/{track-changes-BSF58RK0.d.ts → track-changes-CDjCrwKe.d.ts} +18 -136
  163. package/dist/{types-CJ4U-HHI.d.ts → types-DX4Mh4SL.d.cts} +1 -1
  164. package/dist/{types-CJ4U-HHI.d.cts → types-DX4Mh4SL.d.ts} +1 -1
  165. package/dist/types-GT5a5YAX.d.cts +86 -0
  166. package/dist/types-GT5a5YAX.d.ts +86 -0
  167. package/package.json +23 -2
  168. package/dist/chunk-2TWGLC5K.cjs +0 -262
  169. package/dist/chunk-2TWGLC5K.cjs.map +0 -1
  170. package/dist/chunk-4SUNJZWB.cjs.map +0 -1
  171. package/dist/chunk-6M3BCTBD.cjs.map +0 -1
  172. package/dist/chunk-AA4ZEVCC.cjs.map +0 -1
  173. package/dist/chunk-AXV2ZW34.cjs +0 -118
  174. package/dist/chunk-AXV2ZW34.cjs.map +0 -1
  175. package/dist/chunk-B2ZRLN4S.js +0 -118
  176. package/dist/chunk-B2ZRLN4S.js.map +0 -1
  177. package/dist/chunk-DENSCKFC.js.map +0 -1
  178. package/dist/chunk-GVSMRPHB.cjs.map +0 -1
  179. package/dist/chunk-KAADNAPF.js +0 -262
  180. package/dist/chunk-KAADNAPF.js.map +0 -1
  181. package/dist/chunk-MJZBNWG7.js.map +0 -1
  182. package/dist/chunk-OYXSKQFR.js.map +0 -1
  183. package/dist/chunk-QGHGJ56O.js.map +0 -1
  184. package/dist/chunk-RU52I7QO.js.map +0 -1
  185. package/dist/chunk-SAZRENEZ.cjs.map +0 -1
  186. package/dist/types-BZgcDsC5.d.cts +0 -42
  187. package/dist/types-BZgcDsC5.d.ts +0 -42
  188. /package/dist/{chunk-JJDLPEWL.js.map → chunk-3LV6RRPH.js.map} +0 -0
@@ -13,6 +13,13 @@ interface SpreadsheetColumn {
13
13
  binding?: ColumnBinding;
14
14
  formula?: string;
15
15
  format?: CellFormat;
16
+ /**
17
+ * Number format code for the column's cells (e.g. `#,##0.00`,
18
+ * `"$"#,##0.00;[Red]("$"#,##0.00)`, `m/d/yyyy`). Cells without an explicit
19
+ * code of their own use it instead of the automatic one chosen for typed
20
+ * input. See `SpreadsheetController.setColumnNumberFormat`.
21
+ */
22
+ numberFormat?: string;
16
23
  readOnly?: boolean;
17
24
  hidden?: boolean;
18
25
  }
@@ -39,11 +46,30 @@ interface CellRange {
39
46
  }
40
47
  interface CellData {
41
48
  raw: string;
49
+ /**
50
+ * Evaluated value. Typed (non-formula) input is parsed: `"120"` → 120,
51
+ * `"TRUE"` → true, `"3/4/2026"` → `"2026-03-04"` (dates are ISO text),
52
+ * `"10:30"` → 0.4375 (a time alone is a fraction of a day); `'120` forces
53
+ * the text `"120"`. Formulas store their result.
54
+ */
42
55
  value: any;
43
56
  error?: string;
44
57
  /** Why the formula failed, e.g. `Argument 2 of SUMIF must be a range.` Set alongside `error`. */
45
58
  errorMessage?: string;
46
59
  format?: CellFormat;
60
+ /**
61
+ * Excel number format code used to display the value (see
62
+ * `formatCellDisplay`). Set explicitly (`explicitNumberFormat`), inherited
63
+ * from the column's `numberFormat`, or chosen automatically for typed input,
64
+ * e.g. `"$"#,##0.00` for `$1,200.50`, `0%` for `10%`, `#,##0` for `1,234`,
65
+ * `m/d/yyyy` for `3/4/2026`, `h:mm` for `10:30`. Absent for General.
66
+ */
67
+ numberFormat?: string;
68
+ /**
69
+ * True when `numberFormat` was set explicitly (`setCellNumberFormat`):
70
+ * typing into the cell keeps it instead of choosing an automatic format.
71
+ */
72
+ explicitNumberFormat?: boolean;
47
73
  readOnly?: boolean;
48
74
  /**
49
75
  * Set (only) on cells showing a value spilled from a dynamic array: the
@@ -225,14 +251,34 @@ declare class FormulaParser {
225
251
  }
226
252
  declare function parseFormula(formula: string): ASTNode;
227
253
 
228
- /**
229
- * Value helpers shared by the formula evaluator and the built-in functions:
230
- * error values, spreadsheet coercion rules, comparisons, ranges and dates.
231
- */
232
254
  /** Spreadsheet error values. They propagate through operators and functions. */
233
255
  declare const FORMULA_ERRORS: Set<string>;
234
256
  type FormulaErrorCode = '#DIV/0!' | '#VALUE!' | '#REF!' | '#NAME?' | '#N/A' | '#NUM!' | '#CYCLE!' | '#ERROR!' | '#SPILL!' | '#CALC!';
235
257
  declare function isFormulaError(value: unknown): value is string;
258
+ /**
259
+ * Number to text as Excel converts it in `&` and General display: up to 15
260
+ * significant digits, scientific for very large or very small magnitudes.
261
+ */
262
+ declare function numberToText(n: number): string;
263
+ /**
264
+ * Compares numbers the way Excel does: both are rounded to 15 significant
265
+ * digits first, so binary noise such as `0.1+0.2` versus `0.3` counts as equal.
266
+ */
267
+ declare function compareNumbers(a: number, b: number): number;
268
+ /**
269
+ * Excel's comparison for the `=`, `<>`, `<`… operators: numbers < text <
270
+ * booleans < errors, numbers compared at 15 significant digits, text
271
+ * case-insensitively. A blank acts as 0, "" or FALSE depending on the other
272
+ * side. Dates are ISO text: two ISO dates compare chronologically
273
+ * ("2026-1-5" is before "2026-01-10"), and an ISO date against a number
274
+ * compares as its serial number.
275
+ */
276
+ declare function compareValues(left: unknown, right: unknown): number;
277
+ /**
278
+ * Sort order (ascending): numbers, text, booleans, errors, then blanks last.
279
+ * Errors are equal to each other, so sorting keeps their order.
280
+ */
281
+ declare function sortCompareValues(left: unknown, right: unknown): number;
236
282
  declare function colNameToIndex(col: string): number;
237
283
  declare function indexToColName(index: number): string;
238
284
  /**
@@ -483,6 +529,8 @@ declare const SPREADSHEET_CLIPBOARD_MIME = "application/x.pixerate.spreadsheet+j
483
529
  interface SpreadsheetClipboardCell {
484
530
  raw: string;
485
531
  value: unknown;
532
+ /** Display text for `text/plain` and `text/html` (e.g. `10%` for 0.1); defaults to the value as text. Not stored in the JSON payload. */
533
+ text?: string;
486
534
  }
487
535
  interface SpreadsheetClipboardPayload {
488
536
  type: 'pixerate-spreadsheet';
@@ -622,6 +670,12 @@ interface SpreadsheetControllerOptions {
622
670
  onDocumentChange?: (doc: SpreadsheetDocument) => void;
623
671
  onSelectionChange?: (activeCell: CellCoordinate | null, range: CellRange | null) => void;
624
672
  onCellCommit?: (rowId: string, colId: string, raw: string, value: any) => void;
673
+ /**
674
+ * Approximate memory budget for undo/redo snapshots, in bytes (UTF-16 size of
675
+ * the serialized documents). The oldest undo steps beyond it are dropped, but
676
+ * the most recent one is always kept. Defaults to 64 MiB; 0 = unlimited.
677
+ */
678
+ maxHistoryBytes?: number;
625
679
  }
626
680
  declare class SpreadsheetController {
627
681
  document: SpreadsheetDocument;
@@ -639,6 +693,7 @@ declare class SpreadsheetController {
639
693
  private undoStack;
640
694
  private redoStack;
641
695
  private isApplyingHistory;
696
+ private readonly maxHistoryBytes;
642
697
  private batching;
643
698
  private pendingCommits;
644
699
  private evaluatingRowIndex;
@@ -649,6 +704,35 @@ declare class SpreadsheetController {
649
704
  private spillChanges;
650
705
  constructor(options?: SpreadsheetControllerOptions);
651
706
  loadDocument(document: SpreadsheetDocument): void;
707
+ /**
708
+ * Re-parses the value of every stored typed (non-formula) cell from its
709
+ * `raw` input, so documents saved before typed input was parsed (whose
710
+ * values are text such as `"120"`) compare and sort as numbers. Cells of
711
+ * bound columns in record rows keep their value: it belongs to the data
712
+ * source.
713
+ */
714
+ private rederiveTypedValues;
715
+ /**
716
+ * Value of typed (non-formula) input: a number, boolean, ISO date, error
717
+ * or text (see `parseCellInput`), its automatic number format, and the
718
+ * `CellFormat` to use: the automatic one (currency, percentage, date,
719
+ * number) when `format` is unset or `text` (the default of new columns).
720
+ */
721
+ private typedCell;
722
+ /**
723
+ * The number format a cell keeps whatever is typed into it: its explicit
724
+ * one, else its column's. Undefined lets typed input choose one.
725
+ */
726
+ private fixedNumberFormat;
727
+ /** `numberFormat` / `explicitNumberFormat` fields for a formula, bound or spilled cell. */
728
+ private fixedNumberFormatFields;
729
+ /**
730
+ * Typed input for a bound field, coerced by the field's declared type:
731
+ * number, boolean and date fields get a number, boolean or ISO date when
732
+ * the input parses as one; string and enum fields (and unknown fields)
733
+ * keep the text exactly as typed.
734
+ */
735
+ private boundInputValue;
652
736
  registerDataSource(ds: SpreadsheetDataSource): void;
653
737
  setPrimaryDataSource(dataSourceId: string | undefined): void;
654
738
  syncWithDataSource(): void;
@@ -822,6 +906,27 @@ declare class SpreadsheetController {
822
906
  /** Keeps the first `count` columns visible while scrolling. 0 unfreezes. */
823
907
  setFrozenColumnCount(count: number): void;
824
908
  private setTableCount;
909
+ /**
910
+ * Sets an explicit number format code (e.g. `0.00`, `"$"#,##0.00`,
911
+ * `m/d/yyyy`, `[Red]0;[Blue]-0`) on every cell in `range`, including blank
912
+ * cells, so values typed later keep it. `null` removes explicit formats: the
913
+ * cells go back to their column's format or the one chosen for typed input.
914
+ * Undoable as one step. Returns false when there is no range.
915
+ */
916
+ setCellNumberFormat(range: CellRange | null, code: string | null): boolean;
917
+ /**
918
+ * Sets the number format code of a column (`null` or `General` clears it).
919
+ * Its cells without an explicit format of their own use it, including
920
+ * values typed later; when cleared they go back to the format chosen for
921
+ * typed input. Undoable.
922
+ */
923
+ setColumnNumberFormat(colId: string, code: string | null): void;
924
+ /** The column's format, or the one typed input chose (typed cells only). */
925
+ private implicitNumberFormat;
926
+ /** A copy of `cell` with `numberFormat` set, or removed when undefined. */
927
+ private withNumberFormat;
928
+ /** Re-applies the stored cell's (or the column's) format to a spilled value shown there. */
929
+ private refreshSpilledNumberFormat;
825
930
  hideRows(indices: number[]): void;
826
931
  unhideRows(indices: number[]): void;
827
932
  hideColumns(indices: number[]): void;
@@ -878,9 +983,18 @@ declare class SpreadsheetController {
878
983
  */
879
984
  getViewModel(): SpreadsheetViewModel;
880
985
  private recordSnapshot;
986
+ /** Drops the oldest snapshots beyond `maxHistoryBytes`, always keeping the newest. */
987
+ private trimHistory;
988
+ /** Approximate bytes held by the undo/redo snapshots (UTF-16 size). */
989
+ getHistoryByteSize(): number;
990
+ /** Number of undo / redo snapshots currently held. */
991
+ getHistoryDepth(): {
992
+ undo: number;
993
+ redo: number;
994
+ };
881
995
  undo(): void;
882
996
  redo(): void;
883
997
  private notifyChange;
884
998
  }
885
999
 
886
- export { type SpreadsheetDataSource as $, type ASTNode as A, type BinaryOpNode as B, type CellCoordinate as C, DEFAULT_COLUMN_WIDTH as D, type EvaluationContext as E, FORMULA_ERRORS as F, type GroupAggregate as G, type NewFilterRule as H, type PropertyRefNode as I, type RowType as J, SPREADSHEET_CLIPBOARD_MIME as K, type LiteralNode as L, MAX_FORMULA_ARRAY_SIZE as M, type NameNode as N, type SortDirection as O, type ParsedSpreadsheetClipboard as P, type SortKey as Q, type RangeNode as R, SpreadsheetController as S, type SpillRefNode as T, type SpreadsheetCellSpan as U, type SpreadsheetClipboardCell as V, type SpreadsheetClipboardData as W, type SpreadsheetClipboardPayload as X, type SpreadsheetClipboardSource as Y, type SpreadsheetColumn as Z, type SpreadsheetControllerOptions as _, type CellData as a, type SpreadsheetDataSourceField as a0, type SpreadsheetDocument as a1, type SpreadsheetFilterState as a2, type SpreadsheetGrouping as a3, type SpreadsheetRow as a4, type SpreadsheetRowGroup as a5, type SpreadsheetRowSection as a6, type SpreadsheetSpill as a7, type SpreadsheetTableSettings as a8, type SpreadsheetViewColumn as a9, serializeHtmlTable as aA, shiftFormulaReferences as aB, tokenizeFormula as aC, type SpreadsheetViewModel as aa, type SpreadsheetViewRow as ab, type StructuralChange as ac, type UnaryOpNode as ad, WHOLE_COLUMN_END_ROW as ae, buildSpreadsheetView as af, colNameToIndex as ag, columnDependencyKey as ah, computeRowGroups as ai, createSpreadsheetClipboardData as aj, describeFormulaError as ak, extractCellDependencies as al, getRowSection as am, getTableSections as an, indexToColName as ao, isFormulaError as ap, mapFormulaReferences as aq, offsetFormulaReferences as ar, parseCellReference as as, parseFormula as at, parseHtmlTable as au, parseRange as av, readSpreadsheetClipboard as aw, rebaseClipboardRows as ax, remapFormulaReferences as ay, rowPassesFilters as az, type CellDep as b, type CellFormat as c, type CellPosition as d, type CellRange as e, type CellRefNode as f, type CellValueReader as g, type ColumnBinding as h, type ColumnType as i, type CsvExportOptions as j, type CsvImportOptions as k, DEFAULT_ROW_HEIGHT as l, DataSourceBinder as m, DependencyGraph as n, type FilterOperator as o, type FilterRule as p, type FormulaDiagnostic as q, type FormulaErrorCode as r, type FormulaEvaluationResult as s, FormulaEvaluator as t, FormulaParser as u, type FormulaRange as v, type FormulaToken as w, type FormulaTokenType as x, type FunctionCallNode as y, type GroupSummary as z };
1000
+ export { type SpreadsheetDataSource as $, type ASTNode as A, type BinaryOpNode as B, type CellCoordinate as C, DEFAULT_COLUMN_WIDTH as D, type EvaluationContext as E, FORMULA_ERRORS as F, type GroupAggregate as G, type NewFilterRule as H, type PropertyRefNode as I, type RowType as J, SPREADSHEET_CLIPBOARD_MIME as K, type LiteralNode as L, MAX_FORMULA_ARRAY_SIZE as M, type NameNode as N, type SortDirection as O, type ParsedSpreadsheetClipboard as P, type SortKey as Q, type RangeNode as R, SpreadsheetController as S, type SpillRefNode as T, type SpreadsheetCellSpan as U, type SpreadsheetClipboardCell as V, type SpreadsheetClipboardData as W, type SpreadsheetClipboardPayload as X, type SpreadsheetClipboardSource as Y, type SpreadsheetColumn as Z, type SpreadsheetControllerOptions as _, type CellData as a, type SpreadsheetDataSourceField as a0, type SpreadsheetDocument as a1, type SpreadsheetFilterState as a2, type SpreadsheetGrouping as a3, type SpreadsheetRow as a4, type SpreadsheetRowGroup as a5, type SpreadsheetRowSection as a6, type SpreadsheetSpill as a7, type SpreadsheetTableSettings as a8, type SpreadsheetViewColumn as a9, rebaseClipboardRows as aA, remapFormulaReferences as aB, rowPassesFilters as aC, serializeHtmlTable as aD, shiftFormulaReferences as aE, sortCompareValues as aF, tokenizeFormula as aG, type SpreadsheetViewModel as aa, type SpreadsheetViewRow as ab, type StructuralChange as ac, type UnaryOpNode as ad, WHOLE_COLUMN_END_ROW as ae, buildSpreadsheetView as af, colNameToIndex as ag, columnDependencyKey as ah, compareNumbers as ai, compareValues as aj, computeRowGroups as ak, createSpreadsheetClipboardData as al, describeFormulaError as am, extractCellDependencies as an, getRowSection as ao, getTableSections as ap, indexToColName as aq, isFormulaError as ar, mapFormulaReferences as as, numberToText as at, offsetFormulaReferences as au, parseCellReference as av, parseFormula as aw, parseHtmlTable as ax, parseRange as ay, readSpreadsheetClipboard as az, type CellDep as b, type CellFormat as c, type CellPosition as d, type CellRange as e, type CellRefNode as f, type CellValueReader as g, type ColumnBinding as h, type ColumnType as i, type CsvExportOptions as j, type CsvImportOptions as k, DEFAULT_ROW_HEIGHT as l, DataSourceBinder as m, DependencyGraph as n, type FilterOperator as o, type FilterRule as p, type FormulaDiagnostic as q, type FormulaErrorCode as r, type FormulaEvaluationResult as s, FormulaEvaluator as t, FormulaParser as u, type FormulaRange as v, type FormulaToken as w, type FormulaTokenType as x, type FunctionCallNode as y, type GroupSummary as z };
@@ -13,6 +13,13 @@ interface SpreadsheetColumn {
13
13
  binding?: ColumnBinding;
14
14
  formula?: string;
15
15
  format?: CellFormat;
16
+ /**
17
+ * Number format code for the column's cells (e.g. `#,##0.00`,
18
+ * `"$"#,##0.00;[Red]("$"#,##0.00)`, `m/d/yyyy`). Cells without an explicit
19
+ * code of their own use it instead of the automatic one chosen for typed
20
+ * input. See `SpreadsheetController.setColumnNumberFormat`.
21
+ */
22
+ numberFormat?: string;
16
23
  readOnly?: boolean;
17
24
  hidden?: boolean;
18
25
  }
@@ -39,11 +46,30 @@ interface CellRange {
39
46
  }
40
47
  interface CellData {
41
48
  raw: string;
49
+ /**
50
+ * Evaluated value. Typed (non-formula) input is parsed: `"120"` → 120,
51
+ * `"TRUE"` → true, `"3/4/2026"` → `"2026-03-04"` (dates are ISO text),
52
+ * `"10:30"` → 0.4375 (a time alone is a fraction of a day); `'120` forces
53
+ * the text `"120"`. Formulas store their result.
54
+ */
42
55
  value: any;
43
56
  error?: string;
44
57
  /** Why the formula failed, e.g. `Argument 2 of SUMIF must be a range.` Set alongside `error`. */
45
58
  errorMessage?: string;
46
59
  format?: CellFormat;
60
+ /**
61
+ * Excel number format code used to display the value (see
62
+ * `formatCellDisplay`). Set explicitly (`explicitNumberFormat`), inherited
63
+ * from the column's `numberFormat`, or chosen automatically for typed input,
64
+ * e.g. `"$"#,##0.00` for `$1,200.50`, `0%` for `10%`, `#,##0` for `1,234`,
65
+ * `m/d/yyyy` for `3/4/2026`, `h:mm` for `10:30`. Absent for General.
66
+ */
67
+ numberFormat?: string;
68
+ /**
69
+ * True when `numberFormat` was set explicitly (`setCellNumberFormat`):
70
+ * typing into the cell keeps it instead of choosing an automatic format.
71
+ */
72
+ explicitNumberFormat?: boolean;
47
73
  readOnly?: boolean;
48
74
  /**
49
75
  * Set (only) on cells showing a value spilled from a dynamic array: the
@@ -225,14 +251,34 @@ declare class FormulaParser {
225
251
  }
226
252
  declare function parseFormula(formula: string): ASTNode;
227
253
 
228
- /**
229
- * Value helpers shared by the formula evaluator and the built-in functions:
230
- * error values, spreadsheet coercion rules, comparisons, ranges and dates.
231
- */
232
254
  /** Spreadsheet error values. They propagate through operators and functions. */
233
255
  declare const FORMULA_ERRORS: Set<string>;
234
256
  type FormulaErrorCode = '#DIV/0!' | '#VALUE!' | '#REF!' | '#NAME?' | '#N/A' | '#NUM!' | '#CYCLE!' | '#ERROR!' | '#SPILL!' | '#CALC!';
235
257
  declare function isFormulaError(value: unknown): value is string;
258
+ /**
259
+ * Number to text as Excel converts it in `&` and General display: up to 15
260
+ * significant digits, scientific for very large or very small magnitudes.
261
+ */
262
+ declare function numberToText(n: number): string;
263
+ /**
264
+ * Compares numbers the way Excel does: both are rounded to 15 significant
265
+ * digits first, so binary noise such as `0.1+0.2` versus `0.3` counts as equal.
266
+ */
267
+ declare function compareNumbers(a: number, b: number): number;
268
+ /**
269
+ * Excel's comparison for the `=`, `<>`, `<`… operators: numbers < text <
270
+ * booleans < errors, numbers compared at 15 significant digits, text
271
+ * case-insensitively. A blank acts as 0, "" or FALSE depending on the other
272
+ * side. Dates are ISO text: two ISO dates compare chronologically
273
+ * ("2026-1-5" is before "2026-01-10"), and an ISO date against a number
274
+ * compares as its serial number.
275
+ */
276
+ declare function compareValues(left: unknown, right: unknown): number;
277
+ /**
278
+ * Sort order (ascending): numbers, text, booleans, errors, then blanks last.
279
+ * Errors are equal to each other, so sorting keeps their order.
280
+ */
281
+ declare function sortCompareValues(left: unknown, right: unknown): number;
236
282
  declare function colNameToIndex(col: string): number;
237
283
  declare function indexToColName(index: number): string;
238
284
  /**
@@ -483,6 +529,8 @@ declare const SPREADSHEET_CLIPBOARD_MIME = "application/x.pixerate.spreadsheet+j
483
529
  interface SpreadsheetClipboardCell {
484
530
  raw: string;
485
531
  value: unknown;
532
+ /** Display text for `text/plain` and `text/html` (e.g. `10%` for 0.1); defaults to the value as text. Not stored in the JSON payload. */
533
+ text?: string;
486
534
  }
487
535
  interface SpreadsheetClipboardPayload {
488
536
  type: 'pixerate-spreadsheet';
@@ -622,6 +670,12 @@ interface SpreadsheetControllerOptions {
622
670
  onDocumentChange?: (doc: SpreadsheetDocument) => void;
623
671
  onSelectionChange?: (activeCell: CellCoordinate | null, range: CellRange | null) => void;
624
672
  onCellCommit?: (rowId: string, colId: string, raw: string, value: any) => void;
673
+ /**
674
+ * Approximate memory budget for undo/redo snapshots, in bytes (UTF-16 size of
675
+ * the serialized documents). The oldest undo steps beyond it are dropped, but
676
+ * the most recent one is always kept. Defaults to 64 MiB; 0 = unlimited.
677
+ */
678
+ maxHistoryBytes?: number;
625
679
  }
626
680
  declare class SpreadsheetController {
627
681
  document: SpreadsheetDocument;
@@ -639,6 +693,7 @@ declare class SpreadsheetController {
639
693
  private undoStack;
640
694
  private redoStack;
641
695
  private isApplyingHistory;
696
+ private readonly maxHistoryBytes;
642
697
  private batching;
643
698
  private pendingCommits;
644
699
  private evaluatingRowIndex;
@@ -649,6 +704,35 @@ declare class SpreadsheetController {
649
704
  private spillChanges;
650
705
  constructor(options?: SpreadsheetControllerOptions);
651
706
  loadDocument(document: SpreadsheetDocument): void;
707
+ /**
708
+ * Re-parses the value of every stored typed (non-formula) cell from its
709
+ * `raw` input, so documents saved before typed input was parsed (whose
710
+ * values are text such as `"120"`) compare and sort as numbers. Cells of
711
+ * bound columns in record rows keep their value: it belongs to the data
712
+ * source.
713
+ */
714
+ private rederiveTypedValues;
715
+ /**
716
+ * Value of typed (non-formula) input: a number, boolean, ISO date, error
717
+ * or text (see `parseCellInput`), its automatic number format, and the
718
+ * `CellFormat` to use: the automatic one (currency, percentage, date,
719
+ * number) when `format` is unset or `text` (the default of new columns).
720
+ */
721
+ private typedCell;
722
+ /**
723
+ * The number format a cell keeps whatever is typed into it: its explicit
724
+ * one, else its column's. Undefined lets typed input choose one.
725
+ */
726
+ private fixedNumberFormat;
727
+ /** `numberFormat` / `explicitNumberFormat` fields for a formula, bound or spilled cell. */
728
+ private fixedNumberFormatFields;
729
+ /**
730
+ * Typed input for a bound field, coerced by the field's declared type:
731
+ * number, boolean and date fields get a number, boolean or ISO date when
732
+ * the input parses as one; string and enum fields (and unknown fields)
733
+ * keep the text exactly as typed.
734
+ */
735
+ private boundInputValue;
652
736
  registerDataSource(ds: SpreadsheetDataSource): void;
653
737
  setPrimaryDataSource(dataSourceId: string | undefined): void;
654
738
  syncWithDataSource(): void;
@@ -822,6 +906,27 @@ declare class SpreadsheetController {
822
906
  /** Keeps the first `count` columns visible while scrolling. 0 unfreezes. */
823
907
  setFrozenColumnCount(count: number): void;
824
908
  private setTableCount;
909
+ /**
910
+ * Sets an explicit number format code (e.g. `0.00`, `"$"#,##0.00`,
911
+ * `m/d/yyyy`, `[Red]0;[Blue]-0`) on every cell in `range`, including blank
912
+ * cells, so values typed later keep it. `null` removes explicit formats: the
913
+ * cells go back to their column's format or the one chosen for typed input.
914
+ * Undoable as one step. Returns false when there is no range.
915
+ */
916
+ setCellNumberFormat(range: CellRange | null, code: string | null): boolean;
917
+ /**
918
+ * Sets the number format code of a column (`null` or `General` clears it).
919
+ * Its cells without an explicit format of their own use it, including
920
+ * values typed later; when cleared they go back to the format chosen for
921
+ * typed input. Undoable.
922
+ */
923
+ setColumnNumberFormat(colId: string, code: string | null): void;
924
+ /** The column's format, or the one typed input chose (typed cells only). */
925
+ private implicitNumberFormat;
926
+ /** A copy of `cell` with `numberFormat` set, or removed when undefined. */
927
+ private withNumberFormat;
928
+ /** Re-applies the stored cell's (or the column's) format to a spilled value shown there. */
929
+ private refreshSpilledNumberFormat;
825
930
  hideRows(indices: number[]): void;
826
931
  unhideRows(indices: number[]): void;
827
932
  hideColumns(indices: number[]): void;
@@ -878,9 +983,18 @@ declare class SpreadsheetController {
878
983
  */
879
984
  getViewModel(): SpreadsheetViewModel;
880
985
  private recordSnapshot;
986
+ /** Drops the oldest snapshots beyond `maxHistoryBytes`, always keeping the newest. */
987
+ private trimHistory;
988
+ /** Approximate bytes held by the undo/redo snapshots (UTF-16 size). */
989
+ getHistoryByteSize(): number;
990
+ /** Number of undo / redo snapshots currently held. */
991
+ getHistoryDepth(): {
992
+ undo: number;
993
+ redo: number;
994
+ };
881
995
  undo(): void;
882
996
  redo(): void;
883
997
  private notifyChange;
884
998
  }
885
999
 
886
- export { type SpreadsheetDataSource as $, type ASTNode as A, type BinaryOpNode as B, type CellCoordinate as C, DEFAULT_COLUMN_WIDTH as D, type EvaluationContext as E, FORMULA_ERRORS as F, type GroupAggregate as G, type NewFilterRule as H, type PropertyRefNode as I, type RowType as J, SPREADSHEET_CLIPBOARD_MIME as K, type LiteralNode as L, MAX_FORMULA_ARRAY_SIZE as M, type NameNode as N, type SortDirection as O, type ParsedSpreadsheetClipboard as P, type SortKey as Q, type RangeNode as R, SpreadsheetController as S, type SpillRefNode as T, type SpreadsheetCellSpan as U, type SpreadsheetClipboardCell as V, type SpreadsheetClipboardData as W, type SpreadsheetClipboardPayload as X, type SpreadsheetClipboardSource as Y, type SpreadsheetColumn as Z, type SpreadsheetControllerOptions as _, type CellData as a, type SpreadsheetDataSourceField as a0, type SpreadsheetDocument as a1, type SpreadsheetFilterState as a2, type SpreadsheetGrouping as a3, type SpreadsheetRow as a4, type SpreadsheetRowGroup as a5, type SpreadsheetRowSection as a6, type SpreadsheetSpill as a7, type SpreadsheetTableSettings as a8, type SpreadsheetViewColumn as a9, serializeHtmlTable as aA, shiftFormulaReferences as aB, tokenizeFormula as aC, type SpreadsheetViewModel as aa, type SpreadsheetViewRow as ab, type StructuralChange as ac, type UnaryOpNode as ad, WHOLE_COLUMN_END_ROW as ae, buildSpreadsheetView as af, colNameToIndex as ag, columnDependencyKey as ah, computeRowGroups as ai, createSpreadsheetClipboardData as aj, describeFormulaError as ak, extractCellDependencies as al, getRowSection as am, getTableSections as an, indexToColName as ao, isFormulaError as ap, mapFormulaReferences as aq, offsetFormulaReferences as ar, parseCellReference as as, parseFormula as at, parseHtmlTable as au, parseRange as av, readSpreadsheetClipboard as aw, rebaseClipboardRows as ax, remapFormulaReferences as ay, rowPassesFilters as az, type CellDep as b, type CellFormat as c, type CellPosition as d, type CellRange as e, type CellRefNode as f, type CellValueReader as g, type ColumnBinding as h, type ColumnType as i, type CsvExportOptions as j, type CsvImportOptions as k, DEFAULT_ROW_HEIGHT as l, DataSourceBinder as m, DependencyGraph as n, type FilterOperator as o, type FilterRule as p, type FormulaDiagnostic as q, type FormulaErrorCode as r, type FormulaEvaluationResult as s, FormulaEvaluator as t, FormulaParser as u, type FormulaRange as v, type FormulaToken as w, type FormulaTokenType as x, type FunctionCallNode as y, type GroupSummary as z };
1000
+ export { type SpreadsheetDataSource as $, type ASTNode as A, type BinaryOpNode as B, type CellCoordinate as C, DEFAULT_COLUMN_WIDTH as D, type EvaluationContext as E, FORMULA_ERRORS as F, type GroupAggregate as G, type NewFilterRule as H, type PropertyRefNode as I, type RowType as J, SPREADSHEET_CLIPBOARD_MIME as K, type LiteralNode as L, MAX_FORMULA_ARRAY_SIZE as M, type NameNode as N, type SortDirection as O, type ParsedSpreadsheetClipboard as P, type SortKey as Q, type RangeNode as R, SpreadsheetController as S, type SpillRefNode as T, type SpreadsheetCellSpan as U, type SpreadsheetClipboardCell as V, type SpreadsheetClipboardData as W, type SpreadsheetClipboardPayload as X, type SpreadsheetClipboardSource as Y, type SpreadsheetColumn as Z, type SpreadsheetControllerOptions as _, type CellData as a, type SpreadsheetDataSourceField as a0, type SpreadsheetDocument as a1, type SpreadsheetFilterState as a2, type SpreadsheetGrouping as a3, type SpreadsheetRow as a4, type SpreadsheetRowGroup as a5, type SpreadsheetRowSection as a6, type SpreadsheetSpill as a7, type SpreadsheetTableSettings as a8, type SpreadsheetViewColumn as a9, rebaseClipboardRows as aA, remapFormulaReferences as aB, rowPassesFilters as aC, serializeHtmlTable as aD, shiftFormulaReferences as aE, sortCompareValues as aF, tokenizeFormula as aG, type SpreadsheetViewModel as aa, type SpreadsheetViewRow as ab, type StructuralChange as ac, type UnaryOpNode as ad, WHOLE_COLUMN_END_ROW as ae, buildSpreadsheetView as af, colNameToIndex as ag, columnDependencyKey as ah, compareNumbers as ai, compareValues as aj, computeRowGroups as ak, createSpreadsheetClipboardData as al, describeFormulaError as am, extractCellDependencies as an, getRowSection as ao, getTableSections as ap, indexToColName as aq, isFormulaError as ar, mapFormulaReferences as as, numberToText as at, offsetFormulaReferences as au, parseCellReference as av, parseFormula as aw, parseHtmlTable as ax, parseRange as ay, readSpreadsheetClipboard as az, type CellDep as b, type CellFormat as c, type CellPosition as d, type CellRange as e, type CellRefNode as f, type CellValueReader as g, type ColumnBinding as h, type ColumnType as i, type CsvExportOptions as j, type CsvImportOptions as k, DEFAULT_ROW_HEIGHT as l, DataSourceBinder as m, DependencyGraph as n, type FilterOperator as o, type FilterRule as p, type FormulaDiagnostic as q, type FormulaErrorCode as r, type FormulaEvaluationResult as s, FormulaEvaluator as t, FormulaParser as u, type FormulaRange as v, type FormulaToken as w, type FormulaTokenType as x, type FunctionCallNode as y, type GroupSummary as z };
@@ -0,0 +1,76 @@
1
+ import { Node, Schema } from '@tiptap/pm/model';
2
+ import { R as ReviewAuthor } from './comment-store-BEMgVlAA.js';
3
+
4
+ /** A document to compare: a ProseMirror node, its JSON, or HTML (needs a DOM). */
5
+ type CompareSource = Node | Record<string, any> | string;
6
+ interface CompareDocumentsOptions {
7
+ /** Schema of the documents. Required unless both sources are ProseMirror nodes. */
8
+ schema?: Schema;
9
+ /** Author recorded on every change. Default `{ id: "compare", name: "Compare" }`. */
10
+ author?: ReviewAuthor;
11
+ /** Time recorded on every change (`createdAt`). Default now. */
12
+ date?: number | Date | string;
13
+ /** Compare changed paragraphs word by word (default) or character by character. */
14
+ granularity?: "word" | "char";
15
+ /** Treat text differing only in case as equal (the revised text is kept). */
16
+ ignoreCase?: boolean;
17
+ /** Treat runs of white space as equal (the revised text is kept). */
18
+ ignoreWhitespace?: boolean;
19
+ /** Record formatting differences of equal text as `formatChange` marks. Default `true`. */
20
+ formatting?: boolean;
21
+ /** Change id generator. */
22
+ generateId?: () => string;
23
+ /** Marks not compared as formatting (in addition to review marks, comments and bookmarks). */
24
+ ignoredMarks?: string[];
25
+ /** Node attributes ignored when comparing blocks. Default `["id"]`. */
26
+ ignoredBlockAttributes?: string[];
27
+ /**
28
+ * Paragraphs longer than this (in characters) are compared by words even
29
+ * at `granularity: "char"`. Default 2000.
30
+ */
31
+ maxCharDiff?: number;
32
+ }
33
+ interface CompareSummary {
34
+ /** Inserted text runs and inserted block runs. */
35
+ insertions: number;
36
+ /** Deleted text runs and deleted block runs. */
37
+ deletions: number;
38
+ /** Formatting changes of equal text. */
39
+ formatChanges: number;
40
+ /** Block type, attribute and wrapping changes. */
41
+ blockChanges: number;
42
+ /** Differences the result could not represent as tracked changes. */
43
+ notHonoured: string[];
44
+ }
45
+ interface CompareDocumentsResult {
46
+ /**
47
+ * The revised document with the differences as tracked changes: accepting
48
+ * all changes yields the revised document, rejecting all the original.
49
+ */
50
+ doc: Node;
51
+ summary: CompareSummary;
52
+ }
53
+ /**
54
+ * Compares two documents and returns the revised document with the
55
+ * differences as tracked changes (`insertion`/`deletion`/`formatChange`
56
+ * marks and `blockChange` records), plus a summary.
57
+ *
58
+ * Blocks are matched by their text (Myers diff with patience anchors); in a
59
+ * run of changed blocks the i-th deleted block is paired with the i-th
60
+ * inserted one and compared word by word (or by character), while unpaired
61
+ * blocks are recorded as whole-block insertions/deletions. Equal text is
62
+ * compared for formatting, and type/attribute/wrapping changes become
63
+ * `blockChange` records. Without ignore options, accepting all changes
64
+ * yields the revised document and rejecting all yields the original.
65
+ *
66
+ * The schema needs the `TrackChanges` extension (marks and the
67
+ * `blockChange` attribute). Existing tracked changes in either document are
68
+ * accepted first.
69
+ */
70
+ declare function compareDocuments(original: CompareSource, revised: CompareSource, options?: CompareDocumentsOptions): CompareDocumentsResult;
71
+ /** `compareDocuments` for two HTML strings (needs a DOM, like `setContent`). */
72
+ declare function compareHtml(originalHtml: string, revisedHtml: string, options: CompareDocumentsOptions & {
73
+ schema: Schema;
74
+ }): CompareDocumentsResult;
75
+
76
+ export { type CompareDocumentsOptions as C, type CompareDocumentsResult as a, type CompareSource as b, type CompareSummary as c, compareDocuments as d, compareHtml as e };
@@ -0,0 +1,76 @@
1
+ import { Node, Schema } from '@tiptap/pm/model';
2
+ import { R as ReviewAuthor } from './comment-store-BEMgVlAA.cjs';
3
+
4
+ /** A document to compare: a ProseMirror node, its JSON, or HTML (needs a DOM). */
5
+ type CompareSource = Node | Record<string, any> | string;
6
+ interface CompareDocumentsOptions {
7
+ /** Schema of the documents. Required unless both sources are ProseMirror nodes. */
8
+ schema?: Schema;
9
+ /** Author recorded on every change. Default `{ id: "compare", name: "Compare" }`. */
10
+ author?: ReviewAuthor;
11
+ /** Time recorded on every change (`createdAt`). Default now. */
12
+ date?: number | Date | string;
13
+ /** Compare changed paragraphs word by word (default) or character by character. */
14
+ granularity?: "word" | "char";
15
+ /** Treat text differing only in case as equal (the revised text is kept). */
16
+ ignoreCase?: boolean;
17
+ /** Treat runs of white space as equal (the revised text is kept). */
18
+ ignoreWhitespace?: boolean;
19
+ /** Record formatting differences of equal text as `formatChange` marks. Default `true`. */
20
+ formatting?: boolean;
21
+ /** Change id generator. */
22
+ generateId?: () => string;
23
+ /** Marks not compared as formatting (in addition to review marks, comments and bookmarks). */
24
+ ignoredMarks?: string[];
25
+ /** Node attributes ignored when comparing blocks. Default `["id"]`. */
26
+ ignoredBlockAttributes?: string[];
27
+ /**
28
+ * Paragraphs longer than this (in characters) are compared by words even
29
+ * at `granularity: "char"`. Default 2000.
30
+ */
31
+ maxCharDiff?: number;
32
+ }
33
+ interface CompareSummary {
34
+ /** Inserted text runs and inserted block runs. */
35
+ insertions: number;
36
+ /** Deleted text runs and deleted block runs. */
37
+ deletions: number;
38
+ /** Formatting changes of equal text. */
39
+ formatChanges: number;
40
+ /** Block type, attribute and wrapping changes. */
41
+ blockChanges: number;
42
+ /** Differences the result could not represent as tracked changes. */
43
+ notHonoured: string[];
44
+ }
45
+ interface CompareDocumentsResult {
46
+ /**
47
+ * The revised document with the differences as tracked changes: accepting
48
+ * all changes yields the revised document, rejecting all the original.
49
+ */
50
+ doc: Node;
51
+ summary: CompareSummary;
52
+ }
53
+ /**
54
+ * Compares two documents and returns the revised document with the
55
+ * differences as tracked changes (`insertion`/`deletion`/`formatChange`
56
+ * marks and `blockChange` records), plus a summary.
57
+ *
58
+ * Blocks are matched by their text (Myers diff with patience anchors); in a
59
+ * run of changed blocks the i-th deleted block is paired with the i-th
60
+ * inserted one and compared word by word (or by character), while unpaired
61
+ * blocks are recorded as whole-block insertions/deletions. Equal text is
62
+ * compared for formatting, and type/attribute/wrapping changes become
63
+ * `blockChange` records. Without ignore options, accepting all changes
64
+ * yields the revised document and rejecting all yields the original.
65
+ *
66
+ * The schema needs the `TrackChanges` extension (marks and the
67
+ * `blockChange` attribute). Existing tracked changes in either document are
68
+ * accepted first.
69
+ */
70
+ declare function compareDocuments(original: CompareSource, revised: CompareSource, options?: CompareDocumentsOptions): CompareDocumentsResult;
71
+ /** `compareDocuments` for two HTML strings (needs a DOM, like `setContent`). */
72
+ declare function compareHtml(originalHtml: string, revisedHtml: string, options: CompareDocumentsOptions & {
73
+ schema: Schema;
74
+ }): CompareDocumentsResult;
75
+
76
+ export { type CompareDocumentsOptions as C, type CompareDocumentsResult as a, type CompareSource as b, type CompareSummary as c, compareDocuments as d, compareHtml as e };