Skip to content

Commit

Permalink
fix: fix e2e errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wzhudev committed Oct 10, 2024
1 parent af430e7 commit a82059f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
4 changes: 3 additions & 1 deletion examples/src/sheets-multi/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';

Expand All @@ -47,6 +48,7 @@ function factory(id: string) {
logLevel: LogLevel.VERBOSE,
});

univer.registerPlugin(UniverFormulaEnginePlugin);
univer.registerPlugin(UniverRenderEnginePlugin);
univer.registerPlugin(UniverUIPlugin, {
container: id,
Expand Down
1 change: 0 additions & 1 deletion packages/docs-drawing-ui/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export class UniverDocsDrawingUIPlugin extends Plugin {
}

override onRendered(): void {
this._injector.get(DocDrawingTransformUpdateController);
this._injector.get(DocDrawingPopupMenuController);
}
}
1 change: 0 additions & 1 deletion packages/sheets-ui/src/services/sheets-render.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export class SheetsRenderService extends RxDisposable {
// TODO when does this function get called?
this._createRenderer(workbook);
});

this._instanceSrv.getAllUnitsForType<Workbook>(UniverInstanceType.UNIVER_SHEET)
.forEach((workbook) => this._createRenderer(workbook));

Expand Down
21 changes: 16 additions & 5 deletions packages/ui/src/controllers/ui/ui-desktop.controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
*/

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';
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';
Expand All @@ -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,
Expand All @@ -49,8 +52,7 @@ export class DesktopUIController extends Disposable {

this._initBuiltinComponents();
this._initMenus();

Promise.resolve().then(() => this._bootstrapWorkbench());
this._bootstrapWorkbench();
}

private _initMenus(): void {
Expand All @@ -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);
}));
})
);
}
Expand Down

0 comments on commit a82059f

Please sign in to comment.