@a3s-lab/office 0.14.0 → 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.
- package/README.md +13 -1
- package/dist/0~spreadsheet-editor.js +3676 -1902
- package/dist/0~work-office-diagnostics.js +1 -1
- package/dist/{4476.js → 2180.js} +34 -1
- package/dist/4104.js +41 -19
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/features/work/editors/spreadsheet-command-catalog.d.ts +23 -0
- package/dist/internal/features/work/editors/spreadsheet-command-controller.d.ts +18 -0
- package/dist/internal/features/work/editors/spreadsheet-data-validation-command.d.ts +3 -0
- package/dist/internal/features/work/editors/spreadsheet-data-validation-dialog.d.ts +9 -0
- package/dist/internal/features/work/editors/spreadsheet-data-validation.d.ts +50 -0
- package/dist/internal/features/work/editors/spreadsheet-editor-support.d.ts +1 -0
- package/dist/internal/features/work/editors/spreadsheet-hyperlink-command.d.ts +3 -0
- package/dist/internal/features/work/editors/spreadsheet-hyperlink-dialog.d.ts +9 -0
- package/dist/internal/features/work/editors/spreadsheet-hyperlink.d.ts +44 -0
- package/dist/internal/features/work/editors/use-spreadsheet-data-validation.d.ts +23 -0
- package/dist/internal/features/work/editors/use-spreadsheet-hyperlink.d.ts +24 -0
- package/dist/internal/features/work/work-spreadsheet-data-validation.d.ts +2 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/styles.css +297 -0
- package/package.json +9 -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 "./
|
|
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 = {};
|
package/dist/{4476.js → 2180.js}
RENAMED
|
@@ -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 "./
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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: '
|
|
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 "./
|
|
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 "./
|
|
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 };
|
|
@@ -757,6 +757,20 @@ export declare const spreadsheetCommandCatalog: {
|
|
|
757
757
|
readonly group: "charts";
|
|
758
758
|
};
|
|
759
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
|
+
};
|
|
760
774
|
readonly printSettings: {
|
|
761
775
|
readonly id: "pageLayout.printSettings";
|
|
762
776
|
readonly label: "打印设置";
|
|
@@ -835,6 +849,15 @@ export declare const spreadsheetCommandCatalog: {
|
|
|
835
849
|
readonly editor: readonly ["Alt-ArrowDown"];
|
|
836
850
|
};
|
|
837
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
|
+
};
|
|
838
861
|
readonly pivotTable: {
|
|
839
862
|
readonly id: "data.pivotTable";
|
|
840
863
|
readonly label: "数据透视表";
|
|
@@ -9,8 +9,10 @@ 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';
|
|
@@ -117,6 +119,14 @@ export interface SpreadsheetFormatCellsCommandPort {
|
|
|
117
119
|
canOpen: boolean;
|
|
118
120
|
open: (request: SpreadsheetFormatCellsOpenRequest) => boolean;
|
|
119
121
|
}
|
|
122
|
+
export interface SpreadsheetDataValidationCommandPort {
|
|
123
|
+
canOpen: boolean;
|
|
124
|
+
open: (request: SpreadsheetDataValidationTarget) => boolean;
|
|
125
|
+
}
|
|
126
|
+
export interface SpreadsheetHyperlinkCommandPort {
|
|
127
|
+
canOpen: boolean;
|
|
128
|
+
open: (request: SpreadsheetHyperlinkCell) => boolean;
|
|
129
|
+
}
|
|
120
130
|
export interface SpreadsheetNavigationCommandPort {
|
|
121
131
|
canOpenFind: boolean;
|
|
122
132
|
canOpenGoTo: boolean;
|
|
@@ -136,8 +146,10 @@ export interface SpreadsheetEditorCommands {
|
|
|
136
146
|
adjustDecimalPlaces: (direction: SpreadsheetDecimalPlacesDirection) => boolean;
|
|
137
147
|
applyCellStyle: (preset: SpreadsheetCellStyleChoice) => boolean;
|
|
138
148
|
applyCellFormat: (request: SpreadsheetCellFormatRequest) => boolean;
|
|
149
|
+
applyDataValidation: (request: SpreadsheetDataValidationRequest) => boolean;
|
|
139
150
|
applyAutoSum: (functionName: SpreadsheetAutoSumFunction) => boolean;
|
|
140
151
|
applyFormatPainter: (target: SpreadsheetCommandSelection) => boolean;
|
|
152
|
+
applyHyperlink: (request: SpreadsheetHyperlinkRequest) => boolean;
|
|
141
153
|
cancelFormatPainter: () => boolean;
|
|
142
154
|
clearSelectedCells: (mode?: SpreadsheetCellClearMode) => boolean;
|
|
143
155
|
copySelection: () => boolean;
|
|
@@ -152,14 +164,18 @@ export interface SpreadsheetEditorCommands {
|
|
|
152
164
|
moveSheet: (sheetId: string, direction: SpreadsheetSheetMoveDirection) => boolean;
|
|
153
165
|
moveSelection: (move: SpreadsheetSelectionMove, extend: boolean) => boolean;
|
|
154
166
|
openAutoFilterMenu: () => boolean;
|
|
167
|
+
openDataValidation: () => boolean;
|
|
155
168
|
openFind: () => boolean;
|
|
156
169
|
openFormatCells: () => boolean;
|
|
157
170
|
openGoTo: () => boolean;
|
|
171
|
+
openHyperlink: () => boolean;
|
|
158
172
|
openPasteSpecial: () => boolean;
|
|
159
173
|
pasteCells: (values: readonly (readonly unknown[])[]) => boolean;
|
|
160
174
|
pasteSelection: () => boolean;
|
|
161
175
|
pasteSpecial: (content: SpreadsheetPasteContent) => boolean;
|
|
162
176
|
recalculateFormula: (scope: 'selection' | 'workbook') => boolean;
|
|
177
|
+
removeHyperlink: (target: SpreadsheetHyperlinkCell) => boolean;
|
|
178
|
+
removeDataValidation: (target: SpreadsheetDataValidationTarget) => boolean;
|
|
163
179
|
renameSheet: (sheetId: string, name: string) => boolean;
|
|
164
180
|
redo: () => boolean;
|
|
165
181
|
setCellFormat: (attribute: keyof Cell, value: unknown) => boolean;
|
|
@@ -183,11 +199,13 @@ export interface SpreadsheetCommandContext {
|
|
|
183
199
|
calculation: SpreadsheetCalculationCommandPort | null;
|
|
184
200
|
clipboard: SpreadsheetClipboardCommandPort;
|
|
185
201
|
content: WorkSpreadsheetContent;
|
|
202
|
+
dataValidation: SpreadsheetDataValidationCommandPort;
|
|
186
203
|
editable: boolean;
|
|
187
204
|
fallbackRange: SpreadsheetCommandRange;
|
|
188
205
|
formulaBar: SpreadsheetFormulaBarCommandPort | null;
|
|
189
206
|
formatPainter: SpreadsheetFormatPainterCommandPort;
|
|
190
207
|
formatCells: SpreadsheetFormatCellsCommandPort;
|
|
208
|
+
hyperlink: SpreadsheetHyperlinkCommandPort;
|
|
191
209
|
history: SpreadsheetHistoryCommandPort | null;
|
|
192
210
|
navigation: SpreadsheetNavigationCommandPort;
|
|
193
211
|
onChange: (content: WorkSpreadsheetContent) => void;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { WorkSpreadsheetContent } from '../work-types';
|
|
2
|
+
export type SpreadsheetHyperlinkType = 'webpage' | 'cellrange' | 'sheet';
|
|
3
|
+
export interface SpreadsheetHyperlinkTarget {
|
|
4
|
+
linkType: SpreadsheetHyperlinkType;
|
|
5
|
+
linkAddress: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SpreadsheetHyperlinkCell {
|
|
8
|
+
sheetId: string;
|
|
9
|
+
row: number;
|
|
10
|
+
column: number;
|
|
11
|
+
}
|
|
12
|
+
export interface SpreadsheetHyperlinkRequest extends SpreadsheetHyperlinkCell {
|
|
13
|
+
linkType: SpreadsheetHyperlinkType;
|
|
14
|
+
linkAddress: string;
|
|
15
|
+
displayText?: string;
|
|
16
|
+
}
|
|
17
|
+
export type SpreadsheetHyperlinkDialogValue = Pick<SpreadsheetHyperlinkRequest, 'linkType' | 'linkAddress' | 'displayText'>;
|
|
18
|
+
export type SpreadsheetHyperlinkErrorCode = 'empty-address' | 'formula-display-text' | 'invalid-cell-range' | 'invalid-display-text' | 'invalid-web-address' | 'pivot-cell' | 'protected-cell' | 'source-out-of-bounds' | 'source-sheet-not-found' | 'target-out-of-bounds' | 'target-sheet-hidden' | 'target-sheet-not-found' | 'unsupported-link-type';
|
|
19
|
+
export type SpreadsheetHyperlinkValidation = {
|
|
20
|
+
ok: true;
|
|
21
|
+
target: SpreadsheetHyperlinkTarget;
|
|
22
|
+
displayText?: string;
|
|
23
|
+
} | {
|
|
24
|
+
ok: false;
|
|
25
|
+
code: SpreadsheetHyperlinkErrorCode;
|
|
26
|
+
message: string;
|
|
27
|
+
};
|
|
28
|
+
export interface SpreadsheetHyperlinkDialogSource extends SpreadsheetHyperlinkCell {
|
|
29
|
+
sheetName: string;
|
|
30
|
+
cellReference: string;
|
|
31
|
+
displayText: string;
|
|
32
|
+
displayTextEditable: boolean;
|
|
33
|
+
hasHyperlink: boolean;
|
|
34
|
+
link: SpreadsheetHyperlinkTarget | null;
|
|
35
|
+
sheetOptions: Array<{
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
export declare function validateSpreadsheetHyperlinkRequest(content: WorkSpreadsheetContent, request: SpreadsheetHyperlinkRequest): SpreadsheetHyperlinkValidation;
|
|
41
|
+
export declare function applySpreadsheetHyperlink(content: WorkSpreadsheetContent, request: SpreadsheetHyperlinkRequest): WorkSpreadsheetContent | null;
|
|
42
|
+
export declare function removeSpreadsheetHyperlink(content: WorkSpreadsheetContent, target: SpreadsheetHyperlinkCell): WorkSpreadsheetContent | null;
|
|
43
|
+
export declare function canRemoveSpreadsheetHyperlink(content: WorkSpreadsheetContent, target: SpreadsheetHyperlinkCell): boolean;
|
|
44
|
+
export declare function createSpreadsheetHyperlinkDialogSource(content: WorkSpreadsheetContent, target: SpreadsheetHyperlinkCell): SpreadsheetHyperlinkDialogSource | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Selection } from '@fortune-sheet/core';
|
|
2
|
+
import type { WorkSpreadsheetContent } from '../work-types';
|
|
3
|
+
import type { SpreadsheetDataValidationCommandPort, SpreadsheetEditorCommands } from './spreadsheet-command-controller';
|
|
4
|
+
export interface SpreadsheetDataValidationSelectionState {
|
|
5
|
+
selections: Selection[];
|
|
6
|
+
sheetId: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function useSpreadsheetDataValidation({ commandsRef, contentRef, focusGrid, getGridFocusTarget, getLiveSelections, preview, }: {
|
|
9
|
+
commandsRef: {
|
|
10
|
+
current: SpreadsheetEditorCommands | null;
|
|
11
|
+
};
|
|
12
|
+
contentRef: {
|
|
13
|
+
current: WorkSpreadsheetContent;
|
|
14
|
+
};
|
|
15
|
+
focusGrid: (focusOrigin: Element | null) => void;
|
|
16
|
+
getGridFocusTarget: () => HTMLElement | null;
|
|
17
|
+
getLiveSelections: () => Selection[] | undefined;
|
|
18
|
+
preview: boolean;
|
|
19
|
+
}): {
|
|
20
|
+
commandPort: SpreadsheetDataValidationCommandPort;
|
|
21
|
+
selectionForChange: () => SpreadsheetDataValidationSelectionState | null;
|
|
22
|
+
dialog: import("react").JSX.Element | null;
|
|
23
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Selection } from '@fortune-sheet/core';
|
|
2
|
+
import type { WorkSpreadsheetContent } from '../work-types';
|
|
3
|
+
import type { SpreadsheetEditorCommands, SpreadsheetHyperlinkCommandPort } from './spreadsheet-command-controller';
|
|
4
|
+
export interface SpreadsheetHyperlinkSelectionState {
|
|
5
|
+
sheetId: string;
|
|
6
|
+
selection: Selection;
|
|
7
|
+
}
|
|
8
|
+
export declare function useSpreadsheetHyperlink({ commandsRef, contentRef, focusGrid, getGridFocusTarget, getLiveSelection, preview, selectionState, }: {
|
|
9
|
+
commandsRef: {
|
|
10
|
+
current: SpreadsheetEditorCommands | null;
|
|
11
|
+
};
|
|
12
|
+
contentRef: {
|
|
13
|
+
current: WorkSpreadsheetContent;
|
|
14
|
+
};
|
|
15
|
+
focusGrid: (focusOrigin: Element | null) => void;
|
|
16
|
+
getGridFocusTarget: () => HTMLElement | null;
|
|
17
|
+
getLiveSelection: () => Selection | undefined;
|
|
18
|
+
preview: boolean;
|
|
19
|
+
selectionState: SpreadsheetHyperlinkSelectionState | null;
|
|
20
|
+
}): {
|
|
21
|
+
commandPort: SpreadsheetHyperlinkCommandPort;
|
|
22
|
+
selectionForChange: () => SpreadsheetHyperlinkSelectionState | null;
|
|
23
|
+
dialog: import("react").JSX.Element | null;
|
|
24
|
+
};
|
package/dist/office-kernel.wasm
CHANGED
|
Binary file
|