@guiexpert/table 1.1.98 → 1.1.99

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 (99) hide show
  1. package/README.md +9 -0
  2. package/css/main.css +296 -0
  3. package/css/table-clipboard.css +41 -0
  4. package/css/table-color-vars.css +56 -0
  5. package/css/table-sheet-editing.css +149 -0
  6. package/css/table-spreadsheet.css +50 -0
  7. package/index.cjs +46 -59
  8. package/index.d.ts +46 -0
  9. package/index.js +18934 -11624
  10. package/lib/table/action/action-id.type.d.ts +1 -1
  11. package/lib/table/action/shortcut.service.d.ts +9 -0
  12. package/lib/table/aria/aria-texts.d.ts +26 -0
  13. package/lib/table/aria/aria-texts.if.d.ts +196 -0
  14. package/lib/table/batch-edit/batch-edit-service.d.ts +22 -0
  15. package/lib/table/batch-edit/cell-change.if.d.ts +6 -2
  16. package/lib/table/batch-edit/pending-cell-changes.d.ts +7 -0
  17. package/lib/table/batch-edit/write-row-value.d.ts +14 -0
  18. package/lib/table/calc/column-values.d.ts +2 -0
  19. package/lib/table/clipboard/clipboard-html.d.ts +41 -0
  20. package/lib/table/clipboard/clipboard-keymap.d.ts +18 -0
  21. package/lib/table/clipboard/clipboard-options.d.ts +30 -0
  22. package/lib/table/clipboard/clipboard-options.if.d.ts +67 -0
  23. package/lib/table/clipboard/clipboard-service.d.ts +122 -0
  24. package/lib/table/clipboard/input-pipes.d.ts +59 -0
  25. package/lib/table/clipboard/paste-plan.d.ts +96 -0
  26. package/lib/table/clipboard/tsv.d.ts +31 -0
  27. package/lib/table/data/common/event/ge-edit-event.d.ts +46 -0
  28. package/lib/table/data/common/event/ge-row-drag-event.d.ts +2 -2
  29. package/lib/table/data/common/event/ge-undo-event.d.ts +29 -0
  30. package/lib/table/data/options/table-options.d.ts +28 -0
  31. package/lib/table/data/options/table-options.if.d.ts +99 -1
  32. package/lib/table/data/tablemodel/areamodel/abstract-area-model.d.ts +11 -2
  33. package/lib/table/data/tablemodel/areamodel/area-model-array-of-arrays.d.ts +14 -0
  34. package/lib/table/data/tablemodel/areamodel/area-model-object-array.d.ts +14 -0
  35. package/lib/table/data/tablemodel/areamodel/area-model.if.d.ts +11 -0
  36. package/lib/table/data/tablemodel/column/column-def.d.ts +13 -0
  37. package/lib/table/data/tablemodel/column/column-def.if.d.ts +36 -1
  38. package/lib/table/data/tablemodel/column/default-editable.d.ts +18 -0
  39. package/lib/table/event-adapter.d.ts +6 -0
  40. package/lib/table/event-listener-hub.d.ts +10 -0
  41. package/lib/table/event-listener.if.d.ts +16 -0
  42. package/lib/table/factory/pivot-factory.d.ts +1 -1
  43. package/lib/table/factory/row-group-factory.d.ts +1 -1
  44. package/lib/table/factory/table-factory.d.ts +14 -0
  45. package/lib/table/formula/formula-ast.if.d.ts +32 -2
  46. package/lib/table/formula/formula-error.d.ts +4 -2
  47. package/lib/table/formula/parser.d.ts +5 -2
  48. package/lib/table/formula/tokenizer.d.ts +5 -2
  49. package/lib/table/input-handler.d.ts +8 -0
  50. package/lib/table/master-detail/master-detail-service.d.ts +9 -0
  51. package/lib/table/render-scope.d.ts +40 -0
  52. package/lib/table/row-drag/row-drag-service.d.ts +3 -2
  53. package/lib/table/selection/selection-service.d.ts +48 -0
  54. package/lib/table/service/excel-export-options.if.d.ts +6 -0
  55. package/lib/table/service/excel-service.d.ts +4 -0
  56. package/lib/table/service/excel-service.if.d.ts +35 -0
  57. package/lib/table/sheet/cell-address.d.ts +100 -0
  58. package/lib/table/sheet/cell-formula-options.d.ts +27 -0
  59. package/lib/table/sheet/cell-formula-options.if.d.ts +27 -0
  60. package/lib/table/sheet/excel-formula.d.ts +20 -0
  61. package/lib/table/sheet/format-formula.d.ts +19 -0
  62. package/lib/table/sheet/sheet-cells.if.d.ts +17 -0
  63. package/lib/table/sheet/sheet-compiler.d.ts +47 -0
  64. package/lib/table/sheet/sheet-engine.d.ts +207 -0
  65. package/lib/table/sheet/sheet-function-info.d.ts +25 -0
  66. package/lib/table/sheet/sheet-functions.d.ts +27 -0
  67. package/lib/table/sheet/sheet-values.d.ts +154 -0
  68. package/lib/table/sheet/shift-formula.d.ts +71 -0
  69. package/lib/table/sheet/table-sheet.d.ts +214 -0
  70. package/lib/table/sheet-editing/cell-editor-service.d.ts +105 -0
  71. package/lib/table/sheet-editing/cell-editor.if.d.ts +110 -0
  72. package/lib/table/sheet-editing/editing-keymap.d.ts +17 -0
  73. package/lib/table/sheet-editing/editing-options.d.ts +34 -0
  74. package/lib/table/sheet-editing/editing-options.if.d.ts +49 -0
  75. package/lib/table/sheet-editing/editors/date-cell-editor.d.ts +23 -0
  76. package/lib/table/sheet-editing/editors/number-cell-editor.d.ts +18 -0
  77. package/lib/table/sheet-editing/editors/select-cell-editor.d.ts +36 -0
  78. package/lib/table/sheet-editing/editors/text-cell-editor.d.ts +35 -0
  79. package/lib/table/sheet-editing/formula-assist.d.ts +103 -0
  80. package/lib/table/sheet-editing/formula-text.d.ts +61 -0
  81. package/lib/table/sheet-editing/sheet-navigation.d.ts +26 -0
  82. package/lib/table/spreadsheet/area-model-sheet.d.ts +170 -0
  83. package/lib/table/spreadsheet/formula-bar.d.ts +53 -0
  84. package/lib/table/spreadsheet/spreadsheet-factory.d.ts +111 -0
  85. package/lib/table/spreadsheet/spreadsheet-options.if.d.ts +28 -0
  86. package/lib/table/spreadsheet/spreadsheet-preset.d.ts +37 -0
  87. package/lib/table/spreadsheet/structure-edit.d.ts +35 -0
  88. package/lib/table/table-api.d.ts +511 -2
  89. package/lib/table/table-scope.d.ts +294 -1
  90. package/lib/table/undo/cell-changes-undoable.d.ts +34 -0
  91. package/lib/table/undo/model-rows.d.ts +17 -0
  92. package/lib/table/undo/pending-changes-undoable.d.ts +35 -0
  93. package/lib/table/undo/undo-keymap.d.ts +17 -0
  94. package/lib/table/undo/undo-options.d.ts +26 -0
  95. package/lib/table/undo/undo-options.if.d.ts +30 -0
  96. package/lib/table/undo/undo-service.d.ts +103 -0
  97. package/lib/table/undo/undo-stack.d.ts +62 -0
  98. package/lib/table/undo/undoable.if.d.ts +36 -0
  99. package/package.json +1 -1
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @category Keyboard
7
7
  */
8
- export declare const actionIds: readonly ["COPY_2_CLIPBOARD", "START_EDITING", "TOGGLE_SELECTION", "SELECT_ALL", "DESELECT_ALL", "NAVIGATE_LEFT", "NAVIGATE_RIGHT", "NAVIGATE_UP", "NAVIGATE_DOWN", "NAVIGATE_ROW_START", "NAVIGATE_ROW_END", "NAVIGATE_FIRST_CELL", "NAVIGATE_LAST_CELL", "NAVIGATE_PAGE_UP", "NAVIGATE_PAGE_DOWN", "ACTIVATE_CELL", "MOVE_ROW_UP", "MOVE_ROW_DOWN", "FILL_DOWN", "FILL_RIGHT"];
8
+ export declare const actionIds: readonly ["COPY_2_CLIPBOARD", "START_EDITING", "TOGGLE_SELECTION", "SELECT_ALL", "DESELECT_ALL", "NAVIGATE_LEFT", "NAVIGATE_RIGHT", "NAVIGATE_UP", "NAVIGATE_DOWN", "NAVIGATE_ROW_START", "NAVIGATE_ROW_END", "NAVIGATE_FIRST_CELL", "NAVIGATE_LAST_CELL", "NAVIGATE_PAGE_UP", "NAVIGATE_PAGE_DOWN", "ACTIVATE_CELL", "MOVE_ROW_UP", "MOVE_ROW_DOWN", "FILL_DOWN", "FILL_RIGHT", "NAVIGATE_NEXT_CELL", "NAVIGATE_PREVIOUS_CELL", "EXTEND_SELECTION_UP", "EXTEND_SELECTION_DOWN", "EXTEND_SELECTION_LEFT", "EXTEND_SELECTION_RIGHT", "EXTEND_SELECTION_ROW_START", "EXTEND_SELECTION_ROW_END", "EXTEND_SELECTION_PAGE_UP", "EXTEND_SELECTION_PAGE_DOWN", "NAVIGATE_DATA_EDGE_UP", "NAVIGATE_DATA_EDGE_DOWN", "NAVIGATE_DATA_EDGE_LEFT", "NAVIGATE_DATA_EDGE_RIGHT", "EXTEND_TO_DATA_EDGE_UP", "EXTEND_TO_DATA_EDGE_DOWN", "EXTEND_TO_DATA_EDGE_LEFT", "EXTEND_TO_DATA_EDGE_RIGHT", "SELECT_ROW", "SELECT_COLUMN", "CLEAR_CELLS", "CLEAR_AND_EDIT", "CUT_2_CLIPBOARD", "PASTE_FROM_CLIPBOARD", "UNDO", "REDO"];
9
9
  /**
10
10
  * Represents an action ID.
11
11
  *
@@ -9,6 +9,10 @@ import { OnActionTriggeredIf } from './on-action-triggered.if.js';
9
9
  */
10
10
  export declare class ShortcutService {
11
11
  protected tableScope: TableScope;
12
+ /**
13
+ * The mapping as written: system, feature layers, then the app's mapping – one entry per key (a later spelling of
14
+ * the same key replaces the earlier one). See {@link getShortcutActionMapping}.
15
+ */
12
16
  private shortcutActionIdMapping;
13
17
  private listener;
14
18
  constructor(tableScope: TableScope);
@@ -25,6 +29,11 @@ export declare class ShortcutService {
25
29
  */
26
30
  init(): void;
27
31
  private assignPredefinedSystemShortcutMappings;
32
+ /**
33
+ * Adds a mapping under harmonized keys: a later mapping replaces an earlier one even if it spells the key
34
+ * differently ("meta+arrowleft" replaces "meta+left"; before 1.1.99 the first spelling silently won).
35
+ */
36
+ private assignMapping;
28
37
  private isMacintosh;
29
38
  private isDebug;
30
39
  private isLocalhost;
@@ -44,4 +44,30 @@ export declare class AriaTexts implements AriaTextsIf {
44
44
  changesDiscarded(): string;
45
45
  commitBlocked(invalidCount: number): string;
46
46
  invalidValue(message: string): string;
47
+ editingStarted(columnLabel: string): string;
48
+ readOnlyCell(): string;
49
+ cellsCleared(cellCount: number): string;
50
+ clearTooLarge(maxCells: number): string;
51
+ rangeSelected(rowCount: number, columnCount: number): string;
52
+ rowSelected(rowCount: number): string;
53
+ columnSelected(columnCount: number): string;
54
+ gridEditingHint(): string;
55
+ cellsPasted(cellCount: number, skippedCount: number): string;
56
+ pasteTooLarge(maxCells: number): string;
57
+ copyTooLarge(maxCells: number): string;
58
+ cutMarked(cellCount: number): string;
59
+ copiedLastRangeOnly(): string;
60
+ undone(label: string, cellCount: number): string;
61
+ redone(label: string, cellCount: number): string;
62
+ nothingToUndo(): string;
63
+ nothingToRedo(): string;
64
+ undoSkipped(cellCount: number): string;
65
+ undoHistoryCleared(maxCells: number): string;
66
+ formulaError(message: string): string;
67
+ functionSuggestions(): string;
68
+ referenceInserted(reference: string): string;
69
+ rowsInserted(count: number): string;
70
+ rowsDeleted(count: number): string;
71
+ columnsInserted(count: number): string;
72
+ columnsDeleted(count: number): string;
47
73
  }
@@ -186,4 +186,200 @@ export interface AriaTextsIf {
186
186
  * @since 1.1.97
187
187
  */
188
188
  detailCollapsed?(): string;
189
+ /**
190
+ * Announced when the cell editor opens (Excel-style editing).
191
+ *
192
+ * @param {string} columnLabel - the column label
193
+ * @returns {string} default: `"Editing Price"`
194
+ * @since 1.1.99
195
+ */
196
+ editingStarted?(columnLabel: string): string;
197
+ /**
198
+ * Announced when a key is typed on a cell that cannot be edited (Excel-style editing).
199
+ *
200
+ * @returns {string} default: `"Read only"`
201
+ * @since 1.1.99
202
+ */
203
+ readOnlyCell?(): string;
204
+ /**
205
+ * Announced after Delete/Backspace cleared cells.
206
+ *
207
+ * @param {number} cellCount - the number of cleared cells
208
+ * @returns {string} default: `"8 cells cleared"`
209
+ * @since 1.1.99
210
+ */
211
+ cellsCleared?(cellCount: number): string;
212
+ /**
213
+ * Announced when more cells should be cleared than `EditingOptionsIf.maxClearCells` allows.
214
+ *
215
+ * @param {number} maxCells - the limit
216
+ * @returns {string} default: `"Too many cells to clear (at most 1000000)"`
217
+ * @since 1.1.99
218
+ */
219
+ clearTooLarge?(maxCells: number): string;
220
+ /**
221
+ * Announced when Shift+arrows change the selected range (the focus stays on the active cell).
222
+ *
223
+ * @param {number} rowCount - rows of the range
224
+ * @param {number} columnCount - shown columns of the range
225
+ * @returns {string} default: `"3 rows, 2 columns selected"`
226
+ * @since 1.1.99
227
+ */
228
+ rangeSelected?(rowCount: number, columnCount: number): string;
229
+ /**
230
+ * Announced after Shift+Space selected the rows of the active cell.
231
+ *
232
+ * @param {number} rowCount - number of selected rows
233
+ * @returns {string} default: `"Row selected"`
234
+ * @since 1.1.99
235
+ */
236
+ rowSelected?(rowCount: number): string;
237
+ /**
238
+ * Announced after Ctrl+Space selected the columns of the active cell.
239
+ *
240
+ * @param {number} columnCount - number of selected columns
241
+ * @returns {string} default: `"Column selected"`
242
+ * @since 1.1.99
243
+ */
244
+ columnSelected?(columnCount: number): string;
245
+ /**
246
+ * The description of the grid with Excel-style editing (`aria-description` of the host): how it is used.
247
+ *
248
+ * @returns {string} default: `"Type to edit a cell, Enter to edit or commit, Escape to cancel. Tab in the last column leaves the table."`
249
+ * @since 1.1.99
250
+ */
251
+ gridEditingHint?(): string;
252
+ /**
253
+ * Announced after Ctrl/⌘+V (copy, cut and paste, `tableOptions.clipboard`).
254
+ *
255
+ * @param {number} cellCount - the number of pasted cells
256
+ * @param {number} skippedCount - cells left out (read only, invalid, cut off at the last column)
257
+ * @returns {string} default: `"6 cells pasted"`, `"4 cells pasted, 2 skipped"`
258
+ * @since 1.1.99
259
+ */
260
+ cellsPasted?(cellCount: number, skippedCount: number): string;
261
+ /**
262
+ * Announced when more cells should be pasted than `ClipboardOptionsIf.maxPasteCells` allows.
263
+ *
264
+ * @param {number} maxCells - the limit
265
+ * @returns {string} default: `"Too many cells to paste (at most 1000000)"`
266
+ * @since 1.1.99
267
+ */
268
+ pasteTooLarge?(maxCells: number): string;
269
+ /**
270
+ * Announced when more cells should be copied than `CopyService.maxCopyCells` allows.
271
+ *
272
+ * @param {number} maxCells - the limit
273
+ * @returns {string} default: `"Too many cells to copy (at most 1000000)"`
274
+ * @since 1.1.99
275
+ */
276
+ copyTooLarge?(maxCells: number): string;
277
+ /**
278
+ * Announced after Ctrl/⌘+X: the cells are marked and move on the next paste.
279
+ *
280
+ * @param {number} cellCount - the number of cut cells
281
+ * @returns {string} default: `"6 cells cut, paste to move them"`
282
+ * @since 1.1.99
283
+ */
284
+ cutMarked?(cellCount: number): string;
285
+ /**
286
+ * Announced when several ranges are selected and only the last one is copied (like Google Sheets).
287
+ *
288
+ * @returns {string} default: `"Only the last selected range was copied"`
289
+ * @since 1.1.99
290
+ */
291
+ copiedLastRangeOnly?(): string;
292
+ /**
293
+ * Announced after Ctrl/⌘+Z (undo and redo, `tableOptions.undo`).
294
+ *
295
+ * @param {string} label - the step: `"Edit"`, `"Paste"`, `"Fill"` …
296
+ * @param {number} cellCount - cells written back
297
+ * @returns {string} default: `"Undo Paste, 6 cells"`
298
+ * @since 1.1.99
299
+ */
300
+ undone?(label: string, cellCount: number): string;
301
+ /**
302
+ * Announced after Ctrl+Y / Ctrl/⌘+Shift+Z.
303
+ *
304
+ * @param {string} label - the step
305
+ * @param {number} cellCount - cells written again
306
+ * @returns {string} default: `"Redo Paste, 6 cells"`
307
+ * @since 1.1.99
308
+ */
309
+ redone?(label: string, cellCount: number): string;
310
+ /** @returns {string} default: `"Nothing to undo"` @since 1.1.99 */
311
+ nothingToUndo?(): string;
312
+ /** @returns {string} default: `"Nothing to redo"` @since 1.1.99 */
313
+ nothingToRedo?(): string;
314
+ /**
315
+ * Added to the undo/redo announcement when cells were left out (changed meanwhile, row gone, read only).
316
+ *
317
+ * @param {number} cellCount - cells left out
318
+ * @returns {string} default: `"2 cells skipped"`
319
+ * @since 1.1.99
320
+ */
321
+ undoSkipped?(cellCount: number): string;
322
+ /**
323
+ * Announced when one change has more cells than `UndoOptionsIf.maxCells`: the history is emptied.
324
+ *
325
+ * @param {number} maxCells - the limit
326
+ * @returns {string} default: `"This change cannot be undone (more than 1000000 cells)"`
327
+ * @since 1.1.99
328
+ */
329
+ undoHistoryCleared?(maxCells: number): string;
330
+ /**
331
+ * Announced when a cell formula with a syntax error is stored (it shows `#ERROR!`, `tableOptions.cellFormulas`).
332
+ *
333
+ * @param {string} message - the parser's message
334
+ * @returns {string} default: `"Formula error: <message>"`
335
+ * @since 1.1.99
336
+ */
337
+ formulaError?(message: string): string;
338
+ /**
339
+ * The label of the list of function suggestions while a cell formula is typed.
340
+ *
341
+ * @returns {string} default: `"Functions"`
342
+ * @since 1.1.99
343
+ */
344
+ functionSuggestions?(): string;
345
+ /**
346
+ * Announced when a reference is inserted by pointing (arrow keys or a click while typing a formula).
347
+ *
348
+ * @param {string} reference - e.g. `"B2"` or `"B2:B4"`
349
+ * @returns {string} default: the reference
350
+ * @since 1.1.99
351
+ */
352
+ referenceInserted?(reference: string): string;
353
+ /**
354
+ * Announced after rows were inserted (`TableApi.insertRows`).
355
+ *
356
+ * @param {number} count - the rows
357
+ * @returns {string} default: `"3 rows inserted"`
358
+ * @since 1.1.99
359
+ */
360
+ rowsInserted?(count: number): string;
361
+ /**
362
+ * Announced after rows were deleted (`TableApi.deleteRows`).
363
+ *
364
+ * @param {number} count - the rows
365
+ * @returns {string} default: `"3 rows deleted"`
366
+ * @since 1.1.99
367
+ */
368
+ rowsDeleted?(count: number): string;
369
+ /**
370
+ * Announced after columns were inserted (`TableApi.insertColumns`).
371
+ *
372
+ * @param {number} count - the columns
373
+ * @returns {string} default: `"2 columns inserted"`
374
+ * @since 1.1.99
375
+ */
376
+ columnsInserted?(count: number): string;
377
+ /**
378
+ * Announced after columns were deleted (`TableApi.deleteColumns`).
379
+ *
380
+ * @param {number} count - the columns
381
+ * @returns {string} default: `"2 columns deleted"`
382
+ * @since 1.1.99
383
+ */
384
+ columnsDeleted?(count: number): string;
189
385
  }
@@ -70,6 +70,28 @@ export declare class BatchEditService {
70
70
  * @returns {CellChangeIf[]} the cells whose pending state changed
71
71
  */
72
72
  addPending(inputs: PendingInputIf[]): CellChangeIf[];
73
+ /**
74
+ * The pending entry of a cell by row key and property (undo of a batch edit step).
75
+ *
76
+ * @param {unknown} rowKey - row object (index for models without objects)
77
+ * @param {string} property - the property of the column
78
+ * @returns {PendingCellIf | undefined} the entry
79
+ * @since 1.1.99
80
+ */
81
+ getPendingEntry(rowKey: unknown, property: string): PendingCellIf | undefined;
82
+ /**
83
+ * Puts pending entries back (undo/redo of a batch edit step): an entry is set as it was, none removes the cell's
84
+ * pending value. Reports `onBatchEditChanged` "change"; the caller repaints.
85
+ *
86
+ * @param {{ rowKey: unknown, property: string, entry?: PendingCellIf }[]} cells - the cells
87
+ * @returns {CellChangeIf[]} the cells with their display index (`-1` if not shown)
88
+ * @since 1.1.99
89
+ */
90
+ restorePending(cells: {
91
+ rowKey: unknown;
92
+ property: string;
93
+ entry?: PendingCellIf;
94
+ }[], announce?: boolean): CellChangeIf[];
73
95
  /**
74
96
  * All pending changes with the current display indices (one scan of the shown rows).
75
97
  *
@@ -1,11 +1,15 @@
1
1
  /**
2
2
  * What started a change of cells: `"edit"` (cell editor), `"fill"` (fill handle, Ctrl/⌘+D, Ctrl/⌘+R),
3
- * `"commit"` ({@link TableApi.commitBatchEdit}) or `"api"` ({@link TableApi.applyCellChanges}).
3
+ * `"commit"` ({@link TableApi.commitBatchEdit}), `"api"` ({@link TableApi.applyCellChanges}) or – since 1.1.99 –
4
+ * `"clear"` (Delete/Backspace in Excel-style editing, {@link TableApi.clearCells}), `"paste"` (Ctrl/⌘+V,
5
+ * {@link TableApi.pasteText}), `"cut"` (pasting cut cells: target and emptied source in one change set), `"undo"` and
6
+ * `"redo"` ({@link TableApi.undo}, {@link TableApi.redo}), `"structure"` (rows or columns inserted or deleted,
7
+ * {@link TableApi.insertRows} – the changes are the formulas whose references were adjusted).
4
8
  *
5
9
  * @category Fill handle & batch edit
6
10
  * @since 1.1.96
7
11
  */
8
- export type CellChangeSource = "edit" | "fill" | "commit" | "api";
12
+ export type CellChangeSource = "edit" | "fill" | "commit" | "api" | "clear" | "paste" | "cut" | "undo" | "redo" | "structure";
9
13
  /**
10
14
  * One changed cell: row, column, old and new value – the unit of a change set ({@link GeModelChangeEvent.changes},
11
15
  * {@link TableApi.getPendingChanges}). With old **and** new value it is enough for undo and redo.
@@ -73,6 +73,13 @@ export declare class PendingCellChanges {
73
73
  * @returns {PendingChangeResult} what happened
74
74
  */
75
75
  set(rowKey: unknown, property: string, oldValue: unknown, newValue: unknown, rawValue: unknown, error?: string): PendingChangeResult;
76
+ /**
77
+ * Puts an entry back as it was (undo/redo of a batch edit step) – without comparing it with the old value.
78
+ *
79
+ * @param {PendingCellIf} entry - the entry
80
+ * @since 1.1.99
81
+ */
82
+ put(entry: PendingCellIf): void;
76
83
  /**
77
84
  * The pending entry of a cell.
78
85
  *
@@ -0,0 +1,14 @@
1
+ import { ColumnDefIf } from '../data/tablemodel/column/column-def.if.js';
2
+
3
+ /**
4
+ * Writes a value directly into a row object – for a commit of a row that a filter hides (no display index, so no
5
+ * `setValue`). The value has passed the `editInputPipe` already.
6
+ *
7
+ * @param {unknown} row - the row object (or array)
8
+ * @param {ColumnDefIf | undefined} columnDef - the column
9
+ * @param {number} columnIndex - its index (arrays)
10
+ * @param {unknown} value - the value
11
+ * @returns {boolean} true if written
12
+ * @internal
13
+ */
14
+ export declare function writeRowValue(row: unknown, columnDef: ColumnDefIf | undefined, columnIndex: number, value: unknown): boolean;
@@ -16,6 +16,8 @@ export interface ColumnValuesOwner {
16
16
  length: number;
17
17
  rows: () => ArrayLike<unknown>;
18
18
  };
19
+ /** True if the property holds cell formulas (since 1.1.99): formulas read it through `readPath`, not the object. */
20
+ isSheetFormula?(property: string): boolean;
19
21
  }
20
22
  /**
21
23
  * Resolves `valueGetter`s by property, detects cycles (`#CIRC!`), caches column aggregates.
@@ -0,0 +1,41 @@
1
+ /**
2
+ * One cell for {@link toHtmlTable}: the shown text and – for numbers and dates – the number Excel and LibreOffice
3
+ * take instead of the formatted text (`x:num`).
4
+ *
5
+ * @category Spreadsheet
6
+ * @since 1.1.99
7
+ */
8
+ export interface HtmlTableCellIf {
9
+ text: string;
10
+ num?: number;
11
+ }
12
+ /**
13
+ * A cell matrix as HTML `<table>` for the clipboard (`text/html`): every text escaped, line breaks as `<br>`,
14
+ * numbers with `x:num` (Excel keeps the number although the cell shows formatted text). DOM-free.
15
+ *
16
+ * @param {ReadonlyArray<ReadonlyArray<HtmlTableCellIf>>} matrix - rows of cells
17
+ * @returns {string} the HTML
18
+ *
19
+ * @example
20
+ * toHtmlTable([[{ text: "1,234.50 €", num: 1234.5 }]]);
21
+ * // '<meta charset="utf-8"><table><tbody><tr><td x:num="1234.5">1,234.50 €</td></tr></tbody></table>'
22
+ *
23
+ * @category Spreadsheet
24
+ * @since 1.1.99
25
+ */
26
+ export declare function toHtmlTable(matrix: ReadonlyArray<ReadonlyArray<HtmlTableCellIf>>): string;
27
+ /**
28
+ * The cell texts of the first `<table>` in clipboard HTML (Excel, Google Sheets). Parsed with `DOMParser` into an
29
+ * inert document – no element of it is ever put into the page, no script runs, images do not load; only the text
30
+ * of the cells is read (`<br>` = line break, `colspan` = empty cells, scripts and styles left out). Without a table or without `DOMParser`: `[]`.
31
+ *
32
+ * @param {string} html - the `text/html` content
33
+ * @returns {string[][]} rows of cell texts, all of the same length
34
+ *
35
+ * @example
36
+ * parseHtmlTable("<table><tr><td>a</td><td>1</td></tr></table>"); // [["a", "1"]]
37
+ *
38
+ * @category Spreadsheet
39
+ * @since 1.1.99
40
+ */
41
+ export declare function parseHtmlTable(html: string): string[][];
@@ -0,0 +1,18 @@
1
+ import { ShortcutActionIdMapping } from '../action/shortcut-actionid-mapping.type.js';
2
+
3
+ /**
4
+ * The keys of copy, cut and paste ({@link TableOptionsIf.clipboard}) – a layer over the system mapping that the table
5
+ * only uses with the option; `tableOptions.shortcutActionIdMapping` still overrides it. Ctrl/⌘+X cuts (in the system
6
+ * mapping it is `DESELECT_ALL`, which stays on Ctrl/⌘+Shift+A); Windows also knows Ctrl+Insert, Shift+Delete and
7
+ * Shift+Insert.
8
+ *
9
+ * @param {boolean} mac - macOS keys (⌘)
10
+ * @returns {ShortcutActionIdMapping} the layer
11
+ *
12
+ * @example
13
+ * clipboardShortcutLayer(false)["ctrl+v"]; // "PASTE_FROM_CLIPBOARD"
14
+ *
15
+ * @category Spreadsheet
16
+ * @since 1.1.99
17
+ */
18
+ export declare function clipboardShortcutLayer(mac: boolean): ShortcutActionIdMapping;
@@ -0,0 +1,30 @@
1
+ import { ClipboardOptionsIf, CopyContextIf, PasteContextIf } from './clipboard-options.if.js';
2
+
3
+ /**
4
+ * The defaults of {@link ClipboardOptionsIf} (copy, cut and paste, {@link TableOptionsIf.clipboard}).
5
+ *
6
+ * @example
7
+ * const options = ClipboardOptions.create({ copyHeaders: true });
8
+ * options?.html; // true
9
+ *
10
+ * @category Spreadsheet
11
+ * @since 1.1.99
12
+ */
13
+ export declare class ClipboardOptions implements ClipboardOptionsIf {
14
+ copyHeaders: boolean;
15
+ copyValue: "text" | "raw";
16
+ html: boolean;
17
+ pasteAddsRows: boolean;
18
+ createRow?: (index: number) => unknown;
19
+ maxPasteCells: number;
20
+ processCopy?: (ctx: CopyContextIf) => string[][] | void;
21
+ processPaste?: (ctx: PasteContextIf) => unknown[][] | false | void;
22
+ /**
23
+ * The options of {@link TableOptionsIf.clipboard}: `undefined`/`false` = off, `true` = the defaults, an object = the
24
+ * defaults overridden by its values (`undefined` keeps the default).
25
+ *
26
+ * @param {boolean | Partial<ClipboardOptionsIf>} [option] - `tableOptions.clipboard`
27
+ * @returns {ClipboardOptionsIf | undefined} complete options, `undefined` if the option is off
28
+ */
29
+ static create(option?: boolean | Partial<ClipboardOptionsIf>): ClipboardOptionsIf | undefined;
30
+ }
@@ -0,0 +1,67 @@
1
+ import { CellRange } from '../data/common/cell-range.js';
2
+
3
+ /**
4
+ * What the table copies ({@link ClipboardOptionsIf.processCopy}).
5
+ *
6
+ * @category Spreadsheet
7
+ * @since 1.1.99
8
+ */
9
+ export interface CopyContextIf {
10
+ /** The copied range (body display rows, model columns) – with several selected ranges the last one. */
11
+ readonly ranges: readonly CellRange[];
12
+ /** Text per cell (rows × shown columns): as shown, or the value with `copyValue: "raw"`. */
13
+ readonly matrix: string[][];
14
+ /** True for Ctrl/⌘+X. */
15
+ readonly cut: boolean;
16
+ }
17
+ /**
18
+ * What is pasted ({@link ClipboardOptionsIf.processPaste}).
19
+ *
20
+ * @category Spreadsheet
21
+ * @since 1.1.99
22
+ */
23
+ export interface PasteContextIf {
24
+ /** The `text/plain` content (`""` if there is only HTML). */
25
+ readonly text: string;
26
+ /** The `text/html` content, if any. */
27
+ readonly html?: string;
28
+ /** The parsed cells (rows of texts). */
29
+ readonly matrix: string[][];
30
+ /** The target before tiling and cutting off: anchor cell (display row, model column) and the matrix size. */
31
+ readonly target: CellRange;
32
+ /** True if the content was copied from this table (the values are pasted, not the shown texts). */
33
+ readonly internal: boolean;
34
+ }
35
+ /**
36
+ * Copy, cut and paste like Excel ({@link TableOptionsIf.clipboard}). `clipboard: true` uses the defaults of
37
+ * {@link ClipboardOptions}; an object overrides single values.
38
+ *
39
+ * @example
40
+ * const tableOptions: TableOptionsIf = {
41
+ * ...new TableOptions(),
42
+ * getSelectionModel: () => new SelectionModel("range", "multi"),
43
+ * editing: true,
44
+ * clipboard: { pasteAddsRows: true, createRow: () => ({ name: "", qty: 0 }) },
45
+ * };
46
+ *
47
+ * @category Spreadsheet
48
+ * @since 1.1.99
49
+ */
50
+ export interface ClipboardOptionsIf {
51
+ /** Copy the header labels as first row. Default `false`. */
52
+ copyHeaders: boolean;
53
+ /** `"text"`: the text as shown (default); `"raw"`: the value (a number without group separators, ISO dates). */
54
+ copyValue: "text" | "raw";
55
+ /** Also put an HTML `<table>` into the clipboard (`text/html`, numbers keep their value in Excel). Default `true`. */
56
+ html: boolean;
57
+ /** Pasting over the last row adds rows (`createRow` is needed for arrays of objects). Default `false`. */
58
+ pasteAddsRows: boolean;
59
+ /** Creates a new row for `pasteAddsRows` (the index is the display index it gets). */
60
+ createRow?: (index: number) => unknown;
61
+ /** Upper limit of pasted cells (after tiling); more are refused and announced. Default `1_000_000`. */
62
+ maxPasteCells: number;
63
+ /** Changes the copied cells (return a new matrix) – or only reads them. */
64
+ processCopy?: (ctx: CopyContextIf) => string[][] | void;
65
+ /** Changes the pasted cells (return new values), refuses the paste (`false`) – or only reads them. */
66
+ processPaste?: (ctx: PasteContextIf) => unknown[][] | false | void;
67
+ }
@@ -0,0 +1,122 @@
1
+ import { TableScope } from '../table-scope.js';
2
+ import { ClipboardOptionsIf } from './clipboard-options.if.js';
3
+ import { CellChangeIf } from '../batch-edit/cell-change.if.js';
4
+
5
+ /**
6
+ * A clipboard action of the keyboard.
7
+ *
8
+ * @category Internals
9
+ * @since 1.1.99
10
+ */
11
+ export type ClipboardKind = "copy" | "cut" | "paste";
12
+ /**
13
+ * Copy, cut and paste like Excel ({@link TableOptionsIf.clipboard}): the `copy`, `cut` and `paste` events of the
14
+ * browser (synchronous, no permission prompt). The keys (Ctrl/⌘+C, X, V) focus a hidden text field for the moment of
15
+ * the key press, so that every browser – also Safari, which sends no clipboard events to a focused `div` – fires the
16
+ * event; the focus returns to the table right after it. The Edit menu of the browser works on the focused table, too.
17
+ * Created by {@link TableScope}: with the option (`tableScope.clipboardService`, keys and events), otherwise on
18
+ * demand for the API ({@link TableApi.pasteText}, {@link TableApi.getSelectionAsText}).
19
+ *
20
+ * @category Internals
21
+ * @since 1.1.99
22
+ */
23
+ export declare class ClipboardService {
24
+ private readonly tableScope;
25
+ readonly options: ClipboardOptionsIf;
26
+ private proxy?;
27
+ private memory?;
28
+ private cutFrame?;
29
+ private restoreTimer?;
30
+ private armedKind?;
31
+ /**
32
+ * @param {TableScope} tableScope - the table
33
+ * @param {ClipboardOptionsIf} options - complete options
34
+ * @param {boolean} listen - true: keys and clipboard events (the option is on); false: only the API
35
+ */
36
+ constructor(tableScope: TableScope, options: ClipboardOptionsIf, listen: boolean);
37
+ /** True while cut cells are marked (dashed frame). */
38
+ isCutMarked(): boolean;
39
+ /**
40
+ * Ctrl/⌘+C, X or V (from the shortcut mapping): focuses the hidden text field so that the browser fires its
41
+ * clipboard event there. The key must not be consumed (`preventDefault`) – the caller returns `false`.
42
+ *
43
+ * @param {ClipboardKind} kind - the key
44
+ * @returns {boolean} true if the event will be handled; false: not here (the editor is open, header focus, an own
45
+ * `CopyServiceIf` for copying)
46
+ */
47
+ arm(kind: ClipboardKind): boolean;
48
+ /**
49
+ * The selected cells as tab-separated text, as Ctrl/⌘+C copies them (see {@link TableApi.getSelectionAsText}).
50
+ *
51
+ * @returns {string} the text; `""` without cells or with more than `CopyService.maxCopyCells`
52
+ */
53
+ getSelectionAsText(): string;
54
+ /**
55
+ * Copies (or cuts) the selected cells with the asynchronous clipboard API (`text/plain` and `text/html` with
56
+ * `ClipboardItem`, otherwise `writeText`) – for buttons and menus (see {@link TableApi.copySelection}).
57
+ *
58
+ * @param {boolean} cut - true: mark the cells, they move on the next paste
59
+ * @returns {Promise<void>} resolves when the clipboard was written
60
+ */
61
+ writeSelection(cut: boolean): Promise<void>;
62
+ /**
63
+ * Copy, cut or paste without a key (an `ActionId` from {@link TableApi.triggerAction}, e.g. a context menu): the
64
+ * asynchronous clipboard API – the browser may ask for permission.
65
+ *
66
+ * @param {ClipboardKind} kind - what to do
67
+ * @returns {Promise<void>} resolves when done (a refused permission is ignored)
68
+ */
69
+ runWithoutKey(kind: ClipboardKind): Promise<void>;
70
+ /**
71
+ * Pastes text (see {@link TableApi.pasteText}): parsed like the clipboard, from `target` or the selection.
72
+ *
73
+ * @param {string} text - tab-separated text
74
+ * @param {string} [html] - `text/html` (used only without text)
75
+ * @param {[number, number]} [target] - display row and model column of the first cell (no tiling)
76
+ * @returns {CellChangeIf[]} the written (batch edit: newly pending) cells
77
+ */
78
+ paste(text: string, html?: string, target?: [number, number]): CellChangeIf[];
79
+ /** Removes the mark of cut cells (Escape, another change, {@link TableApi.cancelCut}); the clipboard keeps the text. */
80
+ cancelCut(): void;
81
+ /** Places the dashed frame of cut cells (after every render pass); removes it if the cut rows moved. */
82
+ update(): void;
83
+ /** Removes the hidden text field and the frame (table destroyed). */
84
+ destroy(): void;
85
+ private onClipboardEvent;
86
+ private restoreFocus;
87
+ private ensureProxy;
88
+ /** Stores the copy (pasting the same text pastes the values) and announces it; a cut gets its frame. */
89
+ private remember;
90
+ /** The cells of a copy: the last selected range (everything: the body), without selection the active cell. */
91
+ private buildCopy;
92
+ /** The visible data columns in display order (hidden and row number columns are skipped). */
93
+ private getPasteColumns;
94
+ /** Anchor (first row, first column) and the selected size (rows × shown columns) of a paste. */
95
+ private getPasteAnchor;
96
+ /**
97
+ * External text into a column without `editInputPipe`: converted like the editor of Excel-style editing – a
98
+ * number into a number cell (or `editor: "number"`), `TRUE`/`FALSE` into a `true`/`false` cell, an ISO date into a
99
+ * `Date` cell (or `editor: "date"` on a `Date`); everything else stays text. With a pipe the pipe converts.
100
+ */
101
+ private convertPastedText;
102
+ /**
103
+ * The cut cells whose values arrived (`moved`: row and column offsets in the cut range) and that are not pasted over
104
+ * themselves: emptied – where their rows are now (sorting, filter).
105
+ */
106
+ private cutSourceChanges;
107
+ /**
108
+ * The display index of the i-th cut row: at its old place – or, if the rows were sorted or filtered meanwhile,
109
+ * looked up once by row object (models without row objects: the old place).
110
+ */
111
+ private rowIndexLookup;
112
+ /** True for the table's own `CopyService` (an own `CopyServiceIf` or a subclass keeps the asynchronous way). */
113
+ private hasBuiltInCopyService;
114
+ private rowObjectAt;
115
+ private rowObjectsOf;
116
+ /** Rows can be added: an array of objects or arrays without grouping, tree or pivot (`getAllRows`). */
117
+ private canAppendRows;
118
+ /** Adds `count` rows from `createRow` at the end (also at the end of the displayed rows). */
119
+ private appendRows;
120
+ private showCutFrame;
121
+ private removeCutFrame;
122
+ }