diff --git a/examples/src/sheets-multi/main.tsx b/examples/src/sheets-multi/main.tsx index 5e0460e016c..31f59ddbb13 100644 --- a/examples/src/sheets-multi/main.tsx +++ b/examples/src/sheets-multi/main.tsx @@ -19,6 +19,7 @@ import { defaultTheme } from '@univerjs/design'; import { UniverDocsPlugin } from '@univerjs/docs'; import { UniverDocsUIPlugin } from '@univerjs/docs-ui'; +import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula'; import { UniverRenderEnginePlugin } from '@univerjs/engine-render'; import { DEFAULT_WORKBOOK_DATA_DEMO } from '@univerjs/mockdata'; import { UniverSheetsPlugin } from '@univerjs/sheets'; @@ -29,8 +30,8 @@ import { UniverUIPlugin } from '@univerjs/ui'; import React, { useEffect } from 'react'; import { createRoot } from 'react-dom/client'; import { Mosaic, MosaicWindow } from 'react-mosaic-component'; -import { enUS, ruRU, zhCN } from '../locales'; +import { enUS, ruRU, zhCN } from '../locales'; import 'react-mosaic-component/react-mosaic-component.css'; import './index.css'; @@ -47,6 +48,7 @@ function factory(id: string) { logLevel: LogLevel.VERBOSE, }); + univer.registerPlugin(UniverFormulaEnginePlugin); univer.registerPlugin(UniverRenderEnginePlugin); univer.registerPlugin(UniverUIPlugin, { container: id, diff --git a/packages/docs-drawing-ui/src/plugin.ts b/packages/docs-drawing-ui/src/plugin.ts index bdc03b39fc5..a024d34fa83 100644 --- a/packages/docs-drawing-ui/src/plugin.ts +++ b/packages/docs-drawing-ui/src/plugin.ts @@ -74,7 +74,6 @@ export class UniverDocsDrawingUIPlugin extends Plugin { } override onRendered(): void { - this._injector.get(DocDrawingTransformUpdateController); this._injector.get(DocDrawingPopupMenuController); } } diff --git a/packages/sheets-ui/src/services/sheets-render.service.ts b/packages/sheets-ui/src/services/sheets-render.service.ts index 895eb9ab360..6edf254f9ca 100644 --- a/packages/sheets-ui/src/services/sheets-render.service.ts +++ b/packages/sheets-ui/src/services/sheets-render.service.ts @@ -73,7 +73,6 @@ export class SheetsRenderService extends RxDisposable { // TODO when does this function get called? this._createRenderer(workbook); }); - this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET) .forEach((workbook) => this._createRenderer(workbook)); diff --git a/packages/ui/src/controllers/ui/ui-desktop.controller.tsx b/packages/ui/src/controllers/ui/ui-desktop.controller.tsx index fef9bee1789..6dda7128b92 100644 --- a/packages/ui/src/controllers/ui/ui-desktop.controller.tsx +++ b/packages/ui/src/controllers/ui/ui-desktop.controller.tsx @@ -15,6 +15,7 @@ */ import type { IDisposable, UnitModel } from '@univerjs/core'; +import type { RenderUnit } from '@univerjs/engine-render'; import type { IUniverUIConfig } from '../config.schema'; import type { IWorkbenchOptions } from './ui.controller'; import { connectInjector, Disposable, Inject, Injector, isInternalEditorID, IUniverInstanceService, LifecycleService, LifecycleStages, Optional, toDisposable } from '@univerjs/core'; @@ -22,6 +23,7 @@ import { IRenderManagerService } from '@univerjs/engine-render'; import { render as createRoot, unmount } from 'rc-util/lib/React/render'; import React from 'react'; +import { filter, take } from 'rxjs'; import { ILayoutService } from '../../services/layout/layout.service'; import { IMenuManagerService } from '../../services/menu/menu-manager.service'; import { BuiltInUIPart, IUIPartsService } from '../../services/parts/parts.service'; @@ -34,6 +36,7 @@ const STEADY_TIMEOUT = 3000; export class DesktopUIController extends Disposable { private _steadyTimeout: NodeJS.Timeout; + private _renderTimeout: NodeJS.Timeout; constructor( private readonly _config: IUniverUIConfig, @@ -49,8 +52,7 @@ export class DesktopUIController extends Disposable { this._initBuiltinComponents(); this._initMenus(); - - Promise.resolve().then(() => this._bootstrapWorkbench()); + this._bootstrapWorkbench(); } private _initMenus(): void { @@ -77,14 +79,23 @@ export class DesktopUIController extends Disposable { if (isInternalEditorID(render.unitId)) return; render.engine.setContainer(contentElement); } + }); + + this.disposeWithMe(this._lifecycleService.lifecycle$.pipe(filter((stage) => stage === LifecycleStages.Ready), take(1)).subscribe(() => { + this._renderTimeout = setTimeout(() => { + const allRenders = this._renderManagerService.getRenderAll(); + + for (const [key, render] of allRenders) { + if (isInternalEditorID(key) || !((render) as RenderUnit).isRenderUnit) continue; + render.engine.setContainer(contentElement); + } - if (this._lifecycleService.stage === LifecycleStages.Ready) { this._lifecycleService.stage = LifecycleStages.Rendered; this._steadyTimeout = setTimeout(() => { this._lifecycleService.stage = LifecycleStages.Steady; }, STEADY_TIMEOUT); - } - }); + }, 300); + })); }) ); }