@xlsx-editor.dev/core 0.0.0-placeholder.0 → 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +217 -0
- package/README.md +254 -2
- package/THIRD_PARTY_NOTICES.md +78 -0
- package/dist/automation.d.ts +299 -0
- package/dist/automation.js +42 -0
- package/dist/builtins-nmHrq2Et.d.ts +37 -0
- package/dist/cascade.d.ts +196 -0
- package/dist/cascade.js +60 -0
- package/dist/cell-format-DW8yF-c-.d.ts +226 -0
- package/dist/chunk-2DLJYRJC.js +3171 -0
- package/dist/chunk-2ZU4337U.js +204 -0
- package/dist/chunk-44L37ENZ.js +8219 -0
- package/dist/chunk-77N55BLP.js +911 -0
- package/dist/chunk-7PV5HQPE.js +84 -0
- package/dist/chunk-E4VJJ556.js +756 -0
- package/dist/chunk-KG4IL4JI.js +436 -0
- package/dist/chunk-PLDK4XO6.js +9125 -0
- package/dist/chunk-PRHLYXHL.js +1699 -0
- package/dist/chunk-TE4FXG5T.js +3156 -0
- package/dist/contracts.d.ts +32 -0
- package/dist/contracts.js +0 -0
- package/dist/dist-C7NLNUMD.js +2850 -0
- package/dist/editor.d.ts +3167 -0
- package/dist/editor.js +309 -0
- package/dist/harfbuzz-measurer-CkKfsEyu.d.ts +128 -0
- package/dist/harfbuzz.wasm +0 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +309 -0
- package/dist/layout.d.ts +111 -0
- package/dist/layout.js +104 -0
- package/dist/merge-commands-DthcNpfw.d.ts +53 -0
- package/dist/node-module-shim-LQXGL47O.js +18 -0
- package/dist/ops-CfUCjyph.d.ts +629 -0
- package/dist/output.d.ts +177 -0
- package/dist/output.js +29 -0
- package/dist/sheet-index-P5vevMWX.d.ts +52 -0
- package/dist/sheet-layout-D9M_4EBn.d.ts +494 -0
- package/dist/sheet-protection-D8goxm58.d.ts +209 -0
- package/dist/store.d.ts +615 -0
- package/dist/store.js +272 -0
- package/dist/theme-BprDji6x.d.ts +16 -0
- package/dist/units-D6CD_A5I.d.ts +13 -0
- package/dist/workbook-index-DsbeR8Kb.d.ts +294 -0
- package/licenses/Emscripten-LICENSE.txt +102 -0
- package/licenses/HarfBuzz-COPYING.txt +42 -0
- package/licenses/HarfBuzz-USE-MIT.txt +21 -0
- package/licenses/HarfBuzz-source-notices.txt +4508 -0
- package/licenses/README.md +19 -0
- package/licenses/Unicode-LICENSE.txt +39 -0
- package/licenses/compiler-rt-LICENSE.txt +311 -0
- package/licenses/harfbuzz-manifest.json +84 -0
- package/licenses/musl-COPYRIGHT.txt +193 -0
- package/package.json +79 -6
- package/src/styles/editor.css +1933 -0
- package/src/styles/editor.css.d.ts +2 -0
package/dist/editor.d.ts
ADDED
|
@@ -0,0 +1,3167 @@
|
|
|
1
|
+
import { GridPoint, GridSelection } from './contracts.js';
|
|
2
|
+
export { GridRange } from './contracts.js';
|
|
3
|
+
import { g as SheetProtection, W as WorkbookProtection } from './sheet-protection-D8goxm58.js';
|
|
4
|
+
export { C as CellAddress, M as MAX_COLS, a as MAX_COLUMN_WIDTH, b as MAX_FORMAT_NEW_CELLS, c as MAX_RESIZE_NEW_ROWS, d as MAX_ROWS, e as MAX_ROW_HEIGHT, f as ResourceLimits, l as columnLetters, n as formatCellRef, q as parseCellRef, v as resolveLimits } from './sheet-protection-D8goxm58.js';
|
|
5
|
+
import { F as FormatPatch, j as StructureSubject, C as CellInput } from './ops-CfUCjyph.js';
|
|
6
|
+
export { P as PATCH_BORDER_STYLES, c as PATCH_HORIZONTAL, d as PATCH_VERTICAL, e as PatchBorderStyle, g as PatchHorizontal, h as PatchVertical, i as STRUCTURE_SUBJECT_KINDS, k as StructureSubjectKind } from './ops-CfUCjyph.js';
|
|
7
|
+
export { p as pixelsToPoints, a as pointsToPixels } from './units-D6CD_A5I.js';
|
|
8
|
+
import { c as FontSource } from './harfbuzz-measurer-CkKfsEyu.js';
|
|
9
|
+
import { N as NumberLocale } from './builtins-nmHrq2Et.js';
|
|
10
|
+
export { s as sameNumberLocale } from './builtins-nmHrq2Et.js';
|
|
11
|
+
import { F as FormatToggle, M as MergeOptions } from './merge-commands-DthcNpfw.js';
|
|
12
|
+
import './workbook-index-DsbeR8Kb.js';
|
|
13
|
+
import './sheet-index-P5vevMWX.js';
|
|
14
|
+
import './cell-format-DW8yF-c-.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* How a control reaches the engine, never whether it is enabled. `command`: a press runs one
|
|
18
|
+
* fixed command. `value`: a press needs a picked value (a font, a size, a color, a number
|
|
19
|
+
* format). `save`: the host receives the workbook bytes.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
type ChromeControlKind = 'command' | 'value' | 'save';
|
|
24
|
+
/**
|
|
25
|
+
* How a control renders: an icon button, a dropdown list of values, a color palette, or a
|
|
26
|
+
* button that opens a dialog. A `dialog` control is a `value` control: the dialog produces the
|
|
27
|
+
* value, and its apply runs the slot with it. DOCX Editor's `paragraph.dialog` is a `command`
|
|
28
|
+
* slot with no fixed command; a `value` slot here says that a bare press has nothing to send.
|
|
29
|
+
* DOCX Editor draws that slot with the `icon` shape. Here `dialog` tells a host that walks
|
|
30
|
+
* the registry to render a dialog opener (`aria-haspopup="dialog"`), not a command button.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
type ChromeControlShape = 'icon' | 'dropdown' | 'color' | 'dialog';
|
|
35
|
+
/**
|
|
36
|
+
* One toolbar control: what it renders as and how it reaches the engine.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
interface ChromeControl<Id extends string = string> {
|
|
41
|
+
/** Unique within its group. Public API: renames are breaking. */
|
|
42
|
+
readonly id: Id;
|
|
43
|
+
/** `icon` when absent. */
|
|
44
|
+
readonly shape?: ChromeControlShape;
|
|
45
|
+
/** The catalog key of the accessible name and the tooltip. */
|
|
46
|
+
readonly labelKey: string;
|
|
47
|
+
/** Material Symbols path data (view box `0 -960 960 960`), or null for a picker or a menu item. */
|
|
48
|
+
readonly paths: readonly string[] | null;
|
|
49
|
+
readonly kind: ChromeControlKind;
|
|
50
|
+
/** The control shows a pressed state (`aria-pressed`). */
|
|
51
|
+
readonly toggle?: true;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* One toolbar group, in bar order. The adapters build the default toolbar by walking
|
|
55
|
+
* `CHROME_GROUPS`, never by listing controls by hand.
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
interface ChromeGroup<Id extends string = string, ControlId extends string = string> {
|
|
60
|
+
/** Public API: renames are breaking. */
|
|
61
|
+
readonly id: Id;
|
|
62
|
+
/** The catalog key of the group's name. */
|
|
63
|
+
readonly labelKey: string;
|
|
64
|
+
/**
|
|
65
|
+
* The default toolbar renders the group as one menu button with this icon, and its controls
|
|
66
|
+
* as the menu's items. The slots stay public: a host can place each one alone.
|
|
67
|
+
*/
|
|
68
|
+
readonly menu?: {
|
|
69
|
+
readonly paths: readonly string[];
|
|
70
|
+
};
|
|
71
|
+
readonly controls: readonly ChromeControl<ControlId>[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The editing chrome, in bar order. Literal-typed, so `ChromeSlotId` is derived from the data
|
|
75
|
+
* and cannot drift from it.
|
|
76
|
+
*
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
declare const CHROME_GROUPS: readonly [{
|
|
80
|
+
readonly id: 'history';
|
|
81
|
+
readonly labelKey: 'formattingBar.groups.history';
|
|
82
|
+
readonly controls: readonly [{
|
|
83
|
+
readonly id: 'undo';
|
|
84
|
+
readonly labelKey: 'formattingBar.undo';
|
|
85
|
+
readonly paths: readonly string[];
|
|
86
|
+
readonly kind: 'command';
|
|
87
|
+
}, {
|
|
88
|
+
readonly id: 'redo';
|
|
89
|
+
readonly labelKey: 'formattingBar.redo';
|
|
90
|
+
readonly paths: readonly string[];
|
|
91
|
+
readonly kind: 'command';
|
|
92
|
+
}];
|
|
93
|
+
}, {
|
|
94
|
+
readonly id: 'font';
|
|
95
|
+
readonly labelKey: 'formattingBar.groups.font';
|
|
96
|
+
readonly controls: readonly [{
|
|
97
|
+
readonly id: 'family';
|
|
98
|
+
readonly shape: 'dropdown';
|
|
99
|
+
readonly labelKey: 'font.selectAriaLabel';
|
|
100
|
+
readonly paths: null;
|
|
101
|
+
readonly kind: 'value';
|
|
102
|
+
}, {
|
|
103
|
+
readonly id: 'size';
|
|
104
|
+
readonly shape: 'dropdown';
|
|
105
|
+
readonly labelKey: 'fontSize.label';
|
|
106
|
+
readonly paths: null;
|
|
107
|
+
readonly kind: 'value';
|
|
108
|
+
}, {
|
|
109
|
+
readonly id: 'bold';
|
|
110
|
+
readonly labelKey: 'formattingBar.bold';
|
|
111
|
+
readonly paths: readonly string[];
|
|
112
|
+
readonly kind: 'command';
|
|
113
|
+
readonly toggle: true;
|
|
114
|
+
}, {
|
|
115
|
+
readonly id: 'italic';
|
|
116
|
+
readonly labelKey: 'formattingBar.italic';
|
|
117
|
+
readonly paths: readonly string[];
|
|
118
|
+
readonly kind: 'command';
|
|
119
|
+
readonly toggle: true;
|
|
120
|
+
}, {
|
|
121
|
+
readonly id: 'underline';
|
|
122
|
+
readonly labelKey: 'formattingBar.underline';
|
|
123
|
+
readonly paths: readonly string[];
|
|
124
|
+
readonly kind: 'command';
|
|
125
|
+
readonly toggle: true;
|
|
126
|
+
}, {
|
|
127
|
+
readonly id: 'color';
|
|
128
|
+
readonly shape: 'color';
|
|
129
|
+
readonly labelKey: 'formattingBar.fontColor';
|
|
130
|
+
readonly paths: readonly string[];
|
|
131
|
+
readonly kind: 'value';
|
|
132
|
+
}];
|
|
133
|
+
}, {
|
|
134
|
+
readonly id: 'fill';
|
|
135
|
+
readonly labelKey: 'formattingBar.groups.fill';
|
|
136
|
+
readonly controls: readonly [{
|
|
137
|
+
readonly id: 'color';
|
|
138
|
+
readonly shape: 'color';
|
|
139
|
+
readonly labelKey: 'formattingBar.fillColor';
|
|
140
|
+
readonly paths: readonly string[];
|
|
141
|
+
readonly kind: 'value';
|
|
142
|
+
}];
|
|
143
|
+
}, {
|
|
144
|
+
readonly id: 'borders';
|
|
145
|
+
readonly labelKey: 'formattingBar.groups.borders';
|
|
146
|
+
readonly controls: readonly [{
|
|
147
|
+
readonly id: 'outline';
|
|
148
|
+
readonly labelKey: 'borders.outline';
|
|
149
|
+
readonly paths: readonly string[];
|
|
150
|
+
readonly kind: 'command';
|
|
151
|
+
}, {
|
|
152
|
+
readonly id: 'all';
|
|
153
|
+
readonly labelKey: 'borders.all';
|
|
154
|
+
readonly paths: readonly string[];
|
|
155
|
+
readonly kind: 'command';
|
|
156
|
+
}, {
|
|
157
|
+
readonly id: 'none';
|
|
158
|
+
readonly labelKey: 'borders.none';
|
|
159
|
+
readonly paths: readonly string[];
|
|
160
|
+
readonly kind: 'command';
|
|
161
|
+
}];
|
|
162
|
+
}, {
|
|
163
|
+
readonly id: 'alignment';
|
|
164
|
+
readonly labelKey: 'formattingBar.groups.alignment';
|
|
165
|
+
readonly controls: readonly [{
|
|
166
|
+
readonly id: 'left';
|
|
167
|
+
readonly labelKey: 'alignment.alignLeft';
|
|
168
|
+
readonly paths: readonly string[];
|
|
169
|
+
readonly kind: 'command';
|
|
170
|
+
readonly toggle: true;
|
|
171
|
+
}, {
|
|
172
|
+
readonly id: 'center';
|
|
173
|
+
readonly labelKey: 'alignment.center';
|
|
174
|
+
readonly paths: readonly string[];
|
|
175
|
+
readonly kind: 'command';
|
|
176
|
+
readonly toggle: true;
|
|
177
|
+
}, {
|
|
178
|
+
readonly id: 'right';
|
|
179
|
+
readonly labelKey: 'alignment.alignRight';
|
|
180
|
+
readonly paths: readonly string[];
|
|
181
|
+
readonly kind: 'command';
|
|
182
|
+
readonly toggle: true;
|
|
183
|
+
}, {
|
|
184
|
+
readonly id: 'top';
|
|
185
|
+
readonly labelKey: 'alignment.alignTop';
|
|
186
|
+
readonly paths: readonly string[];
|
|
187
|
+
readonly kind: 'command';
|
|
188
|
+
readonly toggle: true;
|
|
189
|
+
}, {
|
|
190
|
+
readonly id: 'middle';
|
|
191
|
+
readonly labelKey: 'alignment.alignMiddle';
|
|
192
|
+
readonly paths: readonly string[];
|
|
193
|
+
readonly kind: 'command';
|
|
194
|
+
readonly toggle: true;
|
|
195
|
+
}, {
|
|
196
|
+
readonly id: 'bottom';
|
|
197
|
+
readonly labelKey: 'alignment.alignBottom';
|
|
198
|
+
readonly paths: readonly string[];
|
|
199
|
+
readonly kind: 'command';
|
|
200
|
+
readonly toggle: true;
|
|
201
|
+
}, {
|
|
202
|
+
readonly id: 'wrap';
|
|
203
|
+
readonly labelKey: 'alignment.wrapText';
|
|
204
|
+
readonly paths: readonly string[];
|
|
205
|
+
readonly kind: 'command';
|
|
206
|
+
readonly toggle: true;
|
|
207
|
+
}];
|
|
208
|
+
}, {
|
|
209
|
+
readonly id: 'number';
|
|
210
|
+
readonly labelKey: 'formattingBar.groups.number';
|
|
211
|
+
readonly controls: readonly [{
|
|
212
|
+
readonly id: 'format';
|
|
213
|
+
readonly shape: 'dropdown';
|
|
214
|
+
readonly labelKey: 'numberFormat.label';
|
|
215
|
+
readonly paths: null;
|
|
216
|
+
readonly kind: 'value';
|
|
217
|
+
}, {
|
|
218
|
+
readonly id: 'custom';
|
|
219
|
+
readonly shape: 'dialog';
|
|
220
|
+
readonly labelKey: 'numberFormat.more';
|
|
221
|
+
readonly paths: readonly string[];
|
|
222
|
+
readonly kind: 'value';
|
|
223
|
+
}, {
|
|
224
|
+
readonly id: 'increaseDecimals';
|
|
225
|
+
readonly labelKey: 'numberFormat.increaseDecimals';
|
|
226
|
+
readonly paths: readonly string[];
|
|
227
|
+
readonly kind: 'command';
|
|
228
|
+
}, {
|
|
229
|
+
readonly id: 'decreaseDecimals';
|
|
230
|
+
readonly labelKey: 'numberFormat.decreaseDecimals';
|
|
231
|
+
readonly paths: readonly string[];
|
|
232
|
+
readonly kind: 'command';
|
|
233
|
+
}];
|
|
234
|
+
}, {
|
|
235
|
+
readonly id: 'cells';
|
|
236
|
+
readonly labelKey: 'formattingBar.groups.cells';
|
|
237
|
+
readonly menu: {
|
|
238
|
+
readonly paths: readonly string[];
|
|
239
|
+
};
|
|
240
|
+
readonly controls: readonly [{
|
|
241
|
+
readonly id: 'insertRows';
|
|
242
|
+
readonly labelKey: 'cells.insertRows';
|
|
243
|
+
readonly paths: readonly string[];
|
|
244
|
+
readonly kind: 'command';
|
|
245
|
+
}, {
|
|
246
|
+
readonly id: 'insertColumns';
|
|
247
|
+
readonly labelKey: 'cells.insertColumns';
|
|
248
|
+
readonly paths: readonly string[];
|
|
249
|
+
readonly kind: 'command';
|
|
250
|
+
}, {
|
|
251
|
+
readonly id: 'deleteRows';
|
|
252
|
+
readonly labelKey: 'cells.deleteRows';
|
|
253
|
+
readonly paths: null;
|
|
254
|
+
readonly kind: 'command';
|
|
255
|
+
}, {
|
|
256
|
+
readonly id: 'deleteColumns';
|
|
257
|
+
readonly labelKey: 'cells.deleteColumns';
|
|
258
|
+
readonly paths: null;
|
|
259
|
+
readonly kind: 'command';
|
|
260
|
+
}];
|
|
261
|
+
}, {
|
|
262
|
+
readonly id: 'clear';
|
|
263
|
+
readonly labelKey: 'formattingBar.groups.clear';
|
|
264
|
+
readonly menu: {
|
|
265
|
+
readonly paths: readonly string[];
|
|
266
|
+
};
|
|
267
|
+
readonly controls: readonly [{
|
|
268
|
+
readonly id: 'contents';
|
|
269
|
+
readonly labelKey: 'clear.contents';
|
|
270
|
+
readonly paths: null;
|
|
271
|
+
readonly kind: 'command';
|
|
272
|
+
}, {
|
|
273
|
+
readonly id: 'formats';
|
|
274
|
+
readonly labelKey: 'clear.formats';
|
|
275
|
+
readonly paths: readonly string[];
|
|
276
|
+
readonly kind: 'command';
|
|
277
|
+
}, {
|
|
278
|
+
readonly id: 'all';
|
|
279
|
+
readonly labelKey: 'clear.all';
|
|
280
|
+
readonly paths: null;
|
|
281
|
+
readonly kind: 'command';
|
|
282
|
+
}];
|
|
283
|
+
}, {
|
|
284
|
+
readonly id: 'file';
|
|
285
|
+
readonly labelKey: 'formattingBar.groups.file';
|
|
286
|
+
readonly controls: readonly [{
|
|
287
|
+
readonly id: 'save';
|
|
288
|
+
readonly labelKey: 'toolbar.save';
|
|
289
|
+
readonly paths: readonly string[];
|
|
290
|
+
readonly kind: 'save';
|
|
291
|
+
}];
|
|
292
|
+
}];
|
|
293
|
+
/**
|
|
294
|
+
* A group id of `CHROME_GROUPS`.
|
|
295
|
+
*
|
|
296
|
+
* @public
|
|
297
|
+
*/
|
|
298
|
+
type ChromeGroupId = (typeof CHROME_GROUPS)[number]['id'];
|
|
299
|
+
/**
|
|
300
|
+
* The slot ids of one group of `CHROME_GROUPS`: `${groupId}.${controlId}` for each of its
|
|
301
|
+
* controls. {@link ChromeSlotId} applies it to every group.
|
|
302
|
+
*
|
|
303
|
+
* @public
|
|
304
|
+
*/
|
|
305
|
+
type SlotOf<G> = G extends {
|
|
306
|
+
readonly id: infer GroupId extends string;
|
|
307
|
+
readonly controls: readonly (infer C)[];
|
|
308
|
+
} ? C extends {
|
|
309
|
+
readonly id: infer ControlId extends string;
|
|
310
|
+
} ? `${GroupId}.${ControlId}` : never : never;
|
|
311
|
+
/**
|
|
312
|
+
* The public slot vocabulary: `${groupId}.${controlId}` for every control of
|
|
313
|
+
* `CHROME_GROUPS`, such as `font.bold` or `cells.deleteRows`. Renaming a slot is a breaking
|
|
314
|
+
* change.
|
|
315
|
+
*
|
|
316
|
+
* @public
|
|
317
|
+
*/
|
|
318
|
+
type ChromeSlotId = SlotOf<(typeof CHROME_GROUPS)[number]>;
|
|
319
|
+
/**
|
|
320
|
+
* The slot id of a control of a group.
|
|
321
|
+
*
|
|
322
|
+
* @public
|
|
323
|
+
*/
|
|
324
|
+
declare function chromeSlotId(group: {
|
|
325
|
+
readonly id: string;
|
|
326
|
+
}, control: {
|
|
327
|
+
readonly id: string;
|
|
328
|
+
}): ChromeSlotId;
|
|
329
|
+
/** Every slot of the registry, in bar order. @public */
|
|
330
|
+
declare const CHROME_SLOT_IDS: readonly ChromeSlotId[];
|
|
331
|
+
/** The registry control of a slot, or null for an id that the registry does not hold. @public */
|
|
332
|
+
declare function chromeControlForSlot(slot: string): ChromeControl | null;
|
|
333
|
+
|
|
334
|
+
/** How an edit started: by typing (arrows commit) or with F2 (arrows move the caret). */
|
|
335
|
+
type CellEditMode = 'enter' | 'edit';
|
|
336
|
+
/**
|
|
337
|
+
* Where `commitEdit` moves the active cell after the commit: as Enter (`down`), Shift+Enter
|
|
338
|
+
* (`up`), Tab (`right`), and Shift+Tab (`left`).
|
|
339
|
+
*
|
|
340
|
+
* @public
|
|
341
|
+
*/
|
|
342
|
+
type EditMove = 'down' | 'up' | 'right' | 'left';
|
|
343
|
+
/**
|
|
344
|
+
* The options of `setEditText`.
|
|
345
|
+
*
|
|
346
|
+
* @public
|
|
347
|
+
*/
|
|
348
|
+
interface EditTextOptions {
|
|
349
|
+
/**
|
|
350
|
+
* Whether an input method composes in the field that calls `setEditText`. While it is true,
|
|
351
|
+
* each command that would commit the open edit is refused with `composing`.
|
|
352
|
+
*/
|
|
353
|
+
readonly composing?: boolean;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* The most UTF-16 code units of a cell's text that a content field holds. Each layout of a page
|
|
357
|
+
* reads the whole text of its fields, so a longer text shows shortened and read-only there.
|
|
358
|
+
*
|
|
359
|
+
* @public
|
|
360
|
+
*/
|
|
361
|
+
declare const MAX_CONTENT_FIELD_CHARS = 65536;
|
|
362
|
+
/**
|
|
363
|
+
* The start of `text` that a content field holds, with no half of a surrogate pair at its end.
|
|
364
|
+
* A result that is shorter than `text` is only for reading: the edit keeps the complete text.
|
|
365
|
+
*
|
|
366
|
+
* @public
|
|
367
|
+
*/
|
|
368
|
+
declare function contentFieldText(text: string): string;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* The state of the two decimal steps on a selection: null when at least one cell of the
|
|
372
|
+
* selection can step, or else the refusal that the step gives. The refusal is
|
|
373
|
+
* `decimals-unchanged` or `decimals-too-large`, and its `reason` is the disabled reason of the
|
|
374
|
+
* step's control. `toolbarCommandState` reads it: a host reads the enabled state there.
|
|
375
|
+
*
|
|
376
|
+
* @public
|
|
377
|
+
*/
|
|
378
|
+
interface DecimalSteps {
|
|
379
|
+
/** Null when an increase changes at least one selected cell, or the refusal of the increase. */
|
|
380
|
+
readonly increase: EditRefusal | null;
|
|
381
|
+
/** Null when a decrease changes at least one selected cell, or the refusal of the decrease. */
|
|
382
|
+
readonly decrease: EditRefusal | null;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Translate the labels of the surface of `editor` again and paint it once, after its catalog
|
|
387
|
+
* changed: the grid label, the accessible stale words, and the cell editor label. For the
|
|
388
|
+
* adapters, which change the locale. Returns whether the engine made `editor`. @internal
|
|
389
|
+
*/
|
|
390
|
+
declare function relabelEditor(editor: object): boolean;
|
|
391
|
+
|
|
392
|
+
/** The private clipboard type of a copy: it holds only the token of the copy. @public */
|
|
393
|
+
declare const CLIPBOARD_TYPE = "application/x-xlsx-editor";
|
|
394
|
+
/** What a copy or a cut puts on the clipboard. @public */
|
|
395
|
+
interface ClipboardContent {
|
|
396
|
+
/** Tab-separated shown text, rows joined by CR LF, for `text/plain`. */
|
|
397
|
+
readonly text: string;
|
|
398
|
+
/** The token of the copy, for the type `CLIPBOARD_TYPE`. */
|
|
399
|
+
readonly token: string;
|
|
400
|
+
}
|
|
401
|
+
/** The outcome of a copy or a cut. @public */
|
|
402
|
+
type CopyResult = {
|
|
403
|
+
readonly ok: true;
|
|
404
|
+
readonly content: ClipboardContent;
|
|
405
|
+
} | {
|
|
406
|
+
readonly ok: false;
|
|
407
|
+
readonly refusal: EditRefusal;
|
|
408
|
+
};
|
|
409
|
+
/** What a paste event carries. Every field is untrusted. @public */
|
|
410
|
+
interface PasteData {
|
|
411
|
+
/** The `text/plain` data. */
|
|
412
|
+
readonly text?: string;
|
|
413
|
+
/** The `CLIPBOARD_TYPE` data. */
|
|
414
|
+
readonly token?: string;
|
|
415
|
+
/**
|
|
416
|
+
* Whether the clipboard holds `text/html`: the event's list of types holds it. The HTML itself
|
|
417
|
+
* is never read.
|
|
418
|
+
*/
|
|
419
|
+
readonly html?: boolean;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* What caused a `change` event.
|
|
424
|
+
*
|
|
425
|
+
* @public
|
|
426
|
+
*/
|
|
427
|
+
interface DocumentChange {
|
|
428
|
+
/**
|
|
429
|
+
* `'load'` when a load settles (the workbook opened or the open failed), and `'close'` when
|
|
430
|
+
* the workbook closes. Absent for an edit, an undo, and a redo. Do not start external
|
|
431
|
+
* processing, such as a save to a server, for a change with a `source`.
|
|
432
|
+
*/
|
|
433
|
+
readonly source?: 'load' | 'close';
|
|
434
|
+
/**
|
|
435
|
+
* The content revision after the change, the same number as `snapshot().revision`. It starts
|
|
436
|
+
* again at 0 on each open, so compare it with a revision that you kept only while no change
|
|
437
|
+
* with `source` `'load'` came between them.
|
|
438
|
+
*/
|
|
439
|
+
readonly revision: number;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* What `editor.on(...)` and `useEditorEvent` can subscribe to, and what each handler receives.
|
|
443
|
+
*
|
|
444
|
+
* @public
|
|
445
|
+
*/
|
|
446
|
+
interface EditorEvents {
|
|
447
|
+
/**
|
|
448
|
+
* The workbook content changed: an edit, an undo, or a redo (`snapshot().revision` changed),
|
|
449
|
+
* or a load that settled, or a close (`change.source`). A selection change, a sheet change, a
|
|
450
|
+
* zoom change, and the text of an open cell edit do not fire it. A change to view mode that
|
|
451
|
+
* commits an open changed cell edit fires it for that commit. The root's `onChange` prop
|
|
452
|
+
* differs: it fires after every state change. Read the new state with `snapshot()`.
|
|
453
|
+
*/
|
|
454
|
+
change: (change: DocumentChange) => void;
|
|
455
|
+
/**
|
|
456
|
+
* The shown sheet (`snapshot.activeSheet`) or the selection (`snapshot.selection`) changed,
|
|
457
|
+
* also when a load settles or the workbook closes. State derived from the selection, such as
|
|
458
|
+
* `activeFormat`, does not fire it on its own.
|
|
459
|
+
*/
|
|
460
|
+
selectionChange: (snapshot: EditorSnapshot) => void;
|
|
461
|
+
/**
|
|
462
|
+
* The editor refused a command, an edit, or a save (`snapshot.refusal`). It fires once for
|
|
463
|
+
* each refused command, also when a command is refused again for the same reason. While a
|
|
464
|
+
* load runs, every command is refused with `loading`; such a refusal fires once for each run
|
|
465
|
+
* of the same refused command, and a repeat of it, with the same text, does not fire until
|
|
466
|
+
* another refusal comes between. A save, or another command, fires again. It does not fire
|
|
467
|
+
* again while the same refusal stays in the snapshot, and a load that dropped an open edit
|
|
468
|
+
* fires `edit-dropped` once.
|
|
469
|
+
*/
|
|
470
|
+
rejection: (refusal: EditRefusal, snapshot: EditorSnapshot) => void;
|
|
471
|
+
/** A workbook did not open (`snapshot.failure`, with `snapshot.status` `'failed'`). */
|
|
472
|
+
openFailure: (failure: EditorFailure, snapshot: EditorSnapshot) => void;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* The result of {@link XlsxEditorInstance.saveInTasks}.
|
|
477
|
+
*
|
|
478
|
+
* @public
|
|
479
|
+
*/
|
|
480
|
+
interface SavedWorkbook {
|
|
481
|
+
/** The workbook as bytes of the opened package's kind. */
|
|
482
|
+
readonly bytes: Uint8Array<ArrayBuffer>;
|
|
483
|
+
/** The revision that the bytes hold. A later revision has edits that they do not hold. */
|
|
484
|
+
readonly revision: number;
|
|
485
|
+
/**
|
|
486
|
+
* False when another open, `close()`, or `destroy()` ended this workbook during the save. True
|
|
487
|
+
* does not say that the bytes hold the newest edit: compare `revision` for that.
|
|
488
|
+
*/
|
|
489
|
+
readonly stillOpen: boolean;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* A workbook editor instance.
|
|
493
|
+
*
|
|
494
|
+
* @public
|
|
495
|
+
*/
|
|
496
|
+
interface XlsxEditorInstance {
|
|
497
|
+
/**
|
|
498
|
+
* Open the bytes of a workbook or a template package, in place of the open one. Resolves with
|
|
499
|
+
* the snapshot after the open, or the failure. An open cell edit is dropped when the open
|
|
500
|
+
* starts, without a commit; one with changed text leaves the refusal `edit-dropped`, which
|
|
501
|
+
* the live region announces. The undo history of the old workbook goes when the open
|
|
502
|
+
* settles. Until then, every command, `save` included, is refused with `loading`, `select`
|
|
503
|
+
* and `setActiveSheet` return false, and `setZoom` does nothing. When the open settles, ready
|
|
504
|
+
* or failed, the other refusals clear, and `edit-dropped` (with `editDropped`) stays until
|
|
505
|
+
* the next command after the open, done or refused, an edit that the editor stores, a
|
|
506
|
+
* selection change, or the next open. `close()`
|
|
507
|
+
* drops an edit in the same way. A host that must not lose typed text asks first while
|
|
508
|
+
* `snapshot().editing` and `snapshot().editChanged` are both true.
|
|
509
|
+
*
|
|
510
|
+
* `bytes` is a `Uint8Array` or an `ArrayBuffer`, also an `ArrayBuffer` of another window. A
|
|
511
|
+
* `SharedArrayBuffer` opens from a copy of its bytes. A detached buffer gives no bytes, so the
|
|
512
|
+
* open resolves with the failure `package`. `readXlsx` of the store entry takes a `Uint8Array`
|
|
513
|
+
* only.
|
|
514
|
+
*/
|
|
515
|
+
load(bytes: Uint8Array | ArrayBuffer): Promise<EditorSnapshot>;
|
|
516
|
+
/**
|
|
517
|
+
* Close the open workbook, without a save: the grid, the sheet tabs, and the snapshot show no
|
|
518
|
+
* workbook (`status` `'empty'`), an open cell edit and the undo history are dropped, and a
|
|
519
|
+
* `load` that has not settled yet is dropped too.
|
|
520
|
+
*/
|
|
521
|
+
close(): void;
|
|
522
|
+
/**
|
|
523
|
+
* The faces in force, and the packaged substitute faces that did not load (`fonts` omitted).
|
|
524
|
+
* Empty before the first open loads the faces. A failed substitute face does not fail the
|
|
525
|
+
* open: its text measures and paints with another face.
|
|
526
|
+
*/
|
|
527
|
+
fontReport(): FontReport;
|
|
528
|
+
/** Mount the grid surface in `element`, replacing its children. */
|
|
529
|
+
attach(element: HTMLElement): void;
|
|
530
|
+
/** Unmount the grid surface and keep the workbook; an open edit closes as in `destroy`. */
|
|
531
|
+
detach(): void;
|
|
532
|
+
/** Called after every change of `snapshot()`. Returns the unsubscribe function. */
|
|
533
|
+
subscribe(listener: () => void): () => void;
|
|
534
|
+
/**
|
|
535
|
+
* Call `handler` each time `event` happens, as DOCX Editor's `on`: a content change, a
|
|
536
|
+
* selection change, a refused command, or a failed open (`EditorEvents`). Returns the
|
|
537
|
+
* unsubscribe function. Nothing fires for the state at the call. Unlike `subscribe`, which
|
|
538
|
+
* runs after every state change, each event fires only when its part of the state moves.
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```ts
|
|
542
|
+
* const off = editor.on('change', (change) => {
|
|
543
|
+
* if (!change.source) void upload(editor.save());
|
|
544
|
+
* });
|
|
545
|
+
* ```
|
|
546
|
+
*/
|
|
547
|
+
on<E extends keyof EditorEvents>(event: E, handler: EditorEvents[E]): () => void;
|
|
548
|
+
snapshot(): EditorSnapshot;
|
|
549
|
+
/**
|
|
550
|
+
* Show a sheet by its position in `snapshot().sheets`. Hidden sheets and chartsheets refuse. An
|
|
551
|
+
* open cell edit is committed first. While an input method composes, it is refused with
|
|
552
|
+
* `composing`.
|
|
553
|
+
*/
|
|
554
|
+
setActiveSheet(index: number): boolean;
|
|
555
|
+
/** Zoom the shown sheet; 1 is 100%. Clamped to 10% to 400%. Nothing while an open runs. */
|
|
556
|
+
setZoom(zoom: number): void;
|
|
557
|
+
/** Zoom one step in (+1) or out (-1). */
|
|
558
|
+
zoomStep(direction: 1 | -1): void;
|
|
559
|
+
/**
|
|
560
|
+
* Select a cell, or a range from `anchor` to `focus`, on the shown sheet. A point outside the
|
|
561
|
+
* grid moves to its edge, and a fractional coordinate is cut to an integer. Returns `false`,
|
|
562
|
+
* and changes nothing, when a coordinate is not a finite number or no sheet is shown: before
|
|
563
|
+
* an open settles, after a failed open, or after `close`. An open cell edit is committed
|
|
564
|
+
* first, as for `setActiveSheet`; when the store refuses that commit, `select` returns
|
|
565
|
+
* `false`, the selection stays, and the editor keeps its text and shows the reason.
|
|
566
|
+
* While an input method composes, it is refused with `composing`.
|
|
567
|
+
*/
|
|
568
|
+
select(anchor: GridPoint, focus?: GridPoint): boolean;
|
|
569
|
+
/** Give the keyboard to the grid. */
|
|
570
|
+
focus(): void;
|
|
571
|
+
/**
|
|
572
|
+
* Forget the refusal that the snapshot shows: chrome ended the command that it explains, for
|
|
573
|
+
* example Escape ended a sheet rename whose name was refused. Changes no cell.
|
|
574
|
+
*/
|
|
575
|
+
dismissRefusal(): void;
|
|
576
|
+
/**
|
|
577
|
+
* Replace the faces that measure and paint text, in place: the workbook, the selection, and
|
|
578
|
+
* the undo history stay. The new faces load first; when they do not load, the old faces stay
|
|
579
|
+
* and the promise resolves with the failure and its cause. It resolves `null` when the faces
|
|
580
|
+
* apply, or when `fonts` holds the same faces as now (`sameFontSource`). Before the first
|
|
581
|
+
* open, the next open reads them.
|
|
582
|
+
*/
|
|
583
|
+
setFonts(fonts: XlsxEditorOptions['fonts']): Promise<EditorFailure | null>;
|
|
584
|
+
/**
|
|
585
|
+
* Replace the number locale of the shown values, in place. `undefined` restores US English
|
|
586
|
+
* separators. Typed and pasted values read in the new locale: its separators, its date order, and
|
|
587
|
+
* the number formats that a typed form takes. An open cell edit
|
|
588
|
+
* keeps the number locale it opened with; the next edit reads the new one. A locale equal in
|
|
589
|
+
* value to the current one (`sameNumberLocale`) changes nothing and publishes nothing.
|
|
590
|
+
*/
|
|
591
|
+
setNumberLocale(locale: NumberLocale | undefined): void;
|
|
592
|
+
/**
|
|
593
|
+
* Switch between `edit` and `view` without a reload. In `view`, every edit command is
|
|
594
|
+
* refused with `view-mode`; selection, sheet tabs, zoom, and save stay available. An open
|
|
595
|
+
* cell edit is committed first. When the store refuses that commit, the switch is refused:
|
|
596
|
+
* `setMode` returns `false`, the editor stays open with its text, and the reason shows, as
|
|
597
|
+
* `select` and `save` refuse. Returns `true` when the mode is `mode` after the call.
|
|
598
|
+
* Each call that applies, also with the mode that the editor has, counts in
|
|
599
|
+
* `snapshot().modeRequests` and notifies the listeners, so a listener that calls `setMode`
|
|
600
|
+
* compares `snapshot().mode` first. While an input method composes, a switch to `view`
|
|
601
|
+
* returns `false` with no announcement.
|
|
602
|
+
*/
|
|
603
|
+
setMode(mode: EditorMode): boolean;
|
|
604
|
+
/**
|
|
605
|
+
* Open the cell editor over the active cell, with `text`, or with the cell's content when
|
|
606
|
+
* `text` is omitted (F2). `mode` is `enter` (arrow keys commit, as after typing) or `edit`
|
|
607
|
+
* (arrow keys move the caret, as after F2); the default is `edit` without `text` and `enter`
|
|
608
|
+
* with it. Needs a mounted surface, and refuses `not-editable` on a sheet without a part.
|
|
609
|
+
* A cell that no commit could change opens no editor: a locked cell of a protected sheet
|
|
610
|
+
* refuses with `locked`, and a cell that holds a second form of its value with
|
|
611
|
+
* `cell-alternate-content` and the sheet and cell as the subject. A cell of an array or data
|
|
612
|
+
* table range, or a shared master that cannot unshare, refuses with `shared-formula`, as a
|
|
613
|
+
* clear of that cell does. A shared master whose child formula would move out of the grid opens
|
|
614
|
+
* an editor, and its commit is refused with `shared-formula`. An edit that opens clears an
|
|
615
|
+
* earlier refusal, except `edit-dropped`.
|
|
616
|
+
*/
|
|
617
|
+
beginEdit(text?: string, mode?: CellEditMode): EditResult;
|
|
618
|
+
/**
|
|
619
|
+
* Commit the open cell editor. A refused commit keeps the editor open with its text, and the
|
|
620
|
+
* keyboard where it was: in the cell editor, or in a field outside the grid, such as the
|
|
621
|
+
* formula bar. While an input method composes, it is refused with `composing`. When an open
|
|
622
|
+
* edit commits, the grid takes the keyboard, with or without `move`.
|
|
623
|
+
*
|
|
624
|
+
* With `move`, the active cell then moves one cell, as Enter (`down`), Shift+Enter (`up`),
|
|
625
|
+
* Tab (`right`), and Shift+Tab (`left`) move it in the cell editor: inside a multi-cell
|
|
626
|
+
* selection, it moves in the selection and the selection stays. With `move` and no open
|
|
627
|
+
* edit, only the active cell moves, and the grid takes the keyboard. So a field such as the
|
|
628
|
+
* formula bar maps each of these keys to one call, with or without an open edit. A `move`
|
|
629
|
+
* that is not an `EditMove` throws a `TypeError` before anything changes. With no open edit
|
|
630
|
+
* and no workbook ready, it is refused with `loading` or `not-editable`.
|
|
631
|
+
*/
|
|
632
|
+
commitEdit(move?: EditMove): EditResult;
|
|
633
|
+
/** Close the cell editor and keep the cell as it was. The grid takes the keyboard. */
|
|
634
|
+
cancelEdit(): void;
|
|
635
|
+
/**
|
|
636
|
+
* Make `text` the text of the open cell edit, as the formula bar does while the user types in
|
|
637
|
+
* it. The cell editor shows the text in the cell at once, and `snapshot().editText` follows
|
|
638
|
+
* it: the edit has one text, which the bar does not copy. With no open edit, one opens over
|
|
639
|
+
* the active cell first, with the refusals of `beginEdit` (such as `locked` and `view-mode`),
|
|
640
|
+
* in `edit` mode, and without the keyboard: the keyboard stays in the caller's field.
|
|
641
|
+
*
|
|
642
|
+
* `options.composing` is whether an input method composes in the caller's field. While it
|
|
643
|
+
* does, `snapshot().composing` is true, and each command that would commit the edit is
|
|
644
|
+
* refused with `composing`. Call it again with `composing` false when the composition ends,
|
|
645
|
+
* also when the field loses the keyboard or unmounts during a composition. A key typed in the
|
|
646
|
+
* cell editor also ends it. `commitEdit` and `cancelEdit` end the edit as for the cell editor.
|
|
647
|
+
* A `text` that is not a string throws a `TypeError` before anything changes. An edit that
|
|
648
|
+
* opens clears an earlier refusal, except `edit-dropped`, as a new selection does.
|
|
649
|
+
*/
|
|
650
|
+
setEditText(text: string, options?: EditTextOptions): EditResult;
|
|
651
|
+
/**
|
|
652
|
+
* Select the range that `reference` names, as the name box does on Enter: a cell (`B2`,
|
|
653
|
+
* `$B$2`), a range (`B2:C5`), whole columns (`C:E`), or whole rows (`3:5`), in any letter
|
|
654
|
+
* case, with an optional sheet name (`Sheet2!A1`, `'My sheet'!A1:B2`) that shows that
|
|
655
|
+
* sheet. A defined name (`x:definedName`) goes to its range when its text is one such
|
|
656
|
+
* reference with a sheet name. A name that the shown sheet scopes (`@localSheetId`) comes
|
|
657
|
+
* before a workbook name, and a sheet prefix (`Data!Rates`) reads the name that that sheet
|
|
658
|
+
* scopes. The active cell is the top-left cell of the range, and the view scrolls to it.
|
|
659
|
+
* An open cell edit commits first, as `select` states.
|
|
660
|
+
*
|
|
661
|
+
* Refused with `go-to-name` for a defined name that names a formula, several ranges, or a
|
|
662
|
+
* range on a sheet that is not a visible worksheet, or that only another sheet scopes;
|
|
663
|
+
* `go-to-sheet` for a sheet name that names no visible worksheet; `go-to-reference` for any
|
|
664
|
+
* other text; `composing` while an input method composes in the open edit; and `loading` or
|
|
665
|
+
* `not-editable` when no workbook is ready. A refusal shows and is announced as an edit
|
|
666
|
+
* refusal is, and changes nothing.
|
|
667
|
+
*/
|
|
668
|
+
selectReference(reference: string): EditResult;
|
|
669
|
+
/**
|
|
670
|
+
* Write text to the active cell, or to `at` on the shown sheet, as the cell editor commits it.
|
|
671
|
+
* One undo step.
|
|
672
|
+
*
|
|
673
|
+
* - `=` starts a formula, `TRUE` and `FALSE` are booleans, and a leading apostrophe keeps the
|
|
674
|
+
* rest as text. The apostrophe is not stored.
|
|
675
|
+
* - A number form stores a number: a decimal, a percent (`12%`), a currency amount (`$5.50`),
|
|
676
|
+
* a grouped number (`1,234.5`), a negative in parentheses, a fraction with a whole part
|
|
677
|
+
* (`1 1/2`), a date (`2026-11-12`), a time (`13:45`), an elapsed time (`36:00`), or a date
|
|
678
|
+
* and a time. The number locale gives the separators and the day and month order. A date
|
|
679
|
+
* with no year takes the year of the host clock.
|
|
680
|
+
* - A cell with the General format also takes the number format of the form (ECMA-376 Part 1,
|
|
681
|
+
* 18.8.30), in the same undo step. A sheet whose protection does not allow formatting cells
|
|
682
|
+
* keeps the cell format, and so does a styles part whose cell format list or number format
|
|
683
|
+
* list is full (64,000 records), or that the store cannot read, and so does a number locale
|
|
684
|
+
* code that the store cannot read. A cell with another number format keeps it.
|
|
685
|
+
* - A cell with the Text format (`@`) stores the text, but a formula stays a formula, and an
|
|
686
|
+
* empty entry clears the cell.
|
|
687
|
+
* - A date is a serial number in the date system of the workbook (Part 1, 18.17.4.1). In a
|
|
688
|
+
* cell that stores a date value (`t="d"`), ISO 8601 text stays a date value.
|
|
689
|
+
*
|
|
690
|
+
* `at` is 0-based: `row` from 0 to 1048575 and `col` from 0 to 16383, both integers; another
|
|
691
|
+
* point is refused with `bad-reference`. An open cell edit is committed first when `at` is
|
|
692
|
+
* omitted or is the cell of that edit, so its text is not lost; a refused commit refuses the
|
|
693
|
+
* write. Another `at` leaves the open edit open. A write to the active cell keeps the selection
|
|
694
|
+
* in its undo step, so undo and redo select it again. A write to another cell through `at`
|
|
695
|
+
* keeps none: undo and redo of it leave the selection as it is. While an input method
|
|
696
|
+
* composes, it is refused with `composing`.
|
|
697
|
+
*/
|
|
698
|
+
enterValue(text: string, at?: GridPoint): EditResult;
|
|
699
|
+
/**
|
|
700
|
+
* Clear the values and formulas of the selected cells, and keep their formats. One undo step. An
|
|
701
|
+
* open cell edit is committed first. While an input method composes, it is refused with
|
|
702
|
+
* `composing`. A cell that holds a second form of its value that the clear can neither keep nor
|
|
703
|
+
* replace, such as a formula in `mc:AlternateContent`, refuses it with `cell-alternate-content`
|
|
704
|
+
* and the sheet and cell as the subject. A clear that would break a formula range is refused
|
|
705
|
+
* with `shared-formula` and the blocking range or cell as the subject, and `causeCell` when one
|
|
706
|
+
* cell's formula blocks a shared master. `EDIT_REFUSAL_CODES` lists the cases.
|
|
707
|
+
*/
|
|
708
|
+
clearValues(): EditResult;
|
|
709
|
+
/**
|
|
710
|
+
* Apply a format patch to the selected cells, or to the active cell when it is the only cell.
|
|
711
|
+
* Each cell keeps the properties that the patch does not set. One undo step. A range that would
|
|
712
|
+
* create more than `MAX_FORMAT_NEW_CELLS` cells (more than one whole row) is refused with
|
|
713
|
+
* `range-too-large`. An open cell edit is committed first. While an input method composes, it is
|
|
714
|
+
* refused with `composing`.
|
|
715
|
+
*/
|
|
716
|
+
applyFormat(patch: FormatPatch): EditResult;
|
|
717
|
+
/**
|
|
718
|
+
* Remove the cell formats of the selected cells, and keep their values. An empty cell whose
|
|
719
|
+
* row or column has a format gets a plain cell (`s="0"`), so it does not show that format.
|
|
720
|
+
* One undo step. A range that would create more than `MAX_FORMAT_NEW_CELLS` such cells is
|
|
721
|
+
* refused with `clear-too-large`, a protected sheet that does not allow formatting with
|
|
722
|
+
* `locked`, and `view` mode with `view-mode`. An open cell edit is committed first.
|
|
723
|
+
* While an input method composes, it is refused with `composing`. On a protected sheet, each
|
|
724
|
+
* cell keeps whether it is locked or hidden: it gets format 0 with its own protection. When a
|
|
725
|
+
* formula or a defined name calls `CELL` or a macro function `GET.*`, which can read a cell
|
|
726
|
+
* format (`CELL("format")`), the saved workbook asks for a full calculation on load. When
|
|
727
|
+
* the record of that protection would pass the record limit of the styles part, the clear is
|
|
728
|
+
* refused with `style-limit`.
|
|
729
|
+
*/
|
|
730
|
+
clearFormats(): EditResult;
|
|
731
|
+
/**
|
|
732
|
+
* Clear the values, formulas, and cell formats of the selected cells, as `clearValues` and
|
|
733
|
+
* `clearFormats` in one undo step. Refused with the reasons of both: `clear-too-large`,
|
|
734
|
+
* `style-limit`, `cell-alternate-content`, `shared-formula` when the clear would break a
|
|
735
|
+
* formula range, and `locked` for a locked cell that holds content or for a sheet that does not
|
|
736
|
+
* allow formatting. A `locked`, `cell-alternate-content`, or `shared-formula` refusal has the
|
|
737
|
+
* command `clearAll`. An open cell edit is committed first.
|
|
738
|
+
* While an input method composes, it is refused with `composing`.
|
|
739
|
+
*/
|
|
740
|
+
clearAll(): EditResult;
|
|
741
|
+
/**
|
|
742
|
+
* Toggle bold, italic, or underline from the format of the active cell. One undo step. An open
|
|
743
|
+
* cell edit is committed first. While an input method composes, it is refused with `composing`.
|
|
744
|
+
*/
|
|
745
|
+
toggleFormat(which: FormatToggle): EditResult;
|
|
746
|
+
/**
|
|
747
|
+
* Insert rows above the selection: as many as a whole-row selection or a range has rows, or
|
|
748
|
+
* one above the active cell. Every reference of the workbook moves with the rows (design
|
|
749
|
+
* D4), or the edit is refused with `structure-blocked`, which names what holds the
|
|
750
|
+
* reference, `grid-full`, or `sheet-name-too-long`, as `deleteSheet` states. It is refused
|
|
751
|
+
* with `sheet-name-ambiguous`, with the other sheet as the subject, when a file gives the
|
|
752
|
+
* name of the shown sheet to another sheet too, in any case: a prefix such as `DATA!A1` can
|
|
753
|
+
* name either sheet, so no reference can move with certainty. A formula or a defined name
|
|
754
|
+
* inside `mc:AlternateContent` whose text the edit would change refuses it with
|
|
755
|
+
* `structure-blocked`, because the editor does not rewrite each branch. The refusal names the
|
|
756
|
+
* cell or the name, or the wrapper when a name list in `x:workbook` names the sheet. An open
|
|
757
|
+
* cell edit commits first. One undo step. While an input method composes, it is refused with
|
|
758
|
+
* `composing`, and in view mode with `view-mode`.
|
|
759
|
+
*/
|
|
760
|
+
insertRows(): EditResult;
|
|
761
|
+
/** Delete the rows of the selection, or the active cell's row. As `insertRows`. */
|
|
762
|
+
deleteRows(): EditResult;
|
|
763
|
+
/** Insert columns to the left of the selection, or of the active cell. As `insertRows`. */
|
|
764
|
+
insertColumns(): EditResult;
|
|
765
|
+
/** Delete the columns of the selection, or the active cell's column. As `insertRows`. */
|
|
766
|
+
deleteColumns(): EditResult;
|
|
767
|
+
/**
|
|
768
|
+
* Merge the range of the selection into one cell (`x:mergeCell`), and select it with its
|
|
769
|
+
* top-left cell active. The merged cell keeps the value of the top-left cell only. A range
|
|
770
|
+
* where another cell holds a value or a formula is refused with `merge-drops-values`, so the
|
|
771
|
+
* host can ask the user first and then merge with `dropValues`, which clears those cells in
|
|
772
|
+
* the same undo step. With `center`, the merged cell is also centered, and a range too large to
|
|
773
|
+
* format is refused with `range-too-large`, as `applyFormat`. A selection of one cell
|
|
774
|
+
* is refused with `merge-one-cell`, a range that meets a merged range with `merge-overlap`,
|
|
775
|
+
* and a protected sheet with `locked`. The clear of `dropValues` can refuse with
|
|
776
|
+
* `cell-alternate-content` or `shared-formula`, and that refusal has the command `merge`.
|
|
777
|
+
* An open cell edit commits first. One undo step. While
|
|
778
|
+
* an input method composes, it is refused with `composing`, and in view mode with `view-mode`.
|
|
779
|
+
*/
|
|
780
|
+
mergeCells(options?: MergeOptions): EditResult;
|
|
781
|
+
/**
|
|
782
|
+
* Unmerge each merged range that the selection meets. The values stay in the top-left cells.
|
|
783
|
+
* A selection that meets no merged range changes nothing and makes no undo step. As
|
|
784
|
+
* `mergeCells` for the open edit, the protection, and the view mode.
|
|
785
|
+
*/
|
|
786
|
+
unmergeCells(): EditResult;
|
|
787
|
+
/**
|
|
788
|
+
* Add an empty worksheet after the shown sheet, and show it. Without `name`, the name is the
|
|
789
|
+
* catalog text `sheetTabs.newSheetName` with the smallest free number `{n}` from 1. A name
|
|
790
|
+
* that breaks the rules of a sheet name is refused with `sheet-name-invalid` (empty, more
|
|
791
|
+
* than 31 characters counted in UTF-16 code units, one of `[ ] : * ? / \`, a control
|
|
792
|
+
* character such as a tab or a line break, a character that XML cannot hold, an `ST_Xstring`
|
|
793
|
+
* escape sequence such as `_x0041_`, or an apostrophe at the start or the end) or
|
|
794
|
+
* `sheet-name-taken` (another sheet has it, compared without case after NFC). An open cell
|
|
795
|
+
* edit commits first. One undo step. When a formula or a defined name already names the new
|
|
796
|
+
* name, the saved workbook asks for a full calculation on load, as after a value edit. An
|
|
797
|
+
* add, a rename, or a move asks for it too when a formula or a defined name calls a function
|
|
798
|
+
* that reads sheet names or positions: `INDIRECT`, `CELL`, `INFO`, `SHEET`, `SHEETS`, or
|
|
799
|
+
* `FORMULATEXT` (stored as `_xlfn.SHEET`, `_xlfn.SHEETS`, and `_xlfn.FORMULATEXT`), or a
|
|
800
|
+
* macro function `GET.*`, such as `GET.WORKBOOK` or `GET.CELL`, in a formula or a defined
|
|
801
|
+
* name. In view mode, it is refused with `view-mode`. When the workbook protection locks the
|
|
802
|
+
* sheet list (`snapshot().workbookProtection.allowStructure` is false), each sheet command
|
|
803
|
+
* (`addSheet`, `renameSheet`, `deleteSheet`, `moveSheet`) is refused with `locked`, and the
|
|
804
|
+
* lock rule is `workbook`. Refused with `structure-blocked`, with the defined name as the
|
|
805
|
+
* subject, when the add changes the position of the sheet that the local scope of a defined
|
|
806
|
+
* name inside `mc:AlternateContent` names.
|
|
807
|
+
*/
|
|
808
|
+
addSheet(name?: string): EditResult;
|
|
809
|
+
/**
|
|
810
|
+
* Rename the sheet at position `index` of `snapshot().sheets`. Every formula, defined name,
|
|
811
|
+
* and internal hyperlink location that names the sheet gets the new name. Refused with the
|
|
812
|
+
* name codes of `addSheet`, or with `structure-blocked`, with the blocking content as the
|
|
813
|
+
* subject: when the workbook holds any chart, pivot table, or sheet that is not a worksheet,
|
|
814
|
+
* or a relationship outside the allowlist, whatever it names; and when a table, conditional
|
|
815
|
+
* formatting, data validation, a drawing, a control, or other content that the editor does
|
|
816
|
+
* not rewrite names the sheet. Refused with `unknown-sheet` when no sheet is at `index`, also
|
|
817
|
+
* in view mode, because the index is checked before the mode. Refused with
|
|
818
|
+
* `sheet-name-ambiguous`, with the other sheet as the subject, when a file gives the name of
|
|
819
|
+
* this sheet to another sheet too. A name in other case (`Data` and `DATA`) refuses the rename
|
|
820
|
+
* when a formula, a defined name, or a hyperlink location names one of the two. A name in the
|
|
821
|
+
* same case always refuses it, because the name cannot find this sheet. A formula or a
|
|
822
|
+
* defined name inside `mc:AlternateContent` that names the sheet refuses it with
|
|
823
|
+
* `structure-blocked`, which names the cell or the name, or the wrapper when a name list in
|
|
824
|
+
* `x:workbook` names the sheet. Refused with `view-mode` in view mode, and with `locked` (rule
|
|
825
|
+
* `workbook`) as `addSheet` states.
|
|
826
|
+
* One undo step. Marks the cached results stale as `addSheet` states, for a name that a
|
|
827
|
+
* formula already names and for a call to one of the functions that `addSheet` lists.
|
|
828
|
+
*/
|
|
829
|
+
renameSheet(index: number, name: string): EditResult;
|
|
830
|
+
/**
|
|
831
|
+
* Delete the sheet at position `index`. Each reference to it becomes `#REF!`, and its
|
|
832
|
+
* sheet-scoped defined names go. When it is the shown sheet, the nearest visible sheet shows.
|
|
833
|
+
* Printer settings that only this sheet uses go with it. One undo step. Refused with:
|
|
834
|
+
*
|
|
835
|
+
* - `last-sheet` when no visible sheet would be left.
|
|
836
|
+
* - `sheet-range-blocked` when a sheet range (`Sheet1:Sheet3!A1`) starts or ends at the
|
|
837
|
+
* sheet. A range that only spans it keeps its text.
|
|
838
|
+
* - `structure-blocked` for content as `renameSheet` refuses, a custom workbook view that
|
|
839
|
+
* shows the sheet, or a related part of the sheet other than hyperlinks and printer settings.
|
|
840
|
+
* When the sheet is not a worksheet, the refusal has the `about` kind `not-worksheet`. A
|
|
841
|
+
* formula or a defined name inside `mc:AlternateContent` that the delete would change refuses
|
|
842
|
+
* it too, and so does a defined name there whose local scope sheet changes position.
|
|
843
|
+
* - `sheet-name-ambiguous`, with the other sheet as the subject, when a file gives the name of
|
|
844
|
+
* this sheet to another sheet too, in any case.
|
|
845
|
+
* - `sheet-name-too-long`, with the full name as the subject, when a stored sheet name has more
|
|
846
|
+
* than 31 characters. A rename of that sheet can shorten it.
|
|
847
|
+
* - `unknown-sheet` when no sheet is at `index`, also in view mode, because the index is
|
|
848
|
+
* checked before the mode.
|
|
849
|
+
* - `view-mode` in view mode.
|
|
850
|
+
* - `locked`, with the `workbook` rule, as `addSheet` states.
|
|
851
|
+
*/
|
|
852
|
+
deleteSheet(index: number): EditResult;
|
|
853
|
+
/**
|
|
854
|
+
* Move the sheet at position `index` to position `to`. The shown sheet stays shown.
|
|
855
|
+
* Sheet-scoped defined names and the active tab follow their sheets. Charts never refuse a
|
|
856
|
+
* move. A move to the same position changes nothing. One undo step. Marks the cached results
|
|
857
|
+
* stale when a formula or a defined name calls one of the functions that `addSheet` lists.
|
|
858
|
+
* Refused with:
|
|
859
|
+
*
|
|
860
|
+
* - `sheet-range-blocked` when the move changes the sheets between the ends of a sheet range
|
|
861
|
+
* (`Sheet1:Sheet3!A1`) of a formula or a defined name, or which end comes first in tab
|
|
862
|
+
* order. Content that the editor does not rewrite and that holds a sheet range refuses too.
|
|
863
|
+
* - `sheet-name-ambiguous` when another sheet has the same name in the same case, because the
|
|
864
|
+
* name cannot find this sheet.
|
|
865
|
+
* - `sheet-name-too-long`, as `deleteSheet` states.
|
|
866
|
+
* - `structure-blocked`, with the sheet name as the subject, when the sheet is not a
|
|
867
|
+
* worksheet (a chartsheet, a macro sheet, a dialog sheet, or a sheet whose part is
|
|
868
|
+
* missing), as `deleteSheet` refuses it. A worksheet moves past such a sheet. Also with the
|
|
869
|
+
* defined name as the subject, when the move changes the position of the sheet that the local
|
|
870
|
+
* scope of a defined name inside `mc:AlternateContent` names.
|
|
871
|
+
* - `unknown-sheet` when no sheet is at `index`, also in view mode, as `deleteSheet` states.
|
|
872
|
+
* - `bad-position` when `to` is outside the sheet list.
|
|
873
|
+
* - `view-mode` in view mode.
|
|
874
|
+
* - `locked`, with the `workbook` rule, as `addSheet` states.
|
|
875
|
+
*/
|
|
876
|
+
moveSheet(index: number, to: number): EditResult;
|
|
877
|
+
/**
|
|
878
|
+
* Set the width of the columns `first` to `last` of the shown sheet (0-based, as `GridPoint`) to
|
|
879
|
+
* `width` characters of the maximum digit width of the default font, with a custom width flag
|
|
880
|
+
* (ECMA-376 Part 1, 18.3.1.13). The `x:col` elements that the range crosses split and keep their
|
|
881
|
+
* other attributes. The refusals: `bad-size` for a width outside 0 to 255 (this editor's limit,
|
|
882
|
+
* `MAX_COLUMN_WIDTH`; the schema states none); `bad-reference` for a range outside the grid;
|
|
883
|
+
* `resize-anchor` when the resize would change a drawing, control, or object anchor that keeps
|
|
884
|
+
* its size or position, or when the drawing part of the sheet cannot be read; `invalid-sheet`
|
|
885
|
+
* when the sheet has a cell structure that the editor cannot change, or when an `x:cols` after
|
|
886
|
+
* the first has an attribute that the merge of the column lists would drop; and `locked`, with the `size` rule, on a protected sheet that does
|
|
887
|
+
* not allow formatting columns (`SheetProtection.allowFormatColumns`); there, a column heading shows no
|
|
888
|
+
* resize edge. In view mode, it is refused with `view-mode`, and a heading edge starts no drag.
|
|
889
|
+
* An open cell edit commits first. One undo step. A drag of the right edge of a column heading
|
|
890
|
+
* calls it on pointer up. When a formula or a defined name calls `CELL` (`CELL("width")`) or
|
|
891
|
+
* a macro function `GET.*` (`GET.CELL`), which can read a column width, the saved workbook asks
|
|
892
|
+
* for a full calculation on load.
|
|
893
|
+
*/
|
|
894
|
+
setColumnWidth(first: number, last: number, width: number): EditResult;
|
|
895
|
+
/**
|
|
896
|
+
* Set the height of the rows `first` to `last` of the shown sheet (0-based) to `height` points,
|
|
897
|
+
* with a custom height flag (Part 1, 18.3.1.73). A row with no `x:row` gets an empty one. The
|
|
898
|
+
* refusals: `bad-size` for a height outside 0 to 409 (this editor's limit, `MAX_ROW_HEIGHT`; the
|
|
899
|
+
* schema states none); `bad-reference` for a range outside the grid; `too-many-rows` when it
|
|
900
|
+
* would create more than `MAX_RESIZE_NEW_ROWS` rows; `resize-anchor` when the resize would change
|
|
901
|
+
* an anchor that keeps its size or position, or when the drawing part of the sheet cannot be
|
|
902
|
+
* read; `invalid-sheet` when the rows of the sheet are
|
|
903
|
+
* out of order; and `locked`, with the `size` rule, on a protected sheet that does not allow
|
|
904
|
+
* formatting rows (`SheetProtection.allowFormatRows`). In view mode, it is refused with
|
|
905
|
+
* `view-mode`. When a formula or a defined name calls a macro function `GET.*` (`GET.CELL`),
|
|
906
|
+
* which can read a row height, the saved workbook asks for a full calculation on load. As
|
|
907
|
+
* `setColumnWidth` otherwise.
|
|
908
|
+
*/
|
|
909
|
+
setRowHeight(first: number, last: number, height: number): EditResult;
|
|
910
|
+
/**
|
|
911
|
+
* Copy the selected range, as Mod+C does. The editor keeps what each cell holds (its value or
|
|
912
|
+
* formula, and its cell format) and returns the content for the clipboard: `text`, the shown text
|
|
913
|
+
* of the cells, tab-separated with rows joined by CR LF, for `text/plain`, and `token`, which
|
|
914
|
+
* marks this copy, for the type `application/x-xlsx-editor`. A text that starts with `=`, `+`,
|
|
915
|
+
* `-`, `@`, tab, or CR gets an apostrophe in `text`, except the shown text of a number or a date
|
|
916
|
+
* that is one signed number with a digit after its sign and an optional currency symbol, such
|
|
917
|
+
* as `-1,234.50`, `-$1,234.50`, or `-1.2E+03` (`-1+2` and `-$A$1` get it). A tab or a line
|
|
918
|
+
* break inside the shown text becomes a space in `text` (approximation `copied-line-breaks`).
|
|
919
|
+
* A date whose shown text does not read back to the same day, such as `2-Jan` or a two-digit
|
|
920
|
+
* year outside 1930 to 2029, gives its edit text, such as `2035-06-01`.
|
|
921
|
+
* Refused with `merged-range` when the range meets a merged range, `copy-too-large` for more
|
|
922
|
+
* than `MAX_FORMAT_NEW_CELLS` cells, `copy-conditional-limit` when the range has more
|
|
923
|
+
* conditional formatting than one copy can check, `copy-array-formula` when it meets an array
|
|
924
|
+
* or data table range, also without its master cell (that range is the subject, as an edit
|
|
925
|
+
* names it), and `copy-unreadable-formula` when the copy cannot get the text of a formula: an
|
|
926
|
+
* empty formula, or a shared formula whose master cell is missing or cannot move to the cell.
|
|
927
|
+
* `copy-wrapped-formula` refuses a cell whose formula is inside `mc:AlternateContent` (the cell
|
|
928
|
+
* is the subject), so the paste never writes its cached value as a constant. The copy keeps any
|
|
929
|
+
* other formula as its text, also one that the tokenizer cannot read; its paste is then refused
|
|
930
|
+
* with `paste-unreadable-formula`. A copied or cut formula pasted on another sheet gives a name
|
|
931
|
+
* that the source sheet scopes the source sheet prefix. A copy with such a name depends on its
|
|
932
|
+
* source sheet for a paste on another sheet: such a paste after a rename or a delete of that
|
|
933
|
+
* sheet is refused with `copy-expired`. A paste on the source sheet, renamed or not, keeps the
|
|
934
|
+
* binding and is applied. A rich text cell copies as its plain text,
|
|
935
|
+
* and a stored error value as text (approximation `pasted-values`). Hyperlinks, comments, data
|
|
936
|
+
* validation, and conditional formatting stay with the source cells (approximation
|
|
937
|
+
* `cut-cell-attachments`). An open cell edit commits first; while an input method composes, the
|
|
938
|
+
* copy is refused with `composing`. Changes no cell, so it works in view mode and on a protected
|
|
939
|
+
* sheet. The editor keeps one copy, and forgets it when another workbook opens. The live region
|
|
940
|
+
* announces the copied range (`grid.copied`). A dashed outline marks the source range. A paste
|
|
941
|
+
* that leaves the source as it was keeps the outline, and every other edit ends it. Escape on the
|
|
942
|
+
* grid ends the outline and keeps the copy, so a later paste still writes the copied cells.
|
|
943
|
+
*/
|
|
944
|
+
copy(): CopyResult;
|
|
945
|
+
/**
|
|
946
|
+
* Cut the selected range, as Mod+X does: a copy whose next paste also clears the values and cell
|
|
947
|
+
* formats of the source, in the same transaction. A cut formula keeps the cells it refers to:
|
|
948
|
+
* pasted on another sheet, each reference without a sheet name, and each name that the source
|
|
949
|
+
* sheet scopes, gets the name of the source sheet. References to the cut cells do not move.
|
|
950
|
+
* A dashed outline marks the source range until the cut ends. Escape on the grid forgets a
|
|
951
|
+
* pending cut: the source stays, and a later paste of its token takes the `text` lane. When
|
|
952
|
+
* the workbook changes between the cut and the paste, also by an undo or a redo, the paste is refused with `cut-expired`, the source stays, and every later paste of
|
|
953
|
+
* the same cut is refused with `cut-expired` until a new copy or cut. Escape does not forget an
|
|
954
|
+
* expired cut. After one paste, the next paste of the cut is a copy, with the rules of
|
|
955
|
+
* `copy-expired` that `paste` states. Every refusal of a cut has the command `cut`, and its
|
|
956
|
+
* message says that the cells were not cut; `CUT_REFUSAL_CODES` lists the codes with a message.
|
|
957
|
+
* A refusal of the open cell edit that the cut commits first, such as `composing`, is not a
|
|
958
|
+
* refusal of the cut: it has the command `commit` or no command. A cut is refused with `view-mode` in view mode. It runs
|
|
959
|
+
* the checks of `copy` first, so a cut and a copy of one range give the same copy reason, such
|
|
960
|
+
* as `copy-wrapped-formula` for a cell whose formula is inside `mc:AlternateContent`, also on a
|
|
961
|
+
* protected sheet. The cut checks the clear of its source next. So it is also refused when the
|
|
962
|
+
* paste could not clear the source, as `clearAll` states: on a protected sheet with `locked`
|
|
963
|
+
* (the `cell` rule for a locked source cell that holds content, and the `format` rule when the
|
|
964
|
+
* sheet does not allow formatting cells); with
|
|
965
|
+
* `cell-alternate-content` when a source cell holds a second form of its value that the clear can
|
|
966
|
+
* neither keep nor replace; with `shared-formula` when the clear would break a formula range; and
|
|
967
|
+
* with `invalid-sheet` when the store cannot edit the sheet. It is refused with
|
|
968
|
+
* `cut-wrapped-value`, with the sheet and cell as the subject, when a source cell holds its value
|
|
969
|
+
* only in `mc:AlternateContent`, which the copy cannot carry. The paste clears only the source
|
|
970
|
+
* cells that it does not write.
|
|
971
|
+
* On a protected sheet, the clear keeps whether each source cell is locked or hidden.
|
|
972
|
+
*/
|
|
973
|
+
cut(): CopyResult;
|
|
974
|
+
/**
|
|
975
|
+
* Paste clipboard data at the active cell, as Mod+V does, as one transaction and one undo step,
|
|
976
|
+
* and select the pasted range. `token` equal to the last copy pastes that copy: values, formulas
|
|
977
|
+
* moved by the offset from the source, and cell formats. Else `text` pastes as rows split at line
|
|
978
|
+
* breaks and cells split at tab. Each cell is read as `enterValue` reads typed text, so a General
|
|
979
|
+
* cell takes the number format of a typed form such as `12%`, and other cell formats are kept.
|
|
980
|
+
* On a sheet whose protection does not allow formatting cells, or with a full styles part, the
|
|
981
|
+
* paste stores the numbers and keeps the cell formats. Quotes have no meaning, so a quoted
|
|
982
|
+
* value with a line break splits into rows. Else `html` refuses the paste with `paste-html`;
|
|
983
|
+
* the HTML is never read. Rich text and stored error values of a copy paste as text
|
|
984
|
+
* (approximation `pasted-values`). Refused with:
|
|
985
|
+
*
|
|
986
|
+
* - `grid-full` when the range would leave the grid.
|
|
987
|
+
* - `paste-reference-outside` when a moved reference would leave the sheet.
|
|
988
|
+
* - `range-too-large` for more than `MAX_FORMAT_NEW_CELLS` cells.
|
|
989
|
+
* - `merged-range` when the range meets a merged range.
|
|
990
|
+
* - `paste-unreadable-formula`, with the source cell as the subject, when a formula of the copy
|
|
991
|
+
* cannot be read to move it. Also when it fails the check of typed formula input (such as
|
|
992
|
+
* `1+` or `A1:S!B2`, also in a cut on the same sheet), or holds a sheet range that reads two
|
|
993
|
+
* ways.
|
|
994
|
+
* - `unsupported-function`, with the function name, when a formula calls a function outside the
|
|
995
|
+
* predefined functions.
|
|
996
|
+
* - `style-limit` when the clear of a cut source keeps the protection of its cells and that
|
|
997
|
+
* record would pass the record limit of the styles part, as `clearFormats` states.
|
|
998
|
+
* - `cell-alternate-content`, with the sheet and cell as the subject, when a target cell holds
|
|
999
|
+
* a second form of its value that the paste can neither keep nor replace, such as a formula
|
|
1000
|
+
* in `mc:AlternateContent`.
|
|
1001
|
+
* - `shared-formula`, with the blocking range or cell as the subject, when the paste would
|
|
1002
|
+
* break a formula range, as `EDIT_REFUSAL_CODES` states: a cell inside an array or data table
|
|
1003
|
+
* range, or a shared master whose children the editor cannot rewrite (`causeCell` names the
|
|
1004
|
+
* cell).
|
|
1005
|
+
* - `cut-expired` for a cut that the workbook changed after.
|
|
1006
|
+
* - `copy-expired` when a sheet that the copy depends on, or a copied cell format, changed after
|
|
1007
|
+
* the copy. A copy with formulas also expires at an insert or a delete of rows or columns on
|
|
1008
|
+
* any sheet, and at a rename, a move, or a delete of a sheet that a formula names. A formula with a reference
|
|
1009
|
+
* across a span of sheets also expires at an add, a rename, a move, or a delete of any sheet.
|
|
1010
|
+
* An undo or a redo of such an edit does not bring the copy back.
|
|
1011
|
+
* - `paste-name-scope` when a copied or cut formula pasted on another sheet holds a name with no
|
|
1012
|
+
* sheet prefix that the target sheet scopes and the source sheet does not. Also when it calls a
|
|
1013
|
+
* function name that the source sheet scopes.
|
|
1014
|
+
* - `locked` on a protected sheet, with the command `paste`: with the `cell` rule when a
|
|
1015
|
+
* target cell is locked, or when the paste would give a cell a cell format that changes
|
|
1016
|
+
* whether it is locked or hidden, whatever the protection allows; and with the `format`
|
|
1017
|
+
* rule when the paste would give a cell another cell format and the protection does not
|
|
1018
|
+
* allow formatting cells.
|
|
1019
|
+
* - `view-mode` in view mode, and `composing` while an input method composes in the open cell
|
|
1020
|
+
* editor.
|
|
1021
|
+
*
|
|
1022
|
+
* After `cut-expired` or `copy-expired`, every paste of the same `token` is refused with the same
|
|
1023
|
+
* code until a new copy or cut. Such a paste never takes the `text` lane. An open cell edit
|
|
1024
|
+
* commits first. When a paste changes a cell format and a formula or a defined name calls
|
|
1025
|
+
* `CELL` or a macro function `GET.*`, the saved workbook asks for a full calculation on load.
|
|
1026
|
+
*/
|
|
1027
|
+
paste(data: PasteData): EditResult;
|
|
1028
|
+
/**
|
|
1029
|
+
* Undo the last edit, as the toolbar's Undo does. An open cell editor is not committed. When
|
|
1030
|
+
* it holds changed text (`snapshot().editChanged`), the edit is cancelled, the cell shows its
|
|
1031
|
+
* content again, and the history does not move. An open editor with unchanged text closes,
|
|
1032
|
+
* and the undo steps the history once. While an input method composes, the undo is refused
|
|
1033
|
+
* with `composing`. The history keys in an open cell editor never call this: they belong to
|
|
1034
|
+
* the input's own undo. An empty history is refused with `nothing-to-undo`, and `view` mode
|
|
1035
|
+
* with `view-mode`. After
|
|
1036
|
+
* the undo, the editor selects the selection that the edit started from, on its sheet, and
|
|
1037
|
+
* scrolls its active cell into view; an edit that kept no selection leaves it as it is.
|
|
1038
|
+
*/
|
|
1039
|
+
undo(): EditResult;
|
|
1040
|
+
/**
|
|
1041
|
+
* Redo the last undone edit. An open cell edit with changed text (`snapshot().editChanged`)
|
|
1042
|
+
* refuses the redo with `edit-pending` before any write, as the toolbar disables it; an open edit
|
|
1043
|
+
* with no change closes first. While an input method composes, it is refused with `composing`. An
|
|
1044
|
+
* empty redo history is refused with `nothing-to-redo`. After the redo, the editor selects the
|
|
1045
|
+
* selection that the edit ended with, as `undo` does.
|
|
1046
|
+
*/
|
|
1047
|
+
redo(): EditResult;
|
|
1048
|
+
/**
|
|
1049
|
+
* The workbook as bytes of the opened package's kind (`snapshot().workbookKind`: a workbook or a
|
|
1050
|
+
* template), with every edit, or `null` when none is open. An open cell editor is committed
|
|
1051
|
+
* first; when the store refuses that commit, `save` returns `null` and the snapshot holds the
|
|
1052
|
+
* refusal. While an input method composes, it is refused with `composing`.
|
|
1053
|
+
*/
|
|
1054
|
+
save(): Uint8Array<ArrayBuffer> | null;
|
|
1055
|
+
/**
|
|
1056
|
+
* {@link XlsxEditorInstance.save} in short tasks, so the page stays responsive while a large
|
|
1057
|
+
* workbook saves. The workbook is captured at the call: an open cell editor commits then. A
|
|
1058
|
+
* refusal is in the snapshot when the call returns, but a workbook that cannot serialize is
|
|
1059
|
+
* refused when the failure occurs, with the code `save-failed`. An edit made while the save
|
|
1060
|
+
* runs belongs to the next save. A call during a running save of the same revision joins that
|
|
1061
|
+
* save, and gets its own copy of the bytes. Resolves to `null` when the save is refused.
|
|
1062
|
+
*/
|
|
1063
|
+
saveInTasks(): Promise<SavedWorkbook | null>;
|
|
1064
|
+
/**
|
|
1065
|
+
* Unmount and release the editor. An open edit is committed, or its refusal is announced.
|
|
1066
|
+
* While an input method composes, the edit is dropped with `edit-dropped`, and the listeners
|
|
1067
|
+
* hear it before they go. After `destroy`, no listener is left to notify.
|
|
1068
|
+
*/
|
|
1069
|
+
destroy(): void;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* Create a workbook editor. Mount it with `attach`, open a file with `load`.
|
|
1074
|
+
*
|
|
1075
|
+
* @public
|
|
1076
|
+
*/
|
|
1077
|
+
declare function createXlsxEditor(options?: XlsxEditorOptions): XlsxEditorInstance;
|
|
1078
|
+
|
|
1079
|
+
/** The value of an entry of the number format list. @public */
|
|
1080
|
+
type NumberFormatChoiceValue = 'general' | 'number' | 'currency' | 'accounting' | 'percent' | 'scientific' | 'fraction' | 'shortDate' | 'longDate' | 'time' | 'text';
|
|
1081
|
+
/**
|
|
1082
|
+
* One entry of the number format list: its value, the built-in id that it names (null for an
|
|
1083
|
+
* entry with no built-in id), and the catalog key of its name.
|
|
1084
|
+
*
|
|
1085
|
+
* @public
|
|
1086
|
+
*/
|
|
1087
|
+
interface NumberFormatChoice {
|
|
1088
|
+
readonly value: NumberFormatChoiceValue;
|
|
1089
|
+
/** The built-in id that it names (ECMA-376 Part 1, 18.8.30), or null for a custom code. */
|
|
1090
|
+
readonly id: number | null;
|
|
1091
|
+
readonly labelKey: `numberFormat.${NumberFormatChoiceValue}`;
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* The format code that an entry of the number format list shows in a number locale: the code
|
|
1095
|
+
* of its built-in id in the locale (`builtins` of the locale, or the ECMA-376 table), or the
|
|
1096
|
+
* code that it writes. Currency and accounting put the currency symbol of the locale before the
|
|
1097
|
+
* number, with two decimal places. Undefined for currency and accounting when the locale's
|
|
1098
|
+
* currency symbol is not valid: the list then leaves the two entries out.
|
|
1099
|
+
*
|
|
1100
|
+
* @public
|
|
1101
|
+
*/
|
|
1102
|
+
declare function numberFormatChoiceCode(value: NumberFormatChoiceValue, locale?: NumberLocale): string | undefined;
|
|
1103
|
+
/**
|
|
1104
|
+
* The entries of the number format list that have a code in a number locale: all of them,
|
|
1105
|
+
* unless the locale's currency symbol is not valid, which leaves out currency and accounting.
|
|
1106
|
+
* The list never writes another symbol in place of the locale's.
|
|
1107
|
+
*
|
|
1108
|
+
* @public
|
|
1109
|
+
*/
|
|
1110
|
+
declare function numberFormatChoices(locale?: NumberLocale): readonly NumberFormatChoice[];
|
|
1111
|
+
/**
|
|
1112
|
+
* The prefix of a number format value that is no choice: `custom:` and the format code, so a
|
|
1113
|
+
* code that reads like a choice (`percent`) never shows as that choice.
|
|
1114
|
+
*
|
|
1115
|
+
* @public
|
|
1116
|
+
*/
|
|
1117
|
+
declare const CUSTOM_NUMBER_FORMAT_PREFIX: 'custom:';
|
|
1118
|
+
/**
|
|
1119
|
+
* The entry of the number format list that a format shows, or `custom:` and its code when it
|
|
1120
|
+
* shows no entry. An entry with an id matches the cell's code in the locale (`builtins` of the
|
|
1121
|
+
* locale, or the ECMA-376 table), with that id or with a custom id. A workbook that gives a
|
|
1122
|
+
* built-in id another code shows that code, so it matches no entry with the id. Currency,
|
|
1123
|
+
* accounting, and the long date match their code. A format whose `hasCode` is false matches
|
|
1124
|
+
* no entry: it shows `General`, but its id names a code that the workbook or the locale does
|
|
1125
|
+
* not give.
|
|
1126
|
+
*
|
|
1127
|
+
* @public
|
|
1128
|
+
*/
|
|
1129
|
+
declare function numberFormatValue(format: {
|
|
1130
|
+
readonly id: number;
|
|
1131
|
+
readonly code: string;
|
|
1132
|
+
readonly hasCode?: boolean;
|
|
1133
|
+
}, locale?: NumberLocale): NumberFormatChoiceValue | `${typeof CUSTOM_NUMBER_FORMAT_PREFIX}${string}`;
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* Why a control is disabled: a key of the shared catalog (the English catalog of
|
|
1137
|
+
* `@xlsx-editor.dev/i18n`), its parameters, and the subject of a structure refusal. The adapters
|
|
1138
|
+
* translate it with `disabledReasonText`; the engine never returns English text.
|
|
1139
|
+
*
|
|
1140
|
+
* @public
|
|
1141
|
+
*/
|
|
1142
|
+
interface ChromeDisabledReason {
|
|
1143
|
+
readonly key: DisabledReasonKey;
|
|
1144
|
+
readonly params?: Readonly<Record<string, string>>;
|
|
1145
|
+
/** What refuses a structural command; its words are the `{subject}` of the key. */
|
|
1146
|
+
readonly about?: RefusalSubject;
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* The user text of a disabled reason: its key with its parameters, and `{subject}` as the words
|
|
1150
|
+
* of `about` (`subjectText`).
|
|
1151
|
+
*
|
|
1152
|
+
* @public
|
|
1153
|
+
*/
|
|
1154
|
+
declare function disabledReasonText(reason: ChromeDisabledReason, t: EditorTranslate): string;
|
|
1155
|
+
/**
|
|
1156
|
+
* Every catalog key that `toolbarCommandState`, `sheetCommandState`, and `mergeCommandState` can
|
|
1157
|
+
* return as a disabled reason. A test keeps each one in the catalog.
|
|
1158
|
+
*
|
|
1159
|
+
* @public
|
|
1160
|
+
*/
|
|
1161
|
+
declare const DISABLED_REASON_KEYS: readonly ['disabledReason.editorNotReady', 'disabledReason.loading', 'disabledReason.notWired', 'disabledReason.nothingToUndo', 'disabledReason.nothingToRedo', 'disabledReason.editPending', 'disabledReason.rangeTooLarge', 'disabledReason.clearTooLarge', 'disabledReason.structureBlocked', 'disabledReason.structureBlockedUnnamed', 'disabledReason.structureUnavailable', 'disabledReason.wholeSheet', 'disabledReason.noSave', 'disabledReason.viewMode', 'disabledReason.locked', 'disabledReason.cellAlternateContent', 'disabledReason.cellAlternateContentClearAll', 'disabledReason.formulaRange', 'disabledReason.formulaRangeClearAll', 'disabledReason.formulaCell', 'disabledReason.formulaCellClearAll', 'disabledReason.formulaUnreadable', 'disabledReason.formulaUnreadableClearAll', 'disabledReason.formatLocked', 'disabledReason.stylesUnread', 'disabledReason.stylesUnreadProtected', 'disabledReason.structureLocked', 'disabledReason.workbookLocked', 'disabledReason.lastSheet', 'disabledReason.notWorksheet', 'disabledReason.sheetEditBlocked', 'disabledReason.composing', 'disabledReason.decimalsNoNumberSelection', 'disabledReason.decimalsNoNumber', 'disabledReason.decimalsNoShownPlaces', 'disabledReason.decimalsGeneralSection', 'disabledReason.decimalsGeneralSectionSelection', 'disabledReason.decimalsDate', 'disabledReason.decimalsDateSelection', 'disabledReason.decimalsText', 'disabledReason.decimalsTextSelection', 'disabledReason.decimalsFraction', 'disabledReason.decimalsFractionSelection', 'disabledReason.decimalsNoDecimals', 'disabledReason.decimalsNoDecimalsSelection', 'disabledReason.decimalsNoDecimalsCellSelection', 'disabledReason.decimalsMaxDecimals', 'disabledReason.decimalsMaxDecimalsSelection', 'disabledReason.decimalsMaxDecimalsCellSelection', 'disabledReason.decimalsTooLong', 'disabledReason.decimalsTooLongSelection', 'disabledReason.decimalsUnreadable', 'disabledReason.decimalsUnreadableSelection', 'disabledReason.decimalsNoCode', 'disabledReason.decimalsNoCodeSelection', 'disabledReason.decimalsMissingCode', 'disabledReason.decimalsMissingCodeSelection', 'disabledReason.decimalsTooLarge', 'disabledReason.mergeLocked', 'disabledReason.mergeOneCell', 'disabledReason.mergeOverlap', 'disabledReason.noMergedRange'];
|
|
1162
|
+
/**
|
|
1163
|
+
* Why an enabled control can seem to do nothing: a key of the shared catalog. The adapters
|
|
1164
|
+
* translate it, as they translate a {@link ChromeDisabledReason}.
|
|
1165
|
+
*
|
|
1166
|
+
* @public
|
|
1167
|
+
*/
|
|
1168
|
+
interface ChromeHint {
|
|
1169
|
+
readonly key: ToolbarHintKey;
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Every catalog key that `toolbarCommandState` can return as a hint of an enabled control. A
|
|
1173
|
+
* test keeps each one in the catalog.
|
|
1174
|
+
*
|
|
1175
|
+
* @public
|
|
1176
|
+
*/
|
|
1177
|
+
declare const TOOLBAR_HINT_KEYS: readonly ['hint.conditionalFormat', 'hint.decimalsLargeSelection'];
|
|
1178
|
+
/** A hint key. @public */
|
|
1179
|
+
type ToolbarHintKey = (typeof TOOLBAR_HINT_KEYS)[number];
|
|
1180
|
+
/** A disabled-reason key. @public */
|
|
1181
|
+
type DisabledReasonKey = (typeof DISABLED_REASON_KEYS)[number];
|
|
1182
|
+
/**
|
|
1183
|
+
* The state of one control.
|
|
1184
|
+
*
|
|
1185
|
+
* @public
|
|
1186
|
+
*/
|
|
1187
|
+
interface ToolbarCommandState {
|
|
1188
|
+
readonly id: ChromeSlotId;
|
|
1189
|
+
readonly enabled: boolean;
|
|
1190
|
+
/** The engine's reason when disabled, as a catalog key. Shown as the tooltip. */
|
|
1191
|
+
readonly disabledReason: ChromeDisabledReason | null;
|
|
1192
|
+
/** The command is applied at the active cell: bold is on, the cell is left aligned. */
|
|
1193
|
+
readonly active: boolean;
|
|
1194
|
+
/**
|
|
1195
|
+
* What a value control shows: the font name, the size in points, the color as `RRGGBB` (or
|
|
1196
|
+
* `none` for no fill), the number format choice (a `value` of `numberFormatChoices`, or
|
|
1197
|
+
* `CUSTOM_NUMBER_FORMAT_PREFIX` and the format code of any other format), or for
|
|
1198
|
+
* `number.custom` the format code of the active cell, which its dialog starts from
|
|
1199
|
+
* (`General` for a format id with no code here, such as a locale-dependent built-in, so a
|
|
1200
|
+
* run of it sets id 0). Absent for a control that has no value.
|
|
1201
|
+
*/
|
|
1202
|
+
readonly value?: string;
|
|
1203
|
+
/**
|
|
1204
|
+
* Why an enabled control can seem to do nothing: `hint.conditionalFormat` when a true
|
|
1205
|
+
* conditional formatting rule shows a state of this control at the active cell that differs
|
|
1206
|
+
* from the cell format, which the control reads and sets (`EditorSnapshot.conditionalFormat`).
|
|
1207
|
+
* Or why it is enabled while the other format controls are not:
|
|
1208
|
+
* `hint.decimalsLargeSelection` on a decimal step when the selection is too large to format
|
|
1209
|
+
* (`formatRefusal`), because the step changes only the selected cells that hold numbers.
|
|
1210
|
+
* Absent otherwise, and absent on a disabled control. The toolbar shows it after the label in
|
|
1211
|
+
* the tooltip, and as the accessible description. The engine names a catalog key and the
|
|
1212
|
+
* adapter translates it, as this engine does for `disabledReason`.
|
|
1213
|
+
*/
|
|
1214
|
+
readonly hint?: ChromeHint;
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* What the host gives the toolbar beyond the snapshot.
|
|
1218
|
+
*
|
|
1219
|
+
* @public
|
|
1220
|
+
*/
|
|
1221
|
+
interface ToolbarHost {
|
|
1222
|
+
/**
|
|
1223
|
+
* Receives the workbook bytes of `file.save` when they are ready, with what they hold. Without
|
|
1224
|
+
* it, `file.save` is disabled.
|
|
1225
|
+
*/
|
|
1226
|
+
readonly save?: (bytes: Uint8Array<ArrayBuffer>, saved: SavedWorkbook) => void;
|
|
1227
|
+
/**
|
|
1228
|
+
* Called once when a press of `file.save` starts a delivery, with the promise of its result,
|
|
1229
|
+
* so a host can show that the save runs. A press that joins the running save of an earlier
|
|
1230
|
+
* press and a refused save do not call it. A press that joins a save from `saveInTasks` calls
|
|
1231
|
+
* it. The promise resolves to `null` when the save is refused later.
|
|
1232
|
+
*/
|
|
1233
|
+
readonly saveStart?: (saving: Promise<SavedWorkbook | null>) => void;
|
|
1234
|
+
/**
|
|
1235
|
+
* Whether the host opens another workbook now, while the editor still shows the old one: for
|
|
1236
|
+
* example during a download or a read before `load`. While it returns true, `file.save` is
|
|
1237
|
+
* disabled with `disabledReason.loading`, and `runToolbarCommand` refuses the save with
|
|
1238
|
+
* `loading` (`command: 'save'`) before any save work starts, so a key press does not delay the
|
|
1239
|
+
* open. The command state and each run read it at their call.
|
|
1240
|
+
*/
|
|
1241
|
+
readonly opening?: () => boolean;
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* The font families of the font list. A family name is what the workbook stores; the list
|
|
1245
|
+
* also shows the active cell's own family when it is not here. Each has a metric-compatible
|
|
1246
|
+
* substitute face in `loadSubstituteFonts`.
|
|
1247
|
+
*
|
|
1248
|
+
* @public
|
|
1249
|
+
*/
|
|
1250
|
+
declare const FONT_FAMILY_CHOICES: readonly string[];
|
|
1251
|
+
/** The font sizes of the size list, in points. @public */
|
|
1252
|
+
declare const FONT_SIZE_CHOICES: readonly number[];
|
|
1253
|
+
/**
|
|
1254
|
+
* The colors of the font color and fill color palettes, as `RRGGBB`.
|
|
1255
|
+
*
|
|
1256
|
+
* @public
|
|
1257
|
+
*/
|
|
1258
|
+
declare const COLOR_CHOICES: readonly [{
|
|
1259
|
+
readonly value: '000000';
|
|
1260
|
+
readonly labelKey: 'colorPicker.colors.black';
|
|
1261
|
+
}, {
|
|
1262
|
+
readonly value: 'FFFFFF';
|
|
1263
|
+
readonly labelKey: 'colorPicker.colors.white';
|
|
1264
|
+
}, {
|
|
1265
|
+
readonly value: '808080';
|
|
1266
|
+
readonly labelKey: 'colorPicker.colors.darkGray';
|
|
1267
|
+
}, {
|
|
1268
|
+
readonly value: 'C0C0C0';
|
|
1269
|
+
readonly labelKey: 'colorPicker.colors.lightGray';
|
|
1270
|
+
}, {
|
|
1271
|
+
readonly value: 'C00000';
|
|
1272
|
+
readonly labelKey: 'colorPicker.colors.darkRed';
|
|
1273
|
+
}, {
|
|
1274
|
+
readonly value: 'FF0000';
|
|
1275
|
+
readonly labelKey: 'colorPicker.colors.red';
|
|
1276
|
+
}, {
|
|
1277
|
+
readonly value: 'FFC000';
|
|
1278
|
+
readonly labelKey: 'colorPicker.colors.orange';
|
|
1279
|
+
}, {
|
|
1280
|
+
readonly value: 'FFFF00';
|
|
1281
|
+
readonly labelKey: 'colorPicker.colors.yellow';
|
|
1282
|
+
}, {
|
|
1283
|
+
readonly value: '92D050';
|
|
1284
|
+
readonly labelKey: 'colorPicker.colors.lightGreen';
|
|
1285
|
+
}, {
|
|
1286
|
+
readonly value: '00B050';
|
|
1287
|
+
readonly labelKey: 'colorPicker.colors.green';
|
|
1288
|
+
}, {
|
|
1289
|
+
readonly value: '00B0F0';
|
|
1290
|
+
readonly labelKey: 'colorPicker.colors.lightBlue';
|
|
1291
|
+
}, {
|
|
1292
|
+
readonly value: '0070C0';
|
|
1293
|
+
readonly labelKey: 'colorPicker.colors.blue';
|
|
1294
|
+
}, {
|
|
1295
|
+
readonly value: '002060';
|
|
1296
|
+
readonly labelKey: 'colorPicker.colors.darkBlue';
|
|
1297
|
+
}, {
|
|
1298
|
+
readonly value: '7030A0';
|
|
1299
|
+
readonly labelKey: 'colorPicker.colors.purple';
|
|
1300
|
+
}];
|
|
1301
|
+
/** The value of the fill color palette that removes the fill. @public */
|
|
1302
|
+
declare const NO_FILL = "none";
|
|
1303
|
+
/**
|
|
1304
|
+
* The state of one control, from the editor snapshot alone: enabled, pressed, its value, and
|
|
1305
|
+
* the reason when it is disabled.
|
|
1306
|
+
*
|
|
1307
|
+
* @public
|
|
1308
|
+
*/
|
|
1309
|
+
declare function toolbarCommandState(snapshot: EditorSnapshot, id: ChromeSlotId, host?: ToolbarHost): ToolbarCommandState;
|
|
1310
|
+
/**
|
|
1311
|
+
* The state of every slot of a list, from one snapshot, in the order of `ids`.
|
|
1312
|
+
*
|
|
1313
|
+
* @public
|
|
1314
|
+
*/
|
|
1315
|
+
declare function toolbarCommandStates(snapshot: EditorSnapshot, ids: readonly ChromeSlotId[], host?: ToolbarHost): readonly ToolbarCommandState[];
|
|
1316
|
+
/**
|
|
1317
|
+
* Run a slot on the editor: the command of a `command` slot, the picked `value` of a `value` slot,
|
|
1318
|
+
* or the save of `file.save`, which hands the bytes to `host.save` when they are ready, after this
|
|
1319
|
+
* call returns: `ok` then means that the save started or was already running. One undo step for
|
|
1320
|
+
* each edit. A refused edit returns a refusal, never `ok`: the engine's refusal, or one of the
|
|
1321
|
+
* toolbar itself, for an unknown slot (`not-editable`), a value that is not a value of the slot
|
|
1322
|
+
* (`bad-format`), or a save with no `host.save` (`not-editable`). While `host.opening` returns
|
|
1323
|
+
* true, a save is refused with `loading` before any save work starts. While a workbook loads, every
|
|
1324
|
+
* slot is refused with `loading` through the engine, which keeps and announces the refusal, also
|
|
1325
|
+
* where the toolbar refuses on its own; a save to `host.save` has `command: 'save'`.
|
|
1326
|
+
*
|
|
1327
|
+
* @public
|
|
1328
|
+
*/
|
|
1329
|
+
declare function runToolbarCommand(editor: XlsxEditorInstance, id: ChromeSlotId, value?: string, host?: ToolbarHost): EditResult;
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* How typed text reads: the workbook's date system and the year of a date typed with no year.
|
|
1333
|
+
*
|
|
1334
|
+
* @public
|
|
1335
|
+
*/
|
|
1336
|
+
interface CellEntryOptions {
|
|
1337
|
+
/**
|
|
1338
|
+
* True when the workbook uses the 1904 date system (`x:workbookPr/@date1904`, Part 1,
|
|
1339
|
+
* 18.17.4.1). False when absent.
|
|
1340
|
+
*/
|
|
1341
|
+
readonly date1904?: boolean;
|
|
1342
|
+
/**
|
|
1343
|
+
* The year of a date typed with no year, such as `3/15`. The year of the host clock when
|
|
1344
|
+
* absent. A value that is not an integer, or a year that the date system cannot hold, leaves
|
|
1345
|
+
* such a date as text.
|
|
1346
|
+
*/
|
|
1347
|
+
readonly year?: number;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* What a structural refusal names, as a kind of content and a display name: the sheet name,
|
|
1352
|
+
* the defined name, or a reference such as `Data!B5`. Chrome shows it through
|
|
1353
|
+
* {@link refusalText} and {@link subjectText}, never the part path.
|
|
1354
|
+
*
|
|
1355
|
+
* @public
|
|
1356
|
+
*/
|
|
1357
|
+
type RefusalSubject = StructureSubject;
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* Read the text of the cell editor as a store input: the value that a cell with the General
|
|
1361
|
+
* format stores. A typed form such as `12%` or `2026-11-12` reads as a number; the number
|
|
1362
|
+
* format that the editor also sets is not part of the result. `options` gives the date system
|
|
1363
|
+
* of the workbook (1900 when absent) and the year of a date with no year (the year of the host
|
|
1364
|
+
* clock when absent). Write cell values through the editor (`enterValue`), which applies the
|
|
1365
|
+
* number format rules of the cell.
|
|
1366
|
+
*
|
|
1367
|
+
* @public
|
|
1368
|
+
*/
|
|
1369
|
+
declare function parseCellInput(text: string, locale: NumberLocale, options?: CellEntryOptions): CellInput;
|
|
1370
|
+
/**
|
|
1371
|
+
* Why an edit was refused. Each code has a whole-sentence message in the shared catalog at
|
|
1372
|
+
* `editing.refused.<code>`; a test keeps the two lists equal. `edit-dropped` is the one code that
|
|
1373
|
+
* no command returns: the editor keeps it in `snapshot().refusal` when it drops an open edit with
|
|
1374
|
+
* changed text (another open, `close`, or a surface that closes while an input method composes).
|
|
1375
|
+
* `loading` refuses every command, a save included, while a workbook loads.
|
|
1376
|
+
*
|
|
1377
|
+
* `shared-formula` refuses an edit (a typed value or formula, or a paste), a clear, or the clear
|
|
1378
|
+
* of a merge with `dropValues` that would break a formula range. The editor keeps each formula
|
|
1379
|
+
* range whole. The cases:
|
|
1380
|
+
*
|
|
1381
|
+
* - The cell is the master of, or inside, an array or data table formula range. Its master can
|
|
1382
|
+
* be inside `mc:AlternateContent`.
|
|
1383
|
+
* - The cell is a shared formula master whose text cannot be read.
|
|
1384
|
+
* - The cell is a shared formula master, and a child has its `x:f` inside `mc:AlternateContent`
|
|
1385
|
+
* in its cell. The editor cannot rewrite that child. A paste over the master is refused, also
|
|
1386
|
+
* when it covers that child.
|
|
1387
|
+
* - The edit would move the formula of a shared child out of the grid.
|
|
1388
|
+
*
|
|
1389
|
+
* An edit to any other shared formula master writes each child's own formula first. An edit or
|
|
1390
|
+
* a clear of a cell with a formula inside `mc:AlternateContent`, a formula range master or a
|
|
1391
|
+
* wrapped shared child too, is refused with `cell-alternate-content` instead.
|
|
1392
|
+
*
|
|
1393
|
+
* @public
|
|
1394
|
+
*/
|
|
1395
|
+
declare const EDIT_REFUSAL_CODES: readonly ['unknown-sheet', 'bad-reference', 'bad-value', 'text-too-long', 'bad-size', 'merge-one-cell', 'merge-overlap', 'merge-drops-values', 'bad-position', 'invalid-sheet', 'shared-formula', 'unreadable-formula', 'formula-syntax', 'r1c1-formula', 'unsupported-function', 'unknown-formula-reference', 'invalid-character', 'unsupported-package', 'cell-alternate-content', 'bad-format', 'unreadable-number-format', 'range-too-large', 'clear-too-large', 'decimals-too-large', 'decimals-unchanged', 'style-limit', 'invalid-part', 'locked', 'structure-blocked', 'sheet-range-blocked', 'grid-full', 'stale-revision', 'save-failed', 'sheet-name-invalid', 'sheet-name-too-long', 'sheet-name-taken', 'sheet-name-ambiguous', 'last-sheet', 'nothing-to-undo', 'nothing-to-redo', 'not-editable', 'whole-sheet', 'merged-range', 'paste-html', 'copy-too-large', 'copy-conditional-limit', 'copy-array-formula', 'copy-unreadable-formula', 'copy-wrapped-formula', 'paste-unreadable-formula', 'paste-name-scope', 'cut-wrapped-value', 'cut-expired', 'copy-expired', 'paste-reference-outside', 'too-many-rows', 'resize-anchor', 'view-mode', 'composing', 'edit-pending', 'edit-dropped', 'loading', 'go-to-reference', 'go-to-name', 'go-to-sheet'];
|
|
1396
|
+
/**
|
|
1397
|
+
* Why an edit was refused: one of `EDIT_REFUSAL_CODES`.
|
|
1398
|
+
*
|
|
1399
|
+
* @public
|
|
1400
|
+
*/
|
|
1401
|
+
type EditRefusalCode = (typeof EDIT_REFUSAL_CODES)[number];
|
|
1402
|
+
/**
|
|
1403
|
+
* A refused edit: the code, and the fields that the code fills.
|
|
1404
|
+
*
|
|
1405
|
+
* @public
|
|
1406
|
+
*/
|
|
1407
|
+
interface EditRefusal {
|
|
1408
|
+
readonly code: EditRefusalCode;
|
|
1409
|
+
/** The engine's detail for logs. It is never shown as user text, and its words can change. */
|
|
1410
|
+
readonly detail?: string;
|
|
1411
|
+
/**
|
|
1412
|
+
* What the refusal names, as the file or the typed text names it: an element and its part, a
|
|
1413
|
+
* part, a cell (`Data!B5`), a range (`B2:C3`), a sheet name, or the function that
|
|
1414
|
+
* `unsupported-function` refuses. A merge names a cell or a range of the shown sheet, with no
|
|
1415
|
+
* sheet name.
|
|
1416
|
+
* When the refusal has no `about`, `refusalText` shows it where the message has `{subject}`,
|
|
1417
|
+
* with bidirectional controls removed and cut to 64 characters; else `about` stands in its
|
|
1418
|
+
* place and this is for logs. A message whose refusal names nothing has a subject-free text. A
|
|
1419
|
+
* `resize-anchor` refusal of an object with no name shows a generic label.
|
|
1420
|
+
*/
|
|
1421
|
+
readonly subject?: string;
|
|
1422
|
+
/**
|
|
1423
|
+
* The cell, with its sheet (`Data!A2`), whose formula the editor cannot rewrite, on a
|
|
1424
|
+
* `shared-formula` refusal of a shared formula master: a child inside `mc:AlternateContent`, a
|
|
1425
|
+
* child whose formula would move out of the grid, or a master whose text cannot be read. The
|
|
1426
|
+
* message names it beside `masterCell` (`editing.formulaCellRefused.<command>`, with `edit`
|
|
1427
|
+
* for a cell edit).
|
|
1428
|
+
*/
|
|
1429
|
+
readonly causeCell?: string;
|
|
1430
|
+
/**
|
|
1431
|
+
* True when the formula of `causeCell` cannot be read: the message then says so
|
|
1432
|
+
* (`editing.formulaUnreadableRefused.<command>`). On a `resize-anchor` refusal, true when the
|
|
1433
|
+
* drawing part of the sheet cannot be read: the message then says so
|
|
1434
|
+
* (`editing.resizeUnreadDrawing`).
|
|
1435
|
+
*/
|
|
1436
|
+
readonly causeUnreadable?: true;
|
|
1437
|
+
/**
|
|
1438
|
+
* The shared formula master, with its sheet (`Data!A1`), that the refused command would
|
|
1439
|
+
* change, beside `causeCell`. It is inside the edited, cleared, cut, or pasted cells, so the
|
|
1440
|
+
* message names it as the cell to leave out.
|
|
1441
|
+
*/
|
|
1442
|
+
readonly masterCell?: string;
|
|
1443
|
+
/**
|
|
1444
|
+
* What a `structure-blocked` or `grid-full` refusal names, for user text. A
|
|
1445
|
+
* `sheet-range-blocked` refusal has it as `OpRejection.about` states.
|
|
1446
|
+
*/
|
|
1447
|
+
readonly about?: RefusalSubject;
|
|
1448
|
+
/**
|
|
1449
|
+
* The command that the refusal stopped, when it is not a cell edit. `save` marks a save
|
|
1450
|
+
* (`save()`, the save control, or Control or Command and S) that wrote nothing, with the reason
|
|
1451
|
+
* as the code: `loading`, `not-editable`, `composing`, or the code that refused the commit of the
|
|
1452
|
+
* open cell edit (`SAVE_REFUSAL_CODES`). `format`, `clear` (of values or of formats), `clearAll`,
|
|
1453
|
+
* `structure`, `cut`, and `paste` mark a `locked` refusal of that kind of command, so its message
|
|
1454
|
+
* names the command. `clear`, `clearAll`, `paste`, and `merge` also mark a
|
|
1455
|
+
* `cell-alternate-content` or `shared-formula` refusal of that command, so its message names the
|
|
1456
|
+
* command. `merge` marks such a refusal of the clear of `dropValues`. `commit` marks such a
|
|
1457
|
+
* refusal of the commit of an open cell edit: the cell editor stays open, so its message tells
|
|
1458
|
+
* the user to cancel the cell edit. A save that commits first has `save` instead. A `locked`
|
|
1459
|
+
* refusal of a value edit, a column width or a row height, a merge or an unmerge, or a sheet op has no
|
|
1460
|
+
* command: its rule (`lock`: `cell`, `size`, `merge`, or `workbook`) names the message. `cut`
|
|
1461
|
+
* marks every refusal of a cut, whatever its code (`CUT_REFUSAL_CODES` names the codes with
|
|
1462
|
+
* their own cut message), but not a refusal of the open cell edit that the cut commits first:
|
|
1463
|
+
* that refusal has `commit` or no command, as any commit has.
|
|
1464
|
+
* When a load changes a refusal to `loading`, the refusal keeps its command. It is set only on
|
|
1465
|
+
* a refused save or cut, on a `locked` refusal of `format`, `clear`, `clearAll`, `structure`, or
|
|
1466
|
+
* `paste`, on a `cell-alternate-content` or `shared-formula` refusal of `clear`, `clearAll`,
|
|
1467
|
+
* `paste`, `merge`, or `commit`, and on a `loading` refusal that replaced one of those during a load; every
|
|
1468
|
+
* other refusal has no command.
|
|
1469
|
+
*/
|
|
1470
|
+
readonly command?: 'save' | 'format' | 'clear' | 'clearAll' | 'structure' | 'cut' | 'paste' | 'merge' | 'commit';
|
|
1471
|
+
/**
|
|
1472
|
+
* The protection rule of a `locked` refusal: a locked `cell` (or a new cell format that would
|
|
1473
|
+
* change the protection of a cell), `format` when the protected sheet does not allow
|
|
1474
|
+
* formatting cells, `structure` when it does not allow the insert or
|
|
1475
|
+
* the delete, `size` when it does not allow a column width or a row height, or `workbook`
|
|
1476
|
+
* when the workbook protection locks the sheet list (adding, renaming, deleting, and moving
|
|
1477
|
+
* sheets), or `merge` when the sheet is protected, because a protected sheet allows no merge
|
|
1478
|
+
* or unmerge. The message names the rule.
|
|
1479
|
+
*/
|
|
1480
|
+
readonly lock?: 'cell' | 'format' | 'structure' | 'size' | 'workbook' | 'merge';
|
|
1481
|
+
/**
|
|
1482
|
+
* Why the command changed nothing, in the words of its disabled control: a catalog key and its
|
|
1483
|
+
* parameters. Set on `decimals-unchanged` and `decimals-too-large`, which name the cell or the
|
|
1484
|
+
* selection that stops the step. `refusalText` shows it, and `toolbarCommandState` gives it as
|
|
1485
|
+
* the disabled reason.
|
|
1486
|
+
*/
|
|
1487
|
+
readonly reason?: ChromeDisabledReason;
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* The outcome of an edit command. A refused write never reports `ok`.
|
|
1491
|
+
*
|
|
1492
|
+
* @public
|
|
1493
|
+
*/
|
|
1494
|
+
type EditResult = {
|
|
1495
|
+
readonly ok: true;
|
|
1496
|
+
} | {
|
|
1497
|
+
readonly ok: false;
|
|
1498
|
+
readonly refusal: EditRefusal;
|
|
1499
|
+
};
|
|
1500
|
+
/**
|
|
1501
|
+
* A translation function: a key of the shared catalog and its parameters, to display text. The
|
|
1502
|
+
* text helpers (`refusalText`, `subjectText`, `disabledReasonText`) and the editor take it.
|
|
1503
|
+
*
|
|
1504
|
+
* @public
|
|
1505
|
+
*/
|
|
1506
|
+
type EditorTranslate = {
|
|
1507
|
+
translate(key: string, params?: Readonly<Record<string, string | number>>): string;
|
|
1508
|
+
}['translate'];
|
|
1509
|
+
/**
|
|
1510
|
+
* A name from the file as a message shows it: without control characters (C0, U+007F, and C1)
|
|
1511
|
+
* and bidirectional format controls, which could reorder the message around it, and cut to 64
|
|
1512
|
+
* characters, the last one an ellipsis. Use it for each sheet, cell, range, or part name in a
|
|
1513
|
+
* message.
|
|
1514
|
+
*
|
|
1515
|
+
* @public
|
|
1516
|
+
*/
|
|
1517
|
+
declare function displayName(name: string): string;
|
|
1518
|
+
/**
|
|
1519
|
+
* The user words of a refusal subject: a noun of the catalog's `structureSubject` keys, such as
|
|
1520
|
+
* "a drawing" or "the defined name Rates". The name loses bidirectional controls and is cut to
|
|
1521
|
+
* 64 characters.
|
|
1522
|
+
*
|
|
1523
|
+
* @public
|
|
1524
|
+
*/
|
|
1525
|
+
declare function subjectText(about: RefusalSubject, t: EditorTranslate): string;
|
|
1526
|
+
/**
|
|
1527
|
+
* The codes that a save can return: a load, no open workbook, a composition, and the codes
|
|
1528
|
+
* that refuse the commit of the open cell edit. Each has a whole-sentence message at
|
|
1529
|
+
* `editing.saveRefused.<code>`; a save with another code shows `editing.saveRefused.other`.
|
|
1530
|
+
*
|
|
1531
|
+
* @public
|
|
1532
|
+
*/
|
|
1533
|
+
declare const SAVE_REFUSAL_CODES: readonly ["loading", "not-editable", "composing", "view-mode", "unknown-sheet", "bad-reference", "bad-value", "text-too-long", "invalid-sheet", "shared-formula", "unreadable-formula", "formula-syntax", "r1c1-formula", "unsupported-function", "unknown-formula-reference", "invalid-character", "unsupported-package", "cell-alternate-content", "style-limit", "invalid-part", "locked", "stale-revision", "save-failed"];
|
|
1534
|
+
/**
|
|
1535
|
+
* The codes of a cut refusal that have their own message at `editing.cutRefused.<code>`: a load,
|
|
1536
|
+
* view mode, no open workbook, the copy codes (`copy-wrapped-formula` for a formula that only
|
|
1537
|
+
* `mc:AlternateContent` holds, as the copy gives it), `cut-wrapped-value` for a value that the
|
|
1538
|
+
* copy cannot carry, and `cell-alternate-content`, `shared-formula`, or `invalid-sheet` when the
|
|
1539
|
+
* store cannot clear the cut cells. A `locked` cut has an `editing.lockedRefused` message. The
|
|
1540
|
+
* dry run of the clear can also give another store code, such as `style-limit` or
|
|
1541
|
+
* `invalid-part`: that cut shows `editing.cutRefused.other`. A refusal of the open cell edit
|
|
1542
|
+
* that the cut commits first is not a cut refusal.
|
|
1543
|
+
*
|
|
1544
|
+
* @public
|
|
1545
|
+
*/
|
|
1546
|
+
declare const CUT_REFUSAL_CODES: readonly ["loading", "view-mode", "not-editable", "merged-range", "copy-too-large", "copy-conditional-limit", "copy-array-formula", "copy-unreadable-formula", "copy-wrapped-formula", "cut-wrapped-value", "cell-alternate-content", "shared-formula", "invalid-sheet"];
|
|
1547
|
+
|
|
1548
|
+
/**
|
|
1549
|
+
* The user text of a refusal: one whole-sentence message of the catalog, never composed from parts
|
|
1550
|
+
* and never cut. It is `editing.refused.<code>` for a command, `editing.saveRefused.<code>` for a
|
|
1551
|
+
* save, `editing.cutRefused.<code>` for a cut, and an `editing.lockedRefused` key for a `locked`
|
|
1552
|
+
* refusal with a protection rule (`lock`: `cell`, `format`, `structure`, `size`, or `workbook`)
|
|
1553
|
+
* or a command, by the rule that refused it. A `cell-alternate-content` or `shared-formula`
|
|
1554
|
+
* refusal of a clear, a paste, or a merge shows an `editing.alternateRefused` or
|
|
1555
|
+
* `editing.formulaRangeRefused` key of that command. With no subject, a `shared-formula` refusal
|
|
1556
|
+
* of one of them shows `editing.formulaRangeRefusedUnnamed`, and a `cell-alternate-content`
|
|
1557
|
+
* refusal of a merge or a commit shows `editing.alternateRefusedUnnamed`. A `shared-formula` refusal with a
|
|
1558
|
+
* `causeCell` and a `masterCell` shows `editing.formulaCellRefused.<command>` (`edit` for a
|
|
1559
|
+
* cell edit), or `editing.formulaUnreadableRefused.<command>` with `causeUnreadable`. It names
|
|
1560
|
+
* the master to leave out, and the cell whose formula blocks it. A save or a cut with a code
|
|
1561
|
+
* outside its list (`SAVE_REFUSAL_CODES`, `CUT_REFUSAL_CODES`) shows `editing.saveRefused.other`
|
|
1562
|
+
* or `editing.cutRefused.other`. `{subject}` is the words of `about` when the refusal has one, else
|
|
1563
|
+
* the name as the file names it (a cell such as `Data!B5`); a refusal that names nothing shows
|
|
1564
|
+
* the subject-free message (`editing.refusedUnnamed.<code>`, `editing.saveRefusedUnnamed.<code>`,
|
|
1565
|
+
* `editing.cutRefusedUnnamed.<code>`), so no placeholder shows. A `structure-blocked` refusal
|
|
1566
|
+
* whose `about` kind is `not-worksheet` shows `editing.notWorksheetRefused`. A
|
|
1567
|
+
* `structure-blocked` or `sheet-range-blocked` refusal whose `about` kind is `wrapped-formula`
|
|
1568
|
+
* shows `editing.wrappedFormulaRefused`, and a `resize-anchor`
|
|
1569
|
+
* refusal with `causeUnreadable` shows `editing.resizeUnreadDrawing`. `{limit}` is grouped
|
|
1570
|
+
* with the separator of `locale`, US English by default. Chrome and the live region show refusals
|
|
1571
|
+
* through this one function.
|
|
1572
|
+
*
|
|
1573
|
+
* @public
|
|
1574
|
+
*/
|
|
1575
|
+
declare function refusalText(refusal: EditRefusal, t: EditorTranslate, locale?: NumberLocale): string;
|
|
1576
|
+
|
|
1577
|
+
/**
|
|
1578
|
+
* One sheet of the workbook, in tab order.
|
|
1579
|
+
*
|
|
1580
|
+
* @public
|
|
1581
|
+
*/
|
|
1582
|
+
interface EditorSheet {
|
|
1583
|
+
/** The position in `x:sheets`. */
|
|
1584
|
+
readonly index: number;
|
|
1585
|
+
readonly name: string;
|
|
1586
|
+
/** Hidden and very hidden sheets have no tab. */
|
|
1587
|
+
readonly visible: boolean;
|
|
1588
|
+
/**
|
|
1589
|
+
* Whether the sheet is a worksheet that the editor can show. A chartsheet, a macro sheet, a
|
|
1590
|
+
* dialog sheet, or a sheet whose part is missing is not.
|
|
1591
|
+
*/
|
|
1592
|
+
readonly worksheet: boolean;
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* How the editor takes input. `edit` (the default) allows every command. `view` refuses every
|
|
1596
|
+
* edit command with `view-mode`, and keeps selection, sheet tabs, zoom, and save.
|
|
1597
|
+
*
|
|
1598
|
+
* @public
|
|
1599
|
+
*/
|
|
1600
|
+
type EditorMode = 'edit' | 'view';
|
|
1601
|
+
/**
|
|
1602
|
+
* Why a workbook did not open.
|
|
1603
|
+
*
|
|
1604
|
+
* @public
|
|
1605
|
+
*/
|
|
1606
|
+
interface EditorFailure {
|
|
1607
|
+
/**
|
|
1608
|
+
* `package`: the file is not a workbook the engine reads; `fonts`: the text shaper or the fonts did not load;
|
|
1609
|
+
* `no-worksheet`: the workbook opened, but no sheet is a visible worksheet that the editor can
|
|
1610
|
+
* show (every sheet is hidden, a chartsheet, or a missing part).
|
|
1611
|
+
*/
|
|
1612
|
+
readonly code: 'package' | 'fonts' | 'no-worksheet';
|
|
1613
|
+
/** The engine's reason, for logs: never shown as user text. */
|
|
1614
|
+
readonly detail?: string;
|
|
1615
|
+
/**
|
|
1616
|
+
* With the code `package`, the name of the part that did not read, such as
|
|
1617
|
+
* `/xl/sharedStrings.xml`. A failure of the whole package, such as a ZIP limit, names no part.
|
|
1618
|
+
* The name comes from the file: show it as text only, through `displayName`, which drops
|
|
1619
|
+
* control characters and bidirectional format controls and cuts it to 64 characters.
|
|
1620
|
+
*/
|
|
1621
|
+
readonly part?: string;
|
|
1622
|
+
/**
|
|
1623
|
+
* With the code `package`, the limit of the read that the file passed. A refused file with no
|
|
1624
|
+
* `limit` is not a valid package or workbook.
|
|
1625
|
+
*/
|
|
1626
|
+
readonly limit?: 'zip.maxEntries' | 'zip.maxTotalBytes' | 'zip.maxRatio' | 'xml.maxBytes' | 'xml.maxElements' | 'xml.maxDepth';
|
|
1627
|
+
/**
|
|
1628
|
+
* With the code `fonts`, the packaged substitute faces that did not load while other faces
|
|
1629
|
+
* did. Only `onFontError` passes such a failure: the workbook opens, and `snapshot().failure`
|
|
1630
|
+
* stays `null`.
|
|
1631
|
+
*/
|
|
1632
|
+
readonly substituteFailures?: readonly SubstituteFontFailure[];
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* The state of the editor that chrome renders. A new object after each change.
|
|
1636
|
+
*
|
|
1637
|
+
* @public
|
|
1638
|
+
*/
|
|
1639
|
+
interface EditorSnapshot {
|
|
1640
|
+
readonly status: 'empty' | 'loading' | 'ready' | 'failed';
|
|
1641
|
+
readonly failure: EditorFailure | null;
|
|
1642
|
+
readonly sheets: readonly EditorSheet[];
|
|
1643
|
+
/** The position of the shown sheet in `sheets`, or -1. */
|
|
1644
|
+
readonly activeSheet: number;
|
|
1645
|
+
readonly selection: GridSelection | null;
|
|
1646
|
+
/** The selected range as an A1 reference, such as `B2:D2`. */
|
|
1647
|
+
readonly selectionRef: string | null;
|
|
1648
|
+
/**
|
|
1649
|
+
* The active cell's reference and its edit text: formula text, or the value in a form that
|
|
1650
|
+
* reads back, such as `2026-11-12` for a date serial or `12%` for 0.12. A text that would read
|
|
1651
|
+
* back as another type starts with `'`.
|
|
1652
|
+
*/
|
|
1653
|
+
readonly activeCell: {
|
|
1654
|
+
readonly ref: string;
|
|
1655
|
+
readonly content: string;
|
|
1656
|
+
} | null;
|
|
1657
|
+
/** 1 is 100%. */
|
|
1658
|
+
readonly zoom: number;
|
|
1659
|
+
/**
|
|
1660
|
+
* The shown values of formulas can be out of date: the stale flag is set, and the
|
|
1661
|
+
* shown sheet holds a formula cell. That includes a formula cell that the grid does not show:
|
|
1662
|
+
* an `x:c` inside `mc:AlternateContent` (also in a wrapped row), outside a row, or inside
|
|
1663
|
+
* another cell.
|
|
1664
|
+
*/
|
|
1665
|
+
readonly stale: boolean;
|
|
1666
|
+
/** The cell editor is open over the active cell. */
|
|
1667
|
+
readonly editing: boolean;
|
|
1668
|
+
/**
|
|
1669
|
+
* The text of the open cell edit, as typed, or null when no edit is open. A formula bar shows
|
|
1670
|
+
* it in place of `activeCell.content`, so it follows the edit.
|
|
1671
|
+
*/
|
|
1672
|
+
readonly editText: string | null;
|
|
1673
|
+
/**
|
|
1674
|
+
* The open cell edit has typed input, or holds text that differs from the cell's content.
|
|
1675
|
+
* While this is true, redo is refused with `edit-pending`, as the toolbar disables it, and
|
|
1676
|
+
* undo cancels the edit.
|
|
1677
|
+
*/
|
|
1678
|
+
readonly editChanged: boolean;
|
|
1679
|
+
/**
|
|
1680
|
+
* An input method composes in the open cell editor, or in a field that reported it through
|
|
1681
|
+
* `setEditText`. Every command that would commit the
|
|
1682
|
+
* edit, and undo, is refused with `composing` until the composition ends.
|
|
1683
|
+
*/
|
|
1684
|
+
readonly composing: boolean;
|
|
1685
|
+
readonly canUndo: boolean;
|
|
1686
|
+
readonly canRedo: boolean;
|
|
1687
|
+
/**
|
|
1688
|
+
* Why the last edit, save, or command was refused, or null. These events clear it: an edit
|
|
1689
|
+
* that the store accepts, a good save, a copy or a cut that succeeds, a change of the
|
|
1690
|
+
* selection, the sheet, or the mode, a cancel of the open cell edit, a cell edit that opens
|
|
1691
|
+
* (except for `edit-dropped`), and the start or the settle of a load. A new refusal
|
|
1692
|
+
* replaces it, and so does `edit-dropped` when a load, `close`, or a closing surface drops
|
|
1693
|
+
* an open edit with changed text. When the load settles, `edit-dropped` stays (see
|
|
1694
|
+
* `editDropped`). While a load runs, each new refusal is stored with the code `loading`.
|
|
1695
|
+
*/
|
|
1696
|
+
readonly refusal: EditRefusal | null;
|
|
1697
|
+
/**
|
|
1698
|
+
* An open cell edit with changed text was dropped without a commit (a load, `close`, or a
|
|
1699
|
+
* surface that closed while an input method composed). It stays true after the load
|
|
1700
|
+
* settles, until the next command after the load, done or refused, an edit that the editor
|
|
1701
|
+
* stores, or a selection change, or the next load. A cell edit that opens keeps it. While the load runs, it stays true when a `loading` refusal
|
|
1702
|
+
* replaces `edit-dropped` in `refusal`.
|
|
1703
|
+
*/
|
|
1704
|
+
readonly editDropped: boolean;
|
|
1705
|
+
/** The number locale of the shown values, which `refusalText` groups a number with. */
|
|
1706
|
+
readonly numberLocale: NumberLocale;
|
|
1707
|
+
/**
|
|
1708
|
+
* The cell format of the active cell, as the grid shows it: the state of the format
|
|
1709
|
+
* commands. The Mod+B, Mod+I, and Mod+U toggles read the same format.
|
|
1710
|
+
*/
|
|
1711
|
+
readonly activeFormat: ActiveCellFormat | null;
|
|
1712
|
+
/** The decimal steps on the selection, from the stored cells, also while a cell edit is open. */
|
|
1713
|
+
readonly decimalSteps: DecimalSteps;
|
|
1714
|
+
/**
|
|
1715
|
+
* Why the structural commands (insert and delete rows and columns) are refused, or null:
|
|
1716
|
+
* `whole-sheet` when the whole sheet is selected, or the refusal of the shown sheet whatever
|
|
1717
|
+
* the selection. A command that this does not refuse can still be
|
|
1718
|
+
* refused by its own rows or columns, for example with `grid-full`.
|
|
1719
|
+
*/
|
|
1720
|
+
readonly structureRefusal: EditRefusal | null;
|
|
1721
|
+
/**
|
|
1722
|
+
* Why a format patch is refused for the selection (`range-too-large`: it would create more
|
|
1723
|
+
* than `MAX_FORMAT_NEW_CELLS` cells), or null.
|
|
1724
|
+
*/
|
|
1725
|
+
readonly formatRefusal: EditRefusal | null;
|
|
1726
|
+
/**
|
|
1727
|
+
* The shown sheet has conditional formatting that the grid can leave out, for one of these
|
|
1728
|
+
* causes:
|
|
1729
|
+
* - a rule kind or operand that the engine does not evaluate, or a malformed rule;
|
|
1730
|
+
* - rules past the read limits;
|
|
1731
|
+
* - more than 64 shown rules or 1,024 shown ranges, so the caps of one cell or one row can
|
|
1732
|
+
* take effect;
|
|
1733
|
+
* - rules in an extension list (`x:extLst`);
|
|
1734
|
+
* - a layout of this sheet that ran out of its check budget. This cause depends on the window
|
|
1735
|
+
* that was shown; once set, it stays until the shown sheet changes or another workbook
|
|
1736
|
+
* opens, and a return to the sheet starts without it.
|
|
1737
|
+
* The save keeps every rule. Chrome shows a notice.
|
|
1738
|
+
*/
|
|
1739
|
+
readonly conditionalHidden: boolean;
|
|
1740
|
+
/**
|
|
1741
|
+
* The format state that the grid shows at the active cell when a true conditional formatting
|
|
1742
|
+
* rule changes the state of a format control there, or null. A rule that changes only what
|
|
1743
|
+
* no control shows (strike, `x:vertAlign`, or the underline style) gives null, though the
|
|
1744
|
+
* grid paints it. `activeFormat` stays the cell format, which the format commands read and
|
|
1745
|
+
* set, so `toolbarCommandState` gives a hint to each control whose state differs here.
|
|
1746
|
+
* Rich text runs are not read, as `activeFormat` does not read them. Null after a layout of
|
|
1747
|
+
* the sheet ran out of its check budget, because the grid can then show the cell format.
|
|
1748
|
+
*/
|
|
1749
|
+
readonly conditionalFormat: ActiveCellFormat | null;
|
|
1750
|
+
/**
|
|
1751
|
+
* Why clearing the formats of the selection is refused (`clear-too-large`: it would create
|
|
1752
|
+
* more than `MAX_FORMAT_NEW_CELLS` cells with `s="0"` where a row or column format shows),
|
|
1753
|
+
* or null. Clear formats and Clear all read it.
|
|
1754
|
+
*/
|
|
1755
|
+
readonly clearRefusal: EditRefusal | null;
|
|
1756
|
+
/**
|
|
1757
|
+
* The actions that the protection of the shown sheet allows (`x:sheetProtection`), or null
|
|
1758
|
+
* when the sheet is not protected. A locked cell of a protected sheet refuses a value edit
|
|
1759
|
+
* with `locked`.
|
|
1760
|
+
*/
|
|
1761
|
+
readonly protection: SheetProtection | null;
|
|
1762
|
+
/**
|
|
1763
|
+
* Whether the sheet is protected and the active cell is locked, so typing in it, or a value
|
|
1764
|
+
* edit of it alone, is refused with `locked`. False on a sheet that is not protected.
|
|
1765
|
+
*/
|
|
1766
|
+
readonly activeCellLocked: boolean;
|
|
1767
|
+
/**
|
|
1768
|
+
* Whether the sheet is protected and clearing the contents of the selection would change a
|
|
1769
|
+
* locked cell: the active cell of a one-cell selection, or a cell of the range that exists
|
|
1770
|
+
* and holds content. Clear contents and Clear all are then refused with `locked`. False on a
|
|
1771
|
+
* sheet that is not protected.
|
|
1772
|
+
*/
|
|
1773
|
+
readonly selectionContentLocked: boolean;
|
|
1774
|
+
/**
|
|
1775
|
+
* The first cell of the selection, as `Sheet!A1`, whose value a clear can neither keep nor
|
|
1776
|
+
* replace, or null: Clear contents and Clear all are then refused with
|
|
1777
|
+
* `cell-alternate-content`. A cell with no value in any form is not named.
|
|
1778
|
+
*/
|
|
1779
|
+
readonly selectionContentBlocked: string | null;
|
|
1780
|
+
/**
|
|
1781
|
+
* The formula range, as `Sheet!A1:B2`, that a clear of the selection would break, or null:
|
|
1782
|
+
* Clear contents and Clear all are then refused with `shared-formula`. It is the subject of
|
|
1783
|
+
* that refusal: the formula range, or the blocking cell when that range cannot be read or does
|
|
1784
|
+
* not hold the blocking cell. It comes from
|
|
1785
|
+
* the checks that the clear runs before it changes a cell (`clearRangeBlocker`). A clear that
|
|
1786
|
+
* would move the formula of a shared child out of the grid is refused only when it runs, so
|
|
1787
|
+
* this field is null for it. Null when `selectionContentBlocked` names a cell.
|
|
1788
|
+
*/
|
|
1789
|
+
readonly selectionFormulaRangeBlocked: string | null;
|
|
1790
|
+
/**
|
|
1791
|
+
* The cell, as `Sheet!A2`, whose formula the editor cannot rewrite, when it is why a clear of
|
|
1792
|
+
* the selection would break the shared formula range in `selectionFormulaRangeBlocked` (the
|
|
1793
|
+
* `causeCell` of that refusal), or null. The disabled reason names it.
|
|
1794
|
+
*/
|
|
1795
|
+
readonly selectionFormulaRangeCauseCell: string | null;
|
|
1796
|
+
/**
|
|
1797
|
+
* True when the formula of `selectionFormulaRangeCauseCell` cannot be read (the
|
|
1798
|
+
* `causeUnreadable` of that refusal), or null. The disabled reason then says so.
|
|
1799
|
+
*/
|
|
1800
|
+
readonly selectionFormulaRangeCauseUnreadable: true | null;
|
|
1801
|
+
/**
|
|
1802
|
+
* The shared formula master in the selection, as `Sheet!A1`, that the clear would change, when
|
|
1803
|
+
* `selectionFormulaRangeCauseCell` is set (the `masterCell` of that refusal), or null. The
|
|
1804
|
+
* disabled reason names it as the cell to leave out.
|
|
1805
|
+
*/
|
|
1806
|
+
readonly selectionFormulaRangeMasterCell: string | null;
|
|
1807
|
+
/**
|
|
1808
|
+
* Whether the selection meets a merged range of the shown sheet: a merge of the selection is
|
|
1809
|
+
* then refused with `merge-overlap`, and an unmerge changes it. `mergeCommandState` reads it.
|
|
1810
|
+
*/
|
|
1811
|
+
readonly selectionMerged: boolean;
|
|
1812
|
+
/**
|
|
1813
|
+
* Whether the selection is one cell, or exactly one merged range. A pick of the number format
|
|
1814
|
+
* list that shows the current entry then keeps the format, and a decimal step reason speaks
|
|
1815
|
+
* of this cell, not of a selected cell.
|
|
1816
|
+
*/
|
|
1817
|
+
readonly selectionSingle: boolean;
|
|
1818
|
+
/**
|
|
1819
|
+
* The first cell of the selection, in reading order, that a merge would empty (a cell other
|
|
1820
|
+
* than the top-left cell that holds a value or a formula), or null. A host reads it to ask the
|
|
1821
|
+
* user before it calls `mergeCells({ dropValues: true })`. An open cell edit counts as it would
|
|
1822
|
+
* be after its commit, which the merge makes first: text that is not empty is a value. Null
|
|
1823
|
+
* also when the selection is one cell or meets a merged range: the merge then refuses for that
|
|
1824
|
+
* reason (`mergeCommandState`).
|
|
1825
|
+
*/
|
|
1826
|
+
readonly selectionDropsValuesAt: string | null;
|
|
1827
|
+
/**
|
|
1828
|
+
* What the workbook protection allows (`x:workbookProtection`), or null when the workbook
|
|
1829
|
+
* has none. When `allowStructure` is false, `addSheet`, `renameSheet`, `deleteSheet`, and
|
|
1830
|
+
* `moveSheet` are refused with `locked` (rule `workbook`), and the sheet tabs disable them.
|
|
1831
|
+
*/
|
|
1832
|
+
readonly workbookProtection: WorkbookProtection | null;
|
|
1833
|
+
/**
|
|
1834
|
+
* Why a rename or a delete of any sheet is refused, whatever the sheet, or null: a chart, a
|
|
1835
|
+
* pivot table, or a sheet that is not a worksheet in the workbook, or a workbook or package
|
|
1836
|
+
* relationship outside the allowlist (`structure-blocked`). The
|
|
1837
|
+
* sheet menu disables Rename and Delete with it (`sheetCommandState`). A rename or a delete
|
|
1838
|
+
* that this does not refuse can still be refused by its own sheet.
|
|
1839
|
+
*/
|
|
1840
|
+
readonly sheetEditRefusal: EditRefusal | null;
|
|
1841
|
+
/** `edit`, or `view` when every edit command is refused (`setMode`). */
|
|
1842
|
+
readonly mode: EditorMode;
|
|
1843
|
+
/**
|
|
1844
|
+
* The count of `setMode` calls that applied a mode, also the mode that the editor has; a
|
|
1845
|
+
* refused call does not count. It is host coordination, kept public on purpose: an adapter
|
|
1846
|
+
* that waits to apply a mode of its own (the React root's `mode` prop) reads in it that a
|
|
1847
|
+
* host call applied a newer mode, and ends its wait. An internal accessor would hide that
|
|
1848
|
+
* rule from a host that builds its own adapter.
|
|
1849
|
+
*/
|
|
1850
|
+
readonly modeRequests: number;
|
|
1851
|
+
/**
|
|
1852
|
+
* The content revision of the open workbook: 0 after an open, and one more after each change
|
|
1853
|
+
* of its content (an edit, an undo, or a redo). A view change (selection, zoom, sheet, mode,
|
|
1854
|
+
* an open cell edit) keeps it. Compare it to tell a content change from a view change, for
|
|
1855
|
+
* example to track unsaved edits: keep the revision of the last save.
|
|
1856
|
+
*/
|
|
1857
|
+
readonly revision: number;
|
|
1858
|
+
/**
|
|
1859
|
+
* The kind of the open package by its main part: `workbook` (`.xlsx`) or `template`
|
|
1860
|
+
* (`.xltx`), or null with no workbook open. `save()` keeps the kind, so a host names the saved
|
|
1861
|
+
* file with the matching extension.
|
|
1862
|
+
*/
|
|
1863
|
+
readonly workbookKind: WorkbookKind | null;
|
|
1864
|
+
/**
|
|
1865
|
+
* The parts of the open workbook that passed an XML part limit and stay as bytes, by part
|
|
1866
|
+
* name, or an empty list. The list keeps its identity while it does not change. Chrome shows
|
|
1867
|
+
* a notice that names them.
|
|
1868
|
+
*/
|
|
1869
|
+
readonly partsPastLimit: readonly PartPastLimit[];
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* The kind of a package by the content type of its main part.
|
|
1873
|
+
*
|
|
1874
|
+
* @public
|
|
1875
|
+
*/
|
|
1876
|
+
type WorkbookKind = 'workbook' | 'template';
|
|
1877
|
+
/**
|
|
1878
|
+
* A part that passed an XML part limit and stays in the file as bytes. The workbook opens
|
|
1879
|
+
* without it, and a save keeps its bytes.
|
|
1880
|
+
*
|
|
1881
|
+
* @public
|
|
1882
|
+
*/
|
|
1883
|
+
interface PartPastLimit {
|
|
1884
|
+
/**
|
|
1885
|
+
* The part name, such as `/xl/styles.xml`. It comes from the file: show it as text only,
|
|
1886
|
+
* through `displayName`.
|
|
1887
|
+
*/
|
|
1888
|
+
readonly part: string;
|
|
1889
|
+
/**
|
|
1890
|
+
* `styles`: every cell shows the default format. `theme`: the theme colors and fonts do not
|
|
1891
|
+
* apply. `drawing`: the pictures of the drawing do not show. `relationships`: the parts that
|
|
1892
|
+
* the relationship part links to do not show. `other`: a styles or theme part that the
|
|
1893
|
+
* workbook part does not link to, so nothing that the workbook shows depends on it.
|
|
1894
|
+
*/
|
|
1895
|
+
readonly kind: 'styles' | 'theme' | 'drawing' | 'relationships' | 'other';
|
|
1896
|
+
/** The limit that the part passed. */
|
|
1897
|
+
readonly limit: 'xml.maxBytes' | 'xml.maxElements' | 'xml.maxDepth';
|
|
1898
|
+
}
|
|
1899
|
+
/**
|
|
1900
|
+
* The cell format of the active cell, as the format commands read and set it.
|
|
1901
|
+
*
|
|
1902
|
+
* @public
|
|
1903
|
+
*/
|
|
1904
|
+
interface ActiveCellFormat {
|
|
1905
|
+
readonly bold: boolean;
|
|
1906
|
+
readonly italic: boolean;
|
|
1907
|
+
/** Any underline. */
|
|
1908
|
+
readonly underline: boolean;
|
|
1909
|
+
/** The font family, with a theme font resolved to its typeface. */
|
|
1910
|
+
readonly fontName: string;
|
|
1911
|
+
/** Points. */
|
|
1912
|
+
readonly fontSize: number;
|
|
1913
|
+
/** `RRGGBB`. */
|
|
1914
|
+
readonly fontColor: string;
|
|
1915
|
+
/** The color of a solid fill as `RRGGBB`, or `null` for no fill, a pattern, or a gradient. */
|
|
1916
|
+
readonly fillColor: string | null;
|
|
1917
|
+
/** `ST_HorizontalAlignment`; `general` aligns by value type. */
|
|
1918
|
+
readonly horizontal: string;
|
|
1919
|
+
/** `ST_VerticalAlignment`. */
|
|
1920
|
+
readonly vertical: string;
|
|
1921
|
+
readonly wrapText: boolean;
|
|
1922
|
+
/**
|
|
1923
|
+
* The number format id and its code in the editor's locale. `hasCode` is false for an id with
|
|
1924
|
+
* no code here (a built-in id with no locale or ECMA-376 code, or a custom id with no
|
|
1925
|
+
* `x:numFmt` record): such a cell shows `General`.
|
|
1926
|
+
*/
|
|
1927
|
+
readonly numberFormat: {
|
|
1928
|
+
readonly id: number;
|
|
1929
|
+
readonly code: string;
|
|
1930
|
+
readonly hasCode: boolean;
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* How an editor opens workbooks.
|
|
1935
|
+
*
|
|
1936
|
+
* @public
|
|
1937
|
+
*/
|
|
1938
|
+
interface XlsxEditorOptions {
|
|
1939
|
+
/**
|
|
1940
|
+
* The faces that measure and paint text, or a function that loads them once. Omitted, the
|
|
1941
|
+
* packaged substitute faces load (`loadSubstituteFonts()`), as in DOCX Editor and PPTX
|
|
1942
|
+
* Editor. The engine never fetches a font that a workbook names.
|
|
1943
|
+
*/
|
|
1944
|
+
readonly fonts?: readonly FontSource[] | (() => Promise<readonly FontSource[]>);
|
|
1945
|
+
/** The number locale of the shown values. US English separators when absent. */
|
|
1946
|
+
readonly numberLocale?: NumberLocale;
|
|
1947
|
+
/**
|
|
1948
|
+
* Translates the labels that the grid surface shows to assistive technology. English, from
|
|
1949
|
+
* the shared catalog, when absent.
|
|
1950
|
+
*/
|
|
1951
|
+
readonly translate?: EditorTranslate;
|
|
1952
|
+
/** `edit` (the default) or `view`. Change it later with `setMode`. */
|
|
1953
|
+
readonly mode?: EditorMode;
|
|
1954
|
+
}
|
|
1955
|
+
/**
|
|
1956
|
+
* The snapshot of an editor with no workbook.
|
|
1957
|
+
*
|
|
1958
|
+
* @public
|
|
1959
|
+
*/
|
|
1960
|
+
declare const EMPTY_SNAPSHOT: EditorSnapshot;
|
|
1961
|
+
/** The zoom limits of `x:sheetView/@zoomScale` (10 to 400%). */
|
|
1962
|
+
declare const MIN_ZOOM = 0.1;
|
|
1963
|
+
declare const MAX_ZOOM = 4;
|
|
1964
|
+
|
|
1965
|
+
/**
|
|
1966
|
+
* A face that did not load, from `loadSubstituteFonts`.
|
|
1967
|
+
*
|
|
1968
|
+
* @public
|
|
1969
|
+
*/
|
|
1970
|
+
interface SubstituteFontFailure {
|
|
1971
|
+
readonly family: string;
|
|
1972
|
+
readonly file: string;
|
|
1973
|
+
readonly diagnostic: string;
|
|
1974
|
+
}
|
|
1975
|
+
/**
|
|
1976
|
+
* Fetch the packaged substitute faces (Carlito, Caladea, Liberation Sans, Serif, and Mono, and
|
|
1977
|
+
* TeX Gyre Adventor). Resolves with every face that loaded and the failures. A face whose
|
|
1978
|
+
* download stalls ({@link stallLimitedFetch}) is a failure.
|
|
1979
|
+
*
|
|
1980
|
+
* @public
|
|
1981
|
+
*/
|
|
1982
|
+
declare function loadSubstituteFonts(options?: {
|
|
1983
|
+
readonly signal?: AbortSignal;
|
|
1984
|
+
}): Promise<{
|
|
1985
|
+
readonly sources: readonly FontSource[];
|
|
1986
|
+
readonly failures: readonly SubstituteFontFailure[];
|
|
1987
|
+
}>;
|
|
1988
|
+
/**
|
|
1989
|
+
* The fonts of an editor, after PPTX Editor's `FontReport`: the faces in force, and the packaged
|
|
1990
|
+
* substitute faces that did not load. Text in a family whose face failed measures and paints
|
|
1991
|
+
* with another face.
|
|
1992
|
+
*
|
|
1993
|
+
* @public
|
|
1994
|
+
*/
|
|
1995
|
+
interface FontReport {
|
|
1996
|
+
readonly faces: readonly {
|
|
1997
|
+
readonly family: string;
|
|
1998
|
+
readonly origin: string;
|
|
1999
|
+
}[];
|
|
2000
|
+
readonly substituteFailures: readonly SubstituteFontFailure[];
|
|
2001
|
+
}
|
|
2002
|
+
/**
|
|
2003
|
+
* The failure that reports packaged substitute faces that did not load, for `onFontError`, or
|
|
2004
|
+
* null when every face loaded.
|
|
2005
|
+
*
|
|
2006
|
+
* @internal
|
|
2007
|
+
*/
|
|
2008
|
+
declare function substituteFontFailure(failures: readonly SubstituteFontFailure[]): EditorFailure | null;
|
|
2009
|
+
/**
|
|
2010
|
+
* Hand a font failure to the host's `onFontError`, or print one warning when the host has none,
|
|
2011
|
+
* so a failure is never silent, as PPTX Editor's `reportFontError` does.
|
|
2012
|
+
*
|
|
2013
|
+
* @internal
|
|
2014
|
+
*/
|
|
2015
|
+
declare function reportFontError(failure: EditorFailure, handler: ((failure: EditorFailure) => void) | undefined): void;
|
|
2016
|
+
|
|
2017
|
+
/** The faces of an editor: bytes, or a function that loads them once. */
|
|
2018
|
+
type EditorFontSource = readonly FontSource[] | (() => Promise<readonly FontSource[]>);
|
|
2019
|
+
/**
|
|
2020
|
+
* Whether two font sources hold the same faces: the same function, or lists of equal length
|
|
2021
|
+
* whose faces have the same family, style, origin, and bytes (by identity). A host can pass a
|
|
2022
|
+
* new list with each render; only a change of faces loads them again.
|
|
2023
|
+
*/
|
|
2024
|
+
declare function sameFontSource(a: EditorFontSource | undefined, b: EditorFontSource | undefined): boolean;
|
|
2025
|
+
|
|
2026
|
+
/** The color theme of the chrome: `'system'` follows the OS setting. DOCX Editor's type. @public */
|
|
2027
|
+
type ColorMode = 'light' | 'dark' | 'system';
|
|
2028
|
+
/** The theme a root resolved from `colorMode`, never `'system'`. DOCX Editor's type. @public */
|
|
2029
|
+
type ResolvedColorMode = 'light' | 'dark';
|
|
2030
|
+
/** Whether the chrome is dark for `mode`, given the system setting. @internal */
|
|
2031
|
+
declare function resolveDarkChrome(mode: ColorMode | undefined, systemDark: boolean): boolean;
|
|
2032
|
+
/** Whether the operating system prefers a dark scheme now. False without `matchMedia`. @internal */
|
|
2033
|
+
declare function systemPrefersDark(): boolean;
|
|
2034
|
+
/** Be told when the system setting changes. Returns the unsubscribe function. @internal */
|
|
2035
|
+
declare function subscribeSystemDark(listener: () => void): () => void;
|
|
2036
|
+
|
|
2037
|
+
/** The keys that undo and redo: the grid steps the history, and the cell editor keeps them. */
|
|
2038
|
+
/** Modifier and key state of one keydown, as both DOM and framework key events carry it. */
|
|
2039
|
+
interface HistoryShortcutKeys {
|
|
2040
|
+
readonly key: string;
|
|
2041
|
+
readonly metaKey: boolean;
|
|
2042
|
+
readonly ctrlKey: boolean;
|
|
2043
|
+
readonly shiftKey: boolean;
|
|
2044
|
+
}
|
|
2045
|
+
/**
|
|
2046
|
+
* Which history step a keydown asks for, or `null` for any other key.
|
|
2047
|
+
*
|
|
2048
|
+
* Ctrl+Y is the Windows redo; Ctrl/Cmd+Shift+Z is the macOS one. Both are accepted on every
|
|
2049
|
+
* platform, also Meta+Y, which the grid takes as redo.
|
|
2050
|
+
*/
|
|
2051
|
+
declare function historyShortcutOf(event: HistoryShortcutKeys): 'undo' | 'redo' | null;
|
|
2052
|
+
|
|
2053
|
+
/**
|
|
2054
|
+
* The longest text that `selectReference` reads, in UTF-16 code units: a longer text is refused
|
|
2055
|
+
* with `go-to-reference`, and the name box takes no more.
|
|
2056
|
+
*
|
|
2057
|
+
* @public
|
|
2058
|
+
*/
|
|
2059
|
+
declare const MAX_GO_TO_LENGTH = 255;
|
|
2060
|
+
|
|
2061
|
+
/**
|
|
2062
|
+
* Modifier and key state of one keydown, as both DOM and framework key events carry it.
|
|
2063
|
+
*
|
|
2064
|
+
* @public
|
|
2065
|
+
*/
|
|
2066
|
+
interface FieldKeys extends HistoryShortcutKeys {
|
|
2067
|
+
readonly altKey: boolean;
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* The move of Enter (`down`), Shift+Enter (`up`), Tab (`right`), or Shift+Tab (`left`) in a
|
|
2071
|
+
* field that edits the open cell edit, for `commitEdit(move)`, or null for another key. As in
|
|
2072
|
+
* the cell editor, Alt+Enter is a line break, and Control or Command with Enter commits.
|
|
2073
|
+
*
|
|
2074
|
+
* @public
|
|
2075
|
+
*/
|
|
2076
|
+
declare function editMoveOf(keys: FieldKeys): EditMove | null;
|
|
2077
|
+
/**
|
|
2078
|
+
* Whether a keydown belongs to an input method that composes text: the event says so
|
|
2079
|
+
* (`isComposing`, key code 229), or the field saw a composition start and no end (`composing`).
|
|
2080
|
+
*
|
|
2081
|
+
* @public
|
|
2082
|
+
*/
|
|
2083
|
+
declare function composesKey(event: {
|
|
2084
|
+
readonly isComposing?: boolean;
|
|
2085
|
+
readonly keyCode?: number;
|
|
2086
|
+
}, composing: boolean): boolean;
|
|
2087
|
+
/**
|
|
2088
|
+
* The history step that a keydown in a field asks of the workbook, or null: the history keys
|
|
2089
|
+
* (`historyShortcutOf`) when the field holds no typing of its own (`typing` false: no open cell
|
|
2090
|
+
* edit, and no typed draft). With typing, the keys belong to the field.
|
|
2091
|
+
*
|
|
2092
|
+
* @public
|
|
2093
|
+
*/
|
|
2094
|
+
declare function fieldHistoryKey(keys: FieldKeys, typing: boolean): 'undo' | 'redo' | null;
|
|
2095
|
+
/**
|
|
2096
|
+
* Whether the refusal `code` refuses the reference that a field such as the name box gave to
|
|
2097
|
+
* `selectReference`. Another refusal of `selectReference`, such as a refused commit of the open
|
|
2098
|
+
* edit, refuses the edit and not the reference.
|
|
2099
|
+
*
|
|
2100
|
+
* @public
|
|
2101
|
+
*/
|
|
2102
|
+
declare function refusesReference(code: EditRefusalCode): boolean;
|
|
2103
|
+
/**
|
|
2104
|
+
* Whether the refusal `code`, while a cell edit is open, can refuse the text of that edit, so
|
|
2105
|
+
* that a field that shows the text, such as the formula bar, marks it invalid. A refusal of a
|
|
2106
|
+
* typed reference, a composing input method, a pending edit, or a dropped edit does not. The
|
|
2107
|
+
* code alone cannot tell a refusal of the open edit from a refusal of a call that leaves the
|
|
2108
|
+
* edit open, such as `enterValue(text, at)` for another cell: a field that marks the text
|
|
2109
|
+
* marks it only for a refusal that comes while the edit is open.
|
|
2110
|
+
*
|
|
2111
|
+
* @public
|
|
2112
|
+
*/
|
|
2113
|
+
declare function refusesEditText(code: EditRefusalCode): boolean;
|
|
2114
|
+
|
|
2115
|
+
/** The window type of a realm: its own timers, observers and constructors. */
|
|
2116
|
+
type HostWindow = Window & typeof globalThis;
|
|
2117
|
+
/**
|
|
2118
|
+
* The document that owns `node`, or the script's own document when `node` is absent.
|
|
2119
|
+
* Without a DOM (server rendering) and without a node, this is `undefined` despite its type:
|
|
2120
|
+
* call it from effects and event handlers, not during render.
|
|
2121
|
+
*
|
|
2122
|
+
* Use it to add document-level listeners (`selectionchange`, `pointerup`, `keydown`) and to
|
|
2123
|
+
* read `activeElement` for an editor that may live in another window.
|
|
2124
|
+
*
|
|
2125
|
+
* @example
|
|
2126
|
+
* ```ts
|
|
2127
|
+
* const doc = hostDocumentOf(menuElement);
|
|
2128
|
+
* doc.addEventListener('pointerdown', onOutsidePress, true);
|
|
2129
|
+
* ```
|
|
2130
|
+
*
|
|
2131
|
+
* @public
|
|
2132
|
+
*/
|
|
2133
|
+
declare function hostDocumentOf(node: Node | null | undefined): Document;
|
|
2134
|
+
/**
|
|
2135
|
+
* The window that owns `node`: its timers, animation frames, observers and viewport size.
|
|
2136
|
+
*
|
|
2137
|
+
* Falls back to the script's own window when the node's document has no window (an inert
|
|
2138
|
+
* document from `DOMParser`, or a window that closed), and to `globalThis` without a DOM.
|
|
2139
|
+
*
|
|
2140
|
+
* @example
|
|
2141
|
+
* ```ts
|
|
2142
|
+
* const win = hostWindowOf(anchorElement);
|
|
2143
|
+
* const handle = win.setTimeout(close, 300);
|
|
2144
|
+
* const maxX = win.innerWidth - menuWidth;
|
|
2145
|
+
* ```
|
|
2146
|
+
*
|
|
2147
|
+
* @public
|
|
2148
|
+
*/
|
|
2149
|
+
declare function hostWindowOf(node: Node | null | undefined): HostWindow;
|
|
2150
|
+
/**
|
|
2151
|
+
* The element `editor` is mounted in, or `null` while it is detached or headless.
|
|
2152
|
+
*
|
|
2153
|
+
* Use it to tell which editor an event belongs to when several share a window.
|
|
2154
|
+
*
|
|
2155
|
+
* @example
|
|
2156
|
+
* ```ts
|
|
2157
|
+
* const mine = editorHostElement(editor)?.contains(event.target as Node) ?? false;
|
|
2158
|
+
* ```
|
|
2159
|
+
*
|
|
2160
|
+
* @public
|
|
2161
|
+
*/
|
|
2162
|
+
declare function editorHostElement(editor: object): Element | null;
|
|
2163
|
+
/**
|
|
2164
|
+
* The document `editor` is mounted in: a pop-out window's or an iframe's when it is
|
|
2165
|
+
* attached there. While the editor is detached, the script's own document.
|
|
2166
|
+
*
|
|
2167
|
+
* Use it in custom chrome that is not inside the editor's own DOM, such as a toolbar
|
|
2168
|
+
* popover, to add document listeners and to read focus.
|
|
2169
|
+
*
|
|
2170
|
+
* @example
|
|
2171
|
+
* ```ts
|
|
2172
|
+
* const doc = editorHostDocument(editor);
|
|
2173
|
+
* doc.addEventListener('keydown', onShortcut);
|
|
2174
|
+
* ```
|
|
2175
|
+
*
|
|
2176
|
+
* @public
|
|
2177
|
+
*/
|
|
2178
|
+
declare function editorHostDocument(editor: object): Document;
|
|
2179
|
+
/**
|
|
2180
|
+
* The window `editor` is mounted in: its timers, frames, viewport size and clipboard.
|
|
2181
|
+
* While the editor is detached, the script's own window.
|
|
2182
|
+
*
|
|
2183
|
+
* @example
|
|
2184
|
+
* ```ts
|
|
2185
|
+
* const win = editorHostWindow(editor);
|
|
2186
|
+
* await win.navigator.clipboard.writeText(text);
|
|
2187
|
+
* ```
|
|
2188
|
+
*
|
|
2189
|
+
* @public
|
|
2190
|
+
*/
|
|
2191
|
+
declare function editorHostWindow(editor: object): HostWindow;
|
|
2192
|
+
/**
|
|
2193
|
+
* Whether `value` is a DOM element of any window. Use it instead of `instanceof Element`,
|
|
2194
|
+
* which is false for an element of a pop-out window or an iframe.
|
|
2195
|
+
*
|
|
2196
|
+
* @example
|
|
2197
|
+
* ```ts
|
|
2198
|
+
* if (isElementNode(event.target)) event.target.closest('[data-docx-hf]');
|
|
2199
|
+
* ```
|
|
2200
|
+
*
|
|
2201
|
+
* @public
|
|
2202
|
+
*/
|
|
2203
|
+
declare function isElementNode(value: unknown): value is Element;
|
|
2204
|
+
/**
|
|
2205
|
+
* Whether `value` is an HTML (not SVG or MathML) element of any window.
|
|
2206
|
+
*
|
|
2207
|
+
* @example
|
|
2208
|
+
* ```ts
|
|
2209
|
+
* if (isHTMLElementNode(event.target)) event.target.focus();
|
|
2210
|
+
* ```
|
|
2211
|
+
*
|
|
2212
|
+
* @public
|
|
2213
|
+
*/
|
|
2214
|
+
declare function isHTMLElementNode(value: unknown): value is HTMLElement;
|
|
2215
|
+
|
|
2216
|
+
/**
|
|
2217
|
+
* A merge command: merge, merge and center, or unmerge (`mergeCells` and `unmergeCells`).
|
|
2218
|
+
*
|
|
2219
|
+
* @public
|
|
2220
|
+
*/
|
|
2221
|
+
type MergeCommand = 'merge' | 'mergeCenter' | 'unmerge';
|
|
2222
|
+
/**
|
|
2223
|
+
* The state of one merge command: enabled, or the reason when it is disabled.
|
|
2224
|
+
*
|
|
2225
|
+
* @public
|
|
2226
|
+
*/
|
|
2227
|
+
interface MergeCommandState {
|
|
2228
|
+
readonly enabled: boolean;
|
|
2229
|
+
/**
|
|
2230
|
+
* The engine's reason when disabled, as a catalog key: `loading`, `editorNotReady`, `viewMode`,
|
|
2231
|
+
* `composing`, `mergeLocked`, `mergeOneCell`, `mergeOverlap`, `stylesUnread`, `rangeTooLarge`,
|
|
2232
|
+
* or `noMergedRange` (`mergeCommandState` gives the order).
|
|
2233
|
+
*/
|
|
2234
|
+
readonly disabledReason: ChromeDisabledReason | null;
|
|
2235
|
+
/**
|
|
2236
|
+
* For an enabled merge or merge and center: the first cell, in reading order, whose value the
|
|
2237
|
+
* merge would drop, or null. An open cell edit counts as it would be after its commit, which
|
|
2238
|
+
* the merge makes first. When it is set, the command refuses with `merge-drops-values`: ask the
|
|
2239
|
+
* user first, then call `mergeCells({ dropValues: true })`.
|
|
2240
|
+
*/
|
|
2241
|
+
readonly dropsValuesAt: string | null;
|
|
2242
|
+
}
|
|
2243
|
+
/**
|
|
2244
|
+
* The state of a merge command, from the snapshot alone. It first gives the reasons of
|
|
2245
|
+
* `toolbarCommandState`, in its order, and they must stay equal: a workbook that loads or is not
|
|
2246
|
+
* ready, view mode, and a composing input method. Then it gives the reasons of the command: a
|
|
2247
|
+
* protected sheet (`mergeLocked`); for a merge, a selection of one cell (`mergeOneCell`), then
|
|
2248
|
+
* one that overlaps a merged range (`mergeOverlap`); for a merge and center, also a styles part
|
|
2249
|
+
* that stays as bytes (`stylesUnread`) and a range too large to format (`rangeTooLarge`), as the
|
|
2250
|
+
* format controls; and for an unmerge, a selection with no merged range (`noMergedRange`). A
|
|
2251
|
+
* merge over values outside the top-left cell stays enabled, with `dropsValuesAt`: the host asks
|
|
2252
|
+
* the user before the command, then merges with `dropValues`.
|
|
2253
|
+
*
|
|
2254
|
+
* @public
|
|
2255
|
+
*/
|
|
2256
|
+
declare function mergeCommandState(snapshot: EditorSnapshot, command: MergeCommand): MergeCommandState;
|
|
2257
|
+
|
|
2258
|
+
/**
|
|
2259
|
+
* Keep Tab inside the dialog.
|
|
2260
|
+
*
|
|
2261
|
+
* `aria-modal` tells assistive tech the rest of the page is inert; it does not stop Tab,
|
|
2262
|
+
* so without this the third Tab lands on the document behind the dialog — which is the
|
|
2263
|
+
* editable surface, so the next keystroke types into the paragraph being formatted.
|
|
2264
|
+
*
|
|
2265
|
+
* Returns true when the event was handled, so a caller only has to call `preventDefault`.
|
|
2266
|
+
* @public
|
|
2267
|
+
*/
|
|
2268
|
+
declare function trapTabWithin(panel: HTMLElement, event: KeyboardEvent): boolean;
|
|
2269
|
+
/**
|
|
2270
|
+
* True when a pointer event on a dialog element lies outside its box: on the backdrop, as
|
|
2271
|
+
* DOCX Editor's frame checks it. Both adapters use it. @internal
|
|
2272
|
+
*/
|
|
2273
|
+
declare function isDialogBackdropPoint(dialog: Element, event: {
|
|
2274
|
+
readonly target: EventTarget | null;
|
|
2275
|
+
readonly clientX: number;
|
|
2276
|
+
readonly clientY: number;
|
|
2277
|
+
}): boolean;
|
|
2278
|
+
|
|
2279
|
+
/**
|
|
2280
|
+
* Every catalog key that `numberFormatCodeProblem` can return. A test keeps each one in the
|
|
2281
|
+
* catalog.
|
|
2282
|
+
*
|
|
2283
|
+
* @public
|
|
2284
|
+
*/
|
|
2285
|
+
declare const NUMBER_FORMAT_CODE_PROBLEM_KEYS: readonly ['numberFormat.problem.empty', 'numberFormat.problem.tooLong', 'numberFormat.problem.invalidCharacter', 'numberFormat.problem.unreadable'];
|
|
2286
|
+
/**
|
|
2287
|
+
* Why a typed number format code cannot be applied: a key of the shared catalog and its
|
|
2288
|
+
* parameters. The adapters translate it.
|
|
2289
|
+
*
|
|
2290
|
+
* @public
|
|
2291
|
+
*/
|
|
2292
|
+
interface NumberFormatCodeProblem {
|
|
2293
|
+
readonly key: (typeof NUMBER_FORMAT_CODE_PROBLEM_KEYS)[number];
|
|
2294
|
+
readonly params?: Readonly<Record<string, string>>;
|
|
2295
|
+
}
|
|
2296
|
+
/**
|
|
2297
|
+
* Why the store refuses a number format code, or null when it applies the code: the checks of
|
|
2298
|
+
* the format patch `{ numberFormat: { code } }`, which the apply runs. A code of white space
|
|
2299
|
+
* only is refused as empty, because it shows nothing.
|
|
2300
|
+
*
|
|
2301
|
+
* @public
|
|
2302
|
+
*/
|
|
2303
|
+
declare function numberFormatCodeProblem(code: string): NumberFormatCodeProblem | null;
|
|
2304
|
+
|
|
2305
|
+
/**
|
|
2306
|
+
* The value that a preview formats when the active cell holds nothing: a number with a group,
|
|
2307
|
+
* decimals, and a sign, so the preview shows each part of a number format.
|
|
2308
|
+
*
|
|
2309
|
+
* @public
|
|
2310
|
+
*/
|
|
2311
|
+
declare const NUMBER_FORMAT_SAMPLE = -1234.5678;
|
|
2312
|
+
/**
|
|
2313
|
+
* A preview of a number format code: the text that the grid shows before it fits the value to
|
|
2314
|
+
* the column, and the `RRGGBB` color of the code's section. `sample` is true when the active
|
|
2315
|
+
* cell is empty, and the text formats `NUMBER_FORMAT_SAMPLE`. `stale` is true for a formula
|
|
2316
|
+
* result that an edit can have changed. `color` is always six hex digits from the engine's
|
|
2317
|
+
* fixed palette of named and indexed colors, never text from the file.
|
|
2318
|
+
*
|
|
2319
|
+
* @public
|
|
2320
|
+
*/
|
|
2321
|
+
type NumberFormatPreview = {
|
|
2322
|
+
readonly ok: true;
|
|
2323
|
+
readonly text: string;
|
|
2324
|
+
readonly color?: string;
|
|
2325
|
+
readonly sample: boolean;
|
|
2326
|
+
/** The value is a formula result that an edit can have changed (not recalculated). */
|
|
2327
|
+
readonly stale?: boolean;
|
|
2328
|
+
} | {
|
|
2329
|
+
readonly ok: false;
|
|
2330
|
+
readonly problem: NumberFormatCodeProblem;
|
|
2331
|
+
};
|
|
2332
|
+
/**
|
|
2333
|
+
* The preview of a code on the active cell's value, through the display path that the grid
|
|
2334
|
+
* paints with, in the editor's number locale and the workbook's date system. A code that the
|
|
2335
|
+
* store refuses has its problem and no text. With no workbook ready, the preview formats
|
|
2336
|
+
* `NUMBER_FORMAT_SAMPLE` in the 1900 date system. A rich text cell shows its stored text for
|
|
2337
|
+
* every code, because the grid paints rich text with no number format.
|
|
2338
|
+
*
|
|
2339
|
+
* @public
|
|
2340
|
+
*/
|
|
2341
|
+
declare function previewNumberFormat(editor: XlsxEditorInstance, code: string): NumberFormatPreview;
|
|
2342
|
+
/**
|
|
2343
|
+
* What a number format dialog opened with: the code to show first. Only
|
|
2344
|
+
* `numberFormatDialogStart` makes one; the engine keeps what it compares (the workbook, the
|
|
2345
|
+
* selection, and the revision) out of sight, keyed by the start object. Keep the object that
|
|
2346
|
+
* it returns: a copy is not a start, and its Apply closes.
|
|
2347
|
+
*
|
|
2348
|
+
* @public
|
|
2349
|
+
*/
|
|
2350
|
+
interface NumberFormatDialogStart {
|
|
2351
|
+
/** The code that the dialog shows first: the `value` of the `number.custom` slot. */
|
|
2352
|
+
readonly initial: string;
|
|
2353
|
+
}
|
|
2354
|
+
/**
|
|
2355
|
+
* The start of a number format dialog: call it once, when the dialog opens. Null when the
|
|
2356
|
+
* `number.custom` slot is disabled (`toolbarCommandState`, the one source of enabled state)
|
|
2357
|
+
* or the commit of an open cell edit is refused: then do not open the dialog. The reason of a
|
|
2358
|
+
* disabled slot is its `disabledReason`; the reason of a refused commit is in the snapshot's
|
|
2359
|
+
* `refusal`. Otherwise it commits the open edit first, so the preview and the Apply read
|
|
2360
|
+
* the same cell, and `initial` is the slot's `value` after the commit. The commit is an edit:
|
|
2361
|
+
* call it in the event handler that opens the dialog, not during render.
|
|
2362
|
+
*
|
|
2363
|
+
* @public
|
|
2364
|
+
*/
|
|
2365
|
+
declare function numberFormatDialogStart(editor: XlsxEditorInstance): NumberFormatDialogStart | null;
|
|
2366
|
+
/**
|
|
2367
|
+
* True while a dialog's start still holds: the same workbook, selection, and number locale,
|
|
2368
|
+
* and the `number.custom` slot enabled. When it turns false, close the dialog.
|
|
2369
|
+
*
|
|
2370
|
+
* @public
|
|
2371
|
+
*/
|
|
2372
|
+
declare function numberFormatDialogCurrent(editor: XlsxEditorInstance, start: NumberFormatDialogStart): boolean;
|
|
2373
|
+
/**
|
|
2374
|
+
* What an Apply of a number format dialog does, from `numberFormatDialogApplyStep`.
|
|
2375
|
+
*
|
|
2376
|
+
* @public
|
|
2377
|
+
*/
|
|
2378
|
+
type NumberFormatDialogApplyStep = {
|
|
2379
|
+
readonly kind: 'closed';
|
|
2380
|
+
} | {
|
|
2381
|
+
readonly kind: 'unchanged';
|
|
2382
|
+
} | {
|
|
2383
|
+
readonly kind: 'apply';
|
|
2384
|
+
} | {
|
|
2385
|
+
readonly kind: 'problem';
|
|
2386
|
+
readonly problem: NumberFormatCodeProblem;
|
|
2387
|
+
};
|
|
2388
|
+
/**
|
|
2389
|
+
* What an Apply of a number format dialog does with `code`, by `kind`:
|
|
2390
|
+
*
|
|
2391
|
+
* - `closed`: close the dialog and write nothing: `numberFormatDialogCurrent` is false.
|
|
2392
|
+
* - `unchanged`: write nothing and close. The code is the start's `initial`, the workbook
|
|
2393
|
+
* has no edit since the start, and the selection is one cell (a merged cell is one
|
|
2394
|
+
* cell). The cell keeps its format, also a format id that has no code in this editor and
|
|
2395
|
+
* shows as `General`.
|
|
2396
|
+
* - `apply`: run the `number.custom` slot with the code. On a range, an unchanged code sets
|
|
2397
|
+
* it on every cell.
|
|
2398
|
+
* - `problem`: keep the dialog open and show `problem`, a catalog key and its parameters.
|
|
2399
|
+
*
|
|
2400
|
+
* @example
|
|
2401
|
+
* ```ts
|
|
2402
|
+
* const step = numberFormatDialogApplyStep(editor, start, code);
|
|
2403
|
+
* if (step.kind === 'problem') showError(t(step.problem.key, step.problem.params));
|
|
2404
|
+
* ```
|
|
2405
|
+
*
|
|
2406
|
+
* @public
|
|
2407
|
+
*/
|
|
2408
|
+
declare function numberFormatDialogApplyStep(editor: XlsxEditorInstance, start: NumberFormatDialogStart, code: string): NumberFormatDialogApplyStep;
|
|
2409
|
+
/** The most custom codes that `workbookNumberFormatCodes` lists. @public */
|
|
2410
|
+
declare const MAX_LISTED_NUMBER_FORMATS = 200;
|
|
2411
|
+
/**
|
|
2412
|
+
* The custom number format codes of the open workbook (`x:numFmt` with an id of 164 or more),
|
|
2413
|
+
* by id, each once, and only the codes that the store applies. Empty when no workbook is
|
|
2414
|
+
* ready. It checks at most the first 2,000 records by id, so a file with many codes that the
|
|
2415
|
+
* store refuses can list fewer. The codes are file text: render them as text only.
|
|
2416
|
+
*
|
|
2417
|
+
* @public
|
|
2418
|
+
*/
|
|
2419
|
+
declare function workbookNumberFormatCodes(editor: XlsxEditorInstance): readonly string[];
|
|
2420
|
+
|
|
2421
|
+
/**
|
|
2422
|
+
* One entry of the number format list, with its name translated.
|
|
2423
|
+
*
|
|
2424
|
+
* @public
|
|
2425
|
+
*/
|
|
2426
|
+
interface NumberFormatListEntry {
|
|
2427
|
+
readonly value: NumberFormatChoiceValue;
|
|
2428
|
+
readonly label: string;
|
|
2429
|
+
}
|
|
2430
|
+
/**
|
|
2431
|
+
* What the number format list shows for the value of the `number.format` slot.
|
|
2432
|
+
*
|
|
2433
|
+
* @public
|
|
2434
|
+
*/
|
|
2435
|
+
interface NumberFormatListView {
|
|
2436
|
+
/** The entries that have a code in the number locale, in list order. */
|
|
2437
|
+
readonly entries: readonly NumberFormatListEntry[];
|
|
2438
|
+
/**
|
|
2439
|
+
* The text of the closed list: the name of the entry, or `Custom:` and the code of a format
|
|
2440
|
+
* that names no entry. Empty with no value.
|
|
2441
|
+
*/
|
|
2442
|
+
readonly text: string;
|
|
2443
|
+
/**
|
|
2444
|
+
* What the accessible name and the title of the closed list say after the slot label: the
|
|
2445
|
+
* text, and the decimal places of a format that has them, such as `Currency, 3 decimal
|
|
2446
|
+
* places`. Never the code of an entry. Empty with no value.
|
|
2447
|
+
*/
|
|
2448
|
+
readonly name: string;
|
|
2449
|
+
/**
|
|
2450
|
+
* The entry whose code differs from the format only in its decimal places, as after a
|
|
2451
|
+
* decimal step, or undefined. The closed list shows its name. The entry is current, not
|
|
2452
|
+
* picked, because a pick writes the entry's own code: the keyboard opens the list on it.
|
|
2453
|
+
*/
|
|
2454
|
+
readonly current?: NumberFormatChoiceValue;
|
|
2455
|
+
}
|
|
2456
|
+
/**
|
|
2457
|
+
* What the number format list shows for a value of the `number.format` slot
|
|
2458
|
+
* (`ToolbarCommandState.value`), in the number locale. `t` translates the entry names and the
|
|
2459
|
+
* `numberFormat.custom` and `numberFormat.family` texts.
|
|
2460
|
+
*
|
|
2461
|
+
* - An entry shows its name. An entry with decimal places names them, so the name says what a
|
|
2462
|
+
* decimal step changes.
|
|
2463
|
+
* - A code that differs from an entry only in its decimal places shows the entry's name, names
|
|
2464
|
+
* its places, and sets `current` to that entry.
|
|
2465
|
+
* - Any other code shows `Custom:` and the code, and names its places when a step can change
|
|
2466
|
+
* them.
|
|
2467
|
+
*
|
|
2468
|
+
* @public
|
|
2469
|
+
*/
|
|
2470
|
+
declare function numberFormatListView(value: string | undefined, t: EditorTranslate, locale?: NumberLocale): NumberFormatListView;
|
|
2471
|
+
|
|
2472
|
+
/**
|
|
2473
|
+
* A command of the sheet tabs: `add` the add button, and `rename`, `delete`, `moveLeft`, and
|
|
2474
|
+
* `moveRight` the rows of the sheet menu.
|
|
2475
|
+
*
|
|
2476
|
+
* @public
|
|
2477
|
+
*/
|
|
2478
|
+
type SheetCommand = 'add' | 'rename' | 'delete' | 'moveLeft' | 'moveRight';
|
|
2479
|
+
/**
|
|
2480
|
+
* The state of one sheet command.
|
|
2481
|
+
*
|
|
2482
|
+
* @public
|
|
2483
|
+
*/
|
|
2484
|
+
interface SheetCommandState {
|
|
2485
|
+
readonly enabled: boolean;
|
|
2486
|
+
/**
|
|
2487
|
+
* The engine's reason when the command is disabled, as a catalog key: `viewMode`,
|
|
2488
|
+
* `workbookLocked`, `notWorksheet`, `sheetEditBlocked` (with the part that refuses it as its
|
|
2489
|
+
* `about`), or `lastSheet`. Null when the command is enabled, and for a move at the end of
|
|
2490
|
+
* the tabs or a sheet that has no tab.
|
|
2491
|
+
*/
|
|
2492
|
+
readonly disabledReason: ChromeDisabledReason | null;
|
|
2493
|
+
/**
|
|
2494
|
+
* The workbook position that a move takes the sheet to: the position of the next visible tab
|
|
2495
|
+
* in that direction, so a hidden sheet never takes a move. Set only on an enabled move.
|
|
2496
|
+
*/
|
|
2497
|
+
readonly to?: number;
|
|
2498
|
+
}
|
|
2499
|
+
/** What the state reads from the editor snapshot. @public */
|
|
2500
|
+
type SheetCommandInput = Pick<EditorSnapshot, 'mode' | 'sheets' | 'workbookProtection' | 'sheetEditRefusal'>;
|
|
2501
|
+
/**
|
|
2502
|
+
* The state of a sheet command on the sheet at workbook position `sheet` (ignored by `add`).
|
|
2503
|
+
* View mode disables every command with `viewMode`, and a workbook protection that locks the
|
|
2504
|
+
* sheet list with `workbookLocked`. A sheet that is not a worksheet (a chartsheet, a macro
|
|
2505
|
+
* sheet, a dialog sheet, or a sheet whose part is missing) has every command but `add`
|
|
2506
|
+
* disabled with `notWorksheet`. Delete needs another visible sheet (`lastSheet`). A chart, a
|
|
2507
|
+
* pivot table, a sheet that is not a worksheet, or a workbook or package relationship outside
|
|
2508
|
+
* the allowlist (for example data connections) disables Rename and Delete of every sheet with
|
|
2509
|
+
* `sheetEditBlocked` (`snapshot.sheetEditRefusal`), as the store refuses them with
|
|
2510
|
+
* `structure-blocked`.
|
|
2511
|
+
*
|
|
2512
|
+
* @public
|
|
2513
|
+
*/
|
|
2514
|
+
declare function sheetCommandState(snapshot: SheetCommandInput, command: SheetCommand, sheet: number): SheetCommandState;
|
|
2515
|
+
|
|
2516
|
+
/** How {@link listenForPopupEscape} decides and acts. @internal */
|
|
2517
|
+
interface PopupEscapeOptions {
|
|
2518
|
+
/** The popup's root. Its `ownerDocument` receives the listener. */
|
|
2519
|
+
readonly popup: HTMLElement;
|
|
2520
|
+
/** Whether a node belongs to the popup (its trigger, list, or a separate panel). */
|
|
2521
|
+
readonly contains: (node: Node) => boolean;
|
|
2522
|
+
/** Elements of this editor beyond its `.xlsx-editor` container, such as the viewport. */
|
|
2523
|
+
readonly editorElements?: () => readonly (Element | null | undefined)[];
|
|
2524
|
+
/**
|
|
2525
|
+
* The chrome root that holds the popup, such as the toolbar or the menu bar. It scopes
|
|
2526
|
+
* itself with its own `.xlsx-editor` class, and a key from it counts as this editor's.
|
|
2527
|
+
*/
|
|
2528
|
+
readonly chromeRoot?: () => Element | null | undefined;
|
|
2529
|
+
/** Return true to leave this Escape to someone else (an input that owns the key). */
|
|
2530
|
+
readonly skip?: (event: KeyboardEvent) => boolean;
|
|
2531
|
+
/** Close the popup. `fromInside` is true when the key came from inside the popup. */
|
|
2532
|
+
readonly close: (fromInside: boolean) => void;
|
|
2533
|
+
}
|
|
2534
|
+
/**
|
|
2535
|
+
* The nearest `.xlsx-editor` around `from` that holds the painted grid, or null.
|
|
2536
|
+
*
|
|
2537
|
+
* Chrome parts carry their own styling-only `xlsx-editor` class, so the first match from
|
|
2538
|
+
* a toolbar is the toolbar. The instance container is the first one with the grid surface inside.
|
|
2539
|
+
*
|
|
2540
|
+
* @internal
|
|
2541
|
+
*/
|
|
2542
|
+
declare function editorInstanceScope(from: Element | null): Element | null;
|
|
2543
|
+
/**
|
|
2544
|
+
* Close an open toolbar popup on Escape, ahead of the surface. Returns the disposer.
|
|
2545
|
+
*
|
|
2546
|
+
* Shared adapter glue, not for hosts.
|
|
2547
|
+
*
|
|
2548
|
+
* @internal
|
|
2549
|
+
*/
|
|
2550
|
+
declare function listenForPopupEscape(options: PopupEscapeOptions): () => void;
|
|
2551
|
+
/**
|
|
2552
|
+
* Whether a nested popup inside `panel` is open. Its own Escape listener closes it, and
|
|
2553
|
+
* the panel stays open for the next Escape.
|
|
2554
|
+
*
|
|
2555
|
+
* @internal
|
|
2556
|
+
*/
|
|
2557
|
+
declare function hasOpenNestedPopup(panel: Element | null): boolean;
|
|
2558
|
+
/** How {@link listenForPopupFocusLeave} decides. @internal */
|
|
2559
|
+
interface PopupFocusLeaveOptions {
|
|
2560
|
+
/** The popup's root. Its `ownerDocument` receives the listener. */
|
|
2561
|
+
readonly popup: HTMLElement;
|
|
2562
|
+
/** Whether a node belongs to the popup (its trigger, list, or a separate panel). */
|
|
2563
|
+
readonly contains: (node: Node) => boolean;
|
|
2564
|
+
/** Close the popup. */
|
|
2565
|
+
readonly close: () => void;
|
|
2566
|
+
}
|
|
2567
|
+
/**
|
|
2568
|
+
* Close an open popup when focus moves outside it, for example to the find field after
|
|
2569
|
+
* Ctrl+F or to a host input. Two moves keep the popup open: focus that lands in the painted
|
|
2570
|
+
* grid, because a toolbar click leaves the keyboard there while the popup is open, and focus
|
|
2571
|
+
* that enters one of this editor's modal dialogs, because the popup may have opened it and
|
|
2572
|
+
* the dialog returns focus to its opener when it closes. A host's own modal dialog closes
|
|
2573
|
+
* the popup like any other control. Returns the disposer.
|
|
2574
|
+
*
|
|
2575
|
+
* @internal
|
|
2576
|
+
*/
|
|
2577
|
+
declare function listenForPopupFocusLeave(options: PopupFocusLeaveOptions): () => void;
|
|
2578
|
+
/** How {@link listenForOutsidePress} decides. @internal */
|
|
2579
|
+
interface OutsidePressOptions {
|
|
2580
|
+
/** A node of the popup. Its host document receives the listener. */
|
|
2581
|
+
readonly popup: Node | null | undefined;
|
|
2582
|
+
/** Whether a node belongs to the popup. Defaults to the popup's own `contains`. */
|
|
2583
|
+
readonly contains?: (node: Node) => boolean;
|
|
2584
|
+
/** Close the popup. */
|
|
2585
|
+
readonly close: (event: PointerEvent) => void;
|
|
2586
|
+
}
|
|
2587
|
+
/**
|
|
2588
|
+
* Close an open popup when a press lands outside it. Returns the disposer.
|
|
2589
|
+
*
|
|
2590
|
+
* The listener is a capture-phase `pointerdown` on the popup's host document. Capture runs
|
|
2591
|
+
* before the surface cancels the press or stops its propagation, so a press on the painted
|
|
2592
|
+
* grid closes the popup too. A press counts as inside when any node on its composed path
|
|
2593
|
+
* belongs to the popup, so a popup in a shadow root, or one that holds a shadow root,
|
|
2594
|
+
* recognises its own presses.
|
|
2595
|
+
*
|
|
2596
|
+
* Shared adapter glue, not for hosts.
|
|
2597
|
+
*
|
|
2598
|
+
* @internal
|
|
2599
|
+
*/
|
|
2600
|
+
declare function listenForOutsidePress(options: OutsidePressOptions): () => void;
|
|
2601
|
+
|
|
2602
|
+
/** Material Symbol name to SVG path data. */
|
|
2603
|
+
declare const ICON_PATHS: {
|
|
2604
|
+
readonly undo: readonly ["M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z"];
|
|
2605
|
+
readonly redo: readonly ["M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z"];
|
|
2606
|
+
readonly format_bold: readonly ["M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z"];
|
|
2607
|
+
readonly format_italic: readonly ["M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"];
|
|
2608
|
+
readonly format_underlined: readonly ["M200-120v-80h560v80H200Zm123-223q-56-63-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63q-101 0-157-63Z"];
|
|
2609
|
+
readonly format_color_text: readonly ["M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z"];
|
|
2610
|
+
readonly format_color_fill: readonly ["m247-904 57-56 343 343q23 23 23 57t-23 57L457-313q-23 23-57 23t-57-23L153-503q-23-23-23-57t23-57l190-191-96-96Zm153 153L209-560h382L400-751Zm360 471q-33 0-56.5-23.5T680-360q0-21 12.5-45t27.5-45q9-12 19-25t21-25q11 12 21 25t19 25q15 21 27.5 45t12.5 45q0 33-23.5 56.5T760-280ZM80 0v-160h800V0H80Z"];
|
|
2611
|
+
readonly border_outer: readonly ["M200-200h560v-560H200v560Zm-80 80v-720h720v720H120Zm160-320v-80h80v80h-80Zm160 160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 160v-80h80v80h-80Z"];
|
|
2612
|
+
readonly border_all: readonly ["M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"];
|
|
2613
|
+
readonly border_clear: readonly ["M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"];
|
|
2614
|
+
readonly format_align_left: readonly ["M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"];
|
|
2615
|
+
readonly format_align_center: readonly ["M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"];
|
|
2616
|
+
readonly format_align_right: readonly ["M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"];
|
|
2617
|
+
readonly vertical_align_top: readonly ["M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"];
|
|
2618
|
+
readonly vertical_align_center: readonly ["M440-80v-168l-64 64-56-56 160-160 160 160-56 56-64-64v168h-80ZM160-440v-80h640v80H160Zm320-120L320-720l56-56 64 64v-168h80v168l64-64 56 56-160 160Z"];
|
|
2619
|
+
readonly vertical_align_bottom: readonly ["M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"];
|
|
2620
|
+
readonly wrap_text: readonly ["M588-132 440-280l148-148 56 58-50 50h96q29 0 49.5-20.5T760-390q0-29-20.5-49.5T690-460H160v-80h530q63 0 106.5 43.5T840-390q0 63-43.5 106.5T690-240h-96l50 50-56 58ZM160-240v-80h200v80H160Zm0-440v-80h640v80H160Z"];
|
|
2621
|
+
readonly add_row_above: readonly ["M200-160h560v-240H200v240Zm640 80H120v-720h160v80h-80v240h560v-240h-80v-80h160v720ZM480-480Zm0 80v-80 80Zm0 0Zm-40-240v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"];
|
|
2622
|
+
readonly add_column_left: readonly ["M800-200v-560H560v560h240Zm-640 80v-160h80v80h240v-560H240v80h-80v-160h720v720H160Zm320-360Zm80 0h-80 80Zm0 0ZM160-360v-80H80v-80h80v-80h80v80h80v80h-80v80h-80Z"];
|
|
2623
|
+
readonly delete_sweep: readonly ["M600-240v-80h160v80H600Zm0-320v-80h280v80H600Zm0 160v-80h240v80H600ZM120-640H80v-80h160v-60h160v60h160v80h-40v360q0 33-23.5 56.5T440-200H200q-33 0-56.5-23.5T120-280v-360Zm80 0v360h240v-360H200Zm0 0v360-360Z"];
|
|
2624
|
+
readonly format_clear: readonly ["m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"];
|
|
2625
|
+
readonly file_download: readonly ["M480-320 280-520l56-58 104 104v-326h80v326l104-104 56 58-200 200ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"];
|
|
2626
|
+
readonly '123': readonly ["M220-360v-180h-60v-60h120v240h-60Zm140 0v-100q0-17 11.5-28.5T400-500h80v-40H360v-60h140q17 0 28.5 11.5T540-560v60q0 17-11.5 28.5T500-460h-80v40h120v60H360Zm240 0v-60h120v-40h-80v-40h80v-40H600v-60h140q17 0 28.5 11.5T780-560v160q0 17-11.5 28.5T740-360H600Z"];
|
|
2627
|
+
readonly arrow_drop_down: readonly ["M480-360 280-560h400L480-360Z"];
|
|
2628
|
+
readonly check: readonly ["M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"];
|
|
2629
|
+
readonly expand_more: readonly ["M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"];
|
|
2630
|
+
readonly decimal_increase: readonly ["m720-80-56-56 63-64H480v-80h247l-63-64 56-56 160 160L720-80ZM80-440v-120h120v120H80Zm300 0q-58 0-99-41t-41-99v-160q0-58 41-99t99-41q58 0 99 41t41 99v160q0 58-41 99t-99 41Zm360 0q-58 0-99-41t-41-99v-160q0-58 41-99t99-41q58 0 99 41t41 99v160q0 58-41 99t-99 41Zm-360-80q25 0 42.5-17.5T440-580v-160q0-25-17.5-42.5T380-800q-25 0-42.5 17.5T320-740v160q0 25 17.5 42.5T380-520Zm360 0q25 0 42.5-17.5T800-580v-160q0-25-17.5-42.5T740-800q-25 0-42.5 17.5T680-740v160q0 25 17.5 42.5T740-520Z"];
|
|
2631
|
+
readonly decimal_decrease: readonly ["M640-80 480-240l160-160 56 56-63 64h247v80H633l63 64-56 56ZM80-440v-120h120v120H80Zm300 0q-58 0-99-41t-41-99v-160q0-58 41-99t99-41q58 0 99 41t41 99v160q0 58-41 99t-99 41Zm0-80q25 0 42.5-17.5T440-580v-160q0-25-17.5-42.5T380-800q-25 0-42.5 17.5T320-740v160q0 25 17.5 42.5T380-520Z"];
|
|
2632
|
+
readonly more_horiz: readonly ["M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z"];
|
|
2633
|
+
};
|
|
2634
|
+
|
|
2635
|
+
/**
|
|
2636
|
+
* Scroll `target` into view in its nearest scrolling ancestor only, by the least distance on
|
|
2637
|
+
* each axis that scrolls, and inside its `scroll-padding`. Unlike `scrollIntoView`, it leaves
|
|
2638
|
+
* the outer page alone: a host that slides the editor in from off screen, or keeps it in a
|
|
2639
|
+
* clipped panel, does not see its layout move. `within` bounds the search (the rail or the
|
|
2640
|
+
* sorter): an ancestor outside it is never scrolled. @internal
|
|
2641
|
+
*/
|
|
2642
|
+
declare function scrollIntoNearestScroller(target: HTMLElement, within?: Element | null): void;
|
|
2643
|
+
|
|
2644
|
+
/** Whether two slices hold the same values, key by key. @internal */
|
|
2645
|
+
declare function sameSlice<T extends object>(a: T, b: T): boolean;
|
|
2646
|
+
/** The part of the snapshot that the zoom control renders. @internal */
|
|
2647
|
+
declare const zoomSlice: (s: EditorSnapshot) => {
|
|
2648
|
+
status: "empty" | "failed" | "loading" | "ready";
|
|
2649
|
+
zoom: number;
|
|
2650
|
+
};
|
|
2651
|
+
/** The part of the snapshot that the status strip and the status message render. @internal */
|
|
2652
|
+
declare const statusSlice: (s: EditorSnapshot) => {
|
|
2653
|
+
status: "empty" | "failed" | "loading" | "ready";
|
|
2654
|
+
failure: "fonts" | "no-worksheet" | "package" | undefined;
|
|
2655
|
+
failureLimit: "xml.maxBytes" | "xml.maxDepth" | "xml.maxElements" | "zip.maxEntries" | "zip.maxRatio" | "zip.maxTotalBytes" | undefined;
|
|
2656
|
+
failurePart: string | undefined;
|
|
2657
|
+
partsPastLimit: readonly PartPastLimit[];
|
|
2658
|
+
refusal: EditRefusal | null;
|
|
2659
|
+
editDropped: boolean;
|
|
2660
|
+
numberLocale: NumberLocale;
|
|
2661
|
+
stale: boolean;
|
|
2662
|
+
protected: boolean;
|
|
2663
|
+
conditionalHidden: boolean;
|
|
2664
|
+
};
|
|
2665
|
+
/** The part of the snapshot that the formula bar renders. @internal */
|
|
2666
|
+
declare const formulaSlice: (s: EditorSnapshot) => {
|
|
2667
|
+
status: "empty" | "failed" | "loading" | "ready";
|
|
2668
|
+
ref: string | null;
|
|
2669
|
+
text: string;
|
|
2670
|
+
editing: boolean;
|
|
2671
|
+
view: boolean;
|
|
2672
|
+
refusal: EditRefusal | null;
|
|
2673
|
+
numberLocale: NumberLocale;
|
|
2674
|
+
};
|
|
2675
|
+
/** The part of the snapshot that the sheet tabs render. @internal */
|
|
2676
|
+
declare const tabsSlice: (s: EditorSnapshot) => {
|
|
2677
|
+
status: "empty" | "failed" | "loading" | "ready";
|
|
2678
|
+
sheets: readonly EditorSheet[];
|
|
2679
|
+
activeSheet: number;
|
|
2680
|
+
refusal: EditRefusal | null;
|
|
2681
|
+
numberLocale: NumberLocale;
|
|
2682
|
+
mode: EditorMode;
|
|
2683
|
+
workbookProtection: WorkbookProtection | null;
|
|
2684
|
+
sheetEditRefusal: EditRefusal | null;
|
|
2685
|
+
};
|
|
2686
|
+
/**
|
|
2687
|
+
* The message of a load that failed with the code `package`. A file past a limit is too large
|
|
2688
|
+
* to open, as DOCX Editor says it, and the message names the part and the limit. @internal
|
|
2689
|
+
*/
|
|
2690
|
+
declare function packageFailureText(failure: Pick<EditorFailure, 'limit' | 'part'>, t: EditorTranslate): string;
|
|
2691
|
+
/**
|
|
2692
|
+
* The notice for the parts that stay as bytes past a limit: the first part, and a count of the
|
|
2693
|
+
* others. @internal
|
|
2694
|
+
*/
|
|
2695
|
+
declare function pastLimitText(parts: readonly PartPastLimit[], t: EditorTranslate): string;
|
|
2696
|
+
/** What the grid measures after it attaches. @internal */
|
|
2697
|
+
interface GridSetupFacts {
|
|
2698
|
+
/** The computed `overflow-y` of the grid scroller. */
|
|
2699
|
+
readonly overflowY: string;
|
|
2700
|
+
}
|
|
2701
|
+
/**
|
|
2702
|
+
* The setup mistake that the facts show, or `null`. An empty `overflowY` means that the host
|
|
2703
|
+
* computes no styles, so it shows no mistake. `part` and `stylesheet` name the grid part and the
|
|
2704
|
+
* stylesheet of the adapter that asks. @internal
|
|
2705
|
+
*/
|
|
2706
|
+
declare function gridSetupProblem({ overflowY }: GridSetupFacts, part?: string, stylesheet?: string): string | null;
|
|
2707
|
+
/**
|
|
2708
|
+
* Warn in development, once the document has loaded, when the grid in `element` has no editor
|
|
2709
|
+
* styles (`gridSetupProblem`). A stylesheet that loads late gives no warning. Returns the
|
|
2710
|
+
* cancel function. @internal
|
|
2711
|
+
*/
|
|
2712
|
+
declare function watchGridSetup(element: HTMLElement, part: string, stylesheet: string): () => void;
|
|
2713
|
+
/** The state of one chrome slot that `useEditorCommand` shows, with its words translated. @internal */
|
|
2714
|
+
interface EditorCommandSlice {
|
|
2715
|
+
readonly active: boolean;
|
|
2716
|
+
readonly enabled: boolean;
|
|
2717
|
+
readonly disabledReason: string | null;
|
|
2718
|
+
readonly hint: string | null;
|
|
2719
|
+
readonly value: string | null;
|
|
2720
|
+
}
|
|
2721
|
+
/**
|
|
2722
|
+
* The state of `slot` in `snapshot` (`toolbarCommandState`), with the disabled reason and the
|
|
2723
|
+
* hint of an enabled command translated. @internal
|
|
2724
|
+
*/
|
|
2725
|
+
declare function editorCommandSlice(snapshot: EditorSnapshot, slot: ChromeSlotId, host: ToolbarHost, t: EditorTranslate): EditorCommandSlice;
|
|
2726
|
+
/** Whether two slot states show the same thing. @internal */
|
|
2727
|
+
declare function sameEditorCommandSlice(a: EditorCommandSlice, b: EditorCommandSlice): boolean;
|
|
2728
|
+
/** The words of one toolbar slot. @internal */
|
|
2729
|
+
interface SlotWords {
|
|
2730
|
+
/** The accessible name. */
|
|
2731
|
+
readonly label: string;
|
|
2732
|
+
/** The disabled reason or the hint: the accessible description, or null. */
|
|
2733
|
+
readonly description: string | null;
|
|
2734
|
+
/**
|
|
2735
|
+
* The tooltip: the label, and the disabled reason after it when there is one; else the label
|
|
2736
|
+
* with the hint on a second line.
|
|
2737
|
+
*/
|
|
2738
|
+
readonly title: string;
|
|
2739
|
+
}
|
|
2740
|
+
/** The words of a slot with the label key `labelKey` and the state `command`. @internal */
|
|
2741
|
+
declare function slotWords(labelKey: string, command: Pick<EditorCommandSlice, 'disabledReason' | 'hint'>, t: EditorTranslate): SlotWords;
|
|
2742
|
+
/**
|
|
2743
|
+
* One notice of the status strip. While `on`, its live text is the full `text`; `short` shows
|
|
2744
|
+
* the brief text in its place, visually only. @internal
|
|
2745
|
+
*/
|
|
2746
|
+
interface StatusNotice {
|
|
2747
|
+
readonly id: 'stale' | 'protected' | 'conditionalHidden' | 'pastLimit' | 'viewWaits';
|
|
2748
|
+
readonly on: boolean;
|
|
2749
|
+
readonly short: boolean;
|
|
2750
|
+
readonly text: string;
|
|
2751
|
+
readonly brief: string;
|
|
2752
|
+
}
|
|
2753
|
+
/**
|
|
2754
|
+
* What `StatusMessage` shows: the strip of a ready workbook (a refusal on its own row, and the
|
|
2755
|
+
* notices), or the message of an editor with no grid (its text, and the refusals under it).
|
|
2756
|
+
* @internal
|
|
2757
|
+
*/
|
|
2758
|
+
type StatusView = {
|
|
2759
|
+
readonly kind: 'strip';
|
|
2760
|
+
readonly refusal: string | null;
|
|
2761
|
+
readonly notices: readonly StatusNotice[];
|
|
2762
|
+
} | {
|
|
2763
|
+
readonly kind: 'message';
|
|
2764
|
+
/** `alert` for a failed open, else `status`. */
|
|
2765
|
+
readonly role: 'alert' | 'status';
|
|
2766
|
+
readonly text: string;
|
|
2767
|
+
readonly refusals: readonly string[];
|
|
2768
|
+
};
|
|
2769
|
+
/**
|
|
2770
|
+
* The status strip of `snap` (`statusSlice`), with `modeWaits` when a change of the `mode` prop
|
|
2771
|
+
* to view mode waits for the open cell edit. While a workbook is ready, the strip shows every
|
|
2772
|
+
* notice, empty when it is off, so a screen reader announces each one when its text arrives.
|
|
2773
|
+
* When more than one message shows, a notice shows its short text. Without a grid, a refusal
|
|
2774
|
+
* shows under the message: a refused save, or an open edit that a load or `close()` dropped.
|
|
2775
|
+
* @internal
|
|
2776
|
+
*/
|
|
2777
|
+
declare function statusView(snap: ReturnType<typeof statusSlice>, modeWaits: boolean, t: EditorTranslate): StatusView;
|
|
2778
|
+
|
|
2779
|
+
/** The part of a mouse event that the press guards read. @internal */
|
|
2780
|
+
interface ChromePress {
|
|
2781
|
+
readonly target: EventTarget | null;
|
|
2782
|
+
readonly currentTarget: EventTarget | null;
|
|
2783
|
+
preventDefault(): void;
|
|
2784
|
+
}
|
|
2785
|
+
/** Keep the grid's focus when chrome is pressed, except in a form field. @internal */
|
|
2786
|
+
declare function keepGridFocus(e: Pick<ChromePress, 'target' | 'preventDefault'>): void;
|
|
2787
|
+
/**
|
|
2788
|
+
* Keep the grid's focus when the toolbar is pressed, except in a form field. An open sheet
|
|
2789
|
+
* rename commits first, as a blur does (`rename-commit.ts`). The click of the press runs no
|
|
2790
|
+
* command when the store refuses the name, so the reason stays in view, and when the pressed
|
|
2791
|
+
* control was disabled at the press: the commit can enable it (Undo), and its click must not
|
|
2792
|
+
* act. @internal
|
|
2793
|
+
*/
|
|
2794
|
+
declare function guardToolbarMousedown(e: ChromePress): void;
|
|
2795
|
+
/** The part of a key event that the region keys read. @internal */
|
|
2796
|
+
interface RegionKey {
|
|
2797
|
+
readonly key: string;
|
|
2798
|
+
readonly altKey: boolean;
|
|
2799
|
+
readonly ctrlKey: boolean;
|
|
2800
|
+
readonly metaKey: boolean;
|
|
2801
|
+
readonly shiftKey: boolean;
|
|
2802
|
+
preventDefault(): void;
|
|
2803
|
+
}
|
|
2804
|
+
/** Handle F6 and Shift+F6 inside `root`. Returns whether the key moved the focus. @internal */
|
|
2805
|
+
declare function cycleRegion(e: RegionKey, root: HTMLElement, editor: XlsxEditorInstance | null): boolean;
|
|
2806
|
+
|
|
2807
|
+
/** The event that asks the focused rename field to commit; its detail gets the outcome. @internal */
|
|
2808
|
+
declare const RENAME_COMMIT_EVENT = "xlsx-sheet-rename-commit";
|
|
2809
|
+
/** The detail of `RENAME_COMMIT_EVENT`: the field sets `written` to false on a refusal. @internal */
|
|
2810
|
+
interface RenameCommitDetail {
|
|
2811
|
+
written: boolean;
|
|
2812
|
+
}
|
|
2813
|
+
/** Whether a sheet rename field has focus in the document of `from`. @internal */
|
|
2814
|
+
declare function renameFocused(from: Node): boolean;
|
|
2815
|
+
/**
|
|
2816
|
+
* Commit the sheet rename field that has focus in the document of `from`, as a blur does. True
|
|
2817
|
+
* when no rename field has focus, or when the name was written; false when it was refused.
|
|
2818
|
+
* @internal
|
|
2819
|
+
*/
|
|
2820
|
+
declare function commitFocusedRename(from: Node): boolean;
|
|
2821
|
+
/**
|
|
2822
|
+
* Run no command on the click of this press in the document of `from`: the press whose rename
|
|
2823
|
+
* was refused, or whose control was disabled at the press. One click only: the click removes
|
|
2824
|
+
* the listeners, and so do the next press, a key press, and the task after the release, so a
|
|
2825
|
+
* press that is released away from its control, with no click, blocks no later click, such as
|
|
2826
|
+
* a click from the keyboard. @internal
|
|
2827
|
+
*/
|
|
2828
|
+
declare function blockNextClick(from: Node): void;
|
|
2829
|
+
/**
|
|
2830
|
+
* Call `focus` after the release of this press in the document of `from`, when the focus is
|
|
2831
|
+
* then on the page body. A press on a sheet tab that ends a written rename leaves the focus to
|
|
2832
|
+
* its click, so the grid says only the sheet that the click chooses. A release away from the
|
|
2833
|
+
* tab has no click, and the rename field that had the focus is gone. One release only: the
|
|
2834
|
+
* release removes the listeners, and so do the next press and a key press, so a release that
|
|
2835
|
+
* the page does not get moves no later focus. @internal
|
|
2836
|
+
*/
|
|
2837
|
+
declare function focusAfterRelease(from: Node, focus: () => void): void;
|
|
2838
|
+
|
|
2839
|
+
/** The part of a mouse event that `pressFieldBox` reads. @internal */
|
|
2840
|
+
interface FieldBoxPress {
|
|
2841
|
+
readonly target: EventTarget | null;
|
|
2842
|
+
readonly button: number;
|
|
2843
|
+
readonly shiftKey: boolean;
|
|
2844
|
+
preventDefault(): void;
|
|
2845
|
+
}
|
|
2846
|
+
/**
|
|
2847
|
+
* A press on the box of the field `el` outside its text area, such as on the line count or the
|
|
2848
|
+
* gap beside the text, puts the caret at the end of the line that the field shows. With Shift,
|
|
2849
|
+
* on a field that has the keyboard, it extends the selection from its anchor to there, as a
|
|
2850
|
+
* press with Shift in the text does. @internal
|
|
2851
|
+
*/
|
|
2852
|
+
declare function pressFieldBox(el: HTMLTextAreaElement | null, e: FieldBoxPress): void;
|
|
2853
|
+
/**
|
|
2854
|
+
* Insert `text` at the caret of `el` as typed text, which the field's own undo can remove.
|
|
2855
|
+
* @internal
|
|
2856
|
+
*/
|
|
2857
|
+
declare function insertFieldText(el: HTMLTextAreaElement, text: string): boolean;
|
|
2858
|
+
/**
|
|
2859
|
+
* Scroll the one-row field `el`, while it has the keyboard, to the whole line that holds the
|
|
2860
|
+
* caret. The browser scrolls only the caret into view, which can leave the field between two
|
|
2861
|
+
* lines, or on a line without the caret after a line break. With `reveal`, the field also
|
|
2862
|
+
* scrolls a caret at a line end, set from code as by a press on the line count, to the right
|
|
2863
|
+
* edge: the browser does not scroll such a caret into view. @internal
|
|
2864
|
+
*/
|
|
2865
|
+
declare function showCaretLine(el: HTMLTextAreaElement | null, reveal?: boolean): void;
|
|
2866
|
+
/** The part of a key event that `stepFieldHistory` reads. @internal */
|
|
2867
|
+
interface FieldHistoryKey extends FieldKeys {
|
|
2868
|
+
preventDefault(): void;
|
|
2869
|
+
}
|
|
2870
|
+
/**
|
|
2871
|
+
* Step the workbook history for a history key of a field with no typing of its own. True when
|
|
2872
|
+
* the key stepped the history. @internal
|
|
2873
|
+
*/
|
|
2874
|
+
declare function stepFieldHistory(e: FieldHistoryKey, editor: Pick<XlsxEditorInstance, 'undo' | 'redo'>, typing: boolean): boolean;
|
|
2875
|
+
|
|
2876
|
+
/**
|
|
2877
|
+
* The groups of the bar, in registry order, without the hidden slots. A group whose slots are
|
|
2878
|
+
* all hidden is left out. @internal
|
|
2879
|
+
*/
|
|
2880
|
+
declare function toolbarGroups(hidden?: readonly ChromeSlotId[]): readonly ChromeGroup[];
|
|
2881
|
+
/**
|
|
2882
|
+
* How many groups the bar shows: all of them while a group has no measured width, so the next
|
|
2883
|
+
* render measures it, and else as many as fit (`groupsThatFit`). @internal
|
|
2884
|
+
*/
|
|
2885
|
+
declare function shownGroupCount(groups: readonly {
|
|
2886
|
+
readonly id: string;
|
|
2887
|
+
}[], widths: ReadonlyMap<string, number>, width: number, gap?: number): number;
|
|
2888
|
+
/**
|
|
2889
|
+
* How many groups, from the start, fit in a bar whose content box is `width` pixels wide, with
|
|
2890
|
+
* `gap` pixels between two items. Each group after the first is charged its gap, as DOCX
|
|
2891
|
+
* Editor's `useToolbarOverflow.ts` charges `groupGaps`, and so is the More button. @internal
|
|
2892
|
+
*/
|
|
2893
|
+
declare function groupsThatFit(widths: readonly number[], width: number, gap?: number): number;
|
|
2894
|
+
/**
|
|
2895
|
+
* The attribute of the block that holds a host's loose toolbar children. The block never
|
|
2896
|
+
* collapses, so the bar charges its width, and its gap, as fixed width, as DOCX Editor's
|
|
2897
|
+
* `useToolbarOverflow.ts` charges its `FIXED_ATTRIBUTE` block. @internal
|
|
2898
|
+
*/
|
|
2899
|
+
declare const TOOLBAR_FIXED_ATTRIBUTE = "data-toolbar-fixed";
|
|
2900
|
+
/**
|
|
2901
|
+
* Measure the groups that the bar `el` shows into `widths`, and return how many groups of
|
|
2902
|
+
* `groups` fit beside the fixed block (`TOOLBAR_FIXED_ATTRIBUTE`). @internal
|
|
2903
|
+
*/
|
|
2904
|
+
declare function measureToolbar(el: HTMLElement, groups: readonly {
|
|
2905
|
+
readonly id: string;
|
|
2906
|
+
}[], widths: Map<string, number>): number;
|
|
2907
|
+
/**
|
|
2908
|
+
* Watch the bar `el`, each group that it shows, and its fixed block for a change of size, as
|
|
2909
|
+
* when fonts load or a value changes, and call `measure`. Returns the stop function. @internal
|
|
2910
|
+
*/
|
|
2911
|
+
declare function observeToolbar(el: HTMLElement, measure: () => void): () => void;
|
|
2912
|
+
/** The part of a key event that the focus moves read. @internal */
|
|
2913
|
+
interface FocusMoveKey {
|
|
2914
|
+
readonly key: string;
|
|
2915
|
+
readonly target: EventTarget | null;
|
|
2916
|
+
readonly currentTarget: EventTarget | null;
|
|
2917
|
+
/** True when a control of the host handled the key itself. */
|
|
2918
|
+
readonly defaultPrevented?: boolean;
|
|
2919
|
+
preventDefault(): void;
|
|
2920
|
+
}
|
|
2921
|
+
/**
|
|
2922
|
+
* Move focus between the controls of the bar with the arrow keys, Home, and End. `e.currentTarget`
|
|
2923
|
+
* is the bar. A control at any depth is a stop: a built-in control, a host control in a part or
|
|
2924
|
+
* a host group, and a loose control. @internal
|
|
2925
|
+
*/
|
|
2926
|
+
declare function moveBarFocus(e: FocusMoveKey): void;
|
|
2927
|
+
/**
|
|
2928
|
+
* Move focus among the items (`selector`) of a popup, `e.currentTarget`, with the arrow keys,
|
|
2929
|
+
* Home, and End. `grid` adds Left and Right, for a palette. Home and End in a text field move its
|
|
2930
|
+
* caret, not the focus. @internal
|
|
2931
|
+
*/
|
|
2932
|
+
declare function movePopupFocus(e: FocusMoveKey, selector: string, grid?: boolean): boolean;
|
|
2933
|
+
/**
|
|
2934
|
+
* Place the open popup (`[data-popup]`) of the toolbar part `root`. A popup that would run past
|
|
2935
|
+
* the editor's right edge opens from its trigger's end, and is then held inside the editor's
|
|
2936
|
+
* left edge. A popup that would run past the bottom of the visible area opens above its trigger
|
|
2937
|
+
* when there is more room there. The visible area is the window, less the host containers that
|
|
2938
|
+
* clip their overflow (`visibleArea`). With `inline` (inside the overflow panel), the popup
|
|
2939
|
+
* opens in flow, and the panel scrolls it into view. `selector` names the items of the popup.
|
|
2940
|
+
* @internal
|
|
2941
|
+
*/
|
|
2942
|
+
declare function placePopup(root: HTMLElement, inline: boolean, selector: string): void;
|
|
2943
|
+
/**
|
|
2944
|
+
* Focus the selected item (`selector`) of the open popup of `root`, or else the current item
|
|
2945
|
+
* (`aria-current`: an entry that names the value but is not picked), or the first. @internal
|
|
2946
|
+
*/
|
|
2947
|
+
declare function focusPopupItem(root: HTMLElement | null, selector: string): void;
|
|
2948
|
+
/**
|
|
2949
|
+
* What a key on a popup trigger does. Enter, Space, and Down open the popup with the keyboard in
|
|
2950
|
+
* it. On an open popup, Down moves the keyboard into it, and Enter or Space close it. Null for
|
|
2951
|
+
* another key: the key is not the trigger's. @internal
|
|
2952
|
+
*/
|
|
2953
|
+
declare function popupTriggerAction(key: string, open: boolean): 'open' | 'focusIn' | 'close' | null;
|
|
2954
|
+
/** A typed font size: a number of points from 1 to 409, in either decimal separator. @internal */
|
|
2955
|
+
declare function parseFontSize(text: string): string | null;
|
|
2956
|
+
/**
|
|
2957
|
+
* Whether `value` is a six-digit hex color, the only text that a color swatch puts in an inline
|
|
2958
|
+
* style. @internal
|
|
2959
|
+
*/
|
|
2960
|
+
declare const isHexColor: (value: string | null | undefined) => value is string;
|
|
2961
|
+
/**
|
|
2962
|
+
* Run `save` for Control or Command and S in the editor that holds the bar `el`, as DOCX
|
|
2963
|
+
* Editor's menu bar (`DocxEditorMenu`) does, key `s` with the platform modifier. Scoped to this
|
|
2964
|
+
* editor: only a key in the viewport that holds the bar, so a host page's own field keeps the key.
|
|
2965
|
+
* Read in the capture phase, as the cell editor and the grid keep their keys. A key in an open
|
|
2966
|
+
* modal dialog does not save: the dialog's edit is not applied yet. A host dialog marks itself
|
|
2967
|
+
* with `aria-modal="true"`. Returns the stop function. @internal
|
|
2968
|
+
*/
|
|
2969
|
+
declare function listenSaveKey(el: HTMLElement, save: () => void): () => void;
|
|
2970
|
+
|
|
2971
|
+
/** One host group's placement request. @internal */
|
|
2972
|
+
interface ToolbarHostGroupPlacement {
|
|
2973
|
+
readonly id: string;
|
|
2974
|
+
/** The group this one follows. Absent, or unknown, places it after every group. */
|
|
2975
|
+
readonly after?: string | undefined;
|
|
2976
|
+
}
|
|
2977
|
+
/**
|
|
2978
|
+
* Bar order with the host's groups placed.
|
|
2979
|
+
*
|
|
2980
|
+
* A host group without `after` follows every built-in group, in order of appearance. A group
|
|
2981
|
+
* with `after` follows the group it names, after any host groups already placed there, so
|
|
2982
|
+
* several groups anchored to one place keep their order of appearance. An anchor may be
|
|
2983
|
+
* another host group. An anchor that never resolves (an unknown id, or a cycle) places the
|
|
2984
|
+
* group at the end.
|
|
2985
|
+
*
|
|
2986
|
+
* @internal
|
|
2987
|
+
*/
|
|
2988
|
+
declare function arrangeToolbarGroups(builtIn: readonly string[], hosts: readonly ToolbarHostGroupPlacement[]): readonly string[];
|
|
2989
|
+
/** A `Toolbar.Slot` child of the preset toolbar, as the arrangement reads it. @internal */
|
|
2990
|
+
interface ToolbarSlotRequest {
|
|
2991
|
+
/** The slot that the part names. An id that the registry does not hold is a problem. */
|
|
2992
|
+
readonly slotId: string;
|
|
2993
|
+
/** The part removes its slot. */
|
|
2994
|
+
readonly hidden: boolean;
|
|
2995
|
+
/** The part has content of its own, which takes the slot's place. */
|
|
2996
|
+
readonly content: boolean;
|
|
2997
|
+
}
|
|
2998
|
+
/** A `Toolbar.Group` child of the preset toolbar, as the arrangement reads it. @internal */
|
|
2999
|
+
interface ToolbarGroupRequest {
|
|
3000
|
+
readonly id: string;
|
|
3001
|
+
readonly after?: string | undefined;
|
|
3002
|
+
readonly hidden?: boolean | undefined;
|
|
3003
|
+
readonly label?: string | undefined;
|
|
3004
|
+
readonly labelKey?: string | undefined;
|
|
3005
|
+
/** The part has content of its own: the controls of a host group, or extra controls. */
|
|
3006
|
+
readonly content: boolean;
|
|
3007
|
+
}
|
|
3008
|
+
/** A group of the arranged bar. @internal */
|
|
3009
|
+
interface ArrangedToolbarGroup {
|
|
3010
|
+
readonly id: string;
|
|
3011
|
+
/**
|
|
3012
|
+
* The built-in group with its hidden slots left out, or null for a host group. A built-in
|
|
3013
|
+
* group can have no control left and still show, when its `Toolbar.Group` adds content.
|
|
3014
|
+
*/
|
|
3015
|
+
readonly chrome: ChromeGroup | null;
|
|
3016
|
+
/** The literal heading of a host group. */
|
|
3017
|
+
readonly label?: string | undefined;
|
|
3018
|
+
/** The catalog key of a host group's heading. */
|
|
3019
|
+
readonly labelKey?: string | undefined;
|
|
3020
|
+
}
|
|
3021
|
+
/** The names of the two parts in one adapter, for the problems. @internal */
|
|
3022
|
+
interface ToolbarPartNames {
|
|
3023
|
+
readonly slot: string;
|
|
3024
|
+
readonly group: string;
|
|
3025
|
+
}
|
|
3026
|
+
/** The preset bar with the host's parts applied. @internal */
|
|
3027
|
+
interface ToolbarArrangement {
|
|
3028
|
+
/** The groups in bar order. A group with nothing to show is left out. */
|
|
3029
|
+
readonly groups: readonly ArrangedToolbarGroup[];
|
|
3030
|
+
/** The slots whose `Toolbar.Slot` content takes the place of the built-in control. */
|
|
3031
|
+
readonly replaced: ReadonlySet<ChromeSlotId>;
|
|
3032
|
+
/** The `Toolbar.Slot` ids that the registry does not hold. Their content is appended. */
|
|
3033
|
+
readonly outside: readonly string[];
|
|
3034
|
+
/** Development warnings: compositions that cannot do what they say. */
|
|
3035
|
+
readonly problems: readonly string[];
|
|
3036
|
+
/** Equal for two arrangements with the same groups, controls, and replaced slots. */
|
|
3037
|
+
readonly key: string;
|
|
3038
|
+
}
|
|
3039
|
+
/**
|
|
3040
|
+
* The heading of a group part: for a built-in id, the group's own translated label; else the
|
|
3041
|
+
* literal label, else the translated key, else the id. @internal
|
|
3042
|
+
*/
|
|
3043
|
+
declare function toolbarGroupHeading(group: Pick<ArrangedToolbarGroup, 'id' | 'label' | 'labelKey'>, translate: (key: string) => string): string;
|
|
3044
|
+
/**
|
|
3045
|
+
* Arrange the preset bar: the groups of `CHROME_GROUPS` in registry order, with the slots of
|
|
3046
|
+
* `hidden` and of a hidden `Toolbar.Slot` left out, and the `Toolbar.Group` requests applied.
|
|
3047
|
+
* The last request for a slot or a group wins; a group keeps the place of its last request. A
|
|
3048
|
+
* built-in group with `hidden` is left out with its separator, and so is a built-in group with
|
|
3049
|
+
* no control left and no content. A host group with `hidden` or no content is left out, but it
|
|
3050
|
+
* still anchors the groups that name it in `after`. @internal
|
|
3051
|
+
*/
|
|
3052
|
+
declare function arrangeToolbar(input: {
|
|
3053
|
+
readonly hidden?: readonly ChromeSlotId[];
|
|
3054
|
+
readonly slots?: readonly ToolbarSlotRequest[];
|
|
3055
|
+
readonly groups?: readonly ToolbarGroupRequest[];
|
|
3056
|
+
/** How the problems name the parts. The default is the React adapter's names. */
|
|
3057
|
+
readonly names?: ToolbarPartNames;
|
|
3058
|
+
}): ToolbarArrangement;
|
|
3059
|
+
|
|
3060
|
+
/**
|
|
3061
|
+
* A key of the sheet list: it changes when a sheet is added, removed, moved, or renamed.
|
|
3062
|
+
* @internal
|
|
3063
|
+
*/
|
|
3064
|
+
declare const sheetListKey: (sheets: readonly {
|
|
3065
|
+
readonly name: string;
|
|
3066
|
+
readonly visible: boolean;
|
|
3067
|
+
}[]) => string;
|
|
3068
|
+
/** The items of the tab menu. @internal */
|
|
3069
|
+
declare const SHEET_MENU_ITEM = "[role=\"menuitem\"]";
|
|
3070
|
+
/**
|
|
3071
|
+
* The key of a tab: its name, and how many tabs before it have the same name, so a tab keeps its
|
|
3072
|
+
* element when a sheet before it is added, deleted, or moved. A file can give two sheets the same
|
|
3073
|
+
* name: the count keeps their keys apart. @internal
|
|
3074
|
+
*/
|
|
3075
|
+
declare function tabKey(tabs: readonly {
|
|
3076
|
+
readonly name: string;
|
|
3077
|
+
}[], at: number): string;
|
|
3078
|
+
/** Move focus through the menu items for an arrow key, Home, or End. True when it moved. @internal */
|
|
3079
|
+
declare function moveInSheetMenu(menu: HTMLElement, key: string): boolean;
|
|
3080
|
+
/**
|
|
3081
|
+
* An open rename: the sheet name when it started, the box of its tab in the bar, and the room
|
|
3082
|
+
* before the add button. @internal
|
|
3083
|
+
*/
|
|
3084
|
+
interface SheetRenameBox {
|
|
3085
|
+
readonly name: string;
|
|
3086
|
+
readonly left: number;
|
|
3087
|
+
readonly width: number;
|
|
3088
|
+
/** Undefined when the bar has no add button to measure. */
|
|
3089
|
+
readonly maxWidth: number | undefined;
|
|
3090
|
+
}
|
|
3091
|
+
/** The elements of the tab bar that place the rename field. @internal */
|
|
3092
|
+
interface SheetBarParts {
|
|
3093
|
+
readonly bar: HTMLElement | null;
|
|
3094
|
+
readonly list: HTMLElement | null;
|
|
3095
|
+
readonly add: HTMLElement | null;
|
|
3096
|
+
}
|
|
3097
|
+
/**
|
|
3098
|
+
* The rename box over the tab of the sheet named `name`, as the bar shows it now, or null when
|
|
3099
|
+
* the tab is gone. The field stays over the tab list, and ends before the add button, so the
|
|
3100
|
+
* button stays in reach. @internal
|
|
3101
|
+
*/
|
|
3102
|
+
declare function sheetRenameBox(parts: SheetBarParts, sheets: readonly EditorSheet[], name: string): SheetRenameBox | null;
|
|
3103
|
+
/**
|
|
3104
|
+
* Where the tab menu opens in the bar `bar`, in its CSS pixels from the bar's left edge: at the
|
|
3105
|
+
* pointer (`clientX`), or at the tab's left edge when a key opens it. Inside a host that scales
|
|
3106
|
+
* the editor, window pixels are converted to the bar's pixels. @internal
|
|
3107
|
+
*/
|
|
3108
|
+
declare function sheetMenuLeft(bar: HTMLElement | null, tab: HTMLElement, clientX?: number): number;
|
|
3109
|
+
/**
|
|
3110
|
+
* Close the tab menu on a press outside it, a window blur, a resize, a scroll of the page, and a
|
|
3111
|
+
* wheel outside it (PPTX Editor `listenContextMenuDismiss` and `listenAway`). A scroll that code
|
|
3112
|
+
* makes inside the page, such as the grid that restores its scroll position or the tab list
|
|
3113
|
+
* that shows the chosen tab, does not close it. The grid cancels `pointerdown`, so the press is
|
|
3114
|
+
* read in the capture phase, on the document that owns the bar. Returns the stop function.
|
|
3115
|
+
* @internal
|
|
3116
|
+
*/
|
|
3117
|
+
declare function listenSheetMenuDismiss(bar: HTMLElement, inMenu: (node: Node) => boolean, close: () => void): () => void;
|
|
3118
|
+
/** An open tab menu, as the focus rules read it. @internal */
|
|
3119
|
+
interface SheetMenuOpening {
|
|
3120
|
+
readonly sheet: number;
|
|
3121
|
+
/** The element that had focus when the menu opened: focus goes back to it on close. */
|
|
3122
|
+
readonly back: HTMLElement | null;
|
|
3123
|
+
/** Whether a key opened the menu. */
|
|
3124
|
+
readonly keyboard: boolean;
|
|
3125
|
+
}
|
|
3126
|
+
/**
|
|
3127
|
+
* Open the menu `el` inside the bar at `left`, and focus its first item. Returns the function
|
|
3128
|
+
* that the close runs: when focus is still in the menu, it goes back to the element that had it
|
|
3129
|
+
* at the open; when that element is gone, or was the page, a key open gives focus to the tab,
|
|
3130
|
+
* and a press to the grid. @internal
|
|
3131
|
+
*/
|
|
3132
|
+
declare function openSheetMenu(el: HTMLElement, bar: HTMLElement | null, left: number, opening: SheetMenuOpening, editor: Pick<XlsxEditorInstance, 'focus'> | null): () => void;
|
|
3133
|
+
|
|
3134
|
+
/** The snapshot before an editor mounts, with the `mode` prop of the root applied. @internal */
|
|
3135
|
+
declare function emptySnapshotOf(mode: EditorMode): EditorSnapshot;
|
|
3136
|
+
/**
|
|
3137
|
+
* Report each font failure of an editor once: a failed open for its fonts, and each set of
|
|
3138
|
+
* packaged substitute faces that did not all load (`fontReport().substituteFailures`). Returns
|
|
3139
|
+
* the stop function.
|
|
3140
|
+
*
|
|
3141
|
+
* @internal
|
|
3142
|
+
*/
|
|
3143
|
+
declare function watchFontErrors(instance: Pick<XlsxEditorInstance, 'subscribe' | 'snapshot' | 'fontReport'>, report: (failure: EditorFailure) => void): () => void;
|
|
3144
|
+
/**
|
|
3145
|
+
* Call `fire` once, when the first open of `editor` settles (`snapshot().status` is not
|
|
3146
|
+
* `'loading'`), or at once when no open runs. Returns the stop function. @internal
|
|
3147
|
+
*/
|
|
3148
|
+
declare function whenOpenSettles(editor: Pick<XlsxEditorInstance, 'subscribe' | 'snapshot'>, fire: () => void): () => void;
|
|
3149
|
+
/** The `mode` prop of a root, applied to one editor. @internal */
|
|
3150
|
+
interface ModeProp {
|
|
3151
|
+
/** Apply the prop's value. A value equal to the last applied one changes nothing. */
|
|
3152
|
+
apply(mode: EditorMode): void;
|
|
3153
|
+
/** Stop the wait and the subscription. */
|
|
3154
|
+
dispose(): void;
|
|
3155
|
+
}
|
|
3156
|
+
/**
|
|
3157
|
+
* Apply a root's `mode` prop to `editor` when it changes, as DOCX Editor's root applies it: an
|
|
3158
|
+
* instance call to `setMode` stays until the next prop change. The first value applies only when
|
|
3159
|
+
* the editor is in another mode. A change that the open cell edit refuses waits, and applies when
|
|
3160
|
+
* the edit closes; `onWaits` tells the root whether a change waits, so it can show a notice. A
|
|
3161
|
+
* newer `setMode` call (`modeRequests`) during the wait ends the wait: that call wins.
|
|
3162
|
+
* @internal
|
|
3163
|
+
*/
|
|
3164
|
+
declare function followModeProp(editor: Pick<XlsxEditorInstance, 'subscribe' | 'snapshot' | 'setMode'>, onWaits: (waits: boolean) => void): ModeProp;
|
|
3165
|
+
|
|
3166
|
+
export { CHROME_GROUPS, ICON_PATHS as CHROME_ICON_PATHS, CHROME_SLOT_IDS, CLIPBOARD_TYPE, COLOR_CHOICES, CUSTOM_NUMBER_FORMAT_PREFIX, CUT_REFUSAL_CODES, CellInput, DISABLED_REASON_KEYS, EDIT_REFUSAL_CODES, EMPTY_SNAPSHOT, FONT_FAMILY_CHOICES, FONT_SIZE_CHOICES, FontSource, FormatPatch, FormatToggle, GridPoint, GridSelection, MAX_CONTENT_FIELD_CHARS, MAX_GO_TO_LENGTH, MAX_LISTED_NUMBER_FORMATS, MAX_ZOOM, MIN_ZOOM, MergeOptions, NO_FILL, NUMBER_FORMAT_CODE_PROBLEM_KEYS, NUMBER_FORMAT_SAMPLE, NumberLocale, RENAME_COMMIT_EVENT, SAVE_REFUSAL_CODES, SHEET_MENU_ITEM, SheetProtection, StructureSubject, TOOLBAR_FIXED_ATTRIBUTE, TOOLBAR_HINT_KEYS, WorkbookProtection, arrangeToolbar, arrangeToolbarGroups, blockNextClick, chromeControlForSlot, chromeSlotId, commitFocusedRename, composesKey, contentFieldText, createXlsxEditor, cycleRegion, disabledReasonText, displayName, editMoveOf, editorCommandSlice, editorHostDocument, editorHostElement, editorHostWindow, editorInstanceScope, emptySnapshotOf, fieldHistoryKey, focusAfterRelease, focusPopupItem, followModeProp, formulaSlice, gridSetupProblem, groupsThatFit, guardToolbarMousedown, hasOpenNestedPopup, historyShortcutOf, hostDocumentOf, hostWindowOf, insertFieldText, isDialogBackdropPoint, isElementNode, isHTMLElementNode, isHexColor, keepGridFocus, listenForOutsidePress, listenForPopupEscape, listenForPopupFocusLeave, listenSaveKey, listenSheetMenuDismiss, loadSubstituteFonts, measureToolbar, mergeCommandState, moveBarFocus, moveInSheetMenu, movePopupFocus, numberFormatChoiceCode, numberFormatChoices, numberFormatCodeProblem, numberFormatDialogApplyStep, numberFormatDialogCurrent, numberFormatDialogStart, numberFormatListView, numberFormatValue, observeToolbar, openSheetMenu, packageFailureText, parseCellInput, parseFontSize, pastLimitText, placePopup, popupTriggerAction, pressFieldBox, previewNumberFormat, refusalText, refusesEditText, refusesReference, relabelEditor, renameFocused, reportFontError, resolveDarkChrome, runToolbarCommand, sameEditorCommandSlice, sameFontSource, sameSlice, scrollIntoNearestScroller, sheetCommandState, sheetListKey, sheetMenuLeft, sheetRenameBox, showCaretLine, shownGroupCount, slotWords, statusSlice, statusView, stepFieldHistory, subjectText, subscribeSystemDark, substituteFontFailure, systemPrefersDark, tabKey, tabsSlice, toolbarCommandState, toolbarCommandStates, toolbarGroupHeading, toolbarGroups, trapTabWithin, watchFontErrors, watchGridSetup, whenOpenSettles, workbookNumberFormatCodes, zoomSlice };
|
|
3167
|
+
export type { ActiveCellFormat, ArrangedToolbarGroup, CellEditMode, CellEntryOptions, ChromeControl, ChromeControlKind, ChromeControlShape, ChromeDisabledReason, ChromeGroup, ChromeGroupId, ChromeHint, ChromePress, ChromeSlotId, ClipboardContent, ColorMode, CopyResult, DecimalSteps, DisabledReasonKey, DocumentChange, EditMove, EditRefusal, EditRefusalCode, EditResult, EditTextOptions, EditorCommandSlice, EditorEvents, EditorFailure, EditorFontSource, EditorMode, EditorSheet, EditorSnapshot, EditorTranslate, FieldBoxPress, FieldHistoryKey, FieldKeys, FocusMoveKey, FontReport, GridSetupFacts, HistoryShortcutKeys, HostWindow, MergeCommand, MergeCommandState, ModeProp, NumberFormatChoice, NumberFormatChoiceValue, NumberFormatCodeProblem, NumberFormatDialogApplyStep, NumberFormatDialogStart, NumberFormatListEntry, NumberFormatListView, NumberFormatPreview, OutsidePressOptions, PartPastLimit, PasteData, PopupEscapeOptions, PopupFocusLeaveOptions, RefusalSubject, RegionKey, RenameCommitDetail, ResolvedColorMode, SavedWorkbook, SheetBarParts, SheetCommand, SheetCommandInput, SheetCommandState, SheetMenuOpening, SheetRenameBox, SlotOf, SlotWords, StatusNotice, StatusView, SubstituteFontFailure, ToolbarArrangement, ToolbarCommandState, ToolbarGroupRequest, ToolbarHintKey, ToolbarHost, ToolbarHostGroupPlacement, ToolbarPartNames, ToolbarSlotRequest, WorkbookKind, XlsxEditorInstance, XlsxEditorOptions };
|