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: fix dark mode for docs (#5400)

Evan Huc9218b307882
diff --git a/packages/engine-render/src/render-manager/render-manager.service.ts b/packages/engine-render/src/render-manager/render-manager.service.ts
index 1a3ba791d9..dae9e60166 100644
--- a/packages/engine-render/src/render-manager/render-manager.service.ts
+++ b/packages/engine-render/src/render-manager/render-manager.service.ts
@@ -18,10 +18,11 @@ import type { Dependency, DependencyIdentifier, IDisposable, Nullable, UnitModel
import type { Observable } from 'rxjs';
import type { BaseObject } from '../base-object';
import type { DocComponent } from '../components/docs/doc-component';
-
import type { SheetComponent } from '../components/sheets/sheet-component';
+
import type { Slide } from '../components/slides/slide';
import type { IRender } from './render-unit';
+import { ThemeService } from '@univerjs/core';
import { createIdentifier, Disposable, Inject, Injector, IUniverInstanceService, remove, toDisposable, UniverInstanceType } from '@univerjs/core';
import { Subject } from 'rxjs';
import { Engine } from '../engine';
@@ -107,9 +108,12 @@ export class RenderManagerService extends Disposable implements IRenderManagerSe
constructor(
@Inject(Injector) protected readonly _injector: Injector,
- @IUniverInstanceService protected readonly _univerInstanceService: IUniverInstanceService
+ @IUniverInstanceService protected readonly _univerInstanceService: IUniverInstanceService,
+ @Inject(ThemeService) private readonly _themeService: ThemeService
) {
super();
+
+ this._initDarkModeListener();
}
override dispose(): void {
@@ -174,6 +178,17 @@ export class RenderManagerService extends Disposable implements IRenderManagerSe
return Array.from(this._renderDependencies.get(type) ?? []);
}
+ private _initDarkModeListener(): void {
+ this.disposeWithMe(this._themeService.darkMode$.subscribe(() => {
+ this.getRenderAll().forEach((renderer) => {
+ renderer.components.forEach((component) => {
+ component.makeForceDirty(true);
+ component.makeDirty(true);
+ });
+ });
+ }));
+ }
+
create(unitId: string) {
this._createRender$.next(unitId);
}
diff --git a/packages/sheets-ui/src/services/sheets-render.service.ts b/packages/sheets-ui/src/services/sheets-render.service.ts
index e99083769d..a4b0f906d6 100644
--- a/packages/sheets-ui/src/services/sheets-render.service.ts
+++ b/packages/sheets-ui/src/services/sheets-render.service.ts
@@ -72,18 +72,6 @@ export class SheetsRenderService extends RxDisposable {
private _init() {
this._initWorkbookListener();
this._initContextListener();
- this._initDarkModeListener();
- }
-
- private _initDarkModeListener(): void {
- this.disposeWithMe(this._themeService.darkMode$.subscribe(() => {
- this._renderManagerService.getRenderAll().forEach((renderer) => {
- renderer.components.forEach((component) => {
- component.makeForceDirty(true);
- component.makeDirty(true);
- });
- });
- }));
}
private _initWorkbookListener(): void {