Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(sheets): no style in blank cell (#3231)

Ran Luoe9360c4eddb8
diff --git a/packages/engine-render/src/components/sheets/sheet-skeleton.ts b/packages/engine-render/src/components/sheets/sheet-skeleton.ts
index 0c5acdb319..6c2f659c82 100644
--- a/packages/engine-render/src/components/sheets/sheet-skeleton.ts
+++ b/packages/engine-render/src/components/sheets/sheet-skeleton.ts
@@ -1043,9 +1043,12 @@ export class SpreadsheetSkeleton extends Skeleton {
ignoreTextRotation: true,
});
+ const style = this._styles.getStyleByCell(cell);
+ const textStyle = this._getFontFormat(style);
+
if (documentModelObject != null) {
if (documentModelObject.documentModel == null) {
- documentModelObject.documentModel = this._getDocumentDataByStyle('', {}, {});
+ documentModelObject.documentModel = this._getDocumentDataByStyle('', textStyle, {});
}
return documentModelObject;
}
@@ -1062,7 +1065,7 @@ export class SpreadsheetSkeleton extends Skeleton {
fontString = getFontStyleString({}, this._localService).fontCache;
- const documentModel = this._getDocumentDataByStyle(content, {}, {});
+ const documentModel = this._getDocumentDataByStyle(content, textStyle, {});
return {
documentModel,
diff --git a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
index c9d73edade..8fba932987 100644
--- a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
+++ b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
@@ -64,7 +64,7 @@ import {
} from '@univerjs/engine-render';
import { IEditorService, ILayoutService, KeyCode, SetEditorResizeOperation } from '@univerjs/ui';
import type { WorkbookSelections } from '@univerjs/sheets';
-import { ClearSelectionFormatCommand, SetRangeValuesCommand, SetSelectionsOperation, SetWorksheetActivateCommand, SheetsSelectionsService } from '@univerjs/sheets';
+import { ClearSelectionFormatCommand, SetRangeValuesCommand, SetRangeValuesMutation, SetSelectionsOperation, SetWorksheetActivateCommand, SheetsSelectionsService } from '@univerjs/sheets';
import { distinctUntilChanged, filter } from 'rxjs';
import { IFunctionService, LexerTreeBuilder, matchToken } from '@univerjs/engine-formula';
@@ -768,6 +768,12 @@ export class EditingRenderController extends Disposable implements IRenderModule
}
}));
+ d.add(this._commandService.onCommandExecuted((command: ICommandInfo) => {
+ if (command.id === SetRangeValuesMutation.id) {
+ this._editorBridgeService.refreshEditCellState();
+ }
+ }));
+
const closeEditorOperation = [SetCellEditVisibleArrowOperation.id];
d.add(this._commandService.onCommandExecuted((command: ICommandInfo) => {
if (closeEditorOperation.includes(command.id)) {