fix(sheets): allow Save As without edits (#60)

This commit is contained in:
jabberwocky238
2026-08-09 08:52:33 +08:00
committed by GitHub
parent d2e03aad1c
commit 300ad8fbfc
3 changed files with 3 additions and 25 deletions
-23
View File
@@ -584,29 +584,6 @@ export async function planCellEditsToXlsx(
sparklineAdditions: readonly SheetSparklineAddition[] = [],
formulaValues: readonly SheetFormulaValues[] = [],
): Promise<MutationPlan> {
if (
edits.length === 0 &&
structuralOps.length === 0 &&
chartEdits.length === 0 &&
sheetPlan === undefined &&
filterStates.length === 0 &&
hyperlinkEdits.length === 0 &&
cfStates.length === 0 &&
dvStates.length === 0 &&
sheetProtections.length === 0 &&
definedNamesState === null &&
visualAdditions.length === 0 &&
pageSetupStates.length === 0 &&
noteStates.length === 0 &&
tableAdditions.length === 0 &&
pivotAdditions.length === 0 &&
pivotCacheRefreshPaths.length === 0 &&
pivotRefreshUpdates.length === 0 &&
visualEdits.length === 0 &&
sparklineAdditions.length === 0
) {
throw new Error('There are no edits to save.')
}
// A pending pivot pins final coordinates for its source and output; shifts
// on either sheet, and sheet renames (worksheetSource@sheet), would desync
// the recorded ranges. Fail closed, mirroring the table-add guard.
+2 -1
View File
@@ -1078,7 +1078,8 @@ function parseSaveRequest(input: WorkbookSaveRequest): WorkbookSaveRequest {
typeof state.protected !== 'boolean',
) ||
!isDefinedNamesState(input.definedNamesState) ||
(input.edits.length === 0 &&
(input.mode !== 'save-as' &&
input.edits.length === 0 &&
input.structuralOps.length === 0 &&
input.chartEdits.length === 0 &&
input.visualEdits.length === 0 &&
+1 -1
View File
@@ -148,7 +148,7 @@ export async function handleSave(
visualEdits.length +
tableAdditions.length +
pivotAdditions.length
if (total === 0) {
if (total === 0 && mode !== 'save-as') {
if (mode !== 'recovery') ctx.setMessage(t('appNoEditsToSave'))
return
}