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(sheets): active current font color (#5817)
Roman Sergeevc2b427a49cfb
diff --git a/packages/core/src/types/const/const.ts b/packages/core/src/types/const/const.tsindex deb3c62bd8..20924694a7 100644--- a/packages/core/src/types/const/const.ts+++ b/packages/core/src/types/const/const.ts@@ -127,7 +127,7 @@ export const DEFAULT_STYLES = {* color*/cl: {- rgb: '#000',+ rgb: '#000000',},/*** backgrounddiff --git a/packages/sheets-ui/src/controllers/menu/menu.ts b/packages/sheets-ui/src/controllers/menu/menu.tsindex ae410bb439..494aec0ed4 100644--- a/packages/sheets-ui/src/controllers/menu/menu.ts+++ b/packages/sheets-ui/src/controllers/menu/menu.ts@@ -533,7 +533,7 @@ export function ResetTextColorMenuItemFactory(accessor: IAccessor): IMenuButtonI};}-export function TextColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {+export function TextColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string, string | undefined> {const commandService = accessor.get(ICommandService);const themeService = accessor.get(ThemeService);@@ -549,6 +549,29 @@ export function TextColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSelehoverable: false,selectable: false,},+ value$: new Observable<string>((subscriber) => {+ const defaultValue = DEFAULT_STYLES.cl.rgb;+ const calc = () => {+ const textRun = getFontStyleAtCursor(accessor);++ if (!textRun) {+ subscriber.next(defaultValue);+ return;+ }++ const color = textRun.ts?.cl?.rgb;+ subscriber.next(color ?? defaultValue);+ };++ const disposable = commandService.onCommandExecuted((c) => {+ if (c.id === SetRangeTextColorCommand.id) {+ calc();+ }+ });++ calc();+ return disposable.dispose;+ }),},],value$: new Observable<string>((subscriber) => {diff --git a/packages/sheets/src/commands/commands/__tests__/set-style.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-style.command.spec.tsindex 0d01e00633..e54ba1a79e 100644--- a/packages/sheets/src/commands/commands/__tests__/set-style.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-style.command.spec.ts@@ -97,7 +97,7 @@ describe("Test commands used for updating cells' styles", () => {.getFontColor();}- const defaultColor = '#000';+ const defaultColor = '#000000';const color1 = '#aaa';const color2 = '#bbb';const color3 = '#ccc';@@ -485,7 +485,7 @@ describe("Test commands used for updating cells' styles", () => {// undoexpect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();- expect(getFontColor()).toBe('#000');+ expect(getFontColor()).toBe('#000000');expect(getFontThroughLine()).toStrictEqual({s: BooleanNumber.TRUE,}); // no color