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(docs-ui): active text color in docs (#5823)

Roman Sergeevbece66c2d724
diff --git a/packages/docs-ui/src/controllers/menu/menu.ts b/packages/docs-ui/src/controllers/menu/menu.ts
index 7252aabf89..762945a351 100644
--- a/packages/docs-ui/src/controllers/menu/menu.ts
+++ b/packages/docs-ui/src/controllers/menu/menu.ts
@@ -617,7 +617,7 @@ export function HeadingSelectorMenuItemFactory(accessor: IAccessor): IMenuSelect
};
}
-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);
@@ -634,6 +634,29 @@ export function TextColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSele
hoverable: 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 === SetInlineFormatTextColorCommand.id) {
+ calc();
+ }
+ });
+
+ calc();
+ return disposable.dispose;
+ }),
},
],
value$: new Observable<string>((subscriber) => {