@a3s-lab/office 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/COLLABORATION_ROADMAP.md +15 -5
  2. package/README.md +34 -1
  3. package/dist/0~6090.js +7 -8
  4. package/dist/0~spreadsheet-editor.js +6869 -3427
  5. package/dist/0~work-office-diagnostics.js +1 -1
  6. package/dist/{4476.js → 2180.js} +404 -35
  7. package/dist/4104.js +698 -41
  8. package/dist/5184.js +1 -1
  9. package/dist/8715.js +156 -156
  10. package/dist/core.js +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/internal/collaboration/office-spreadsheet-collaboration-records.d.ts +2 -0
  13. package/dist/internal/collaboration/office-spreadsheet-collaboration-validation-support.d.ts +6 -0
  14. package/dist/internal/features/work/editors/spreadsheet-auto-filter.d.ts +1 -0
  15. package/dist/internal/features/work/editors/spreadsheet-command-catalog.d.ts +44 -1
  16. package/dist/internal/features/work/editors/spreadsheet-command-controller.d.ts +28 -0
  17. package/dist/internal/features/work/editors/spreadsheet-data-validation-command.d.ts +3 -0
  18. package/dist/internal/features/work/editors/spreadsheet-data-validation-dialog.d.ts +9 -0
  19. package/dist/internal/features/work/editors/spreadsheet-data-validation.d.ts +50 -0
  20. package/dist/internal/features/work/editors/spreadsheet-editor-ribbon.d.ts +4 -2
  21. package/dist/internal/features/work/editors/spreadsheet-editor-support.d.ts +1 -0
  22. package/dist/internal/features/work/editors/spreadsheet-hyperlink-command.d.ts +3 -0
  23. package/dist/internal/features/work/editors/spreadsheet-hyperlink-dialog.d.ts +9 -0
  24. package/dist/internal/features/work/editors/spreadsheet-hyperlink.d.ts +44 -0
  25. package/dist/internal/features/work/editors/spreadsheet-table-command.d.ts +3 -0
  26. package/dist/internal/features/work/editors/spreadsheet-table-conversion.d.ts +7 -0
  27. package/dist/internal/features/work/editors/spreadsheet-table-dialog.d.ts +8 -0
  28. package/dist/internal/features/work/editors/spreadsheet-table-limits.d.ts +1 -0
  29. package/dist/internal/features/work/editors/spreadsheet-table-reconciliation.d.ts +21 -0
  30. package/dist/internal/features/work/editors/spreadsheet-table-render.d.ts +16 -0
  31. package/dist/internal/features/work/editors/spreadsheet-table-ribbon.d.ts +8 -0
  32. package/dist/internal/features/work/editors/spreadsheet-table-style.d.ts +31 -0
  33. package/dist/internal/features/work/editors/spreadsheet-table.d.ts +55 -0
  34. package/dist/internal/features/work/editors/use-spreadsheet-data-validation.d.ts +23 -0
  35. package/dist/internal/features/work/editors/use-spreadsheet-hyperlink.d.ts +24 -0
  36. package/dist/internal/features/work/editors/use-spreadsheet-table.d.ts +23 -0
  37. package/dist/internal/features/work/work-spreadsheet-data-validation.d.ts +2 -0
  38. package/dist/internal/features/work/work-types.d.ts +100 -0
  39. package/dist/internal/features/work/work-xlsx-interop.d.ts +2 -0
  40. package/dist/internal/features/work/work-xlsx-table-filters.d.ts +3 -0
  41. package/dist/internal/features/work/work-xlsx-tables.d.ts +4 -0
  42. package/dist/office-kernel.wasm +0 -0
  43. package/dist/styles.css +486 -0
  44. package/dist/work-spreadsheet-package-scan.worker.js +3 -2
  45. package/docs/latest/en/browser-editor-architecture.md +43 -0
  46. package/package.json +12 -3
package/dist/5184.js CHANGED
@@ -25,7 +25,7 @@ const WORK_TEMPLATES = [
25
25
  id: 'blank-spreadsheet',
26
26
  kind: 'spreadsheet',
27
27
  name: '空白表格',
28
- description: '公式、筛选与多工作表',
28
+ description: '公式、表格、筛选与多工作表',
29
29
  accent: '#16a36a'
30
30
  },
31
31
  {
package/dist/8715.js CHANGED
@@ -1,4 +1,160 @@
1
1
  import { createOfficeId as createWorkId, directChild, attribute } from "./5184.js";
2
+ const CELL_REFERENCE = /\$?([A-Z]{1,3})\$?([1-9]\d*)/i;
3
+ const CELL_OR_RANGE = new RegExp(`^${CELL_REFERENCE.source}(?::${CELL_REFERENCE.source})?$`, 'i');
4
+ const COLUMN_RANGE = /^\$?([A-Z]{1,3}):\$?([A-Z]{1,3})$/i;
5
+ const ROW_RANGE = /^\$?([1-9]\d*):\$?([1-9]\d*)$/;
6
+ const DEFINED_NAME = /^[\p{L}_\\][\p{L}\p{N}_.\\]*$/u;
7
+ function isValidSpreadsheetDefinedName(value) {
8
+ const name = value.trim();
9
+ if (!name || Array.from(name).length > 255 || !DEFINED_NAME.test(name) || /^_xlnm\./i.test(name)) return false;
10
+ if (/^[A-Z]{1,3}[1-9]\d*$/i.test(name) || /^R\d+C\d+$/i.test(name)) return false;
11
+ return true;
12
+ }
13
+ function normalizeSpreadsheetPrintArea(value) {
14
+ const parts = splitRangeList(value.trim().replace(/^=/, ''));
15
+ if (!parts.length) return null;
16
+ const normalized = parts.map((part)=>{
17
+ const reference = unqualifiedReference(part);
18
+ if (!CELL_OR_RANGE.test(reference) && !COLUMN_RANGE.test(reference) && !ROW_RANGE.test(reference)) return null;
19
+ return reference.replace(/[A-Z]+/gi, (column)=>column.toUpperCase());
20
+ });
21
+ return normalized.every((part)=>Boolean(part)) ? normalized.join(',') : null;
22
+ }
23
+ function normalizeSpreadsheetPrintTitleRows(value) {
24
+ const match = ROW_RANGE.exec(unqualifiedReference(value.trim().replace(/^=/, '')));
25
+ if (!match) return null;
26
+ const start = Number(match[1]);
27
+ const end = Number(match[2]);
28
+ return `$${Math.min(start, end)}:$${Math.max(start, end)}`;
29
+ }
30
+ function normalizeSpreadsheetPrintTitleColumns(value) {
31
+ const match = COLUMN_RANGE.exec(unqualifiedReference(value.trim().replace(/^=/, '')));
32
+ if (!match) return null;
33
+ const start = decodeColumn(match[1]);
34
+ const end = decodeColumn(match[2]);
35
+ return `$${encodeColumn(Math.min(start, end))}:$${encodeColumn(Math.max(start, end))}`;
36
+ }
37
+ function parseSpreadsheetPrintTitles(value) {
38
+ let rows;
39
+ let columns;
40
+ for (const part of splitRangeList(value.trim().replace(/^=/, ''))){
41
+ const rowReference = normalizeSpreadsheetPrintTitleRows(part);
42
+ if (rowReference) {
43
+ if (rows) return null;
44
+ const match = ROW_RANGE.exec(rowReference);
45
+ rows = [
46
+ Number(match[1]) - 1,
47
+ Number(match[2]) - 1
48
+ ];
49
+ continue;
50
+ }
51
+ const columnReference = normalizeSpreadsheetPrintTitleColumns(part);
52
+ if (!columnReference || columns) return null;
53
+ const match = COLUMN_RANGE.exec(columnReference);
54
+ columns = [
55
+ decodeColumn(match[1]),
56
+ decodeColumn(match[2])
57
+ ];
58
+ }
59
+ return rows || columns ? {
60
+ rows,
61
+ columns
62
+ } : null;
63
+ }
64
+ function parseSpreadsheetCellRanges(value) {
65
+ const parts = splitRangeList(value.trim().replace(/^=/, ''));
66
+ if (!parts.length) return null;
67
+ const ranges = parts.map((part)=>{
68
+ const cells = CELL_OR_RANGE.exec(unqualifiedReference(part));
69
+ if (!cells) return null;
70
+ const first = decodeCell(cells[1], cells[2]);
71
+ const second = cells[3] && cells[4] ? decodeCell(cells[3], cells[4]) : first;
72
+ return {
73
+ row: [
74
+ Math.min(first.row, second.row),
75
+ Math.max(first.row, second.row)
76
+ ],
77
+ column: [
78
+ Math.min(first.column, second.column),
79
+ Math.max(first.column, second.column)
80
+ ]
81
+ };
82
+ });
83
+ return ranges.every((range)=>Boolean(range)) ? ranges : null;
84
+ }
85
+ function formatSpreadsheetCellRanges(ranges) {
86
+ return ranges.map((range)=>{
87
+ const start = encodeCell(range.row[0], range.column[0]);
88
+ const end = encodeCell(range.row[1], range.column[1]);
89
+ return start === end ? start : `${start}:${end}`;
90
+ }).join(',');
91
+ }
92
+ function qualifySpreadsheetRange(value, sheetName) {
93
+ const prefix = `'${sheetName.replaceAll("'", "''")}'!`;
94
+ return splitRangeList(value).map((part)=>part.includes('!') ? part.trim() : `${prefix}${part.trim()}`).join(',');
95
+ }
96
+ function stripSpreadsheetSheetQualifier(value, sheetName) {
97
+ const quotedPrefix = `'${sheetName.replaceAll("'", "''")}'!`;
98
+ const plainPrefix = `${sheetName}!`;
99
+ return splitRangeList(value.trim().replace(/^=/, '')).map((part)=>{
100
+ const reference = part.trim();
101
+ if (reference.toLowerCase().startsWith(quotedPrefix.toLowerCase())) return reference.slice(quotedPrefix.length);
102
+ if (reference.toLowerCase().startsWith(plainPrefix.toLowerCase())) return reference.slice(plainPrefix.length);
103
+ return reference;
104
+ }).join(',');
105
+ }
106
+ function splitRangeList(value) {
107
+ const parts = [];
108
+ let current = '';
109
+ let quoted = false;
110
+ for(let index = 0; index < value.length; index += 1){
111
+ const character = value[index];
112
+ if ("'" === character) {
113
+ if (quoted && "'" === value[index + 1]) {
114
+ current += "''";
115
+ index += 1;
116
+ continue;
117
+ }
118
+ quoted = !quoted;
119
+ }
120
+ if (',' !== character || quoted) current += character;
121
+ else {
122
+ if (current.trim()) parts.push(current.trim());
123
+ current = '';
124
+ }
125
+ }
126
+ if (current.trim()) parts.push(current.trim());
127
+ return parts;
128
+ }
129
+ function unqualifiedReference(value) {
130
+ const reference = value.trim().replace(/^=/, '');
131
+ const separator = reference.lastIndexOf('!');
132
+ return separator >= 0 ? reference.slice(separator + 1) : reference;
133
+ }
134
+ function decodeCell(column, row) {
135
+ return {
136
+ row: Math.max(0, Number(row) - 1),
137
+ column: decodeColumn(column)
138
+ };
139
+ }
140
+ function decodeColumn(value) {
141
+ let result = 0;
142
+ for (const character of value.toUpperCase())result = 26 * result + character.charCodeAt(0) - 64;
143
+ return Math.max(0, result - 1);
144
+ }
145
+ function encodeCell(row, column) {
146
+ return `${encodeColumn(column)}${Math.max(0, row) + 1}`;
147
+ }
148
+ function encodeColumn(column) {
149
+ let value = Math.max(0, column) + 1;
150
+ let label = '';
151
+ while(value > 0){
152
+ value -= 1;
153
+ label = String.fromCharCode(65 + value % 26) + label;
154
+ value = Math.floor(value / 26);
155
+ }
156
+ return label;
157
+ }
2
158
  function sparseArrayIndexes(values) {
3
159
  if (!values) return [];
4
160
  return Object.keys(values).flatMap((key)=>{
@@ -323,162 +479,6 @@ function formatPivotNumber(value) {
323
479
  function matchesPivotReportFilters(values, pivot) {
324
480
  return (pivot.reportFilters ?? []).every((filter)=>void 0 === filter.selectedItem || spreadsheetPivotFilterValueKey(normalizeSpreadsheetPivotFilterValue(values[filter.fieldIndex])) === spreadsheetPivotFilterValueKey(filter.selectedItem));
325
481
  }
326
- const CELL_REFERENCE = /\$?([A-Z]{1,3})\$?([1-9]\d*)/i;
327
- const CELL_OR_RANGE = new RegExp(`^${CELL_REFERENCE.source}(?::${CELL_REFERENCE.source})?$`, 'i');
328
- const COLUMN_RANGE = /^\$?([A-Z]{1,3}):\$?([A-Z]{1,3})$/i;
329
- const ROW_RANGE = /^\$?([1-9]\d*):\$?([1-9]\d*)$/;
330
- const DEFINED_NAME = /^[\p{L}_\\][\p{L}\p{N}_.\\]*$/u;
331
- function isValidSpreadsheetDefinedName(value) {
332
- const name = value.trim();
333
- if (!name || name.length > 255 || !DEFINED_NAME.test(name) || /^_xlnm\./i.test(name)) return false;
334
- if (/^[A-Z]{1,3}[1-9]\d*$/i.test(name) || /^R\d+C\d+$/i.test(name)) return false;
335
- return true;
336
- }
337
- function normalizeSpreadsheetPrintArea(value) {
338
- const parts = splitRangeList(value.trim().replace(/^=/, ''));
339
- if (!parts.length) return null;
340
- const normalized = parts.map((part)=>{
341
- const reference = unqualifiedReference(part);
342
- if (!CELL_OR_RANGE.test(reference) && !COLUMN_RANGE.test(reference) && !ROW_RANGE.test(reference)) return null;
343
- return reference.replace(/[A-Z]+/gi, (column)=>column.toUpperCase());
344
- });
345
- return normalized.every((part)=>Boolean(part)) ? normalized.join(',') : null;
346
- }
347
- function normalizeSpreadsheetPrintTitleRows(value) {
348
- const match = ROW_RANGE.exec(unqualifiedReference(value.trim().replace(/^=/, '')));
349
- if (!match) return null;
350
- const start = Number(match[1]);
351
- const end = Number(match[2]);
352
- return `$${Math.min(start, end)}:$${Math.max(start, end)}`;
353
- }
354
- function normalizeSpreadsheetPrintTitleColumns(value) {
355
- const match = COLUMN_RANGE.exec(unqualifiedReference(value.trim().replace(/^=/, '')));
356
- if (!match) return null;
357
- const start = decodeColumn(match[1]);
358
- const end = decodeColumn(match[2]);
359
- return `$${encodeColumn(Math.min(start, end))}:$${encodeColumn(Math.max(start, end))}`;
360
- }
361
- function parseSpreadsheetPrintTitles(value) {
362
- let rows;
363
- let columns;
364
- for (const part of splitRangeList(value.trim().replace(/^=/, ''))){
365
- const rowReference = normalizeSpreadsheetPrintTitleRows(part);
366
- if (rowReference) {
367
- if (rows) return null;
368
- const match = ROW_RANGE.exec(rowReference);
369
- rows = [
370
- Number(match[1]) - 1,
371
- Number(match[2]) - 1
372
- ];
373
- continue;
374
- }
375
- const columnReference = normalizeSpreadsheetPrintTitleColumns(part);
376
- if (!columnReference || columns) return null;
377
- const match = COLUMN_RANGE.exec(columnReference);
378
- columns = [
379
- decodeColumn(match[1]),
380
- decodeColumn(match[2])
381
- ];
382
- }
383
- return rows || columns ? {
384
- rows,
385
- columns
386
- } : null;
387
- }
388
- function parseSpreadsheetCellRanges(value) {
389
- const parts = splitRangeList(value.trim().replace(/^=/, ''));
390
- if (!parts.length) return null;
391
- const ranges = parts.map((part)=>{
392
- const cells = CELL_OR_RANGE.exec(unqualifiedReference(part));
393
- if (!cells) return null;
394
- const first = decodeCell(cells[1], cells[2]);
395
- const second = cells[3] && cells[4] ? decodeCell(cells[3], cells[4]) : first;
396
- return {
397
- row: [
398
- Math.min(first.row, second.row),
399
- Math.max(first.row, second.row)
400
- ],
401
- column: [
402
- Math.min(first.column, second.column),
403
- Math.max(first.column, second.column)
404
- ]
405
- };
406
- });
407
- return ranges.every((range)=>Boolean(range)) ? ranges : null;
408
- }
409
- function formatSpreadsheetCellRanges(ranges) {
410
- return ranges.map((range)=>{
411
- const start = encodeCell(range.row[0], range.column[0]);
412
- const end = encodeCell(range.row[1], range.column[1]);
413
- return start === end ? start : `${start}:${end}`;
414
- }).join(',');
415
- }
416
- function qualifySpreadsheetRange(value, sheetName) {
417
- const prefix = `'${sheetName.replaceAll("'", "''")}'!`;
418
- return splitRangeList(value).map((part)=>part.includes('!') ? part.trim() : `${prefix}${part.trim()}`).join(',');
419
- }
420
- function stripSpreadsheetSheetQualifier(value, sheetName) {
421
- const quotedPrefix = `'${sheetName.replaceAll("'", "''")}'!`;
422
- const plainPrefix = `${sheetName}!`;
423
- return splitRangeList(value.trim().replace(/^=/, '')).map((part)=>{
424
- const reference = part.trim();
425
- if (reference.toLowerCase().startsWith(quotedPrefix.toLowerCase())) return reference.slice(quotedPrefix.length);
426
- if (reference.toLowerCase().startsWith(plainPrefix.toLowerCase())) return reference.slice(plainPrefix.length);
427
- return reference;
428
- }).join(',');
429
- }
430
- function splitRangeList(value) {
431
- const parts = [];
432
- let current = '';
433
- let quoted = false;
434
- for(let index = 0; index < value.length; index += 1){
435
- const character = value[index];
436
- if ("'" === character) {
437
- if (quoted && "'" === value[index + 1]) {
438
- current += "''";
439
- index += 1;
440
- continue;
441
- }
442
- quoted = !quoted;
443
- }
444
- if (',' !== character || quoted) current += character;
445
- else {
446
- if (current.trim()) parts.push(current.trim());
447
- current = '';
448
- }
449
- }
450
- if (current.trim()) parts.push(current.trim());
451
- return parts;
452
- }
453
- function unqualifiedReference(value) {
454
- const reference = value.trim().replace(/^=/, '');
455
- const separator = reference.lastIndexOf('!');
456
- return separator >= 0 ? reference.slice(separator + 1) : reference;
457
- }
458
- function decodeCell(column, row) {
459
- return {
460
- row: Math.max(0, Number(row) - 1),
461
- column: decodeColumn(column)
462
- };
463
- }
464
- function decodeColumn(value) {
465
- let result = 0;
466
- for (const character of value.toUpperCase())result = 26 * result + character.charCodeAt(0) - 64;
467
- return Math.max(0, result - 1);
468
- }
469
- function encodeCell(row, column) {
470
- return `${encodeColumn(column)}${Math.max(0, row) + 1}`;
471
- }
472
- function encodeColumn(column) {
473
- let value = Math.max(0, column) + 1;
474
- let label = '';
475
- while(value > 0){
476
- value -= 1;
477
- label = String.fromCharCode(65 + value % 26) + label;
478
- value = Math.floor(value / 26);
479
- }
480
- return label;
481
- }
482
482
  const MAXIMUM_SOURCE_CELLS = 100000;
483
483
  const MAXIMUM_OUTPUT_CELLS = 20000;
484
484
  const MAXIMUM_XLSX_ROW = 1048575;
package/dist/core.js CHANGED
@@ -7,6 +7,6 @@ export { createArtifact, createOfficeId, officeTemplates } from "./5184.js";
7
7
  export { createOfficeDocumentCollaborationBinding, initializeOfficeDocumentCollaboration, officeDocumentCollaborationFragment, readOfficeDocumentCollaboration } from "./6282.js";
8
8
  export { createOfficeMarkdownCollaborationBinding, initializeOfficeMarkdownCollaboration, readOfficeMarkdownCollaboration, replaceOfficeMarkdownCollaboration } from "./2591.js";
9
9
  export { createOfficePresentationCollaborationBinding, initializeOfficePresentationCollaboration, readOfficePresentationCollaboration, replaceOfficePresentationCollaboration } from "./4560.js";
10
- export { createOfficeSpreadsheetCollaborationBinding, initializeOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration, replaceOfficeSpreadsheetCollaboration } from "./4476.js";
10
+ export { createOfficeSpreadsheetCollaborationBinding, initializeOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration, replaceOfficeSpreadsheetCollaboration } from "./2180.js";
11
11
  export { normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetBubbleSizeRepresents, normalizeWorkSpreadsheetChartAxisGroup, normalizeWorkSpreadsheetCombinationSeriesType, normalizeWorkSpreadsheetDataLabelPosition, normalizeWorkSpreadsheetDataLabels, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetErrorBars, normalizeWorkSpreadsheetRadarStyle, normalizeWorkSpreadsheetScatterStyle, normalizeWorkSpreadsheetTrendline, normalizeWorkSpreadsheetTrendlineType, workSpreadsheetChartSupportsAxes, workSpreadsheetChartSupportsErrorBars, workSpreadsheetChartSupportsTrendlines, workSpreadsheetChartTypeLabel, workSpreadsheetChartUsesNumericXAxis, workSpreadsheetCombinationSeriesTypeLabel, workSpreadsheetDataLabelPositionLabel, workSpreadsheetErrorBarTypeLabel, workSpreadsheetErrorBarValueTypeLabel, workSpreadsheetTrendlineTypeLabel } from "./8715.js";
12
12
  export { core_OFFICE_COLLABORATION_VERSION as OFFICE_COLLABORATION_VERSION };
package/dist/index.js CHANGED
@@ -10,6 +10,6 @@ export { createArtifact, createOfficeId, officeTemplates } from "./5184.js";
10
10
  export { createOfficeDocumentCollaborationBinding, initializeOfficeDocumentCollaboration, officeDocumentCollaborationFragment, readOfficeDocumentCollaboration } from "./6282.js";
11
11
  export { createOfficeMarkdownCollaborationBinding, initializeOfficeMarkdownCollaboration, readOfficeMarkdownCollaboration, replaceOfficeMarkdownCollaboration } from "./2591.js";
12
12
  export { createOfficePresentationCollaborationBinding, initializeOfficePresentationCollaboration, readOfficePresentationCollaboration, replaceOfficePresentationCollaboration } from "./4560.js";
13
- export { createOfficeSpreadsheetCollaborationBinding, initializeOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration, replaceOfficeSpreadsheetCollaboration } from "./4476.js";
13
+ export { createOfficeSpreadsheetCollaborationBinding, initializeOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration, replaceOfficeSpreadsheetCollaboration } from "./2180.js";
14
14
  export { normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetBubbleSizeRepresents, normalizeWorkSpreadsheetChartAxisGroup, normalizeWorkSpreadsheetCombinationSeriesType, normalizeWorkSpreadsheetDataLabelPosition, normalizeWorkSpreadsheetDataLabels, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetErrorBars, normalizeWorkSpreadsheetRadarStyle, normalizeWorkSpreadsheetScatterStyle, normalizeWorkSpreadsheetTrendline, normalizeWorkSpreadsheetTrendlineType, workSpreadsheetChartSupportsAxes, workSpreadsheetChartSupportsErrorBars, workSpreadsheetChartSupportsTrendlines, workSpreadsheetChartTypeLabel, workSpreadsheetChartUsesNumericXAxis, workSpreadsheetCombinationSeriesTypeLabel, workSpreadsheetDataLabelPositionLabel, workSpreadsheetErrorBarTypeLabel, workSpreadsheetErrorBarValueTypeLabel, workSpreadsheetTrendlineTypeLabel } from "./8715.js";
15
15
  export { src_DOCUMENT_SNAPSHOT_VERSION as DOCUMENT_SNAPSHOT_VERSION, src_DOCUMENT_SOURCE_VERSION as DOCUMENT_SOURCE_VERSION, src_OFFICE_COLLABORATION_VERSION as OFFICE_COLLABORATION_VERSION };
@@ -8,6 +8,8 @@ export declare const SPREADSHEET_RECORD_CHARTS = "charts";
8
8
  export declare const SPREADSHEET_RECORD_CHART_ORDER = "chartOrder";
9
9
  export declare const SPREADSHEET_RECORD_PIVOTS = "pivotTables";
10
10
  export declare const SPREADSHEET_RECORD_PIVOT_ORDER = "pivotOrder";
11
+ export declare const SPREADSHEET_RECORD_TABLES = "tables";
12
+ export declare const SPREADSHEET_RECORD_TABLE_ORDER = "tableOrder";
11
13
  export declare function initializeSpreadsheetSheetRecord(record: Y.Map<unknown>, sheet: WorkSpreadsheetSheet): void;
12
14
  export declare function patchSpreadsheetSheetRecord(record: Y.Map<unknown>, previous: WorkSpreadsheetSheet | undefined, next: WorkSpreadsheetSheet): void;
13
15
  export declare function readSpreadsheetSheetRecord(record: Y.Map<unknown>, id: string): WorkSpreadsheetSheet;
@@ -0,0 +1,6 @@
1
+ export declare function requiredCoordinate(value: unknown, maximum: number, label: string, sheetId: string): number;
2
+ export declare function requiredInputRecord(value: unknown, label: string): Record<string, unknown>;
3
+ export declare function requiredIdentifier(value: unknown, label: string): string;
4
+ export declare function requiredNonEmptyString(value: unknown, label: string): string;
5
+ export declare function validateJsonRecord(value: Record<string, unknown>, label: string): Record<string, unknown>;
6
+ export declare function invalidWorkOfficeSpreadsheetInput(expected: string): never;
@@ -5,5 +5,6 @@ export interface SpreadsheetAutoFilterRange {
5
5
  column: [number, number];
6
6
  }
7
7
  export declare function spreadsheetAutoFilterRange(sheet: WorkSpreadsheetSheet, selection: Selection): SpreadsheetAutoFilterRange | null;
8
+ export declare function spreadsheetSelectionOrCurrentRegion(sheet: WorkSpreadsheetSheet, selection: Selection): SpreadsheetAutoFilterRange | null;
8
9
  export declare function spreadsheetAutoFilterHeaderColumn(sheet: WorkSpreadsheetSheet | undefined, selection: Selection): number | null;
9
10
  export declare function toggleSpreadsheetAutoFilter(content: WorkSpreadsheetContent, sheetId: string, selection: Selection): WorkSpreadsheetContent | null;
@@ -21,7 +21,13 @@ export declare const spreadsheetRibbonTabs: readonly [{
21
21
  readonly id: "view";
22
22
  readonly label: "视图";
23
23
  }];
24
- export type SpreadsheetRibbonTabId = (typeof spreadsheetRibbonTabs)[number]['id'];
24
+ export declare const spreadsheetTableDesignRibbonTab: {
25
+ readonly id: "tableDesign";
26
+ readonly label: "表格设计";
27
+ readonly compactLabel: "设计";
28
+ readonly contextual: true;
29
+ };
30
+ export type SpreadsheetRibbonTabId = (typeof spreadsheetRibbonTabs)[number]['id'] | typeof spreadsheetTableDesignRibbonTab.id;
25
31
  export interface SpreadsheetCommandShortcut {
26
32
  label: string;
27
33
  aria: string;
@@ -757,6 +763,34 @@ export declare const spreadsheetCommandCatalog: {
757
763
  readonly group: "charts";
758
764
  };
759
765
  };
766
+ readonly table: {
767
+ readonly id: "insert.table";
768
+ readonly label: "表格";
769
+ readonly location: {
770
+ readonly area: "ribbon";
771
+ readonly tab: "insert";
772
+ readonly group: "tables";
773
+ };
774
+ readonly shortcut: {
775
+ readonly label: "Cmd/Ctrl+T";
776
+ readonly aria: "Control+T Meta+T";
777
+ readonly editor: readonly ["Mod-t"];
778
+ };
779
+ };
780
+ readonly hyperlink: {
781
+ readonly id: "insert.hyperlink";
782
+ readonly label: "超链接";
783
+ readonly location: {
784
+ readonly area: "ribbon";
785
+ readonly tab: "insert";
786
+ readonly group: "links";
787
+ };
788
+ readonly shortcut: {
789
+ readonly label: "Cmd/Ctrl+K";
790
+ readonly aria: "Control+K Meta+K";
791
+ readonly editor: readonly ["Mod-k"];
792
+ };
793
+ };
760
794
  readonly printSettings: {
761
795
  readonly id: "pageLayout.printSettings";
762
796
  readonly label: "打印设置";
@@ -835,6 +869,15 @@ export declare const spreadsheetCommandCatalog: {
835
869
  readonly editor: readonly ["Alt-ArrowDown"];
836
870
  };
837
871
  };
872
+ readonly dataValidation: {
873
+ readonly id: "data.validation";
874
+ readonly label: "数据验证";
875
+ readonly location: {
876
+ readonly area: "ribbon";
877
+ readonly tab: "data";
878
+ readonly group: "dataTools";
879
+ };
880
+ };
838
881
  readonly pivotTable: {
839
882
  readonly id: "data.pivotTable";
840
883
  readonly label: "数据透视表";
@@ -9,13 +9,16 @@ import type { SpreadsheetCellFormatRequest } from './spreadsheet-cell-format';
9
9
  import type { SpreadsheetCellRange } from './spreadsheet-cell-range';
10
10
  import type { SpreadsheetCellStyleChoice } from './spreadsheet-cell-style';
11
11
  import type { SpreadsheetCellFillDirection } from './spreadsheet-cell-fill';
12
+ import type { SpreadsheetDataValidationRequest, SpreadsheetDataValidationTarget } from './spreadsheet-data-validation';
12
13
  import { type SpreadsheetCellMergeCommand } from './spreadsheet-cell-merge';
13
14
  import type { SpreadsheetFormatPainterMode } from './spreadsheet-format-painter';
15
+ import type { SpreadsheetHyperlinkCell, SpreadsheetHyperlinkRequest } from './spreadsheet-hyperlink';
14
16
  import { type SpreadsheetFreezePanePreset } from './spreadsheet-freeze-panes';
15
17
  import { type SpreadsheetKeyboardSelection, type SpreadsheetSelectionMove, type SpreadsheetSelectionScope } from './spreadsheet-keyboard-navigation';
16
18
  import type { SpreadsheetPasteContent } from './spreadsheet-paste-special';
17
19
  import { type SpreadsheetDecimalPlacesDirection } from './spreadsheet-number-format-command';
18
20
  import { type SpreadsheetSheetMoveDirection } from './spreadsheet-sheet-model';
21
+ import type { SpreadsheetTableDesignPatch, SpreadsheetTableRequest, SpreadsheetTableTarget } from './spreadsheet-table';
19
22
  export interface SpreadsheetWorkbookCommandPort {
20
23
  autoFillCell: (copyRange: SpreadsheetCommandRange, applyRange: SpreadsheetCommandRange, direction: SpreadsheetCellFillDirection) => void;
21
24
  batchCallApis: (apiCalls: Array<{
@@ -117,6 +120,18 @@ export interface SpreadsheetFormatCellsCommandPort {
117
120
  canOpen: boolean;
118
121
  open: (request: SpreadsheetFormatCellsOpenRequest) => boolean;
119
122
  }
123
+ export interface SpreadsheetDataValidationCommandPort {
124
+ canOpen: boolean;
125
+ open: (request: SpreadsheetDataValidationTarget) => boolean;
126
+ }
127
+ export interface SpreadsheetHyperlinkCommandPort {
128
+ canOpen: boolean;
129
+ open: (request: SpreadsheetHyperlinkCell) => boolean;
130
+ }
131
+ export interface SpreadsheetTableCommandPort {
132
+ canOpen: boolean;
133
+ open: (target: SpreadsheetTableTarget) => boolean;
134
+ }
120
135
  export interface SpreadsheetNavigationCommandPort {
121
136
  canOpenFind: boolean;
122
137
  canOpenGoTo: boolean;
@@ -136,8 +151,11 @@ export interface SpreadsheetEditorCommands {
136
151
  adjustDecimalPlaces: (direction: SpreadsheetDecimalPlacesDirection) => boolean;
137
152
  applyCellStyle: (preset: SpreadsheetCellStyleChoice) => boolean;
138
153
  applyCellFormat: (request: SpreadsheetCellFormatRequest) => boolean;
154
+ applyDataValidation: (request: SpreadsheetDataValidationRequest) => boolean;
139
155
  applyAutoSum: (functionName: SpreadsheetAutoSumFunction) => boolean;
140
156
  applyFormatPainter: (target: SpreadsheetCommandSelection) => boolean;
157
+ applyHyperlink: (request: SpreadsheetHyperlinkRequest) => boolean;
158
+ applyTable: (request: SpreadsheetTableRequest) => boolean;
141
159
  cancelFormatPainter: () => boolean;
142
160
  clearSelectedCells: (mode?: SpreadsheetCellClearMode) => boolean;
143
161
  copySelection: () => boolean;
@@ -152,14 +170,19 @@ export interface SpreadsheetEditorCommands {
152
170
  moveSheet: (sheetId: string, direction: SpreadsheetSheetMoveDirection) => boolean;
153
171
  moveSelection: (move: SpreadsheetSelectionMove, extend: boolean) => boolean;
154
172
  openAutoFilterMenu: () => boolean;
173
+ openDataValidation: () => boolean;
155
174
  openFind: () => boolean;
156
175
  openFormatCells: () => boolean;
157
176
  openGoTo: () => boolean;
177
+ openHyperlink: () => boolean;
158
178
  openPasteSpecial: () => boolean;
179
+ openTable: () => boolean;
159
180
  pasteCells: (values: readonly (readonly unknown[])[]) => boolean;
160
181
  pasteSelection: () => boolean;
161
182
  pasteSpecial: (content: SpreadsheetPasteContent) => boolean;
162
183
  recalculateFormula: (scope: 'selection' | 'workbook') => boolean;
184
+ removeHyperlink: (target: SpreadsheetHyperlinkCell) => boolean;
185
+ removeDataValidation: (target: SpreadsheetDataValidationTarget) => boolean;
163
186
  renameSheet: (sheetId: string, name: string) => boolean;
164
187
  redo: () => boolean;
165
188
  setCellFormat: (attribute: keyof Cell, value: unknown) => boolean;
@@ -174,6 +197,8 @@ export interface SpreadsheetEditorCommands {
174
197
  setZoom: (percent: number) => boolean;
175
198
  sortSelectedCells: (direction: SpreadsheetSortDirection) => boolean;
176
199
  toggleAutoFilter: () => boolean;
200
+ updateTable: (sheetId: string, tableId: string, patch: SpreadsheetTableDesignPatch) => boolean;
201
+ convertTableToRange: (sheetId: string, tableId: string) => boolean;
177
202
  undo: () => boolean;
178
203
  }
179
204
  export type SpreadsheetEditorCanCommands = OfficeEditorCanCommands<SpreadsheetEditorCommands>;
@@ -183,15 +208,18 @@ export interface SpreadsheetCommandContext {
183
208
  calculation: SpreadsheetCalculationCommandPort | null;
184
209
  clipboard: SpreadsheetClipboardCommandPort;
185
210
  content: WorkSpreadsheetContent;
211
+ dataValidation: SpreadsheetDataValidationCommandPort;
186
212
  editable: boolean;
187
213
  fallbackRange: SpreadsheetCommandRange;
188
214
  formulaBar: SpreadsheetFormulaBarCommandPort | null;
189
215
  formatPainter: SpreadsheetFormatPainterCommandPort;
190
216
  formatCells: SpreadsheetFormatCellsCommandPort;
217
+ hyperlink: SpreadsheetHyperlinkCommandPort;
191
218
  history: SpreadsheetHistoryCommandPort | null;
192
219
  navigation: SpreadsheetNavigationCommandPort;
193
220
  onChange: (content: WorkSpreadsheetContent) => void;
194
221
  selection: SpreadsheetCommandSelection | null;
222
+ table: SpreadsheetTableCommandPort;
195
223
  targetSheetGridSize?: SpreadsheetGridSize | null;
196
224
  targetSheetId: string;
197
225
  toolbarCell: Cell | null;
@@ -0,0 +1,3 @@
1
+ import type { SpreadsheetCommandContext, SpreadsheetEditorCommands } from './spreadsheet-command-controller';
2
+ import { type OfficeEditorExtension } from './office-editor-extension';
3
+ export declare function createSpreadsheetDataValidationExtension(): OfficeEditorExtension<SpreadsheetCommandContext, SpreadsheetEditorCommands>;
@@ -0,0 +1,9 @@
1
+ import { type SpreadsheetDataValidationDialogSource, type SpreadsheetDataValidationDialogValue } from './spreadsheet-data-validation';
2
+ export declare function SpreadsheetDataValidationDialog({ source, restoreFocusTarget, onApply, onClose, onRemove, onValidate, }: {
3
+ source: SpreadsheetDataValidationDialogSource;
4
+ restoreFocusTarget: () => HTMLElement | null;
5
+ onApply: (value: SpreadsheetDataValidationDialogValue) => boolean;
6
+ onClose: () => void;
7
+ onRemove: () => boolean;
8
+ onValidate: (value: SpreadsheetDataValidationDialogValue) => string | null;
9
+ }): import("react").JSX.Element;
@@ -0,0 +1,50 @@
1
+ import type { WorkSpreadsheetContent, WorkSpreadsheetDataValidationItem, WorkSpreadsheetSheet } from '../work-types';
2
+ import { type SpreadsheetCellRange } from './spreadsheet-cell-range';
3
+ export declare const MAX_SPREADSHEET_DATA_VALIDATION_CELLS = 10000;
4
+ export type SpreadsheetDataValidationType = 'date' | 'dropdown' | 'number' | 'number_integer' | 'text_length';
5
+ export type SpreadsheetDataValidationOperator = 'between' | 'equal' | 'greaterOrEqualTo' | 'lessThan' | 'lessThanOrEqualTo' | 'moreThanThe' | 'noEarlierThan' | 'noLaterThan' | 'notBetween' | 'notEqualTo' | 'earlierThan' | 'laterThan';
6
+ export interface SpreadsheetDataValidationDialogValue {
7
+ hintShow: boolean;
8
+ hintValue: string;
9
+ prohibitInput: boolean;
10
+ type: SpreadsheetDataValidationType;
11
+ type2: SpreadsheetDataValidationOperator | '';
12
+ value1: string;
13
+ value2: string;
14
+ }
15
+ export interface SpreadsheetDataValidationTarget {
16
+ activeCell: {
17
+ row: number;
18
+ column: number;
19
+ };
20
+ ranges: readonly SpreadsheetCellRange[];
21
+ sheetId: string;
22
+ }
23
+ export interface SpreadsheetDataValidationRequest extends SpreadsheetDataValidationTarget {
24
+ value: SpreadsheetDataValidationDialogValue;
25
+ }
26
+ export interface SpreadsheetDataValidationDialogSource extends SpreadsheetDataValidationTarget {
27
+ hasValidation: boolean;
28
+ mixed: boolean;
29
+ rangeReference: string;
30
+ sheetName: string;
31
+ value: SpreadsheetDataValidationDialogValue;
32
+ }
33
+ export type SpreadsheetDataValidationResult = {
34
+ item: WorkSpreadsheetDataValidationItem;
35
+ ok: true;
36
+ ranges: SpreadsheetCellRange[];
37
+ sheet: WorkSpreadsheetSheet;
38
+ } | {
39
+ code: SpreadsheetDataValidationErrorCode;
40
+ message: string;
41
+ ok: false;
42
+ };
43
+ export type SpreadsheetDataValidationErrorCode = 'invalid-date' | 'invalid-list-source' | 'invalid-number' | 'invalid-operator' | 'invalid-range' | 'invalid-text-length' | 'missing-value' | 'multiple-list-columns' | 'out-of-bounds' | 'protected-range' | 'range-too-large' | 'sheet-not-found' | 'value-order';
44
+ export declare function spreadsheetDataValidationOperators(type: SpreadsheetDataValidationType): readonly SpreadsheetDataValidationOperator[];
45
+ export declare function createSpreadsheetDataValidationDialogSource(content: WorkSpreadsheetContent, target: SpreadsheetDataValidationTarget): SpreadsheetDataValidationDialogSource | null;
46
+ export declare function validateSpreadsheetDataValidationRequest(content: WorkSpreadsheetContent, request: SpreadsheetDataValidationRequest): SpreadsheetDataValidationResult;
47
+ export declare function applySpreadsheetDataValidation(content: WorkSpreadsheetContent, request: SpreadsheetDataValidationRequest): WorkSpreadsheetContent | null;
48
+ export declare function removeSpreadsheetDataValidation(content: WorkSpreadsheetContent, target: SpreadsheetDataValidationTarget): WorkSpreadsheetContent | null;
49
+ export declare function canRemoveSpreadsheetDataValidation(content: WorkSpreadsheetContent, target: SpreadsheetDataValidationTarget): boolean;
50
+ export declare function spreadsheetDataValidationFailureMessage(content: WorkSpreadsheetContent, request: SpreadsheetDataValidationRequest): string | null;
@@ -1,5 +1,5 @@
1
1
  import type { Cell, Selection } from '@fortune-sheet/core';
2
- import type { WorkSpreadsheetContent } from '../work-types';
2
+ import type { WorkSpreadsheetContent, WorkSpreadsheetTable } from '../work-types';
3
3
  import type { SpreadsheetResolvedCellBorders } from './spreadsheet-cell-border';
4
4
  import { type SpreadsheetRibbonTabId } from './spreadsheet-command-catalog';
5
5
  import type { SpreadsheetEditorCanCommands, SpreadsheetEditorCommands } from './spreadsheet-command-controller';
@@ -7,8 +7,10 @@ import type { SpreadsheetFormatPainterMode } from './spreadsheet-format-painter'
7
7
  import type { SpreadsheetWorkbookPanelView } from './spreadsheet-workbook-panel';
8
8
  import { type WorkOfficeFileAction } from './work-office-chrome';
9
9
  export type { SpreadsheetRibbonTabId } from './spreadsheet-command-catalog';
10
- export declare function SpreadsheetEditorRibbon({ activeTab, autoFilterActive, can, commands, content, fileActions, findOpen, formatPainterMode, freezePanesActive, freezePanesSelection, gridLinesVisible, panelId, onTabChange, onTogglePanel, panel, toolbarCell, toolbarCellBorders, }: {
10
+ export declare function SpreadsheetEditorRibbon({ activeTab, activeTable, activeTableSheetId, autoFilterActive, can, commands, content, fileActions, findOpen, formatPainterMode, freezePanesActive, freezePanesSelection, gridLinesVisible, panelId, onTabChange, onTogglePanel, panel, toolbarCell, toolbarCellBorders, }: {
11
11
  activeTab: SpreadsheetRibbonTabId;
12
+ activeTable?: WorkSpreadsheetTable | null;
13
+ activeTableSheetId?: string;
12
14
  autoFilterActive?: boolean;
13
15
  can: SpreadsheetEditorCanCommands;
14
16
  commands: SpreadsheetEditorCommands;
@@ -32,6 +32,7 @@ export declare function sameSpreadsheetWorkbookState(changed: WorkSpreadsheetCon
32
32
  export declare function sameSpreadsheetWorkbookStateAfterOperations(changed: WorkSpreadsheetContent['sheets'], rendered: WorkSpreadsheetContent['sheets'], operations: readonly Op[]): boolean | null;
33
33
  export declare function sameSpreadsheetHistoryContent(left: WorkSpreadsheetContent, right: WorkSpreadsheetContent): boolean;
34
34
  export declare function spreadsheetContentWithSelection(content: WorkSpreadsheetContent, sheetId: string, selection: Selection | null | undefined): WorkSpreadsheetContent;
35
+ export declare function spreadsheetContentWithSelections(content: WorkSpreadsheetContent, sheetId: string, selections: readonly Selection[]): WorkSpreadsheetContent;
35
36
  export declare function isSpreadsheetNativeTextUndoTarget(target: EventTarget | null): boolean;
36
37
  export declare function isSpreadsheetCellEditingTarget(target: EventTarget | null): boolean;
37
38
  export declare function spreadsheetFormulaBarSelectAllTarget(event: KeyboardEvent): HTMLElement | null;
@@ -0,0 +1,3 @@
1
+ import type { SpreadsheetCommandContext, SpreadsheetEditorCommands } from './spreadsheet-command-controller';
2
+ import { type OfficeEditorExtension } from './office-editor-extension';
3
+ export declare function createSpreadsheetHyperlinkExtension(): OfficeEditorExtension<SpreadsheetCommandContext, SpreadsheetEditorCommands>;
@@ -0,0 +1,9 @@
1
+ import type { SpreadsheetHyperlinkDialogSource, SpreadsheetHyperlinkDialogValue } from './spreadsheet-hyperlink';
2
+ export declare function SpreadsheetHyperlinkDialog({ source, restoreFocusTarget, onApply, onClose, onRemove, onValidate, }: {
3
+ source: SpreadsheetHyperlinkDialogSource;
4
+ restoreFocusTarget: () => HTMLElement | null;
5
+ onApply: (value: SpreadsheetHyperlinkDialogValue) => boolean;
6
+ onClose: () => void;
7
+ onRemove: () => boolean;
8
+ onValidate: (value: SpreadsheetHyperlinkDialogValue) => string | null;
9
+ }): import("react").JSX.Element;