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-ui): style error when save text from cell-editor (#4541)

zhangwa16d79aaf04b
diff --git a/packages/docs-ui/src/basics/paragraph.ts b/packages/docs-ui/src/basics/paragraph.ts
index 9ce46f599d..dac5783c0e 100644
--- a/packages/docs-ui/src/basics/paragraph.ts
+++ b/packages/docs-ui/src/basics/paragraph.ts
@@ -24,12 +24,13 @@ export function getTextRunAtPosition(
textRuns: ITextRun[],
position: number,
defaultStyle: ITextStyle,
- cacheStyle: Nullable<ITextStyle>
+ cacheStyle: Nullable<ITextStyle>,
+ isCellEditor?: boolean
): ITextRun {
const retTextRun: ITextRun = {
st: 0,
ed: 0,
- ts: defaultStyle,
+ ts: isCellEditor ? {} : defaultStyle,
};
for (let i = textRuns.length - 1; i >= 0; i--) {
diff --git a/packages/docs-ui/src/controllers/render-controllers/doc-input.controller.ts b/packages/docs-ui/src/controllers/render-controllers/doc-input.controller.ts
index fcd1c0ec65..e818e0231d 100644
--- a/packages/docs-ui/src/controllers/render-controllers/doc-input.controller.ts
+++ b/packages/docs-ui/src/controllers/render-controllers/doc-input.controller.ts
@@ -77,7 +77,7 @@ export class DocInputController extends Disposable implements IRenderModule {
const defaultTextStyle = this._docMenuStyleService.getDefaultStyle();
const cacheStyle = this._docMenuStyleService.getStyleCache();
const curCustomRange = getCustomRangeAtPosition(originBody?.customRanges ?? [], activeRange.endOffset, SHEET_EDITOR_UNITS.includes(unitId));
- const curTextRun = getTextRunAtPosition(originBody?.textRuns ?? [], activeRange.endOffset, defaultTextStyle, cacheStyle);
+ const curTextRun = getTextRunAtPosition(originBody?.textRuns ?? [], activeRange.endOffset, defaultTextStyle, cacheStyle, SHEET_EDITOR_UNITS.includes(unitId));
const curCustomDecorations = getCustomDecorationAtPosition(originBody?.customDecorations ?? [], activeRange.endOffset);
await this._commandService.executeCommand(InsertCommand.id, {