@a3s-lab/office 0.13.1 → 0.15.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 (50) hide show
  1. package/README.md +40 -5
  2. package/dist/0~7048.js +14 -4
  3. package/dist/0~spreadsheet-editor.js +14748 -8939
  4. package/dist/0~work-office-diagnostics.js +1 -1
  5. package/dist/{4476.js → 2180.js} +34 -1
  6. package/dist/4104.js +41 -19
  7. package/dist/core.js +1 -1
  8. package/dist/index.js +1 -1
  9. package/dist/internal/features/work/editors/office-checkbox.d.ts +3 -2
  10. package/dist/internal/features/work/editors/spreadsheet-auto-sum-command.d.ts +3 -0
  11. package/dist/internal/features/work/editors/spreadsheet-auto-sum.d.ts +19 -0
  12. package/dist/internal/features/work/editors/spreadsheet-cell-format-command.d.ts +3 -0
  13. package/dist/internal/features/work/editors/spreadsheet-cell-format.d.ts +36 -0
  14. package/dist/internal/features/work/editors/spreadsheet-cell-mutation-guard.d.ts +4 -0
  15. package/dist/internal/features/work/editors/spreadsheet-clipboard-shortcuts.d.ts +1 -0
  16. package/dist/internal/features/work/editors/spreadsheet-clipboard.d.ts +13 -0
  17. package/dist/internal/features/work/editors/spreadsheet-command-catalog.d.ts +142 -0
  18. package/dist/internal/features/work/editors/spreadsheet-command-controller.d.ts +56 -0
  19. package/dist/internal/features/work/editors/spreadsheet-context-menu.d.ts +5 -15
  20. package/dist/internal/features/work/editors/spreadsheet-data-validation-command.d.ts +3 -0
  21. package/dist/internal/features/work/editors/spreadsheet-data-validation-dialog.d.ts +9 -0
  22. package/dist/internal/features/work/editors/spreadsheet-data-validation.d.ts +50 -0
  23. package/dist/internal/features/work/editors/spreadsheet-editor-ribbon.d.ts +1 -2
  24. package/dist/internal/features/work/editors/spreadsheet-editor-support.d.ts +1 -0
  25. package/dist/internal/features/work/editors/spreadsheet-format-cells-dialog-model.d.ts +86 -0
  26. package/dist/internal/features/work/editors/spreadsheet-format-cells-dialog-panels.d.ts +15 -0
  27. package/dist/internal/features/work/editors/spreadsheet-format-cells-dialog.d.ts +8 -0
  28. package/dist/internal/features/work/editors/spreadsheet-go-to.d.ts +24 -0
  29. package/dist/internal/features/work/editors/spreadsheet-hyperlink-command.d.ts +3 -0
  30. package/dist/internal/features/work/editors/spreadsheet-hyperlink-dialog.d.ts +9 -0
  31. package/dist/internal/features/work/editors/spreadsheet-hyperlink.d.ts +44 -0
  32. package/dist/internal/features/work/editors/spreadsheet-keyboard-navigation.d.ts +4 -0
  33. package/dist/internal/features/work/editors/spreadsheet-navigation-command.d.ts +3 -0
  34. package/dist/internal/features/work/editors/spreadsheet-number-format-command.d.ts +24 -0
  35. package/dist/internal/features/work/editors/spreadsheet-paste-special-cell.d.ts +17 -0
  36. package/dist/internal/features/work/editors/spreadsheet-paste-special-dialog.d.ts +9 -0
  37. package/dist/internal/features/work/editors/spreadsheet-paste-special-mode.d.ts +11 -0
  38. package/dist/internal/features/work/editors/spreadsheet-paste-special-plan.d.ts +4 -0
  39. package/dist/internal/features/work/editors/spreadsheet-paste-special-sheet.d.ts +23 -0
  40. package/dist/internal/features/work/editors/spreadsheet-paste-special-snapshot.d.ts +10 -0
  41. package/dist/internal/features/work/editors/spreadsheet-paste-special-types.d.ts +127 -0
  42. package/dist/internal/features/work/editors/spreadsheet-paste-special.d.ts +7 -0
  43. package/dist/internal/features/work/editors/use-spreadsheet-clipboard.d.ts +36 -0
  44. package/dist/internal/features/work/editors/use-spreadsheet-data-validation.d.ts +23 -0
  45. package/dist/internal/features/work/editors/use-spreadsheet-hyperlink.d.ts +24 -0
  46. package/dist/internal/features/work/work-spreadsheet-data-validation.d.ts +2 -0
  47. package/dist/office-kernel.wasm +0 -0
  48. package/dist/styles.css +845 -1
  49. package/docs/latest/en/browser-editor-architecture.md +12 -1
  50. package/package.json +15 -3
@@ -5,7 +5,7 @@ import { markDocxParagraphShading, inspectDocxPageSize, docxCaptionBookmark, has
5
5
  import { normalizeDocumentHref } from "./0~work-document-links.js";
6
6
  import { xmlAttributeLocalName, parseDocxParagraphDefaultCollapsed, readDocxBibliography, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace, createDocxThemeResolver } from "./0~2805.js";
7
7
  import { updateSpreadsheetWorksheetCompatibilitySummary, inspectXlsxPivotTables, isSupportedXlsxChartLegend, isSupportedXlsxChartPlotLayout, xlsxChartNodeUsesStackedGrouping, isSupportedXlsxChartSeriesFormatting, readXlsxFormulaFeaturesFromPackage, inspectXlsxHeaderFooterText, emptySpreadsheetWorksheetCompatibilitySummary, xlsxChartSeriesFormattingShapeProperties, MAX_XLSX_WORKSHEET_IMAGE_BYTES, isSupportedXlsxWorksheetImageContentType, xlsxWorksheetCellEntries, diagnoseXlsxProtection, isEditableXlsxPaperSizeCode, isSupportedXlsxCombinationChartNodes } from "./4104.js";
8
- import { spreadsheetConditionalComparisonNeedsUpperValue, isSpreadsheetConditionalIconSetName, isSpreadsheetConditionalComparisonOperator, spreadsheetConditionalIconSetCount } from "./4476.js";
8
+ import { spreadsheetConditionalComparisonNeedsUpperValue, isSpreadsheetConditionalIconSetName, isSpreadsheetConditionalComparisonOperator, spreadsheetConditionalIconSetCount } from "./2180.js";
9
9
  import { formulaHasStructuredReference, formulaHasExternalReference, parseSpreadsheetPrintTitles, volatileSpreadsheetFormulaFunctions, stripSpreadsheetSheetQualifier } from "./8715.js";
10
10
  import { unsupportedSpreadsheetFormulaFunctions } from "./0~work-spreadsheet-formula-support.js";
11
11
  var work_office_diagnostics_namespaceObject = {};
@@ -1723,6 +1723,39 @@ function stringRecord(value) {
1723
1723
  const entries = Object.entries(value).filter((entry)=>'string' == typeof entry[1]);
1724
1724
  return entries.length ? Object.fromEntries(entries) : void 0;
1725
1725
  }
1726
+ const MILLISECONDS_PER_DAY = 86400000;
1727
+ function normalizeSpreadsheetDateValidationBoundary(value, uses1904DateSystem = false) {
1728
+ const trimmed = value.trim().replace(/^=/, '');
1729
+ const iso = normalizeIsoDate(trimmed);
1730
+ if (iso) return iso;
1731
+ const formula = /^DATE\((\d{4}),\s*(\d{1,2}),\s*(\d{1,2})\)$/i.exec(trimmed);
1732
+ if (formula) return normalizeIsoDate(`${formula[1]}-${String(formula[2]).padStart(2, '0')}-${String(formula[3]).padStart(2, '0')}`);
1733
+ const serial = Number(trimmed);
1734
+ if (!Number.isInteger(serial) || serial < 0) return null;
1735
+ if (!uses1904DateSystem && (0 === serial || 60 === serial)) return null;
1736
+ const adjustedSerial = uses1904DateSystem ? serial : serial > 60 ? serial - 1 : serial;
1737
+ const epoch = uses1904DateSystem ? Date.UTC(1904, 0, 1) : Date.UTC(1899, 11, 31);
1738
+ return isoDateFromTimestamp(epoch + adjustedSerial * MILLISECONDS_PER_DAY);
1739
+ }
1740
+ function spreadsheetDateValidationFormula(value) {
1741
+ const normalized = normalizeIsoDate(value.trim());
1742
+ if (!normalized) return value.trim().replace(/^=/, '');
1743
+ const [year, month, day] = normalized.split('-');
1744
+ return `DATE(${year},${Number(month)},${Number(day)})`;
1745
+ }
1746
+ function normalizeIsoDate(value) {
1747
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
1748
+ if (!match) return null;
1749
+ const timestamp = Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3]));
1750
+ const normalized = isoDateFromTimestamp(timestamp);
1751
+ return normalized === value ? normalized : null;
1752
+ }
1753
+ function isoDateFromTimestamp(timestamp) {
1754
+ const date = new Date(timestamp);
1755
+ const year = date.getUTCFullYear();
1756
+ if (!Number.isFinite(timestamp) || year < 1900 || year > 9999) return null;
1757
+ return `${String(year).padStart(4, '0')}-${String(date.getUTCMonth() + 1).padStart(2, '0')}-${String(date.getUTCDate()).padStart(2, '0')}`;
1758
+ }
1726
1759
  const SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS = [
1727
1760
  'greaterThan',
1728
1761
  'greaterThanOrEqual',
@@ -2216,4 +2249,4 @@ function boundedInteger(value, minimum, maximum, fallback) {
2216
2249
  function boundedNumber(value, minimum, maximum, fallback) {
2217
2250
  return 'number' == typeof value && Number.isFinite(value) && value >= minimum && value <= maximum ? value : fallback;
2218
2251
  }
2219
- export { DEFAULT_PROTECTION_HINT, SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS, SPREADSHEET_CONDITIONAL_ICON_SETS, attachSpreadsheetShownCommentCells, createWorkOfficeSpreadsheetCollaborationBinding as createOfficeSpreadsheetCollaborationBinding, defaultSpreadsheetColorScaleThresholds, defaultSpreadsheetConditionalIconThresholds, defaultSpreadsheetDataBarOptions, drawSpreadsheetConditionalIcon, editableRangeCellCount, editableRangeRequiresCredentials, effectiveSpreadsheetPageSetup, freezeImportedSpreadsheetCell, importedSheetProtectionAuthority, initializeWorkOfficeSpreadsheetCollaboration as initializeOfficeSpreadsheetCollaboration, isSpreadsheetConditionalComparisonOperator, isSpreadsheetConditionalIconSetName, normalizeSheetProtectionAuthority, normalizeSpreadsheetConditionalIconSetFormat, normalizeSpreadsheetConditionalVisualOptions, normalizeSpreadsheetPaperSize, protectedSheetCount, readWorkOfficeSpreadsheetCollaboration as readOfficeSpreadsheetCollaboration, registerDerivedSpreadsheetMatrix, registerImportedSpreadsheetMatrix, replaceWorkOfficeSpreadsheetCollaboration as replaceOfficeSpreadsheetCollaboration, sameSpreadsheetHistoryValue, sheetHasProtectionState, sheetProtectionAuthority, spreadsheetConditionalComparisonNeedsUpperValue, spreadsheetConditionalIconForValue, spreadsheetConditionalIconSetCount, spreadsheetConditionalThresholdValue, spreadsheetConditionalThresholdsEqual, spreadsheetMatrixProfile, spreadsheetProtectionKey, unlockedCellCount, withEditableRange, withSheetProtection, withSheetSelectionPermissions, withoutEditableRange };
2252
+ export { DEFAULT_PROTECTION_HINT, SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS, SPREADSHEET_CONDITIONAL_ICON_SETS, attachSpreadsheetShownCommentCells, createWorkOfficeSpreadsheetCollaborationBinding as createOfficeSpreadsheetCollaborationBinding, defaultSpreadsheetColorScaleThresholds, defaultSpreadsheetConditionalIconThresholds, defaultSpreadsheetDataBarOptions, drawSpreadsheetConditionalIcon, editableRangeCellCount, editableRangeRequiresCredentials, effectiveSpreadsheetPageSetup, freezeImportedSpreadsheetCell, importedSheetProtectionAuthority, initializeWorkOfficeSpreadsheetCollaboration as initializeOfficeSpreadsheetCollaboration, isSpreadsheetConditionalComparisonOperator, isSpreadsheetConditionalIconSetName, normalizeSheetProtectionAuthority, normalizeSpreadsheetConditionalIconSetFormat, normalizeSpreadsheetConditionalVisualOptions, normalizeSpreadsheetDateValidationBoundary, normalizeSpreadsheetPaperSize, protectedSheetCount, readWorkOfficeSpreadsheetCollaboration as readOfficeSpreadsheetCollaboration, registerDerivedSpreadsheetMatrix, registerImportedSpreadsheetMatrix, replaceWorkOfficeSpreadsheetCollaboration as replaceOfficeSpreadsheetCollaboration, sameSpreadsheetHistoryValue, sheetHasProtectionState, sheetProtectionAuthority, spreadsheetConditionalComparisonNeedsUpperValue, spreadsheetConditionalIconForValue, spreadsheetConditionalIconSetCount, spreadsheetConditionalThresholdValue, spreadsheetConditionalThresholdsEqual, spreadsheetDateValidationFormula, spreadsheetMatrixProfile, spreadsheetProtectionKey, unlockedCellCount, withEditableRange, withSheetProtection, withSheetSelectionPermissions, withoutEditableRange };
package/dist/4104.js CHANGED
@@ -5,7 +5,7 @@ import { OFFICE_COLLABORATION_PROTOCOL as WORK_OFFICE_COLLABORATION_PROTOCOL, Of
5
5
  import { contentTypeForPart, directChildren, bytesToDataUrl, OoxmlPackage as work_ooxml_package_OoxmlPackage, parseXml, firstDescendant, xmlNamespacePrefix, descendants, directChild, createArtifact as createWorkArtifact, xmlContainsAnyElement, createOfficeId as createWorkId, attribute as work_ooxml_package_attribute } from "./5184.js";
6
6
  import { mountWorkLiveDocumentCapture, materializeWorkDocumentContent as work_document_model_codec_materializeWorkDocumentContent, documentPageSurfaceGeometryForElement, createWorkDocumentModel, documentContentLayoutProperties, documentModelForContent, createWorkDocumentExtensions, positionWorkLiveDocumentCapture } from "./6282.js";
7
7
  import { normalizeWorkSpreadsheetDataLabels, workSpreadsheetChartSupportsGrouping, normalizeSpreadsheetPrintArea, normalizeWorkSpreadsheetChartLegendPosition, formatSpreadsheetCellRanges, spreadsheetCellAddress, normalizeWorkSpreadsheetChartSmoothLines, spreadsheetFormulaRangeForCell, normalizeWorkSpreadsheetChartColor, readXlsxDrawingAnchor, sparseArrayEntries, qualifySpreadsheetRange, normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetChartSeriesStyle, normalizeSpreadsheetPrintTitleRows, normalizeSpreadsheetPrintTitleColumns, spreadsheetPivotFilterValueKey, normalizeWorkSpreadsheetErrorBars, normalizeWorkSpreadsheetBubbleSizeRepresents, workSpreadsheetChartSupportsTrendlines, stripSpreadsheetSheetQualifier, normalizeWorkSpreadsheetChartLegendOverlay, normalizeWorkSpreadsheetChartGapWidth, normalizeWorkSpreadsheetChartGrouping, workSpreadsheetChartSupportsBarSpacing, workSpreadsheetChartSupportsSmoothLines, workSpreadsheetChartGroupingIsStacked, xlsxDrawingAnchorToBounds, xlsxTwoCellAnchorMarkers, workSpreadsheetChartSupportsErrorBars, sparseMatrixColumnCount, refreshSpreadsheetPivotTables, normalizeWorkSpreadsheetChartAxisGroup, isValidSpreadsheetDefinedName, normalizeWorkSpreadsheetScatterStyle, workSpreadsheetChartAxisDefaultLabelPosition, spreadsheetPivotValidation, resolveSpreadsheetChart, parseSpreadsheetCellRanges, workSpreadsheetChartAxisIsCategoryAxis, spreadsheetPivotFields, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetChartAxes, parseSpreadsheetPrintTitles, spreadsheetFormulaRangeConflict, spreadsheetFormulaForXlsx, editableSpreadsheetFormula, workSpreadsheetChartUsesNumericXAxis, normalizeWorkSpreadsheetChartOverlap, workSpreadsheetChartSupportsAxes, workSpreadsheetChartAxisShowsMajorGridlinesByDefault, normalizeWorkSpreadsheetCombinationSeriesType, effectiveSpreadsheetCalculationSettings, normalizeWorkSpreadsheetTrendline, normalizeWorkSpreadsheetRadarStyle } from "./8715.js";
8
- import { freezeImportedSpreadsheetCell, editableRangeRequiresCredentials, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, normalizeSpreadsheetConditionalVisualOptions, normalizeSpreadsheetPaperSize, normalizeSheetProtectionAuthority, importedSheetProtectionAuthority, defaultSpreadsheetColorScaleThresholds, sheetHasProtectionState, spreadsheetConditionalComparisonNeedsUpperValue, isSpreadsheetConditionalComparisonOperator, registerImportedSpreadsheetMatrix, defaultSpreadsheetConditionalIconThresholds, DEFAULT_PROTECTION_HINT, isSpreadsheetConditionalIconSetName, spreadsheetConditionalThresholdsEqual, spreadsheetConditionalIconSetCount } from "./4476.js";
8
+ import { freezeImportedSpreadsheetCell, editableRangeRequiresCredentials, spreadsheetDateValidationFormula, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, normalizeSpreadsheetConditionalVisualOptions, normalizeSpreadsheetPaperSize, normalizeSheetProtectionAuthority, importedSheetProtectionAuthority, defaultSpreadsheetColorScaleThresholds, sheetHasProtectionState, spreadsheetConditionalComparisonNeedsUpperValue, isSpreadsheetConditionalComparisonOperator, registerImportedSpreadsheetMatrix, defaultSpreadsheetConditionalIconThresholds, DEFAULT_PROTECTION_HINT, normalizeSpreadsheetDateValidationBoundary, isSpreadsheetConditionalIconSetName, spreadsheetConditionalThresholdsEqual, spreadsheetConditionalIconSetCount } from "./2180.js";
9
9
  import { WorkFileImportController, materializeWorkFileSource } from "./9356.js";
10
10
  import "./2591.js";
11
11
  import "./3818.js";
@@ -5680,7 +5680,9 @@ function scanXlsxWorksheetXml(source) {
5680
5680
  };
5681
5681
  }
5682
5682
  async function readXlsxSheetFeaturesFromPackage(archive, worksheetScans) {
5683
- const worksheetParts = await work_xlsx_interop_readWorksheetParts(archive);
5683
+ const workbook = archive.has('xl/workbook.xml') ? await archive.xml('xl/workbook.xml') : null;
5684
+ const worksheetParts = await work_xlsx_interop_readWorksheetParts(archive, workbook);
5685
+ const uses1904DateSystem = xlsxUses1904DateSystem(workbook);
5684
5686
  const styles = archive.has('xl/styles.xml') ? await archive.xml('xl/styles.xml') : null;
5685
5687
  const theme = archive.has('xl/theme/theme1.xml') ? await archive.xml('xl/theme/theme1.xml') : null;
5686
5688
  const differentialFormats = readXlsxDifferentialFormats(styles);
@@ -5705,7 +5707,7 @@ async function readXlsxSheetFeaturesFromPackage(archive, worksheetScans) {
5705
5707
  features.set(sheetName, {
5706
5708
  directCellStyles: readXlsxDirectCellStyles(document1, styles, theme),
5707
5709
  frozen: parseFrozenPane(document1) ?? void 0,
5708
- validations: parseDataValidations(document1),
5710
+ validations: parseDataValidations(document1, uses1904DateSystem),
5709
5711
  conditionalFormats: readXlsxConditionalFormats(document1, differentialFormats),
5710
5712
  protection: readXlsxProtection(document1, styles),
5711
5713
  pageBreaks: readXlsxManualPageBreaks(document1),
@@ -5760,7 +5762,7 @@ async function patchXlsxSheetFeatures(buffer, content) {
5760
5762
  if (!partPath || !entry) continue;
5761
5763
  const document1 = parseXml(await entry.async('text'), partPath);
5762
5764
  if (sheet.frozen) writeFrozenPane(document1, sheet.frozen);
5763
- writeDataValidations(document1, sheet.dataVerification, sheet.dataValidationRanges);
5765
+ writeDataValidations(document1, sheet.dataVerification, sheet.dataValidationRanges, new Set((content.namedRanges ?? []).filter((namedRange)=>!namedRange.scopeSheetId || namedRange.scopeSheetId === sheet.id).map((namedRange)=>namedRange.name.trim().toLocaleLowerCase())));
5764
5766
  writeXlsxConditionalFormats(document1, sheet.luckysheet_conditionformat_save, differentialFormats);
5765
5767
  if (directCellStyles) writeXlsxDirectCellStyles(document1, sheet, directCellStyles);
5766
5768
  writeXlsxProtection(document1, sheet, cellProtection);
@@ -5774,9 +5776,9 @@ async function patchXlsxSheetFeatures(buffer, content) {
5774
5776
  compression: 'DEFLATE'
5775
5777
  });
5776
5778
  }
5777
- async function work_xlsx_interop_readWorksheetParts(archive) {
5779
+ async function work_xlsx_interop_readWorksheetParts(archive, workbookDocument) {
5778
5780
  if (!archive.has('xl/workbook.xml')) return new Map();
5779
- const workbook = await archive.xml('xl/workbook.xml');
5781
+ const workbook = workbookDocument ?? await archive.xml('xl/workbook.xml');
5780
5782
  const relationships = await archive.relationships('xl/workbook.xml');
5781
5783
  const parts = new Map();
5782
5784
  for (const sheet of firstDescendant(workbook, 'sheets')?.children ?? []){
@@ -5802,7 +5804,7 @@ function parseFrozenPane(document1) {
5802
5804
  }
5803
5805
  };
5804
5806
  }
5805
- function parseDataValidations(document1) {
5807
+ function parseDataValidations(document1, uses1904DateSystem) {
5806
5808
  const validations = firstDescendant(document1, 'dataValidations');
5807
5809
  if (!validations) return [];
5808
5810
  return directChildren(validations, 'dataValidation').flatMap((element)=>{
@@ -5813,10 +5815,10 @@ function parseDataValidations(document1) {
5813
5815
  const formula2 = firstDescendant(element, 'formula2')?.textContent?.trim() ?? '';
5814
5816
  const item = {
5815
5817
  type,
5816
- type2: fortuneValidationOperator(work_ooxml_package_attribute(element, 'operator')),
5818
+ type2: fortuneValidationOperator(work_ooxml_package_attribute(element, 'operator'), 'date' === type),
5817
5819
  rangeTxt: references.join(','),
5818
- value1: 'dropdown' === type ? parseListFormula(formula1) : formula1,
5819
- value2: formula2,
5820
+ value1: 'dropdown' === type ? parseListFormula(formula1) : 'date' === type ? normalizeSpreadsheetDateValidationBoundary(formula1, uses1904DateSystem) ?? formula1 : formula1,
5821
+ value2: 'date' === type ? normalizeSpreadsheetDateValidationBoundary(formula2, uses1904DateSystem) ?? formula2 : formula2,
5820
5822
  validity: '',
5821
5823
  remote: false,
5822
5824
  prohibitInput: work_xlsx_interop_booleanAttribute(element, 'showErrorMessage'),
@@ -5832,7 +5834,7 @@ function parseDataValidations(document1) {
5832
5834
  ];
5833
5835
  });
5834
5836
  }
5835
- function writeDataValidations(document1, source, compact) {
5837
+ function writeDataValidations(document1, source, compact, namedListSources) {
5836
5838
  const root = document1.documentElement;
5837
5839
  for (const existing of directChildren(root, 'dataValidations'))existing.remove();
5838
5840
  const grouped = groupDataValidations(source, compact);
@@ -5852,8 +5854,8 @@ function writeDataValidations(document1, source, compact) {
5852
5854
  element.setAttribute('showInputMessage', item.hintShow ? '1' : '0');
5853
5855
  if (item.hintValue) element.setAttribute('prompt', item.hintValue.slice(0, 255));
5854
5856
  element.setAttribute('sqref', references.join(' '));
5855
- work_xlsx_interop_appendFormula(document1, element, 'formula1', xlsxValidationFormula(item));
5856
- if (item.value2) work_xlsx_interop_appendFormula(document1, element, 'formula2', item.value2);
5857
+ work_xlsx_interop_appendFormula(document1, element, 'formula1', xlsxValidationFormula(item, item.value1, namedListSources));
5858
+ if (item.value2) work_xlsx_interop_appendFormula(document1, element, 'formula2', xlsxValidationFormula(item, item.value2, namedListSources));
5857
5859
  container.append(element);
5858
5860
  }
5859
5861
  if (!container.children.length) return;
@@ -5931,10 +5933,12 @@ function work_xlsx_interop_appendFormula(document1, parent, name, value) {
5931
5933
  formula.textContent = value.replace(/^=/, '');
5932
5934
  parent.append(formula);
5933
5935
  }
5934
- function xlsxValidationFormula(item) {
5935
- const value = item.value1.trim();
5936
+ function xlsxValidationFormula(item, source, namedListSources) {
5937
+ const value = source.trim();
5938
+ if ('date' === item.type) return spreadsheetDateValidationFormula(value);
5936
5939
  if ('dropdown' !== item.type) return value;
5937
- if (/^=?[^,]+![A-Z]+\d+(?::[A-Z]+\d+)?$/i.test(value) || /^=?\$?[A-Z]+\$?\d+(?::\$?[A-Z]+\$?\d+)?$/i.test(value)) return value.replace(/^=/, '');
5940
+ const formula = value.replace(/^=/, '');
5941
+ if (/^=?[^,]+![A-Z]+\d+(?::[A-Z]+\d+)?$/i.test(value) || /^=?\$?[A-Z]+\$?\d+(?::\$?[A-Z]+\$?\d+)?$/i.test(value) || namedListSources.has(formula.toLocaleLowerCase())) return formula;
5938
5942
  return `"${value.replaceAll('"', '""')}"`;
5939
5943
  }
5940
5944
  function parseListFormula(value) {
@@ -5945,7 +5949,7 @@ function fortuneValidationType(value) {
5945
5949
  const types = {
5946
5950
  list: 'dropdown',
5947
5951
  whole: 'number_integer',
5948
- decimal: 'number_decimal',
5952
+ decimal: 'number',
5949
5953
  textLength: 'text_length',
5950
5954
  date: 'date'
5951
5955
  };
@@ -5962,7 +5966,16 @@ function xlsxValidationType(value) {
5962
5966
  };
5963
5967
  return types[value] ?? null;
5964
5968
  }
5965
- function fortuneValidationOperator(value) {
5969
+ function fortuneValidationOperator(value, date) {
5970
+ if (date) {
5971
+ const dateOperators = {
5972
+ lessThan: 'earlierThan',
5973
+ lessThanOrEqual: 'noLaterThan',
5974
+ greaterThan: 'laterThan',
5975
+ greaterThanOrEqual: 'noEarlierThan'
5976
+ };
5977
+ if (value && dateOperators[value]) return dateOperators[value];
5978
+ }
5966
5979
  const operators = {
5967
5980
  between: 'between',
5968
5981
  notBetween: 'notBetween',
@@ -5984,10 +5997,19 @@ function xlsxValidationOperator(value) {
5984
5997
  moreThanThe: 'greaterThan',
5985
5998
  lessThan: 'lessThan',
5986
5999
  greaterOrEqualTo: 'greaterThanOrEqual',
5987
- lessThanOrEqualTo: 'lessThanOrEqual'
6000
+ lessThanOrEqualTo: 'lessThanOrEqual',
6001
+ earlierThan: 'lessThan',
6002
+ noEarlierThan: 'greaterThanOrEqual',
6003
+ laterThan: 'greaterThan',
6004
+ noLaterThan: 'lessThanOrEqual'
5988
6005
  };
5989
6006
  return operators[value] ?? null;
5990
6007
  }
6008
+ function xlsxUses1904DateSystem(workbook) {
6009
+ if (!workbook) return false;
6010
+ const workbookProperties = firstDescendant(workbook, 'workbookPr');
6011
+ return workbookProperties ? work_xlsx_interop_booleanAttribute(workbookProperties, 'date1904') : false;
6012
+ }
5991
6013
  function work_xlsx_interop_booleanAttribute(element, name) {
5992
6014
  const value = work_ooxml_package_attribute(element, name)?.toLowerCase();
5993
6015
  return '1' === value || 'true' === value;
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 };
@@ -1,9 +1,10 @@
1
- import type { ReactNode } from 'react';
2
- export declare function OfficeCheckbox({ ariaLabel, checked, onCheckedChange, children, disabled, className, }: {
1
+ import { type ReactNode } from 'react';
2
+ export declare function OfficeCheckbox({ ariaLabel, checked, onCheckedChange, children, disabled, className, indeterminate, }: {
3
3
  ariaLabel: string;
4
4
  checked: boolean;
5
5
  onCheckedChange: (checked: boolean) => void;
6
6
  children: ReactNode;
7
7
  disabled?: boolean;
8
8
  className?: string;
9
+ indeterminate?: boolean;
9
10
  }): import("react").JSX.Element;
@@ -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 createSpreadsheetAutoSumExtension(): OfficeEditorExtension<SpreadsheetCommandContext, SpreadsheetEditorCommands>;
@@ -0,0 +1,19 @@
1
+ import type { WorkSpreadsheetSheet } from '../work-types';
2
+ import { type SpreadsheetCellRange, type SpreadsheetCellRangeInput } from './spreadsheet-cell-range';
3
+ export declare const spreadsheetAutoSumMaximumTargets = 1000;
4
+ export type SpreadsheetAutoSumFunction = 'sum' | 'average' | 'count' | 'max' | 'min';
5
+ export interface SpreadsheetAutoSumWrite {
6
+ range: SpreadsheetCellRange;
7
+ values: string[][];
8
+ }
9
+ export interface SpreadsheetAutoSumPlan {
10
+ formulaBarValue: string;
11
+ function: SpreadsheetAutoSumFunction;
12
+ selection: SpreadsheetCellRange & {
13
+ row_focus: number;
14
+ column_focus: number;
15
+ };
16
+ targetCellCount: number;
17
+ writes: SpreadsheetAutoSumWrite[];
18
+ }
19
+ export declare function planSpreadsheetAutoSum(sheet: WorkSpreadsheetSheet | undefined, selection: SpreadsheetCellRangeInput, functionName: SpreadsheetAutoSumFunction): SpreadsheetAutoSumPlan | 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 createSpreadsheetCellFormatExtension(): OfficeEditorExtension<SpreadsheetCommandContext, SpreadsheetEditorCommands>;
@@ -0,0 +1,36 @@
1
+ import type { Cell } from '@fortune-sheet/core';
2
+ import type { WorkSpreadsheetContent, WorkSpreadsheetSheet } from '../work-types';
3
+ import { type SpreadsheetCellBorderFormat } from './spreadsheet-cell-border';
4
+ import { type SpreadsheetCellRange } from './spreadsheet-cell-range';
5
+ export declare const MAX_SPREADSHEET_CELL_FORMAT_CELLS = 10000;
6
+ export type SpreadsheetHorizontalAlignment = 'general' | 'left' | 'center' | 'right';
7
+ export type SpreadsheetVerticalAlignment = 'top' | 'middle' | 'bottom';
8
+ export interface SpreadsheetCellFormatPatch {
9
+ numberFormat?: string;
10
+ horizontalAlignment?: SpreadsheetHorizontalAlignment;
11
+ verticalAlignment?: SpreadsheetVerticalAlignment;
12
+ wrapText?: boolean;
13
+ rotation?: number;
14
+ fontFamily?: string;
15
+ fontSize?: number;
16
+ fontColor?: string;
17
+ bold?: boolean;
18
+ italic?: boolean;
19
+ underline?: boolean;
20
+ strike?: boolean;
21
+ fillColor?: string | null;
22
+ borders?: readonly SpreadsheetCellBorderFormat[];
23
+ locked?: boolean;
24
+ hidden?: boolean;
25
+ }
26
+ export interface SpreadsheetCellFormatRequest {
27
+ sheetId: string;
28
+ range: SpreadsheetCellRange;
29
+ patch: SpreadsheetCellFormatPatch;
30
+ }
31
+ export declare function canApplySpreadsheetCellFormat(content: WorkSpreadsheetContent, request: SpreadsheetCellFormatRequest): boolean;
32
+ export declare function applySpreadsheetCellFormat(content: WorkSpreadsheetContent, request: SpreadsheetCellFormatRequest): WorkSpreadsheetContent | null;
33
+ export declare function spreadsheetCellProtectionAt(sheet: WorkSpreadsheetSheet, row: number, column: number, cell?: Cell | null | undefined): {
34
+ locked: boolean;
35
+ hidden: boolean;
36
+ };
@@ -0,0 +1,4 @@
1
+ import type { WorkSpreadsheetSheet } from '../work-types';
2
+ import { type SpreadsheetCellRange } from './spreadsheet-cell-range';
3
+ export declare function canMutateSpreadsheetCellRange(sheet: WorkSpreadsheetSheet | undefined, range: SpreadsheetCellRange): boolean;
4
+ export declare function canMutateSpreadsheetCellRanges(sheet: WorkSpreadsheetSheet | undefined, ranges: readonly SpreadsheetCellRange[]): boolean;
@@ -3,3 +3,4 @@ export interface SpreadsheetClipboardShortcutOptions {
3
3
  execute(): boolean;
4
4
  }
5
5
  export declare function runSpreadsheetClipboardShortcut(event: KeyboardEvent, canExecute: SpreadsheetClipboardShortcutOptions['canExecute'], execute: SpreadsheetClipboardShortcutOptions['execute']): boolean;
6
+ export declare function runSpreadsheetPasteSpecialShortcut(event: KeyboardEvent, canExecute: SpreadsheetClipboardShortcutOptions['canExecute'], execute: SpreadsheetClipboardShortcutOptions['execute']): boolean;
@@ -0,0 +1,13 @@
1
+ import { type SpreadsheetClipboardSnapshot } from './spreadsheet-paste-special';
2
+ export interface SpreadsheetClipboardPort {
3
+ readText(): Promise<string>;
4
+ writeText(value: string): Promise<void>;
5
+ }
6
+ export declare function parseSpreadsheetClipboardText(value: string): string[][];
7
+ export declare const browserSpreadsheetClipboard: SpreadsheetClipboardPort;
8
+ export declare function storeRichSpreadsheetClipboard(snapshot: SpreadsheetClipboardSnapshot): void;
9
+ export declare function spreadsheetClipboardSnapshotForText(plainText: string): SpreadsheetClipboardSnapshot | null;
10
+ export declare function clearRichSpreadsheetClipboard(): void;
11
+ export declare function readSpreadsheetClipboardText(readSystem: (() => Promise<string>) | undefined, readLocal: () => string, timeoutMs?: number, canReadSystem?: () => boolean | Promise<boolean>): Promise<string>;
12
+ export declare function writeSpreadsheetClipboardText(value: string, writeSystem: ((value: string) => Promise<void>) | undefined, writeLocal: (value: string) => void, timeoutMs?: number, onSystemWriteResult?: (succeeded: boolean) => void): Promise<void>;
13
+ export declare function copySpreadsheetSelection(clipboard: SpreadsheetClipboardPort, value: string, cut: boolean): Promise<boolean>;
@@ -80,6 +80,20 @@ export declare const spreadsheetCommandCatalog: {
80
80
  readonly editor: readonly ["Mod-v"];
81
81
  };
82
82
  };
83
+ readonly pasteSpecial: {
84
+ readonly id: "clipboard.pasteSpecial";
85
+ readonly label: "选择性粘贴";
86
+ readonly location: {
87
+ readonly area: "ribbon";
88
+ readonly tab: "home";
89
+ readonly group: "clipboard";
90
+ };
91
+ readonly shortcut: {
92
+ readonly label: "Cmd/Ctrl+Alt+V";
93
+ readonly aria: "Control+Alt+V Meta+Alt+V";
94
+ readonly editor: readonly ["Mod-Alt-v"];
95
+ };
96
+ };
83
97
  readonly cut: {
84
98
  readonly id: "clipboard.cut";
85
99
  readonly label: "剪切";
@@ -298,6 +312,38 @@ export declare const spreadsheetCommandCatalog: {
298
312
  readonly group: "number";
299
313
  };
300
314
  };
315
+ readonly decreaseDecimalPlaces: {
316
+ readonly id: "number.decreaseDecimalPlaces";
317
+ readonly label: "减少小数位";
318
+ readonly location: {
319
+ readonly area: "ribbon";
320
+ readonly tab: "home";
321
+ readonly group: "number";
322
+ };
323
+ };
324
+ readonly increaseDecimalPlaces: {
325
+ readonly id: "number.increaseDecimalPlaces";
326
+ readonly label: "增加小数位";
327
+ readonly location: {
328
+ readonly area: "ribbon";
329
+ readonly tab: "home";
330
+ readonly group: "number";
331
+ };
332
+ };
333
+ readonly formatCells: {
334
+ readonly id: "number.formatCells";
335
+ readonly label: "设置单元格格式";
336
+ readonly location: {
337
+ readonly area: "ribbon";
338
+ readonly tab: "home";
339
+ readonly group: "number";
340
+ };
341
+ readonly shortcut: {
342
+ readonly label: "Cmd/Ctrl+1";
343
+ readonly aria: "Control+1 Meta+1";
344
+ readonly editor: readonly ["Mod-1"];
345
+ };
346
+ };
301
347
  readonly borderTop: {
302
348
  readonly id: "font.borderTop";
303
349
  readonly label: "上框线";
@@ -519,6 +565,56 @@ export declare const spreadsheetCommandCatalog: {
519
565
  readonly group: "cells";
520
566
  };
521
567
  };
568
+ readonly autoSum: {
569
+ readonly id: "editing.autoSum";
570
+ readonly label: "自动求和";
571
+ readonly location: {
572
+ readonly area: "ribbon";
573
+ readonly tab: "home";
574
+ readonly group: "editing";
575
+ };
576
+ readonly shortcut: {
577
+ readonly label: "Alt+=";
578
+ readonly aria: "Alt+=";
579
+ readonly editor: readonly ["Alt-equal"];
580
+ };
581
+ };
582
+ readonly autoAverage: {
583
+ readonly id: "editing.autoAverage";
584
+ readonly label: "平均值";
585
+ readonly location: {
586
+ readonly area: "ribbon";
587
+ readonly tab: "home";
588
+ readonly group: "editing";
589
+ };
590
+ };
591
+ readonly autoCount: {
592
+ readonly id: "editing.autoCount";
593
+ readonly label: "计数";
594
+ readonly location: {
595
+ readonly area: "ribbon";
596
+ readonly tab: "home";
597
+ readonly group: "editing";
598
+ };
599
+ };
600
+ readonly autoMaximum: {
601
+ readonly id: "editing.autoMaximum";
602
+ readonly label: "最大值";
603
+ readonly location: {
604
+ readonly area: "ribbon";
605
+ readonly tab: "home";
606
+ readonly group: "editing";
607
+ };
608
+ };
609
+ readonly autoMinimum: {
610
+ readonly id: "editing.autoMinimum";
611
+ readonly label: "最小值";
612
+ readonly location: {
613
+ readonly area: "ribbon";
614
+ readonly tab: "home";
615
+ readonly group: "editing";
616
+ };
617
+ };
522
618
  readonly fillDown: {
523
619
  readonly id: "editing.fillDown";
524
620
  readonly label: "向下填充";
@@ -629,6 +725,29 @@ export declare const spreadsheetCommandCatalog: {
629
725
  readonly editor: readonly ["Mod-f"];
630
726
  };
631
727
  };
728
+ readonly findAndSelect: {
729
+ readonly id: "editing.findAndSelect";
730
+ readonly label: "查找和选择";
731
+ readonly location: {
732
+ readonly area: "ribbon";
733
+ readonly tab: "home";
734
+ readonly group: "editing";
735
+ };
736
+ };
737
+ readonly goTo: {
738
+ readonly id: "editing.goTo";
739
+ readonly label: "定位";
740
+ readonly location: {
741
+ readonly area: "ribbon";
742
+ readonly tab: "home";
743
+ readonly group: "editing";
744
+ };
745
+ readonly shortcut: {
746
+ readonly label: "Ctrl+G 或 F5";
747
+ readonly aria: "Control+G F5";
748
+ readonly editor: readonly ["Control-g", "F5"];
749
+ };
750
+ };
632
751
  readonly insertChart: {
633
752
  readonly id: "insert.chart";
634
753
  readonly label: "插入图表";
@@ -638,6 +757,20 @@ export declare const spreadsheetCommandCatalog: {
638
757
  readonly group: "charts";
639
758
  };
640
759
  };
760
+ readonly hyperlink: {
761
+ readonly id: "insert.hyperlink";
762
+ readonly label: "超链接";
763
+ readonly location: {
764
+ readonly area: "ribbon";
765
+ readonly tab: "insert";
766
+ readonly group: "links";
767
+ };
768
+ readonly shortcut: {
769
+ readonly label: "Cmd/Ctrl+K";
770
+ readonly aria: "Control+K Meta+K";
771
+ readonly editor: readonly ["Mod-k"];
772
+ };
773
+ };
641
774
  readonly printSettings: {
642
775
  readonly id: "pageLayout.printSettings";
643
776
  readonly label: "打印设置";
@@ -716,6 +849,15 @@ export declare const spreadsheetCommandCatalog: {
716
849
  readonly editor: readonly ["Alt-ArrowDown"];
717
850
  };
718
851
  };
852
+ readonly dataValidation: {
853
+ readonly id: "data.validation";
854
+ readonly label: "数据验证";
855
+ readonly location: {
856
+ readonly area: "ribbon";
857
+ readonly tab: "data";
858
+ readonly group: "dataTools";
859
+ };
860
+ };
719
861
  readonly pivotTable: {
720
862
  readonly id: "data.pivotTable";
721
863
  readonly label: "数据透视表";