@guiexpert/table 1.1.98 → 1.1.100
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 +9 -0
- package/css/main.css +296 -0
- package/css/table-clipboard.css +41 -0
- package/css/table-color-vars.css +56 -0
- package/css/table-sheet-editing.css +149 -0
- package/css/table-spreadsheet.css +50 -0
- package/index.cjs +46 -59
- package/index.d.ts +46 -0
- package/index.js +18934 -11624
- package/lib/table/action/action-id.type.d.ts +1 -1
- package/lib/table/action/shortcut.service.d.ts +9 -0
- package/lib/table/aria/aria-texts.d.ts +26 -0
- package/lib/table/aria/aria-texts.if.d.ts +196 -0
- package/lib/table/batch-edit/batch-edit-service.d.ts +22 -0
- package/lib/table/batch-edit/cell-change.if.d.ts +6 -2
- package/lib/table/batch-edit/pending-cell-changes.d.ts +7 -0
- package/lib/table/batch-edit/write-row-value.d.ts +14 -0
- package/lib/table/calc/column-values.d.ts +2 -0
- package/lib/table/clipboard/clipboard-html.d.ts +41 -0
- package/lib/table/clipboard/clipboard-keymap.d.ts +18 -0
- package/lib/table/clipboard/clipboard-options.d.ts +30 -0
- package/lib/table/clipboard/clipboard-options.if.d.ts +67 -0
- package/lib/table/clipboard/clipboard-service.d.ts +122 -0
- package/lib/table/clipboard/input-pipes.d.ts +59 -0
- package/lib/table/clipboard/paste-plan.d.ts +96 -0
- package/lib/table/clipboard/tsv.d.ts +31 -0
- package/lib/table/data/common/event/ge-edit-event.d.ts +46 -0
- package/lib/table/data/common/event/ge-row-drag-event.d.ts +2 -2
- package/lib/table/data/common/event/ge-undo-event.d.ts +29 -0
- package/lib/table/data/options/table-options.d.ts +28 -0
- package/lib/table/data/options/table-options.if.d.ts +99 -1
- package/lib/table/data/tablemodel/areamodel/abstract-area-model.d.ts +11 -2
- package/lib/table/data/tablemodel/areamodel/area-model-array-of-arrays.d.ts +14 -0
- package/lib/table/data/tablemodel/areamodel/area-model-object-array.d.ts +14 -0
- package/lib/table/data/tablemodel/areamodel/area-model.if.d.ts +11 -0
- package/lib/table/data/tablemodel/column/column-def.d.ts +13 -0
- package/lib/table/data/tablemodel/column/column-def.if.d.ts +36 -1
- package/lib/table/data/tablemodel/column/default-editable.d.ts +18 -0
- package/lib/table/event-adapter.d.ts +6 -0
- package/lib/table/event-listener-hub.d.ts +10 -0
- package/lib/table/event-listener.if.d.ts +16 -0
- package/lib/table/factory/pivot-factory.d.ts +1 -1
- package/lib/table/factory/row-group-factory.d.ts +1 -1
- package/lib/table/factory/table-factory.d.ts +14 -0
- package/lib/table/formula/formula-ast.if.d.ts +32 -2
- package/lib/table/formula/formula-error.d.ts +4 -2
- package/lib/table/formula/parser.d.ts +5 -2
- package/lib/table/formula/tokenizer.d.ts +5 -2
- package/lib/table/input-handler.d.ts +8 -0
- package/lib/table/master-detail/master-detail-service.d.ts +9 -0
- package/lib/table/render-scope.d.ts +40 -0
- package/lib/table/row-drag/row-drag-service.d.ts +3 -2
- package/lib/table/selection/selection-service.d.ts +48 -0
- package/lib/table/service/excel-export-options.if.d.ts +6 -0
- package/lib/table/service/excel-service.d.ts +4 -0
- package/lib/table/service/excel-service.if.d.ts +35 -0
- package/lib/table/sheet/cell-address.d.ts +100 -0
- package/lib/table/sheet/cell-formula-options.d.ts +27 -0
- package/lib/table/sheet/cell-formula-options.if.d.ts +27 -0
- package/lib/table/sheet/excel-formula.d.ts +20 -0
- package/lib/table/sheet/format-formula.d.ts +19 -0
- package/lib/table/sheet/sheet-cells.if.d.ts +17 -0
- package/lib/table/sheet/sheet-compiler.d.ts +47 -0
- package/lib/table/sheet/sheet-engine.d.ts +207 -0
- package/lib/table/sheet/sheet-function-info.d.ts +25 -0
- package/lib/table/sheet/sheet-functions.d.ts +27 -0
- package/lib/table/sheet/sheet-values.d.ts +154 -0
- package/lib/table/sheet/shift-formula.d.ts +71 -0
- package/lib/table/sheet/table-sheet.d.ts +214 -0
- package/lib/table/sheet-editing/cell-editor-service.d.ts +105 -0
- package/lib/table/sheet-editing/cell-editor.if.d.ts +110 -0
- package/lib/table/sheet-editing/editing-keymap.d.ts +17 -0
- package/lib/table/sheet-editing/editing-options.d.ts +34 -0
- package/lib/table/sheet-editing/editing-options.if.d.ts +49 -0
- package/lib/table/sheet-editing/editors/date-cell-editor.d.ts +23 -0
- package/lib/table/sheet-editing/editors/number-cell-editor.d.ts +18 -0
- package/lib/table/sheet-editing/editors/select-cell-editor.d.ts +36 -0
- package/lib/table/sheet-editing/editors/text-cell-editor.d.ts +35 -0
- package/lib/table/sheet-editing/formula-assist.d.ts +103 -0
- package/lib/table/sheet-editing/formula-text.d.ts +61 -0
- package/lib/table/sheet-editing/sheet-navigation.d.ts +26 -0
- package/lib/table/spreadsheet/area-model-sheet.d.ts +170 -0
- package/lib/table/spreadsheet/formula-bar.d.ts +53 -0
- package/lib/table/spreadsheet/spreadsheet-factory.d.ts +111 -0
- package/lib/table/spreadsheet/spreadsheet-options.if.d.ts +28 -0
- package/lib/table/spreadsheet/spreadsheet-preset.d.ts +37 -0
- package/lib/table/spreadsheet/structure-edit.d.ts +35 -0
- package/lib/table/table-api.d.ts +511 -2
- package/lib/table/table-scope.d.ts +294 -1
- package/lib/table/undo/cell-changes-undoable.d.ts +34 -0
- package/lib/table/undo/model-rows.d.ts +17 -0
- package/lib/table/undo/pending-changes-undoable.d.ts +35 -0
- package/lib/table/undo/undo-keymap.d.ts +17 -0
- package/lib/table/undo/undo-options.d.ts +26 -0
- package/lib/table/undo/undo-options.if.d.ts +30 -0
- package/lib/table/undo/undo-service.d.ts +103 -0
- package/lib/table/undo/undo-stack.d.ts +62 -0
- package/lib/table/undo/undoable.if.d.ts +36 -0
- package/package.json +1 -1
|
@@ -44,6 +44,12 @@ import { FillDirection } from './fill/fill-direction.type.js';
|
|
|
44
44
|
import { FillMode } from './fill/fill-series.js';
|
|
45
45
|
import { CellRange } from './data/common/cell-range.js';
|
|
46
46
|
import { AriaTextsIf } from './aria/aria-texts.if.js';
|
|
47
|
+
import { EditingOptionsIf } from './sheet-editing/editing-options.if.js';
|
|
48
|
+
import { CellEditMode } from './sheet-editing/cell-editor.if.js';
|
|
49
|
+
import { ClipboardService } from './clipboard/clipboard-service.js';
|
|
50
|
+
import { UndoOptionsIf } from './undo/undo-options.if.js';
|
|
51
|
+
import { UndoService } from './undo/undo-service.js';
|
|
52
|
+
import { ShortcutActionIdMapping } from './action/shortcut-actionid-mapping.type.js';
|
|
47
53
|
|
|
48
54
|
/**
|
|
49
55
|
* Creates and runs one table in a host element – the core that every framework wrapper uses.
|
|
@@ -124,6 +130,20 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
124
130
|
private firstDraggingRendering;
|
|
125
131
|
/** Last comparator passed to `sort()`; re-applied after filtering. Cleared by a header sort. */
|
|
126
132
|
private lastSortCompareFn?;
|
|
133
|
+
/** Excel-style editing (`tableOptions.editing`), `undefined` = off. @since 1.1.99 */
|
|
134
|
+
private readonly editingOptions?;
|
|
135
|
+
/** Listeners of {@link TableApi.subscribe}. @since 1.1.99 */
|
|
136
|
+
private readonly subscribers;
|
|
137
|
+
/** Copy, cut and paste (`tableOptions.clipboard`), `undefined` = off. @since 1.1.99 */
|
|
138
|
+
private readonly clipboardOptions?;
|
|
139
|
+
/** Copy, cut and paste: with the option keys and events, otherwise created for the API. @since 1.1.99 */
|
|
140
|
+
clipboardService?: ClipboardService;
|
|
141
|
+
/** Undo and redo (`tableOptions.undo`), `undefined` = off. @since 1.1.99 */
|
|
142
|
+
private readonly undoOptions?;
|
|
143
|
+
/** Undo and redo: records the changes of the write path (only with the option). @since 1.1.99 */
|
|
144
|
+
undoService?: UndoService;
|
|
145
|
+
/** The key event the {@link ShortcutService} is handling right now (`undefined` for `triggerAction`). @since 1.1.99 */
|
|
146
|
+
shortcutKeyEvent?: KeyboardEvent;
|
|
127
147
|
constructor(hostElement: HTMLDivElement, tableModel: TableModelIf, domService: DomServiceIf, tableOptions: TableOptionsIf, eventListener: EventListenerIf, copyService?: CopyServiceIf, excelService?: ExcelServiceIf);
|
|
128
148
|
/**
|
|
129
149
|
* The options of a nested table (master/detail `ctx.createTable()`): as given; without an own `direction` in a
|
|
@@ -159,6 +179,154 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
159
179
|
* @return {boolean} - Returns true if the action was triggered successfully, false otherwise.
|
|
160
180
|
*/
|
|
161
181
|
onActionTriggered(actionId: ActionId): boolean;
|
|
182
|
+
/**
|
|
183
|
+
* The options of Excel-style editing ({@link TableOptionsIf.editing}), `undefined` if it is off.
|
|
184
|
+
*
|
|
185
|
+
* @returns {EditingOptionsIf | undefined} complete options
|
|
186
|
+
* @since 1.1.99
|
|
187
|
+
*/
|
|
188
|
+
getEditingOptions(): EditingOptionsIf | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Shortcut layers of switched-on features, applied over the system mapping (see {@link ShortcutService}).
|
|
191
|
+
*
|
|
192
|
+
* @param {boolean} mac - macOS keys
|
|
193
|
+
* @returns {ShortcutActionIdMapping[]} the layers (none without Excel-style editing)
|
|
194
|
+
* @since 1.1.99
|
|
195
|
+
*/
|
|
196
|
+
getShortcutLayers(mac: boolean): ShortcutActionIdMapping[];
|
|
197
|
+
/**
|
|
198
|
+
* Adds a listener next to the one given to the constructor (see {@link TableApi.subscribe}).
|
|
199
|
+
*
|
|
200
|
+
* @param {Partial<EventListenerIf>} listener - the events of interest
|
|
201
|
+
* @returns {() => void} removes the listener again
|
|
202
|
+
* @since 1.1.99
|
|
203
|
+
*/
|
|
204
|
+
subscribe(listener: Partial<EventListenerIf>): () => void;
|
|
205
|
+
/**
|
|
206
|
+
* Opens the cell editor of a body cell: the editor above the cell (Excel-style editing) or – for columns with an
|
|
207
|
+
* own `getEditRenderer`, and without `tableOptions.editing` – the editor inside the cell.
|
|
208
|
+
*
|
|
209
|
+
* @param {number} rowIndex - display row index
|
|
210
|
+
* @param {number} columnIndex - model column index
|
|
211
|
+
* @param {CellEditMode} [mode="edit"] - "edit" (F2, Enter, double click) or "enter" (typing)
|
|
212
|
+
* @param {"all" | "end"} [textSelection] - select the text or put the caret at the end (default: the option)
|
|
213
|
+
* @returns {boolean} true if an editor is open
|
|
214
|
+
* @since 1.1.99
|
|
215
|
+
*/
|
|
216
|
+
startEditing(rowIndex: number, columnIndex: number, mode?: CellEditMode, textSelection?: 'all' | 'end'): boolean;
|
|
217
|
+
/** True if a new editor may open now: no header focus, no blocking overlay, no running drag or fill. @since 1.1.99 */
|
|
218
|
+
canStartEditing(): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* The value a body cell shows: a pending value of a batch edit, otherwise the model value – with cell formulas the
|
|
221
|
+
* input ({@link getCellInput}: the formula text for the editor).
|
|
222
|
+
*
|
|
223
|
+
* @param {number} rowIndex - display row index
|
|
224
|
+
* @param {number} columnIndex - model column index
|
|
225
|
+
* @returns {unknown} the value
|
|
226
|
+
* @since 1.1.99
|
|
227
|
+
*/
|
|
228
|
+
getShownCellValue(rowIndex: number, columnIndex: number): unknown;
|
|
229
|
+
/** The body cell with the keyboard focus, `undefined` if there is none (or the header has the focus). @since 1.1.99 */
|
|
230
|
+
getActiveBodyCell(): [number, number] | undefined;
|
|
231
|
+
/**
|
|
232
|
+
* Builds the view again after rows or columns were inserted or deleted (filter and sorting applied again, new
|
|
233
|
+
* columns measured).
|
|
234
|
+
*
|
|
235
|
+
* @param {boolean} columns - true: the columns changed
|
|
236
|
+
* @since 1.1.99
|
|
237
|
+
*/
|
|
238
|
+
refreshAfterStructureChange(columns: boolean): void;
|
|
239
|
+
/**
|
|
240
|
+
* The next shown column in a direction (hidden columns skipped; the same column at the edge).
|
|
241
|
+
*
|
|
242
|
+
* @param {number} columnIndex - model column index
|
|
243
|
+
* @param {number} direction - 1 or -1
|
|
244
|
+
* @returns {number} the column
|
|
245
|
+
* @since 1.1.99
|
|
246
|
+
*/
|
|
247
|
+
nextShownColumn(columnIndex: number, direction: number): number;
|
|
248
|
+
/**
|
|
249
|
+
* True if there is a shown column (no row number column) next to `columnIndex` in that direction – Tab uses it:
|
|
250
|
+
* in the last column it leaves the table.
|
|
251
|
+
*
|
|
252
|
+
* @param {number} columnIndex - model column index
|
|
253
|
+
* @param {number} direction - 1 or -1
|
|
254
|
+
* @returns {boolean} true if Tab can move
|
|
255
|
+
* @since 1.1.99
|
|
256
|
+
*/
|
|
257
|
+
hasShownColumnBeside(columnIndex: number, direction: number): boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Moves the keyboard focus from a cell by rows/columns (Excel-style editing: Enter, Tab and arrow keys after
|
|
260
|
+
* committing); the selection follows with `collapseSelectionOnNavigate`.
|
|
261
|
+
*
|
|
262
|
+
* @param {number} rowIndex - start row
|
|
263
|
+
* @param {number} columnIndex - start column
|
|
264
|
+
* @param {number} dRow - rows
|
|
265
|
+
* @param {number} dColumn - columns (hidden columns are skipped)
|
|
266
|
+
* @returns {boolean} true if a focus model exists
|
|
267
|
+
* @since 1.1.99
|
|
268
|
+
*/
|
|
269
|
+
moveActiveCell(rowIndex: number, columnIndex: number, dRow: number, dColumn: number): boolean;
|
|
270
|
+
/**
|
|
271
|
+
* The selected body cells (shown columns, inside the table) – `undefined` if there are more than `maxCells`.
|
|
272
|
+
*
|
|
273
|
+
* @param {number} maxCells - upper limit
|
|
274
|
+
* @returns {Array<[number, number]> | undefined} row and column per cell; none without selection
|
|
275
|
+
* @since 1.1.99
|
|
276
|
+
*/
|
|
277
|
+
getSelectedBodyCells(maxCells: number): Array<[number, number]> | undefined;
|
|
278
|
+
/**
|
|
279
|
+
* The body cells of the selection (or of `given` ranges): clamped to the table, shown columns without row number
|
|
280
|
+
* column, each cell once – `undefined` if there are more than `maxCells` (checked before the cells are visited).
|
|
281
|
+
*/
|
|
282
|
+
private collectSelectedBodyCells;
|
|
283
|
+
/**
|
|
284
|
+
* Clears body cells (Delete in Excel-style editing): editable cells get `ColumnDef.emptyValue` (default
|
|
285
|
+
* `EditingOptionsIf.emptyValue`, `""`), cells that are already empty are left alone; **one** `onModelChanged` with
|
|
286
|
+
* the source `"clear"`. Without `ranges`: the selected cells, or the focused cell.
|
|
287
|
+
*
|
|
288
|
+
* @param {CellRange[]} [ranges] - body ranges (display indices)
|
|
289
|
+
* @returns {number} the number of cleared cells; `-1` if more than `maxClearCells`
|
|
290
|
+
* @since 1.1.99
|
|
291
|
+
*/
|
|
292
|
+
clearCells(ranges?: CellRange[]): number;
|
|
293
|
+
/**
|
|
294
|
+
* Writes the value of the editor above the cell (Excel-style editing): into one cell, or – Ctrl/⌘+Enter – into
|
|
295
|
+
* several; batch edit: marks it. Used by {@link CellEditorService}.
|
|
296
|
+
*
|
|
297
|
+
* @param {Array<[number, number]>} cells - display row and model column per cell
|
|
298
|
+
* @param {unknown} value - the editor value (it runs through `editInputPipe` and `validate`)
|
|
299
|
+
* @param {boolean} deferRepaint - repaint after the current mouse click
|
|
300
|
+
* @returns {{ written: number, invalid: number, message?: string }} what happened
|
|
301
|
+
* @since 1.1.99
|
|
302
|
+
*/
|
|
303
|
+
commitCellEditor(cells: Array<[number, number]>, value: unknown, deferRepaint: boolean): {
|
|
304
|
+
written: number;
|
|
305
|
+
invalid: number;
|
|
306
|
+
message?: string;
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Space on a cell with a `true`/`false` value (Excel-style editing): writes the opposite value.
|
|
310
|
+
*
|
|
311
|
+
* @param {number} rowIndex - display row index
|
|
312
|
+
* @param {number} columnIndex - model column index
|
|
313
|
+
* @since 1.1.99
|
|
314
|
+
*/
|
|
315
|
+
toggleBooleanCell(rowIndex: number, columnIndex: number): void;
|
|
316
|
+
/** The texts of Excel-style editing (own functions of `tableOptions.ariaTexts`, otherwise English). @since 1.1.99 */
|
|
317
|
+
getSheetTexts(): Required<Pick<AriaTextsIf, 'editingStarted' | 'readOnlyCell' | 'cellsCleared' | 'clearTooLarge' | 'rangeSelected' | 'rowSelected' | 'columnSelected' | 'gridEditingHint' | 'cellsPasted' | 'pasteTooLarge' | 'copyTooLarge' | 'cutMarked' | 'copiedLastRangeOnly'>>;
|
|
318
|
+
/** The keys of Excel-style editing that are ActionIds (Tab, Shift+arrows, Ctrl+arrows, Delete …). */
|
|
319
|
+
private onSheetAction;
|
|
320
|
+
/** The moving corner of the selected range (Shift+arrows), the active cell if there is none. */
|
|
321
|
+
private getSelectionExtent;
|
|
322
|
+
/** The first shown column that is no row number column. */
|
|
323
|
+
private getFirstShownDataColumnIndex;
|
|
324
|
+
/** Ctrl+arrow: Excel's edge of the data block from a cell (shown columns, no row number column). */
|
|
325
|
+
private dataEdge;
|
|
326
|
+
/** Shift+arrows: the range from the anchor to `(row, column)`, scrolled into view and announced. */
|
|
327
|
+
private extendSelectionTo;
|
|
328
|
+
/** Shift+Space / Ctrl+Space: the rows (columns) of the last range or of the active cell. */
|
|
329
|
+
private selectWholeRowsOrColumns;
|
|
162
330
|
/**
|
|
163
331
|
* The event listener of this table (the one given to the constructor, or an empty {@link EventAdapter}).
|
|
164
332
|
*
|
|
@@ -227,6 +395,8 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
227
395
|
getHeaderFocus(): [number, number] | undefined;
|
|
228
396
|
/** Moves the body focus to a cell, scrolls it into view and repaints (also leaves the header). */
|
|
229
397
|
private setFocusCell;
|
|
398
|
+
/** Excel-style editing: the keyboard moved the active cell – it becomes the selection and the anchor. */
|
|
399
|
+
private afterActiveCellMoved;
|
|
230
400
|
private getFirstShownColumnIndex;
|
|
231
401
|
private getLastShownColumnIndex;
|
|
232
402
|
/** Home, End, Ctrl+Home, Ctrl+End, Page Up/Down and Enter in the body; `undefined` = not such an action. */
|
|
@@ -273,7 +443,9 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
273
443
|
* @returns {CellChangeIf[]} the written (or, in a batch edit, newly pending) cells
|
|
274
444
|
* @since 1.1.96
|
|
275
445
|
*/
|
|
276
|
-
applyCellChanges(changes: CellValueChangeIf[], source?: CellChangeSource
|
|
446
|
+
applyCellChanges(changes: CellValueChangeIf[], source?: CellChangeSource, opts?: {
|
|
447
|
+
undoable?: boolean;
|
|
448
|
+
}): CellChangeIf[];
|
|
277
449
|
/**
|
|
278
450
|
* Writes cell values directly (no batch edit) – used by {@link applyCellChanges} and the batch commit.
|
|
279
451
|
*
|
|
@@ -293,6 +465,122 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
293
465
|
skipValidation?: boolean;
|
|
294
466
|
}): CellChangeIf[];
|
|
295
467
|
private writeCellsInternal;
|
|
468
|
+
/**
|
|
469
|
+
* Writes pasted cells (copy, cut and paste): like {@link applyCellChanges} – not editable cells skipped, `validate`,
|
|
470
|
+
* batch edit marks – with **one** `onModelChanged`; `raw` = values copied inside the table (no `editInputPipe`).
|
|
471
|
+
*
|
|
472
|
+
* @param {CellValueChangeIf[]} changes - target cells (and emptied cut cells)
|
|
473
|
+
* @param {CellChangeSource} source - `"paste"` or `"cut"`
|
|
474
|
+
* @param {boolean} raw - true: without `editInputPipe`
|
|
475
|
+
* @returns {CellChangeIf[]} the written (batch edit: newly pending) cells
|
|
476
|
+
* @since 1.1.99
|
|
477
|
+
*/
|
|
478
|
+
writePastedCells(changes: CellValueChangeIf[], source: CellChangeSource, raw: boolean): CellChangeIf[];
|
|
479
|
+
/**
|
|
480
|
+
* Selects a body range (after pasting): its first cell becomes the active cell and the anchor.
|
|
481
|
+
*
|
|
482
|
+
* @param {CellRange} range - display rows, model columns
|
|
483
|
+
* @since 1.1.99
|
|
484
|
+
*/
|
|
485
|
+
selectBodyRange(range: CellRange): void;
|
|
486
|
+
/**
|
|
487
|
+
* The message of the column's `validate` for a value that would be pasted, `undefined` if it is valid.
|
|
488
|
+
*
|
|
489
|
+
* @param {number} rowIndex - display row
|
|
490
|
+
* @param {number} columnIndex - model column
|
|
491
|
+
* @param {unknown} value - the value
|
|
492
|
+
* @param {boolean} raw - true: without `editInputPipe`
|
|
493
|
+
* @returns {string | undefined} the message
|
|
494
|
+
* @since 1.1.99
|
|
495
|
+
*/
|
|
496
|
+
checkPastedValue(rowIndex: number, columnIndex: number, value: unknown, raw: boolean): string | undefined;
|
|
497
|
+
/**
|
|
498
|
+
* The input of a body cell – what was typed: the formula text of a cell formula (`"=B2*C2"`), otherwise the value
|
|
499
|
+
* ({@link AreaModelIf.getInputValueAt}). Editor, undo and the batch edit use it.
|
|
500
|
+
*
|
|
501
|
+
* @param {number} rowIndex - display row
|
|
502
|
+
* @param {number} columnIndex - model column
|
|
503
|
+
* @returns {unknown} the input
|
|
504
|
+
* @since 1.1.99
|
|
505
|
+
*/
|
|
506
|
+
getCellInput(rowIndex: number, columnIndex: number): unknown;
|
|
507
|
+
/**
|
|
508
|
+
* The value of a body cell to choose an editor or convert pasted text by: the result of a formula cell (a number
|
|
509
|
+
* stays a number when overwritten), otherwise {@link getShownCellValue}.
|
|
510
|
+
*
|
|
511
|
+
* @param {number} rowIndex - display row
|
|
512
|
+
* @param {number} columnIndex - model column
|
|
513
|
+
* @returns {unknown} the value
|
|
514
|
+
* @since 1.1.99
|
|
515
|
+
*/
|
|
516
|
+
getTypedCellValue(rowIndex: number, columnIndex: number): unknown;
|
|
517
|
+
/**
|
|
518
|
+
* The announcement of a stored formula with a syntax error (`AriaTextsIf.formulaError`).
|
|
519
|
+
*
|
|
520
|
+
* @param {string} message - the parser's message
|
|
521
|
+
* @returns {string} the text
|
|
522
|
+
* @since 1.1.99
|
|
523
|
+
*/
|
|
524
|
+
getFormulaErrorText(message: string): string;
|
|
525
|
+
/** A syntax error of a formula refuses it only with `rejectInvalidFormulas` (otherwise it is stored: `#ERROR!`). */
|
|
526
|
+
private checkFormulaSyntax;
|
|
527
|
+
/**
|
|
528
|
+
* Resolves a formula copied inside the table for a target cell: its relative references move (Excel); a target
|
|
529
|
+
* without formulas gets the copied value. A cut formula moves unchanged.
|
|
530
|
+
*
|
|
531
|
+
* @param {unknown} value - a pasted value (maybe a {@link CopiedFormula})
|
|
532
|
+
* @param {number} rowIndex - display row of the target
|
|
533
|
+
* @param {number} columnIndex - model column of the target
|
|
534
|
+
* @param {boolean} cut - true: the formula moves (cut and paste)
|
|
535
|
+
* @returns {unknown} the value to write
|
|
536
|
+
* @since 1.1.99
|
|
537
|
+
*/
|
|
538
|
+
resolvePastedValue(value: unknown, rowIndex: number, columnIndex: number, cut: boolean): unknown;
|
|
539
|
+
/**
|
|
540
|
+
* The value of a cell for a copy inside the table: a formula cell gives a {@link CopiedFormula}.
|
|
541
|
+
*
|
|
542
|
+
* @param {number} rowIndex - display row
|
|
543
|
+
* @param {number} columnIndex - model column
|
|
544
|
+
* @returns {unknown} the value
|
|
545
|
+
* @since 1.1.99
|
|
546
|
+
*/
|
|
547
|
+
getCopyValue(rowIndex: number, columnIndex: number): unknown;
|
|
548
|
+
/** True while a batch edit collects changes. @since 1.1.99 */
|
|
549
|
+
isBatchEditActive(): boolean;
|
|
550
|
+
/** The options of undo and redo ({@link TableOptionsIf.undo}), `undefined` if it is off. @since 1.1.99 */
|
|
551
|
+
getUndoOptions(): UndoOptionsIf | undefined;
|
|
552
|
+
/**
|
|
553
|
+
* Writes the values of an undo or redo: without `editInputPipe` (the values were piped already) and validation, only
|
|
554
|
+
* editable cells; cells of hidden rows (`hidden`, written into their objects already) in the same event; no new
|
|
555
|
+
* step.
|
|
556
|
+
*
|
|
557
|
+
* @param {{ rowIndex: number, columnIndex: number, value: unknown }[]} cells - shown cells
|
|
558
|
+
* @param {CellChangeIf[]} hidden - cells of rows a filter hides
|
|
559
|
+
* @param {"undo" | "redo"} source - reported in the event
|
|
560
|
+
* @returns {CellChangeIf[]} the written cells (including `hidden`)
|
|
561
|
+
* @since 1.1.99
|
|
562
|
+
*/
|
|
563
|
+
writeUndoCells(cells: {
|
|
564
|
+
rowIndex: number;
|
|
565
|
+
columnIndex: number;
|
|
566
|
+
value: unknown;
|
|
567
|
+
}[], hidden: CellChangeIf[], source: 'undo' | 'redo'): CellChangeIf[];
|
|
568
|
+
/** The texts of undo and redo (own functions of `tableOptions.ariaTexts`, otherwise English). @since 1.1.99 */
|
|
569
|
+
getUndoTexts(): Required<Pick<AriaTextsIf, 'undone' | 'redone' | 'nothingToUndo' | 'nothingToRedo' | 'undoSkipped' | 'undoHistoryCleared'>>;
|
|
570
|
+
/** True while an overlay blocks the table ("Loading…"). @since 1.1.99 */
|
|
571
|
+
isOverlayBlocking(): boolean;
|
|
572
|
+
/** Rows were added at the end of the body (pasting with `pasteAddsRows`): derived values are recomputed. @since 1.1.99 */
|
|
573
|
+
rowsAppended(): void;
|
|
574
|
+
/** True for a tree, a row grouping or a pivot table in the body (rows cannot simply be appended). @since 1.1.99 */
|
|
575
|
+
isRowGroupingOrTree(): boolean;
|
|
576
|
+
/**
|
|
577
|
+
* The clipboard service for the API ({@link TableApi.pasteText}, {@link TableApi.getSelectionAsText}): the one of
|
|
578
|
+
* the option, otherwise one with the defaults that does not listen to keys or events.
|
|
579
|
+
*
|
|
580
|
+
* @returns {ClipboardService} the service
|
|
581
|
+
* @since 1.1.99
|
|
582
|
+
*/
|
|
583
|
+
getClipboardService(): ClipboardService;
|
|
296
584
|
/** Marks values as pending (batch edit): pipe, validation, then the batch edit service. */
|
|
297
585
|
private markPending;
|
|
298
586
|
/**
|
|
@@ -326,6 +614,11 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
|
|
|
326
614
|
* @since 1.1.96
|
|
327
615
|
*/
|
|
328
616
|
fillRange(source: CellRange, direction: FillDirection, count: number, mode?: FillMode, selectAfter?: CellRange): number;
|
|
617
|
+
/**
|
|
618
|
+
* Cell formulas (since 1.1.99): a filled cell whose source cell (the source repeats) holds a formula gets the formula
|
|
619
|
+
* with moved references (Excel: `=B2*C2` → `=B3*C3`, `$B$1` stays) instead of a series value.
|
|
620
|
+
*/
|
|
621
|
+
private moveFilledFormulas;
|
|
329
622
|
/** The last selected range, clamped to the body (`undefined` without one). */
|
|
330
623
|
getFillSourceRange(): CellRange | undefined;
|
|
331
624
|
private normalizeRange;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TableScope } from '../table-scope.js';
|
|
2
|
+
import { CellChangeIf, CellChangeSource } from '../batch-edit/cell-change.if.js';
|
|
3
|
+
import { UndoableIf, UndoResultIf } from './undoable.if.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A step of written cells (an edit, a fill, a paste …): undo writes the old values back, redo the new ones. The cells
|
|
7
|
+
* are found by row **object** and property – sorting and filtering in between don't matter; a row a filter hides is
|
|
8
|
+
* written directly into its object (reported in the same event), a row that left the model is skipped. A cell that
|
|
9
|
+
* no longer has the expected value is skipped (`onConflict: "skip"`) or overwritten.
|
|
10
|
+
*
|
|
11
|
+
* @category Spreadsheet
|
|
12
|
+
* @since 1.1.99
|
|
13
|
+
*/
|
|
14
|
+
export declare class CellChangesUndoable implements UndoableIf {
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly source: CellChangeSource;
|
|
17
|
+
private readonly entries;
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} label - for buttons and announcements
|
|
20
|
+
* @param {CellChangeSource} source - what started the step
|
|
21
|
+
* @param {CellChangeIf[]} changes - the written cells (`GeModelChangeEvent.changes`)
|
|
22
|
+
*/
|
|
23
|
+
constructor(label: string, source: CellChangeSource, changes: CellChangeIf[]);
|
|
24
|
+
get cellCount(): number;
|
|
25
|
+
/**
|
|
26
|
+
* Adds cells written by the same user action (an `onModelChanged` handler that derives values) to this step.
|
|
27
|
+
*
|
|
28
|
+
* @param {CellChangeIf[]} changes - the written cells
|
|
29
|
+
*/
|
|
30
|
+
append(changes: CellChangeIf[]): void;
|
|
31
|
+
undo(scope: TableScope): UndoResultIf;
|
|
32
|
+
redo(scope: TableScope): UndoResultIf;
|
|
33
|
+
private apply;
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rows array of a body model (object array: `getAllRows`, row grouping: `getSourceRows`, array of arrays: `arr`,
|
|
3
|
+
* tree: its root rows) – another array means `setRows` replaced the data.
|
|
4
|
+
*
|
|
5
|
+
* @param {unknown} body - the body area model
|
|
6
|
+
* @returns {unknown[] | undefined} the array, `undefined` for models that can't tell
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function rowsArrayOf(body: unknown): unknown[] | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* All row objects of a body model, also filtered and collapsed ones (tree: the data of every node).
|
|
12
|
+
*
|
|
13
|
+
* @param {unknown} body - the body area model
|
|
14
|
+
* @returns {Set<unknown> | null} the rows, `null` for models that can't tell
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function allRowObjectsOf(body: unknown): Set<unknown> | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { TableScope } from '../table-scope.js';
|
|
2
|
+
import { CellChangeSource } from '../batch-edit/cell-change.if.js';
|
|
3
|
+
import { PendingCellIf } from '../batch-edit/pending-cell-changes.js';
|
|
4
|
+
import { UndoableIf, UndoResultIf } from './undoable.if.js';
|
|
5
|
+
|
|
6
|
+
/** One cell of a batch edit step: its pending entry before and after (none = not pending). */
|
|
7
|
+
export interface PendingSnapshotIf {
|
|
8
|
+
rowKey: unknown;
|
|
9
|
+
property: string;
|
|
10
|
+
before?: PendingCellIf;
|
|
11
|
+
after?: PendingCellIf;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A step of a batch edit (values marked, not written): undo restores the pending state before the step, redo the one
|
|
15
|
+
* after it. A cell whose pending value changed since then is skipped (`onConflict: "skip"`). Commit and cancel of the
|
|
16
|
+
* batch edit empty the history.
|
|
17
|
+
*
|
|
18
|
+
* @category Spreadsheet
|
|
19
|
+
* @since 1.1.99
|
|
20
|
+
*/
|
|
21
|
+
export declare class PendingChangesUndoable implements UndoableIf {
|
|
22
|
+
readonly label: string;
|
|
23
|
+
readonly source: CellChangeSource;
|
|
24
|
+
private readonly cells;
|
|
25
|
+
/**
|
|
26
|
+
* @param {string} label - for buttons and announcements
|
|
27
|
+
* @param {CellChangeSource} source - what started the step
|
|
28
|
+
* @param {PendingSnapshotIf[]} cells - the pending entries before and after
|
|
29
|
+
*/
|
|
30
|
+
constructor(label: string, source: CellChangeSource, cells: PendingSnapshotIf[]);
|
|
31
|
+
get cellCount(): number;
|
|
32
|
+
undo(scope: TableScope): UndoResultIf;
|
|
33
|
+
redo(scope: TableScope): UndoResultIf;
|
|
34
|
+
private apply;
|
|
35
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ShortcutActionIdMapping } from '../action/shortcut-actionid-mapping.type.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The keys of undo and redo ({@link TableOptionsIf.undo}) – a layer over the system mapping that the table only uses
|
|
5
|
+
* with the option; `tableOptions.shortcutActionIdMapping` still overrides it. In an open editor the keys belong to
|
|
6
|
+
* the editor (the browser's text undo).
|
|
7
|
+
*
|
|
8
|
+
* @param {boolean} mac - macOS keys (⌘+Z, ⌘+Shift+Z)
|
|
9
|
+
* @returns {ShortcutActionIdMapping} the layer
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* undoShortcutLayer(false)["ctrl+y"]; // "REDO"
|
|
13
|
+
*
|
|
14
|
+
* @category Spreadsheet
|
|
15
|
+
* @since 1.1.99
|
|
16
|
+
*/
|
|
17
|
+
export declare function undoShortcutLayer(mac: boolean): ShortcutActionIdMapping;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { UndoOptionsIf } from './undo-options.if.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The defaults of {@link UndoOptionsIf} (undo and redo, {@link TableOptionsIf.undo}).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const options = UndoOptions.create({ maxSteps: 20 });
|
|
8
|
+
* options?.onConflict; // "skip"
|
|
9
|
+
*
|
|
10
|
+
* @category Spreadsheet
|
|
11
|
+
* @since 1.1.99
|
|
12
|
+
*/
|
|
13
|
+
export declare class UndoOptions implements UndoOptionsIf {
|
|
14
|
+
maxSteps: number;
|
|
15
|
+
maxCells: number;
|
|
16
|
+
onConflict: "skip" | "overwrite";
|
|
17
|
+
recordApiChanges: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The options of {@link TableOptionsIf.undo}: `undefined`/`false` = off, `true` = the defaults, an object = the
|
|
20
|
+
* defaults overridden by its values (`undefined` keeps the default).
|
|
21
|
+
*
|
|
22
|
+
* @param {boolean | Partial<UndoOptionsIf>} [option] - `tableOptions.undo`
|
|
23
|
+
* @returns {UndoOptionsIf | undefined} complete options, `undefined` if undo is off
|
|
24
|
+
*/
|
|
25
|
+
static create(option?: boolean | Partial<UndoOptionsIf>): UndoOptionsIf | undefined;
|
|
26
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Undo and redo ({@link TableOptionsIf.undo}). `undo: true` uses the defaults of {@link UndoOptions}; an object
|
|
3
|
+
* overrides single values.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const tableOptions: TableOptionsIf = {
|
|
7
|
+
* ...new TableOptions(),
|
|
8
|
+
* editing: true,
|
|
9
|
+
* undo: { maxSteps: 50, onConflict: "overwrite" },
|
|
10
|
+
* };
|
|
11
|
+
*
|
|
12
|
+
* @category Spreadsheet
|
|
13
|
+
* @since 1.1.99
|
|
14
|
+
*/
|
|
15
|
+
export interface UndoOptionsIf {
|
|
16
|
+
/** Steps kept; the oldest is dropped. Default `100`. */
|
|
17
|
+
maxSteps: number;
|
|
18
|
+
/**
|
|
19
|
+
* Cells kept over all steps (the oldest steps are dropped). A single change with more cells empties the history
|
|
20
|
+
* and is announced – it cannot be undone. Default `1_000_000`.
|
|
21
|
+
*/
|
|
22
|
+
maxCells: number;
|
|
23
|
+
/**
|
|
24
|
+
* A cell changed by something else since the step (live data, `updateCells`): `"skip"` leaves it and announces it
|
|
25
|
+
* (default, safe), `"overwrite"` writes anyway.
|
|
26
|
+
*/
|
|
27
|
+
onConflict: "skip" | "overwrite";
|
|
28
|
+
/** Record `api.applyCellChanges(…)` with source `"api"` too. Default `false` (per call: `{ undoable: true }`). */
|
|
29
|
+
recordApiChanges: boolean;
|
|
30
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { TableScope } from '../table-scope.js';
|
|
2
|
+
import { UndoOptionsIf } from './undo-options.if.js';
|
|
3
|
+
import { UndoableIf } from './undoable.if.js';
|
|
4
|
+
import { CellChangeIf, CellChangeSource } from '../batch-edit/cell-change.if.js';
|
|
5
|
+
import { PendingSnapshotIf } from './pending-changes-undoable.js';
|
|
6
|
+
import { GeUndoEvent } from '../data/common/event/ge-undo-event.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Undo and redo ({@link TableOptionsIf.undo}, `tableScope.undoService`, only with the option): records every change
|
|
10
|
+
* that goes through the table's one write path (editor, fill handle, paste, cut, Delete; `api.applyCellChanges` only
|
|
11
|
+
* with `recordApiChanges` or `{ undoable: true }`) as one step, and marked values of a batch edit. Not recorded:
|
|
12
|
+
* `updateCells`, `setRows` (the history is emptied when the rows array is replaced), sorting, filter, row drag.
|
|
13
|
+
*
|
|
14
|
+
* @category Internals
|
|
15
|
+
* @since 1.1.99
|
|
16
|
+
*/
|
|
17
|
+
export declare class UndoService {
|
|
18
|
+
private readonly tableScope;
|
|
19
|
+
readonly options: UndoOptionsIf;
|
|
20
|
+
private readonly stack;
|
|
21
|
+
private group?;
|
|
22
|
+
/** An undo or redo is running: its writes (also of event handlers) are not recorded. */
|
|
23
|
+
private running;
|
|
24
|
+
/** The step whose `onModelChanged` is being reported: writes of handlers are added to it. */
|
|
25
|
+
private folding?;
|
|
26
|
+
private foldDepth;
|
|
27
|
+
/** The rows array when the first step was recorded – another array (`setRows`) empties the history. */
|
|
28
|
+
private rowsRef?;
|
|
29
|
+
/**
|
|
30
|
+
* @param {TableScope} tableScope - the table
|
|
31
|
+
* @param {UndoOptionsIf} options - complete options
|
|
32
|
+
*/
|
|
33
|
+
constructor(tableScope: TableScope, options: UndoOptionsIf);
|
|
34
|
+
/**
|
|
35
|
+
* Records an own step (e.g. inserting rows) – not while an undo or redo runs.
|
|
36
|
+
*
|
|
37
|
+
* @param {UndoableIf} step - the step
|
|
38
|
+
* @since 1.1.99
|
|
39
|
+
*/
|
|
40
|
+
addStep(step: UndoableIf): void;
|
|
41
|
+
/**
|
|
42
|
+
* Records written cells as a step (called by the table's write path).
|
|
43
|
+
*
|
|
44
|
+
* @param {CellChangeIf[]} changes - the written cells
|
|
45
|
+
* @param {CellChangeSource} source - what wrote them
|
|
46
|
+
* @param {boolean} [undoable] - `api.applyCellChanges(…, { undoable })`: overrides `recordApiChanges`
|
|
47
|
+
*/
|
|
48
|
+
record(changes: CellChangeIf[], source: CellChangeSource, undoable?: boolean): void;
|
|
49
|
+
/** The step recorded last (for {@link beginFold}). */
|
|
50
|
+
private lastRecorded?;
|
|
51
|
+
/**
|
|
52
|
+
* The table reports the write that was just recorded (`onModelChanged`): writes of handlers until {@link endFold}
|
|
53
|
+
* belong to the same step.
|
|
54
|
+
*/
|
|
55
|
+
beginFold(): void;
|
|
56
|
+
/** End of {@link beginFold}. */
|
|
57
|
+
endFold(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Records marked values of a batch edit as a step (called by the table).
|
|
60
|
+
*
|
|
61
|
+
* @param {PendingSnapshotIf[]} cells - pending entries before and after
|
|
62
|
+
* @param {CellChangeSource} source - what marked them
|
|
63
|
+
* @param {boolean} [undoable] - as in {@link record}
|
|
64
|
+
*/
|
|
65
|
+
recordPending(cells: PendingSnapshotIf[], source: CellChangeSource, undoable?: boolean): void;
|
|
66
|
+
/**
|
|
67
|
+
* Records everything `fn` changes as one step (see {@link TableApi.batchUndoable}).
|
|
68
|
+
*
|
|
69
|
+
* @param {string} label - the label of the step
|
|
70
|
+
* @param {() => T} fn - the changes
|
|
71
|
+
* @returns {T} what `fn` returns
|
|
72
|
+
*/
|
|
73
|
+
batch<T>(label: string, fn: () => T): T;
|
|
74
|
+
/**
|
|
75
|
+
* Undoes the last step: writes the old values back (source `"undo"`), selects the cells, announces it.
|
|
76
|
+
*
|
|
77
|
+
* @returns {boolean} true if a step was undone
|
|
78
|
+
*/
|
|
79
|
+
undo(): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Redoes the last undone step (source `"redo"`).
|
|
82
|
+
*
|
|
83
|
+
* @returns {boolean} true if a step was redone
|
|
84
|
+
*/
|
|
85
|
+
redo(): boolean;
|
|
86
|
+
/** @returns {boolean} true if there is a step to undo */
|
|
87
|
+
canUndo(): boolean;
|
|
88
|
+
/** @returns {boolean} true if there is a step to redo */
|
|
89
|
+
canRedo(): boolean;
|
|
90
|
+
/** @returns {GeUndoEvent} the state of the history (for buttons) */
|
|
91
|
+
getState(): GeUndoEvent;
|
|
92
|
+
/** Empties the history (batch commit/cancel, {@link TableApi.clearUndoHistory}). */
|
|
93
|
+
clear(silent?: boolean): void;
|
|
94
|
+
private add;
|
|
95
|
+
private run;
|
|
96
|
+
/**
|
|
97
|
+
* `setRows` (or `api.addRows`/`removeRows`, which build a new array) replaced the rows array: the steps point to rows
|
|
98
|
+
* that may be gone – the history is emptied (silently when asked by a getter; the next change reports it).
|
|
99
|
+
*/
|
|
100
|
+
private checkRows;
|
|
101
|
+
private currentRows;
|
|
102
|
+
private fire;
|
|
103
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The undo and redo stacks of steps (DOM-free): a new step clears the redo stack; at most `maxSteps` steps and
|
|
3
|
+
* `maxCells` cells (over both stacks) are kept – the oldest go first; a single step with more than `maxCells` cells
|
|
4
|
+
* empties the history and is not kept.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const stack = new UndoStack<{ cellCount: number; label: string }>(100, 1_000_000);
|
|
8
|
+
* stack.push({ cellCount: 1, label: "Edit" });
|
|
9
|
+
* stack.undo()?.label; // "Edit" – now on the redo stack
|
|
10
|
+
* stack.canRedo(); // true
|
|
11
|
+
*
|
|
12
|
+
* @category Spreadsheet
|
|
13
|
+
* @since 1.1.99
|
|
14
|
+
*/
|
|
15
|
+
export declare class UndoStack<T extends {
|
|
16
|
+
readonly cellCount: number;
|
|
17
|
+
}> {
|
|
18
|
+
private readonly maxSteps;
|
|
19
|
+
private readonly maxCells;
|
|
20
|
+
private readonly undoSteps;
|
|
21
|
+
private readonly redoSteps;
|
|
22
|
+
private cells;
|
|
23
|
+
/**
|
|
24
|
+
* @param {number} maxSteps - steps kept on the undo stack
|
|
25
|
+
* @param {number} maxCells - cells kept over both stacks
|
|
26
|
+
*/
|
|
27
|
+
constructor(maxSteps: number, maxCells: number);
|
|
28
|
+
/**
|
|
29
|
+
* Adds a step and clears the redo stack.
|
|
30
|
+
*
|
|
31
|
+
* @param {T} step - the new step
|
|
32
|
+
* @returns {boolean} false if the step was too large (the history is empty now)
|
|
33
|
+
*/
|
|
34
|
+
push(step: T): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Takes the last step for undo (it moves to the redo stack).
|
|
37
|
+
*
|
|
38
|
+
* @returns {T | undefined} the step, `undefined` if there is none
|
|
39
|
+
*/
|
|
40
|
+
undo(): T | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Takes the last undone step for redo (it moves back to the undo stack).
|
|
43
|
+
*
|
|
44
|
+
* @returns {T | undefined} the step, `undefined` if there is none
|
|
45
|
+
*/
|
|
46
|
+
redo(): T | undefined;
|
|
47
|
+
/** @returns {T | undefined} the step the next undo takes */
|
|
48
|
+
peekUndo(): T | undefined;
|
|
49
|
+
/** @returns {T | undefined} the step the next redo takes */
|
|
50
|
+
peekRedo(): T | undefined;
|
|
51
|
+
/** @returns {boolean} true if there is a step to undo */
|
|
52
|
+
canUndo(): boolean;
|
|
53
|
+
/** @returns {boolean} true if there is a step to redo */
|
|
54
|
+
canRedo(): boolean;
|
|
55
|
+
/** @returns {number} steps on the undo stack */
|
|
56
|
+
size(): number;
|
|
57
|
+
/** @returns {number} cells kept over both stacks */
|
|
58
|
+
cellCount(): number;
|
|
59
|
+
/** Empties both stacks. */
|
|
60
|
+
clear(): void;
|
|
61
|
+
private clearRedo;
|
|
62
|
+
}
|