gridjs-spreadsheet 26.6.1 → 26.6.2

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/index.d.ts CHANGED
@@ -1,472 +1,471 @@
1
- declare module 'gridjs-spreadsheet' {
2
- export interface Options {
3
- mode?: 'edit' | 'read';
4
- showToolbar?: boolean;
5
- showGrid?: boolean;
6
- showContextmenu?: boolean;
7
- showFileName?: boolean;
8
- local?:string;
9
- view?: {
10
- height: () => number;
11
- width: () => number;
12
- };
13
- row?: {
14
- len: number;
15
- height: number;
16
- };
17
- col?: {
18
- len: number;
19
- width: number;
20
- indexWidth: number;
21
- minWidth: number;
22
- };
23
- style?: {
24
- bgcolor: string;
25
- align: 'left' | 'center' | 'right';
26
- valign: 'top' | 'middle' | 'bottom';
27
- textwrap: boolean;
28
- strike: boolean;
29
- underline: boolean;
30
- color: string;
31
- font: {
32
- name: 'Helvetica';
33
- size: number;
34
- bold: boolean;
35
- italic: false;
36
- };
37
- };
38
- /** Enable redaction feature */
39
- enableRedactionShape?: boolean;
40
- /** Predefined redaction reasons */
41
- redactionReasons?: string[];
42
- /** Default redaction color */
43
- redactionDefaultColor?: string;
44
- /**
45
- * Custom toolbar buttons injected before the "more" dropdown.
46
- * Each item defines a tag, tooltip, icon, and onClick handler.
47
- */
48
- customToolbarButtons?: CustomToolbarButtonConfig[];
49
- /**
50
- * Custom callback for adding new redaction reason.
51
- * If provided, replaces the default modal dialog.
52
- * @param existingReasons - Current list of existing reasons
53
- * @returns Promise<string> for the new reason, or null to cancel
54
- */
55
- onRedactionAddReason?: (existingReasons: string[]) => Promise<string | null>;
56
- }
57
-
58
- export type CELL_SELECTED = 'cell-selected';
59
- export type CELLS_SELECTED = 'cells-selected';
60
- export type CELL_EDITED = 'cell-edited';
61
- export type OBJECT_SELECTED = 'object-selected';
62
- export type SHEET_SELECTED = 'sheet-selected';
63
- export type SHEET_LOADED = 'sheet-loaded';
64
- export type VERTICAL_SCROLLED = 'vertical-scrolled';
65
- export type HORIZONTAL_SCROLLED = 'horizontal-scrolled';
66
- export type CELLS_DELETED = 'cells-deleted';
67
- export type CELLS_UPDATED = 'cells-updated';
68
- export type ROWS_INSERTED = 'rows-inserted';
69
- export type COLUMNS_INSERTED = 'columns-inserted';
70
- export type ROWS_DELETED = 'rows-deleted';
71
- export type COLUMNS_DELETED = 'columns-deleted';
72
- export type CHANGE = 'change';
73
- export type REDACTION_BURNED = 'redaction-burned';
74
- export type REDACTION_INSERTED = 'redaction-inserted';
75
- export type REDACTION_DELETED = 'redaction-deleted';
76
- export type REDACTION_UPDATED = 'redaction-updated';
77
- export type REDACTION_REASON_INSERTED = 'redactionReason-inserted';
78
- export type REDACTION_TRANSPARENCY_TOGGLED = 'redactionTransparency-toggled';
79
- export type CUSTOM_BUTTON = 'custom-button';
80
- export type UPDATE_SERVER_ERROR = 'updateServerError';
81
- export type UPDATE_CELL_ERROR = 'updateCellError';
82
-
83
- export type CellMerge = [number, number];
84
-
85
- export interface CellRange {
86
- sri: number;
87
- sci: number;
88
- eri: number;
89
- eci: number;
90
- }
91
-
92
- /** Icon descriptor for a custom toolbar button (choose one form) */
93
- export interface CustomToolbarButtonIcon {
94
- /** Image URL used as background-image */
95
- url?: string;
96
- /** CSS class applied to the inner icon element (user supplies CSS) */
97
- className?: string;
98
- /** Raw HTML fragment, e.g. inline <svg>...</svg> */
99
- html?: string;
100
- /** Plain text / emoji, e.g. '��' */
101
- text?: string;
102
- /** Width in px when using `url` (default: 16) */
103
- width?: number;
104
- /** Height in px when using `url` (default: 16) */
105
- height?: number;
106
- }
107
-
108
- /** Runtime instance of a custom toolbar button (passed to onClick and `custom-button` event) */
109
- export interface CustomToolbarButton {
110
- /** Unique tag identifier */
111
- tag: string;
112
- /** Tooltip text */
113
- tip: string;
114
- /** Reference to the owning Spreadsheet instance (injected by Toolbar) */
115
- spreadsheet: Spreadsheet;
116
- /** Original config passed in via Options.customToolbarButtons */
117
- config: CustomToolbarButtonConfig;
118
- /** Update the icon at runtime */
119
- setIcon(iconConfig: CustomToolbarButtonIcon): void;
120
- /** Update the tooltip text at runtime */
121
- setTooltip(text: string): void;
122
- /** Toggle active (highlighted) state */
123
- setActive(active: boolean): void;
124
- /** Toggle disabled state (click events suppressed) */
125
- setDisabled(disabled: boolean): void;
126
- /** Show the button */
127
- show(): void;
128
- /** Hide the button */
129
- hide(): void;
130
- }
131
-
132
- /** Configuration for a single custom toolbar button */
133
- export interface CustomToolbarButtonConfig {
134
- /** Unique identifier; forwarded as the second argument of the `custom-button` change event */
135
- tag: string;
136
- /** Tooltip shown on hover */
137
- tooltip?: string;
138
- /** Icon descriptor (url / className / html / text) */
139
- icon?: CustomToolbarButtonIcon;
140
- /** Click handler; `button` is the CustomToolbarButton instance, `spreadsheet` is the Spreadsheet instance */
141
- onClick?: (button: CustomToolbarButton, spreadsheet: Spreadsheet) => void;
142
- /** Initial active state */
143
- active?: boolean;
144
- /** Initial disabled state */
145
- disabled?: boolean;
146
- /** Optional fixed button width in px */
147
- width?: number;
148
- }
149
-
150
- export interface RedactionData {
151
- id: string;
152
- originId?: string;
153
- redactionReason?: string;
154
- redactionLabel?: string;
155
- redactionColor?: string;
156
- bgColor?: string;
157
- targetType?: string;
158
- targetId?: string;
159
- isRedaction?: boolean;
160
- fabobj?: any;
161
- }
162
-
163
- export interface SpreadsheetEventHandler {
164
- (
165
- envt: CELL_SELECTED,
166
- callback: (cell: Cell, rowIndex: number, colIndex: number) => void
167
- ): void;
168
- (
169
- envt: CELLS_SELECTED,
170
- callback: (
171
- cell: Cell,
172
- range: CellRange
173
- ) => void
174
- ): void;
175
- (
176
- envt: OBJECT_SELECTED,
177
- callback: (obj: { id: string; type: string; left: number; top: number; width: number; height: number }) => void
178
- ): void;
179
- (
180
- envt: SHEET_SELECTED,
181
- callback: (index: number, name: string) => void
182
- ): void;
183
- (
184
- envt: CELL_EDITED,
185
- callback: (text: string, rowIndex: number, colIndex: number) => void
186
- ): void;
187
- (
188
- envt: SHEET_LOADED,
189
- callback: (index: number, name: string) => void
190
- ): void;
191
- (
192
- envt: VERTICAL_SCROLLED,
193
- callback: (rowIndex: number) => void
194
- ): void;
195
- (
196
- envt: HORIZONTAL_SCROLLED,
197
- callback: (colIndex: number) => void
198
- ): void;
199
- (
200
- envt: CELLS_DELETED,
201
- callback: (range: CellRange) => void
202
- ): void;
203
- (
204
- envt: CELLS_UPDATED,
205
- callback: (sheetName: string, cells: any) => void
206
- ): void;
207
- (
208
- envt: ROWS_INSERTED,
209
- callback: (rowIndex: number, count: number) => void
210
- ): void;
211
- (
212
- envt: COLUMNS_INSERTED,
213
- callback: (colIndex: number, count: number) => void
214
- ): void;
215
- (
216
- envt: ROWS_DELETED,
217
- callback: (rowIndex: number, count: number) => void
218
- ): void;
219
- (
220
- envt: COLUMNS_DELETED,
221
- callback: (colIndex: number, count: number) => void
222
- ): void;
223
- (
224
- envt: CHANGE,
225
- callback: (...args: any[]) => void
226
- ): void;
227
- (
228
- envt: REDACTION_BURNED,
229
- callback: () => void
230
- ): void;
231
- (
232
- envt: REDACTION_INSERTED,
233
- callback: (sheetName: string, redactionData: RedactionData) => void
234
- ): void;
235
- (
236
- envt: REDACTION_DELETED,
237
- callback: (sheetName: string, redactionData: RedactionData) => void
238
- ): void;
239
- (
240
- envt: REDACTION_UPDATED,
241
- callback: (sheetName: string, shape: any) => void
242
- ): void;
243
- (
244
- envt: REDACTION_REASON_INSERTED,
245
- callback: (reason: string) => void
246
- ): void;
247
- (
248
- envt: REDACTION_TRANSPARENCY_TOGGLED,
249
- callback: (isTransparent: boolean) => void
250
- ): void;
251
- (
252
- envt: CUSTOM_BUTTON,
253
- callback: (tag: string, button: CustomToolbarButton) => void
254
- ): void;
255
- (
256
- envt: UPDATE_SERVER_ERROR,
257
- callback: (...args: any[]) => void
258
- ): void;
259
- (
260
- envt: UPDATE_CELL_ERROR,
261
- callback: (...args: any[]) => void
262
- ): void;
263
- }
264
-
265
- export interface ColProperties {
266
- width?: number;
267
- }
268
-
269
- /**
270
- * Data for representing a cell
271
- */
272
- export interface CellData {
273
- text: string;
274
- style?: number;
275
- merge?: CellMerge;
276
- }
277
- /**
278
- * Data for representing a row
279
- */
280
- export interface RowData {
281
- cells: {
282
- [key: number]: CellData;
283
- }
284
- }
285
-
286
- /**
287
- * Data for representing a sheet
288
- */
289
- export interface SheetData {
290
- name?: string;
291
- freeze?: string;
292
- styles?: CellStyle[];
293
- merges?: string[];
294
- cols?: {
295
- len?: number;
296
- [key: number]: ColProperties;
297
- };
298
- rows?: {
299
- [key: number]: RowData
300
- };
301
- }
302
-
303
- /**
304
- * Data for representing a spreadsheet
305
- */
306
- export interface SpreadsheetData {
307
- [index: number]: SheetData;
308
- }
309
-
310
- export interface CellStyle {
311
- align?: 'left' | 'center' | 'right';
312
- valign?: 'top' | 'middle' | 'bottom';
313
- font?: {
314
- bold?: boolean;
315
- }
316
- bgcolor?: string;
317
- textwrap?: boolean;
318
- color?: string;
319
- border?: {
320
- top?: string[];
321
- right?: string[];
322
- bottom?: string[];
323
- left?: string[];
324
- };
325
- }
326
- export interface Editor {}
327
- export interface Element {}
328
-
329
- export interface Row {}
330
- export interface Table {}
331
- export interface Cell {}
332
- export interface Sheet {}
333
-
334
- export default class Spreadsheet {
335
- constructor(container: string | HTMLElement, opts?: Options);
336
- /** Build version string (injected at compile time) */
337
- readonly version: string;
338
- on: SpreadsheetEventHandler;
339
- /**
340
- * retrieve cell
341
- * @param rowIndex {number} row index
342
- * @param colIndex {number} column index
343
- * @param sheetIndex {number} sheet iindex
344
- */
345
- cell(rowIndex: number, colIndex: number, sheetIndex: number): Cell;
346
- /**
347
- * retrieve cell style
348
- * @param rowIndex
349
- * @param colIndex
350
- * @param sheetIndex
351
- */
352
- cellStyle(
353
- rowIndex: number,
354
- colIndex: number,
355
- sheetIndex: number
356
- ): CellStyle;
357
- /**
358
- * get/set cell text
359
- * @param rowIndex
360
- * @param colIndex
361
- * @param text
362
- * @param sheetIndex
363
- */
364
- cellText(
365
- rowIndex: number,
366
- colIndex: number,
367
- text: string,
368
- sheetIndex?: number
369
- ): string;
370
- /**
371
- * remove current sheet
372
- */
373
- deleteSheet(): void;
374
- /**
375
- * move sheet to a new tab index
376
- * @param fromIndex current sheet index
377
- * @param toIndex target sheet index
378
- */
379
- moveSheet(fromIndex: number, toIndex: number): this;
380
-
381
- /**
382
- * insert a redaction shape on a target shape/image
383
- * @param reason redaction reason text
384
- * @param color background color
385
- * @param targetId target shape/image id
386
- * @param sheetName sheet name, defaults to active sheet
387
- */
388
- insertRedactionForShape(reason: string, color: string, targetId: string, sheetName?: string): Promise<void>;
389
-
390
- /**
391
- * insert a redaction on a cell range
392
- * @param reason redaction reason text
393
- * @param color background color
394
- * @param range cell range {sri, sci, eri, eci}
395
- * @param sheetName sheet name, defaults to active sheet
396
- */
397
- insertRedactionForRange(reason: string, color: string, range: CellRange, sheetName?: string): Promise<void>;
398
-
399
- /**
400
- * remove a redaction by id
401
- * @param id redaction id
402
- * @param sheetName sheet name, defaults to active sheet
403
- */
404
- removeRedaction(id: string, sheetName?: string): Promise<void>;
405
-
406
- /**
407
- * sync redaction operations from history records
408
- * @param historyOprArray array of operation history records
409
- * @param isSyncToServer whether to sync to server
410
- */
411
- syncRedactionOprClient(historyOprArray: any[], isSyncToServer?: boolean): Promise<void>;
412
-
413
- /**
414
- * burn all redactions permanently
415
- */
416
- burnAllRedactions(): void;
417
-
418
- /**
419
- * clear all redaction shapes on a sheet or sheets array
420
- * @param sheetNameOrArray sheet name, array of sheet names, or null for active sheet
421
- * @param isSyncToServer whether to sync to server
422
- */
423
- clearRedactionClient(sheetNameOrArray?: string | string[] | null, isSyncToServer?: boolean): Promise<void>;
424
-
425
- /**
426
- * load data
427
- * @param json
428
- * @param activeSheetName optional sheet name to activate after loading
429
- */
430
- loadData(json: Record<string, any>, activeSheetName?: string): this;
431
- /**
432
- * set active sheet by index
433
- * @param id sheet index
434
- * @param isReActive force re-activate even if already active
435
- */
436
- setActiveSheet(id: number, isReActive?: boolean): this;
437
- /**
438
- * set active sheet by name
439
- * @param sheetname sheet name
440
- * @param isReActive force re-activate even if already active
441
- */
442
- setActiveSheetByName(sheetname: string, isReActive?: boolean): this;
443
- /**
444
- * set active cell
445
- * @param rowIndex row index
446
- * @param colIndex column index
447
- * @param scrollToCell whether to scroll the active cell into view, defaults to true
448
- */
449
- setActiveCell(rowIndex: number, colIndex: number, scrollToCell?: boolean): this;
450
- /**
451
- * get data
452
- */
453
- getData(): Record<string, any>;
454
- /**
455
- * bind handler to change event, including data change and user actions
456
- * @param callback
457
- */
458
- change(callback: (json: Record<string, any>) => void): void;
459
- /**
460
- * set locale
461
- * @param lang
462
- * @param message
463
- */
464
- locale(lang: string, message: string): void;
465
- }
466
- global {
467
- interface Window {
468
- x_spreadsheet(container: string | HTMLElement, opts?: Options): Spreadsheet;
469
- }
470
- }
471
- }
472
-
1
+ declare module 'gridjs-spreadsheet' {
2
+ export interface Options {
3
+ mode?: 'edit' | 'read';
4
+ showToolbar?: boolean;
5
+ showGrid?: boolean;
6
+ showContextmenu?: boolean;
7
+ showFileName?: boolean;
8
+ local?:string;
9
+ view?: {
10
+ height: () => number;
11
+ width: () => number;
12
+ };
13
+ row?: {
14
+ len: number;
15
+ height: number;
16
+ };
17
+ col?: {
18
+ len: number;
19
+ width: number;
20
+ indexWidth: number;
21
+ minWidth: number;
22
+ };
23
+ style?: {
24
+ bgcolor: string;
25
+ align: 'left' | 'center' | 'right';
26
+ valign: 'top' | 'middle' | 'bottom';
27
+ textwrap: boolean;
28
+ strike: boolean;
29
+ underline: boolean;
30
+ color: string;
31
+ font: {
32
+ name: 'Helvetica';
33
+ size: number;
34
+ bold: boolean;
35
+ italic: false;
36
+ };
37
+ };
38
+ /** Enable redaction feature */
39
+ enableRedactionShape?: boolean;
40
+ /** Predefined redaction reasons */
41
+ redactionReasons?: string[];
42
+ /** Default redaction color */
43
+ redactionDefaultColor?: string;
44
+ /**
45
+ * Custom toolbar buttons injected before the "more" dropdown.
46
+ * Each item defines a tag, tooltip, icon, and onClick handler.
47
+ */
48
+ customToolbarButtons?: CustomToolbarButtonConfig[];
49
+ /**
50
+ * Custom callback for adding new redaction reason.
51
+ * If provided, replaces the default modal dialog.
52
+ * @param existingReasons - Current list of existing reasons
53
+ * @returns Promise<string> for the new reason, or null to cancel
54
+ */
55
+ onRedactionAddReason?: (existingReasons: string[]) => Promise<string | null>;
56
+ }
57
+
58
+ export type CELL_SELECTED = 'cell-selected';
59
+ export type CELLS_SELECTED = 'cells-selected';
60
+ export type CELL_EDITED = 'cell-edited';
61
+ export type OBJECT_SELECTED = 'object-selected';
62
+ export type SHEET_SELECTED = 'sheet-selected';
63
+ export type SHEET_LOADED = 'sheet-loaded';
64
+ export type VERTICAL_SCROLLED = 'vertical-scrolled';
65
+ export type HORIZONTAL_SCROLLED = 'horizontal-scrolled';
66
+ export type CELLS_DELETED = 'cells-deleted';
67
+ export type CELLS_UPDATED = 'cells-updated';
68
+ export type ROWS_INSERTED = 'rows-inserted';
69
+ export type COLUMNS_INSERTED = 'columns-inserted';
70
+ export type ROWS_DELETED = 'rows-deleted';
71
+ export type COLUMNS_DELETED = 'columns-deleted';
72
+ export type CHANGE = 'change';
73
+ export type REDACTION_BURNED = 'redaction-burned';
74
+ export type REDACTION_INSERTED = 'redaction-inserted';
75
+ export type REDACTION_DELETED = 'redaction-deleted';
76
+ export type REDACTION_UPDATED = 'redaction-updated';
77
+ export type REDACTION_REASON_INSERTED = 'redactionReason-inserted';
78
+ export type REDACTION_TRANSPARENCY_TOGGLED = 'redactionTransparency-toggled';
79
+ export type CUSTOM_BUTTON = 'custom-button';
80
+ export type UPDATE_SERVER_ERROR = 'updateServerError';
81
+ export type UPDATE_CELL_ERROR = 'updateCellError';
82
+
83
+ export type CellMerge = [number, number];
84
+
85
+ export interface CellRange {
86
+ sri: number;
87
+ sci: number;
88
+ eri: number;
89
+ eci: number;
90
+ }
91
+
92
+ /** Icon descriptor for a custom toolbar button (choose one form) */
93
+ export interface CustomToolbarButtonIcon {
94
+ /** Image URL used as background-image */
95
+ url?: string;
96
+ /** CSS class applied to the inner icon element (user supplies CSS) */
97
+ className?: string;
98
+ /** Raw HTML fragment, e.g. inline <svg>...</svg> */
99
+ html?: string;
100
+ /** Plain text / emoji, e.g. '' */
101
+ text?: string;
102
+ /** Width in px when using `url` (default: 16) */
103
+ width?: number;
104
+ /** Height in px when using `url` (default: 16) */
105
+ height?: number;
106
+ }
107
+
108
+ /** Runtime instance of a custom toolbar button (passed to onClick and `custom-button` event) */
109
+ export interface CustomToolbarButton {
110
+ /** Unique tag identifier */
111
+ tag: string;
112
+ /** Tooltip text */
113
+ tip: string;
114
+ /** Reference to the owning Spreadsheet instance (injected by Toolbar) */
115
+ spreadsheet: Spreadsheet;
116
+ /** Original config passed in via Options.customToolbarButtons */
117
+ config: CustomToolbarButtonConfig;
118
+ /** Update the icon at runtime */
119
+ setIcon(iconConfig: CustomToolbarButtonIcon): void;
120
+ /** Update the tooltip text at runtime */
121
+ setTooltip(text: string): void;
122
+ /** Toggle active (highlighted) state */
123
+ setActive(active: boolean): void;
124
+ /** Toggle disabled state (click events suppressed) */
125
+ setDisabled(disabled: boolean): void;
126
+ /** Show the button */
127
+ show(): void;
128
+ /** Hide the button */
129
+ hide(): void;
130
+ }
131
+
132
+ /** Configuration for a single custom toolbar button */
133
+ export interface CustomToolbarButtonConfig {
134
+ /** Unique identifier; forwarded as the second argument of the `custom-button` change event */
135
+ tag: string;
136
+ /** Tooltip shown on hover */
137
+ tooltip?: string;
138
+ /** Icon descriptor (url / className / html / text) */
139
+ icon?: CustomToolbarButtonIcon;
140
+ /** Click handler; `button` is the CustomToolbarButton instance, `spreadsheet` is the Spreadsheet instance */
141
+ onClick?: (button: CustomToolbarButton, spreadsheet: Spreadsheet) => void;
142
+ /** Initial active state */
143
+ active?: boolean;
144
+ /** Initial disabled state */
145
+ disabled?: boolean;
146
+ /** Optional fixed button width in px */
147
+ width?: number;
148
+ }
149
+
150
+ export interface RedactionData {
151
+ id: string;
152
+ originId?: string;
153
+ redactionReason?: string;
154
+ redactionLabel?: string;
155
+ redactionColor?: string;
156
+ bgColor?: string;
157
+ targetType?: string;
158
+ targetId?: string;
159
+ isRedaction?: boolean;
160
+ fabobj?: any;
161
+ }
162
+
163
+ export interface SpreadsheetEventHandler {
164
+ (
165
+ envt: CELL_SELECTED,
166
+ callback: (cell: Cell, rowIndex: number, colIndex: number) => void
167
+ ): void;
168
+ (
169
+ envt: CELLS_SELECTED,
170
+ callback: (
171
+ cell: Cell,
172
+ range: CellRange
173
+ ) => void
174
+ ): void;
175
+ (
176
+ envt: OBJECT_SELECTED,
177
+ callback: (obj: { id: string; type: string; left: number; top: number; width: number; height: number }) => void
178
+ ): void;
179
+ (
180
+ envt: SHEET_SELECTED,
181
+ callback: (index: number, name: string) => void
182
+ ): void;
183
+ (
184
+ envt: CELL_EDITED,
185
+ callback: (text: string, rowIndex: number, colIndex: number) => void
186
+ ): void;
187
+ (
188
+ envt: SHEET_LOADED,
189
+ callback: (index: number, name: string) => void
190
+ ): void;
191
+ (
192
+ envt: VERTICAL_SCROLLED,
193
+ callback: (rowIndex: number) => void
194
+ ): void;
195
+ (
196
+ envt: HORIZONTAL_SCROLLED,
197
+ callback: (colIndex: number) => void
198
+ ): void;
199
+ (
200
+ envt: CELLS_DELETED,
201
+ callback: (range: CellRange) => void
202
+ ): void;
203
+ (
204
+ envt: CELLS_UPDATED,
205
+ callback: (sheetName: string, cells: any) => void
206
+ ): void;
207
+ (
208
+ envt: ROWS_INSERTED,
209
+ callback: (rowIndex: number, count: number) => void
210
+ ): void;
211
+ (
212
+ envt: COLUMNS_INSERTED,
213
+ callback: (colIndex: number, count: number) => void
214
+ ): void;
215
+ (
216
+ envt: ROWS_DELETED,
217
+ callback: (rowIndex: number, count: number) => void
218
+ ): void;
219
+ (
220
+ envt: COLUMNS_DELETED,
221
+ callback: (colIndex: number, count: number) => void
222
+ ): void;
223
+ (
224
+ envt: CHANGE,
225
+ callback: (...args: any[]) => void
226
+ ): void;
227
+ (
228
+ envt: REDACTION_BURNED,
229
+ callback: () => void
230
+ ): void;
231
+ (
232
+ envt: REDACTION_INSERTED,
233
+ callback: (sheetName: string, redactionData: RedactionData) => void
234
+ ): void;
235
+ (
236
+ envt: REDACTION_DELETED,
237
+ callback: (sheetName: string, redactionData: RedactionData) => void
238
+ ): void;
239
+ (
240
+ envt: REDACTION_UPDATED,
241
+ callback: (sheetName: string, shape: any) => void
242
+ ): void;
243
+ (
244
+ envt: REDACTION_REASON_INSERTED,
245
+ callback: (reason: string) => void
246
+ ): void;
247
+ (
248
+ envt: REDACTION_TRANSPARENCY_TOGGLED,
249
+ callback: (isTransparent: boolean) => void
250
+ ): void;
251
+ (
252
+ envt: CUSTOM_BUTTON,
253
+ callback: (tag: string, button: CustomToolbarButton) => void
254
+ ): void;
255
+ (
256
+ envt: UPDATE_SERVER_ERROR,
257
+ callback: (...args: any[]) => void
258
+ ): void;
259
+ (
260
+ envt: UPDATE_CELL_ERROR,
261
+ callback: (...args: any[]) => void
262
+ ): void;
263
+ }
264
+
265
+ export interface ColProperties {
266
+ width?: number;
267
+ }
268
+
269
+ /**
270
+ * Data for representing a cell
271
+ */
272
+ export interface CellData {
273
+ text: string;
274
+ style?: number;
275
+ merge?: CellMerge;
276
+ }
277
+ /**
278
+ * Data for representing a row
279
+ */
280
+ export interface RowData {
281
+ cells: {
282
+ [key: number]: CellData;
283
+ }
284
+ }
285
+
286
+ /**
287
+ * Data for representing a sheet
288
+ */
289
+ export interface SheetData {
290
+ name?: string;
291
+ freeze?: string;
292
+ styles?: CellStyle[];
293
+ merges?: string[];
294
+ cols?: {
295
+ len?: number;
296
+ [key: number]: ColProperties;
297
+ };
298
+ rows?: {
299
+ [key: number]: RowData
300
+ };
301
+ }
302
+
303
+ /**
304
+ * Data for representing a spreadsheet
305
+ */
306
+ export interface SpreadsheetData {
307
+ [index: number]: SheetData;
308
+ }
309
+
310
+ export interface CellStyle {
311
+ align?: 'left' | 'center' | 'right';
312
+ valign?: 'top' | 'middle' | 'bottom';
313
+ font?: {
314
+ bold?: boolean;
315
+ }
316
+ bgcolor?: string;
317
+ textwrap?: boolean;
318
+ color?: string;
319
+ border?: {
320
+ top?: string[];
321
+ right?: string[];
322
+ bottom?: string[];
323
+ left?: string[];
324
+ };
325
+ }
326
+ export interface Editor {}
327
+ export interface Element {}
328
+
329
+ export interface Row {}
330
+ export interface Table {}
331
+ export interface Cell {}
332
+ export interface Sheet {}
333
+
334
+ export default class Spreadsheet {
335
+ constructor(container: string | HTMLElement, opts?: Options);
336
+ /** Build version string (injected at compile time) */
337
+ readonly version: string;
338
+ on: SpreadsheetEventHandler;
339
+ /**
340
+ * retrieve cell
341
+ * @param rowIndex {number} row index
342
+ * @param colIndex {number} column index
343
+ * @param sheetIndex {number} sheet iindex
344
+ */
345
+ cell(rowIndex: number, colIndex: number, sheetIndex: number): Cell;
346
+ /**
347
+ * retrieve cell style
348
+ * @param rowIndex
349
+ * @param colIndex
350
+ * @param sheetIndex
351
+ */
352
+ cellStyle(
353
+ rowIndex: number,
354
+ colIndex: number,
355
+ sheetIndex: number
356
+ ): CellStyle;
357
+ /**
358
+ * get/set cell text
359
+ * @param rowIndex
360
+ * @param colIndex
361
+ * @param text
362
+ * @param sheetIndex
363
+ */
364
+ cellText(
365
+ rowIndex: number,
366
+ colIndex: number,
367
+ text: string,
368
+ sheetIndex?: number
369
+ ): string;
370
+ /**
371
+ * remove current sheet
372
+ */
373
+ deleteSheet(): void;
374
+ /**
375
+ * move sheet to a new tab index
376
+ * @param fromIndex current sheet index
377
+ * @param toIndex target sheet index
378
+ */
379
+ moveSheet(fromIndex: number, toIndex: number): this;
380
+
381
+ /**
382
+ * insert a redaction shape on a target shape/image
383
+ * @param reason redaction reason text
384
+ * @param color background color
385
+ * @param targetId target shape/image id
386
+ * @param sheetName sheet name, defaults to active sheet
387
+ */
388
+ insertRedactionForShape(reason: string, color: string, targetId: string, sheetName?: string): Promise<void>;
389
+
390
+ /**
391
+ * insert a redaction on a cell range
392
+ * @param reason redaction reason text
393
+ * @param color background color
394
+ * @param range cell range {sri, sci, eri, eci}
395
+ * @param sheetName sheet name, defaults to active sheet
396
+ */
397
+ insertRedactionForRange(reason: string, color: string, range: CellRange, sheetName?: string): Promise<void>;
398
+
399
+ /**
400
+ * remove a redaction by id
401
+ * @param id redaction id
402
+ * @param sheetName sheet name, defaults to active sheet
403
+ */
404
+ removeRedaction(id: string, sheetName?: string): Promise<void>;
405
+
406
+ /**
407
+ * sync redaction operations from history records
408
+ * @param historyOprArray array of operation history records
409
+ * @param isSyncToServer whether to sync to server
410
+ */
411
+ syncRedactionOprClient(historyOprArray: any[], isSyncToServer?: boolean): Promise<void>;
412
+
413
+ /**
414
+ * burn all redactions permanently
415
+ */
416
+ burnAllRedactions(): void;
417
+
418
+ /**
419
+ * clear all redaction shapes on a sheet or sheets array
420
+ * @param sheetNameOrArray sheet name, array of sheet names, or null for active sheet
421
+ * @param isSyncToServer whether to sync to server
422
+ */
423
+ clearRedactionClient(sheetNameOrArray?: string | string[] | null, isSyncToServer?: boolean): Promise<void>;
424
+
425
+ /**
426
+ * load data
427
+ * @param json
428
+ * @param activeSheetName optional sheet name to activate after loading
429
+ */
430
+ loadData(json: Record<string, any>, activeSheetName?: string): this;
431
+ /**
432
+ * set active sheet by index
433
+ * @param id sheet index
434
+ * @param isReActive force re-activate even if already active
435
+ */
436
+ setActiveSheet(id: number, isReActive?: boolean): this;
437
+ /**
438
+ * set active sheet by name
439
+ * @param sheetname sheet name
440
+ * @param isReActive force re-activate even if already active
441
+ */
442
+ setActiveSheetByName(sheetname: string, isReActive?: boolean): this;
443
+ /**
444
+ * set active cell
445
+ * @param rowIndex row index
446
+ * @param colIndex column index
447
+ * @param scrollToCell whether to scroll the active cell into view, defaults to true
448
+ */
449
+ setActiveCell(rowIndex: number, colIndex: number, scrollToCell?: boolean): this;
450
+ /**
451
+ * get data
452
+ */
453
+ getData(): Record<string, any>;
454
+ /**
455
+ * bind handler to change event, including data change and user actions
456
+ * @param callback
457
+ */
458
+ change(callback: (json: Record<string, any>) => void): void;
459
+ /**
460
+ * set locale
461
+ * @param lang
462
+ * @param message
463
+ */
464
+ locale(lang: string, message: string): void;
465
+ }
466
+ global {
467
+ interface Window {
468
+ x_spreadsheet(container: string | HTMLElement, opts?: Options): Spreadsheet;
469
+ }
470
+ }
471
+ }