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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(conditional-formatting): the style that involves conditional formatting does not fall (#4195)
Gpound.liud7f5f726af75
diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.editor.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.editor.controller.tsindex 6c35d32fda..4e7593ee00 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.editor.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.editor.controller.ts@@ -15,7 +15,6 @@*/import {- BuildTextUtils,Disposable,Inject,toDisposable,@@ -45,21 +44,29 @@ export class ConditionalFormattingEditorController extends Disposable {AFTER_CELL_EDIT,{handler: (value, context, next) => {+ if (!value) {+ next(value);+ }const result = this._conditionalFormattingService.composeStyle(context.unitId, context.subUnitId, context.row, context.col);- if (result?.style && value?.p) {- const keys = Object.keys(result?.style);- if (keys.length > 0) {- const v = BuildTextUtils.transform.getPlainText(value.p.body?.dataStream ?? '');- const s = { ...(typeof value.s === 'string' ? context.workbook.getStyles().get(value.s) : value.s) || {} };- keys.forEach((key) => {- delete s[key as keyof typeof s];- });- const cellData = { ...value, s: { ...s }, v };- delete cellData.p;- return next(cellData);- }+ const cfStyle = result?.style ?? {};+ const keys = Object.keys(cfStyle);+ if (value?.p) {+ value.p.body?.textRuns?.forEach((item) => {+ if (item.ts) {+ keys.forEach((key) => {+ delete item.ts?.[key as keyof typeof item.ts];+ });+ }+ });+ return next(value);+ } else {+ const s = { ...(typeof value?.s === 'string' ? context.workbook.getStyles().get(value.s) : value?.s) || {} };+ keys.forEach((key) => {+ delete s[key as keyof typeof s];+ });+ const cellData = { ...value, s: { ...s } };+ return next(cellData);}- return next(value);},})diff --git a/packages/sheets-numfmt-ui/src/controllers/numfmt.editor.controller.ts b/packages/sheets-numfmt-ui/src/controllers/numfmt.editor.controller.tsindex 2edd1e697a..c7b3d6796f 100644--- a/packages/sheets-numfmt-ui/src/controllers/numfmt.editor.controller.ts+++ b/packages/sheets-numfmt-ui/src/controllers/numfmt.editor.controller.ts@@ -148,7 +148,6 @@ export class NumfmtEditorController extends Disposable {handler: (value, context, next) => {// clear the effectthis._collectEffectMutation.clean();- const { worksheet, row, col } = context;const currentNumfmtValue = this._numfmtService.getValue(context.unitId,context.subUnitId,@@ -204,9 +203,7 @@ export class NumfmtEditorController extends Disposable {);}const v = Number(numfmtInfo.v);- // The format needs to discard the current style settings- const originStyle = worksheet.getCellStyleOnly(row, col)?.s;- return { ...value, v, p: null, s: originStyle, t: CellValueType.NUMBER };+ return next({ ...value, p: undefined, v, t: CellValueType.NUMBER });} else if (['date', 'time', 'datetime', 'percent'].includes(currentNumfmtType) || !isNumeric(content)) {clean();}