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
refactor!: remove runOnLifecycle and add smoking tests (#3672)
Wenzhao Huf5e97b186bdd
diff --git a/common/storybook/.storybook/preview.tsx b/common/storybook/.storybook/preview.tsxindex ff50f01a1e..fdc691b784 100644--- a/common/storybook/.storybook/preview.tsx+++ b/common/storybook/.storybook/preview.tsx@@ -14,11 +14,7 @@* limitations under the License.*/-import React from 'react';import type { Preview } from '@storybook/react';-import { ConfigProvider, defaultTheme, greenTheme, themeInstance } from '@univerjs/design';-import zhCN from '@univerjs/design/locale/zh-CN';-import enUS from '@univerjs/design/locale/en-US';import {CommandService,ConfigService,@@ -35,7 +31,6 @@ import {IResourceManagerService,IUndoRedoService,IUniverInstanceService,- LifecycleInitializerService,LifecycleService,LocaleService,LocaleType,@@ -46,7 +41,11 @@ import {ThemeService,UniverInstanceService,} from '@univerjs/core';+import { ConfigProvider, defaultTheme, greenTheme, themeInstance } from '@univerjs/design';+import enUS from '@univerjs/design/locale/en-US';+import zhCN from '@univerjs/design/locale/zh-CN';import { DesktopLocalStorageService } from '@univerjs/ui';+import React from 'react';export const themes: Record<string, Record<string, string>> = {default: defaultTheme,@@ -94,7 +93,6 @@ const preview: Preview = {[LocaleService],[ThemeService],[LifecycleService],- [LifecycleInitializerService],[ILogService, { useClass: DesktopLogService, lazy: true }],[ICommandService, { useClass: CommandService, lazy: true }],[IUndoRedoService, { useClass: LocalUndoRedoService, lazy: true }],diff --git a/e2e/disposing/disposing.spec.ts b/e2e/disposing/disposing.spec.tsindex 885b494e66..9525fd4f37 100644--- a/e2e/disposing/disposing.spec.ts+++ b/e2e/disposing/disposing.spec.ts@@ -65,7 +65,6 @@ test('no error on constructing and disposing sheet unit', async ({ page }) => {});test('no error when dispose a unit', async ({ page }) => {- // test.setTimeout(40 * 1000);let errored = false;page.on('pageerror', (error) => {diff --git a/e2e/smoking/README.md b/e2e/smoking/README.mdnew file mode 100644index 0000000000..8d6677ade8--- /dev/null+++ b/e2e/smoking/README.md@@ -0,0 +1,6 @@+# Notes on Smoking++These tests make sure that all the demo pages can be loaded without any errors. Some demos are implemented in visual comparison tests, so they are not included in this suite.++- docs+- sheetsdiff --git a/e2e/smoking/mobile-s/mobile-s-smoking.spec.ts b/e2e/smoking/mobile-s/mobile-s-smoking.spec.tsnew file mode 100644index 0000000000..b5705575a0--- /dev/null+++ b/e2e/smoking/mobile-s/mobile-s-smoking.spec.ts@@ -0,0 +1,31 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { expect, test } from '@playwright/test';++test('ensure mobile-s boots up without errors', async ({ page }) => {+ let errored = false;++ page.on('pageerror', (error) => {+ console.error('Page error:', error);+ errored = true;+ });++ await page.goto('http://localhost:3000/mobile-s/');+ await page.waitForTimeout(10000);++ expect(errored).toBeFalsy();+});diff --git a/e2e/smoking/sheets-multi/sheets-multi-smoking.spec.ts b/e2e/smoking/sheets-multi/sheets-multi-smoking.spec.tsnew file mode 100644index 0000000000..b11e397e03--- /dev/null+++ b/e2e/smoking/sheets-multi/sheets-multi-smoking.spec.ts@@ -0,0 +1,31 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { expect, test } from '@playwright/test';++test('ensure sheets-multi boots up without errors', async ({ page }) => {+ let errored = false;++ page.on('pageerror', (error) => {+ console.error('Page error:', error);+ errored = true;+ });++ await page.goto('http://localhost:3000/sheets-multi/');+ await page.waitForTimeout(10000);++ expect(errored).toBeFalsy();+});diff --git a/packages/sheets-numfmt/src/controllers/numfmt.i18n.controller.ts b/e2e/smoking/uni/uni-smoking.spec.tssimilarity index 61%rename from packages/sheets-numfmt/src/controllers/numfmt.i18n.controller.tsrename to e2e/smoking/uni/uni-smoking.spec.tsindex 7a8c9b5259..9789789fc2 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.i18n.controller.ts+++ b/e2e/smoking/uni/uni-smoking.spec.ts@@ -14,11 +14,18 @@* limitations under the License.*/-import { Disposable, Inject, LifecycleStages, LocaleService, OnLifecycle } from '@univerjs/core';+import { expect, test } from '@playwright/test';-@OnLifecycle(LifecycleStages.Rendered, NumfmtI18nController)-export class NumfmtI18nController extends Disposable {- constructor(@Inject(LocaleService) private _localeService: LocaleService) {- super();- }-}+test('ensure uni boots up without errors', async ({ page }) => {+ let errored = false;++ page.on('pageerror', (error) => {+ console.error('Page error:', error);+ errored = true;+ });++ await page.goto('http://localhost:3000/uni/');+ await page.waitForTimeout(10000);++ expect(errored).toBeFalsy();+});diff --git a/e2e/visual-comparison/README.md b/e2e/visual-comparison/README.mdindex 40d5133f76..d3b0d40f3e 100644--- a/e2e/visual-comparison/README.md+++ b/e2e/visual-comparison/README.md@@ -1,4 +1,6 @@-# Notes on visual comparison+# Notes on Visual ComparisonYou should set `maxDiffPixels` on a minimum value. The cursor may be different in snapshots because it is blinking,especially in rich-text editors.++For more instructions, please read related part in [CONTRIBUTING.md](../../CONTRIBUTING.md).diff --git a/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts b/e2e/visual-comparison/docs/docs-visual-comparison.spec.tsindex 8e3a982210..39b0d9fc70 100644--- a/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts+++ b/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts@@ -18,6 +18,13 @@ import { expect, test } from '@playwright/test';import { generateSnapshotName } from '../const';test('diff default doc content', async ({ page }) => {+ let errored = false;++ page.on('pageerror', (error) => {+ console.error('Page error:', error);+ errored = true;+ });+await page.goto('http://localhost:3000/docs/');await page.waitForTimeout(2000);@@ -25,4 +32,5 @@ test('diff default doc content', async ({ page }) => {await page.waitForTimeout(5000);await expect(page).toHaveScreenshot(generateSnapshotName('default-doc'), { maxDiffPixels: 30 });+ expect(errored).toBeFalsy();});diff --git a/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/default-sheet-ci-chromium-linux.png b/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/default-sheet-ci-chromium-linux.pngdeleted file mode 100644index 85e8c788d0..0000000000Binary files a/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/default-sheet-ci-chromium-linux.png and /dev/null differdiff --git a/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-ci-chromium-linux.png b/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-ci-chromium-linux.pngdeleted file mode 100644index 6bfb595ffa..0000000000Binary files a/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-ci-chromium-linux.png and /dev/null differdiff --git a/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/diff-demo-sheet-content-1-chromium-darwin.png b/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/diff-demo-sheet-content-1-chromium-darwin.pngdeleted file mode 100644index d1c05430c1..0000000000Binary files a/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/diff-demo-sheet-content-1-chromium-darwin.png and /dev/null differdiff --git a/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.tssimilarity index 89%rename from e2e/visual-comparison/sheet/sheets-visual-comparison.spec.tsrename to e2e/visual-comparison/sheets/sheets-visual-comparison.spec.tsindex dab25a44ab..ca76b196d6 100644--- a/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts+++ b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts@@ -28,6 +28,13 @@ test('diff default sheet content', async ({ page }) => {});test('diff demo sheet content', async ({ page }) => {+ let errored = false;++ page.on('pageerror', (error) => {+ console.error('Page error:', error);+ errored = true;+ });+await page.goto('http://localhost:3000/sheets/');await page.waitForTimeout(2000);@@ -35,4 +42,5 @@ test('diff demo sheet content', async ({ page }) => {await page.waitForTimeout(5000);await expect(page).toHaveScreenshot(generateSnapshotName('demo-sheet'), { maxDiffPixels: 5 });+ expect(errored).toBeFalsy();});diff --git a/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/default-sheet-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-chromium-linux.pngsimilarity index 100%rename from e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/default-sheet-chromium-linux.pngrename to e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-chromium-linux.pngdiff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-ci-chromium-linux.pngnew file mode 100644index 0000000000..97828dd477Binary files /dev/null and b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-ci-chromium-linux.png differdiff --git a/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-chromium-linux.pngsimilarity index 100%rename from e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-chromium-linux.pngrename to e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-chromium-linux.pngdiff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-ci-chromium-linux.pngnew file mode 100644index 0000000000..ba7ccfd100Binary files /dev/null and b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/demo-sheet-ci-chromium-linux.png differdiff --git a/examples/src/mobile-s/main.ts b/examples/src/mobile-s/main.tsindex d0d930c141..73d90b86c2 100644--- a/examples/src/mobile-s/main.ts+++ b/examples/src/mobile-s/main.ts@@ -27,9 +27,10 @@ import { UniverRPCMainThreadPlugin } from '@univerjs/rpc';import { UniverSheetsPlugin } from '@univerjs/sheets';import { UniverSheetsConditionalFormattingMobileUIPlugin } from '@univerjs/sheets-conditional-formatting-ui';import { UniverSheetsDataValidationPlugin } from '@univerjs/sheets-data-validation';+import { UniverSheetsDataValidationMobileUIPlugin } from '@univerjs/sheets-data-validation-ui';import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';import { UniverSheetsFilterMobileUIPlugin } from '@univerjs/sheets-filter-ui';-import { UniverSheetsFormulaMobilePlugin } from '@univerjs/sheets-formula';+import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula';import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt';import { UniverSheetsMobileUIPlugin } from '@univerjs/sheets-ui';import { UniverMobileUIPlugin } from '@univerjs/ui';@@ -65,9 +66,10 @@ univer.registerPlugin(UniverSheetsMobileUIPlugin);univer.registerPlugin(UniverSheetsFilterPlugin);univer.registerPlugin(UniverSheetsFilterMobileUIPlugin);univer.registerPlugin(UniverSheetsNumfmtPlugin);-univer.registerPlugin(UniverSheetsFormulaMobilePlugin);+univer.registerPlugin(UniverSheetsFormulaPlugin);univer.registerPlugin(UniverSheetsConditionalFormattingMobileUIPlugin);univer.registerPlugin(UniverSheetsDataValidationPlugin);+univer.registerPlugin(UniverSheetsDataValidationMobileUIPlugin);const mockUser = {userID: 'Owner_qxVnhPbQ',diff --git a/examples/src/sheets-multi/main.tsx b/examples/src/sheets-multi/main.tsxindex 5e0460e016..31f59ddbb1 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/examples/src/sheets/main.ts b/examples/src/sheets/main.tsindex 7cc34cbe24..4a42c1edc2 100644--- a/examples/src/sheets/main.ts+++ b/examples/src/sheets/main.ts@@ -25,8 +25,8 @@ import { UniverDocsUIPlugin } from '@univerjs/docs-ui';import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';import { UniverRenderEnginePlugin } from '@univerjs/engine-render';import { FUniver } from '@univerjs/facade';-import { DEFAULT_WORKBOOK_DATA_DEMO } from '@univerjs/mockdata';+import { DEFAULT_WORKBOOK_DATA_DEMO } from '@univerjs/mockdata';import { UniverRPCMainThreadPlugin } from '@univerjs/rpc';import { UniverSheetsPlugin } from '@univerjs/sheets';import { UniverSheetsConditionalFormattingPlugin } from '@univerjs/sheets-conditional-formatting';diff --git a/examples/src/uni/main.ts b/examples/src/uni/main.tsindex 47b59c450b..e0baf08def 100644--- a/examples/src/uni/main.ts+++ b/examples/src/uni/main.ts@@ -48,9 +48,6 @@ import { UniSlidesUIController } from '@univerjs/uni-slides-ui';import { UniverUniUIPlugin } from '@univerjs/uniui';import { enUS } from '../locales';-/* eslint-disable-next-line node/prefer-global/process */-const IS_E2E: boolean = !!process.env.IS_E2E;-const LOAD_LAZY_PLUGINS_TIMEOUT = 4_000;// univer@@ -99,11 +96,9 @@ class CustomMentionDataService implements IThreadCommentMentionDataService {}// create univer instances-if (!IS_E2E) {- univer.createUnit(UniverInstanceType.UNIVER_SHEET, DEFAULT_WORKBOOK_DATA_DEMO);- univer.createUnit(UniverInstanceType.UNIVER_DOC, DEFAULT_DOCUMENT_DATA_EN);- univer.createUnit(UniverInstanceType.UNIVER_SHEET, DEFAULT_WORKBOOK_DATA_DEMO1);-}+univer.createUnit(UniverInstanceType.UNIVER_SHEET, DEFAULT_WORKBOOK_DATA_DEMO);+univer.createUnit(UniverInstanceType.UNIVER_DOC, DEFAULT_DOCUMENT_DATA_EN);+univer.createUnit(UniverInstanceType.UNIVER_SHEET, DEFAULT_WORKBOOK_DATA_DEMO1);// debugger pluginuniver.registerPlugin(UniverDebuggerPlugin);diff --git a/packages-experimental/debugger/src/controllers/debugger.controller.ts b/packages-experimental/debugger/src/controllers/debugger.controller.tsindex 4e4b48efb1..c8fa8825d4 100644--- a/packages-experimental/debugger/src/controllers/debugger.controller.ts+++ b/packages-experimental/debugger/src/controllers/debugger.controller.ts@@ -14,9 +14,8 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, ICommandService, Inject, Injector } from '@univerjs/core';import { ComponentManager, IMenuManagerService } from '@univerjs/ui';-import { CreateFloatDomCommand } from '../commands/commands/float-dom.command';import { CreateEmptySheetCommand, DisposeCurrentUnitCommand, DisposeUniverCommand, LoadSheetSnapshotCommand } from '../commands/commands/unit.command';import { ShowCellContentOperation } from '../commands/operations/cell.operation';@@ -28,19 +27,18 @@ import { MessageOperation } from '../commands/operations/message.operation';import { NotificationOperation } from '../commands/operations/notification.operation';import { SaveSnapshotOptions } from '../commands/operations/save-snapshot.operations';import { SetEditable } from '../commands/operations/set.editable.operation';-import { SidebarOperation } from '../commands/operations/sidebar.operation';-import { ThemeOperation } from '../commands/operations/theme.operation';import { ImageDemo } from '../components/Image';+// @ts-ignoreimport VueI18nIcon from '../components/VueI18nIcon.vue';+import { TEST_EDITOR_CONTAINER_COMPONENT } from '../views/test-editor/component-name';import { TestEditorContainer } from '../views/test-editor/TestTextEditor';import { RecordController } from './local-save/record.controller';import { menuSchema } from './menu.schema';-@OnLifecycle(LifecycleStages.Ready, DebuggerController)export class DebuggerController extends Disposable {constructor(@Inject(Injector) private readonly _injector: Injector,diff --git a/packages-experimental/debugger/src/controllers/performance-monitor.controller.ts b/packages-experimental/debugger/src/controllers/performance-monitor.controller.tsindex 9818724bcf..8543a5645f 100644--- a/packages-experimental/debugger/src/controllers/performance-monitor.controller.ts+++ b/packages-experimental/debugger/src/controllers/performance-monitor.controller.ts@@ -14,13 +14,12 @@* limitations under the License.*/-import { Inject, IUniverInstanceService, LifecycleService, LifecycleStages, OnLifecycle, RxDisposable } from '@univerjs/core';-import { IRenderManagerService } from '@univerjs/engine-render';-import { distinctUntilChanged, filter, take, takeUntil } from 'rxjs';import type { Nullable } from '@univerjs/core';import type { Subscription } from 'rxjs';+import { Inject, IUniverInstanceService, LifecycleService, LifecycleStages, RxDisposable } from '@univerjs/core';+import { IRenderManagerService } from '@univerjs/engine-render';+import { distinctUntilChanged, filter, take, takeUntil } from 'rxjs';-@OnLifecycle(LifecycleStages.Rendered, PerformanceMonitorController)export class PerformanceMonitorController extends RxDisposable {private _initListener = false;private _containerElement!: HTMLDivElement;diff --git a/packages-experimental/debugger/src/debugger-plugin.ts b/packages-experimental/debugger/src/debugger-plugin.tsindex b8ec344cb3..3447db5d8b 100644--- a/packages-experimental/debugger/src/debugger-plugin.ts+++ b/packages-experimental/debugger/src/debugger-plugin.ts@@ -52,6 +52,14 @@ export class UniverDebuggerPlugin extends Plugin {this._injector.get(E2EController);}+ override onReady(): void {+ this._injector.get(DebuggerController);+ }++ override onRendered(): void {+ this._injector.get(PerformanceMonitorController);+ }+getDebuggerController() {this._debuggerController = this._injector.get(DebuggerController);return this._debuggerController;diff --git a/packages-experimental/uni-docs-ui/src/controllers/uni-docs-ui.controller.tsx b/packages-experimental/uni-docs-ui/src/controllers/uni-docs-ui.controller.tsxindex 177bb10d44..3fe264b7f8 100644--- a/packages-experimental/uni-docs-ui/src/controllers/uni-docs-ui.controller.tsx+++ b/packages-experimental/uni-docs-ui/src/controllers/uni-docs-ui.controller.tsx@@ -14,7 +14,7 @@* limitations under the License.*/-import { ICommandService, IConfigService, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import { ICommandService, IConfigService, Inject, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { IMAGE_MENU_ID as DocsImageMenuId } from '@univerjs/docs-drawing-ui';import { BulletListCommand, DocCreateTableOperation, DocUIController, OrderListCommand, SetInlineFormatBoldCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextColorCommand, SetInlineFormatUnderlineCommand } from '@univerjs/docs-ui';import { ComponentManager, ILayoutService, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui';@@ -22,7 +22,6 @@ import { BuiltinUniToolbarItemId, generateCloneMutation, UniToolbarService } froimport { DOC_BOLD_MUTATION_ID, DOC_ITALIC_MUTATION_ID, DOC_STRIKE_MUTATION_ID, DOC_TABLE_MUTATION_ID, DOC_UNDERLINE_MUTATION_ID } from './menu';import { menuSchema } from './menu.schema';-@OnLifecycle(LifecycleStages.Ready, UniDocsUIController)export class UniDocsUIController extends DocUIController {constructor(@Inject(Injector) injector: Injector,diff --git a/packages-experimental/uni-formula-ui/src/controllers/doc-formula-input.controller.ts b/packages-experimental/uni-formula-ui/src/controllers/doc-formula-input.controller.tsindex aefdb0e997..1915982485 100644--- a/packages-experimental/uni-formula-ui/src/controllers/doc-formula-input.controller.ts+++ b/packages-experimental/uni-formula-ui/src/controllers/doc-formula-input.controller.ts@@ -14,23 +14,22 @@* limitations under the License.*/-import { CustomRangeType, Disposable, ICommandService, ILogService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import type { DocumentDataModel } from '@univerjs/core';+import type { IInsertCommandParams } from '@univerjs/docs-ui';+import type { IShowFormulaPopupOperationParams } from '../commands/operations/operation';+import { CustomRangeType, Disposable, ICommandService, ILogService, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { DocSelectionManagerService } from '@univerjs/docs';+import { DeleteLeftCommand, DocEventManagerService, IEditorService, InsertCommand, MoveCursorOperation } from '@univerjs/docs-ui';import { IRenderManagerService } from '@univerjs/engine-render';import { filter, map, mergeMap } from 'rxjs';--import type { DocumentDataModel } from '@univerjs/core';-import type { IInsertCommandParams } from '@univerjs/docs-ui';import { AddDocUniFormulaCommand, RemoveDocUniFormulaCommand, UpdateDocUniFormulaCommand } from '../commands/commands/doc.command';import { CloseFormulaPopupOperation, ShowFormulaPopupOperation } from '../commands/operations/operation';import { UniFormulaPopupService } from '../services/formula-popup.service';import { UNI_FORMULA_EDITOR_ID } from '../views/components/DocFormulaPopup';-import type { IShowFormulaPopupOperationParams } from '../commands/operations/operation';const FORMULA_INPUT_TRIGGER_CHAR = '=';-@OnLifecycle(LifecycleStages.Steady, DocUniFormulaInputController)export class DocUniFormulaInputController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages-experimental/uni-formula-ui/src/controllers/slide-formula-input.controller.ts b/packages-experimental/uni-formula-ui/src/controllers/slide-formula-input.controller.tsindex d0a52cedd2..9e698dd22d 100644--- a/packages-experimental/uni-formula-ui/src/controllers/slide-formula-input.controller.ts+++ b/packages-experimental/uni-formula-ui/src/controllers/slide-formula-input.controller.ts@@ -14,20 +14,19 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import type { IInsertCommandParams } from '@univerjs/docs-ui';+import type { IShowFormulaPopupOperationParams, ISlidePopupPosition } from '../commands/operations/operation';+import { Disposable, ICommandService, Inject, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { DocSelectionManagerService } from '@univerjs/docs';import { IEditorService, InsertCommand } from '@univerjs/docs-ui';import { ISlideEditorBridgeService } from '@univerjs/slides-ui';-import type { IInsertCommandParams } from '@univerjs/docs-ui';import { AddSlideUniFormulaCommand } from '../commands/commands/slide.command';import { CloseFormulaPopupOperation, ShowFormulaPopupOperation } from '../commands/operations/operation';import { UniFormulaPopupService } from '../services/formula-popup.service';import { UNI_FORMULA_EDITOR_ID } from '../views/components/DocFormulaPopup';-import type { IShowFormulaPopupOperationParams, ISlidePopupPosition } from '../commands/operations/operation';const FORMULA_INPUT_TRIGGER_CHAR = '=';-@OnLifecycle(LifecycleStages.Steady, SlideUniFormulaInputController)export class SlideUniFormulaInputController extends Disposable {constructor(@Inject(Injector) private readonly _injector: Injector,diff --git a/packages-experimental/uni-formula-ui/src/controllers/uni-formula-ui.controller.ts b/packages-experimental/uni-formula-ui/src/controllers/uni-formula-ui.controller.tsindex e453488723..4ebc32f4e6 100644--- a/packages-experimental/uni-formula-ui/src/controllers/uni-formula-ui.controller.ts+++ b/packages-experimental/uni-formula-ui/src/controllers/uni-formula-ui.controller.ts@@ -14,12 +14,11 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, ICommandService, Inject } from '@univerjs/core';import { ComponentManager } from '@univerjs/ui';-import { UniFormulaPopup } from '../views/components/DocFormulaPopup';import { CloseFormulaPopupOperation, ConfirmFormulaPopupCommand, ShowFormulaPopupOperation } from '../commands/operations/operation';+import { UniFormulaPopup } from '../views/components/DocFormulaPopup';-@OnLifecycle(LifecycleStages.Steady, UniFormulaUniController)export class UniFormulaUniController extends Disposable {constructor(@ICommandService private readonly _commandSrv: ICommandService,diff --git a/packages-experimental/uni-formula-ui/src/uni-formula-ui.plugin.ts b/packages-experimental/uni-formula-ui/src/uni-formula-ui.plugin.tsindex 1938bbaef0..0d5b48606a 100644--- a/packages-experimental/uni-formula-ui/src/uni-formula-ui.plugin.ts+++ b/packages-experimental/uni-formula-ui/src/uni-formula-ui.plugin.ts@@ -19,12 +19,12 @@ import { DependentOn, Inject, Injector, Plugin, UniverInstanceType } from '@univimport { IUniFormulaService, UniverDocUniFormulaPlugin } from '@univerjs/uni-formula';import { DOC_FORMULA_UI_PLUGIN_NAME } from './const';-import { UniFormulaPopupService } from './services/formula-popup.service';import { DocUniFormulaInputController } from './controllers/doc-formula-input.controller';-import { UniFormulaService } from './services/uni-formula.service';-import { UniFormulaUniController } from './controllers/uni-formula-ui.controller';import { SlideUniFormulaInputController } from './controllers/slide-formula-input.controller';+import { UniFormulaUniController } from './controllers/uni-formula-ui.controller';+import { UniFormulaPopupService } from './services/formula-popup.service';import { SlideUIFormulaCacheService } from './services/slide-ui-formula-cache.service';+import { UniFormulaService } from './services/uni-formula.service';@DependentOn(UniverDocUniFormulaPlugin)export class UniverDocUniFormulaUIPlugin extends Plugin {@@ -52,4 +52,10 @@ export class UniverDocUniFormulaUIPlugin extends Plugin {override onReady(): void {this._injector.get(IUniFormulaService);}++ override onSteady(): void {+ this._injector.get(UniFormulaUniController);+ this._injector.get(DocUniFormulaInputController);+ this._injector.get(SlideUniFormulaInputController);+ }}diff --git a/packages-experimental/uni-sheets-ui/src/controllers/uni-sheets-ui.controller.tsx b/packages-experimental/uni-sheets-ui/src/controllers/uni-sheets-ui.controller.tsxindex 8c380a137e..460ebd0c59 100644--- a/packages-experimental/uni-sheets-ui/src/controllers/uni-sheets-ui.controller.tsx+++ b/packages-experimental/uni-sheets-ui/src/controllers/uni-sheets-ui.controller.tsx@@ -15,7 +15,7 @@*/import type { Workbook } from '@univerjs/core';-import { connectInjector, ICommandService, IConfigService, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType, useDependency } from '@univerjs/core';+import { connectInjector, ICommandService, IConfigService, Inject, Injector, IUniverInstanceService, UniverInstanceType, useDependency } from '@univerjs/core';import { SetBackgroundColorCommand } from '@univerjs/sheets';import { IMAGE_MENU_ID as SheetsImageMenuId } from '@univerjs/sheets-drawing-ui';import { RenderSheetContent, SetRangeBoldCommand, SetRangeFontFamilyCommand, SetRangeFontSizeCommand, SetRangeItalicCommand, SetRangeStrickThroughCommand, SetRangeTextColorCommand, SetRangeUnderlineCommand, SheetUIController } from '@univerjs/sheets-ui';@@ -26,7 +26,6 @@ import { UniSheetBar } from '../views/uni-sheet-bar/UniSheetBar';import { SHEET_BOLD_MUTATION_ID, SHEET_ITALIC_MUTATION_ID, SHEET_STRIKE_MUTATION_ID, SHEET_UNDERLINE_MUTATION_ID } from './menu';import { menuSchema } from './menu.schema';-@OnLifecycle(LifecycleStages.Ready, SheetUIController)export class UniSheetsUIController extends SheetUIController {constructor(@Inject(Injector) injector: Injector,diff --git a/packages-experimental/uni-slides-ui/src/controllers/uni-slides-ui.controller.tsx b/packages-experimental/uni-slides-ui/src/controllers/uni-slides-ui.controller.tsxindex e767af2895..0dda109d48 100644--- a/packages-experimental/uni-slides-ui/src/controllers/uni-slides-ui.controller.tsx+++ b/packages-experimental/uni-slides-ui/src/controllers/uni-slides-ui.controller.tsx@@ -14,16 +14,15 @@* limitations under the License.*/-import React from 'react';import type { SlideDataModel } from '@univerjs/core';-import { connectInjector, ICommandService, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType, useDependency } from '@univerjs/core';+import { connectInjector, ICommandService, Inject, Injector, IUniverInstanceService, UniverInstanceType, useDependency } from '@univerjs/core';import { IMAGE_MENU_ID, SHAPE_MENU_ID, SlideAddTextCommand, SlideEditorContainer, SlidesUIController } from '@univerjs/slides-ui';import { BuiltInUIPart, ComponentManager, IMenuManagerService, IShortcutService, IUIPartsService, useObservable } from '@univerjs/ui';import { BuiltinUniToolbarItemId, UniToolbarService, UniUIPart } from '@univerjs/uniui';+import React from 'react';import { UniSlideSideBar } from '../views/UniSlideSideBar';import { menuSchema } from './menu.schema';-@OnLifecycle(LifecycleStages.Ready, UniSlidesUIController)export class UniSlidesUIController extends SlidesUIController {constructor(@Inject(Injector) _injector: Injector,diff --git a/packages-experimental/uniui/src/controllers/uniui-flow.controller.tsx b/packages-experimental/uniui/src/controllers/uniui-flow.controller.tsxindex 6a42f9a69a..51cbb536fb 100644--- a/packages-experimental/uniui/src/controllers/uniui-flow.controller.tsx+++ b/packages-experimental/uniui/src/controllers/uniui-flow.controller.tsx@@ -14,14 +14,13 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';+import type { IFlowViewport } from '../services/flow/flow-manager.service';+import { Disposable, ICommandService, Inject } from '@univerjs/core';import { auditTime, throttleTime } from 'rxjs';import { SetFlowViewportOperation } from '../commands/operations/set-flow-viewport.operation';-import type { IFlowViewport } from '../services/flow/flow-manager.service';-import { FlowManagerService } from '../services/flow/flow-manager.service';import { UniFocusUnitOperation } from '../commands/operations/uni-focus-unit.operation';+import { FlowManagerService } from '../services/flow/flow-manager.service';-@OnLifecycle(LifecycleStages.Ready, UniuiFlowController)export class UniuiFlowController extends Disposable {constructor(@ICommandService protected readonly _commandService: ICommandService,diff --git a/packages-experimental/uniui/src/controllers/uniui-leftsidebar.controller.tsx b/packages-experimental/uniui/src/controllers/uniui-leftsidebar.controller.tsxindex 8e28622070..d076f8c365 100644--- a/packages-experimental/uniui/src/controllers/uniui-leftsidebar.controller.tsx+++ b/packages-experimental/uniui/src/controllers/uniui-leftsidebar.controller.tsx@@ -14,15 +14,14 @@* limitations under the License.*/-import { Disposable, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';import type { ISidebarService } from '@univerjs/ui';+import { Disposable, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { ComponentManager, ILeftSidebarService } from '@univerjs/ui';import { distinctUntilChanged, map } from 'rxjs';import { Outline } from '../views/outline/Outline';const OUTLINE_COMPONENT = 'OUTLINE_COMPONENT';-@OnLifecycle(LifecycleStages.Ready, UniuiLeftSidebarController)export class UniuiLeftSidebarController extends Disposable {constructor(@Inject(ComponentManager) private readonly _componentManager: ComponentManager,diff --git a/packages-experimental/uniui/src/controllers/uniui-toolbar.controller.tsx b/packages-experimental/uniui/src/controllers/uniui-toolbar.controller.tsxindex 73e98eaf99..f837db83a4 100644--- a/packages-experimental/uniui/src/controllers/uniui-toolbar.controller.tsx+++ b/packages-experimental/uniui/src/controllers/uniui-toolbar.controller.tsx@@ -14,9 +14,9 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';-import { DeleteSingle, DownloadSingle, LockSingle, PivotTableSingle, PrintSingle, ShareSingle, ZenSingle } from '@univerjs/icons';import type { MenuConfig } from '@univerjs/ui';+import { Disposable, ICommandService, Inject, Injector } from '@univerjs/core';+import { DeleteSingle, DownloadSingle, LockSingle, PivotTableSingle, PrintSingle, ShareSingle, ZenSingle } from '@univerjs/icons';import { ComponentManager, IMenuManagerService } from '@univerjs/ui';import { DisposeUnitOperation } from '../commands/operations/uni.operation';import { UniToolbarService } from '../services/toolbar/uni-toolbar-service';@@ -28,7 +28,6 @@ export interface IUniuiToolbarConfig {export const DefaultUniuiToolbarConfig = {};-@OnLifecycle(LifecycleStages.Ready, UniuiToolbarController)export class UniuiToolbarController extends Disposable {constructor(@IMenuManagerService protected readonly _menuManagerService: IMenuManagerService,diff --git a/packages-experimental/uniui/src/plugin.ts b/packages-experimental/uniui/src/plugin.tsindex 7dae6cfd0a..a16e0f5c51 100644--- a/packages-experimental/uniui/src/plugin.ts+++ b/packages-experimental/uniui/src/plugin.ts@@ -14,8 +14,9 @@* limitations under the License.*/+import type { Dependency } from '@univerjs/core';+import type { IUniverUIConfig } from '@univerjs/ui';import { DependentOn, IContextService, ILocalStorageService, Inject, Injector, mergeOverrideWithDependencies, Plugin, Tools } from '@univerjs/core';-import { EditorService, IEditorService, IRangeSelectorService, RangeSelectorService } from '@univerjs/docs-ui';import { UniverRenderEnginePlugin } from '@univerjs/engine-render';import {BrowserClipboardService,@@ -28,6 +29,7 @@ import {DesktopDialogService,DesktopGlobalZoneService,DesktopLayoutService,+ DesktopLocalFileService,DesktopLocalStorageService,DesktopMessageService,DesktopNotificationService,@@ -44,6 +46,7 @@ import {IGlobalZoneService,ILayoutService,ILeftSidebarService,+ ILocalFileService,IMenuManagerService,IMenuService,IMessageService,@@ -67,8 +70,6 @@ import {UNIVER_UI_PLUGIN_NAME,ZIndexManager,} from '@univerjs/ui';-import type { Dependency } from '@univerjs/core';-import type { IUniverUIConfig } from '@univerjs/ui';import { UniverUniUIController } from './controllers/uniui-desktop.controller';import { UniuiFlowController } from './controllers/uniui-flow.controller';import { UniuiLeftSidebarController } from './controllers/uniui-leftsidebar.controller';@@ -77,8 +78,6 @@ import { FlowManagerService } from './services/flow/flow-manager.service';import { UniToolbarService } from './services/toolbar/uni-toolbar-service';import { IUnitGridService, UnitGridService } from './services/unit-grid/unit-grid.service';-const UI_BOOTSTRAP_DELAY = 16;-/*** This plugin enables the Uni Mode of Univer. It should replace* `UniverUIPlugin` when registered.@@ -126,8 +125,7 @@ export class UniverUniUIPlugin extends Plugin {[IMessageService, { useClass: DesktopMessageService, lazy: true }],[ILocalStorageService, { useClass: DesktopLocalStorageService, lazy: true }],[IBeforeCloseService, { useClass: DesktopBeforeCloseService }],- [IEditorService, { useClass: EditorService }],- [IRangeSelectorService, { useClass: RangeSelectorService }],+ [ILocalFileService, { useClass: DesktopLocalFileService }],[ICanvasPopupService, { useClass: CanvasPopupService }],[IProgressService, { useClass: ProgressService }],[CanvasFloatDomService],@@ -142,5 +140,13 @@ export class UniverUniUIPlugin extends Plugin {[UniuiFlowController],], this._config.override);dependencies.forEach((dependency) => this._injector.add(dependency));++ this._injector.get(IUIController);+ }++ override onReady(): void {+ this._injector.get(UniuiFlowController);+ this._injector.get(UniuiLeftSidebarController);+ this._injector.get(UniuiToolbarController);}}diff --git a/packages-experimental/uniui/src/services/flow/flow-manager.service.ts b/packages-experimental/uniui/src/services/flow/flow-manager.service.tsindex 23ccb00fe7..9d01b210ff 100644--- a/packages-experimental/uniui/src/services/flow/flow-manager.service.ts+++ b/packages-experimental/uniui/src/services/flow/flow-manager.service.ts@@ -14,10 +14,8 @@* limitations under the License.*/-import { Disposable, LifecycleStages, OnLifecycle } from '@univerjs/core';-import type {- ReactFlowInstance,-} from '@xyflow/react';+import type { ReactFlowInstance } from '@xyflow/react';+import { Disposable } from '@univerjs/core';import { BehaviorSubject } from 'rxjs';@@ -27,7 +25,6 @@ export interface IFlowViewport {y: number;}-@OnLifecycle(LifecycleStages.Ready, FlowManagerService)export class FlowManagerService extends Disposable {private readonly _viewportChanged$ = new BehaviorSubject<IFlowViewport | null>(null);readonly viewportChanged$ = this._viewportChanged$.asObservable();diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex b3f9e95f33..719e266c15 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -93,9 +93,8 @@ export { ContextService, IContextService } from './services/context/context.servexport { ErrorService, type IError } from './services/error/error.service';export { IUniverInstanceService } from './services/instance/instance.service';export { UniverInstanceService } from './services/instance/instance.service';-export { LifecycleStages, OnLifecycle, runOnLifecycle } from './services/lifecycle/lifecycle';+export { LifecycleStages } from './services/lifecycle/lifecycle';export { LifecycleService } from './services/lifecycle/lifecycle.service';-export { LifecycleInitializerService } from './services/lifecycle/lifecycle.service';export { ILocalStorageService } from './services/local-storage/local-storage.service';export { LocaleService } from './services/locale/locale.service';export { DesktopLogService, ILogService, LogLevel } from './services/log/log.service';diff --git a/packages/core/src/services/command/command.service.ts b/packages/core/src/services/command/command.service.tsindex c7c2046221..120c2c86f9 100644--- a/packages/core/src/services/command/command.service.ts+++ b/packages/core/src/services/command/command.service.ts@@ -370,13 +370,15 @@ export class CommandService extends Disposable implements ICommandService {return result;}+throw new Error(`[CommandService]: command "${id}" is not registered.`);} catch (error) {+ this._logService.error(error);+if (error instanceof CustomCommandExecutionError) {// If need custom logic, can add it herereturn false as R;} else {- this._logService.error(error);throw error;}}diff --git a/packages/core/src/services/lifecycle/__tests__/lifecycle.service.spec.ts b/packages/core/src/services/lifecycle/__tests__/lifecycle.service.spec.tsindex 65c76118c7..ad71241f20 100644--- a/packages/core/src/services/lifecycle/__tests__/lifecycle.service.spec.ts+++ b/packages/core/src/services/lifecycle/__tests__/lifecycle.service.spec.ts@@ -19,13 +19,12 @@ import { Injector } from '../../../common/di';import { DesktopLogService, ILogService } from '../../log/log.service';import { LifecycleStages } from '../lifecycle';-import { LifecycleInitializerService, LifecycleService } from '../lifecycle.service';+import { LifecycleService } from '../lifecycle.service';function createLifecycleTestBed() {const injector = new Injector();injector.add([ILogService, { useClass: DesktopLogService }]);- injector.add([LifecycleInitializerService]);injector.add([LifecycleService]);return {@@ -117,34 +116,4 @@ describe('Test LifecycleService', () => {expect(lifecycleStages4).toEqual(steadyStages);expect(lifecycleStages5).toEqual(steadyStages);});-- // describe('Test automatically instantiate modules on lifecycle stages', () => {- // let initializer: LifecycleInitializerService;-- // it('Should instantiate modules on lifecycle stages', () => {- // injector = createLifecycleTestBed().injector;- // initializer = injector.get(LifecycleInitializerService);- // lifecycleService = injector.get(LifecycleService);-- // initializer.start();- // initializer.start(); // For just test coverage.-- // const initModules: string[] = [];-- // @OnLifecycle(LifecycleStages.Rendered, TestModule1)- // class TestModule1 {- // constructor() {- // initModules.push('test1');- // }- // }- // injector.add([TestModule1]);-- // lifecycleService.stage = LifecycleStages.Starting;- // lifecycleService.stage = LifecycleStages.Ready;- // expect(initModules).toEqual([]);-- // lifecycleService.stage = LifecycleStages.Rendered;- // expect(initModules).toEqual(['test1']);- // });- // });});diff --git a/packages/core/src/services/lifecycle/lifecycle.service.ts b/packages/core/src/services/lifecycle/lifecycle.service.tsindex 0fc1ff5564..f7a8b28d8f 100644--- a/packages/core/src/services/lifecycle/lifecycle.service.ts+++ b/packages/core/src/services/lifecycle/lifecycle.service.ts@@ -16,13 +16,11 @@import type { Observable } from 'rxjs';import { BehaviorSubject, merge, of, skip } from 'rxjs';-import type { DependencyIdentifier } from '../../common/di';-import { Inject, Injector } from '../../common/di';import { Disposable } from '../../shared/lifecycle';-import { ILogService } from '../log/log.service';import { takeAfter } from '../../shared/rxjs';-import { LifecycleNameMap, LifecycleStages, LifecycleToModules } from './lifecycle';+import { ILogService } from '../log/log.service';+import { LifecycleNameMap, LifecycleStages } from './lifecycle';/*** This service controls the lifecycle of a Univer instance. Other modules can@@ -76,33 +74,6 @@ export class LifecycleService extends Disposable {}}-/**- * This service is used to initialize modules on a certain lifecycle stage.- * Refer to `runOnLifecycle` and `OnLifecycle` for more details.- *- * @internal- */-export class LifecycleInitializerService extends Disposable {- private _seenTokens = new Set<DependencyIdentifier<unknown>>();-- constructor(- @Inject(Injector) private readonly _injector: Injector- ) {- super();- }-- initModulesOnStage(stage: LifecycleStages): void {- LifecycleToModules.get(stage)?.forEach((m) => {- if (this._injector.has(m) && !this._seenTokens.has(m)) {- this._injector.get(m);-- // swap these two lines and they will be fixed- this._seenTokens.add(m);- }- });- }-}-export function getLifecycleStagesAndBefore(lifecycleStage: LifecycleStages): Observable<LifecycleStages> {switch (lifecycleStage) {case LifecycleStages.Starting:diff --git a/packages/core/src/services/lifecycle/lifecycle.ts b/packages/core/src/services/lifecycle/lifecycle.tsindex a7278bc2e2..ec29f52928 100644--- a/packages/core/src/services/lifecycle/lifecycle.ts+++ b/packages/core/src/services/lifecycle/lifecycle.ts@@ -14,8 +14,6 @@* limitations under the License.*/-import type { Ctor, DependencyIdentifier } from '../../common/di';-/*** This enum defines multiple lifecycle stages in Univer SDK.*/@@ -48,59 +46,3 @@ export const LifecycleNameMap = {[LifecycleStages.Rendered]: 'Rendered',[LifecycleStages.Steady]: 'Steady',};--export const LifecycleToModules = new Map<LifecycleStages, Array<DependencyIdentifier<unknown>>>();--/**- * Register the decorated class to be automatically instantiated when Univer progresses to the certain lifecycle stage.- *- * @param lifecycleStage The lifecycle stage to instantiate this class.- * @param identifier The dependency identifier of the class. Usually, it is the class itself unless you bind this class- * with another injection identifier.- *- * @deprecated This API does not work as expected and will be removed in future versions. Please call- * `this._injector.get(YourDependency)` in plugins' lifecycle hooks instead.- *- * @example- * // Ignore the `\` below. This is JSDoc's bug.- * \@OnLifecycle(LifecycleStages.Ready, MyService)- * class MyService {- * }- *- * @example- * // Ignore the `\` below. This is JSDoc's bug.- * \@OnLifecycle(LifecycleStages.Rendered, IMyService)- * class MyService implements IMyService {- * }- */-export function OnLifecycle(lifecycleStage: LifecycleStages, identifier: DependencyIdentifier<unknown>) {- const decorator = function decorator(_: Ctor<unknown>) {- runOnLifecycle(lifecycleStage, identifier);- };-- return decorator;-}--/**- * Register a dependency to be automatically instantiated when Univer progresses to the certain lifecycle stage.- *- * @param lifecycleStage The lifecycle stage to instantiate this dependency.- * @param identifier The dependencies' identifier. **Beware** that if the dependency (e.g. a class) is bound to an- * identifier, you should register the identifier instead of the dependency itself.- *- * @deprecated This API does not work as expected and will be removed in future versions. Please call- * `this._injector.get(YourDependency)` in plugins' lifecycle hooks instead.- *- * @example- * runOnLifecycle(LifecycleStages.Ready, MyService);- *- * @example- * runOnLifecycle(LifecycleStages.Rendered, IMyService);- */-export function runOnLifecycle(lifecycleStage: LifecycleStages, identifier: DependencyIdentifier<unknown>) {- if (!LifecycleToModules.has(lifecycleStage)) {- LifecycleToModules.set(lifecycleStage, []);- }-- LifecycleToModules.get(lifecycleStage)!.push(identifier);-}diff --git a/packages/core/src/services/permission/permission.service.ts b/packages/core/src/services/permission/permission.service.tsindex 0e16779036..2ed94cf101 100644--- a/packages/core/src/services/permission/permission.service.ts+++ b/packages/core/src/services/permission/permission.service.ts@@ -15,10 +15,10 @@*/import type { Observable } from 'rxjs';+import type { IPermissionPoint, IPermissionService } from './type';import { BehaviorSubject, combineLatest, Subject } from 'rxjs';import { map } from 'rxjs/operators';import { Disposable } from '../../shared';-import type { IPermissionPoint, IPermissionService } from './type';import { PermissionStatus } from './type';export class PermissionService extends Disposable implements IPermissionService {diff --git a/packages/core/src/services/permission/type.ts b/packages/core/src/services/permission/type.tsindex 140696562d..1c543e22d9 100644--- a/packages/core/src/services/permission/type.ts+++ b/packages/core/src/services/permission/type.ts@@ -14,12 +14,11 @@* limitations under the License.*/-import type { BehaviorSubject, Observable } from 'rxjs';import type { UnitAction, UnitObject } from '@univerjs/protocol';-import { createIdentifier } from '../../common/di';-import { LifecycleStages, runOnLifecycle } from '../lifecycle/lifecycle';-import type { IRange } from '../../sheets/typedef';+import type { BehaviorSubject, Observable } from 'rxjs';import type { Nullable } from '../../shared/types';+import type { IRange } from '../../sheets/typedef';+import { createIdentifier } from '../../common/di';export enum PermissionStatus {INIT = 'init',@@ -66,4 +65,3 @@ export interface IPermissionService {}export const IPermissionService = createIdentifier<IPermissionService>('univer.permission-service');-runOnLifecycle(LifecycleStages.Starting, IPermissionService);diff --git a/packages/core/src/services/plugin/plugin.service.ts b/packages/core/src/services/plugin/plugin.service.tsindex d5aac0aac1..e5a22eafb8 100644--- a/packages/core/src/services/plugin/plugin.service.ts+++ b/packages/core/src/services/plugin/plugin.service.ts@@ -14,14 +14,13 @@* limitations under the License.*/-import { skip } from 'rxjs';import type { Ctor, IDisposable } from '../../common/di';+import { skip } from 'rxjs';import { Inject, Injector } from '../../common/di';--import { Disposable } from '../../shared/lifecycle';import { type UnitType, UniverInstanceType } from '../../common/unit';+import { Disposable } from '../../shared/lifecycle';import { LifecycleStages } from '../lifecycle/lifecycle';-import { getLifecycleStagesAndBefore, LifecycleInitializerService, LifecycleService } from '../lifecycle/lifecycle.service';+import { getLifecycleStagesAndBefore, LifecycleService } from '../lifecycle/lifecycle.service';import { ILogService } from '../log/log.service';import { DependentOnSymbol, Plugin, type PluginCtor, PluginRegistry, PluginStore } from './plugin';@@ -189,8 +188,7 @@ export class PluginHolder extends Disposable {private _registerPlugin: <T extends PluginCtor>(plugin: T, config?: ConstructorParameters<T>[0]) => void,@ILogService protected readonly _logService: ILogService,@Inject(Injector) protected readonly _injector: Injector,- @Inject(LifecycleService) protected readonly _lifecycleService: LifecycleService,- @Inject(LifecycleInitializerService) protected readonly _lifecycleInitializerService: LifecycleInitializerService+ @Inject(LifecycleService) protected readonly _lifecycleService: LifecycleService) {super();@@ -310,8 +308,5 @@ export class PluginHolder extends Disposable {break;}});-- // Plugins run first, and then we should run the modules.- this._lifecycleInitializerService.initModulesOnStage(stage);}}diff --git a/packages/core/src/services/resource-loader/type.ts b/packages/core/src/services/resource-loader/type.tsindex 612906b94e..e449888f30 100644--- a/packages/core/src/services/resource-loader/type.ts+++ b/packages/core/src/services/resource-loader/type.ts@@ -14,12 +14,10 @@* limitations under the License.*/-import { createIdentifier } from '../../common/di';-import { LifecycleStages, runOnLifecycle } from '../lifecycle/lifecycle';import type { IResources } from '../resource-manager/type';+import { createIdentifier } from '../../common/di';+export const IResourceLoaderService = createIdentifier<IResourceLoaderService>('resource-loader-service');export interface IResourceLoaderService {saveUnit<T = object>(unitId: string): T & { resources: IResources } | null;}-export const IResourceLoaderService = createIdentifier<IResourceLoaderService>('resource-loader-service');-runOnLifecycle(LifecycleStages.Ready, IResourceLoaderService);diff --git a/packages/core/src/services/user-manager/user-manager.service.ts b/packages/core/src/services/user-manager/user-manager.service.tsindex de54ec20dc..01f12884c8 100644--- a/packages/core/src/services/user-manager/user-manager.service.ts+++ b/packages/core/src/services/user-manager/user-manager.service.ts@@ -15,13 +15,12 @@*/import { BehaviorSubject, Subject } from 'rxjs';-import { LifecycleStages, OnLifecycle } from '../lifecycle/lifecycle';import { createDefaultUser } from './const';export interface IUser {userID: string; name: string; avatar?: string;};-@OnLifecycle(LifecycleStages.Starting, UserManagerService)+export class UserManagerService {private _model = new Map<string, IUser>();private _userChange$ = new Subject<{ type: 'add' | 'delete'; user: IUser } | { type: 'clear' }>();diff --git a/packages/core/src/univer.ts b/packages/core/src/univer.tsindex 50c0b4c412..a95d5098f7 100644--- a/packages/core/src/univer.ts+++ b/packages/core/src/univer.ts@@ -14,23 +14,33 @@* limitations under the License.*/+import type { Dependency } from './common/di';+import type { UnitModel, UnitType } from './common/unit';++import type { LogLevel } from './services/log/log.service';+import type { Plugin, PluginCtor } from './services/plugin/plugin';+import type { DependencyOverride } from './services/plugin/plugin-override';+import type { IStyleSheet } from './services/theme/theme.service';+import type { ILocales } from './shared';+import type { IWorkbookData } from './sheets/typedef';+import type { LocaleType } from './types/enum/locale-type';+import type { IDocumentData, ISlideData } from './types/interfaces';import { Injector } from './common/di';import { UniverInstanceType } from './common/unit';-import { DocumentDataModel } from './docs/data-model/document-data-model';import { AuthzIoLocalService } from './services/authz-io/authz-io-local.service';import { IAuthzIoService } from './services/authz-io/type';+import { CommandService, ICommandService } from './services/command/command.service';import { ConfigService, IConfigService } from './services/config/config.service';import { ContextService, IContextService } from './services/context/context.service';import { ErrorService } from './services/error/error.service';import { IUniverInstanceService, UniverInstanceService } from './services/instance/instance.service';import { LifecycleStages } from './services/lifecycle/lifecycle';-import { LifecycleInitializerService, LifecycleService } from './services/lifecycle/lifecycle.service';+import { LifecycleService } from './services/lifecycle/lifecycle.service';import { LocaleService } from './services/locale/locale.service';import { DesktopLogService, ILogService } from './services/log/log.service';import { PermissionService } from './services/permission/permission.service';-import { IPermissionService } from './services/permission/type';import { PluginService } from './services/plugin/plugin.service';import { mergeOverrideWithDependencies } from './services/plugin/plugin-override';@@ -43,16 +53,6 @@ import { IUndoRedoService, LocalUndoRedoService } from './services/undoredo/undoimport { UserManagerService } from './services/user-manager/user-manager.service';import { Workbook } from './sheets/workbook';import { SlideDataModel } from './slides/slide-model';-import type { Dependency } from './common/di';-import type { UnitModel, UnitType } from './common/unit';-import type { LogLevel } from './services/log/log.service';-import type { Plugin, PluginCtor } from './services/plugin/plugin';-import type { DependencyOverride } from './services/plugin/plugin-override';-import type { IStyleSheet } from './services/theme/theme.service';-import type { ILocales } from './shared';-import type { IWorkbookData } from './sheets/typedef';-import type { LocaleType } from './types/enum/locale-type';-import type { IDocumentData, ISlideData } from './types/interfaces';export interface IUniverConfig {theme: IStyleSheet;@@ -180,7 +180,6 @@ function createUniverInjector(parentInjector?: Injector, override?: DependencyOv[LocaleService],[ThemeService],[LifecycleService],- [LifecycleInitializerService],[PluginService],[UserManagerService],@@ -197,5 +196,13 @@ function createUniverInjector(parentInjector?: Injector, override?: DependencyOv[IAuthzIoService, { useClass: AuthzIoLocalService, lazy: true }],], override);- return parentInjector ? parentInjector.createChild(dependencies) : new Injector(dependencies);+ const injector = parentInjector ? parentInjector.createChild(dependencies) : new Injector(dependencies);+ inintialzeStaringModules(injector);++ return injector;+}++function inintialzeStaringModules(injector: Injector): void {+ injector.get(UserManagerService);+ injector.get(IResourceLoaderService);}diff --git a/packages/data-validation/src/controllers/dv-resource.controller.ts b/packages/data-validation/src/controllers/dv-resource.controller.tsindex eac8d95a6f..b41e7c774e 100644--- a/packages/data-validation/src/controllers/dv-resource.controller.ts+++ b/packages/data-validation/src/controllers/dv-resource.controller.ts@@ -14,15 +14,14 @@* limitations under the License.*/-import { Disposable, Inject, IResourceManagerService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';import type { ISheetDataValidationRule } from '@univerjs/core';+import { Disposable, Inject, IResourceManagerService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { DataValidationModel } from '../models/data-validation-model';type DataValidationJSON = Record<string, ISheetDataValidationRule[]>;const DATA_VALIDATION_PLUGIN_NAME = 'SHEET_DATA_VALIDATION_PLUGIN';-@OnLifecycle(LifecycleStages.Ready, DataValidationResourceController)export class DataValidationResourceController extends Disposable {constructor(@IResourceManagerService private readonly _resourceManagerService: IResourceManagerService,diff --git a/packages/data-validation/src/plugin.ts b/packages/data-validation/src/plugin.tsindex 8421eda6bc..e40f37f285 100644--- a/packages/data-validation/src/plugin.ts+++ b/packages/data-validation/src/plugin.ts@@ -14,15 +14,15 @@* limitations under the License.*/-import { ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import type { Dependency } from '@univerjs/core';+import type { IUniverDataValidationConfig } from './controllers/config.schema';+import { ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import { AddDataValidationCommand, RemoveAllDataValidationCommand, RemoveDataValidationCommand, UpdateDataValidationOptionsCommand, UpdateDataValidationSettingCommand } from './commands/commands/data-validation.command';import { AddDataValidationMutation, RemoveDataValidationMutation, UpdateDataValidationMutation } from './commands/mutations/data-validation.mutation';import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { DataValidationResourceController } from './controllers/dv-resource.controller';import { DataValidationModel } from './models/data-validation-model';import { DataValidatorRegistryService } from './services/data-validator-registry.service';-import type { IUniverDataValidationConfig } from './controllers/config.schema';const PLUGIN_NAME = 'UNIVER_DATA_VALIDATION_PLUGIN';@@ -66,4 +66,8 @@ export class UniverDataValidationPlugin extends Plugin {this._commandService.registerCommand(command);});}++ override onReady(): void {+ this._injector.get(DataValidationResourceController);+ }}diff --git a/packages/docs-drawing-ui/src/controllers/doc-drawing-notification.controller.ts b/packages/docs-drawing-ui/src/controllers/doc-drawing-notification.controller.tsindex cd7899a9f5..3af604ea6b 100644--- a/packages/docs-drawing-ui/src/controllers/doc-drawing-notification.controller.ts+++ b/packages/docs-drawing-ui/src/controllers/doc-drawing-notification.controller.ts@@ -17,21 +17,19 @@/* eslint-disable ts/no-explicit-any */import type { ICommandInfo, JSONXActions, Nullable } from '@univerjs/core';+import type { IRichTextEditingMutationParams } from '@univerjs/docs';+import type { IDocDrawing } from '@univerjs/docs-drawing';+import type { IDrawingJsonUndo1, IDrawingOrderMapParam, IDrawingSearch } from '@univerjs/drawing';import {Disposable,ICommandService,IUniverInstanceService,JSONX,- LifecycleStages,- OnLifecycle,RedoCommand,UndoCommand,} from '@univerjs/core';-import type { IRichTextEditingMutationParams } from '@univerjs/docs';import { RichTextEditingMutation } from '@univerjs/docs';-import type { IDocDrawing } from '@univerjs/docs-drawing';import { IDocDrawingService } from '@univerjs/docs-drawing';-import type { IDrawingJsonUndo1, IDrawingOrderMapParam, IDrawingSearch } from '@univerjs/drawing';import { IDrawingManagerService } from '@univerjs/drawing';import { IRenderManagerService } from '@univerjs/engine-render';@@ -117,7 +115,6 @@ function getReOrderedDrawings(actions: JSONXActions): number[] {return drawingIndexes;}-@OnLifecycle(LifecycleStages.Ready, DocDrawingAddRemoveController)export class DocDrawingAddRemoveController extends Disposable {constructor(@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,diff --git a/packages/docs-drawing-ui/src/controllers/doc-drawing-transformer-update.controller.ts b/packages/docs-drawing-ui/src/controllers/doc-drawing-transformer-update.controller.tsindex ae4276f1df..9605cf72ef 100644--- a/packages/docs-drawing-ui/src/controllers/doc-drawing-transformer-update.controller.ts+++ b/packages/docs-drawing-ui/src/controllers/doc-drawing-transformer-update.controller.ts@@ -14,20 +14,20 @@* limitations under the License.*/+import type { IDocDrawingBase, IDocDrawingPosition, Nullable } from '@univerjs/core';+import type { BaseObject, Documents, IDocumentSkeletonGlyph, IDocumentSkeletonPage, Image, INodeSearch, IPoint, Viewport } from '@univerjs/engine-render';+import type { IDrawingDocTransform } from '../commands/commands/update-doc-drawing.command';import {BooleanNumber,COLORS,- Disposable, ICommandService, IUniverInstanceService, LifecycleStages, ObjectRelativeFromH, ObjectRelativeFromV,- OnLifecycle, PositionedObjectLayoutType, throttle, toDisposable, Tools,+ Disposable, ICommandService, IUniverInstanceService, ObjectRelativeFromH, ObjectRelativeFromV,+ PositionedObjectLayoutType, throttle, toDisposable, Tools,} from '@univerjs/core';import { DocSkeletonManagerService } from '@univerjs/docs';import { DocSelectionRenderService, getAnchorBounding, getDocObject, getOneTextSelectionRange, NodePositionConvertToCursor, TEXT_RANGE_LAYER_INDEX } from '@univerjs/docs-ui';import { IDrawingManagerService } from '@univerjs/drawing';import { DocumentSkeletonPageType, getColor, IRenderManagerService, Liquid, PageLayoutType, Rect, Vector2 } from '@univerjs/engine-render';-import type { IDocDrawingBase, IDocDrawingPosition, Nullable } from '@univerjs/core';-import type { BaseObject, Documents, IDocumentSkeletonGlyph, IDocumentSkeletonPage, Image, INodeSearch, IPoint, Viewport } from '@univerjs/engine-render';import { IMoveInlineDrawingCommand, ITransformNonInlineDrawingCommand, UpdateDrawingDocTransformCommand } from '../commands/commands/update-doc-drawing.command';-import type { IDrawingDocTransform } from '../commands/commands/update-doc-drawing.command';const INLINE_DRAWING_ANCHOR_KEY_PREFIX = '__InlineDrawingAnchor__';@@ -55,8 +55,6 @@ function isInTableCell(nodePosition: INodeSearch) {}// Listen doc drawing transformer change, and update drawing data.--@OnLifecycle(LifecycleStages.Rendered, DocDrawingTransformerController)export class DocDrawingTransformerController extends Disposable {private _liquid = new Liquid();private _listenerOnImageMap = new Set();diff --git a/packages/docs-drawing-ui/src/controllers/doc-drawing.controller.ts b/packages/docs-drawing-ui/src/controllers/doc-drawing.controller.tsindex 6133d13303..3e19932101 100644--- a/packages/docs-drawing-ui/src/controllers/doc-drawing.controller.ts+++ b/packages/docs-drawing-ui/src/controllers/doc-drawing.controller.ts@@ -14,30 +14,29 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';-import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';-+import { Disposable, ICommandService, Inject } from '@univerjs/core';import { AddImageSingle } from '@univerjs/icons';-import { ImageUploadIcon } from '../views/menu/image.menu';-import { COMPONENT_DOC_DRAWING_PANEL } from '../views/doc-image-panel/component-name';-import { DocDrawingPanel } from '../views/doc-image-panel/DocDrawingPanel';-import { ClearDocDrawingTransformerOperation } from '../commands/operations/clear-drawing-transformer.operation';-import { EditDocDrawingOperation } from '../commands/operations/edit-doc-drawing.operation';-import { SidebarDocDrawingOperation } from '../commands/operations/open-drawing-panel.operation';-import { MoveDocDrawingsCommand } from '../commands/commands/move-drawings.command';+import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';import { DeleteDocDrawingsCommand } from '../commands/commands/delete-doc-drawing.command';-import { SetDocDrawingArrangeCommand } from '../commands/commands/set-drawing-arrange.command';-import { RemoveDocDrawingCommand } from '../commands/commands/remove-doc-drawing.command';-import { UngroupDocDrawingCommand } from '../commands/commands/ungroup-doc-drawing.command';import { GroupDocDrawingCommand } from '../commands/commands/group-doc-drawing.command';import { InsertDocDrawingCommand } from '../commands/commands/insert-doc-drawing.command';-import { IMoveInlineDrawingCommand, ITransformNonInlineDrawingCommand, UpdateDocDrawingDistanceCommand, UpdateDocDrawingWrappingStyleCommand, UpdateDocDrawingWrapTextCommand, UpdateDrawingDocTransformCommand } from '../commands/commands/update-doc-drawing.command';+import { InsertDocImageCommand } from '../commands/commands/insert-image.command';-import { DeleteDrawingsShortcutItem, MoveDrawingDownShortcutItem, MoveDrawingLeftShortcutItem, MoveDrawingRightShortcutItem, MoveDrawingUpShortcutItem } from './shortcuts/drawing.shortcut';+import { MoveDocDrawingsCommand } from '../commands/commands/move-drawings.command';+import { RemoveDocDrawingCommand } from '../commands/commands/remove-doc-drawing.command';+import { SetDocDrawingArrangeCommand } from '../commands/commands/set-drawing-arrange.command';+import { UngroupDocDrawingCommand } from '../commands/commands/ungroup-doc-drawing.command';+import { IMoveInlineDrawingCommand, ITransformNonInlineDrawingCommand, UpdateDocDrawingDistanceCommand, UpdateDocDrawingWrappingStyleCommand, UpdateDocDrawingWrapTextCommand, UpdateDrawingDocTransformCommand } from '../commands/commands/update-doc-drawing.command';+import { ClearDocDrawingTransformerOperation } from '../commands/operations/clear-drawing-transformer.operation';+import { EditDocDrawingOperation } from '../commands/operations/edit-doc-drawing.operation';+import { SidebarDocDrawingOperation } from '../commands/operations/open-drawing-panel.operation';+import { COMPONENT_DOC_DRAWING_PANEL } from '../views/doc-image-panel/component-name';+import { DocDrawingPanel } from '../views/doc-image-panel/DocDrawingPanel';+import { ImageUploadIcon } from '../views/menu/image.menu';import { menuSchema } from './menu.schema';+import { DeleteDrawingsShortcutItem, MoveDrawingDownShortcutItem, MoveDrawingLeftShortcutItem, MoveDrawingRightShortcutItem, MoveDrawingUpShortcutItem } from './shortcuts/drawing.shortcut';-@OnLifecycle(LifecycleStages.Ready, DocDrawingUIController)export class DocDrawingUIController extends Disposable {constructor(@Inject(ComponentManager) private readonly _componentManager: ComponentManager,diff --git a/packages/docs-drawing-ui/src/controllers/drawing-popup-menu.controller.ts b/packages/docs-drawing-ui/src/controllers/drawing-popup-menu.controller.tsindex 65ffa69e7f..fd75aed469 100644--- a/packages/docs-drawing-ui/src/controllers/drawing-popup-menu.controller.ts+++ b/packages/docs-drawing-ui/src/controllers/drawing-popup-menu.controller.ts@@ -15,17 +15,16 @@*/import type { DocumentDataModel, IDisposable, Nullable } from '@univerjs/core';-import { FOCUSING_COMMON_DRAWINGS, IContextService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, RxDisposable, toDisposable, UniverInstanceType } from '@univerjs/core';import type { BaseObject, Scene } from '@univerjs/engine-render';-import { IRenderManagerService } from '@univerjs/engine-render';-import { COMPONENT_IMAGE_POPUP_MENU, ImageCropperObject, ImageResetSizeOperation, OpenImageCropOperation } from '@univerjs/drawing-ui';-import { takeUntil } from 'rxjs';+import { FOCUSING_COMMON_DRAWINGS, IContextService, Inject, IUniverInstanceService, RxDisposable, toDisposable, UniverInstanceType } from '@univerjs/core';import { DocCanvasPopManagerService } from '@univerjs/docs-ui';import { IDrawingManagerService } from '@univerjs/drawing';+import { COMPONENT_IMAGE_POPUP_MENU, ImageCropperObject, ImageResetSizeOperation, OpenImageCropOperation } from '@univerjs/drawing-ui';+import { IRenderManagerService } from '@univerjs/engine-render';+import { takeUntil } from 'rxjs';import { RemoveDocDrawingCommand } from '../commands/commands/remove-doc-drawing.command';import { EditDocDrawingOperation } from '../commands/operations/edit-doc-drawing.operation';-@OnLifecycle(LifecycleStages.Rendered, DocDrawingPopupMenuController)export class DocDrawingPopupMenuController extends RxDisposable {private _initImagePopupMenu = new Set<string>();diff --git a/packages/docs-drawing-ui/src/controllers/render-controllers/doc-drawing-update.render-controller.ts b/packages/docs-drawing-ui/src/controllers/render-controllers/doc-drawing-update.render-controller.tsindex 38dedeaccb..33c255c03c 100644--- a/packages/docs-drawing-ui/src/controllers/render-controllers/doc-drawing-update.render-controller.ts+++ b/packages/docs-drawing-ui/src/controllers/render-controllers/doc-drawing-update.render-controller.ts@@ -14,6 +14,11 @@* limitations under the License.*/+import type { DocumentDataModel, ICommandInfo, IDocDrawingPosition, Nullable } from '@univerjs/core';+import type { IDocDrawing } from '@univerjs/docs-drawing';+import type { IImageIoServiceParam } from '@univerjs/drawing';+import type { Documents, Image, IRenderContext, IRenderModule } from '@univerjs/engine-render';+import type { IInsertDrawingCommandParams } from '../../commands/commands/interfaces';import { BooleanNumber, Disposable, FOCUSING_COMMON_DRAWINGS, ICommandService, IContextService, Inject, LocaleService, ObjectRelativeFromH, ObjectRelativeFromV, PositionedObjectLayoutType, WrapTextType } from '@univerjs/core';import { MessageType } from '@univerjs/design';import { DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation } from '@univerjs/docs';@@ -21,18 +26,13 @@ import { IDocDrawingService } from '@univerjs/docs-drawing';import { docDrawingPositionToTransform, DocSelectionRenderService } from '@univerjs/docs-ui';import { DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_ALLOW_SIZE, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, DrawingTypeEnum, getDrawingShapeKeyByDrawingSearch, getImageSize, IDrawingManagerService, IImageIoService, ImageUploadStatusType } from '@univerjs/drawing';import { DocumentEditArea, IRenderManagerService } from '@univerjs/engine-render';-import { ILocalFileService, IMessageService } from '@univerjs/ui';-import type { DocumentDataModel, ICommandInfo, IDocDrawingPosition, Nullable } from '@univerjs/core';-import type { IDocDrawing } from '@univerjs/docs-drawing';-import type { IImageIoServiceParam } from '@univerjs/drawing';-import type { Documents, Image, IRenderContext, IRenderModule } from '@univerjs/engine-render';+import { ILocalFileService, IMessageService } from '@univerjs/ui';import { GroupDocDrawingCommand } from '../../commands/commands/group-doc-drawing.command';import { InsertDocDrawingCommand } from '../../commands/commands/insert-doc-drawing.command';import { type ISetDrawingArrangeCommandParams, SetDocDrawingArrangeCommand } from '../../commands/commands/set-drawing-arrange.command';import { UngroupDocDrawingCommand } from '../../commands/commands/ungroup-doc-drawing.command';import { DocRefreshDrawingsService } from '../../services/doc-refresh-drawings.service';-import type { IInsertDrawingCommandParams } from '../../commands/commands/interfaces';export class DocDrawingUpdateRenderController extends Disposable implements IRenderModule {constructor(diff --git a/packages/docs-drawing-ui/src/plugin.ts b/packages/docs-drawing-ui/src/plugin.tsindex 60de399b9c..a024d34fa8 100644--- a/packages/docs-drawing-ui/src/plugin.ts+++ b/packages/docs-drawing-ui/src/plugin.ts@@ -14,25 +14,26 @@* limitations under the License.*/-import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import type { Dependency } from '@univerjs/core';-import { UniverDrawingUIPlugin } from '@univerjs/drawing-ui';-import { UniverDrawingPlugin } from '@univerjs/drawing';+import type { IUniverDocsDrawingUIConfig } from './controllers/config.schema';+import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import { UniverDocsDrawingPlugin } from '@univerjs/docs-drawing';+import { UniverDrawingPlugin } from '@univerjs/drawing';+import { UniverDrawingUIPlugin } from '@univerjs/drawing-ui';import { IRenderManagerService } from '@univerjs/engine-render';-import { DocDrawingPopupMenuController } from './controllers/drawing-popup-menu.controller';+import { UniverUIPlugin } from '@univerjs/ui';+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { DocDrawingUIController } from './controllers/doc-drawing.controller';-import { DocDrawingUpdateRenderController } from './controllers/render-controllers/doc-drawing-update.render-controller';-import { DocDrawingTransformUpdateController } from './controllers/render-controllers/doc-drawing-transform-update.controller';import { DocDrawingAddRemoveController } from './controllers/doc-drawing-notification.controller';import { DocDrawingTransformerController } from './controllers/doc-drawing-transformer-update.controller';+import { DocDrawingPopupMenuController } from './controllers/drawing-popup-menu.controller';+import { DocDrawingTransformUpdateController } from './controllers/render-controllers/doc-drawing-transform-update.controller';+import { DocDrawingUpdateRenderController } from './controllers/render-controllers/doc-drawing-update.render-controller';import { DocRefreshDrawingsService } from './services/doc-refresh-drawings.service';-import type { IUniverDocsDrawingUIConfig } from './controllers/config.schema';-import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';const PLUGIN_NAME = 'DOC_DRAWING_UI_PLUGIN';-@DependentOn(UniverDrawingUIPlugin, UniverDrawingPlugin, UniverDocsDrawingPlugin)+@DependentOn(UniverDrawingUIPlugin, UniverDrawingPlugin, UniverDocsDrawingPlugin, UniverUIPlugin)export class UniverDocsDrawingUIPlugin extends Plugin {static override type = UniverInstanceType.UNIVER_DOC;static override pluginName = PLUGIN_NAME;@@ -67,5 +68,12 @@ export class UniverDocsDrawingUIPlugin extends Plugin {[DocDrawingUpdateRenderController],[DocDrawingTransformUpdateController],] as Dependency[]).forEach((m) => this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, m));++ this._injector.get(DocDrawingAddRemoveController);+ this._injector.get(DocDrawingUIController);+ }++ override onRendered(): void {+ this._injector.get(DocDrawingPopupMenuController);}}diff --git a/packages/docs-drawing/src/controllers/doc-drawing.controller.ts b/packages/docs-drawing/src/controllers/doc-drawing.controller.tsindex 224a1776ab..0b910a578f 100644--- a/packages/docs-drawing/src/controllers/doc-drawing.controller.ts+++ b/packages/docs-drawing/src/controllers/doc-drawing.controller.ts@@ -14,25 +14,15 @@* limitations under the License.*/-import { Disposable, ICommandService, IResourceManagerService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';-import { IDrawingManagerService } from '@univerjs/drawing';import type { DocumentDataModel, IDocumentData } from '@univerjs/core';import type { IDrawingMapItem, IDrawingMapItemData } from '@univerjs/drawing';+import { Disposable, IResourceManagerService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';+import { IDrawingManagerService } from '@univerjs/drawing';import { type IDocDrawing, IDocDrawingService } from '../services/doc-drawing.service';export const DOCS_DRAWING_PLUGIN = 'DOC_DRAWING_PLUGIN';export interface IDocDrawingModel { drawings?: IDocumentData['drawings']; drawingsOrder?: IDocumentData['drawingsOrder'] };-@OnLifecycle(LifecycleStages.Starting, DocDrawingLoadController)-export class DocDrawingLoadController extends Disposable {- constructor(- @ICommandService private readonly _commandService: ICommandService- ) {- super();- }-}--@OnLifecycle(LifecycleStages.Starting, DocDrawingController)export class DocDrawingController extends Disposable {constructor(@IDocDrawingService private readonly _docDrawingService: IDocDrawingService,diff --git a/packages/docs-drawing/src/plugin.ts b/packages/docs-drawing/src/plugin.tsindex cd44529636..0b75f743e5 100644--- a/packages/docs-drawing/src/plugin.ts+++ b/packages/docs-drawing/src/plugin.ts@@ -14,12 +14,12 @@* limitations under the License.*/-import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import type { Dependency } from '@univerjs/core';-import { DocDrawingController, DocDrawingLoadController, DOCS_DRAWING_PLUGIN } from './controllers/doc-drawing.controller';-import { DocDrawingService, IDocDrawingService } from './services/doc-drawing.service';import type { IUniverDocsDrawingConfig } from './controllers/config.schema';+import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';+import { DocDrawingController, DOCS_DRAWING_PLUGIN } from './controllers/doc-drawing.controller';+import { DocDrawingService, IDocDrawingService } from './services/doc-drawing.service';export class UniverDocsDrawingPlugin extends Plugin {static override pluginName = DOCS_DRAWING_PLUGIN;@@ -39,12 +39,13 @@ export class UniverDocsDrawingPlugin extends Plugin {override onStarting(): void {([- [DocDrawingLoadController],[DocDrawingController],[DocDrawingService],[IDocDrawingService, { useClass: DocDrawingService }],] as Dependency[]).forEach((dependency) => this._injector.add(dependency));++ this._injector.get(DocDrawingController);}}diff --git a/packages/docs-hyper-link-ui/src/controllers/doc-hyper-link-selection.controller.ts b/packages/docs-hyper-link-ui/src/controllers/doc-hyper-link-selection.controller.tsindex 426843130a..c0e02abdd2 100644--- a/packages/docs-hyper-link-ui/src/controllers/doc-hyper-link-selection.controller.ts+++ b/packages/docs-hyper-link-ui/src/controllers/doc-hyper-link-selection.controller.ts@@ -15,12 +15,11 @@*/import type { DocumentDataModel } from '@univerjs/core';-import { Disposable, ICommandService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';import type { ISetTextSelectionsOperationParams } from '@univerjs/docs';+import { Disposable, ICommandService, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { SetTextSelectionsOperation } from '@univerjs/docs';import { DocHyperLinkPopupService } from '../services/hyper-link-popup.service';-@OnLifecycle(LifecycleStages.Ready, DocHyperLinkSelectionController)export class DocHyperLinkSelectionController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/docs-hyper-link-ui/src/controllers/ui.controller.ts b/packages/docs-hyper-link-ui/src/controllers/ui.controller.tsindex ca2e182ff6..62d69fccd1 100644--- a/packages/docs-hyper-link-ui/src/controllers/ui.controller.ts+++ b/packages/docs-hyper-link-ui/src/controllers/ui.controller.ts@@ -14,15 +14,15 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';import type { MenuConfig } from '@univerjs/ui';-import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';+import { Disposable, ICommandService, Inject } from '@univerjs/core';import { LinkSingle } from '@univerjs/icons';-import { DocHyperLinkEdit } from '../views/hyper-link-edit';+import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';import { AddDocHyperLinkCommand } from '../commands/commands/add-link.command';-import { UpdateDocHyperLinkCommand } from '../commands/commands/update-link.command';import { DeleteDocHyperLinkCommand } from '../commands/commands/delete-link.command';+import { UpdateDocHyperLinkCommand } from '../commands/commands/update-link.command';import { ClickDocHyperLinkOperation, ShowDocHyperLinkEditPopupOperation, ToggleDocHyperLinkInfoPopupOperation } from '../commands/operations/popup.operation';+import { DocHyperLinkEdit } from '../views/hyper-link-edit';import { DocLinkPopup } from '../views/hyper-link-popup';import { addLinkShortcut, DOC_LINK_ICON } from './menu';import { menuSchema } from './menu.schema';@@ -31,13 +31,11 @@ export interface IDocHyperLinkUIConfig {menu: MenuConfig;}-@OnLifecycle(LifecycleStages.Starting, DocHyperLinkUIController)export class DocHyperLinkUIController extends Disposable {constructor(@Inject(ComponentManager) private readonly _componentManager: ComponentManager,@ICommandService private readonly _commandService: ICommandService,@IMenuManagerService private readonly _menuManagerService: IMenuManagerService,- @Inject(Injector) private readonly _injector: Injector,@IShortcutService private readonly _shortcutService: IShortcutService) {super();diff --git a/packages/docs-hyper-link-ui/src/plugin.ts b/packages/docs-hyper-link-ui/src/plugin.tsindex 73c9c43019..9ec442f4c3 100644--- a/packages/docs-hyper-link-ui/src/plugin.ts+++ b/packages/docs-hyper-link-ui/src/plugin.ts@@ -14,10 +14,11 @@* limitations under the License.*/+import type { Dependency } from '@univerjs/core';+import type { IUniverDocsHyperLinkUIConfig } from './controllers/config.schema';import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import { UniverDocsHyperLinkPlugin } from '@univerjs/docs-hyper-link';import { IRenderManagerService } from '@univerjs/engine-render';-import type { Dependency } from '@univerjs/core';import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { DocHyperLinkSelectionController } from './controllers/doc-hyper-link-selection.controller';import { DocHyperLinkEventRenderController } from './controllers/render-controllers/hyper-link-event.render-controller';@@ -25,7 +26,6 @@ import { DocHyperLinkRenderController } from './controllers/render-controllers/rimport { DocHyperLinkUIController } from './controllers/ui.controller';import { DocHyperLinkPopupService } from './services/hyper-link-popup.service';import { DOC_HYPER_LINK_UI_PLUGIN } from './types/const';-import type { IUniverDocsHyperLinkUIConfig } from './controllers/config.schema';@DependentOn(UniverDocsHyperLinkPlugin)export class UniverDocsHyperLinkUIPlugin extends Plugin {@@ -54,10 +54,15 @@ export class UniverDocsHyperLinkUIPlugin extends Plugin {[DocHyperLinkUIController],[DocHyperLinkSelectionController],];-deps.forEach((dep) => {this._injector.add(dep);});++ this._injector.get(DocHyperLinkUIController);+ }++ override onReady(): void {+ this._injector.get(DocHyperLinkSelectionController);}override onRendered(): void {diff --git a/packages/docs-hyper-link/src/controllers/resource.controller.ts b/packages/docs-hyper-link/src/controllers/resource.controller.tsindex 6cd0c362b6..67094736fb 100644--- a/packages/docs-hyper-link/src/controllers/resource.controller.ts+++ b/packages/docs-hyper-link/src/controllers/resource.controller.ts@@ -15,7 +15,7 @@*/import type { DocumentDataModel, ICustomRange } from '@univerjs/core';-import { CustomRangeType, Disposable, Inject, IResourceManagerService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import { CustomRangeType, Disposable, Inject, IResourceManagerService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';export const DOC_HYPER_LINK_PLUGIN = 'DOC_HYPER_LINK_PLUGIN';@@ -23,7 +23,6 @@ interface IDocHyperLinkJSON {links: { id: string; payload: string }[];}-@OnLifecycle(LifecycleStages.Starting, DocHyperLinkResourceController)export class DocHyperLinkResourceController extends Disposable {constructor(@Inject(IResourceManagerService) private readonly _resourceManagerService: IResourceManagerService,diff --git a/packages/docs-hyper-link/src/plugin.ts b/packages/docs-hyper-link/src/plugin.tsindex 1c5d957947..5428c85daf 100644--- a/packages/docs-hyper-link/src/plugin.ts+++ b/packages/docs-hyper-link/src/plugin.ts@@ -14,12 +14,12 @@* limitations under the License.*/-import { ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import type { Dependency } from '@univerjs/core';+import type { IUniverDocsHyperLinkConfig } from './controllers/config.schema';+import { ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import { AddHyperLinkMuatation, DeleteHyperLinkMuatation, UpdateHyperLinkMuatation } from './commands/mutations/hyper-link.mutation';import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { DOC_HYPER_LINK_PLUGIN, DocHyperLinkResourceController } from './controllers/resource.controller';-import type { IUniverDocsHyperLinkConfig } from './controllers/config.schema';export class UniverDocsHyperLinkPlugin extends Plugin {static override pluginName = DOC_HYPER_LINK_PLUGIN;@@ -39,16 +39,13 @@ export class UniverDocsHyperLinkPlugin extends Plugin {}override onStarting(): void {- const deps: Dependency[] = [- [DocHyperLinkResourceController],- ];-- deps.forEach((dep) => {- this._injector.add(dep);- });+ const deps: Dependency[] = [[DocHyperLinkResourceController]];+ deps.forEach((dep) => this._injector.add(dep));[AddHyperLinkMuatation, DeleteHyperLinkMuatation, UpdateHyperLinkMuatation].forEach((mutation) => {this.disposeWithMe(this._commandService.registerCommand(mutation));});++ this._injector.get(DocHyperLinkResourceController);}}diff --git a/packages/docs-mention-ui/src/controllers/doc-mention-trigger.controller.ts b/packages/docs-mention-ui/src/controllers/doc-mention-trigger.controller.tsindex e0cb6fbb16..0b681f593a 100644--- a/packages/docs-mention-ui/src/controllers/doc-mention-trigger.controller.ts+++ b/packages/docs-mention-ui/src/controllers/doc-mention-trigger.controller.ts@@ -14,15 +14,14 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle, Tools } from '@univerjs/core';+import type { IInsertCommandParams } from '@univerjs/docs-ui';+import { Disposable, ICommandService, Inject, Tools } from '@univerjs/core';import { DocSelectionManagerService } from '@univerjs/docs';import { DeleteLeftCommand, InsertCommand, MoveCursorOperation } from '@univerjs/docs-ui';-import type { IInsertCommandParams } from '@univerjs/docs-ui';import { CloseMentionEditPopupOperation, ShowMentionEditPopupOperation } from '../commands/operations/mention-popup.operation';import { DocMentionService } from '../services/doc-mention.service';import { DocMentionPopupService } from '../services/doc-mention-popup.service';-@OnLifecycle(LifecycleStages.Rendered, DocMentionTriggerController)export class DocMentionTriggerController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/docs-mention-ui/src/controllers/doc-mention-ui.controller.ts b/packages/docs-mention-ui/src/controllers/doc-mention-ui.controller.tsindex ddeea690c8..4b694b6935 100644--- a/packages/docs-mention-ui/src/controllers/doc-mention-ui.controller.ts+++ b/packages/docs-mention-ui/src/controllers/doc-mention-ui.controller.ts@@ -14,13 +14,12 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, ICommandService, Inject } from '@univerjs/core';import { ComponentManager } from '@univerjs/ui';+import { AddDocMentionCommand, DeleteDocMentionCommand } from '../commands/commands/doc-mention.command';import { CloseMentionEditPopupOperation, CloseMentionInfoPopupOperation, ShowMentionEditPopupOperation, ShowMentionInfoPopupOperation } from '../commands/operations/mention-popup.operation';import { MentionEditPopup } from '../views/mention-edit-popup';-import { AddDocMentionCommand, DeleteDocMentionCommand } from '../commands/commands/doc-mention.command';-@OnLifecycle(LifecycleStages.Starting, DocMentionUIController)export class DocMentionUIController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/docs-mention-ui/src/plugin.ts b/packages/docs-mention-ui/src/plugin.tsindex 2f7fb144a9..9858b09647 100644--- a/packages/docs-mention-ui/src/plugin.ts+++ b/packages/docs-mention-ui/src/plugin.ts@@ -14,15 +14,15 @@* limitations under the License.*/-import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import type { Dependency } from '@univerjs/core';-import { DOC_MENTION_UI_PLUGIN } from './types/const/const';-import { DocMentionPopupService } from './services/doc-mention-popup.service';-import { DocMentionUIController } from './controllers/doc-mention-ui.controller';-import { DocMentionTriggerController } from './controllers/doc-mention-trigger.controller';-import { DocMentionService } from './services/doc-mention.service';import type { IUniverDocsMentionUIConfig } from './controllers/config.schema';+import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';+import { DocMentionTriggerController } from './controllers/doc-mention-trigger.controller';+import { DocMentionUIController } from './controllers/doc-mention-ui.controller';+import { DocMentionService } from './services/doc-mention.service';+import { DocMentionPopupService } from './services/doc-mention-popup.service';+import { DOC_MENTION_UI_PLUGIN } from './types/const/const';export class UniverDocsMentionUIPlugin extends Plugin {static override pluginName = DOC_MENTION_UI_PLUGIN;@@ -44,15 +44,20 @@ export class UniverDocsMentionUIPlugin extends Plugin {}override onStarting(): void {- const deps: Dependency[] = [+ ([[DocMentionService],[DocMentionPopupService],[DocMentionUIController],[DocMentionTriggerController],- ];-- deps.forEach((dep) => {+ ] as Dependency[]).forEach((dep) => {this._injector.add(dep);});++ this._injector.get(DocMentionUIController);+ }++ override onRendered(): void {+ this._injector.get(DocMentionTriggerController);+ this._injector.get(DocMentionPopupService);}}diff --git a/packages/docs-mention-ui/src/services/doc-mention-popup.service.ts b/packages/docs-mention-ui/src/services/doc-mention-popup.service.tsindex ceb7fb21b6..9e3c5024d8 100644--- a/packages/docs-mention-ui/src/services/doc-mention-popup.service.ts+++ b/packages/docs-mention-ui/src/services/doc-mention-popup.service.ts@@ -15,13 +15,12 @@*/import type { IDisposable, Nullable } from '@univerjs/core';-import { Disposable, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, Inject } from '@univerjs/core';import { DocCanvasPopManagerService } from '@univerjs/docs-ui';import { BehaviorSubject } from 'rxjs';import { MentionEditPopup } from '../views/mention-edit-popup';import { DocMentionService } from './doc-mention.service';-@OnLifecycle(LifecycleStages.Rendered, DocMentionPopupService)export class DocMentionPopupService extends Disposable {private readonly _infoPopup$ = new BehaviorSubject(undefined);readonly infoPopup$ = this._infoPopup$.asObservable();diff --git a/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-selection.controller.ts b/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-selection.controller.tsindex 7688d7ba38..496f1fc7b8 100644--- a/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-selection.controller.ts+++ b/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-selection.controller.ts@@ -14,20 +14,19 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import type { DocumentDataModel, ITextRange } from '@univerjs/core';+import type { ISetTextSelectionsOperationParams } from '@univerjs/docs';+import type { ITextRangeWithStyle } from '@univerjs/engine-render';+import { Disposable, ICommandService, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { SetTextSelectionsOperation } from '@univerjs/docs';import { DocBackScrollRenderController } from '@univerjs/docs-ui';import { IRenderManagerService } from '@univerjs/engine-render';import { ThreadCommentModel } from '@univerjs/thread-comment';import { SetActiveCommentOperation, ThreadCommentPanelService } from '@univerjs/thread-comment-ui';-import type { DocumentDataModel, ITextRange } from '@univerjs/core';-import type { ISetTextSelectionsOperationParams } from '@univerjs/docs';-import type { ITextRangeWithStyle } from '@univerjs/engine-render';import { ShowCommentPanelOperation } from '../commands/operations/show-comment-panel.operation';import { DEFAULT_DOC_SUBUNIT_ID } from '../common/const';import { DocThreadCommentService } from '../services/doc-thread-comment.service';-@OnLifecycle(LifecycleStages.Rendered, DocThreadCommentSelectionController)export class DocThreadCommentSelectionController extends Disposable {constructor(@Inject(ThreadCommentPanelService) private readonly _threadCommentPanelService: ThreadCommentPanelService,diff --git a/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-ui.controller.ts b/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-ui.controller.tsindex 2dfec8805d..80c20f79e3 100644--- a/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-ui.controller.ts+++ b/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-ui.controller.ts@@ -14,16 +14,15 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';-import { ComponentManager, IMenuManagerService } from '@univerjs/ui';+import { Disposable, ICommandService, Inject } from '@univerjs/core';import { CommentSingle } from '@univerjs/icons';+import { ComponentManager, IMenuManagerService } from '@univerjs/ui';import { AddDocCommentComment } from '../commands/commands/add-doc-comment.command';-import { DocThreadCommentPanel } from '../views/doc-thread-comment-panel';-import { ShowCommentPanelOperation, StartAddCommentOperation, ToggleCommentPanelOperation } from '../commands/operations/show-comment-panel.operation';import { DeleteDocCommentComment } from '../commands/commands/delete-doc-comment.command';+import { ShowCommentPanelOperation, StartAddCommentOperation, ToggleCommentPanelOperation } from '../commands/operations/show-comment-panel.operation';+import { DocThreadCommentPanel } from '../views/doc-thread-comment-panel';import { menuSchema } from './menu.schema';-@OnLifecycle(LifecycleStages.Rendered, DocThreadCommentUIController)export class DocThreadCommentUIController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/docs-thread-comment-ui/src/controllers/render-controllers/render.controller.ts b/packages/docs-thread-comment-ui/src/controllers/render-controllers/render.controller.tsindex 39f0e6cc09..ff56b3f00f 100644--- a/packages/docs-thread-comment-ui/src/controllers/render-controllers/render.controller.ts+++ b/packages/docs-thread-comment-ui/src/controllers/render-controllers/render.controller.ts@@ -15,15 +15,14 @@*/import type { DocumentDataModel } from '@univerjs/core';-import { Disposable, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';+import { Disposable, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { DOC_INTERCEPTOR_POINT, DocInterceptorService } from '@univerjs/docs';import { DocRenderController } from '@univerjs/docs-ui';-import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';import { ThreadCommentModel } from '@univerjs/thread-comment';import { ThreadCommentPanelService } from '@univerjs/thread-comment-ui';import { DEFAULT_DOC_SUBUNIT_ID } from '../../common/const';-@OnLifecycle(LifecycleStages.Starting, DocThreadCommentRenderController)export class DocThreadCommentRenderController extends Disposable implements IRenderModule {constructor(private readonly _context: IRenderContext<DocumentDataModel>,diff --git a/packages/docs-thread-comment-ui/src/plugin.ts b/packages/docs-thread-comment-ui/src/plugin.tsindex 862d556610..7302124c06 100644--- a/packages/docs-thread-comment-ui/src/plugin.ts+++ b/packages/docs-thread-comment-ui/src/plugin.ts@@ -14,17 +14,17 @@* limitations under the License.*/-import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import type { Dependency } from '@univerjs/core';-import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';+import type { IUniverDocsThreadCommentUIConfig } from './controllers/config.schema';+import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import { IRenderManagerService } from '@univerjs/engine-render';+import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';import { PLUGIN_NAME } from './common/const';-import { DocThreadCommentUIController } from './controllers/doc-thread-comment-ui.controller';-import { DocThreadCommentService } from './services/doc-thread-comment.service';+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { DocThreadCommentSelectionController } from './controllers/doc-thread-comment-selection.controller';+import { DocThreadCommentUIController } from './controllers/doc-thread-comment-ui.controller';import { DocThreadCommentRenderController } from './controllers/render-controllers/render.controller';-import type { IUniverDocsThreadCommentUIConfig } from './controllers/config.schema';-import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';+import { DocThreadCommentService } from './services/doc-thread-comment.service';@DependentOn(UniverThreadCommentUIPlugin)export class UniverDocsThreadCommentUIPlugin extends Plugin {@@ -51,7 +51,6 @@ export class UniverDocsThreadCommentUIPlugin extends Plugin {([[DocThreadCommentUIController],[DocThreadCommentSelectionController],-[DocThreadCommentService],] as Dependency[]).forEach((dep) => {this._injector.add(dep);@@ -60,6 +59,9 @@ export class UniverDocsThreadCommentUIPlugin extends Plugin {override onRendered(): void {this._initRenderModule();++ this._injector.get(DocThreadCommentSelectionController);+ this._injector.get(DocThreadCommentUIController);}private _initRenderModule() {diff --git a/packages/docs-ui/src/commands/commands/__tests__/create-command-test-bed.ts b/packages/docs-ui/src/commands/commands/__tests__/create-command-test-bed.tsindex 61d556a2d0..753d70db1f 100644--- a/packages/docs-ui/src/commands/commands/__tests__/create-command-test-bed.ts+++ b/packages/docs-ui/src/commands/commands/__tests__/create-command-test-bed.ts@@ -16,6 +16,8 @@/* eslint-disable ts/no-explicit-any */+import type { Ctor, Dependency, DependencyIdentifier, DocumentDataModel, IDocumentData, Nullable } from '@univerjs/core';+import type { DocumentSkeleton, IRender, IRenderContext, IRenderModule } from '@univerjs/engine-render';import {BooleanNumber,DOCS_NORMAL_EDITOR_UNIT_ID_KEY,@@ -31,11 +33,9 @@ import {UniverInstanceType,} from '@univerjs/core';import { DocSelectionManagerService, DocSkeletonManagerService, DocStateEmitService } from '@univerjs/docs';+import { DocumentViewModel, IRenderManagerService } from '@univerjs/engine-render';import { BehaviorSubject, takeUntil } from 'rxjs';--import type { Ctor, Dependency, DependencyIdentifier, DocumentDataModel, IDocumentData, Nullable } from '@univerjs/core';-import type { DocumentSkeleton, IRender, IRenderContext, IRenderModule } from '@univerjs/engine-render';import { DocIMEInputManagerService } from '../../../services/doc-ime-input-manager.service';import { DocStateChangeManagerService } from '../../../services/doc-state-change-manager.service';import { DocSelectionRenderService } from '../../../services/selection/doc-selection-render.service';@@ -124,6 +124,10 @@ export function createCommandTestBed(docData?: IDocumentData, dependencies?: Depdependencies?.forEach((d) => injector.add(d));}++ override onReady(): void {+ this._injector.get(DocStateChangeManagerService);+ }}univer.registerPlugin(TestPlugin);diff --git a/packages/docs-ui/src/commands/commands/__tests__/inline-format.command.spec.ts b/packages/docs-ui/src/commands/commands/__tests__/inline-format.command.spec.tsindex 4081ef278b..48e8308b9f 100644--- a/packages/docs-ui/src/commands/commands/__tests__/inline-format.command.spec.ts+++ b/packages/docs-ui/src/commands/commands/__tests__/inline-format.command.spec.ts@@ -14,11 +14,10 @@* limitations under the License.*/+import type { DocumentDataModel, ICommand, Injector, IStyleBase, Univer } from '@univerjs/core';import { BooleanNumber, ICommandService, IUniverInstanceService, RedoCommand, UndoCommand, UniverInstanceType } from '@univerjs/core';import { DocSelectionManagerService, RichTextEditingMutation, SetTextSelectionsOperation } from '@univerjs/docs';import { afterEach, beforeEach, describe, expect, it } from 'vitest';--import type { DocumentDataModel, ICommand, Injector, IStyleBase, Univer } from '@univerjs/core';import {SetInlineFormatBoldCommand,SetInlineFormatCommand,diff --git a/packages/docs-ui/src/controllers/doc-auto-format.controller.ts b/packages/docs-ui/src/controllers/doc-auto-format.controller.tsindex da2577c04f..0a90a8bdd2 100644--- a/packages/docs-ui/src/controllers/doc-auto-format.controller.ts+++ b/packages/docs-ui/src/controllers/doc-auto-format.controller.ts@@ -14,17 +14,16 @@* limitations under the License.*/-import { Disposable, Inject, LifecycleStages, OnLifecycle, QuickListTypeMap } from '@univerjs/core';import type { Nullable } from 'vitest';+import type { ITabCommandParams } from '../commands/commands/auto-format.command';+import { Disposable, Inject, QuickListTypeMap } from '@univerjs/core';import { AfterSpaceCommand, EnterCommand, TabCommand } from '../commands/commands/auto-format.command';import { BreakLineCommand } from '../commands/commands/break-line.command';import { ChangeListNestingLevelCommand, ChangeListNestingLevelType, ListOperationCommand, QuickListCommand } from '../commands/commands/list.command';import { DocTableTabCommand } from '../commands/commands/table/doc-table-tab.command';import { DocAutoFormatService } from '../services/doc-auto-format.service';import { isInSameTableCell } from '../services/selection/convert-rect-range';-import type { ITabCommandParams } from '../commands/commands/auto-format.command';-@OnLifecycle(LifecycleStages.Rendered, DocAutoFormatController)export class DocAutoFormatController extends Disposable {constructor(@Inject(DocAutoFormatService) private readonly _docAutoFormatService: DocAutoFormatServicediff --git a/packages/docs-ui/src/controllers/doc-move-cursor.controller.ts b/packages/docs-ui/src/controllers/doc-move-cursor.controller.tsindex 14aa5bd127..eccfc2c16e 100644--- a/packages/docs-ui/src/controllers/doc-move-cursor.controller.ts+++ b/packages/docs-ui/src/controllers/doc-move-cursor.controller.ts@@ -14,19 +14,6 @@* limitations under the License.*/-import {- DataStreamTreeTokenType,- Direction,- Disposable,- ICommandService,- Inject,- IUniverInstanceService,- LifecycleStages,- OnLifecycle,- RANGE_DIRECTION,-} from '@univerjs/core';-import { DocSelectionManagerService, DocSkeletonManagerService } from '@univerjs/docs';-import { DocumentSkeletonPageType, IRenderManagerService } from '@univerjs/engine-render';import type { ICommandInfo, Nullable } from '@univerjs/core';import type {DocumentSkeleton,@@ -38,16 +25,26 @@ import type {INodePosition,INodeSearch,} from '@univerjs/engine-render';-import type { Subscription } from 'rxjs';+import type { IMoveCursorOperationParams } from '../commands/operations/doc-cursor.operation';+import {+ DataStreamTreeTokenType,+ Direction,+ Disposable,+ ICommandService,+ Inject,+ IUniverInstanceService,+ RANGE_DIRECTION,+} from '@univerjs/core';++import { DocSelectionManagerService, DocSkeletonManagerService } from '@univerjs/docs';+import { DocumentSkeletonPageType, IRenderManagerService } from '@univerjs/engine-render';import { getDocObject } from '../basics/component-tools';import { findAboveCell, findBellowCell, findLineBeforeAndAfterTable, findTableAfterLine, findTableBeforeLine, firstLineInCell, firstLineInTable, lastLineInCell, lastLineInTable } from '../basics/table';import { MoveCursorOperation, MoveSelectionOperation } from '../commands/operations/doc-cursor.operation';import { NodePositionConvertToCursor } from '../services/selection/convert-text-range';import { DocBackScrollRenderController } from './render-controllers/back-scroll.render-controller';-import type { IMoveCursorOperationParams } from '../commands/operations/doc-cursor.operation';-@OnLifecycle(LifecycleStages.Rendered, DocMoveCursorController)export class DocMoveCursorController extends Disposable {private _onInputSubscription: Nullable<Subscription>;diff --git a/packages/docs-ui/src/controllers/doc-paragraph-setting.controller.ts b/packages/docs-ui/src/controllers/doc-paragraph-setting.controller.tsindex c46ff717cb..ba1b807dbe 100644--- a/packages/docs-ui/src/controllers/doc-paragraph-setting.controller.ts+++ b/packages/docs-ui/src/controllers/doc-paragraph-setting.controller.ts@@ -14,13 +14,12 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, ICommandService, Inject } from '@univerjs/core';import { ComponentManager, ISidebarService } from '@univerjs/ui';import { ParagraphSettingIndex } from '../views/paragraph-setting/index';const paragraphSettingIndexKey = 'doc_ui_paragraph-setting-panel';-@OnLifecycle(LifecycleStages.Rendered, DocParagraphSettingController)export class DocParagraphSettingController extends Disposable {private _id: 'DocParagraphSetting';diff --git a/packages/docs-ui/src/controllers/doc-table.controller.ts b/packages/docs-ui/src/controllers/doc-table.controller.tsindex 971906f385..7b2d1a1ea1 100644--- a/packages/docs-ui/src/controllers/doc-table.controller.ts+++ b/packages/docs-ui/src/controllers/doc-table.controller.ts@@ -14,14 +14,12 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';-+import { Disposable, ICommandService, Inject } from '@univerjs/core';import { ComponentManager } from '@univerjs/ui';+import { DocCreateTableOperation } from '../commands/operations/doc-create-table.operation';import { COMPONENT_DOC_CREATE_TABLE_CONFIRM } from '../views/table/create/component-name';import { DocCreateTableConfirm } from '../views/table/create/TableCreate';-import { DocCreateTableOperation } from '../commands/operations/doc-create-table.operation';-@OnLifecycle(LifecycleStages.Rendered, DocTableController)export class DocTableController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/docs-ui/src/controllers/doc-ui.controller.ts b/packages/docs-ui/src/controllers/doc-ui.controller.tsindex e8e64c1f41..7d9252dad8 100644--- a/packages/docs-ui/src/controllers/doc-ui.controller.ts+++ b/packages/docs-ui/src/controllers/doc-ui.controller.ts@@ -14,6 +14,7 @@* limitations under the License.*/+import type { IUniverDocsUIConfig } from './config.schema';import {connectInjector,Disposable,@@ -22,12 +23,10 @@ import {Inject,Injector,IUniverInstanceService,- LifecycleStages,- OnLifecycle,UniverInstanceType,} from '@univerjs/core';-import { IRenderManagerService } from '@univerjs/engine-render';+import { IRenderManagerService } from '@univerjs/engine-render';import { TodoList } from '@univerjs/icons';import { BuiltInUIPart, ComponentManager, ILayoutService, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui';import { CoreHeaderFooterCommand, OpenHeaderFooterPanelCommand } from '../commands/commands/doc-header-footer.command';@@ -60,10 +59,7 @@ import {import { DocFooter } from '../views/doc-footer';import { PLUGIN_CONFIG_KEY } from './config.schema';import { menuSchema } from './menu.schema';-import type { IUniverDocsUIConfig } from './config.schema';-// FIXME: LifecycleStages.Rendered must be used, otherwise the menu cannot be added to the DOM, but the sheet ui plug-in can be added in LifecycleStages.Ready-@OnLifecycle(LifecycleStages.Rendered, DocUIController)export class DocUIController extends Disposable {constructor(@Inject(Injector) protected readonly _injector: Injector,diff --git a/packages/docs-ui/src/docs-ui-plugin.ts b/packages/docs-ui/src/docs-ui-plugin.tsindex c8de6c00f3..c5dc0745b5 100644--- a/packages/docs-ui/src/docs-ui-plugin.ts+++ b/packages/docs-ui/src/docs-ui-plugin.ts@@ -115,6 +115,7 @@ export class UniverDocsUIPlugin extends Plugin {this._configService.setConfig('menu', menu, { merge: true });}this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);+this._initDependencies(_injector);this._initializeShortcut();this._initCommand();@@ -123,11 +124,23 @@ export class UniverDocsUIPlugin extends Plugin {override onReady(): void {this._initRenderBasics();this._markDocAsFocused();++ this._injector.get(DocStateChangeManagerService);+ this._injector.get(DocsRenderService);}override onRendered(): void {this._initUI();this._initRenderModules();++ this._injector.get(DocAutoFormatController);+ this._injector.get(DocMoveCursorController);+ this._injector.get(DocParagraphSettingController);+ this._injector.get(DocTableController);++ // FIXME: LifecycleStages.Rendered must be used, otherwise the menu cannot be added to the DOM, but the sheet ui+ // plugin can be added in LifecycleStages.Ready+ this._injector.get(DocUIController);}private _initCommand() {@@ -220,18 +233,15 @@ export class UniverDocsUIPlugin extends Plugin {}private _initDependencies(injector: Injector) {- const dependencies: Dependency[] = [+ const dependencies = mergeOverrideWithDependencies([[DocClipboardController],[DocEditorBridgeController],- // Controller[DocUIController],[DocAutoFormatController],[DocTableController],[DocMoveCursorController],[AppUIController],[DocParagraphSettingController],-- // Services[IEditorService, { useClass: EditorService }],[IRangeSelectorService, { useClass: RangeSelectorService }],[IDocClipboardService, { useClass: DocClipboardService }],@@ -239,11 +249,8 @@ export class UniverDocsUIPlugin extends Plugin {[DocsRenderService],[DocStateChangeManagerService],[DocAutoFormatService],- ];-- const dependency = mergeOverrideWithDependencies(dependencies, this._config.override);-- dependency.forEach((d) => injector.add(d));+ ], this._config.override);+ dependencies.forEach((d) => injector.add(d));}private _markDocAsFocused() {diff --git a/packages/docs-ui/src/services/doc-state-change-manager.service.ts b/packages/docs-ui/src/services/doc-state-change-manager.service.tsindex 7ca314e451..9dc023de7b 100644--- a/packages/docs-ui/src/services/doc-state-change-manager.service.ts+++ b/packages/docs-ui/src/services/doc-state-change-manager.service.ts@@ -14,11 +14,11 @@* limitations under the License.*/-import { ICommandService, Inject, IUndoRedoService, IUniverInstanceService, JSONX, LifecycleStages, OnLifecycle, RedoCommandId, RxDisposable, UndoCommandId } from '@univerjs/core';+import type { JSONXActions, Nullable } from '@univerjs/core';+import { ICommandService, Inject, IUndoRedoService, IUniverInstanceService, JSONX, RedoCommandId, RxDisposable, UndoCommandId } from '@univerjs/core';import { DocStateEmitService, type IDocStateChangeParams, type IRichTextEditingMutationParams } from '@univerjs/docs';import { IRenderManagerService } from '@univerjs/engine-render';import { BehaviorSubject, takeUntil } from 'rxjs';-import type { JSONXActions, Nullable } from '@univerjs/core';import { DocIMEInputManagerService } from './doc-ime-input-manager.service';type ChangeStateCacheType = 'history' | 'collaboration';@@ -28,7 +28,6 @@ const DEBOUNCE_DELAY = 300;// This class sends out state-changing events, what is the state, the data model,// and the cursor & selection, and this class mainly serves the History(undo/redo) module and// the collaboration module.-@OnLifecycle(LifecycleStages.Ready, DocStateChangeManagerService)export class DocStateChangeManagerService extends RxDisposable {private readonly _docStateChange$ = new BehaviorSubject<Nullable<IDocStateChangeParams>>(null);readonly docStateChange$ = this._docStateChange$.asObservable();diff --git a/packages/docs-ui/src/services/docs-render.service.ts b/packages/docs-ui/src/services/docs-render.service.tsindex de45162ad5..90712b3ef0 100644--- a/packages/docs-ui/src/services/docs-render.service.ts+++ b/packages/docs-ui/src/services/docs-render.service.ts@@ -14,12 +14,11 @@* limitations under the License.*/-import { IUniverInstanceService, LifecycleStages, OnLifecycle, RxDisposable, UniverInstanceType } from '@univerjs/core';+import type { DocumentDataModel } from '@univerjs/core';+import { IUniverInstanceService, RxDisposable, UniverInstanceType } from '@univerjs/core';import { IRenderManagerService } from '@univerjs/engine-render';import { takeUntil } from 'rxjs';-import type { DocumentDataModel } from '@univerjs/core';-@OnLifecycle(LifecycleStages.Ready, DocsRenderService)export class DocsRenderService extends RxDisposable {constructor(@IUniverInstanceService private readonly _instanceSrv: IUniverInstanceService,diff --git a/packages/docs/src/controllers/custom-range.controller.ts b/packages/docs/src/controllers/custom-range.controller.tsindex e0030a0991..7bebc96397 100644--- a/packages/docs/src/controllers/custom-range.controller.ts+++ b/packages/docs/src/controllers/custom-range.controller.ts@@ -14,14 +14,13 @@* limitations under the License.*/-import { BuildTextUtils, Disposable, ICommandService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle } from '@univerjs/core';import type { DocumentDataModel } from '@univerjs/core';import type { ITextRangeWithStyle } from '@univerjs/engine-render';+import type { ISetTextSelectionsOperationParams } from '../commands/operations/text-selection.operation';+import { BuildTextUtils, Disposable, ICommandService, Inject, IUniverInstanceService } from '@univerjs/core';import { SetTextSelectionsOperation } from '../commands/operations/text-selection.operation';import { DocSelectionManagerService } from '../services/doc-selection-manager.service';-import type { ISetTextSelectionsOperationParams } from '../commands/operations/text-selection.operation';-@OnLifecycle(LifecycleStages.Ready, DocCustomRangeController)export class DocCustomRangeController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/docs/src/doc-plugin.ts b/packages/docs/src/doc-plugin.tsindex a5767ef3ff..39de187052 100644--- a/packages/docs/src/doc-plugin.ts+++ b/packages/docs/src/doc-plugin.ts@@ -14,6 +14,8 @@* limitations under the License.*/+import type { Dependency, ICommand } from '@univerjs/core';+import type { IUniverDocsConfig } from './controllers/config.schema';import {ICommandService,IConfigService,@@ -21,7 +23,6 @@ import {Injector,Plugin,} from '@univerjs/core';-import type { Dependency, ICommand } from '@univerjs/core';import { RichTextEditingMutation } from './commands/mutations/core-editing.mutation';import { DocsRenameMutation } from './commands/mutations/docs-rename.mutation';import { SetTextSelectionsOperation } from './commands/operations/text-selection.operation';@@ -29,7 +30,6 @@ import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schimport { DocCustomRangeController } from './controllers/custom-range.controller';import { DocSelectionManagerService } from './services/doc-selection-manager.service';import { DocStateEmitService } from './services/doc-state-emit.service';-import type { IUniverDocsConfig } from './controllers/config.schema';const PLUGIN_NAME = 'DOCS_PLUGIN';@@ -47,9 +47,10 @@ export class UniverDocsPlugin extends Plugin {// Manage the plugin configuration.const { ...rest } = this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);+ }- this._initializeDependencies(_injector);-+ override onStarting(): void {+ this._initializeDependencies();this._initializeCommands();}@@ -65,16 +66,17 @@ export class UniverDocsPlugin extends Plugin {});}- private _initializeDependencies(docInjector: Injector) {+ private _initializeDependencies() {([- // services[DocSelectionManagerService],[DocStateEmitService],- // controllers[DocCustomRangeController],-] as Dependency[]- ).forEach((d) => docInjector.add(d));+ ).forEach((d) => this._injector.add(d));+ }++ override onReady(): void {+ this._injector.get(DocCustomRangeController);}}diff --git a/packages/docs/src/services/doc-interceptor/doc-interceptor.service.ts b/packages/docs/src/services/doc-interceptor/doc-interceptor.service.tsindex fb75289e3d..73926e49e0 100644--- a/packages/docs/src/services/doc-interceptor/doc-interceptor.service.ts+++ b/packages/docs/src/services/doc-interceptor/doc-interceptor.service.ts@@ -15,12 +15,11 @@*/import type { DocumentDataModel, ICustomDecorationForInterceptor, ICustomRangeForInterceptor, IInterceptor, Nullable } from '@univerjs/core';-import { composeInterceptors, Disposable, DisposableCollection, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, Inject, LifecycleStages, OnLifecycle, remove, toDisposable } from '@univerjs/core';import type { DocumentViewModel, IRenderContext, IRenderModule } from '@univerjs/engine-render';+import { composeInterceptors, Disposable, DisposableCollection, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, Inject, remove, toDisposable } from '@univerjs/core';import { DocSkeletonManagerService } from '../doc-skeleton-manager.service';import { DOC_INTERCEPTOR_POINT } from './interceptor-const';-@OnLifecycle(LifecycleStages.Starting, DocInterceptorService)export class DocInterceptorService extends Disposable implements IRenderModule {private _interceptorsByName: Map<string, Array<IInterceptor<unknown, unknown>>> = new Map();diff --git a/packages/drawing-ui/src/controllers/drawing-ui.controller.ts b/packages/drawing-ui/src/controllers/drawing-ui.controller.tsindex 577e77e2bf..e3982dd352 100644--- a/packages/drawing-ui/src/controllers/drawing-ui.controller.ts+++ b/packages/drawing-ui/src/controllers/drawing-ui.controller.ts@@ -14,17 +14,16 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, ICommandService, Inject } from '@univerjs/core';import { ComponentManager } from '@univerjs/ui';+import { SetDrawingAlignOperation } from '../commands/operations/drawing-align.operation';+import { AutoImageCropOperation, CloseImageCropOperation, OpenImageCropOperation } from '../commands/operations/image-crop.operation';+import { ImageResetSizeOperation } from '../commands/operations/image-reset-size.operation';import { COMPONENT_IMAGE_POPUP_MENU } from '../views/image-popup-menu/component-name';import { ImagePopupMenu } from '../views/image-popup-menu/ImagePopupMenu';-import { AutoImageCropOperation, CloseImageCropOperation, OpenImageCropOperation } from '../commands/operations/image-crop.operation';-import { ImageViewer } from '../views/image-viewer/ImageViewer';import { COMPONENT_IMAGE_VIEWER } from '../views/image-viewer/component-name';-import { ImageResetSizeOperation } from '../commands/operations/image-reset-size.operation';-import { SetDrawingAlignOperation } from '../commands/operations/drawing-align.operation';+import { ImageViewer } from '../views/image-viewer/ImageViewer';-@OnLifecycle(LifecycleStages.Rendered, DrawingUIController)export class DrawingUIController extends Disposable {constructor(@Inject(ComponentManager) private readonly _componentManager: ComponentManager,diff --git a/packages/drawing-ui/src/controllers/drawing-update.controller.ts b/packages/drawing-ui/src/controllers/drawing-update.controller.tsindex 3feb870077..f1b01c34da 100644--- a/packages/drawing-ui/src/controllers/drawing-update.controller.ts+++ b/packages/drawing-ui/src/controllers/drawing-update.controller.ts@@ -18,20 +18,18 @@ import type {ICommandInfo,Nullable,} from '@univerjs/core';+import type { DrawingTypeEnum, IDrawingGroupUpdateParam, IDrawingOrderMapParam, IDrawingParam, IDrawingSearch, ITransformState } from '@univerjs/drawing';+import type { BaseObject, Image, IShapeProps, Scene, Shape } from '@univerjs/engine-render';+import type { ISetDrawingAlignOperationParams } from '../commands/operations/drawing-align.operation';import {checkIfMove,Disposable,ICommandService,IUniverInstanceService,- LifecycleStages,- OnLifecycle,toDisposable,} from '@univerjs/core';-import type { BaseObject, Image, IShapeProps, Scene, Shape } from '@univerjs/engine-render';-import { DRAWING_OBJECT_LAYER_INDEX, Group, IRenderManagerService, RENDER_CLASS_TYPE } from '@univerjs/engine-render';-import type { DrawingTypeEnum, IDrawingGroupUpdateParam, IDrawingOrderMapParam, IDrawingParam, IDrawingSearch, ITransformState } from '@univerjs/drawing';import { getDrawingShapeKeyByDrawingSearch, IDrawingManagerService } from '@univerjs/drawing';-import type { ISetDrawingAlignOperationParams } from '../commands/operations/drawing-align.operation';+import { DRAWING_OBJECT_LAYER_INDEX, Group, IRenderManagerService, RENDER_CLASS_TYPE } from '@univerjs/engine-render';import { AlignType, SetDrawingAlignOperation } from '../commands/operations/drawing-align.operation';import { CloseImageCropOperation } from '../commands/operations/image-crop.operation';import { getUpdateParams } from '../utils/get-update-params';@@ -45,7 +43,6 @@ interface IDrawingTransformCache {transform: ITransformState;}-@OnLifecycle(LifecycleStages.Rendered, DrawingUpdateController)export class DrawingUpdateController extends Disposable {constructor(@IUniverInstanceService private readonly _currentUniverService: IUniverInstanceService,diff --git a/packages/drawing-ui/src/controllers/image-cropper.controller.ts b/packages/drawing-ui/src/controllers/image-cropper.controller.tsindex bbf79075cf..9e446f39ea 100644--- a/packages/drawing-ui/src/controllers/image-cropper.controller.ts+++ b/packages/drawing-ui/src/controllers/image-cropper.controller.ts@@ -15,19 +15,18 @@*/import type { ICommandInfo, ISrcRect, Nullable, Workbook } from '@univerjs/core';-import { checkIfMove, Disposable, ICommandService, Inject, IUniverInstanceService, LifecycleStages, LocaleService, OnLifecycle, UniverInstanceType } from '@univerjs/core';-import { MessageType } from '@univerjs/design';import type { IDrawingSearch, IImageData, ITransformState } from '@univerjs/drawing';-import { getDrawingShapeKeyByDrawingSearch, IDrawingManagerService } from '@univerjs/drawing';import type { BaseObject, Scene } from '@univerjs/engine-render';+import type { IOpenImageCropOperationBySrcRectParams } from '../commands/operations/image-crop.operation';+import { checkIfMove, Disposable, ICommandService, Inject, IUniverInstanceService, LocaleService, UniverInstanceType } from '@univerjs/core';+import { MessageType } from '@univerjs/design';+import { getDrawingShapeKeyByDrawingSearch, IDrawingManagerService } from '@univerjs/drawing';import { CURSOR_TYPE, degToRad, Image, IRenderManagerService, precisionTo, Vector2 } from '@univerjs/engine-render';import { IMessageService } from '@univerjs/ui';import { filter, switchMap } from 'rxjs';-import type { IOpenImageCropOperationBySrcRectParams } from '../commands/operations/image-crop.operation';import { AutoImageCropOperation, CloseImageCropOperation, CropType, OpenImageCropOperation } from '../commands/operations/image-crop.operation';import { ImageCropperObject } from '../views/crop/image-cropper-object';-@OnLifecycle(LifecycleStages.Rendered, ImageCropperController)export class ImageCropperController extends Disposable {private _sceneListenerOnImageMap: WeakSet<Scene> = new WeakSet();diff --git a/packages/drawing-ui/src/controllers/image-update.controller.ts b/packages/drawing-ui/src/controllers/image-update.controller.tsindex 8bb26b02f8..a06ea07477 100644--- a/packages/drawing-ui/src/controllers/image-update.controller.ts+++ b/packages/drawing-ui/src/controllers/image-update.controller.ts@@ -15,28 +15,25 @@*/import type { ICommandInfo, Nullable } from '@univerjs/core';+import type { IDrawingSearch, IImageData } from '@univerjs/drawing';+import type { Image, Scene } from '@univerjs/engine-render';import {Disposable,ICommandService,Inject,IUniverInstanceService,- LifecycleStages,- OnLifecycle,toDisposable,} from '@univerjs/core';-import type { Image, Scene } from '@univerjs/engine-render';-import { CURSOR_TYPE, IRenderManagerService } from '@univerjs/engine-render';-import type { IDrawingSearch, IImageData } from '@univerjs/drawing';import { DrawingTypeEnum, getDrawingShapeKeyByDrawingSearch, IDrawingManagerService, IImageIoService } from '@univerjs/drawing';+import { CURSOR_TYPE, IRenderManagerService } from '@univerjs/engine-render';import { IDialogService } from '@univerjs/ui';-import { COMPONENT_IMAGE_VIEWER } from '../views/image-viewer/component-name';import { ImageResetSizeOperation } from '../commands/operations/image-reset-size.operation';import { DrawingRenderService } from '../services/drawing-render.service';+import { COMPONENT_IMAGE_VIEWER } from '../views/image-viewer/component-name';import { getCurrentUnitInfo } from './utils';const IMAGE_VIEWER_DROPDOWN_PADDING = 50;-@OnLifecycle(LifecycleStages.Rendered, ImageUpdateController)export class ImageUpdateController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/drawing-ui/src/plugin.ts b/packages/drawing-ui/src/plugin.tsindex 139ddd9b80..7e569eeef6 100644--- a/packages/drawing-ui/src/plugin.ts+++ b/packages/drawing-ui/src/plugin.ts@@ -14,15 +14,15 @@* limitations under the License.*/-import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core';import type { Dependency } from '@univerjs/core';-import { DrawingUpdateController } from './controllers/drawing-update.controller';+import type { IUniverDrawingUIConfig } from './controllers/config.schema';+import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core';+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { DrawingUIController } from './controllers/drawing-ui.controller';+import { DrawingUpdateController } from './controllers/drawing-update.controller';import { ImageCropperController } from './controllers/image-cropper.controller';import { ImageUpdateController } from './controllers/image-update.controller';import { DrawingRenderService } from './services/drawing-render.service';-import type { IUniverDrawingUIConfig } from './controllers/config.schema';-import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';const PLUGIN_NAME = 'UNIVER_DRAWING_UI_PLUGIN';@@ -48,12 +48,16 @@ export class UniverDrawingUIPlugin extends Plugin {this._initDependencies();}+ override onRendered(): void {+ this._injector.get(DrawingUIController);+ this._injector.get(DrawingUpdateController);+ this._injector.get(ImageCropperController);+ this._injector.get(ImageUpdateController);+ }+private _initDependencies(): void {const dependencies: Dependency[] = [-- // services[DrawingRenderService],- // controllers[DrawingUpdateController],[DrawingUIController],[ImageCropperController],diff --git a/packages/drawing/src/services/drawing-manager-impl.service.ts b/packages/drawing/src/services/drawing-manager-impl.service.tsindex 872c1e8a0b..5c55724d39 100644--- a/packages/drawing/src/services/drawing-manager-impl.service.ts+++ b/packages/drawing/src/services/drawing-manager-impl.service.ts@@ -14,12 +14,12 @@* limitations under the License.*/-import { type Observable, Subject } from 'rxjs';import type { Nullable } from '@univerjs/core';-import { sortRules, sortRulesByDesc } from '@univerjs/core';import type { JSONOp, JSONOpList } from 'ot-json1';-import * as json1 from 'ot-json1';import type { IDrawingGroupUpdateParam, IDrawingMap, IDrawingMapItemData, IDrawingOrderMapParam, IDrawingOrderUpdateParam, IDrawingParam, IDrawingSearch, IDrawingSubunitMap, IDrawingVisibleParam, IUnitDrawingService } from './drawing-manager.service';+import { sortRules, sortRulesByDesc } from '@univerjs/core';+import * as json1 from 'ot-json1';+import { type Observable, Subject } from 'rxjs';export interface IDrawingJsonUndo1 {undo: JSONOp;@@ -137,7 +137,7 @@ export class UnitDrawingService<T extends IDrawingParam> implements IUnitDrawing}getDrawingDataForUnit(unitId: string) {- return this.drawingManagerData[unitId];+ return this.drawingManagerData[unitId] || {};}removeDrawingDataForUnit(unitId: string) {diff --git a/packages/engine-formula/src/controller/calculate.controller.ts b/packages/engine-formula/src/controller/calculate.controller.tsindex a006cfbda5..949561c202 100644--- a/packages/engine-formula/src/controller/calculate.controller.ts+++ b/packages/engine-formula/src/controller/calculate.controller.ts@@ -21,7 +21,7 @@ import type { ISetArrayFormulaDataMutationParams } from '../commands/mutations/simport type { ISetFormulaCalculationStartMutation } from '../commands/mutations/set-formula-calculation.mutation';import type { ISetFormulaDataMutationParams } from '../commands/mutations/set-formula-data.mutation';import type { IAllRuntimeData } from '../services/runtime.service';-import { Disposable, ICommandService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, ICommandService, Inject } from '@univerjs/core';import { convertRuntimeToUnitData } from '../basics/runtime';import { SetArrayFormulaDataMutation } from '../commands/mutations/set-array-formula-data.mutation';import {@@ -35,12 +35,10 @@ import { FormulaDataModel } from '../models/formula-data.model';import { CalculateFormulaService } from '../services/calculate-formula.service';import { FormulaExecutedStateType } from '../services/runtime.service';-@OnLifecycle(LifecycleStages.Ready, CalculateController)export class CalculateController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,@Inject(CalculateFormulaService) private readonly _calculateFormulaService: CalculateFormulaService,- @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,@Inject(FormulaDataModel) private readonly _formulaDataModel: FormulaDataModel) {super();@@ -57,7 +55,7 @@ export class CalculateController extends Disposable {private _commandExecutedListener() {this.disposeWithMe(- this._commandService.onCommandExecuted((command: ICommandInfo, options) => {+ this._commandService.onCommandExecuted((command: ICommandInfo) => {if (command.id === SetFormulaCalculationStopMutation.id) {this._calculateFormulaService.stopFormulaExecution();} else if (command.id === SetFormulaDataMutation.id) {diff --git a/packages/engine-formula/src/controller/formula.controller.ts b/packages/engine-formula/src/controller/formula.controller.tsindex cdea2e4cd0..8dd2071e0d 100644--- a/packages/engine-formula/src/controller/formula.controller.ts+++ b/packages/engine-formula/src/controller/formula.controller.ts@@ -14,11 +14,13 @@* limitations under the License.*/-import { Disposable, ICommandService, IConfigService, LifecycleStages, OnLifecycle } from '@univerjs/core';+import type { IFunctionNames } from '../basics/function';+import type { BaseFunction } from '../functions/base-function';+import type { IUniverEngineFormulaConfig } from './config.schema';++import { Disposable, ICommandService, IConfigService } from '@univerjs/core';import { type Ctor, Optional } from '@univerjs/core';import { DataSyncPrimaryController } from '@univerjs/rpc';--import type { IFunctionNames } from '../basics/function';import { RegisterFunctionMutation } from '../commands/mutations/register-function.mutation';import { SetArrayFormulaDataMutation } from '../commands/mutations/set-array-formula-data.mutation';import { RemoveDefinedNameMutation, SetDefinedNameMutation } from '../commands/mutations/set-defined-name.mutation';@@ -40,7 +42,6 @@ import {SetSuperTableOptionMutation,} from '../commands/mutations/set-super-table.mutation';import { functionArray } from '../functions/array/function-map';-import type { BaseFunction } from '../functions/base-function';import { functionCompatibility } from '../functions/compatibility/function-map';import { functionCube } from '../functions/cube/function-map';import { functionDatabase } from '../functions/database/function-map';@@ -57,10 +58,8 @@ import { functionText } from '../functions/text/function-map';import { functionUniver } from '../functions/univer/function-map';import { functionWeb } from '../functions/web/function-map';import { IFunctionService } from '../services/function.service';-import type { IUniverEngineFormulaConfig } from './config.schema';import { PLUGIN_CONFIG_KEY } from './config.schema';-@OnLifecycle(LifecycleStages.Ready, FormulaController)export class FormulaController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/engine-formula/src/controller/set-defined-name.controller.ts b/packages/engine-formula/src/controller/set-defined-name.controller.tsindex b0ba87d270..9ce75b9a1b 100644--- a/packages/engine-formula/src/controller/set-defined-name.controller.ts+++ b/packages/engine-formula/src/controller/set-defined-name.controller.ts@@ -15,16 +15,15 @@*/import type { ICommandInfo } from '@univerjs/core';-import { Disposable, ICommandService, LifecycleStages, OnLifecycle } from '@univerjs/core';-import type {ISetDefinedNameMutationParam,ISetDefinedNameMutationSearchParam,} from '../commands/mutations/set-defined-name.mutation';++import { Disposable, ICommandService } from '@univerjs/core';import { RemoveDefinedNameMutation, SetDefinedNameMutation } from '../commands/mutations/set-defined-name.mutation';import { IDefinedNamesService } from '../services/defined-names.service';-@OnLifecycle(LifecycleStages.Ready, SetDefinedNameController)export class SetDefinedNameController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/engine-formula/src/controller/set-dependency.controller.ts b/packages/engine-formula/src/controller/set-dependency.controller.tsindex 48ce25d894..2217b5f747 100644--- a/packages/engine-formula/src/controller/set-dependency.controller.ts+++ b/packages/engine-formula/src/controller/set-dependency.controller.ts@@ -14,9 +14,14 @@* limitations under the License.*/-import { Disposable, ICommandService, LifecycleStages, ObjectMatrix, OnLifecycle } from '@univerjs/core';import type { ICommandInfo } from '@univerjs/core';+import type {+ IRemoveFeatureCalculationMutationParam,+ ISetFeatureCalculationMutation } from '../commands/mutations/set-feature-calculation.mutation';+import type { ISetFormulaDataMutationParams } from '../commands/mutations/set-formula-data.mutation';+import type { IRemoveOtherFormulaMutationParams, ISetOtherFormulaMutationParams } from '../commands/mutations/set-other-formula.mutation';+import { Disposable, ICommandService, ObjectMatrix } from '@univerjs/core';import {RemoveFeatureCalculationMutation,SetFeatureCalculationMutation,@@ -25,13 +30,7 @@ import { SetFormulaDataMutation } from '../commands/mutations/set-formula-data.mimport { RemoveOtherFormulaMutation, SetOtherFormulaMutation } from '../commands/mutations/set-other-formula.mutation';import { IDependencyManagerService } from '../services/dependency-manager.service';import { IFeatureCalculationManagerService } from '../services/feature-calculation-manager.service';-import type {- IRemoveFeatureCalculationMutationParam,- ISetFeatureCalculationMutation } from '../commands/mutations/set-feature-calculation.mutation';-import type { ISetFormulaDataMutationParams } from '../commands/mutations/set-formula-data.mutation';-import type { IRemoveOtherFormulaMutationParams, ISetOtherFormulaMutationParams } from '../commands/mutations/set-other-formula.mutation';-@OnLifecycle(LifecycleStages.Ready, SetDependencyController)export class SetDependencyController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/engine-formula/src/controller/set-feature-calculation.controller.ts b/packages/engine-formula/src/controller/set-feature-calculation.controller.tsindex 4fb88aa227..a15a33c328 100644--- a/packages/engine-formula/src/controller/set-feature-calculation.controller.ts+++ b/packages/engine-formula/src/controller/set-feature-calculation.controller.ts@@ -15,18 +15,17 @@*/import type { ICommandInfo } from '@univerjs/core';-import { Disposable, ICommandService, LifecycleStages, OnLifecycle } from '@univerjs/core';-import type {IRemoveFeatureCalculationMutationParam,- ISetFeatureCalculationMutation } from '../commands/mutations/set-feature-calculation.mutation';+ ISetFeatureCalculationMutation,+} from '../commands/mutations/set-feature-calculation.mutation';+import { Disposable, ICommandService } from '@univerjs/core';import {RemoveFeatureCalculationMutation,SetFeatureCalculationMutation,} from '../commands/mutations/set-feature-calculation.mutation';import { IFeatureCalculationManagerService } from '../services/feature-calculation-manager.service';-@OnLifecycle(LifecycleStages.Ready, SetFeatureCalculationController)export class SetFeatureCalculationController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/engine-formula/src/controller/set-other-formula.controller.ts b/packages/engine-formula/src/controller/set-other-formula.controller.tsindex 009b488c20..9f1bf54c20 100644--- a/packages/engine-formula/src/controller/set-other-formula.controller.ts+++ b/packages/engine-formula/src/controller/set-other-formula.controller.ts@@ -15,16 +15,15 @@*/import type { ICommandInfo } from '@univerjs/core';-import { Disposable, ICommandService, LifecycleStages, OnLifecycle } from '@univerjs/core';+import type { IRemoveOtherFormulaMutationParams, ISetOtherFormulaMutationParams } from '../commands/mutations/set-other-formula.mutation';+import { Disposable, ICommandService } from '@univerjs/core';+import { RemoveOtherFormulaMutation, SetOtherFormulaMutation } from '../commands/mutations/set-other-formula.mutation';+import { IDependencyManagerService } from '../services/dependency-manager.service';import {IOtherFormulaManagerService,} from '../services/other-formula-manager.service';-import { RemoveOtherFormulaMutation, SetOtherFormulaMutation } from '../commands/mutations/set-other-formula.mutation';-import type { IRemoveOtherFormulaMutationParams, ISetOtherFormulaMutationParams } from '../commands/mutations/set-other-formula.mutation';-import { IDependencyManagerService } from '../services/dependency-manager.service';-@OnLifecycle(LifecycleStages.Ready, SetOtherFormulaController)export class SetOtherFormulaController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/engine-formula/src/controller/set-super-table.controller.ts b/packages/engine-formula/src/controller/set-super-table.controller.tsindex b5d5d1c181..f790977ab1 100644--- a/packages/engine-formula/src/controller/set-super-table.controller.ts+++ b/packages/engine-formula/src/controller/set-super-table.controller.ts@@ -15,18 +15,17 @@*/import type { ICommandInfo } from '@univerjs/core';-import { Disposable, ICommandService, LifecycleStages, OnLifecycle } from '@univerjs/core';+import type { ISuperTableOptionParam } from '../services/super-table.service';+import { Disposable, ICommandService } from '@univerjs/core';import { RemoveDefinedNameMutation, SetDefinedNameMutation } from '../commands/mutations/set-defined-name.mutation';import {type ISetSuperTableMutationParam,type ISetSuperTableMutationSearchParam,SetSuperTableOptionMutation,} from '../commands/mutations/set-super-table.mutation';-import type { ISuperTableOptionParam } from '../services/super-table.service';import { ISuperTableService } from '../services/super-table.service';-@OnLifecycle(LifecycleStages.Ready, SetSuperTableController)export class SetSuperTableController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/engine-formula/src/engine/dependency/formula-dependency.ts b/packages/engine-formula/src/engine/dependency/formula-dependency.tsindex 9202515ea1..40acac8944 100644--- a/packages/engine-formula/src/engine/dependency/formula-dependency.ts+++ b/packages/engine-formula/src/engine/dependency/formula-dependency.ts@@ -15,33 +15,32 @@*/import type { IRange, Nullable } from '@univerjs/core';-import { Disposable, Inject, LifecycleStages, ObjectMatrix, OnLifecycle } from '@univerjs/core';--import { FormulaAstLRU } from '../../basics/cache-lru';import type { IDirtyUnitSheetNameMap, IFeatureDirtyRangeType, IFormulaData, IOtherFormulaData, IUnitData } from '../../basics/common';import type { ErrorType } from '../../basics/error-type';+import type { IFormulaDirtyData } from '../../services/current-data.service';+import type { IFeatureCalculationManagerParam } from '../../services/feature-calculation-manager.service';+import type { IAllRuntimeData } from '../../services/runtime.service';+import type { LexerNode } from '../analysis/lexer-node';+import type { AstRootNode, FunctionNode, PrefixNode, SuffixNode } from '../ast-node';+import type { BaseAstNode } from '../ast-node/base-ast-node';+import type { BaseReferenceObject } from '../reference-object/base-reference-object';+import type { PreCalculateNodeType } from '../utils/node-type';+import type { IUnitRangeWithToken } from './dependency-tree';+import { Disposable, Inject, ObjectMatrix } from '@univerjs/core';+import { FormulaAstLRU } from '../../basics/cache-lru';import { ERROR_TYPE_SET } from '../../basics/error-type';import { prefixToken, suffixToken } from '../../basics/token';-import type { IFormulaDirtyData } from '../../services/current-data.service';import { IFormulaCurrentConfigService } from '../../services/current-data.service';-import type { IFeatureCalculationManagerParam } from '../../services/feature-calculation-manager.service';+import { IDependencyManagerService } from '../../services/dependency-manager.service';import { IFeatureCalculationManagerService } from '../../services/feature-calculation-manager.service';import { IOtherFormulaManagerService } from '../../services/other-formula-manager.service';-import type { IAllRuntimeData } from '../../services/runtime.service';import { IFormulaRuntimeService } from '../../services/runtime.service';import { Lexer } from '../analysis/lexer';-import type { LexerNode } from '../analysis/lexer-node';import { AstTreeBuilder } from '../analysis/parser';-import type { AstRootNode, FunctionNode, PrefixNode, SuffixNode } from '../ast-node';-import type { BaseAstNode } from '../ast-node/base-ast-node';import { ErrorNode } from '../ast-node/base-ast-node';import { NodeType } from '../ast-node/node-type';import { Interpreter } from '../interpreter/interpreter';-import type { BaseReferenceObject } from '../reference-object/base-reference-object';-import type { PreCalculateNodeType } from '../utils/node-type';import { serializeRangeToRefString } from '../utils/reference';-import { IDependencyManagerService } from '../../services/dependency-manager.service';-import type { IUnitRangeWithToken } from './dependency-tree';import { FormulaDependencyTree, FormulaDependencyTreeCache } from './dependency-tree';const FORMULA_CACHE_LRU_COUNT = 100000;@@ -52,7 +51,6 @@ interface IFeatureFormulaParam {featureId: string;}-@OnLifecycle(LifecycleStages.Rendered, FormulaDependencyGenerator)export class FormulaDependencyGenerator extends Disposable {private _updateRangeFlattenCache = new Map<string, Map<string, IRange[]>>();diff --git a/packages/engine-formula/src/plugin.ts b/packages/engine-formula/src/plugin.tsindex bb194eb421..3a8dffd91e 100644--- a/packages/engine-formula/src/plugin.ts+++ b/packages/engine-formula/src/plugin.ts@@ -14,12 +14,14 @@* limitations under the License.*/-import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core';import type { Dependency } from '@univerjs/core';-+import type { IUniverEngineFormulaConfig } from './controller/config.schema';+import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core';import { CalculateController } from './controller/calculate.controller';+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controller/config.schema';import { FormulaController } from './controller/formula.controller';import { SetDefinedNameController } from './controller/set-defined-name.controller';+import { SetDependencyController } from './controller/set-dependency.controller';import { SetFeatureCalculationController } from './controller/set-feature-calculation.controller';import { SetOtherFormulaController } from './controller/set-other-formula.controller';import { SetSuperTableController } from './controller/set-super-table.controller';@@ -39,9 +41,11 @@ import { ValueNodeFactory } from './engine/ast-node/value-node';import { FormulaDependencyGenerator } from './engine/dependency/formula-dependency';import { Interpreter } from './engine/interpreter/interpreter';import { FormulaDataModel } from './models/formula-data.model';+import { ActiveDirtyManagerService, IActiveDirtyManagerService } from './services/active-dirty-manager.service';import { CalculateFormulaService } from './services/calculate-formula.service';import { FormulaCurrentConfigService, IFormulaCurrentConfigService } from './services/current-data.service';import { DefinedNamesService, IDefinedNamesService } from './services/defined-names.service';+import { DependencyManagerService, IDependencyManagerService } from './services/dependency-manager.service';import {FeatureCalculationManagerService,IFeatureCalculationManagerService,@@ -50,11 +54,6 @@ import { FunctionService, IFunctionService } from './services/function.service';import { IOtherFormulaManagerService, OtherFormulaManagerService } from './services/other-formula-manager.service';import { FormulaRuntimeService, IFormulaRuntimeService } from './services/runtime.service';import { ISuperTableService, SuperTableService } from './services/super-table.service';-import { ActiveDirtyManagerService, IActiveDirtyManagerService } from './services/active-dirty-manager.service';-import { DependencyManagerService, IDependencyManagerService } from './services/dependency-manager.service';-import { SetDependencyController } from './controller/set-dependency.controller';-import type { IUniverEngineFormulaConfig } from './controller/config.schema';-import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controller/config.schema';const PLUGIN_NAME = 'UNIVER_ENGINE_FORMULA_PLUGIN';@@ -77,6 +76,26 @@ export class UniverFormulaEnginePlugin extends Plugin {this._initialize();}+ override onReady(): void {+ this._injector.get(FormulaController);+ this._injector.get(SetDefinedNameController);+ this._injector.get(SetSuperTableController);++ if (!this._config?.notExecuteFormula) {+ this._injector.get(SetOtherFormulaController);+ this._injector.get(SetFeatureCalculationController);+ this._injector.get(SetDependencyController);+ this._injector.get(CalculateController);+ }+ }++ override onRendered(): void {+ if (!this._config?.notExecuteFormula) {+ this._injector.get(CalculateFormulaService);+ this._injector.get(FormulaDependencyGenerator);+ }+ }+private _initialize() {// worker and main threadconst dependencies: Dependency[] = [diff --git a/packages/engine-formula/src/services/calculate-formula.service.ts b/packages/engine-formula/src/services/calculate-formula.service.tsindex 274ec30cfe..cc1d4a7c8c 100644--- a/packages/engine-formula/src/services/calculate-formula.service.ts+++ b/packages/engine-formula/src/services/calculate-formula.service.ts@@ -15,35 +15,33 @@*/import type { IUnitRange } from '@univerjs/core';+import type {+ IArrayFormulaRangeType,+ IFeatureDirtyRangeType,+ IFormulaDatasetConfig,+ IRuntimeUnitDataType,+ IUnitExcludedCell,+} from '../basics/common';+import type { LexerNode } from '../engine/analysis/lexer-node';++import type { IAllRuntimeData, IExecutionInProgressParams } from './runtime.service';import {Disposable,IConfigService,Inject,- LifecycleStages,ObjectMatrix,- OnLifecycle,requestImmediateMacroTask,} from '@univerjs/core';import { Subject } from 'rxjs';--import type {- IArrayFormulaRangeType,- IFeatureDirtyRangeType,- IFormulaDatasetConfig,- IRuntimeUnitDataType,- IUnitExcludedCell,-} from '../basics/common';import { ErrorType } from '../basics/error-type';import { CELL_INVERTED_INDEX_CACHE } from '../basics/inverted-index-cache';import { Lexer } from '../engine/analysis/lexer';-import type { LexerNode } from '../engine/analysis/lexer-node';import { AstTreeBuilder } from '../engine/analysis/parser';import { ErrorNode } from '../engine/ast-node/base-ast-node';import { FormulaDependencyGenerator } from '../engine/dependency/formula-dependency';import { Interpreter } from '../engine/interpreter/interpreter';import { FORMULA_REF_TO_ARRAY_CACHE, type FunctionVariantType } from '../engine/reference-object/base-reference-object';import { IFormulaCurrentConfigService } from './current-data.service';-import type { IAllRuntimeData, IExecutionInProgressParams } from './runtime.service';import { FormulaExecuteStageType, IFormulaRuntimeService } from './runtime.service';export const DEFAULT_CYCLE_REFERENCE_COUNT = 1;@@ -52,7 +50,6 @@ export const CYCLE_REFERENCE_COUNT = 'cycleReferenceCount';export const EVERY_N_FUNCTION_EXECUTION_PAUSE = 100;-@OnLifecycle(LifecycleStages.Rendered, CalculateFormulaService)export class CalculateFormulaService extends Disposable {private readonly _executionStartListener$ = new Subject<boolean>();diff --git a/packages/facade/src/apis/__tests__/create-test-bed.ts b/packages/facade/src/apis/__tests__/create-test-bed.tsindex 500128a126..bae3cf5593 100644--- a/packages/facade/src/apis/__tests__/create-test-bed.ts+++ b/packages/facade/src/apis/__tests__/create-test-bed.ts@@ -204,6 +204,15 @@ export function createFacadeTestBed(workbookData?: IWorkbookData, dependencies?:});dependencies?.forEach((d) => injector.add(d));++ this._injector.get(SheetInterceptorService);+ this._injector.get(WorkbookPermissionService);+ this._injector.get(WorksheetPermissionService);+ this._injector.get(ConditionalFormattingService);+ }++ override onReady(): void {+ this._injector.get(SheetsRenderService);}}diff --git a/packages/facade/src/apis/docs/__tests__/create-test-bed.ts b/packages/facade/src/apis/docs/__tests__/create-test-bed.tsindex 6eea2c5764..a897760bc6 100644--- a/packages/facade/src/apis/docs/__tests__/create-test-bed.ts+++ b/packages/facade/src/apis/docs/__tests__/create-test-bed.ts@@ -88,6 +88,11 @@ export function createTestBed(documentConfig?: IDocumentData, dependencies?: DeprenderManagerService.registerRenderModule(UniverInstanceType.UNIVER_DOC, [DocSkeletonManagerService] as Dependency);renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_DOC, [DocIMEInputManagerService] as Dependency);}++ override onReady(): void {+ this._injector.get(DocStateChangeManagerService);+ this._injector.get(DocsRenderService);+ }}injector.get(LocaleService).load({ zhCN, enUS });diff --git a/packages/facade/src/apis/sheets/__tests__/f-range.spec.ts b/packages/facade/src/apis/sheets/__tests__/f-range.spec.tsindex 6cf24ff859..cec1b0e523 100644--- a/packages/facade/src/apis/sheets/__tests__/f-range.spec.ts+++ b/packages/facade/src/apis/sheets/__tests__/f-range.spec.ts@@ -16,14 +16,14 @@/* eslint-disable ts/no-non-null-asserted-optional-chain */+import type { ICellData, Injector, IRange, IStyleData, Nullable } from '@univerjs/core';import { DataValidationType, HorizontalAlign, ICommandService, IUniverInstanceService, VerticalAlign, WrapStrategy } from '@univerjs/core';import { FormulaDataModel } from '@univerjs/engine-formula';import { AddWorksheetMergeCommand, SetHorizontalTextAlignCommand, SetRangeValuesCommand, SetRangeValuesMutation, SetStyleCommand, SetTextWrapCommand, SetVerticalTextAlignCommand } from '@univerjs/sheets';-import { AddSheetDataValidationCommand } from '@univerjs/sheets-data-validation';+import { AddSheetDataValidationCommand } from '@univerjs/sheets-data-validation';import { ClearSheetsFilterCriteriaCommand, RemoveSheetFilterCommand, SetSheetFilterRangeCommand, SetSheetsFilterCriteriaCommand } from '@univerjs/sheets-filter-ui';import { beforeEach, describe, expect, it } from 'vitest';-import type { ICellData, Injector, IRange, IStyleData, Nullable } from '@univerjs/core';import { createFacadeTestBed } from '../../__tests__/create-test-bed';import { FUniver } from '../../facade';diff --git a/packages/facade/src/apis/sheets/f-formula.ts b/packages/facade/src/apis/sheets/f-formula.tsindex b93ad22aa8..246b7efd60 100644--- a/packages/facade/src/apis/sheets/f-formula.ts+++ b/packages/facade/src/apis/sheets/f-formula.ts@@ -80,6 +80,21 @@ export class FFormula {});}+ onCalculationEnd(): Promise<void> {+ return new Promise((resolve, reject) => {+ const timer = setTimeout(() => {+ reject(new Error('Calculation end timeout'));+ }, 30_000);++ const disposable = this.calculationEnd(() => {+ clearTimeout(timer);+ disposable.dispose();++ resolve();+ });+ });+ }+/*** Listening calculation processing.*/diff --git a/packages/find-replace/src/controllers/find-replace.controller.ts b/packages/find-replace/src/controllers/find-replace.controller.tsindex fefa2fe755..008ea6bced 100644--- a/packages/find-replace/src/controllers/find-replace.controller.ts+++ b/packages/find-replace/src/controllers/find-replace.controller.ts@@ -22,9 +22,7 @@ import {Inject,Injector,IUniverInstanceService,- LifecycleStages,LocaleService,- OnLifecycle,RxDisposable,toDisposable,} from '@univerjs/core';@@ -37,6 +35,7 @@ import { ComponentManager,} from '@univerjs/ui';import { takeUntil } from 'rxjs';+import { ReplaceAllMatchesCommand, ReplaceCurrentMatchCommand } from '../commands/commands/replace.command';import {GoToNextMatchOperation,GoToPreviousMatchOperation,@@ -45,7 +44,6 @@ import {} from '../commands/operations/find-replace.operation';import { IFindReplaceService } from '../services/find-replace.service';import { FindReplaceDialog } from '../views/dialog/FindReplaceDialog';-import { ReplaceAllMatchesCommand, ReplaceCurrentMatchCommand } from '../commands/commands/replace.command';import {GoToNextFindMatchShortcutItem,GoToPreviousFindMatchShortcutItem,@@ -61,7 +59,6 @@ const FIND_REPLACE_PANEL_WIDTH = 350;const FIND_REPLACE_PANEL_RIGHT_PADDING = 20;const FIND_REPLACE_PANEL_TOP_PADDING = -90;-@OnLifecycle(LifecycleStages.Rendered, FindReplaceController)export class FindReplaceController extends RxDisposable {constructor(@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,diff --git a/packages/find-replace/src/plugin.ts b/packages/find-replace/src/plugin.tsindex cd995c07fb..6c74ffc563 100644--- a/packages/find-replace/src/plugin.ts+++ b/packages/find-replace/src/plugin.ts@@ -14,13 +14,13 @@* limitations under the License.*/+import type { IUniverFindReplaceConfig } from './controllers/config.schema';import { IConfigService, Plugin } from '@univerjs/core';-import { type Dependency, Inject, Injector } from '@univerjs/core';+import { type Dependency, Inject, Injector } from '@univerjs/core';+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { FindReplaceController } from './controllers/find-replace.controller';import { FindReplaceService, IFindReplaceService } from './services/find-replace.service';-import type { IUniverFindReplaceConfig } from './controllers/config.schema';-import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';const PLUGIN_NAME = 'UNIVER_FIND_REPLACE_PLUGIN';@@ -43,10 +43,10 @@ export class UniverFindReplacePlugin extends Plugin {([[FindReplaceController],[IFindReplaceService, { useClass: FindReplaceService }],- ] as Dependency[]).forEach(- (d) => {- this._injector.add(d);- }- );+ ] as Dependency[]).forEach((d) => this._injector.add(d));+ }++ override onRendered(): void {+ this._injector.get(FindReplaceController);}}diff --git a/packages/rpc/src/controllers/data-sync/data-sync-primary.controller.ts b/packages/rpc/src/controllers/data-sync/data-sync-primary.controller.tsindex 5853c97e33..3a150cd3e7 100644--- a/packages/rpc/src/controllers/data-sync/data-sync-primary.controller.ts+++ b/packages/rpc/src/controllers/data-sync/data-sync-primary.controller.ts@@ -15,21 +15,18 @@*/import type { IDisposable, IMutation, IMutationInfo, Workbook } from '@univerjs/core';+import type { IRemoteSyncMutationOptions } from '../../services/remote-instance/remote-instance.service';import {CommandType,ICommandService,Inject,Injector,IUniverInstanceService,- LifecycleStages,- OnLifecycle,RxDisposable,toDisposable,UniverInstanceType,} from '@univerjs/core';import { takeUntil } from 'rxjs/operators';--import type { IRemoteSyncMutationOptions } from '../../services/remote-instance/remote-instance.service';import {IRemoteInstanceService,IRemoteSyncService,@@ -45,7 +42,6 @@ import { fromModule, toModule } from '../../services/rpc/rpc.service';** Note that only spreadsheets will be synced to the remote calculation instance by default.*/-@OnLifecycle(LifecycleStages.Starting, DataSyncPrimaryController)export class DataSyncPrimaryController extends RxDisposable {private _remoteInstanceService!: IRemoteInstanceService;diff --git a/packages/rpc/src/controllers/data-sync/data-sync-replica.controller.ts b/packages/rpc/src/controllers/data-sync/data-sync-replica.controller.tsindex 3f0816b8fd..9bccd8d652 100644--- a/packages/rpc/src/controllers/data-sync/data-sync-replica.controller.ts+++ b/packages/rpc/src/controllers/data-sync/data-sync-replica.controller.ts@@ -15,9 +15,8 @@*/import type { IMutationInfo } from '@univerjs/core';-import { CommandType, Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';-import type { IRemoteSyncMutationOptions } from '../../services/remote-instance/remote-instance.service';+import { CommandType, Disposable, ICommandService, Inject, Injector } from '@univerjs/core';import {IRemoteInstanceService,IRemoteSyncService,@@ -31,7 +30,6 @@ import { fromModule, toModule } from '../../services/rpc/rpc.service';* This controller is responsible for syncing data from the worker thread to* the primary thread.*/-@OnLifecycle(LifecycleStages.Starting, DataSyncReplicaController)export class DataSyncReplicaController extends Disposable {private _remoteSyncService!: IRemoteSyncService;diff --git a/packages/rpc/src/plugin.ts b/packages/rpc/src/plugin.tsindex 41969d4d1f..43ec115ac8 100644--- a/packages/rpc/src/plugin.ts+++ b/packages/rpc/src/plugin.ts@@ -14,9 +14,17 @@* limitations under the License.*/-import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core';import type { Dependency } from '@univerjs/core';-+import type {+ IUniverRPCMainThreadConfig,+ IUniverRPCWorkerThreadConfig,+} from './controllers/config.schema';+import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core';+import {+ defaultPluginMainThreadConfig,+ defaultPluginWorkerThreadConfig,+ PLUGIN_CONFIG_KEY_MAIN_THREAD, PLUGIN_CONFIG_KEY_WORKER_THREAD,+} from './controllers/config.schema';import { DataSyncPrimaryController } from './controllers/data-sync/data-sync-primary.controller';import { DataSyncReplicaController } from './controllers/data-sync/data-sync-replica.controller';import {@@ -30,14 +38,6 @@ import {createWebWorkerMessagePortOnMain,createWebWorkerMessagePortOnWorker,} from './services/rpc/implementations/web-worker-rpc.service';-import type {- IUniverRPCMainThreadConfig,- IUniverRPCWorkerThreadConfig } from './controllers/config.schema';-import {- defaultPluginMainThreadConfig,- defaultPluginWorkerThreadConfig,- PLUGIN_CONFIG_KEY_MAIN_THREAD, PLUGIN_CONFIG_KEY_WORKER_THREAD,-} from './controllers/config.schema';/*** This plugin is used to register the RPC services on the main thread. Itdiff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.auto-fill.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.auto-fill.controller.tsindex 91b9ef0efa..e8094b4369 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.auto-fill.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.auto-fill.controller.ts@@ -15,24 +15,20 @@*/import type { IMutationInfo, IRange, Workbook } from '@univerjs/core';-import { Disposable, Inject, Injector, IUniverInstanceService, LifecycleStages, ObjectMatrix, OnLifecycle, Range, Rectangle, UniverInstanceType } from '@univerjs/core';-import { createTopMatrixFromMatrix, findAllRectangle } from '@univerjs/sheets';-+import type { IDeleteConditionalRuleMutationParams, ISetConditionalRuleMutationParams } from '@univerjs/sheets-conditional-formatting';import type { IDiscreteRange, ISheetAutoFillHook } from '@univerjs/sheets-ui';-import { APPLY_TYPE, getAutoFillRepeatRange, IAutoFillService, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';+import { Disposable, Inject, Injector, IUniverInstanceService, ObjectMatrix, Range, Rectangle, UniverInstanceType } from '@univerjs/core';+import { createTopMatrixFromMatrix, findAllRectangle } from '@univerjs/sheets';import { ConditionalFormattingRuleModel, ConditionalFormattingViewModel, DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, SetConditionalRuleMutation, setConditionalRuleMutationUndoFactory, SHEET_CONDITIONAL_FORMATTING_PLUGIN } from '@univerjs/sheets-conditional-formatting';-import type { IDeleteConditionalRuleMutationParams, ISetConditionalRuleMutationParams } from '@univerjs/sheets-conditional-formatting';+import { APPLY_TYPE, getAutoFillRepeatRange, IAutoFillService, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';-@OnLifecycle(LifecycleStages.Rendered, ConditionalFormattingAutoFillController)export class ConditionalFormattingAutoFillController extends Disposable {constructor(@Inject(Injector) private _injector: Injector,@Inject(IUniverInstanceService) private _univerInstanceService: IUniverInstanceService,@Inject(IAutoFillService) private _autoFillService: IAutoFillService,@Inject(ConditionalFormattingRuleModel) private _conditionalFormattingRuleModel: ConditionalFormattingRuleModel,-@Inject(ConditionalFormattingViewModel) private _conditionalFormattingViewModel: ConditionalFormattingViewModel-) {super();diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.clear.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.clear.controller.tsindex 050bfa32b6..47019f0e82 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.clear.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.clear.controller.ts@@ -14,13 +14,12 @@* limitations under the License.*/-import { Disposable, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, Rectangle, UniverInstanceType } from '@univerjs/core';import type { IMutationInfo, IRange, Workbook } from '@univerjs/core';+import type { IConditionalFormattingRuleConfig, IConditionFormattingRule, IDeleteConditionalRuleMutationParams, ISetConditionalRuleMutationParams } from '@univerjs/sheets-conditional-formatting';+import { Disposable, Inject, Injector, IUniverInstanceService, Rectangle, UniverInstanceType } from '@univerjs/core';import { ClearSelectionAllCommand, ClearSelectionFormatCommand, RangeMergeUtil, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';import { ConditionalFormattingRuleModel, DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, SetConditionalRuleMutation, setConditionalRuleMutationUndoFactory } from '@univerjs/sheets-conditional-formatting';-import type { IConditionalFormattingRuleConfig, IConditionFormattingRule, IDeleteConditionalRuleMutationParams, ISetConditionalRuleMutationParams } from '@univerjs/sheets-conditional-formatting';-@OnLifecycle(LifecycleStages.Rendered, ConditionalFormattingClearController)export class ConditionalFormattingClearController extends Disposable {constructor(@Inject(Injector) private _injector: Injector,diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.copy-paste.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.copy-paste.controller.tsindex a5129ce6a0..693f6c001b 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.copy-paste.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.copy-paste.controller.ts@@ -15,14 +15,14 @@*/import type { IRange, Nullable, Workbook } from '@univerjs/core';+import type { IAddConditionalRuleMutationParams, IConditionalFormattingRuleConfig, IConditionFormattingRule, IDeleteConditionalRuleMutationParams, ISetConditionalRuleMutationParams } from '@univerjs/sheets-conditional-formatting';+import type { IDiscreteRange } from '@univerjs/sheets-ui';import {Disposable,Inject,Injector,IUniverInstanceService,- LifecycleStages,ObjectMatrix,- OnLifecycle,Range,Rectangle,Tools,@@ -31,12 +31,9 @@ import {import {createTopMatrixFromMatrix, findAllRectangle,} from '@univerjs/sheets';-import type { IDiscreteRange } from '@univerjs/sheets-ui';-import { COPY_TYPE, getRepeatRange, ISheetClipboardService, PREDEFINED_HOOK_NAME, rangeToDiscreteRange, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';import { AddConditionalRuleMutation, AddConditionalRuleMutationUndoFactory, ConditionalFormattingRuleModel, ConditionalFormattingViewModel, DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, SetConditionalRuleMutation, setConditionalRuleMutationUndoFactory, SHEET_CONDITIONAL_FORMATTING_PLUGIN } from '@univerjs/sheets-conditional-formatting';-import type { IAddConditionalRuleMutationParams, IConditionalFormattingRuleConfig, IConditionFormattingRule, IDeleteConditionalRuleMutationParams, ISetConditionalRuleMutationParams } from '@univerjs/sheets-conditional-formatting';+import { COPY_TYPE, getRepeatRange, ISheetClipboardService, PREDEFINED_HOOK_NAME, rangeToDiscreteRange, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';-@OnLifecycle(LifecycleStages.Rendered, ConditionalFormattingCopyPasteController)export class ConditionalFormattingCopyPasteController extends Disposable {private _copyInfo: Nullable<{matrix: ObjectMatrix<string[]>;diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.editor.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.editor.controller.tsindex 8626b9f06c..c70d957612 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.editor.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.editor.controller.ts@@ -18,15 +18,12 @@ import {BuildTextUtils,Disposable,Inject,- LifecycleStages,- OnLifecycle,toDisposable,} from '@univerjs/core';import { ConditionalFormattingService } from '@univerjs/sheets-conditional-formatting';import { IEditorBridgeService } from '@univerjs/sheets-ui';-@OnLifecycle(LifecycleStages.Rendered, ConditionalFormattingEditorController)export class ConditionalFormattingEditorController extends Disposable {constructor(@Inject(IEditorBridgeService) private _editorBridgeService: IEditorBridgeService,diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.i18n.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.i18n.controller.tsindex 4200fbfaee..3e26c8358a 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.i18n.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.i18n.controller.ts@@ -14,11 +14,9 @@* limitations under the License.*/-import { Disposable, Inject, LifecycleStages, LocaleService, OnLifecycle } from '@univerjs/core';-import type { ReactNode } from 'react';+import { Disposable, Inject, LocaleService } from '@univerjs/core';-@OnLifecycle(LifecycleStages.Rendered, ConditionalFormattingI18nController)export class ConditionalFormattingI18nController extends Disposable {constructor(@Inject(LocaleService) private _localeService: LocaleService) {super();diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.menu.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.menu.controller.tsindex db33d926d2..544b04c6c0 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.menu.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.menu.controller.ts@@ -15,11 +15,10 @@*/import type { IDisposable } from '@univerjs/core';-import { Disposable, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, Inject, Injector } from '@univerjs/core';import { IMenuManagerService } from '@univerjs/ui';import { menuSchema } from './menu.schema';-@OnLifecycle(LifecycleStages.Ready, ConditionalFormattingMenuController)export class ConditionalFormattingMenuController extends Disposable {private _sidebarDisposable: IDisposable | null = null;diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.painter.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.painter.controller.tsindex 57045fb29b..0a098c37a2 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.painter.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.painter.controller.ts@@ -14,13 +14,13 @@* limitations under the License.*/-import { Disposable, Inject, Injector, IUniverInstanceService, LifecycleStages, ObjectMatrix, OnLifecycle, Range, Rectangle, Tools, UniverInstanceType } from '@univerjs/core';-import { createTopMatrixFromMatrix, findAllRectangle, SheetsSelectionsService } from '@univerjs/sheets';-import { AddConditionalRuleMutation, AddConditionalRuleMutationUndoFactory, ConditionalFormattingRuleModel, ConditionalFormattingViewModel, DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, SetConditionalRuleMutation, setConditionalRuleMutationUndoFactory, SHEET_CONDITIONAL_FORMATTING_PLUGIN } from '@univerjs/sheets-conditional-formatting';-import { FormatPainterStatus, IFormatPainterService } from '@univerjs/sheets-ui';import type { IMutationInfo, IRange, Nullable, Workbook } from '@univerjs/core';import type { IAddConditionalRuleMutationParams, IDeleteConditionalRuleMutationParams, ISetConditionalRuleMutationParams } from '@univerjs/sheets-conditional-formatting';import type { IFormatPainterHook } from '@univerjs/sheets-ui';+import { Disposable, Inject, Injector, IUniverInstanceService, ObjectMatrix, Range, Rectangle, Tools, UniverInstanceType } from '@univerjs/core';+import { createTopMatrixFromMatrix, findAllRectangle, SheetsSelectionsService } from '@univerjs/sheets';+import { AddConditionalRuleMutation, AddConditionalRuleMutationUndoFactory, ConditionalFormattingRuleModel, ConditionalFormattingViewModel, DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, SetConditionalRuleMutation, setConditionalRuleMutationUndoFactory, SHEET_CONDITIONAL_FORMATTING_PLUGIN } from '@univerjs/sheets-conditional-formatting';+import { FormatPainterStatus, IFormatPainterService } from '@univerjs/sheets-ui';const repeatByRange = (sourceRange: IRange, targetRange: IRange) => {const getRowLength = (range: IRange) => range.endRow - range.startRow + 1;@@ -73,7 +73,6 @@ const repeatByRange = (sourceRange: IRange, targetRange: IRange) => {return repeatList;};-@OnLifecycle(LifecycleStages.Rendered, ConditionalFormattingPainterController)export class ConditionalFormattingPainterController extends Disposable {private _painterConfig: Nullable<{ unitId: string; subUnitId: string; range: IRange }> = null;constructor(diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.panel.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.panel.controller.tsindex 40a9b479d9..9d671e93d6 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.panel.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.panel.controller.ts@@ -15,13 +15,13 @@*/import type { IDisposable } from '@univerjs/core';-import { Disposable, generateRandomId, Inject, Injector, IUniverInstanceService, LifecycleStages, LocaleService, OnLifecycle, UniverInstanceType } from '@univerjs/core';-import { ComponentManager, ISidebarService } from '@univerjs/ui';import type { IConditionFormattingRule } from '@univerjs/sheets-conditional-formatting';+import { Disposable, generateRandomId, Inject, Injector, IUniverInstanceService, LocaleService, UniverInstanceType } from '@univerjs/core';+import { ComponentManager, ISidebarService } from '@univerjs/ui';import { ConditionFormattingPanel } from '../components/panel';const CF_PANEL_KEY = 'sheet.conditional.formatting.panel';-@OnLifecycle(LifecycleStages.Ready, ConditionalFormattingPanelController)+export class ConditionalFormattingPanelController extends Disposable {private _sidebarDisposable: IDisposable | null = null;diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.permission.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.permission.controller.tsindex 05e042db09..9f75c5367b 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.permission.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.permission.controller.ts@@ -15,14 +15,12 @@*/import type { ICommandInfo } from '@univerjs/core';-import { Disposable, ICommandService, Inject, LifecycleStages, LocaleService, OnLifecycle } from '@univerjs/core';+import type { IAddCfCommandParams } from '../commands/commands/add-cf.command';+import { Disposable, ICommandService, Inject, LocaleService } from '@univerjs/core';import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission } from '@univerjs/sheets';-import { SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';-import type { IAddCfCommandParams } from '../commands/commands/add-cf.command';import { AddCfCommand } from '../commands/commands/add-cf.command';-@OnLifecycle(LifecycleStages.Rendered, ConditionalFormattingPermissionController)export class ConditionalFormattingPermissionController extends Disposable {constructor(@Inject(LocaleService) private _localeService: LocaleService,diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.ref-range.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.ref-range.controller.tsindex 78c5b6ffc8..783235b26f 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.ref-range.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.ref-range.controller.ts@@ -15,13 +15,12 @@*/import type { IRange, Workbook } from '@univerjs/core';-import { Disposable, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, toDisposable, UniverInstanceType } from '@univerjs/core';import type { EffectRefRangeParams } from '@univerjs/sheets';+import type { IConditionFormattingRule, IDeleteConditionalRuleMutationParams, ISetConditionalRuleMutationParams } from '@univerjs/sheets-conditional-formatting';+import { Disposable, Inject, Injector, IUniverInstanceService, toDisposable, UniverInstanceType } from '@univerjs/core';import { handleDefaultRangeChangeWithEffectRefCommands, RefRangeService } from '@univerjs/sheets';import { ConditionalFormattingRuleModel, DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, isRangesEqual, SetConditionalRuleMutation, setConditionalRuleMutationUndoFactory } from '@univerjs/sheets-conditional-formatting';-import type { IConditionFormattingRule, IDeleteConditionalRuleMutationParams, ISetConditionalRuleMutationParams } from '@univerjs/sheets-conditional-formatting';-@OnLifecycle(LifecycleStages.Rendered, SheetsCfRefRangeController)export class SheetsCfRefRangeController extends Disposable {constructor(@Inject(ConditionalFormattingRuleModel) private _conditionalFormattingRuleModel: ConditionalFormattingRuleModel,diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.tsindex bac47256f7..69a0073fbf 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts@@ -14,16 +14,15 @@* limitations under the License.*/-import { Disposable, Inject, InterceptorEffectEnum, IUniverInstanceService, LifecycleStages, OnLifecycle, Range, UniverInstanceType } from '@univerjs/core';+import type { ICellDataForSheetInterceptor, Workbook } from '@univerjs/core';+import type { IConditionalFormattingCellData, IConditionFormattingRule } from '@univerjs/sheets-conditional-formatting';+import { Disposable, Inject, InterceptorEffectEnum, IUniverInstanceService, Range, UniverInstanceType } from '@univerjs/core';import { IRenderManagerService } from '@univerjs/engine-render';import { INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';import { ConditionalFormattingRuleModel, ConditionalFormattingService, ConditionalFormattingViewModel, DEFAULT_PADDING, DEFAULT_WIDTH } from '@univerjs/sheets-conditional-formatting';import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';import { bufferTime, filter } from 'rxjs/operators';-import type { ICellDataForSheetInterceptor, Workbook } from '@univerjs/core';-import type { IConditionalFormattingCellData, IConditionFormattingRule } from '@univerjs/sheets-conditional-formatting';-@OnLifecycle(LifecycleStages.Starting, SheetsCfRenderController)export class SheetsCfRenderController extends Disposable {/*** When a set operation is triggered multiple times over a short period of time, it may result in some callbacks not being disposed,and caused a render cache exception.diff --git a/packages/sheets-conditional-formatting-ui/src/plugin.ts b/packages/sheets-conditional-formatting-ui/src/plugin.tsindex 39e350bb27..2af214f451 100644--- a/packages/sheets-conditional-formatting-ui/src/plugin.ts+++ b/packages/sheets-conditional-formatting-ui/src/plugin.ts@@ -14,6 +14,7 @@* limitations under the License.*/+import type { IUniverSheetsConditionalFormattingUIConfig } from './controllers/config.schema';import {DependentOn,ICommandService,@@ -39,8 +40,8 @@ import { ClearWorksheetCfCommand } from './commands/commands/clear-worksheet-cf.import { DeleteCfCommand } from './commands/commands/delete-cf.command';import { MoveCfCommand } from './commands/commands/move-cf.command';import { SetCfCommand } from './commands/commands/set-cf.command';-import { OpenConditionalFormattingOperator } from './commands/operations/open-conditional-formatting-panel';+import { OpenConditionalFormattingOperator } from './commands/operations/open-conditional-formatting-panel';import { ConditionalFormattingAutoFillController } from './controllers/cf.auto-fill.controller';import { ConditionalFormattingClearController } from './controllers/cf.clear.controller';import { ConditionalFormattingCopyPasteController } from './controllers/cf.copy-paste.controller';@@ -53,7 +54,6 @@ import { ConditionalFormattingPermissionController } from './controllers/cf.permimport { SheetsCfRefRangeController } from './controllers/cf.ref-range.controller';import { SheetsCfRenderController } from './controllers/cf.render.controller';import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';-import type { IUniverSheetsConditionalFormattingUIConfig } from './controllers/config.schema';@DependentOn(UniverSheetsConditionalFormattingPlugin)export class UniverSheetsConditionalFormattingUIPlugin extends Plugin {@@ -90,6 +90,26 @@ export class UniverSheetsConditionalFormattingUIPlugin extends Plugin {this._injector.add([ConditionalFormattingPainterController]);}+ override onStarting(): void {+ this._injector.get(SheetsCfRenderController);+ }++ override onReady(): void {+ this._injector.get(ConditionalFormattingMenuController);+ this._injector.get(ConditionalFormattingPanelController);+ }++ override onRendered(): void {+ this._injector.get(ConditionalFormattingAutoFillController);+ this._injector.get(ConditionalFormattingClearController);+ this._injector.get(ConditionalFormattingCopyPasteController);+ this._injector.get(ConditionalFormattingEditorController);+ this._injector.get(ConditionalFormattingI18nController);+ this._injector.get(ConditionalFormattingPainterController);+ this._injector.get(ConditionalFormattingPermissionController);+ this._injector.get(SheetsCfRefRangeController);+ }+private _initCommand() {[AddAverageCfCommand,diff --git a/packages/sheets-conditional-formatting/src/plugin.ts b/packages/sheets-conditional-formatting/src/plugin.tsindex 2c203a3fce..18a4187b2c 100644--- a/packages/sheets-conditional-formatting/src/plugin.ts+++ b/packages/sheets-conditional-formatting/src/plugin.ts@@ -14,24 +14,23 @@* limitations under the License.*/-import { ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import type { Dependency } from '@univerjs/core';+import type { IUniverSheetsConditionalFormattingConfig } from './controllers/config.schema';+import { ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import { SHEET_CONDITIONAL_FORMATTING_PLUGIN } from './base/const';-import { ConditionalFormattingService } from './services/conditional-formatting.service';-import { ConditionalFormattingRuleModel } from './models/conditional-formatting-rule-model';-import { ConditionalFormattingViewModel } from './models/conditional-formatting-view-model';import { AddConditionalRuleMutation } from './commands/mutations/add-conditional-rule.mutation';import { DeleteConditionalRuleMutation } from './commands/mutations/delete-conditional-rule.mutation';-import { SetConditionalRuleMutation } from './commands/mutations/set-conditional-rule.mutation';--import { MoveConditionalRuleMutation } from './commands/mutations/move-conditional-rule.mutation';-import { ConditionalFormattingFormulaService } from './services/conditional-formatting-formula.service';import { ConditionalFormattingFormulaMarkDirty } from './commands/mutations/formula-mark-dirty.mutation';-import type { IUniverSheetsConditionalFormattingConfig } from './controllers/config.schema';+import { MoveConditionalRuleMutation } from './commands/mutations/move-conditional-rule.mutation';+import { SetConditionalRuleMutation } from './commands/mutations/set-conditional-rule.mutation';import {defaultPluginConfig,PLUGIN_CONFIG_KEY,} from './controllers/config.schema';+import { ConditionalFormattingRuleModel } from './models/conditional-formatting-rule-model';+import { ConditionalFormattingViewModel } from './models/conditional-formatting-view-model';+import { ConditionalFormattingService } from './services/conditional-formatting.service';+import { ConditionalFormattingFormulaService } from './services/conditional-formatting-formula.service';export class UniverSheetsConditionalFormattingPlugin extends Plugin {static override pluginName = SHEET_CONDITIONAL_FORMATTING_PLUGIN;@@ -68,4 +67,8 @@ export class UniverSheetsConditionalFormattingPlugin extends Plugin {this._commandService.registerCommand(m);});}++ override onStarting(): void {+ this._injector.get(ConditionalFormattingService);+ }}diff --git a/packages/sheets-conditional-formatting/src/services/conditional-formatting-formula.service.ts b/packages/sheets-conditional-formatting/src/services/conditional-formatting-formula.service.tsindex bb7cffc81e..3800b39482 100644--- a/packages/sheets-conditional-formatting/src/services/conditional-formatting-formula.service.ts+++ b/packages/sheets-conditional-formatting/src/services/conditional-formatting-formula.service.ts@@ -15,21 +15,21 @@*/import type { ICellData, Nullable, ObjectMatrix } from '@univerjs/core';-import { BooleanNumber, CellValueType, Disposable, ICommandService, Inject, Injector, RefAlias, toDisposable, Tools } from '@univerjs/core';import type { IRemoveOtherFormulaMutationParams, ISetFormulaCalculationResultMutation, ISetOtherFormulaMutationParams } from '@univerjs/engine-formula';+import type { IConditionalFormattingFormulaMarkDirtyParams } from '../commands/mutations/formula-mark-dirty.mutation';+import { BooleanNumber, CellValueType, Disposable, ICommandService, Inject, Injector, RefAlias, toDisposable, Tools } from '@univerjs/core';+import {IActiveDirtyManagerService,RemoveOtherFormulaMutation,SetFormulaCalculationResultMutation,SetOtherFormulaMutation,} from '@univerjs/engine-formula';-import { Subject } from 'rxjs';import { bufferTime, filter, map } from 'rxjs/operators';-import type { IConditionalFormattingFormulaMarkDirtyParams } from '../commands/mutations/formula-mark-dirty.mutation';import { ConditionalFormattingFormulaMarkDirty } from '../commands/mutations/formula-mark-dirty.mutation';-import { ConditionalFormattingViewModel } from '../models/conditional-formatting-view-model';import { ConditionalFormattingRuleModel } from '../models/conditional-formatting-rule-model';+import { ConditionalFormattingViewModel } from '../models/conditional-formatting-view-model';import { ConditionalFormattingService } from './conditional-formatting.service';// eslint-disable-next-line ts/consistent-type-definitionsdiff --git a/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts b/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.tsindex b5cba6c2de..8208aac073 100644--- a/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts+++ b/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts@@ -20,7 +20,7 @@ import type { IDeleteConditionalRuleMutationParams } from '../commands/mutationsimport type { IConditionFormattingRule, IHighlightCell, IRuleModelJson } from '../models/type';import type { IDataBarCellData, IDataBarRenderParams, IIconSetCellData, IIconSetRenderParams } from '../render/type';import type { ICalculateUnit, IContext } from './calculate-unit/type';-import { createInterceptorKey, Disposable, ICommandService, Inject, Injector, InterceptorManager, IResourceManagerService, IUniverInstanceService, LifecycleStages, ObjectMatrix, OnLifecycle, Rectangle, Tools, UniverInstanceType } from '@univerjs/core';+import { createInterceptorKey, Disposable, ICommandService, Inject, Injector, InterceptorManager, IResourceManagerService, IUniverInstanceService, ObjectMatrix, Rectangle, Tools, UniverInstanceType } from '@univerjs/core';import { InsertColMutation, InsertRowMutation, MoveColsMutation, MoveRangeMutation, MoveRowsMutation, RemoveColMutation, RemoveRowMutation, RemoveSheetCommand, ReorderRangeMutation, SetRangeValuesMutation, SheetInterceptorService } from '@univerjs/sheets';import { Subject } from 'rxjs';import { bufferTime, filter, map } from 'rxjs/operators';@@ -39,7 +39,7 @@ type ComputeStatus = 'computing' | 'end' | 'error';interface IComputeCache { status: ComputeStatus };const beforeUpdateRuleResult = createInterceptorKey<{ subUnitId: string; unitId: string; cfId: string }, undefined>('conditional-formatting-before-update-rule-result');-@OnLifecycle(LifecycleStages.Starting, ConditionalFormattingService)+export class ConditionalFormattingService extends Disposable {// <unitId,<subUnitId,<cfId,IComputeCache>>>private _ruleCacheMap: Map<string, Map<string, Map<string, IComputeCache>>> = new Map();diff --git a/packages/sheets-data-validation-ui/src/controllers/dv-alert.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-alert.controller.tsindex ab8a51bd7b..bf07a91249 100644--- a/packages/sheets-data-validation-ui/src/controllers/dv-alert.controller.ts+++ b/packages/sheets-data-validation-ui/src/controllers/dv-alert.controller.ts@@ -16,14 +16,13 @@import type { Workbook } from '@univerjs/core';import type { BaseDataValidator } from '@univerjs/data-validation';-import { DataValidationStatus, Disposable, Inject, IUniverInstanceService, LifecycleStages, LocaleService, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import { DataValidationStatus, Disposable, Inject, IUniverInstanceService, LocaleService, UniverInstanceType } from '@univerjs/core';import { CellAlertManagerService, CellAlertType, HoverManagerService } from '@univerjs/sheets-ui';import { IZenZoneService } from '@univerjs/ui';import { debounceTime } from 'rxjs';const ALERT_KEY = 'SHEET_DATA_VALIDATION_ALERT';-@OnLifecycle(LifecycleStages.Rendered, DataValidationAlertController)export class DataValidationAlertController extends Disposable {constructor(@Inject(HoverManagerService) private readonly _hoverManagerService: HoverManagerService,diff --git a/packages/sheets-data-validation-ui/src/controllers/dv-auto-fill.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-auto-fill.controller.tsindex e8bd108197..0535e65f8a 100644--- a/packages/sheets-data-validation-ui/src/controllers/dv-auto-fill.controller.ts+++ b/packages/sheets-data-validation-ui/src/controllers/dv-auto-fill.controller.ts@@ -15,13 +15,12 @@*/import type { IAutoFillLocation, ISheetAutoFillHook } from '@univerjs/sheets-ui';-import { DataValidationType, Disposable, Inject, Injector, LifecycleStages, ObjectMatrix, OnLifecycle, queryObjectMatrix, Range, Rectangle } from '@univerjs/core';+import { DataValidationType, Disposable, Inject, Injector, ObjectMatrix, queryObjectMatrix, Range, Rectangle } from '@univerjs/core';import { DATA_VALIDATION_PLUGIN_NAME, getDataValidationDiffMutations, SheetDataValidationModel } from '@univerjs/sheets-data-validation';import { APPLY_TYPE, getAutoFillRepeatRange, IAutoFillService, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';// TODO: adjust imports-@OnLifecycle(LifecycleStages.Ready, DataValidationAutoFillController)export class DataValidationAutoFillController extends Disposable {constructor(@IAutoFillService private readonly _autoFillService: IAutoFillService,diff --git a/packages/sheets-data-validation-ui/src/controllers/dv-copy-paste.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-copy-paste.controller.tsindex cedf33ca2b..7a461f1c75 100644--- a/packages/sheets-data-validation-ui/src/controllers/dv-copy-paste.controller.ts+++ b/packages/sheets-data-validation-ui/src/controllers/dv-copy-paste.controller.ts@@ -16,11 +16,10 @@import type { IRange, ISheetDataValidationRule, Nullable } from '@univerjs/core';import type { IDiscreteRange } from '@univerjs/sheets-ui';-import { Disposable, Inject, Injector, LifecycleStages, ObjectMatrix, OnLifecycle, queryObjectMatrix, Rectangle } from '@univerjs/core';+import { Disposable, Inject, Injector, ObjectMatrix, queryObjectMatrix, Rectangle } from '@univerjs/core';import { DATA_VALIDATION_PLUGIN_NAME, getDataValidationDiffMutations, SheetDataValidationModel } from '@univerjs/sheets-data-validation';import { COPY_TYPE, getRepeatRange, ISheetClipboardService, PREDEFINED_HOOK_NAME, rangeToDiscreteRange, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';-@OnLifecycle(LifecycleStages.Ready, DataValidationCopyPasteController)export class DataValidationCopyPasteController extends Disposable {private _copyInfo: Nullable<{matrix: ObjectMatrix<string>;diff --git a/packages/sheets-data-validation-ui/src/controllers/dv-permission.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-permission.controller.tsindex 20d33a3022..d53cb9fde6 100644--- a/packages/sheets-data-validation-ui/src/controllers/dv-permission.controller.ts+++ b/packages/sheets-data-validation-ui/src/controllers/dv-permission.controller.ts@@ -16,12 +16,11 @@import type { ICommandInfo } from '@univerjs/core';import type { IUpdateSheetDataValidationRangeCommandParams } from '@univerjs/sheets-data-validation';-import { Disposable, ICommandService, Inject, LifecycleStages, LocaleService, OnLifecycle } from '@univerjs/core';+import { Disposable, ICommandService, Inject, LocaleService } from '@univerjs/core';import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission } from '@univerjs/sheets';import { AddSheetDataValidationCommand, UpdateSheetDataValidationRangeCommand } from '@univerjs/sheets-data-validation';import { SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';-@OnLifecycle(LifecycleStages.Ready, DataValidationPermissionController)export class DataValidationPermissionController extends Disposable {constructor(@Inject(LocaleService) private _localeService: LocaleService,diff --git a/packages/sheets-data-validation-ui/src/controllers/dv-reject-input.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-reject-input.controller.tsindex 93f97d7051..e5ac5f27a9 100644--- a/packages/sheets-data-validation-ui/src/controllers/dv-reject-input.controller.ts+++ b/packages/sheets-data-validation-ui/src/controllers/dv-reject-input.controller.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { DataValidationErrorStyle, Disposable, Inject, LifecycleStages, LocaleService, OnLifecycle } from '@univerjs/core';+import { DataValidationErrorStyle, Disposable, Inject, LocaleService } from '@univerjs/core';import { DataValidatorRegistryService } from '@univerjs/data-validation';import { Button } from '@univerjs/design';import { getCellValueOrigin, SheetDataValidationModel } from '@univerjs/sheets-data-validation';@@ -22,7 +22,6 @@ import { IEditorBridgeService } from '@univerjs/sheets-ui';import { IDialogService } from '@univerjs/ui';import React from 'react';-@OnLifecycle(LifecycleStages.Ready, DataValidationRejectInputController)export class DataValidationRejectInputController extends Disposable {constructor(@IEditorBridgeService private readonly _editorBridgeService: IEditorBridgeService,diff --git a/packages/sheets-data-validation-ui/src/controllers/dv-render.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-render.controller.tsindex 2c988d3a03..88f2169901 100644--- a/packages/sheets-data-validation-ui/src/controllers/dv-render.controller.ts+++ b/packages/sheets-data-validation-ui/src/controllers/dv-render.controller.ts@@ -15,7 +15,7 @@*/import type { CellValue, ICellRenderContext, IRange, Nullable } from '@univerjs/core';-import { DataValidationStatus, DataValidationType, ICommandService, Inject, InterceptorEffectEnum, IUniverInstanceService, LifecycleStages, OnLifecycle, Optional, RxDisposable, sequenceExecute } from '@univerjs/core';+import { DataValidationStatus, DataValidationType, ICommandService, Inject, InterceptorEffectEnum, IUniverInstanceService, Optional, RxDisposable, sequenceExecute } from '@univerjs/core';import { DataValidatorRegistryService } from '@univerjs/data-validation';import { IRenderManagerService } from '@univerjs/engine-render';import { InterceptCellContentPriority, INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';@@ -33,7 +33,6 @@ const INVALID_MARK = {},};-@OnLifecycle(LifecycleStages.Rendered, SheetsDataValidationRenderController)export class SheetsDataValidationRenderController extends RxDisposable {constructor(@ICommandService private readonly _commandService: ICommandService,@@ -258,7 +257,6 @@ export class SheetsDataValidationRenderController extends RxDisposable {}// The mobile version does not provide the ability to change data validation model.-@OnLifecycle(LifecycleStages.Rendered, SheetsDataValidationMobileRenderController)export class SheetsDataValidationMobileRenderController extends RxDisposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/sheets-data-validation-ui/src/controllers/dv-ui.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-ui.controller.tsindex f6960a4756..4a337ab7ad 100644--- a/packages/sheets-data-validation-ui/src/controllers/dv-ui.controller.ts+++ b/packages/sheets-data-validation-ui/src/controllers/dv-ui.controller.ts@@ -16,7 +16,7 @@import type { Ctor } from '@univerjs/core';import type { BaseSheetDataValidatorView } from '../views/validator-views/sheet-validator-view';-import { Inject, Injector, LifecycleStages, OnLifecycle, RxDisposable } from '@univerjs/core';+import { Inject, Injector, RxDisposable } from '@univerjs/core';import { DataValidatorRegistryService } from '@univerjs/data-validation';import { DataValidationSingle } from '@univerjs/icons';import { ComponentManager } from '@univerjs/ui';@@ -36,7 +36,6 @@ import { TextLengthValidatorView } from '../views/validator-views/text-length-vaimport { WholeValidatorView } from '../views/validator-views/whole-validator-view';import { DataValidationIcon } from './dv.menu';-@OnLifecycle(LifecycleStages.Rendered, SheetsDataValidationUIController)export class SheetsDataValidationUIController extends RxDisposable {constructor(@Inject(Injector) private readonly _injector: Injector,diff --git a/packages/sheets-data-validation-ui/src/index.ts b/packages/sheets-data-validation-ui/src/index.tsindex 43c875ed23..a436bbaddc 100644--- a/packages/sheets-data-validation-ui/src/index.ts+++ b/packages/sheets-data-validation-ui/src/index.ts@@ -16,3 +16,4 @@export { DATE_DROPDOWN_KEY, LIST_DROPDOWN_KEY } from './views/components';export { UniverSheetsDataValidationUIPlugin } from './plugin';+export { UniverSheetsDataValidationMobileUIPlugin } from './mobile-plugin';diff --git a/packages/sheets-data-validation-ui/src/mobile-plugin.ts b/packages/sheets-data-validation-ui/src/mobile-plugin.tsnew file mode 100644index 0000000000..a3a20df719--- /dev/null+++ b/packages/sheets-data-validation-ui/src/mobile-plugin.ts@@ -0,0 +1,99 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Dependency } from '@univerjs/core';+import type { IUniverSheetsDataValidationConfig } from './controllers/config.schema';+import { ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';+import { AddSheetDataValidationAndOpenCommand } from './commands/commands/data-validation-ui.command';+import {+ CloseValidationPanelOperation,+ HideDataValidationDropdown,+ OpenValidationPanelOperation,+ ShowDataValidationDropdown,+ ToggleValidationPanelOperation,+} from './commands/operations/data-validation.operation';+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';+import { DataValidationAlertController } from './controllers/dv-alert.controller';+import { DataValidationAutoFillController } from './controllers/dv-auto-fill.controller';+import { DataValidationCopyPasteController } from './controllers/dv-copy-paste.controller';+import { DataValidationPermissionController } from './controllers/dv-permission.controller';+import { SheetsDataValidationRenderController } from './controllers/dv-render.controller';+import { SheetsDataValidationUIController } from './controllers/dv-ui.controller';+import { DataValidationPanelService } from './services/data-validation-panel.service';+import { DataValidationDropdownManagerService } from './services/dropdown-manager.service';++const PLUGIN_NAME = 'SHEET_DATA_VALIDATION_UI_PLUGIN';++export class UniverSheetsDataValidationMobileUIPlugin extends Plugin {+ static override pluginName: string = PLUGIN_NAME;+ static override type = UniverInstanceType.UNIVER_SHEET;++ constructor(+ private readonly _config: Partial<IUniverSheetsDataValidationConfig> = defaultPluginConfig,+ @Inject(Injector) protected readonly _injector: Injector,+ @ICommandService private readonly _commandService: ICommandService,+ @IConfigService private readonly _configService: IConfigService+ ) {+ super();++ // Manage the plugin configuration..+ const { menu, ...rest } = this._config;+ if (menu) {+ this._configService.setConfig('menu', menu, { merge: true });+ }+ this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);+ }++ override onStarting(): void {+ ([+ [DataValidationPanelService],+ [DataValidationDropdownManagerService],+ [DataValidationAlertController],+ [DataValidationAutoFillController],+ [SheetsDataValidationRenderController],+ [DataValidationPermissionController],+ [DataValidationCopyPasteController],+ [SheetsDataValidationUIController],+ ] as Dependency[]).forEach((dep) => {+ this._injector.add(dep);+ });++ [+ AddSheetDataValidationAndOpenCommand,+ ShowDataValidationDropdown,+ HideDataValidationDropdown,+ CloseValidationPanelOperation,+ OpenValidationPanelOperation,+ ToggleValidationPanelOperation,+ ].forEach((command) => {+ this._commandService.registerCommand(command);+ });+ }++ override onReady(): void {+ this._injector.get(DataValidationCopyPasteController);+ this._injector.get(DataValidationPermissionController);+ }++ override onRendered(): void {+ this._injector.get(SheetsDataValidationUIController);+ this._injector.get(SheetsDataValidationRenderController);+ }++ override onSteady(): void {+ this._injector.get(DataValidationAutoFillController);+ }+}diff --git a/packages/sheets-data-validation-ui/src/plugin.ts b/packages/sheets-data-validation-ui/src/plugin.tsindex 3cbe665044..7f04226fef 100644--- a/packages/sheets-data-validation-ui/src/plugin.ts+++ b/packages/sheets-data-validation-ui/src/plugin.ts@@ -84,4 +84,19 @@ export class UniverSheetsDataValidationUIPlugin extends Plugin {this._commandService.registerCommand(command);});}++ override onReady(): void {+ this._injector.get(DataValidationCopyPasteController);+ this._injector.get(DataValidationPermissionController);+ this._injector.get(DataValidationRejectInputController);+ }++ override onRendered(): void {+ this._injector.get(SheetsDataValidationUIController);+ this._injector.get(SheetsDataValidationRenderController);+ }++ override onSteady(): void {+ this._injector.get(DataValidationAutoFillController);+ }}diff --git a/packages/sheets-data-validation/src/controllers/dv-formula.controller.ts b/packages/sheets-data-validation/src/controllers/dv-formula.controller.tsindex a52abee820..f779935e38 100644--- a/packages/sheets-data-validation/src/controllers/dv-formula.controller.ts+++ b/packages/sheets-data-validation/src/controllers/dv-formula.controller.ts@@ -15,12 +15,11 @@*/import type { ICellDataForSheetInterceptor, Nullable, Workbook, Worksheet } from '@univerjs/core';-import { Disposable, Inject, IPermissionService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import { Disposable, Inject, IPermissionService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { deserializeRangeWithSheet, LexerTreeBuilder } from '@univerjs/engine-formula';-import { type ICellPermission, WorksheetViewPermission } from '@univerjs/sheets';import { UnitAction } from '@univerjs/protocol';+import { type ICellPermission, WorksheetViewPermission } from '@univerjs/sheets';-@OnLifecycle(LifecycleStages.Rendered, DataValidationFormulaController)export class DataValidationFormulaController extends Disposable {constructor(@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,diff --git a/packages/sheets-data-validation/src/controllers/dv-ref-range.controller.ts b/packages/sheets-data-validation/src/controllers/dv-ref-range.controller.tsindex 0d92021a52..652613e648 100644--- a/packages/sheets-data-validation/src/controllers/dv-ref-range.controller.ts+++ b/packages/sheets-data-validation/src/controllers/dv-ref-range.controller.ts@@ -17,7 +17,7 @@import type { ISheetDataValidationRule } from '@univerjs/core';import type { IRemoveDataValidationMutationParams, IUpdateDataValidationMutationParams } from '@univerjs/data-validation';import type { EffectRefRangeParams } from '@univerjs/sheets';-import { DataValidationType, Disposable, Inject, Injector, isRangesEqual, LifecycleStages, OnLifecycle, toDisposable } from '@univerjs/core';+import { DataValidationType, Disposable, Inject, Injector, isRangesEqual, toDisposable } from '@univerjs/core';import { RemoveDataValidationMutation, UpdateDataValidationMutation, UpdateRuleType } from '@univerjs/data-validation';import { handleCommonDefaultRangeChangeWithEffectRefCommands, RefRangeService } from '@univerjs/sheets';import { FormulaRefRangeService } from '@univerjs/sheets-formula';@@ -26,7 +26,6 @@ import { SheetDataValidationModel } from '../models/sheet-data-validation-model'import { DataValidationCustomFormulaService } from '../services/dv-custom-formula.service';import { DataValidationFormulaService } from '../services/dv-formula.service';-@OnLifecycle(LifecycleStages.Starting, DataValidationRefRangeController)export class DataValidationRefRangeController extends Disposable {private _disposableMap: Map<string, Set<() => void>> = new Map();diff --git a/packages/sheets-data-validation/src/controllers/dv-sheet.controller.ts b/packages/sheets-data-validation/src/controllers/dv-sheet.controller.tsindex 39ca7858f2..8d48287c48 100644--- a/packages/sheets-data-validation/src/controllers/dv-sheet.controller.ts+++ b/packages/sheets-data-validation/src/controllers/dv-sheet.controller.ts@@ -17,12 +17,11 @@import type { Workbook } from '@univerjs/core';import type { IAddDataValidationMutationParams, IRemoveDataValidationMutationParams } from '@univerjs/data-validation';import type { IRemoveSheetCommandParams } from '@univerjs/sheets';-import { Disposable, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import { Disposable, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { AddDataValidationMutation, RemoveDataValidationMutation } from '@univerjs/data-validation';import { RemoveSheetCommand, SheetInterceptorService } from '@univerjs/sheets';import { SheetDataValidationModel } from '../models/sheet-data-validation-model';-@OnLifecycle(LifecycleStages.Ready, SheetDataValidationSheetController)export class SheetDataValidationSheetController extends Disposable {constructor(@Inject(SheetInterceptorService) private _sheetInterceptorService: SheetInterceptorService,diff --git a/packages/sheets-data-validation/src/controllers/dv.controller.ts b/packages/sheets-data-validation/src/controllers/dv.controller.tsindex a9331f562a..8297355431 100644--- a/packages/sheets-data-validation/src/controllers/dv.controller.ts+++ b/packages/sheets-data-validation/src/controllers/dv.controller.ts@@ -15,7 +15,7 @@*/import type { Workbook } from '@univerjs/core';-import { Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, RxDisposable, toDisposable, UniverInstanceType } from '@univerjs/core';+import { Inject, Injector, IUniverInstanceService, RxDisposable, toDisposable, UniverInstanceType } from '@univerjs/core';import { DataValidatorRegistryService } from '@univerjs/data-validation';import { ClearSelectionAllCommand, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';import { getDataValidationDiffMutations } from '../commands/commands/data-validation.command';@@ -25,7 +25,6 @@ import { CustomFormulaValidator } from '../validators/custom-validator';import { ListMultipleValidator } from '../validators/list-multiple-validator';import { WholeValidator } from '../validators/whole-validator';-@OnLifecycle(LifecycleStages.Rendered, DataValidationController)export class DataValidationController extends RxDisposable {constructor(@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,diff --git a/packages/sheets-data-validation/src/models/sheet-data-validation-model.ts b/packages/sheets-data-validation/src/models/sheet-data-validation-model.tsindex b44ef3952f..da0164f1f8 100644--- a/packages/sheets-data-validation/src/models/sheet-data-validation-model.ts+++ b/packages/sheets-data-validation/src/models/sheet-data-validation-model.ts@@ -17,7 +17,7 @@import type { DataValidationType, ICellDataForSheetInterceptor, ISheetDataValidationRule, Nullable } from '@univerjs/core';import type { IRuleChange, IUpdateRulePayload, IValidStatusChange } from '@univerjs/data-validation';import type { IRemoveSheetMutationParams, ISheetLocation } from '@univerjs/sheets';-import { DataValidationStatus, Disposable, ICommandService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { DataValidationStatus, Disposable, ICommandService, Inject, IUniverInstanceService } from '@univerjs/core';import { DataValidationModel, DataValidatorRegistryService, UpdateRuleType } from '@univerjs/data-validation';import { RemoveSheetMutation } from '@univerjs/sheets';import { Subject } from 'rxjs';@@ -27,7 +27,6 @@ import { DataValidationFormulaService } from '../services/dv-formula.service';import { getCellValueOrigin } from '../utils/get-cell-data-origin';import { RuleMatrix } from './rule-matrix';-@OnLifecycle(LifecycleStages.Starting, SheetDataValidationModel)export class SheetDataValidationModel extends Disposable {private readonly _ruleMatrixMap = new Map<string, Map<string, RuleMatrix>>();private readonly _validStatusChange$ = new Subject<IValidStatusChange>();diff --git a/packages/sheets-data-validation/src/plugin.ts b/packages/sheets-data-validation/src/plugin.tsindex ee572b71fb..f2bcc45f22 100644--- a/packages/sheets-data-validation/src/plugin.ts+++ b/packages/sheets-data-validation/src/plugin.ts@@ -82,5 +82,16 @@ export class UniverSheetsDataValidationPlugin extends Plugin {].forEach((command) => {this._commandService.registerCommand(command);});++ this._injector.get(DataValidationRefRangeController);+ }++ override onReady(): void {+ this._injector.get(SheetDataValidationSheetController);+ }++ override onRendered(): void {+ this._injector.get(DataValidationController);+ this._injector.get(DataValidationFormulaController);}}diff --git a/packages/sheets-drawing-ui/src/controllers/drawing-popup-menu.controller.ts b/packages/sheets-drawing-ui/src/controllers/drawing-popup-menu.controller.tsindex 0baf745676..6c8c61b52b 100644--- a/packages/sheets-drawing-ui/src/controllers/drawing-popup-menu.controller.ts+++ b/packages/sheets-drawing-ui/src/controllers/drawing-popup-menu.controller.ts@@ -14,21 +14,20 @@* limitations under the License.*/-import { connectInjector, FOCUSING_COMMON_DRAWINGS, IContextService, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, RxDisposable, toDisposable, UniverInstanceType } from '@univerjs/core';+import type { IDisposable, Nullable, Workbook } from '@univerjs/core';+import type { BaseObject, Scene } from '@univerjs/engine-render';+import { connectInjector, FOCUSING_COMMON_DRAWINGS, IContextService, Inject, Injector, IUniverInstanceService, RxDisposable, toDisposable, UniverInstanceType } from '@univerjs/core';import { DrawingTypeEnum, IDrawingManagerService } from '@univerjs/drawing';import { COMPONENT_IMAGE_POPUP_MENU, ImageCropperObject, ImageResetSizeOperation, OpenImageCropOperation } from '@univerjs/drawing-ui';import { IRenderManagerService } from '@univerjs/engine-render';import { SheetCanvasPopManagerService } from '@univerjs/sheets-ui';import { BuiltInUIPart, IUIPartsService } from '@univerjs/ui';import { takeUntil } from 'rxjs';-import type { IDisposable, Nullable, Workbook } from '@univerjs/core';-import type { BaseObject, Scene } from '@univerjs/engine-render';import { RemoveSheetDrawingCommand } from '../commands/commands/remove-sheet-drawing.command';import { EditSheetDrawingOperation } from '../commands/operations/edit-sheet-drawing.operation';import { UploadLoading } from '../views/upload-loading/UploadLoading';-@OnLifecycle(LifecycleStages.Steady, DrawingPopupMenuController)export class DrawingPopupMenuController extends RxDisposable {private _initImagePopupMenu = new Set<string>();diff --git a/packages/sheets-drawing-ui/src/controllers/render-controllers/sheet-drawing.render-controller.ts b/packages/sheets-drawing-ui/src/controllers/render-controllers/sheet-drawing.render-controller.tsindex ef59325535..fa483d97f2 100644--- a/packages/sheets-drawing-ui/src/controllers/render-controllers/sheet-drawing.render-controller.ts+++ b/packages/sheets-drawing-ui/src/controllers/render-controllers/sheet-drawing.render-controller.ts@@ -14,9 +14,9 @@* limitations under the License.*/-import { Disposable, Inject, LifecycleService, UniverInstanceType } from '@univerjs/core';-import { IDrawingManagerService } from '@univerjs/drawing';import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';+import { Disposable, Inject } from '@univerjs/core';+import { IDrawingManagerService } from '@univerjs/drawing';import { ISheetDrawingService } from '@univerjs/sheets-drawing';import { ISheetSelectionRenderService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';import { drawingPositionToTransform } from '../../basics/transform-position';@@ -26,7 +26,6 @@ export class SheetsDrawingRenderController extends Disposable implements IRenderprivate _context: IRenderContext,@ISheetDrawingService private readonly _sheetDrawingService: ISheetDrawingService,@IDrawingManagerService private readonly _drawingManagerService: IDrawingManagerService,- @Inject(LifecycleService) private _lifecycleService: LifecycleService,@Inject(ISheetSelectionRenderService) private _sheetSelectionRenderService: ISheetSelectionRenderService,@Inject(SheetSkeletonManagerService) private _sheetSkeletonManagerService: SheetSkeletonManagerService) {@@ -41,19 +40,17 @@ export class SheetsDrawingRenderController extends Disposable implements IRenderprivate _drawingInitializeListener() {// initialize drawing data and add to sheet canvas- if (this._context.type === UniverInstanceType.UNIVER_SHEET) {- this._sheetDrawingService.initializeNotification(this._context.unitId);- const data = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);- for (const subUnit in data) {- const subUnitData = data[subUnit];- for (const drawingId in subUnitData.data) {- const drawingData = subUnitData.data[drawingId];- drawingData.transform = drawingPositionToTransform(drawingData.sheetTransform, this._sheetSelectionRenderService, this._sheetSkeletonManagerService);- }+ this._sheetDrawingService.initializeNotification(this._context.unitId);+ const data = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);+ for (const subUnit in data) {+ const subUnitData = data[subUnit];+ for (const drawingId in subUnitData.data) {+ const drawingData = subUnitData.data[drawingId];+ drawingData.transform = drawingPositionToTransform(drawingData.sheetTransform, this._sheetSelectionRenderService, this._sheetSkeletonManagerService);}-- this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId));- this._drawingManagerService.initializeNotification(this._context.unitId);}++ this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId));+ this._drawingManagerService.initializeNotification(this._context.unitId);}}diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-copy-paste.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-copy-paste.controller.tsindex 2eb5abc3f2..86b44198e2 100644--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-copy-paste.controller.ts+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-copy-paste.controller.ts@@ -15,15 +15,14 @@*/import type { IMutationInfo, IRange, Nullable } from '@univerjs/core';-import { Disposable, LifecycleStages, OnLifecycle, Tools } from '@univerjs/core';import type { IDrawingJsonUndo1 } from '@univerjs/drawing';-import { IRenderManagerService } from '@univerjs/engine-render';import type { ISheetDrawing } from '@univerjs/sheets-drawing';-import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation, SheetDrawingAnchorType } from '@univerjs/sheets-drawing';import type { IDiscreteRange, ISheetDiscreteRangeLocation } from '@univerjs/sheets-ui';+import { Disposable, Tools } from '@univerjs/core';+import { IRenderManagerService } from '@univerjs/engine-render';+import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation, SheetDrawingAnchorType } from '@univerjs/sheets-drawing';import { COPY_TYPE, ISheetClipboardService, PREDEFINED_HOOK_NAME, SheetSkeletonManagerService, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';-@OnLifecycle(LifecycleStages.Ready, SheetsDrawingCopyPasteController)export class SheetsDrawingCopyPasteController extends Disposable {private _copyInfo: Nullable<{drawings: ISheetDrawing[];diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-permission.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-permission.controller.tsindex c6b94a5de6..d492bc73b0 100644--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-permission.controller.ts+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-permission.controller.ts@@ -15,13 +15,12 @@*/import type { Workbook } from '@univerjs/core';-import { Disposable, Inject, IPermissionService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType, UserManagerService } from '@univerjs/core';+import { Disposable, Inject, IPermissionService, IUniverInstanceService, UniverInstanceType, UserManagerService } from '@univerjs/core';import { IDrawingManagerService } from '@univerjs/drawing';import { IRenderManagerService, RENDER_CLASS_TYPE } from '@univerjs/engine-render';import { WorkbookEditablePermission, WorkbookViewPermission, WorksheetEditPermission, WorksheetViewPermission } from '@univerjs/sheets';import { combineLatest, distinctUntilChanged, filter, map } from 'rxjs';-@OnLifecycle(LifecycleStages.Rendered, SheetDrawingPermissionController)export class SheetDrawingPermissionController extends Disposable {constructor(@IDrawingManagerService private readonly _drawingManagerService: IDrawingManagerService,diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-printing.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-printing.controller.tsindex be95e9f832..e095aa5091 100644--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-printing.controller.ts+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-printing.controller.ts@@ -15,13 +15,12 @@*/import type { IRange } from '@univerjs/core';-import { Disposable, Inject, LifecycleStages, OnLifecycle, Tools } from '@univerjs/core';+import { Disposable, Inject, Tools } from '@univerjs/core';import { DrawingTypeEnum, IDrawingManagerService } from '@univerjs/drawing';import { DrawingRenderService } from '@univerjs/drawing-ui';import { IRenderManagerService } from '@univerjs/engine-render';import { SheetPrintInterceptorService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';-@OnLifecycle(LifecycleStages.Rendered, SheetDrawingPrintingController)export class SheetDrawingPrintingController extends Disposable {constructor(@Inject(SheetPrintInterceptorService) private readonly _sheetPrintInterceptorService: SheetPrintInterceptorService,diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing.controller.tsindex 9f30128d8f..057700a6b8 100644--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing.controller.ts+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing.controller.ts@@ -14,33 +14,30 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';-import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';-+import { Disposable, ICommandService, Inject } from '@univerjs/core';import { AddImageSingle } from '@univerjs/icons';-import { IMAGE_UPLOAD_ICON } from '../views/menu/image.menu';++import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';+import { DeleteDrawingsCommand } from '../commands/commands/delete-drawings.command';+import { GroupSheetDrawingCommand } from '../commands/commands/group-sheet-drawing.command';import { InsertFloatImageCommand } from '../commands/commands/insert-image.command';import { InsertSheetDrawingCommand } from '../commands/commands/insert-sheet-drawing.command';+import { MoveDrawingsCommand } from '../commands/commands/move-drawings.command';import { RemoveSheetDrawingCommand } from '../commands/commands/remove-sheet-drawing.command';+import { SetDrawingArrangeCommand } from '../commands/commands/set-drawing-arrange.command';import { SetSheetDrawingCommand } from '../commands/commands/set-sheet-drawing.command';-import { COMPONENT_SHEET_DRAWING_PANEL } from '../views/sheet-image-panel/component-name';-import { SheetDrawingPanel } from '../views/sheet-image-panel/SheetDrawingPanel';-+import { UngroupSheetDrawingCommand } from '../commands/commands/ungroup-sheet-drawing.command';import { ClearSheetDrawingTransformerOperation } from '../commands/operations/clear-drawing-transformer.operation';import { EditSheetDrawingOperation } from '../commands/operations/edit-sheet-drawing.operation';-import { GroupSheetDrawingCommand } from '../commands/commands/group-sheet-drawing.command';-import { UngroupSheetDrawingCommand } from '../commands/commands/ungroup-sheet-drawing.command';import { SidebarSheetDrawingOperation } from '../commands/operations/open-drawing-panel.operation';-import { MoveDrawingsCommand } from '../commands/commands/move-drawings.command';-import { DeleteDrawingsCommand } from '../commands/commands/delete-drawings.command';-import { SetDrawingArrangeCommand } from '../commands/commands/set-drawing-arrange.command';-import { DeleteDrawingsShortcutItem, MoveDrawingDownShortcutItem, MoveDrawingLeftShortcutItem, MoveDrawingRightShortcutItem, MoveDrawingUpShortcutItem } from './shortcuts/drawing.shortcut';+import { IMAGE_UPLOAD_ICON } from '../views/menu/image.menu';+import { COMPONENT_SHEET_DRAWING_PANEL } from '../views/sheet-image-panel/component-name';+import { SheetDrawingPanel } from '../views/sheet-image-panel/SheetDrawingPanel';import { menuSchema } from './menu.schema';+import { DeleteDrawingsShortcutItem, MoveDrawingDownShortcutItem, MoveDrawingLeftShortcutItem, MoveDrawingRightShortcutItem, MoveDrawingUpShortcutItem } from './shortcuts/drawing.shortcut';-@OnLifecycle(LifecycleStages.Rendered, SheetDrawingUIController)export class SheetDrawingUIController extends Disposable {constructor(- @Inject(Injector) private readonly _injector: Injector,@Inject(ComponentManager) private readonly _componentManager: ComponentManager,@IMenuManagerService private readonly _menuManagerService: IMenuManagerService,@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/sheets-drawing-ui/src/plugin.ts b/packages/sheets-drawing-ui/src/plugin.tsindex 535b3d1132..6786acf40e 100644--- a/packages/sheets-drawing-ui/src/plugin.ts+++ b/packages/sheets-drawing-ui/src/plugin.ts@@ -14,6 +14,8 @@* limitations under the License.*/+import type { Dependency } from '@univerjs/core';+import type { IUniverSheetsDrawingUIConfig } from './controllers/config.schema';import {DependentOn,IConfigService,@@ -22,22 +24,20 @@ import {Plugin,UniverInstanceType,} from '@univerjs/core';-import type { Dependency } from '@univerjs/core';-import { UniverDrawingUIPlugin } from '@univerjs/drawing-ui';-import { UniverSheetsDrawingPlugin } from '@univerjs/sheets-drawing';import { UniverDrawingPlugin } from '@univerjs/drawing';+import { UniverDrawingUIPlugin } from '@univerjs/drawing-ui';import { IRenderManagerService } from '@univerjs/engine-render';+import { UniverSheetsDrawingPlugin } from '@univerjs/sheets-drawing';+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { DrawingPopupMenuController } from './controllers/drawing-popup-menu.controller';-import { SheetDrawingUpdateController } from './controllers/sheet-drawing-update.controller';+import { SheetsDrawingRenderController } from './controllers/render-controllers/sheet-drawing.render-controller';import { SheetDrawingUIController } from './controllers/sheet-drawing.controller';+import { SheetsDrawingCopyPasteController } from './controllers/sheet-drawing-copy-paste.controller';+import { SheetDrawingPermissionController } from './controllers/sheet-drawing-permission.controller';+import { SheetDrawingPrintingController } from './controllers/sheet-drawing-printing.controller';import { SheetDrawingTransformAffectedController } from './controllers/sheet-drawing-transform-affected.controller';+import { SheetDrawingUpdateController } from './controllers/sheet-drawing-update.controller';import { SheetCanvasFloatDomManagerService } from './services/canvas-float-dom-manager.service';-import { SheetDrawingPrintingController } from './controllers/sheet-drawing-printing.controller';-import { SheetDrawingPermissionController } from './controllers/sheet-drawing-permission.controller';-import { SheetsDrawingCopyPasteController } from './controllers/sheet-drawing-copy-paste.controller';-import { SheetsDrawingRenderController } from './controllers/render-controllers/sheet-drawing.render-controller';-import type { IUniverSheetsDrawingUIConfig } from './controllers/config.schema';-import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';const PLUGIN_NAME = 'SHEET_IMAGE_UI_PLUGIN';@@ -64,10 +64,24 @@ export class UniverSheetsDrawingUIPlugin extends Plugin {override onStarting(): void {this._initDependencies();++ this._injector.get(SheetCanvasFloatDomManagerService);+ }++ override onReady(): void {+ this._injector.get(SheetsDrawingCopyPasteController);}override onRendered(): void {this._registerRenderModules();++ this._injector.get(SheetDrawingPermissionController);+ this._injector.get(SheetDrawingPrintingController);+ this._injector.get(SheetDrawingUIController);+ }++ override onSteady(): void {+ this._injector.get(DrawingPopupMenuController);}private _initDependencies(): void {@@ -79,6 +93,7 @@ export class UniverSheetsDrawingUIPlugin extends Plugin {[SheetDrawingPermissionController],[SheetsDrawingCopyPasteController],];+dependencies.forEach((dependency) => this._injector.add(dependency));}diff --git a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.tsindex dea9d5f9b2..bcd8b3c8fb 100644--- a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts+++ b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts@@ -21,7 +21,7 @@ import type { ISetFrozenMutationParams } from '@univerjs/sheets';import type { IFloatDomData, ISheetDrawingPosition, ISheetFloatDom } from '@univerjs/sheets-drawing';import type { IFloatDomLayout } from '@univerjs/ui';import type { IInsertDrawingCommandParams } from '../commands/commands/interfaces';-import { Disposable, DisposableCollection, DrawingTypeEnum, generateRandomId, ICommandService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, DisposableCollection, DrawingTypeEnum, generateRandomId, ICommandService, Inject, IUniverInstanceService } from '@univerjs/core';import { getDrawingShapeKeyByDrawingSearch, IDrawingManagerService } from '@univerjs/drawing';import { DRAWING_OBJECT_LAYER_INDEX, IRenderManagerService, Rect, SHEET_VIEWPORT_KEY } from '@univerjs/engine-render';import { getSheetCommandTarget, SetFrozenMutation } from '@univerjs/sheets';@@ -174,7 +174,6 @@ export interface ISheetCanvasFloatDomHook {onGetFloatDomProps: (id: string) => Record<string, any>;}-@OnLifecycle(LifecycleStages.Starting, SheetCanvasFloatDomManagerService)export class SheetCanvasFloatDomManagerService extends Disposable {private _domLayerMap: Map<string, Map<string, Map<string, { props?: any }>>> = new Map();private _domLayerInfoMap: Map<string, ICanvasFloatDomInfo> = new Map();diff --git a/packages/sheets-drawing/src/controllers/sheet-drawing.controller.ts b/packages/sheets-drawing/src/controllers/sheet-drawing.controller.tsindex 75bb168923..5701f54afd 100644--- a/packages/sheets-drawing/src/controllers/sheet-drawing.controller.ts+++ b/packages/sheets-drawing/src/controllers/sheet-drawing.controller.ts@@ -16,14 +16,13 @@import type { IDrawingSubunitMap } from '@univerjs/drawing';import type { ISheetDrawing } from '../services/sheet-drawing.service';-import { Disposable, ICommandService, IResourceManagerService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import { Disposable, ICommandService, IResourceManagerService, UniverInstanceType } from '@univerjs/core';import { IDrawingManagerService } from '@univerjs/drawing';import { SetDrawingApplyMutation } from '../commands/mutations/set-drawing-apply.mutation';import { ISheetDrawingService } from '../services/sheet-drawing.service';export const SHEET_DRAWING_PLUGIN = 'SHEET_DRAWING_PLUGIN';-@OnLifecycle(LifecycleStages.Starting, SheetsDrawingLoadController)export class SheetsDrawingLoadController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/sheets-drawing/src/plugin.ts b/packages/sheets-drawing/src/plugin.tsindex 29b795d15e..102fb9044e 100644--- a/packages/sheets-drawing/src/plugin.ts+++ b/packages/sheets-drawing/src/plugin.ts@@ -14,13 +14,13 @@* limitations under the License.*/+import type { Dependency } from '@univerjs/core';+import type { IUniverSheetsDrawingConfig } from './controllers/config.schema';import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import { UniverDrawingPlugin } from '@univerjs/drawing';-import type { Dependency } from '@univerjs/core';import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { SHEET_DRAWING_PLUGIN, SheetsDrawingLoadController } from './controllers/sheet-drawing.controller';import { ISheetDrawingService, SheetDrawingService } from './services/sheet-drawing.service';-import type { IUniverSheetsDrawingConfig } from './controllers/config.schema';@DependentOn(UniverDrawingPlugin)export class UniverSheetsDrawingPlugin extends Plugin {@@ -44,5 +44,7 @@ export class UniverSheetsDrawingPlugin extends Plugin {[SheetsDrawingLoadController],[ISheetDrawingService, { useClass: SheetDrawingService }],] as Dependency[]).forEach((dependency) => this._injector.add(dependency));++ this._injector.get(SheetsDrawingLoadController);}}diff --git a/packages/sheets-filter-ui/src/commands/commands/__tests__/sheets-filter.command.spec.ts b/packages/sheets-filter-ui/src/commands/commands/__tests__/sheets-filter.command.spec.tsindex e7bbdc07ce..9e93c0d5ad 100644--- a/packages/sheets-filter-ui/src/commands/commands/__tests__/sheets-filter.command.spec.ts+++ b/packages/sheets-filter-ui/src/commands/commands/__tests__/sheets-filter.command.spec.ts@@ -14,17 +14,17 @@* limitations under the License.*/-import type { Dependency, IRange, IWorkbookData } from '@univerjs/core';-import { AuthzIoLocalService, IAuthzIoService, ICommandService, Inject, Injector, IUniverInstanceService, LocaleType, Plugin, RANGE_TYPE, RedoCommand, UndoCommand, Univer, UniverInstanceType } from '@univerjs/core';+import type { Dependency, IRange, IWorkbookData, Workbook } from '@univerjs/core';import type { ISetRangeValuesCommandParams } from '@univerjs/sheets';-import { RangeProtectionRuleModel, RefRangeService, SetRangeValuesCommand, SetRangeValuesMutation, SheetInterceptorService, SheetsSelectionsService, WorkbookPermissionService, WorksheetPermissionService, WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '@univerjs/sheets';import type { FilterModel, ISetSheetsFilterRangeMutationParams } from '@univerjs/sheets-filter';+import type { ISetSheetsFilterCriteriaCommandParams } from '../sheets-filter.command';+import { AuthzIoLocalService, IAuthzIoService, ICommandService, Inject, Injector, IUniverInstanceService, LocaleType, Plugin, RANGE_TYPE, RedoCommand, UndoCommand, Univer, UniverInstanceType } from '@univerjs/core';+import { RangeProtectionRuleModel, RefRangeService, SetRangeValuesCommand, SetRangeValuesMutation, SheetInterceptorService, SheetsSelectionsService, WorkbookPermissionService, WorksheetPermissionService, WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '@univerjs/sheets';import { SetSheetsFilterRangeMutation, SheetsFilterService, UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';-import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { IMessageService } from '@univerjs/ui';import { MockMessageService } from '@univerjs/ui/services/message/__testing__/mock-message.service.js';-import type { ISetSheetsFilterCriteriaCommandParams } from '../sheets-filter.command';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, RemoveSheetFilterCommand, SetSheetFilterRangeCommand, SetSheetsFilterCriteriaCommand, SmartToggleSheetsFilterCommand } from '../sheets-filter.command';function testWorkbookDataFactory(): IWorkbookData {@@ -83,6 +83,7 @@ function createFilterCommandTestBed() {class SheetsFilterCommandTestPlugin extends Plugin {static override pluginName = 'sheets-filter-command-test';static override type = UniverInstanceType.UNIVER_SHEET;+constructor(_config: unknown, @Inject(Injector) protected readonly _injector: Injector) {super();}@@ -100,13 +101,17 @@ function createFilterCommandTestBed() {[RangeProtectionRuleModel],[IMessageService, { useClass: MockMessageService }],] as Dependency[]).forEach((d) => this._injector.add(d));++ this._injector.get(SheetInterceptorService);+ this._injector.get(WorkbookPermissionService);+ this._injector.get(WorksheetPermissionService);}}univer.registerPlugin(UniverSheetsFilterPlugin);univer.registerPlugin(SheetsFilterCommandTestPlugin);- univer.createUniverSheet(testWorkbookDataFactory());+ univer.createUnit<IWorkbookData, Workbook>(UniverInstanceType.UNIVER_SHEET, testWorkbookDataFactory());const commandService = get(ICommandService);[diff --git a/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts b/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.tsindex 163c8c8a80..5774226ef0 100644--- a/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts+++ b/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts@@ -14,15 +14,15 @@* limitations under the License.*/-import type { Dependency, IOperation, IWorkbookData } from '@univerjs/core';-import { CommandType, ICommandService, IContextService, Inject, Injector, LocaleService, LocaleType, Plugin, Univer, UniverInstanceType } from '@univerjs/core';+import type { Dependency, IOperation, IWorkbookData, Workbook } from '@univerjs/core';import type { ISetSheetsFilterRangeMutationParams } from '@univerjs/sheets-filter';+import type { IEditorBridgeServiceVisibleParam } from '@univerjs/sheets-ui';+import { CommandType, ICommandService, IContextService, Inject, Injector, LocaleService, LocaleType, Plugin, Univer, UniverInstanceType } from '@univerjs/core';+import { RefRangeService, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';import { SetSheetsFilterRangeMutation, UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-import { RefRangeService, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';-import type { IEditorBridgeServiceVisibleParam } from '@univerjs/sheets-ui';-import { CloseFilterPanelOperation, FILTER_PANEL_OPENED_KEY, OpenFilterPanelOperation } from '../sheets-filter.operation';import { SheetsFilterPanelService } from '../../../services/sheets-filter-panel.service';+import { CloseFilterPanelOperation, FILTER_PANEL_OPENED_KEY, OpenFilterPanelOperation } from '../sheets-filter.operation';const SetCellEditVisibleOperation: IOperation<IEditorBridgeServiceVisibleParam> = {id: 'sheet.operation.set-cell-edit-visible',@@ -85,7 +85,7 @@ function createFilterOperationTestBed() {univer.registerPlugin(UniverSheetsFilterPlugin);univer.registerPlugin(SheetsFilterOperationTestPlugin);- univer.createUniverSheet(testWorkbookDataFactory());+ univer.createUnit<IWorkbookData, Workbook>(UniverInstanceType.UNIVER_SHEET, testWorkbookDataFactory());get(LocaleService).load({});diff --git a/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts b/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.tsindex a814387b3f..075be0b578 100644--- a/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts+++ b/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { IWorkbookData } from '@univerjs/core';+import type { IWorkbookData, Workbook } from '@univerjs/core';import type { ISetSheetsFilterCriteriaMutationParams, ISetSheetsFilterRangeMutationParams } from '@univerjs/sheets-filter';import { AuthzIoLocalService, DisposableCollection, IAuthzIoService, ICommandService, Inject, Injector, LocaleType, Plugin, Univer, UniverInstanceType } from '@univerjs/core';import { ExclusiveRangeService, IExclusiveRangeService, RangeProtectionRuleModel, RefRangeService, SetWorksheetActiveOperation, SheetInterceptorService, SheetsSelectionsService, WorkbookPermissionService, WorksheetPermissionService, WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '@univerjs/sheets';@@ -86,13 +86,17 @@ function createSheetsFilterMenuTestBed() {OpenFilterPanelOperation,CloseFilterPanelOperation,].forEach((command) => commandService.registerCommand(command));++ this._injector.get(SheetInterceptorService);+ this._injector.get(WorkbookPermissionService);+ this._injector.get(WorksheetPermissionService);}}univer.registerPlugin(TestPlugin);univer.registerPlugin(UniverSheetsFilterPlugin);- const sheet = univer.createUniverSheet(TEST_WORKBOOK_DATA_DEMO);+ const sheet = univer.createUnit<IWorkbookData, Workbook>(UniverInstanceType.UNIVER_SHEET, TEST_WORKBOOK_DATA_DEMO);return { univer, get, sheet };}diff --git a/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts b/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.tsindex f53791d631..252d8567ee 100644--- a/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts+++ b/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts@@ -14,20 +14,20 @@* limitations under the License.*/-import type { Dependency, IOperation, IWorkbookData } from '@univerjs/core';+import type { Dependency, IOperation, IWorkbookData, Workbook } from '@univerjs/core';+import type { IEditorBridgeServiceVisibleParam } from '@univerjs/sheets-ui';+import type { IOpenFilterPanelOperationParams } from '../../commands/operations/sheets-filter.operation';+import type { IFilterConditionFormParams } from '../../models/conditions';import { CommandType, ICommandService, Inject, Injector, LocaleService, Plugin, Univer, UniverInstanceType } from '@univerjs/core';import { RefRangeService, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';-import { afterEach, beforeEach, describe, expect, it, vitest } from 'vitest';import { CustomFilterOperator, SheetsFilterService, UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';-import type { IEditorBridgeServiceVisibleParam } from '@univerjs/sheets-ui';-import { ByConditionsModel, ByValuesModel, FilterBy, SheetsFilterPanelService } from '../sheets-filter-panel.service';-import type { IOpenFilterPanelOperationParams } from '../../commands/operations/sheets-filter.operation';-import { CloseFilterPanelOperation, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';+import { afterEach, beforeEach, describe, expect, it, vitest } from 'vitest';import { E_ITEMS, ITEMS, WithCustomFilterModelFactory, WithMergedCellFilterFactory, WithMultiEmptyCellsModelFactory, WithTwoFilterColumnsFactory, WithValuesAndEmptyFilterModelFactory, WithValuesFilterModelFactory } from '../../__testing__/data';-import type { IFilterConditionFormParams } from '../../models/conditions';+import { SetSheetsFilterCriteriaCommand } from '../../commands/commands/sheets-filter.command';+import { CloseFilterPanelOperation, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';import { FilterConditionItems } from '../../models/conditions';import { ExtendCustomFilterOperator } from '../../models/extended-operators';-import { SetSheetsFilterCriteriaCommand } from '../../commands/commands/sheets-filter.command';+import { ByConditionsModel, ByValuesModel, FilterBy, SheetsFilterPanelService } from '../sheets-filter-panel.service';const SetCellEditVisibleOperation: IOperation<IEditorBridgeServiceVisibleParam> = {id: 'sheet.operation.set-cell-edit-visible',@@ -65,11 +65,7 @@ function createSheetsFilterPanelServiceTestBed(workbookData: IWorkbookData) {univer.registerPlugin(UniverSheetsFilterPlugin);univer.registerPlugin(SheetsFilterPanelTestPlugin);- univer.createUniverSheet(workbookData);-- // It should be registered later in avoid of time sequence problem.- // injector.add([ISnapshotPersistenceService, { useClass: LocalSnapshotService }]);- // injector.get(ISnapshotPersistenceService);+ univer.createUnit<IWorkbookData, Workbook>(UniverInstanceType.UNIVER_SHEET, workbookData);const commandService = get(ICommandService);diff --git a/packages/sheets-find-replace/src/controllers/sheet-find-replace.controller.ts b/packages/sheets-find-replace/src/controllers/sheet-find-replace.controller.tsindex b81951ea8d..d4eb802f8c 100644--- a/packages/sheets-find-replace/src/controllers/sheet-find-replace.controller.ts+++ b/packages/sheets-find-replace/src/controllers/sheet-find-replace.controller.ts@@ -15,23 +15,22 @@*/import type { ICellData, IDisposable, IObjectMatrixPrimitiveType, IRange, Nullable, Workbook, Worksheet } from '@univerjs/core';-import { ColorKit, CommandType, Disposable, EDITOR_ACTIVATED, fromCallback, groupBy, ICommandService, IContextService, Inject, Injector, IUniverInstanceService, LifecycleStages, ObjectMatrix, OnLifecycle, replaceInDocumentBody, rotate, ThemeService, Tools, UniverInstanceType } from '@univerjs/core';-import { IRenderManagerService, RENDER_RAW_FORMULA_KEY } from '@univerjs/engine-render';import type { IFindComplete, IFindMatch, IFindMoveParams, IFindQuery, IFindReplaceProvider, IReplaceAllResult } from '@univerjs/find-replace';-import { FindBy, FindDirection, FindModel, FindReplaceController, FindScope, IFindReplaceService } from '@univerjs/find-replace';import type { ISelectionWithStyle, ISetRangeValuesCommandParams, ISetSelectionsOperationParams, ISetWorksheetActivateCommandParams, ISheetCommandSharedParams, WorkbookSelections } from '@univerjs/sheets';-import { SetRangeValuesCommand, SetSelectionsOperation, SetWorksheetActivateCommand, SetWorksheetActiveOperation, SheetsSelectionsService } from '@univerjs/sheets';import type { IScrollToCellCommandParams } from '@univerjs/sheets-ui';+import type { ISheetReplaceCommandParams, ISheetReplacement } from '../commands/commands/sheet-replace.command';+import type { ISheetFindReplaceHighlightShapeProps } from '../views/shapes/find-replace-highlight.shape';+import { ColorKit, CommandType, Disposable, EDITOR_ACTIVATED, fromCallback, groupBy, ICommandService, IContextService, Inject, Injector, IUniverInstanceService, ObjectMatrix, replaceInDocumentBody, rotate, ThemeService, Tools, UniverInstanceType } from '@univerjs/core';+import { IRenderManagerService, RENDER_RAW_FORMULA_KEY } from '@univerjs/engine-render';+import { FindBy, FindDirection, FindModel, FindReplaceController, FindScope, IFindReplaceService } from '@univerjs/find-replace';+import { SetRangeValuesCommand, SetSelectionsOperation, SetWorksheetActivateCommand, SetWorksheetActiveOperation, SheetsSelectionsService } from '@univerjs/sheets';+import { getCoordByCell, getSheetObject, ScrollToCellCommand, SheetSkeletonManagerService } from '@univerjs/sheets-ui';import { debounceTime, filter, merge, skip, Subject, throttleTime } from 'rxjs';--import type { ISheetFindReplaceHighlightShapeProps } from '../views/shapes/find-replace-highlight.shape';-import { SheetFindReplaceHighlightShape } from '../views/shapes/find-replace-highlight.shape';-import type { ISheetReplaceCommandParams, ISheetReplacement } from '../commands/commands/sheet-replace.command';import { SheetReplaceCommand } from '../commands/commands/sheet-replace.command';+import { SheetFindReplaceHighlightShape } from '../views/shapes/find-replace-highlight.shape';import { isBeforePositionWithColumnPriority, isBeforePositionWithRowPriority, isBehindPositionWithColumnPriority, isBehindPositionWithRowPriority, isSamePosition, isSelectionSingleCell } from './utils';-@OnLifecycle(LifecycleStages.Steady, SheetsFindReplaceController)export class SheetsFindReplaceController extends Disposable implements IDisposable {private _provider!: SheetsFindReplaceProvider;diff --git a/packages/sheets-find-replace/src/plugin.ts b/packages/sheets-find-replace/src/plugin.tsindex 2de442c915..999e6ec74f 100644--- a/packages/sheets-find-replace/src/plugin.ts+++ b/packages/sheets-find-replace/src/plugin.ts@@ -14,13 +14,13 @@* limitations under the License.*/-import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import type { Dependency } from '@univerjs/core';+import type { IUniverSheetsFindReplaceConfig } from './controllers/config.schema';+import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import { UniverFindReplacePlugin } from '@univerjs/find-replace';import { UniverSheetsPlugin } from '@univerjs/sheets';-import { SheetsFindReplaceController } from './controllers/sheet-find-replace.controller';-import type { IUniverSheetsFindReplaceConfig } from './controllers/config.schema';import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';+import { SheetsFindReplaceController } from './controllers/sheet-find-replace.controller';const NAME = 'SHEET_FIND_REPLACE_PLUGIN';@@ -44,4 +44,8 @@ export class UniverSheetsFindReplacePlugin extends Plugin {override onStarting(): void {([[SheetsFindReplaceController]] as Dependency[]).forEach((d) => this._injector.add(d));}++ override onSteady(): void {+ this._injector.get(SheetsFindReplaceController);+ }}diff --git a/packages/sheets-formula-ui/src/commands/operations/__tests__/create-command-test-bed.ts b/packages/sheets-formula-ui/src/commands/operations/__tests__/create-command-test-bed.tsindex 47c3be71a7..ed78651351 100644--- a/packages/sheets-formula-ui/src/commands/operations/__tests__/create-command-test-bed.ts+++ b/packages/sheets-formula-ui/src/commands/operations/__tests__/create-command-test-bed.ts@@ -84,6 +84,10 @@ export function createCommandTestBed(workbookData?: IWorkbookData, dependencies?injector.add([WorksheetProtectionRuleModel]);dependencies?.forEach((d) => injector.add(d));++ this._injector.get(SheetInterceptorService);+ this._injector.get(WorkbookPermissionService);+ this._injector.get(WorksheetPermissionService);}}diff --git a/packages/sheets-formula-ui/src/controllers/__tests__/create-command-test-bed.ts b/packages/sheets-formula-ui/src/controllers/__tests__/create-command-test-bed.tsindex ae6b9bae2c..2ada7c7318 100644--- a/packages/sheets-formula-ui/src/controllers/__tests__/create-command-test-bed.ts+++ b/packages/sheets-formula-ui/src/controllers/__tests__/create-command-test-bed.ts@@ -99,6 +99,10 @@ export function createCommandTestBed(workbookData?: IWorkbookData, dependencies?injector.add([IRefSelectionsService, { useClass: SheetsSelectionsService }]);dependencies?.forEach((d) => injector.add(d));++ this._injector.get(SheetInterceptorService);+ this._injector.get(WorkbookPermissionService);+ this._injector.get(WorksheetPermissionService);}override onReady(): void {diff --git a/packages/sheets-formula-ui/src/controllers/__tests__/formula-auto-fill.controller.spec.ts b/packages/sheets-formula-ui/src/controllers/__tests__/formula-auto-fill.controller.spec.tsindex d8405f6d18..16bf6dfc8c 100644--- a/packages/sheets-formula-ui/src/controllers/__tests__/formula-auto-fill.controller.spec.ts+++ b/packages/sheets-formula-ui/src/controllers/__tests__/formula-auto-fill.controller.spec.ts@@ -81,18 +81,23 @@ describe('Test auto fill with formula', () => {[RangeProtectionRenderModel],[SheetsRenderService, { useClass: mockSheetsRenderService }],]);+univer = testBed.univer;get = testBed.get;+commandService = get(ICommandService);themeService = get(ThemeService);themeService.setTheme(theme);autoFillController = get(AutoFillController);+commandService.registerCommand(SetRangeValuesMutation);commandService.registerCommand(SetSelectionsOperation);commandService.registerCommand(AddWorksheetMergeMutation);commandService.registerCommand(RemoveWorksheetMergeMutation);commandService.registerCommand(AutoFillCommand);+ get(FormulaAutoFillController);+getValues = (startRow: number,startColumn: number,diff --git a/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts b/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.tsindex 9549e68113..e84fd4658d 100644--- a/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts+++ b/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICellData, Injector, IObjectMatrixPrimitiveType, IWorkbookData, Nullable, Univer } from '@univerjs/core';+import type { ICellData, Injector, IWorkbookData, Nullable, Univer, Workbook } from '@univerjs/core';import type { IDeleteRangeMoveLeftCommandParams, IDeleteRangeMoveUpCommandParams, IInsertColCommandParams, IInsertRowCommandParams, IMoveColsCommandParams, IMoveRangeCommandParams, IMoveRowsCommandParams, InsertRangeMoveDownCommandParams, InsertRangeMoveRightCommandParams, IRemoveRowColCommandParams, IRemoveSheetCommandParams, ISetRangeValuesCommandParams, ISetWorksheetNameCommandParams } from '@univerjs/sheets';import { CellValueType, Direction, ICommandService, IUniverInstanceService, LocaleType, RANGE_TYPE, RedoCommand, UndoCommand } from '@univerjs/core';import { SetArrayFormulaDataMutation, SetFormulaDataMutation } from '@univerjs/engine-formula';@@ -280,12 +280,12 @@ describe('Test insert function operation', () => {endRow: number,endColumn: number) => Array<Array<Nullable<ICellData>>> | undefined;- let getCellData: () => IObjectMatrixPrimitiveType<Nullable<ICellData>> | undefined;beforeEach(() => {const testBed = createCommandTestBed(TEST_WORKBOOK_DATA_DEMO(), [[UpdateFormulaController],]);+univer = testBed.univer;get = testBed.get;@@ -334,14 +334,12 @@ describe('Test insert function operation', () => {endColumn: number): Array<Array<Nullable<ICellData>>> | undefined =>get(IUniverInstanceService)- .getUniverSheetInstance('test')+ .getUnit<Workbook>('test')?.getSheetBySheetId('sheet1')?.getRange(startRow, startColumn, endRow, endColumn).getValues();- getCellData = () => {- return get(IUniverInstanceService).getUniverSheetInstance('test')?.getSheetBySheetId('sheet1')?.getCellMatrix().clone();- };+ get(UpdateFormulaController);});afterEach(() => {diff --git a/packages/sheets-formula-ui/src/controllers/formula-auto-fill.controller.ts b/packages/sheets-formula-ui/src/controllers/formula-auto-fill.controller.tsindex 099332d3c8..7add902471 100644--- a/packages/sheets-formula-ui/src/controllers/formula-auto-fill.controller.ts+++ b/packages/sheets-formula-ui/src/controllers/formula-auto-fill.controller.ts@@ -22,14 +22,11 @@ import {Inject,isFormulaId,isFormulaString,- LifecycleStages,- OnLifecycle,Tools,} from '@univerjs/core';import { LexerTreeBuilder } from '@univerjs/engine-formula';import { APPLY_TYPE, DATA_TYPE, IAutoFillService } from '@univerjs/sheets-ui';-@OnLifecycle(LifecycleStages.Ready, FormulaAutoFillController)export class FormulaAutoFillController extends Disposable {constructor(@IAutoFillService private readonly _autoFillService: AutoFillService,@@ -37,10 +34,6 @@ export class FormulaAutoFillController extends Disposable {) {super();- this._initialize();- }-- private _initialize(): void {this._registerAutoFill();}diff --git a/packages/sheets-formula-ui/src/controllers/formula-clipboard.controller.ts b/packages/sheets-formula-ui/src/controllers/formula-clipboard.controller.tsindex 2828539a81..785c6fe3ea 100644--- a/packages/sheets-formula-ui/src/controllers/formula-clipboard.controller.ts+++ b/packages/sheets-formula-ui/src/controllers/formula-clipboard.controller.ts@@ -25,9 +25,7 @@ import {isFormulaId,isFormulaString,IUniverInstanceService,- LifecycleStages,ObjectMatrix,- OnLifecycle,Tools,UniverInstanceType,} from '@univerjs/core';@@ -37,7 +35,6 @@ import { COPY_TYPE, ISheetClipboardService, PREDEFINED_HOOK_NAME } from '@univerexport const DEFAULT_PASTE_FORMULA = 'default-paste-formula';-@OnLifecycle(LifecycleStages.Ready, FormulaClipboardController)export class FormulaClipboardController extends Disposable {constructor(@IUniverInstanceService private readonly _currentUniverSheet: IUniverInstanceService,diff --git a/packages/sheets-formula-ui/src/controllers/formula-render.controller.ts b/packages/sheets-formula-ui/src/controllers/formula-render.controller.tsindex 472e31344b..56c019da0b 100644--- a/packages/sheets-formula-ui/src/controllers/formula-render.controller.ts+++ b/packages/sheets-formula-ui/src/controllers/formula-render.controller.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { Inject, InterceptorEffectEnum, LifecycleStages, OnLifecycle, RxDisposable } from '@univerjs/core';+import { Inject, InterceptorEffectEnum, RxDisposable } from '@univerjs/core';import { INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';import { extractFormulaError } from './utils/utils';@@ -25,17 +25,12 @@ const FORMULA_ERROR_MARK = {},};-@OnLifecycle(LifecycleStages.Rendered, FormulaRenderManagerController)export class FormulaRenderManagerController extends RxDisposable {constructor(@Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService) {super();- this._init();- }-- private _init() {this.disposeWithMe(this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT,{diff --git a/packages/sheets-formula-ui/src/controllers/formula-ui.controller.ts b/packages/sheets-formula-ui/src/controllers/formula-ui.controller.tsindex e3047b140a..0737f4f844 100644--- a/packages/sheets-formula-ui/src/controllers/formula-ui.controller.ts+++ b/packages/sheets-formula-ui/src/controllers/formula-ui.controller.ts@@ -15,7 +15,7 @@*/import type { Dependency } from '@univerjs/core';-import { connectInjector, Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import { connectInjector, Disposable, ICommandService, Inject, Injector, UniverInstanceType } from '@univerjs/core';import { IRenderManagerService } from '@univerjs/engine-render';import { BuiltInUIPart, ComponentManager, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui';@@ -40,7 +40,6 @@ import {singleEditorPromptSelectionShortcutItem,} from './shortcuts/prompt.shortcut';-@OnLifecycle(LifecycleStages.Ready, FormulaUIController)export class FormulaUIController extends Disposable {constructor(@Inject(Injector) private readonly _injector: Injector,diff --git a/packages/sheets-formula-ui/src/controllers/prompt.controller.ts b/packages/sheets-formula-ui/src/controllers/prompt.controller.tsindex d9f7803cc6..aadfd1da17 100644--- a/packages/sheets-formula-ui/src/controllers/prompt.controller.ts+++ b/packages/sheets-formula-ui/src/controllers/prompt.controller.ts@@ -47,8 +47,6 @@ import {Inject,isFormulaString,IUniverInstanceService,- LifecycleStages,- OnLifecycle,RANGE_TYPE,Rectangle,ThemeService,@@ -131,7 +129,6 @@ enum InputPanelState {const sheetEditorUnitIds = [DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY];-@OnLifecycle(LifecycleStages.Steady, PromptController)export class PromptController extends Disposable {private _listenInputCache: Set<string> = new Set();private _formulaRefColors: string[] = [];diff --git a/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts b/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.tsindex 70f398f270..1c16866912 100644--- a/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts+++ b/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts@@ -74,6 +74,10 @@ export class UniverSheetsFormulaUIPlugin extends Plugin {dependencies.forEach((dependency) => j.add(dependency));}+ override onReady(): void {+ this._injector.get(FormulaUIController);+ }+override onRendered(): void {([[RefSelectionsRenderService],@@ -81,5 +85,13 @@ export class UniverSheetsFormulaUIPlugin extends Plugin {] as Dependency[]).forEach((dep) => {this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, dep));});++ this._injector.get(FormulaClipboardController);+ this._injector.get(FormulaRenderManagerController);+ }++ override onSteady(): void {+ this._injector.get(FormulaAutoFillController);+ this._injector.get(PromptController);}}diff --git a/packages/sheets-formula/src/controllers/active-dirty.controller.ts b/packages/sheets-formula/src/controllers/active-dirty.controller.tsindex 7515f428d6..36b02bdeb4 100644--- a/packages/sheets-formula/src/controllers/active-dirty.controller.ts+++ b/packages/sheets-formula/src/controllers/active-dirty.controller.ts@@ -15,17 +15,7 @@*/import type { ICellData, ICommandInfo, IObjectMatrixPrimitiveType, IRange, IUnitRange, Nullable } from '@univerjs/core';-import {- Dimension,- Disposable,- Inject,- IUniverInstanceService,- LifecycleStages,- ObjectMatrix,- OnLifecycle,-} from '@univerjs/core';import type { IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, ISetDefinedNameMutationParam } from '@univerjs/engine-formula';-import { FormulaDataModel, IActiveDirtyManagerService, IDefinedNamesService, RemoveDefinedNameMutation, SetDefinedNameMutation } from '@univerjs/engine-formula';import type {IDeleteRangeMutationParams,IInsertSheetMutationParams,@@ -39,6 +29,14 @@ import type {ISetDefinedNameCommandParams,ISetRangeValuesMutationParams,} from '@univerjs/sheets';+import {+ Dimension,+ Disposable,+ Inject,+ IUniverInstanceService,+ ObjectMatrix,+} from '@univerjs/core';+import { FormulaDataModel, IActiveDirtyManagerService, RemoveDefinedNameMutation, SetDefinedNameMutation } from '@univerjs/engine-formula';import {InsertSheetMutation,MoveColsMutation,@@ -53,14 +51,11 @@ import {SetStyleCommand,} from '@univerjs/sheets';-@OnLifecycle(LifecycleStages.Ready, ActiveDirtyController)export class ActiveDirtyController extends Disposable {constructor(@IActiveDirtyManagerService private readonly _activeDirtyManagerService: IActiveDirtyManagerService,@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,- @Inject(FormulaDataModel) private readonly _formulaDataModel: FormulaDataModel,- @IDefinedNamesService private readonly _definedNamesService: IDefinedNamesService-+ @Inject(FormulaDataModel) private readonly _formulaDataModel: FormulaDataModel) {super();@@ -72,20 +67,6 @@ export class ActiveDirtyController extends Disposable {}private _initialConversion() {- // const updateCommandList = [- // SetRangeValuesMutation.id,- // MoveRangeMutation.id,- // MoveRowsMutation.id,- // MoveColsMutation.id,- // DeleteRangeMutation.id,- // InsertRangeMutation.id,- // RemoveRowMutation.id,- // RemoveColMutation.id,- // RemoveSheetMutation.id,- // InsertSheetMutation.id,- // // SetWorksheetNameMutation.id,- // ];-this._activeDirtyManagerService.register(SetRangeValuesMutation.id, {commandId: SetRangeValuesMutation.id,getDirtyData: (command: ICommandInfo) => {@@ -111,17 +92,6 @@ export class ActiveDirtyController extends Disposable {this._initialSheet();this._initialDefinedName();-- /**- * Changing the name of a sheet triggers an adjustment of the formula references, but does not trigger formula calculation; therefore, this logic has been removed.- */- // this._activeDirtyManagerService.register(SetWorksheetNameMutation.id, {- // commandId: SetWorksheetNameMutation.id,- // getDirtyData: (command: ICommandInfo) => {- // const params = command.params as ISetWorksheetNameMutationParams;- // return { dirtyNameMap: this._getRemoveSheetMutation(params, params.name) };- // },- // });}private _initialMove() {diff --git a/packages/sheets-formula/src/controllers/array-formula-cell-interceptor.controller.ts b/packages/sheets-formula/src/controllers/array-formula-cell-interceptor.controller.tsindex 569de3209d..d491872287 100644--- a/packages/sheets-formula/src/controllers/array-formula-cell-interceptor.controller.ts+++ b/packages/sheets-formula/src/controllers/array-formula-cell-interceptor.controller.ts@@ -16,11 +16,10 @@import type { ICommandInfo } from '@univerjs/core';import type { ISetArrayFormulaDataMutationParams } from '@univerjs/engine-formula';-import { CellValueType, Disposable, ICommandService, Inject, InterceptorEffectEnum, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { CellValueType, Disposable, ICommandService, Inject, InterceptorEffectEnum } from '@univerjs/core';import { FormulaDataModel, SetArrayFormulaDataMutation, stripErrorMargin } from '@univerjs/engine-formula';import { INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';-@OnLifecycle(LifecycleStages.Ready, ArrayFormulaCellInterceptorController)export class ArrayFormulaCellInterceptorController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/sheets-formula/src/controllers/defined-name.controller.ts b/packages/sheets-formula/src/controllers/defined-name.controller.tsindex 5bc028374a..66108b381d 100644--- a/packages/sheets-formula/src/controllers/defined-name.controller.ts+++ b/packages/sheets-formula/src/controllers/defined-name.controller.ts@@ -21,8 +21,6 @@ import {Disposable,ICommandService,IUniverInstanceService,- LifecycleStages,- OnLifecycle,toDisposable,UniverInstanceType,} from '@univerjs/core';@@ -31,11 +29,11 @@ import { InsertDefinedNameCommand, RemoveDefinedNameCommand, SetDefinedNameCommaimport { IDescriptionService } from '../services/description.service';export const SCOPE_WORKBOOK_VALUE = 'AllDefaultWorkbook';+/*** header highlight* column menu: show, hover and mousedown event*/-@OnLifecycle(LifecycleStages.Rendered, DefinedNameController)export class DefinedNameController extends Disposable {private _preUnitId: Nullable<string> = null;diff --git a/packages/sheets-formula/src/controllers/update-formula.controller.ts b/packages/sheets-formula/src/controllers/update-formula.controller.tsindex 5c1a6c0832..d202632266 100644--- a/packages/sheets-formula/src/controllers/update-formula.controller.ts+++ b/packages/sheets-formula/src/controllers/update-formula.controller.ts@@ -47,12 +47,9 @@ import {Inject,Injector,IUniverInstanceService,- LifecycleStages,ObjectMatrix,- OnLifecycle,RANGE_TYPE,Rectangle,-Tools,UniverInstanceType,} from '@univerjs/core';@@ -159,7 +156,6 @@ enum OriginRangeEdgeType {** 3. onCommandExecuted, before formula calculation, use the setRangeValues information to delete the old formulaData, ArrayFormula and ArrayFormulaCellData, and send the worker (complementary setRangeValues after collaborative conflicts, normal operation triggers formula update, undo/redo are captured and processed here)*/-@OnLifecycle(LifecycleStages.Ready, UpdateFormulaController)export class UpdateFormulaController extends Disposable {constructor(@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,diff --git a/packages/sheets-formula/src/index.ts b/packages/sheets-formula/src/index.tsindex b1e85fdec5..34496ed79d 100644--- a/packages/sheets-formula/src/index.ts+++ b/packages/sheets-formula/src/index.ts@@ -16,6 +16,7 @@export { type IInsertFunction, type IInsertFunctionCommandParams, InsertFunctionCommand } from './commands/commands/insert-function.command';export { OtherFormulaMarkDirty } from './commands/mutations/formula.mutation';+// #region - all commandsexport { UpdateFormulaController } from './controllers/update-formula.controller';@@ -27,6 +28,6 @@ export { RegisterFunctionService } from './services/register-function.service';export { IRegisterFunctionService } from './services/register-function.service';export { RegisterOtherFormulaService } from './services/register-other-formula.service';export { IRemoteRegisterFunctionService, RemoteRegisterFunctionService } from './services/remote/remote-register-function.service';-export { UniverRemoteSheetsFormulaPlugin, UniverSheetsFormulaMobilePlugin, UniverSheetsFormulaPlugin } from './sheets-formula.plugin';+export { UniverRemoteSheetsFormulaPlugin, UniverSheetsFormulaPlugin } from './sheets-formula.plugin';// #endregiondiff --git a/packages/sheets-formula/src/sheets-formula.plugin.ts b/packages/sheets-formula/src/sheets-formula.plugin.tsindex 295ec17674..b87d5e0108 100644--- a/packages/sheets-formula/src/sheets-formula.plugin.ts+++ b/packages/sheets-formula/src/sheets-formula.plugin.ts@@ -114,42 +114,14 @@ export class UniverSheetsFormulaPlugin extends Plugin {}override onReady(): void {- this._injector.get(TriggerCalculationController);this._injector.get(FormulaController);- }-}--// TODO@wzhudev: after I separate the sheets-formula-ui plugin,-// I found out that `UniverSheetsFormulaPlugin` provides the same services as `UniverSheetsFormulaMobilePlugin`.-// The the later on can be removed.--export class UniverSheetsFormulaMobilePlugin extends Plugin {- static override pluginName = SHEETS_FORMULA_PLUGIN_NAME;- static override type = UniverInstanceType.UNIVER_SHEET;-- constructor(- private readonly _config: undefined,- @Inject(Injector) override readonly _injector: Injector- ) {- super();- }-- override onStarting(): void {- const dependencies: Dependency[] = [- [IRegisterFunctionService, { useClass: RegisterFunctionService }],- [FormulaRefRangeService],- [RegisterOtherFormulaService],- [ArrayFormulaCellInterceptorController],- [TriggerCalculationController],- [UpdateFormulaController],- [ActiveDirtyController],- [DefinedNameController],- ];-- dependencies.forEach((dependency) => this._injector.add(dependency));+ this._injector.get(TriggerCalculationController);+ this._injector.get(ActiveDirtyController);+ this._injector.get(ArrayFormulaCellInterceptorController);+ this._injector.get(UpdateFormulaController);}- override onReady(): void {- ([TriggerCalculationController]).forEach((module) => this._injector.get(module));+ override onRendered(): void {+ this._injector.get(DefinedNameController);}}diff --git a/packages/sheets-hyper-link-ui/src/controllers/auto-fill.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/auto-fill.controller.tsindex 3c2d31d78c..2d7297e43c 100644--- a/packages/sheets-hyper-link-ui/src/controllers/auto-fill.controller.ts+++ b/packages/sheets-hyper-link-ui/src/controllers/auto-fill.controller.ts@@ -15,13 +15,12 @@*/import type { IMutationInfo } from '@univerjs/core';-import { Disposable, Inject, LifecycleStages, OnLifecycle, Range, Rectangle, Tools } from '@univerjs/core';-import { AddHyperLinkMutation, HyperLinkModel, RemoveHyperLinkMutation } from '@univerjs/sheets-hyper-link';import type { IAutoFillLocation, ISheetAutoFillHook } from '@univerjs/sheets-ui';+import { Disposable, Inject, Range, Rectangle, Tools } from '@univerjs/core';+import { AddHyperLinkMutation, HyperLinkModel, RemoveHyperLinkMutation } from '@univerjs/sheets-hyper-link';import { APPLY_TYPE, getAutoFillRepeatRange, IAutoFillService, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';import { SHEET_HYPER_LINK_UI_PLUGIN } from '../types/const';-@OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkAutoFillController)export class SheetsHyperLinkAutoFillController extends Disposable {constructor(@IAutoFillService private readonly _autoFillService: IAutoFillService,diff --git a/packages/sheets-hyper-link-ui/src/controllers/copy-paste.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/copy-paste.controller.tsindex f8d77bb605..c780a8a9c7 100644--- a/packages/sheets-hyper-link-ui/src/controllers/copy-paste.controller.ts+++ b/packages/sheets-hyper-link-ui/src/controllers/copy-paste.controller.ts@@ -15,15 +15,14 @@*/import type { IMutationInfo, IRange, Nullable } from '@univerjs/core';-import { Disposable, Inject, Injector, LifecycleStages, ObjectMatrix, OnLifecycle, Range, Rectangle, Tools } from '@univerjs/core';-import { AddHyperLinkMutation, HyperLinkModel, RemoveHyperLinkMutation } from '@univerjs/sheets-hyper-link';import type { IDiscreteRange, ISheetDiscreteRangeLocation } from '@univerjs/sheets-ui';+import { Disposable, Inject, Injector, ObjectMatrix, Range, Rectangle, Tools } from '@univerjs/core';+import { AddHyperLinkMutation, HyperLinkModel, RemoveHyperLinkMutation } from '@univerjs/sheets-hyper-link';import { COPY_TYPE, getRepeatRange, ISheetClipboardService, PREDEFINED_HOOK_NAME, rangeToDiscreteRange, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';-import { SHEET_HYPER_LINK_UI_PLUGIN } from '../types/const';import { isLegalLink } from '../common/util';import { SheetsHyperLinkResolverService } from '../services/resolver.service';+import { SHEET_HYPER_LINK_UI_PLUGIN } from '../types/const';-@OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkCopyPasteController)export class SheetsHyperLinkCopyPasteController extends Disposable {private _plainTextFilter = new Set<(text: string) => boolean>();diff --git a/packages/sheets-hyper-link-ui/src/controllers/hyper-link-permission.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/hyper-link-permission.controller.tsindex e41436319e..bd4cc09b21 100644--- a/packages/sheets-hyper-link-ui/src/controllers/hyper-link-permission.controller.ts+++ b/packages/sheets-hyper-link-ui/src/controllers/hyper-link-permission.controller.ts@@ -15,12 +15,11 @@*/import type { ICommandInfo } from '@univerjs/core';-import { Disposable, ICommandService, Inject, LifecycleStages, LocaleService, OnLifecycle } from '@univerjs/core';-import { SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';+import { Disposable, ICommandService, Inject, LocaleService } from '@univerjs/core';import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetEditPermission, WorksheetInsertHyperlinkPermission, WorksheetSetCellValuePermission } from '@univerjs/sheets';+import { SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';import { InsertLinkShortcut } from './menu';-@OnLifecycle(LifecycleStages.Rendered, SheetsHyperLinkPermissionController)export class SheetsHyperLinkPermissionController extends Disposable {constructor(@Inject(LocaleService) private _localeService: LocaleService,diff --git a/packages/sheets-hyper-link-ui/src/controllers/popup.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/popup.controller.tsindex 8ffeacbc76..13bf1ddad7 100644--- a/packages/sheets-hyper-link-ui/src/controllers/popup.controller.ts+++ b/packages/sheets-hyper-link-ui/src/controllers/popup.controller.ts@@ -14,7 +14,10 @@* limitations under the License.*/-import { CustomRangeType, Disposable, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOCS_ZEN_EDITOR_UNIT_ID_KEY, ICommandService, Inject, IPermissionService, IUniverInstanceService, LifecycleStages, OnLifecycle, Rectangle, UniverInstanceType } from '@univerjs/core';+import type { Nullable, Workbook } from '@univerjs/core';+import type { ISheetLocationBase } from '@univerjs/sheets';+import type { Subscription } from 'rxjs';+import { CustomRangeType, Disposable, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOCS_ZEN_EDITOR_UNIT_ID_KEY, ICommandService, Inject, IPermissionService, IUniverInstanceService, Rectangle, UniverInstanceType } from '@univerjs/core';import { DocSelectionManagerService } from '@univerjs/docs';import { DocEventManagerService } from '@univerjs/docs-ui';import { IRenderManagerService } from '@univerjs/engine-render';@@ -35,13 +38,9 @@ import {import { HoverManagerService, HoverRenderController, IEditorBridgeService, SheetPermissionInterceptorBaseController, SheetSkeletonManagerService } from '@univerjs/sheets-ui';import { IZenZoneService } from '@univerjs/ui';import { debounceTime, map, mergeMap, Observable } from 'rxjs';-import type { Nullable, Workbook } from '@univerjs/core';-import type { ISheetLocationBase } from '@univerjs/sheets';-import type { Subscription } from 'rxjs';import { SheetsHyperLinkPopupService } from '../services/popup.service';import { HyperLinkEditSourceType } from '../types/enums/edit-source';-@OnLifecycle(LifecycleStages.Rendered, SheetsHyperLinkPopupController)export class SheetsHyperLinkPopupController extends Disposable {constructor(@Inject(HoverManagerService) private readonly _hoverManagerService: HoverManagerService,diff --git a/packages/sheets-hyper-link-ui/src/controllers/remove-sheet.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/remove-sheet.controller.tsindex 6db71892e3..3874106507 100644--- a/packages/sheets-hyper-link-ui/src/controllers/remove-sheet.controller.ts+++ b/packages/sheets-hyper-link-ui/src/controllers/remove-sheet.controller.ts@@ -15,12 +15,11 @@*/import type { Workbook } from '@univerjs/core';-import { Disposable, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';import type { IRemoveSheetCommandParams } from '@univerjs/sheets';+import { Disposable, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { RemoveSheetCommand, SheetInterceptorService } from '@univerjs/sheets';import { AddHyperLinkMutation, HyperLinkModel, RemoveHyperLinkMutation } from '@univerjs/sheets-hyper-link';-@OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkRemoveSheetController)export class SheetsHyperLinkRemoveSheetController extends Disposable {constructor(@Inject(SheetInterceptorService) private _sheetInterceptorService: SheetInterceptorService,diff --git a/packages/sheets-hyper-link-ui/src/controllers/render-controllers/render.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/render-controllers/render.controller.tsindex 40c2c15100..1a90f757b9 100644--- a/packages/sheets-hyper-link-ui/src/controllers/render-controllers/render.controller.ts+++ b/packages/sheets-hyper-link-ui/src/controllers/render-controllers/render.controller.ts@@ -16,7 +16,7 @@import type { Workbook } from '@univerjs/core';import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';-import { Disposable, Inject, InterceptorEffectEnum, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, Inject, InterceptorEffectEnum } from '@univerjs/core';import { INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';import { HyperLinkModel } from '@univerjs/sheets-hyper-link';import { debounceTime } from 'rxjs';@@ -41,7 +41,6 @@ export class SheetsHyperLinkRenderController extends Disposable implements IRend}}-@OnLifecycle(LifecycleStages.Starting, SheetsHyperLinkRenderManagerController)export class SheetsHyperLinkRenderManagerController extends Disposable {constructor(@Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService,diff --git a/packages/sheets-hyper-link-ui/src/controllers/rich-text-ref-range.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/rich-text-ref-range.controller.tsindex a9772ff977..67a02fc477 100644--- a/packages/sheets-hyper-link-ui/src/controllers/rich-text-ref-range.controller.ts+++ b/packages/sheets-hyper-link-ui/src/controllers/rich-text-ref-range.controller.ts@@ -15,13 +15,12 @@*/import type { IDisposable, IDocumentData, IRange, Nullable, Workbook } from '@univerjs/core';-import { CustomRangeType, Disposable, DisposableCollection, ICommandService, Inject, isValidRange, IUniverInstanceService, LifecycleStages, ObjectMatrix, OnLifecycle, Tools, UniverInstanceType } from '@univerjs/core';-import { deserializeRangeWithSheet, serializeRange } from '@univerjs/engine-formula';import type { EffectRefRangeParams, ISetRangeValuesMutationParams } from '@univerjs/sheets';+import { CustomRangeType, Disposable, DisposableCollection, ICommandService, Inject, isValidRange, IUniverInstanceService, ObjectMatrix, Tools, UniverInstanceType } from '@univerjs/core';+import { deserializeRangeWithSheet, serializeRange } from '@univerjs/engine-formula';import { handleDefaultRangeChangeWithEffectRefCommands, RefRangeService, SetRangeValuesMutation } from '@univerjs/sheets';import { ERROR_RANGE } from '@univerjs/sheets-hyper-link';-@OnLifecycle(LifecycleStages.Starting, SheetsHyperLinkRichTextRefRangeController)export class SheetsHyperLinkRichTextRefRangeController extends Disposable {private _refRangeMap: Map<string, Map<string, ObjectMatrix<IDisposable>>> = new Map();constructor(diff --git a/packages/sheets-hyper-link-ui/src/controllers/set-range.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/set-range.controller.tsindex 623d37ad6c..f8ce3c9dd9 100644--- a/packages/sheets-hyper-link-ui/src/controllers/set-range.controller.ts+++ b/packages/sheets-hyper-link-ui/src/controllers/set-range.controller.ts@@ -14,15 +14,14 @@* limitations under the License.*/-import { BuildTextUtils, CustomRangeType, DataStreamTreeTokenType, Disposable, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, generateRandomId, Inject, IUniverInstanceService, LifecycleStages, ObjectMatrix, OnLifecycle, Range, TextX, Tools } from '@univerjs/core';+import type { IMutationInfo } from '@univerjs/core';+import type { ISetRangeValuesMutationParams } from '@univerjs/sheets';+import { BuildTextUtils, CustomRangeType, DataStreamTreeTokenType, Disposable, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, generateRandomId, Inject, IUniverInstanceService, ObjectMatrix, Range, TextX, Tools } from '@univerjs/core';import { IRenderManagerService } from '@univerjs/engine-render';import { ClearSelectionAllCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, getSheetCommandTarget, SetRangeValuesCommand, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';import { AddHyperLinkMutation, HyperLinkModel, RemoveHyperLinkMutation } from '@univerjs/sheets-hyper-link';import { IEditorBridgeService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';-import type { IMutationInfo } from '@univerjs/core';-import type { ISetRangeValuesMutationParams } from '@univerjs/sheets';-@OnLifecycle(LifecycleStages.Starting, SheetHyperLinkSetRangeController)export class SheetHyperLinkSetRangeController extends Disposable {constructor(@Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService,diff --git a/packages/sheets-hyper-link-ui/src/controllers/ui.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/ui.controller.tsindex 1dd7de6d0b..45b61450eb 100644--- a/packages/sheets-hyper-link-ui/src/controllers/ui.controller.ts+++ b/packages/sheets-hyper-link-ui/src/controllers/ui.controller.ts@@ -14,19 +14,18 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';-import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';+import { Disposable, ICommandService, Inject, Injector } from '@univerjs/core';import { LinkSingle } from '@univerjs/icons';-import { CellLinkPopup } from '../views/CellLinkPopup';-import { CellLinkEdit } from '../views/CellLinkEdit';-import { CloseHyperLinkPopupOperation, InsertHyperLinkOperation, InsertHyperLinkToolbarOperation, OpenHyperLinkEditPanelOperation } from '../commands/operations/popup.operations';+import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';import { AddHyperLinkCommand, AddRichHyperLinkCommand } from '../commands/commands/add-hyper-link.command';-import { UpdateHyperLinkCommand, UpdateRichHyperLinkCommand } from '../commands/commands/update-hyper-link.command';import { CancelHyperLinkCommand, CancelRichHyperLinkCommand } from '../commands/commands/remove-hyper-link.command';-import { menuSchema } from './menu.schema';+import { UpdateHyperLinkCommand, UpdateRichHyperLinkCommand } from '../commands/commands/update-hyper-link.command';+import { CloseHyperLinkPopupOperation, InsertHyperLinkOperation, InsertHyperLinkToolbarOperation, OpenHyperLinkEditPanelOperation } from '../commands/operations/popup.operations';+import { CellLinkEdit } from '../views/CellLinkEdit';+import { CellLinkPopup } from '../views/CellLinkPopup';import { InsertLinkShortcut } from './menu';+import { menuSchema } from './menu.schema';-@OnLifecycle(LifecycleStages.Ready, SheetsHyperLinkUIController)export class SheetsHyperLinkUIController extends Disposable {constructor(@Inject(ComponentManager) private _componentManager: ComponentManager,diff --git a/packages/sheets-hyper-link-ui/src/controllers/url.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/url.controller.tsindex 41f65c3a39..fd1dcc5361 100644--- a/packages/sheets-hyper-link-ui/src/controllers/url.controller.ts+++ b/packages/sheets-hyper-link-ui/src/controllers/url.controller.ts@@ -14,10 +14,9 @@* limitations under the License.*/-import { Disposable, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, Inject } from '@univerjs/core';import { SheetsHyperLinkResolverService } from '../services/resolver.service';-@OnLifecycle(LifecycleStages.Rendered, SheetHyperLinkUrlController)export class SheetHyperLinkUrlController extends Disposable {constructor(@Inject(SheetsHyperLinkResolverService) private _resolverService: SheetsHyperLinkResolverServicediff --git a/packages/sheets-hyper-link-ui/src/plugin.ts b/packages/sheets-hyper-link-ui/src/plugin.tsindex 3c9fdb7edd..d782786677 100644--- a/packages/sheets-hyper-link-ui/src/plugin.ts+++ b/packages/sheets-hyper-link-ui/src/plugin.ts@@ -73,12 +73,26 @@ export class UniverSheetsHyperLinkUIPlugin extends Plugin {[SheetHyperLinkUrlController],[SheetsHyperLinkRichTextRefRangeController],];-dependencies.forEach((dep) => this._injector.add(dep));++ this._injector.get(SheetsHyperLinkRenderManagerController);+ this._injector.get(SheetsHyperLinkRichTextRefRangeController);+ this._injector.get(SheetHyperLinkSetRangeController);}override onReady(): void {const renderManager = this._injector.get(IRenderManagerService);renderManager.registerRenderModule<Workbook>(UniverInstanceType.UNIVER_SHEET, [SheetsHyperLinkRenderController] as Dependency);++ this._injector.get(SheetsHyperLinkAutoFillController);+ this._injector.get(SheetsHyperLinkCopyPasteController);+ this._injector.get(SheetsHyperLinkRemoveSheetController);+ this._injector.get(SheetsHyperLinkUIController);+ }++ override onRendered(): void {+ this._injector.get(SheetsHyperLinkPermissionController);+ this._injector.get(SheetHyperLinkUrlController);+ this._injector.get(SheetsHyperLinkPopupController);}}diff --git a/packages/sheets-hyper-link/src/controllers/ref-range.controller.ts b/packages/sheets-hyper-link/src/controllers/ref-range.controller.tsindex e2a72544b0..9981647401 100644--- a/packages/sheets-hyper-link/src/controllers/ref-range.controller.ts+++ b/packages/sheets-hyper-link/src/controllers/ref-range.controller.ts@@ -15,15 +15,14 @@*/import type { IDisposable, IRange, Nullable } from '@univerjs/core';-import { Disposable, ICommandService, Inject, isValidRange, LifecycleStages, OnLifecycle, sequenceExecuteAsync, toDisposable } from '@univerjs/core';import type { EffectRefRangeParams } from '@univerjs/sheets';-import { handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests, handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests, RefRangeService, SheetsSelectionsService } from '@univerjs/sheets';import type { IAddHyperLinkMutationParams, ICellHyperLink, IRemoveHyperLinkMutationParams, IUpdateHyperLinkMutationParams, IUpdateHyperLinkRefMutationParams } from '@univerjs/sheets-hyper-link';-import { AddHyperLinkMutation, HyperLinkModel, RemoveHyperLinkMutation, UpdateHyperLinkMutation, UpdateHyperLinkRefMutation } from '@univerjs/sheets-hyper-link';+import { Disposable, ICommandService, Inject, isValidRange, sequenceExecuteAsync, toDisposable } from '@univerjs/core';import { deserializeRangeWithSheet, serializeRange } from '@univerjs/engine-formula';+import { handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests, handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests, RefRangeService, SheetsSelectionsService } from '@univerjs/sheets';+import { AddHyperLinkMutation, HyperLinkModel, RemoveHyperLinkMutation, UpdateHyperLinkMutation, UpdateHyperLinkRefMutation } from '@univerjs/sheets-hyper-link';import { ERROR_RANGE } from '../types/const';-@OnLifecycle(LifecycleStages.Starting, SheetsHyperLinkRefRangeController)export class SheetsHyperLinkRefRangeController extends Disposable {private _disposableMap = new Map<string, IDisposable>();private _watchDisposableMap = new Map<string, IDisposable>();diff --git a/packages/sheets-hyper-link/src/controllers/sheet-hyper-link-resource.controller.ts b/packages/sheets-hyper-link/src/controllers/sheet-hyper-link-resource.controller.tsindex 0ba555216b..54499c6e87 100644--- a/packages/sheets-hyper-link/src/controllers/sheet-hyper-link-resource.controller.ts+++ b/packages/sheets-hyper-link/src/controllers/sheet-hyper-link-resource.controller.ts@@ -14,15 +14,14 @@* limitations under the License.*/-import { Disposable, Inject, IResourceManagerService, LifecycleStages, OnLifecycle } from '@univerjs/core';+import type { ICellHyperLink } from '../types/interfaces/i-hyper-link';+import { Disposable, Inject, IResourceManagerService } from '@univerjs/core';import { UniverType } from '@univerjs/protocol';import { HyperLinkModel } from '../models/hyper-link.model';-import type { ICellHyperLink } from '../types/interfaces/i-hyper-link';import { SHEET_HYPER_LINK_PLUGIN } from '../types/const';type UnitHyperLinkJSON = Record<string, ICellHyperLink[]>;-@OnLifecycle(LifecycleStages.Starting, SheetsHyperLinkResourceController)export class SheetsHyperLinkResourceController extends Disposable {constructor(@IResourceManagerService private readonly _resourceManagerService: IResourceManagerService,diff --git a/packages/sheets-hyper-link/src/controllers/sheet-hyper-link.controller.ts b/packages/sheets-hyper-link/src/controllers/sheet-hyper-link.controller.tsindex fe10106ba6..45c728b95a 100644--- a/packages/sheets-hyper-link/src/controllers/sheet-hyper-link.controller.ts+++ b/packages/sheets-hyper-link/src/controllers/sheet-hyper-link.controller.ts@@ -14,12 +14,11 @@* limitations under the License.*/-import { Disposable, ICommandService, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, ICommandService } from '@univerjs/core';import { AddHyperLinkMutation } from '../commands/mutations/add-hyper-link.mutation';-import { UpdateHyperLinkMutation, UpdateHyperLinkRefMutation } from '../commands/mutations/update-hyper-link.mutation';import { RemoveHyperLinkMutation } from '../commands/mutations/remove-hyper-link.mutation';+import { UpdateHyperLinkMutation, UpdateHyperLinkRefMutation } from '../commands/mutations/update-hyper-link.mutation';-@OnLifecycle(LifecycleStages.Starting, SheetsHyperLinkController)export class SheetsHyperLinkController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandServicediff --git a/packages/sheets-hyper-link/src/plugin.ts b/packages/sheets-hyper-link/src/plugin.tsindex e3d6ec1607..cb51800153 100644--- a/packages/sheets-hyper-link/src/plugin.ts+++ b/packages/sheets-hyper-link/src/plugin.ts@@ -14,16 +14,16 @@* limitations under the License.*/-import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import type { Dependency } from '@univerjs/core';+import type { IUniverSheetsHyperLinkConfig } from './controllers/config.schema';+import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import { UniverSheetsPlugin } from '@univerjs/sheets';+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';+import { SheetsHyperLinkRefRangeController } from './controllers/ref-range.controller';import { SheetsHyperLinkController } from './controllers/sheet-hyper-link.controller';+import { SheetsHyperLinkResourceController } from './controllers/sheet-hyper-link-resource.controller';import { HyperLinkModel } from './models/hyper-link.model';import { SHEET_HYPER_LINK_PLUGIN } from './types/const';-import { SheetsHyperLinkResourceController } from './controllers/sheet-hyper-link-resource.controller';-import { SheetsHyperLinkRefRangeController } from './controllers/ref-range.controller';-import type { IUniverSheetsHyperLinkConfig } from './controllers/config.schema';-import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';@DependentOn(UniverSheetsPlugin)export class UniverSheetsHyperLinkPlugin extends Plugin {@@ -51,5 +51,9 @@ export class UniverSheetsHyperLinkPlugin extends Plugin {] as Dependency[]).forEach((dep) => {this._injector.add(dep);});++ this._injector.get(SheetsHyperLinkRefRangeController);+ this._injector.get(SheetsHyperLinkResourceController);+ this._injector.get(SheetsHyperLinkController);}}diff --git a/packages/sheets-numfmt/src/controllers/__tests__/test.util.ts b/packages/sheets-numfmt/src/controllers/__tests__/test.util.tsindex ff68f8097a..e27b5cf949 100644--- a/packages/sheets-numfmt/src/controllers/__tests__/test.util.ts+++ b/packages/sheets-numfmt/src/controllers/__tests__/test.util.ts@@ -73,6 +73,10 @@ export const createTestBed = (dependencies?: Dependency[]) => {injector.get(SheetInterceptorService);}++ override onRendered(): void {+ this._injector.get(INumfmtService);+ }}univer.registerPlugin(TestPlugin);diff --git a/packages/sheets-numfmt/src/controllers/numfmt.cell-content.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.cell-content.controller.tsindex 418bdedb3d..66d112967f 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.cell-content.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.cell-content.controller.ts@@ -14,6 +14,12 @@* limitations under the License.*/+import type {+ ICellData,+ ICellDataForSheetInterceptor,+ Workbook,+} from '@univerjs/core';+import type { ISetNumfmtMutationParams, ISetRangeValuesMutationParams } from '@univerjs/sheets';import {CellValueType,Disposable,@@ -21,26 +27,17 @@ import {Inject,InterceptorEffectEnum,IUniverInstanceService,- LifecycleStages,LocaleService,ObjectMatrix,- OnLifecycle,Range,ThemeService,UniverInstanceType,} from '@univerjs/core';import { InterceptCellContentPriority, INTERCEPTOR_POINT, INumfmtService, SetNumfmtMutation, SetRangeValuesMutation, SheetInterceptorService } from '@univerjs/sheets';-import { of, skip, switchMap } from 'rxjs';-import type {- ICellData,- ICellDataForSheetInterceptor,- Workbook,-} from '@univerjs/core';-import type { ISetNumfmtMutationParams, ISetRangeValuesMutationParams } from '@univerjs/sheets';+import { of, skip, switchMap } from 'rxjs';import { getPatternPreviewIgnoreGeneral } from '../utils/pattern';-@OnLifecycle(LifecycleStages.Rendered, SheetsNumfmtCellContentController)export class SheetsNumfmtCellContentController extends Disposable {constructor(@IUniverInstanceService private readonly _instanceService: IUniverInstanceService,diff --git a/packages/sheets-numfmt/src/controllers/numfmt.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.controller.tsindex 4da6949d25..d0598d4668 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.controller.ts@@ -14,6 +14,11 @@* limitations under the License.*/+import type { IDisposable, IRange, Workbook } from '@univerjs/core';+import type { ISetNumfmtMutationParams } from '@univerjs/sheets';+import type { ISetNumfmtCommandParams } from '../commands/commands/set-numfmt.command';+import type { ISheetNumfmtPanelProps } from '../components/index';+import type { INumfmtController } from './type';import {CellValueType,Disposable,@@ -22,9 +27,7 @@ import {Inject,InterceptorEffectEnum,IUniverInstanceService,- LifecycleStages,LocaleService,- OnLifecycle,Range,ThemeService,toDisposable,@@ -39,13 +42,11 @@ import {SheetInterceptorService,SheetsSelectionsService,} from '@univerjs/sheets';+import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';import { ComponentManager, ISidebarService } from '@univerjs/ui';import { combineLatest, Observable } from 'rxjs';import { debounceTime, map, switchMap, tap } from 'rxjs/operators';-import type { IDisposable, IRange, Workbook } from '@univerjs/core';--import type { ISetNumfmtMutationParams } from '@univerjs/sheets';import { SHEET_NUMFMT_PLUGIN } from '../base/const/PLUGIN_NAME';import { AddDecimalCommand } from '../commands/commands/add-decimal.command';import { SetCurrencyCommand } from '../commands/commands/set-currency.command';@@ -56,11 +57,7 @@ import { CloseNumfmtPanelOperator } from '../commands/operations/close.numfmt.paimport { OpenNumfmtPanelOperator } from '../commands/operations/open.numfmt.panel.operation';import { SheetNumfmtPanel } from '../components/index';import { getPatternPreviewIgnoreGeneral, getPatternType } from '../utils/pattern';-import type { ISetNumfmtCommandParams } from '../commands/commands/set-numfmt.command';-import type { ISheetNumfmtPanelProps } from '../components/index';-import type { INumfmtController } from './type';-@OnLifecycle(LifecycleStages.Rendered, NumfmtController)export class NumfmtController extends Disposable implements INumfmtController {/*** If _previewPattern is null ,the realTimeRenderingInterceptor will skip and if it is '',realTimeRenderingInterceptor will clear numfmt.diff --git a/packages/sheets-numfmt/src/controllers/numfmt.currency.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.currency.controller.tsindex fde35b6afd..87db583312 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.currency.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.currency.controller.ts@@ -14,22 +14,14 @@* limitations under the License.*/-import { Disposable, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';--import { BehaviorSubject } from 'rxjs';import type { countryCurrencyMap } from '../base/const/CURRENCY-SYMBOLS';+import { Disposable } from '@univerjs/core';+import { BehaviorSubject } from 'rxjs';-@OnLifecycle(LifecycleStages.Rendered, NumfmtCurrencyController)export class NumfmtCurrencyController extends Disposable {private _currencySymbol$ = new BehaviorSubject<keyof typeof countryCurrencyMap>('US');public readonly currencySymbol$ = this._currencySymbol$.asObservable();- constructor(- @Inject(Injector) private _injector: Injector- ) {- super();- }-/*** Set the currency symbol by setting the country code.*/diff --git a/packages/sheets-numfmt/src/controllers/numfmt.editor.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.editor.controller.tsindex 78ebb9b33a..79917180be 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.editor.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.editor.controller.ts@@ -15,25 +15,23 @@*/import type { IRange, Nullable, Workbook } from '@univerjs/core';+import type {+ INumfmtItemWithCache,+ IRemoveNumfmtMutationParams,+ ISetCellsNumfmt,+ ISetNumfmtMutationParams,+} from '@univerjs/sheets';import {CellValueType,Disposable,Inject,Injector,IUniverInstanceService,- LifecycleStages,numfmt,- OnLifecycle,Optional,toDisposable,UniverInstanceType,} from '@univerjs/core';-import type {- INumfmtItemWithCache,- IRemoveNumfmtMutationParams,- ISetCellsNumfmt,- ISetNumfmtMutationParams,-} from '@univerjs/sheets';import {factoryRemoveNumfmtUndoMutation,factorySetNumfmtUndoMutation,@@ -69,7 +67,7 @@ const createCollectEffectMutation = () => {clean,};};-@OnLifecycle(LifecycleStages.Rendered, NumfmtEditorController)+export class NumfmtEditorController extends Disposable {// collect effect mutations when edit end and push this to commands stack in next commands progressprivate _collectEffectMutation = createCollectEffectMutation();@@ -160,7 +158,6 @@ export class NumfmtEditorController extends Disposable {);const currentNumfmtType = (currentNumfmtValue && getPatternType(currentNumfmtValue.pattern)) ?? '';const clean = () => {- // eslint-disable-next-line ts/no-unused-expressionscurrentNumfmtValue &&this._collectEffectMutation.add(context.unitId,diff --git a/packages/sheets-numfmt/src/controllers/numfmt.menu.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.menu.controller.tsindex 0f1a95947c..f0dc57e11a 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.menu.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.menu.controller.ts@@ -14,20 +14,19 @@* limitations under the License.*/-import { Disposable, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, Inject } from '@univerjs/core';import { ComponentManager, IMenuManagerService } from '@univerjs/ui';import { MORE_NUMFMT_TYPE_KEY, MoreNumfmtType, Options, OPTIONS_KEY } from '../components/more-numfmt-type/MoreNumfmtType';import { menuSchema } from './menu.schema';-@OnLifecycle(LifecycleStages.Rendered, NumfmtMenuController)export class NumfmtMenuController extends Disposable {constructor(- @Inject(Injector) private _injector: Injector,@Inject(ComponentManager) private _componentManager: ComponentManager,@IMenuManagerService private readonly _menuManagerService: IMenuManagerService) {super();+this._initMenu();}diff --git a/packages/sheets-numfmt/src/controllers/type.ts b/packages/sheets-numfmt/src/controllers/type.tsindex 6efe9b9d88..181217519c 100644--- a/packages/sheets-numfmt/src/controllers/type.ts+++ b/packages/sheets-numfmt/src/controllers/type.ts@@ -14,10 +14,9 @@* limitations under the License.*/-import { createIdentifier, LifecycleStages, runOnLifecycle } from '@univerjs/core';+import { createIdentifier } from '@univerjs/core';+export const INumfmtController = createIdentifier<INumfmtController>('INumfmtController');export interface INumfmtController {openPanel(): void;}-export const INumfmtController = createIdentifier<INumfmtController>('INumfmtController');-runOnLifecycle(LifecycleStages.Rendered, INumfmtController);diff --git a/packages/sheets-numfmt/src/numfmt-plugin.ts b/packages/sheets-numfmt/src/numfmt-plugin.tsindex b9b1ed98aa..be84aa63fe 100644--- a/packages/sheets-numfmt/src/numfmt-plugin.ts+++ b/packages/sheets-numfmt/src/numfmt-plugin.ts@@ -14,22 +14,21 @@* limitations under the License.*/-import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';+import type { IUniverSheetsNumfmtConfig } from './controllers/config.schema';+import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import { UniverSheetsPlugin } from '@univerjs/sheets';import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui';import { SHEET_NUMFMT_PLUGIN } from './base/const/PLUGIN_NAME';+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { SheetsNumfmtCellContentController } from './controllers/numfmt.cell-content.controller';import { NumfmtController } from './controllers/numfmt.controller';+import { NumfmtCurrencyController } from './controllers/numfmt.currency.controller';import { NumfmtEditorController } from './controllers/numfmt.editor.controller';-import { NumfmtI18nController } from './controllers/numfmt.i18n.controller';import { NumfmtMenuController } from './controllers/numfmt.menu.controller';-import { NumfmtCurrencyController } from './controllers/numfmt.currency.controller';import { INumfmtController } from './controllers/type';import { UserHabitController } from './controllers/user-habit.controller';import { MenuCurrencyService } from './service/menu.currency.service';-import type { IUniverSheetsNumfmtConfig } from './controllers/config.schema';-import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';@DependentOn(UniverSheetsPlugin, UniverSheetsUIPlugin)export class UniverSheetsNumfmtPlugin extends Plugin {@@ -56,9 +55,16 @@ export class UniverSheetsNumfmtPlugin extends Plugin {this._injector.add([NumfmtEditorController]);this._injector.add([UserHabitController]);this._injector.add([SheetsNumfmtCellContentController]);- this._injector.add([NumfmtI18nController]);this._injector.add([MenuCurrencyService]);this._injector.add([NumfmtCurrencyController]);this._injector.add([NumfmtMenuController]);}++ override onRendered(): void {+ this._injector.get(INumfmtController);+ this._injector.get(SheetsNumfmtCellContentController);+ this._injector.get(NumfmtCurrencyController);+ this._injector.get(NumfmtEditorController);+ this._injector.get(NumfmtMenuController);+ }}diff --git a/packages/sheets-sort-ui/src/controllers/sheets-sort-ui.controller.ts b/packages/sheets-sort-ui/src/controllers/sheets-sort-ui.controller.tsindex 25477bc705..72c4413a41 100644--- a/packages/sheets-sort-ui/src/controllers/sheets-sort-ui.controller.ts+++ b/packages/sheets-sort-ui/src/controllers/sheets-sort-ui.controller.ts@@ -14,19 +14,19 @@* limitations under the License.*/-import { connectInjector, ICommandService, Inject, Injector, LifecycleStages, LocaleService, OnLifecycle, RxDisposable } from '@univerjs/core';-import type { UIPartsService } from '@univerjs/ui';-import { ComponentManager, IDialogService, ILayoutService, IMenuManagerService, IUIPartsService } from '@univerjs/ui';-import { takeUntil } from 'rxjs';++import type { ISheetSortLocation } from '../services/sheets-sort-ui.service';+import { connectInjector, ICommandService, Inject, Injector, LocaleService, RxDisposable } from '@univerjs/core';import { serializeRange } from '@univerjs/engine-formula';import { AscendingSingle, CustomSortSingle, DescendingSingle, ExpandAscendingSingle, ExpandDescendingSingle } from '@univerjs/icons';-import { SheetsRenderService, SheetsUIPart } from '@univerjs/sheets-ui';import { SortRangeCommand } from '@univerjs/sheets-sort';+import { SheetsRenderService, SheetsUIPart } from '@univerjs/sheets-ui';+import { ComponentManager, IDialogService, ILayoutService, IMenuManagerService, IUIPartsService } from '@univerjs/ui';+import { takeUntil } from 'rxjs';import { SortRangeAscCommand, SortRangeAscExtCommand, SortRangeAscExtInCtxMenuCommand, SortRangeAscInCtxMenuCommand, SortRangeCustomCommand, SortRangeCustomInCtxMenuCommand, SortRangeDescCommand, SortRangeDescExtCommand, SortRangeDescExtInCtxMenuCommand, SortRangeDescInCtxMenuCommand } from '../commands/commands/sheets-sort.command';-import { CustomSortPanel } from '../views/CustomSortPanel';-import type { ISheetSortLocation } from '../services/sheets-sort-ui.service';import { SheetsSortUIService } from '../services/sheets-sort-ui.service';+import { CustomSortPanel } from '../views/CustomSortPanel';import EmbedSortBtn from '../views/EmbedSortBtn';import { menuSchema } from './menu.schema';import { SHEETS_SORT_ASC_EXT_ICON, SHEETS_SORT_ASC_ICON, SHEETS_SORT_CUSTOM_ICON, SHEETS_SORT_DESC_EXT_ICON, SHEETS_SORT_DESC_ICON } from './sheets-sort.menu';@@ -34,7 +34,6 @@ import { SHEETS_SORT_ASC_EXT_ICON, SHEETS_SORT_ASC_ICON, SHEETS_SORT_CUSTOM_ICONconst CUSTOM_SORT_DIALOG_ID = 'custom-sort-dialog';const CUSTOM_SORT_PANEL_WIDTH = 560;-@OnLifecycle(LifecycleStages.Ready, SheetsSortUIController)export class SheetsSortUIController extends RxDisposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/sheets-sort-ui/src/plugin.ts b/packages/sheets-sort-ui/src/plugin.tsindex 16eb7f7e90..3764cc5761 100644--- a/packages/sheets-sort-ui/src/plugin.ts+++ b/packages/sheets-sort-ui/src/plugin.ts@@ -14,6 +14,8 @@* limitations under the License.*/+import type { Dependency } from '@univerjs/core';+import type { IUniverSheetsSortUIConfig } from './controllers/config.schema';import {DependentOn,IConfigService,@@ -22,13 +24,10 @@ import {Plugin,UniverInstanceType,} from '@univerjs/core';-import type { Dependency } from '@univerjs/core';-import { UniverSheetsSortPlugin } from '@univerjs/sheets-sort';-import { SheetsSortUIService } from './services/sheets-sort-ui.service';-import { SheetsSortUIController } from './controllers/sheets-sort-ui.controller';-import type { IUniverSheetsSortUIConfig } from './controllers/config.schema';import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';+import { SheetsSortUIController } from './controllers/sheets-sort-ui.controller';+import { SheetsSortUIService } from './services/sheets-sort-ui.service';const NAME = 'SHEET_SORT_UI_PLUGIN';@@ -55,4 +54,8 @@ export class UniverSheetsSortUIPlugin extends Plugin {[SheetsSortUIController],] as Dependency[]).forEach((d) => this._injector.add(d));}++ override onRendered(): void {+ this._injector.get(SheetsSortUIController);+ }}diff --git a/packages/sheets-sort-ui/src/services/sheets-sort-ui.service.tsx b/packages/sheets-sort-ui/src/services/sheets-sort-ui.service.tsxindex 9e27417762..3d11d4d432 100644--- a/packages/sheets-sort-ui/src/services/sheets-sort-ui.service.tsx+++ b/packages/sheets-sort-ui/src/services/sheets-sort-ui.service.tsx@@ -15,27 +15,25 @@*/import type { IRange, Nullable, Workbook, Worksheet } from '@univerjs/core';+import type { ISheetRangeLocation } from '@univerjs/sheets';++import type { ISortOption } from '@univerjs/sheets-sort';import {Disposable,ICommandService,ILogService,Inject,IUniverInstanceService,- LifecycleStages,LocaleService,LocaleType,- OnLifecycle,Tools,UniverInstanceType,} from '@univerjs/core';import { expandToContinuousRange, getPrimaryForRange, SetSelectionsOperation, SheetsSelectionsService } from '@univerjs/sheets';-import type { ISheetRangeLocation } from '@univerjs/sheets';--import type { ISortOption } from '@univerjs/sheets-sort';import { SheetsSortService, SortType } from '@univerjs/sheets-sort';-import React from 'react';import { IConfirmService } from '@univerjs/ui';+import React from 'react';import { BehaviorSubject } from 'rxjs';import { ExtendConfirm } from '../views/ExtendConfirm';@@ -61,7 +59,6 @@ const SORT_ERROR_MESSAGE = {FORMULA_ARRAY: 'sheets-sort.error.formula-array',};-@OnLifecycle(LifecycleStages.Ready, SheetsSortService)export class SheetsSortUIService extends Disposable {private readonly _customSortState$ = new BehaviorSubject<Nullable<ICustomSortState>>(null);readonly customSortState$ = this._customSortState$.asObservable();diff --git a/packages/sheets-sort/src/commands/commands/__tests__/create-command-test-bed.ts b/packages/sheets-sort/src/commands/commands/__tests__/create-command-test-bed.tsindex 399d485b05..6599cf63bf 100644--- a/packages/sheets-sort/src/commands/commands/__tests__/create-command-test-bed.ts+++ b/packages/sheets-sort/src/commands/commands/__tests__/create-command-test-bed.ts@@ -16,11 +16,11 @@import type { Dependency, IWorkbookData, Workbook } from '@univerjs/core';import { BooleanNumber, ILogService, Inject, Injector, IUniverInstanceService, LocaleService, LocaleType, LogLevel, Plugin, Tools, Univer, UniverInstanceType } from '@univerjs/core';-import { SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';import { FormulaDataModel } from '@univerjs/engine-formula';+import { SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';+import { SheetsSortController } from '../../../controllers/sheets-sort.controller';import enUS from '../../../locale/en-US';import { SheetsSortService } from '../../../services/sheets-sort.service';-import { SheetsSortController } from '../../../controllers/sheets-sort.controller';const TEST_WORKBOOK_DATA_DEMO: IWorkbookData = {id: 'test',@@ -147,6 +147,10 @@ export function createCommandTestBed(workbookData?: IWorkbookData, dependencies?dependencies?.forEach((d) => injector.add(d));}++ override onReady(): void {+ this._injector.get(SheetsSortController);+ }}univer.registerPlugin(TestPlugin);diff --git a/packages/sheets-sort/src/commands/commands/__tests__/sheets-reorder.command.spec.ts b/packages/sheets-sort/src/commands/commands/__tests__/sheets-reorder.command.spec.tsindex 50aad32359..9a6e4cbdf2 100644--- a/packages/sheets-sort/src/commands/commands/__tests__/sheets-reorder.command.spec.ts+++ b/packages/sheets-sort/src/commands/commands/__tests__/sheets-reorder.command.spec.ts@@ -15,10 +15,10 @@*/import type { ICellData, Injector, Nullable, Univer, Workbook } from '@univerjs/core';+import type { ISortRangeCommandParams } from '../sheets-sort.command';import { ICommandService, IUniverInstanceService } from '@univerjs/core';-import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { ReorderRangeCommand, ReorderRangeMutation, SetSelectionsOperation } from '@univerjs/sheets';-import type { ISortRangeCommandParams } from '../sheets-sort.command';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { SortRangeCommand } from '../sheets-sort.command';import { createCommandTestBed } from './create-command-test-bed';diff --git a/packages/sheets-sort/src/controllers/sheets-sort.controller.ts b/packages/sheets-sort/src/controllers/sheets-sort.controller.tsindex 3f967a3c40..ac2ab1ec24 100644--- a/packages/sheets-sort/src/controllers/sheets-sort.controller.ts+++ b/packages/sheets-sort/src/controllers/sheets-sort.controller.ts@@ -15,16 +15,15 @@*/import type { ICellData, Nullable } from '@univerjs/core';-import { CellValueType, Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';-import type { ICellValueCompareFn } from '../commands/commands/sheets-sort.command';++import { CellValueType, Disposable, ICommandService, Inject } from '@univerjs/core';import { SortRangeCommand } from '../commands/commands/sheets-sort.command';import { SheetsSortService } from '../services/sheets-sort.service';import { compareNull, compareNumber, compareString, isNullValue } from './utils';export type ICommonComparableCellValue = number | string | null;-@OnLifecycle(LifecycleStages.Ready, SheetsSortController)export class SheetsSortController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/sheets-sort/src/plugin.ts b/packages/sheets-sort/src/plugin.tsindex f965788d57..981b4baad9 100644--- a/packages/sheets-sort/src/plugin.ts+++ b/packages/sheets-sort/src/plugin.ts@@ -14,13 +14,13 @@* limitations under the License.*/-import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import type { Dependency } from '@univerjs/core';+import type { IUniverSheetsSortConfig } from './controllers/config.schema';+import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { SheetsSortController } from './controllers/sheets-sort.controller';import { SheetsSortService } from './services/sheets-sort.service';-import type { IUniverSheetsSortConfig } from './controllers/config.schema';-import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';const NAME = 'SHEET_SORT_PLUGIN';@@ -46,4 +46,8 @@ export class UniverSheetsSortPlugin extends Plugin {[SheetsSortService],] as Dependency[]).forEach((d) => this._injector.add(d));}++ override onReady(): void {+ this._injector.get(SheetsSortController);+ }}diff --git a/packages/sheets-sort/src/services/sheets-sort.service.ts b/packages/sheets-sort/src/services/sheets-sort.service.tsindex 4a13f2701f..ab49a7e70c 100644--- a/packages/sheets-sort/src/services/sheets-sort.service.ts+++ b/packages/sheets-sort/src/services/sheets-sort.service.ts@@ -15,24 +15,20 @@*/import type { IRange, Workbook } from '@univerjs/core';+import type { ISheetRangeLocation } from '@univerjs/sheets';+import type { ISortOption } from './interface';import {Disposable,ICommandService,Inject,IUniverInstanceService,- LifecycleStages,- OnLifecycle,Rectangle,} from '@univerjs/core';--import type { ISheetRangeLocation } from '@univerjs/sheets';-import { getSheetCommandTarget } from '@univerjs/sheets';import { FormulaDataModel } from '@univerjs/engine-formula';+import { getSheetCommandTarget } from '@univerjs/sheets';import { type ICellValueCompareFn, SortRangeCommand } from '../commands/commands/sheets-sort.command';import { isNullValue } from '../controllers/utils';-import type { ISortOption } from './interface';-@OnLifecycle(LifecycleStages.Ready, SheetsSortService)export class SheetsSortService extends Disposable {private _compareFns: ICellValueCompareFn[] = [];diff --git a/packages/sheets-thread-comment-base/src/controllers/sheets-thread-comment-ref-range.controller.ts b/packages/sheets-thread-comment-base/src/controllers/sheets-thread-comment-ref-range.controller.tsindex d28e9bd5ab..5abc2859d7 100644--- a/packages/sheets-thread-comment-base/src/controllers/sheets-thread-comment-ref-range.controller.ts+++ b/packages/sheets-thread-comment-base/src/controllers/sheets-thread-comment-ref-range.controller.ts@@ -15,16 +15,15 @@*/import type { IDisposable, IRange, Nullable } from '@univerjs/core';-import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle, sequenceExecuteAsync, toDisposable } from '@univerjs/core';import type { EffectRefRangeParams } from '@univerjs/sheets';-import { handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests, RefRangeService, SheetsSelectionsService } from '@univerjs/sheets';import type { IAddCommentMutationParams, IUpdateCommentRefMutationParams } from '@univerjs/thread-comment';-import { AddCommentMutation, DeleteCommentMutation, ThreadCommentModel, UpdateCommentRefMutation } from '@univerjs/thread-comment';-import { serializeRange, singleReferenceToGrid } from '@univerjs/engine-formula';import type { ISheetThreadComment } from '../types/interfaces/i-sheet-thread-comment';+import { Disposable, ICommandService, Inject, sequenceExecuteAsync, toDisposable } from '@univerjs/core';+import { serializeRange, singleReferenceToGrid } from '@univerjs/engine-formula';+import { handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests, RefRangeService, SheetsSelectionsService } from '@univerjs/sheets';+import { AddCommentMutation, DeleteCommentMutation, ThreadCommentModel, UpdateCommentRefMutation } from '@univerjs/thread-comment';import { SheetsThreadCommentModel } from '../models/sheets-thread-comment.model';-@OnLifecycle(LifecycleStages.Starting, SheetsThreadCommentRefRangeController)export class SheetsThreadCommentRefRangeController extends Disposable {private _disposableMap = new Map<string, IDisposable>();private _watcherMap = new Map<string, IDisposable>();diff --git a/packages/sheets-thread-comment-base/src/plugin.ts b/packages/sheets-thread-comment-base/src/plugin.tsindex 1dc14f914a..6098d735e3 100644--- a/packages/sheets-thread-comment-base/src/plugin.ts+++ b/packages/sheets-thread-comment-base/src/plugin.ts@@ -41,5 +41,7 @@ export class UniverSheetsThreadCommentBasePlugin extends Plugin {] as Dependency[]).forEach((dep) => {this._injector.add(dep);});++ this._injector.get(SheetsThreadCommentRefRangeController);}}diff --git a/packages/sheets-thread-comment/src/controllers/render-controllers/render.controller.ts b/packages/sheets-thread-comment/src/controllers/render-controllers/render.controller.tsindex baa3a49139..8167418476 100644--- a/packages/sheets-thread-comment/src/controllers/render-controllers/render.controller.ts+++ b/packages/sheets-thread-comment/src/controllers/render-controllers/render.controller.ts@@ -15,13 +15,12 @@*/import type { Workbook } from '@univerjs/core';-import { Disposable, Inject, InterceptorEffectEnum, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import { Disposable, Inject, InterceptorEffectEnum, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { IRenderManagerService } from '@univerjs/engine-render';import { INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';import { debounceTime } from 'rxjs';-@OnLifecycle(LifecycleStages.Ready, SheetsThreadCommentRenderController)export class SheetsThreadCommentRenderController extends Disposable {constructor(@Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService,diff --git a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-copy-paste.controller.ts b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-copy-paste.controller.tsindex b33bdf8533..30a9eae91c 100644--- a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-copy-paste.controller.ts+++ b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-copy-paste.controller.ts@@ -15,11 +15,11 @@*/import type { IMutationInfo, IRange, Nullable } from '@univerjs/core';-import { Disposable, Inject, LifecycleStages, OnLifecycle, Range } from '@univerjs/core';-import { COPY_TYPE, ISheetClipboardService } from '@univerjs/sheets-ui';-import { AddCommentMutation, DeleteCommentMutation, type IThreadComment, IThreadCommentDataSourceService } from '@univerjs/thread-comment';+import { Disposable, Inject, Range } from '@univerjs/core';import { serializeRange, singleReferenceToGrid } from '@univerjs/engine-formula';import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';+import { COPY_TYPE, ISheetClipboardService } from '@univerjs/sheets-ui';+import { AddCommentMutation, DeleteCommentMutation, type IThreadComment, IThreadCommentDataSourceService } from '@univerjs/thread-comment';import { SHEETS_THREAD_COMMENT } from '../types/const';const transformRef = (ref: string, source: { row: number; column: number }, target: { row: number; column: number }) => {@@ -35,7 +35,6 @@ const transformRef = (ref: string, source: { row: number; column: number }, targreturn serializeRange(targetRange);};-@OnLifecycle(LifecycleStages.Rendered, SheetsThreadCommentCopyPasteController)export class SheetsThreadCommentCopyPasteController extends Disposable {private _copyInfo: Nullable<{unitId: string;diff --git a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-hover.controller.ts b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-hover.controller.tsindex 7e3df58766..3777d53b1a 100644--- a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-hover.controller.ts+++ b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-hover.controller.ts@@ -14,14 +14,13 @@* limitations under the License.*/-import { Disposable, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, Inject } from '@univerjs/core';import { RangeProtectionPermissionViewPoint, WorkbookCommentPermission, WorksheetViewPermission } from '@univerjs/sheets';import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';import { HoverManagerService, SheetPermissionInterceptorBaseController } from '@univerjs/sheets-ui';import { debounceTime } from 'rxjs';import { SheetsThreadCommentPopupService } from '../services/sheets-thread-comment-popup.service';-@OnLifecycle(LifecycleStages.Rendered, SheetsThreadCommentHoverController)export class SheetsThreadCommentHoverController extends Disposable {constructor(@Inject(HoverManagerService) private readonly _hoverManagerService: HoverManagerService,diff --git a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-popup.controller.ts b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-popup.controller.tsindex 8c04c1660a..5f5558d645 100644--- a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-popup.controller.ts+++ b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-popup.controller.ts@@ -17,7 +17,7 @@import type { Nullable, Workbook } from '@univerjs/core';import type { ISelectionWithStyle } from '@univerjs/sheets';import type { IDeleteCommentMutationParams } from '@univerjs/thread-comment';-import { Disposable, ICommandService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, RANGE_TYPE, UniverInstanceType } from '@univerjs/core';+import { Disposable, ICommandService, Inject, IUniverInstanceService, RANGE_TYPE, UniverInstanceType } from '@univerjs/core';import { singleReferenceToGrid } from '@univerjs/engine-formula';import { RangeProtectionPermissionViewPoint, SetWorksheetActiveOperation, SheetsSelectionsService, WorkbookCommentPermission, WorksheetViewPermission } from '@univerjs/sheets';import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';@@ -34,7 +34,6 @@ interface ISelectionShapeInfo {commentId: string;}-@OnLifecycle(LifecycleStages.Rendered, SheetsThreadCommentPopupController)export class SheetsThreadCommentPopupController extends Disposable {private _isSwitchToCommenting = false;private _selectionShapeInfo: Nullable<ISelectionShapeInfo> = null;diff --git a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-remove.controller.ts b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-remove.controller.tsindex 9e9c9a9087..d4da29a38d 100644--- a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-remove.controller.ts+++ b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment-remove.controller.ts@@ -15,13 +15,12 @@*/import type { Workbook } from '@univerjs/core';-import { Disposable, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';import type { IRemoveSheetCommandParams } from '@univerjs/sheets';-import { RemoveSheetCommand, SheetInterceptorService } from '@univerjs/sheets';import type { IDeleteCommentMutationParams } from '@univerjs/thread-comment';+import { Disposable, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';+import { RemoveSheetCommand, SheetInterceptorService } from '@univerjs/sheets';import { AddCommentMutation, DeleteCommentMutation, IThreadCommentDataSourceService, ThreadCommentModel } from '@univerjs/thread-comment';-@OnLifecycle(LifecycleStages.Ready, ThreadCommentRemoveSheetsController)export class ThreadCommentRemoveSheetsController extends Disposable {constructor(@Inject(SheetInterceptorService) private _sheetInterceptorService: SheetInterceptorService,diff --git a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.tsindex 76b8756821..202e408dbd 100644--- a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts+++ b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts@@ -14,17 +14,16 @@* limitations under the License.*/-import { Disposable, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';-import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';+import { Disposable, Inject } from '@univerjs/core';import { CommentSingle } from '@univerjs/icons';import { THREAD_COMMENT_PANEL } from '@univerjs/thread-comment-ui';-import { SheetsThreadCommentCell } from '../views/sheets-thread-comment-cell';+import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';import { COMMENT_SINGLE_ICON, SHEETS_THREAD_COMMENT_MODAL } from '../types/const';+import { SheetsThreadCommentCell } from '../views/sheets-thread-comment-cell';import { SheetsThreadCommentPanel } from '../views/sheets-thread-comment-panel';import { AddCommentShortcut } from './menu';import { menuSchema } from './menu.schema';-@OnLifecycle(LifecycleStages.Starting, SheetsThreadCommentController)export class SheetsThreadCommentController extends Disposable {constructor(@IMenuManagerService private readonly _menuManagerService: IMenuManagerService,diff --git a/packages/sheets-thread-comment/src/plugin.ts b/packages/sheets-thread-comment/src/plugin.tsindex f51bbee341..3d401b2e0e 100644--- a/packages/sheets-thread-comment/src/plugin.ts+++ b/packages/sheets-thread-comment/src/plugin.ts@@ -14,10 +14,11 @@* limitations under the License.*/+import type { Dependency } from '@univerjs/core';+import type { IUniverSheetsThreadCommentConfig } from './controllers/config.schema';import { DependentOn, ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';import { UniverSheetsThreadCommentBasePlugin } from '@univerjs/sheets-thread-comment-base';import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';-import type { Dependency } from '@univerjs/core';import { ShowAddSheetCommentModalOperation } from './commands/operations/comment.operation';import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { SheetsThreadCommentRenderController } from './controllers/render-controllers/render.controller';@@ -28,7 +29,6 @@ import { SheetsThreadCommentPopupController } from './controllers/sheets-thread-import { ThreadCommentRemoveSheetsController } from './controllers/sheets-thread-comment-remove.controller';import { SheetsThreadCommentPopupService } from './services/sheets-thread-comment-popup.service';import { SHEETS_THREAD_COMMENT } from './types/const';-import type { IUniverSheetsThreadCommentConfig } from './controllers/config.schema';@DependentOn(UniverThreadCommentUIPlugin, UniverSheetsThreadCommentBasePlugin)export class UniverSheetsThreadCommentPlugin extends Plugin {@@ -67,5 +67,18 @@ export class UniverSheetsThreadCommentPlugin extends Plugin {[ShowAddSheetCommentModalOperation].forEach((command) => {this._commandService.registerCommand(command);});++ this._injector.get(SheetsThreadCommentController);+ }++ override onReady(): void {+ this._injector.get(SheetsThreadCommentRenderController);+ this._injector.get(ThreadCommentRemoveSheetsController);+ }++ override onRendered(): void {+ this._injector.get(SheetsThreadCommentCopyPasteController);+ this._injector.get(SheetsThreadCommentHoverController);+ this._injector.get(SheetsThreadCommentPopupController);}}diff --git a/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.ts b/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.tsindex f948f77557..f0b40eda7c 100644--- a/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.ts+++ b/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.ts@@ -22,7 +22,7 @@ import type {ISetWorksheetActiveOperationParams,ISetWorksheetHideMutationParams,} from '@univerjs/sheets';-import { Disposable, ICommandService, IUniverInstanceService, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';import {InsertSheetMutation,RemoveSheetMutation,@@ -36,7 +36,6 @@ import {* worksheet tab related mutations executes. We cannot write this logic in* commands because it does not take collaborative editing into consideration.*/-@OnLifecycle(LifecycleStages.Ready, ActiveWorksheetController)export class ActiveWorksheetController extends Disposable {private _previousSheetIndex = -1;diff --git a/packages/sheets-ui/src/controllers/auto-fill.controller.ts b/packages/sheets-ui/src/controllers/auto-fill.controller.tsindex b1beecd7c2..f5e61b2b3c 100644--- a/packages/sheets-ui/src/controllers/auto-fill.controller.ts+++ b/packages/sheets-ui/src/controllers/auto-fill.controller.ts@@ -38,9 +38,7 @@ import {Inject,Injector,IUniverInstanceService,- LifecycleStages,ObjectMatrix,- OnLifecycle,Rectangle,toDisposable,Tools,@@ -82,7 +80,6 @@ import { ISheetSelectionRenderService } from '../services/selection/base-selectiimport { SheetsRenderService } from '../services/sheets-render.service';import { discreteRangeToRange, generateNullCellValueRowCol, rangeToDiscreteRange } from './utils/range-tools';-@OnLifecycle(LifecycleStages.Steady, AutoFillController)export class AutoFillController extends Disposable {private _beforeApplyData: Array<Array<Nullable<ICellData>>> = [];private _currentLocation: Nullable<IAutoFillLocation> = null;diff --git a/packages/sheets-ui/src/controllers/auto-height.controller.ts b/packages/sheets-ui/src/controllers/auto-height.controller.tsindex 7bf98c11ee..c8a058a10c 100644--- a/packages/sheets-ui/src/controllers/auto-height.controller.ts+++ b/packages/sheets-ui/src/controllers/auto-height.controller.ts@@ -15,13 +15,15 @@*/import type { IRange, Workbook } from '@univerjs/core';-import { Disposable, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import type { RenderManagerService } from '@univerjs/engine-render';import type {ISetRangeValuesRangeMutationParams,ISetStyleCommandParams,ISetWorksheetRowAutoHeightMutationParams,ISetWorksheetRowIsAutoHeightMutationParams,} from '@univerjs/sheets';+import { Disposable, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';+import { IRenderManagerService } from '@univerjs/engine-render';import {SetRangeValuesCommand,SetStyleCommand,@@ -31,17 +33,13 @@ import {SheetInterceptorService,SheetsSelectionsService,} from '@univerjs/sheets';-import type { RenderManagerService } from '@univerjs/engine-render';-import { IRenderManagerService } from '@univerjs/engine-render';import { SheetSkeletonManagerService } from '../services/sheet-skeleton-manager.service';export const AFFECT_LAYOUT_STYLES = ['ff', 'fs', 'tr', 'tb'];-@OnLifecycle(LifecycleStages.Ready, AutoHeightController)export class AutoHeightController extends Disposable {constructor(@IRenderManagerService private readonly _renderManagerService: RenderManagerService,- @Inject(Injector) private readonly _injector: Injector,@Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService,@Inject(SheetsSelectionsService) private readonly _selectionManagerService: SheetsSelectionsService,@Inject(IUniverInstanceService) private readonly _univerInstanceService: IUniverInstanceServicediff --git a/packages/sheets-ui/src/controllers/cell-alert.controller.ts b/packages/sheets-ui/src/controllers/cell-alert.controller.tsindex 713e64395a..47099f6b25 100644--- a/packages/sheets-ui/src/controllers/cell-alert.controller.ts+++ b/packages/sheets-ui/src/controllers/cell-alert.controller.ts@@ -15,13 +15,14 @@*/import type { Workbook } from '@univerjs/core';-import { Disposable, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';-import { ComponentManager } from '@univerjs/ui';import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';-import { CellAlert } from '../views/cell-alert/CellAlertPopup';+import { Disposable, Inject } from '@univerjs/core';+import { ComponentManager } from '@univerjs/ui';import { CELL_ALERT_KEY } from '../views/cell-alert';+import { CellAlert } from '../views/cell-alert/CellAlertPopup';++// FIXME@weird94: this should not be render module-@OnLifecycle(LifecycleStages.Starting, CellAlertRenderController)export class CellAlertRenderController extends Disposable implements IRenderModule {constructor(private readonly _context: IRenderContext<Workbook>,diff --git a/packages/sheets-ui/src/controllers/cell-custom-render.controller.ts b/packages/sheets-ui/src/controllers/cell-custom-render.controller.tsindex f801aaf93d..32385b4c9a 100644--- a/packages/sheets-ui/src/controllers/cell-custom-render.controller.ts+++ b/packages/sheets-ui/src/controllers/cell-custom-render.controller.ts@@ -14,16 +14,15 @@* limitations under the License.*/-import { Disposable, DisposableCollection, Inject, IPermissionService, IUniverInstanceService, LifecycleStages, OnLifecycle, sortRules } from '@univerjs/core';-import { IRenderManagerService, Vector2 } from '@univerjs/engine-render';-import { UnitAction, WorkbookEditablePermission, WorksheetEditPermission } from '@univerjs/sheets';-import type { ICellCustomRender, ICellDataForSheetInterceptor, ICellRenderContext, Nullable, UniverInstanceService, Workbook } from '@univerjs/core';+import type { ICellCustomRender, ICellDataForSheetInterceptor, ICellRenderContext, Nullable, Workbook } from '@univerjs/core';import type { IMouseEvent, IPointerEvent, IRenderContext, IRenderModule, RenderManagerService, Spreadsheet } from '@univerjs/engine-render';import type { ICellPermission } from '@univerjs/sheets';-import { SheetSkeletonManagerService } from '../services/sheet-skeleton-manager.service';import type { ISheetSkeletonManagerParam } from '../services/sheet-skeleton-manager.service';+import { Disposable, DisposableCollection, Inject, IPermissionService, sortRules } from '@univerjs/core';+import { IRenderManagerService, Vector2 } from '@univerjs/engine-render';+import { UnitAction, WorkbookEditablePermission, WorksheetEditPermission } from '@univerjs/sheets';+import { SheetSkeletonManagerService } from '../services/sheet-skeleton-manager.service';-@OnLifecycle(LifecycleStages.Rendered, CellCustomRenderController)export class CellCustomRenderController extends Disposable implements IRenderModule {private _enterActiveRender: Nullable<{render: ICellCustomRender;@@ -34,7 +33,6 @@ export class CellCustomRenderController extends Disposable implements IRenderModprivate readonly _context: IRenderContext<Workbook>,@Inject(SheetSkeletonManagerService) private readonly _sheetSkeletonManagerService: SheetSkeletonManagerService,@IRenderManagerService private readonly _renderManagerService: RenderManagerService,- @IUniverInstanceService private readonly _univerInstanceService: UniverInstanceService,@IPermissionService private readonly _permissionService: IPermissionService) {super();diff --git a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.tsindex d652e62536..a6d997c361 100644--- a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts+++ b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts@@ -14,6 +14,33 @@* limitations under the License.*/+import type {+ ICellData,+ ICommandInfo,+ IDocumentData,+ IMutationInfo,+ IObjectArrayPrimitiveType,+ IObjectMatrixPrimitiveType,+ IRange,+ IRowData,+ Nullable,+ Workbook,+ Worksheet,+} from '@univerjs/core';+import type {+ IInsertColMutationParams,+ IInsertRowMutationParams,+ ISetRangeValuesMutationParams,+ ISetWorksheetColWidthMutationParams,+ ISetWorksheetRowHeightMutationParams,+} from '@univerjs/sheets';+import type {+ ICellDataWithSpanInfo,+ IClipboardPropertyItem,+ ICopyPastePayload,+ ISheetClipboardHook,+ ISheetDiscreteRangeLocation,+} from '../../services/clipboard/type';import {BooleanNumber,convertBodyToHtml,@@ -30,15 +57,15 @@ import {Injector,isFormulaString,IUniverInstanceService,- LifecycleStages,LocaleService,ObjectMatrix,- OnLifecycle,RxDisposable,Tools,UniverInstanceType,} from '@univerjs/core';+import { MessageType } from '@univerjs/design';+import { DocSelectionRenderService } from '@univerjs/docs-ui';import { IRenderManagerService } from '@univerjs/engine-render';@@ -53,30 +80,8 @@ import {SetWorksheetColWidthMutation,SetWorksheetRowHeightMutation,} from '@univerjs/sheets';-import { IMessageService } from '@univerjs/ui';import { takeUntil } from 'rxjs';--import type {- ICellData,- ICommandInfo,- IDocumentData,- IMutationInfo,- IObjectArrayPrimitiveType,- IObjectMatrixPrimitiveType,- IRange,- IRowData,- Nullable,- Workbook,- Worksheet,-} from '@univerjs/core';-import type {- IInsertColMutationParams,- IInsertRowMutationParams,- ISetRangeValuesMutationParams,- ISetWorksheetColWidthMutationParams,- ISetWorksheetRowHeightMutationParams,-} from '@univerjs/sheets';import { AddWorksheetMergeCommand } from '../../commands/commands/add-worksheet-merge.command';import {SheetCopyCommand,@@ -99,19 +104,11 @@ import {getSetCellStyleMutations,getSetCellValueMutations,} from './utils';-import type {- ICellDataWithSpanInfo,- IClipboardPropertyItem,- ICopyPastePayload,- ISheetClipboardHook,- ISheetDiscreteRangeLocation,-} from '../../services/clipboard/type';/*** This controller add basic clipboard logic for basic features such as text color / BISU / row widths to the clipboard* service. You can create a similar clipboard controller to add logic for your own features.*/-@OnLifecycle(LifecycleStages.Rendered, SheetClipboardController)export class SheetClipboardController extends RxDisposable {constructor(@Inject(Injector) private readonly _injector: Injector,diff --git a/packages/sheets-ui/src/controllers/defined-name/defined-name.controller.ts b/packages/sheets-ui/src/controllers/defined-name/defined-name.controller.tsindex 5b7adb96b3..93ad3c2dd3 100644--- a/packages/sheets-ui/src/controllers/defined-name/defined-name.controller.ts+++ b/packages/sheets-ui/src/controllers/defined-name/defined-name.controller.ts@@ -15,13 +15,12 @@*/import type { Workbook } from '@univerjs/core';-import { Disposable, ICommandService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, ThemeService, UniverInstanceType } from '@univerjs/core';-import { deserializeRangeWithSheet, IDefinedNamesService, isReferenceStrings, operatorToken } from '@univerjs/engine-formula';import type { ISelectionWithStyle } from '@univerjs/sheets';+import { Disposable, ICommandService, Inject, IUniverInstanceService, ThemeService, UniverInstanceType } from '@univerjs/core';+import { deserializeRangeWithSheet, IDefinedNamesService, isReferenceStrings, operatorToken } from '@univerjs/engine-formula';import { getNormalSelectionStyle, getPrimaryForRange, ScrollToCellOperation, SetWorksheetActivateCommand, SheetsSelectionsService } from '@univerjs/sheets';import { filter, merge } from 'rxjs';-@OnLifecycle(LifecycleStages.Rendered, SheetsDefinedNameController)export class SheetsDefinedNameController extends Disposable {constructor(@Inject(SheetsSelectionsService) private readonly _selectionManagerService: SheetsSelectionsService,diff --git a/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts b/packages/sheets-ui/src/controllers/editor/formula-editor.controller.tsindex a576238867..1ce9d0945f 100644--- a/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts+++ b/packages/sheets-ui/src/controllers/editor/formula-editor.controller.ts@@ -14,6 +14,11 @@* limitations under the License.*/+import type { DocumentDataModel, ICommandInfo, ICustomRange, IParagraph, ITextRun, JSONXActions, Nullable } from '@univerjs/core';+import type { IRichTextEditingMutationParams } from '@univerjs/docs';+import type { DocumentViewModel, RenderComponentType } from '@univerjs/engine-render';+import type { IMoveRangeMutationParams, ISetRangeValuesMutationParams } from '@univerjs/sheets';+import type { IEditorBridgeServiceParam } from '../../services/editor-bridge.service';import {BooleanNumber,DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,@@ -27,8 +32,6 @@ import {Inject,IUndoRedoService,IUniverInstanceService,- LifecycleStages,- OnLifecycle,RxDisposable,Tools,UniverInstanceType,@@ -40,20 +43,14 @@ import {} from '@univerjs/docs';import { CoverContentCommand, VIEWPORT_KEY as DOC_VIEWPORT_KEY } from '@univerjs/docs-ui';import { DeviceInputEventType, IRenderManagerService, ScrollBar } from '@univerjs/engine-render';+import { MoveRangeMutation, RangeProtectionRuleModel, SetRangeValuesMutation, WorksheetProtectionRuleModel } from '@univerjs/sheets';import { SetEditorResizeOperation } from '@univerjs/ui';import { takeUntil } from 'rxjs';-import type { DocumentDataModel, ICommandInfo, ICustomRange, IParagraph, ITextRun, JSONXActions, Nullable } from '@univerjs/core';-import type { IRichTextEditingMutationParams } from '@univerjs/docs';--import type { DocumentViewModel, RenderComponentType } from '@univerjs/engine-render';-import type { IMoveRangeMutationParams, ISetRangeValuesMutationParams } from '@univerjs/sheets';import { getEditorObject } from '../../basics/editor/get-editor-object';import { IFormulaEditorManagerService } from '../../services/editor/formula-editor-manager.service';import { IEditorBridgeService } from '../../services/editor-bridge.service';-import type { IEditorBridgeServiceParam } from '../../services/editor-bridge.service';-@OnLifecycle(LifecycleStages.Rendered, FormulaEditorController)export class FormulaEditorController extends RxDisposable {private _loadedMap = new WeakSet<RenderComponentType>();diff --git a/packages/sheets-ui/src/controllers/force-string-alert-render.controller.ts b/packages/sheets-ui/src/controllers/force-string-alert-render.controller.tsindex 686c52d951..6aaa9483b0 100644--- a/packages/sheets-ui/src/controllers/force-string-alert-render.controller.ts+++ b/packages/sheets-ui/src/controllers/force-string-alert-render.controller.ts@@ -15,15 +15,13 @@*/import type { Workbook } from '@univerjs/core';-import { CellValueType, Disposable, Inject, isRealNum, LifecycleStages, LocaleService, OnLifecycle } from '@univerjs/core';-import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';-import { HoverManagerService } from '../services/hover-manager.service';+import { CellValueType, Disposable, Inject, isRealNum, LocaleService } from '@univerjs/core';import { CellAlertManagerService, CellAlertType } from '../services/cell-alert-manager.service';+import { HoverManagerService } from '../services/hover-manager.service';const ALERT_KEY = 'SHEET_FORCE_STRING_ALERT';-@OnLifecycle(LifecycleStages.Rendered, ForceStringAlertRenderController)export class ForceStringAlertRenderController extends Disposable implements IRenderModule {constructor(private readonly _context: IRenderContext<Workbook>,diff --git a/packages/sheets-ui/src/controllers/force-string-render.controller.ts b/packages/sheets-ui/src/controllers/force-string-render.controller.tsindex 2e67c15d66..793cd599fa 100644--- a/packages/sheets-ui/src/controllers/force-string-render.controller.ts+++ b/packages/sheets-ui/src/controllers/force-string-render.controller.ts@@ -14,23 +14,20 @@* limitations under the License.*/-import { CellValueType, Inject, InterceptorEffectEnum, isRealNum, LifecycleStages, OnLifecycle, RxDisposable } from '@univerjs/core';-import { INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';import type { Workbook } from '@univerjs/core';import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';+import { CellValueType, Inject, InterceptorEffectEnum, isRealNum, RxDisposable } from '@univerjs/core';+import { INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';import { SheetSkeletonManagerService } from '../services/sheet-skeleton-manager.service';-@OnLifecycle(LifecycleStages.Rendered, ForceStringRenderController)export class ForceStringRenderController extends RxDisposable implements IRenderModule {constructor(private readonly _context: IRenderContext<Workbook>,@Inject(SheetSkeletonManagerService) private readonly _sheetSkeletonManagerService: SheetSkeletonManagerService,- @Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService) {+ @Inject(SheetInterceptorService) private readonly _sheetInterceptorService: SheetInterceptorService+ ) {super();- this._init();- }- private _init() {this._initViewModelIntercept();}diff --git a/packages/sheets-ui/src/controllers/format-painter/format-painter.controller.ts b/packages/sheets-ui/src/controllers/format-painter/format-painter.controller.tsindex 71fdea6179..34d00434ae 100644--- a/packages/sheets-ui/src/controllers/format-painter/format-painter.controller.ts+++ b/packages/sheets-ui/src/controllers/format-painter/format-painter.controller.ts@@ -14,23 +14,22 @@* limitations under the License.*/+import type { ICellData, IMutationInfo, IRange, IStyleData, Workbook } from '@univerjs/core';+import type { IAddWorksheetMergeMutationParams, IRemoveWorksheetMergeMutationParams, ISetRangeValuesMutationParams } from '@univerjs/sheets';++import type { IFormatPainterHook, ISelectionFormatInfo } from '../../services/format-painter/format-painter.service';import {Disposable,ICommandService,Inject,Injector,IUniverInstanceService,- LifecycleStages,ObjectMatrix,- OnLifecycle,Tools,UniverInstanceType,} from '@univerjs/core';import { IRenderManagerService } from '@univerjs/engine-render';-import { AddMergeUndoMutationFactory, AddWorksheetMergeMutation, getAddMergeMutationRangeByType, RemoveMergeUndoMutationFactory, RemoveWorksheetMergeMutation, SetRangeValuesCommand, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';-import type { ICellData, IMutationInfo, IRange, IStyleData, Workbook } from '@univerjs/core';-import type { IAddWorksheetMergeMutationParams, IRemoveWorksheetMergeMutationParams, ISetRangeValuesMutationParams } from '@univerjs/sheets';import {ApplyFormatPainterCommand,SetOnceFormatPainterCommand,@@ -38,9 +37,7 @@ import {import { checkCellContentInRanges, getClearContentMutationParamsForRanges } from '../../common/utils';import { FormatPainterStatus, IFormatPainterService } from '../../services/format-painter/format-painter.service';import { ISheetSelectionRenderService } from '../../services/selection/base-selection-render.service';-import type { IFormatPainterHook, ISelectionFormatInfo } from '../../services/format-painter/format-painter.service';-@OnLifecycle(LifecycleStages.Steady, FormatPainterController)export class FormatPainterController extends Disposable {constructor(@ICommandService private readonly _commandService: ICommandService,diff --git a/packages/sheets-ui/src/controllers/menu/__tests__/create-menu-test-bed.ts b/packages/sheets-ui/src/controllers/menu/__tests__/create-menu-test-bed.tsindex 356de1129e..30f6a2928a 100644--- a/packages/sheets-ui/src/controllers/menu/__tests__/create-menu-test-bed.ts+++ b/packages/sheets-ui/src/controllers/menu/__tests__/create-menu-test-bed.ts@@ -80,6 +80,10 @@ export function createMenuTestBed() {injector.add([RangeProtectionCache]);injector.add([RangeProtectionRuleModel]);injector.add([RangeProtectionService]);++ this._injector.get(SheetInterceptorService);+ this._injector.get(WorkbookPermissionService);+ this._injector.get(WorksheetPermissionService);}}diff --git a/packages/sheets-ui/src/controllers/mobile/mobile-sheet-ui.controller.ts b/packages/sheets-ui/src/controllers/mobile/mobile-sheet-ui.controller.tsindex fb71584d81..1d6346a615 100644--- a/packages/sheets-ui/src/controllers/mobile/mobile-sheet-ui.controller.ts+++ b/packages/sheets-ui/src/controllers/mobile/mobile-sheet-ui.controller.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { connectInjector, Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import { connectInjector, Disposable, ICommandService, Inject, Injector, UniverInstanceType } from '@univerjs/core';import {SetBoldCommand,SetFontFamilyCommand,@@ -31,6 +31,7 @@ import {AddWorksheetMergeHorizontalCommand,AddWorksheetMergeVerticalCommand,} from '../../commands/commands/add-worksheet-merge.command';+import { AutoClearContentCommand, AutoFillCommand } from '../../commands/commands/auto-fill.command';import { DeleteRangeMoveLeftConfirmCommand } from '../../commands/commands/delete-range-move-left-confirm.command';import { DeleteRangeMoveUpConfirmCommand } from '../../commands/commands/delete-range-move-up-confirm.command';import { HideColConfirmCommand, HideRowConfirmCommand } from '../../commands/commands/hide-row-col-confirm.command';@@ -47,6 +48,7 @@ import {} from '../../commands/commands/inline-format.command';import { InsertRangeMoveDownConfirmCommand } from '../../commands/commands/insert-range-move-down-confirm.command';import { InsertRangeMoveRightConfirmCommand } from '../../commands/commands/insert-range-move-right-confirm.command';+import { AddRangeProtectionFromContextMenuCommand, AddRangeProtectionFromSheetBarCommand, AddRangeProtectionFromToolbarCommand, DeleteRangeProtectionFromContextMenuCommand, SetProtectionCommand, SetRangeProtectionFromContextMenuCommand, ViewSheetPermissionFromContextMenuCommand, ViewSheetPermissionFromSheetBarCommand } from '../../commands/commands/range-protection.command';import { RefillCommand } from '../../commands/commands/refill.command';import { RemoveColConfirmCommand, RemoveRowConfirmCommand } from '../../commands/commands/remove-row-col-confirm.command';import { RemoveSheetConfirmCommand } from '../../commands/commands/remove-sheet-confirm.command';@@ -70,6 +72,7 @@ import {} from '../../commands/commands/set-selection.command';import { ChangeZoomRatioCommand, SetZoomRatioCommand } from '../../commands/commands/set-zoom-ratio.command';import { ShowMenuListCommand } from '../../commands/commands/unhide.command';+import { AddWorksheetProtectionCommand, ChangeSheetProtectionFromSheetBarCommand, DeleteWorksheetProtectionCommand, DeleteWorksheetProtectionFormSheetBarCommand, SetWorksheetProtectionCommand } from '../../commands/commands/worksheet-protection.command';import { SetActivateCellEditOperation } from '../../commands/operations/activate-cell-edit.operation';import {SetCellEditVisibleArrowOperation,@@ -80,6 +83,9 @@ import { RenameSheetOperation } from '../../commands/operations/rename-sheet.opeimport { SetScrollOperation } from '../../commands/operations/scroll.operation';import { SetFormatPainterOperation } from '../../commands/operations/set-format-painter.operation';import { SetZoomRatioOperation } from '../../commands/operations/set-zoom-ratio.operation';+import { SheetPermissionOpenDialogOperation } from '../../commands/operations/sheet-permission-open-dialog.operation';+import { SheetPermissionOpenPanelOperation } from '../../commands/operations/sheet-permission-open-panel.operation';+import { SidebarDefinedNameOperation } from '../../commands/operations/sidebar-defined-name.operation';import { BorderPanel } from '../../components/border-panel/BorderPanel';import { BORDER_PANEL_COMPONENT } from '../../components/border-panel/interface';import { COLOR_PICKER_COMPONENT, ColorPicker } from '../../components/color-picker';@@ -89,18 +95,13 @@ import {FontFamily,FontFamilyItem,} from '../../components/font-family';+import { FONT_SIZE_COMPONENT, FontSize } from '../../components/font-size';import { MENU_ITEM_INPUT_COMPONENT, MenuItemInput } from '../../components/menu-item-input';import { DEFINED_NAME_CONTAINER } from '../../views/defined-name/component-name';import { DefinedNameContainer } from '../../views/defined-name/DefinedNameContainer';-import { SidebarDefinedNameOperation } from '../../commands/operations/sidebar-defined-name.operation';-import { AutoClearContentCommand, AutoFillCommand } from '../../commands/commands/auto-fill.command';--import { SheetPermissionOpenPanelOperation } from '../../commands/operations/sheet-permission-open-panel.operation';-import { SheetPermissionOpenDialogOperation } from '../../commands/operations/sheet-permission-open-dialog.operation';-import { AddRangeProtectionFromContextMenuCommand, AddRangeProtectionFromSheetBarCommand, AddRangeProtectionFromToolbarCommand, DeleteRangeProtectionFromContextMenuCommand, SetProtectionCommand, SetRangeProtectionFromContextMenuCommand, ViewSheetPermissionFromContextMenuCommand, ViewSheetPermissionFromSheetBarCommand } from '../../commands/commands/range-protection.command';-import { AddWorksheetProtectionCommand, ChangeSheetProtectionFromSheetBarCommand, DeleteWorksheetProtectionCommand, DeleteWorksheetProtectionFormSheetBarCommand, SetWorksheetProtectionCommand } from '../../commands/commands/worksheet-protection.command';+import { MobileSheetBar } from '../../views/mobile/sheet-bar/MobileSheetBar';import {EditorBreakLineShortcut,EditorCursorEnterShortcut,@@ -151,10 +152,8 @@ import {ZoomInShortcutItem,ZoomOutShortcutItem,} from '../shortcuts/view.shortcut';-import { MobileSheetBar } from '../../views/mobile/sheet-bar/MobileSheetBar';import { menuSchema } from './menu.schema';-@OnLifecycle(LifecycleStages.Ready, SheetUIMobileController)export class SheetUIMobileController extends Disposable {constructor(@Inject(Injector) private readonly _injector: Injector,diff --git a/packages/sheets-ui/src/controllers/permission/sheet-permission-init.controller.ts b/packages/sheets-ui/src/controllers/permission/sheet-permission-init.controller.tsindex 286adcf850..d42e524314 100644--- a/packages/sheets-ui/src/controllers/permission/sheet-permission-init.controller.ts+++ b/packages/sheets-ui/src/controllers/permission/sheet-permission-init.controller.ts@@ -16,19 +16,13 @@import type { Workbook } from '@univerjs/core';import type { IAddRangeProtectionMutationParams, IAddWorksheetProtectionParams, ISetWorksheetPermissionPointsMutationParams, IWorksheetProtectionRenderCellData } from '@univerjs/sheets';--import { Disposable, IAuthzIoService, ICommandService, Inject, InterceptorEffectEnum, IPermissionService, IUndoRedoService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType, UserManagerService } from '@univerjs/core';+import { Disposable, IAuthzIoService, ICommandService, Inject, InterceptorEffectEnum, IPermissionService, IUndoRedoService, IUniverInstanceService, UniverInstanceType, UserManagerService } from '@univerjs/core';import { UnitAction, UnitObject } from '@univerjs/protocol';+import { AddRangeProtectionMutation, AddWorksheetProtectionMutation, defaultWorkbookPermissionPoints, defaultWorksheetPermissionPoint, getAllRangePermissionPoint, getAllWorkbookPermissionPoint, getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel, INTERCEPTOR_POINT, RangeProtectionCache, RangeProtectionRuleModel, SetWorksheetPermissionPointsMutation, SheetInterceptorService, WorksheetEditPermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetViewPermission } from '@univerjs/sheets';-import { AddRangeProtectionMutation, AddWorksheetProtectionMutation, defaultWorkbookPermissionPoints, defaultWorksheetPermissionPoint, getAllRangePermissionPoint, getAllWorkbookPermissionPoint, getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel, INTERCEPTOR_POINT, RangeProtectionCache, RangeProtectionRenderModel, RangeProtectionRuleModel, SetWorksheetPermissionPointsMutation, SheetInterceptorService, WorksheetEditPermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetViewPermission } from '@univerjs/sheets';--import { IDialogService } from '@univerjs/ui';--@OnLifecycle(LifecycleStages.Rendered, SheetPermissionInitController)export class SheetPermissionInitController extends Disposable {constructor(@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,- @IDialogService private readonly _dialogService: IDialogService,@IPermissionService private _permissionService: IPermissionService,@IAuthzIoService private _authzIoService: IAuthzIoService,@Inject(RangeProtectionRuleModel) private _rangeProtectionRuleModel: RangeProtectionRuleModel,@@ -36,7 +30,6 @@ export class SheetPermissionInitController extends Disposable {@Inject(UserManagerService) private _userManagerService: UserManagerService,@Inject(WorksheetProtectionPointModel) private _worksheetProtectionPointRuleModel: WorksheetProtectionPointModel,@Inject(SheetInterceptorService) private _sheetInterceptorService: SheetInterceptorService,- @Inject(RangeProtectionRenderModel) private _selectionProtectionRenderModel: RangeProtectionRenderModel,@Inject(IUndoRedoService) private _undoRedoService: IUndoRedoService,@Inject(ICommandService) private _commandService: ICommandService,@Inject(RangeProtectionCache) private _rangeProtectionCache: RangeProtectionCachediff --git a/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-base.controller.ts b/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-base.controller.tsindex d0734e54cf..7b7fa631d0 100644--- a/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-base.controller.ts+++ b/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-base.controller.ts@@ -17,14 +17,16 @@/* eslint-disable complexity *//* eslint-disable max-lines-per-function */-import { CustomCommandExecutionError, Disposable, DisposableCollection, FOCUSING_EDITOR_STANDALONE, ICommandService, IContextService, Inject, IPermissionService, isICellData, IUniverInstanceService, LifecycleStages, LocaleService, ObjectMatrix, OnLifecycle, Rectangle, Tools, UniverInstanceType } from '@univerjs/core';+import type { ICellData, ICellDataForSheetInterceptor, ICommandInfo, IObjectMatrixPrimitiveType, IPermissionTypes, IRange, Nullable, Workbook, WorkbookPermissionPointConstructor, Worksheet } from '@univerjs/core';+import type { IMoveColsCommandParams, IMoveRangeCommandParams, IMoveRowsCommandParams, ISetRangeValuesCommandParams, ISetSpecificColsVisibleCommandParams, ISetSpecificRowsVisibleCommandParams, ISetWorksheetNameMutationParams, ISetWorksheetShowCommandParams } from '@univerjs/sheets';+import type { ISheetPasteParams } from '../../commands/commands/clipboard.command';+import type { IEditorBridgeServiceVisibleParam } from '../../services/editor-bridge.service';+import { CustomCommandExecutionError, Disposable, DisposableCollection, FOCUSING_EDITOR_STANDALONE, ICommandService, IContextService, Inject, IPermissionService, isICellData, IUniverInstanceService, LocaleService, ObjectMatrix, Rectangle, Tools, UniverInstanceType } from '@univerjs/core';import { IMEInputCommand, InsertCommand } from '@univerjs/docs-ui';import { deserializeRangeWithSheet, IDefinedNamesService, LexerTreeBuilder, operatorToken, sequenceNodeType } from '@univerjs/engine-formula';import { UnitAction } from '@univerjs/protocol';import { ClearSelectionContentCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, getSheetCommandTarget, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, MoveColsCommand, MoveRangeCommand, MoveRowsCommand, RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint, RangeProtectionRuleModel, SetBackgroundColorCommand, SetColWidthCommand, SetRangeValuesCommand, SetRowHeightCommand, SetSelectedColsVisibleCommand, SetSelectedRowsVisibleCommand, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetWorksheetNameCommand, SetWorksheetNameMutation, SetWorksheetOrderCommand, SetWorksheetRowIsAutoHeightCommand, SetWorksheetShowCommand, SheetsSelectionsService, WorkbookCopyPermission, WorkbookEditablePermission, WorkbookHideSheetPermission, WorkbookManageCollaboratorPermission, WorkbookMoveSheetPermission, WorkbookRenameSheetPermission, WorksheetCopyPermission, WorksheetEditPermission, WorksheetProtectionRuleModel, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, WorksheetViewPermission } from '@univerjs/sheets';import { IDialogService } from '@univerjs/ui';-import type { ICellData, ICellDataForSheetInterceptor, ICommandInfo, IObjectMatrixPrimitiveType, IPermissionTypes, IRange, Nullable, Workbook, WorkbookPermissionPointConstructor, Worksheet } from '@univerjs/core';-import type { IMoveColsCommandParams, IMoveRangeCommandParams, IMoveRowsCommandParams, ISetRangeValuesCommandParams, ISetSpecificColsVisibleCommandParams, ISetSpecificRowsVisibleCommandParams, ISetWorksheetNameMutationParams, ISetWorksheetShowCommandParams } from '@univerjs/sheets';import { AutoFillCommand } from '../../commands/commands/auto-fill.command';import { SheetCopyCommand, SheetCutCommand, SheetPasteColWidthCommand, SheetPasteShortKeyCommand } from '../../commands/commands/clipboard.command';import { SetRangeBoldCommand, SetRangeItalicCommand, SetRangeStrickThroughCommand, SetRangeUnderlineCommand } from '../../commands/commands/inline-format.command';@@ -33,15 +35,12 @@ import { SetCellEditVisibleOperation } from '../../commands/operations/cell-editimport { IAutoFillService } from '../../services/auto-fill/auto-fill.service';import { PREDEFINED_HOOK_NAME } from '../../services/clipboard/clipboard.service';import { UNIVER_SHEET_PERMISSION_ALERT_DIALOG, UNIVER_SHEET_PERMISSION_ALERT_DIALOG_ID } from '../../views/permission/error-msg-dialog/interface';-import type { ISheetPasteParams } from '../../commands/commands/clipboard.command';-import type { IEditorBridgeServiceVisibleParam } from '../../services/editor-bridge.service';type ICellPermission = Record<UnitAction, boolean> & { ruleId?: string; ranges?: IRange[] };type ICheckPermissionCommandParams = IEditorBridgeServiceVisibleParam | IMoveRowsCommandParams | IMoveColsCommandParams | IMoveRangeCommandParams | ISetRangeValuesCommandParams | ISheetPasteParams | ISetSpecificRowsVisibleCommandParams;export const SHEET_PERMISSION_PASTE_PLUGIN = 'SHEET_PERMISSION_PASTE_PLUGIN';-@OnLifecycle(LifecycleStages.Ready, SheetPermissionInterceptorBaseController)export class SheetPermissionInterceptorBaseController extends Disposable {disposableCollection = new DisposableCollection();diff --git a/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-canvas-render.controller.ts b/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-canvas-render.controller.tsindex 54ff979280..088a196545 100644--- a/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-canvas-render.controller.ts+++ b/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-canvas-render.controller.ts@@ -16,7 +16,7 @@import type { ICellDataForSheetInterceptor, IRange, Nullable, Workbook } from '@univerjs/core';import type { IRenderContext, IRenderModule, Scene, SpreadsheetSkeleton } from '@univerjs/engine-render';-import { DisposableCollection, Inject, IPermissionService, IUniverInstanceService, LifecycleStages, OnLifecycle, Optional, RANGE_TYPE, Rectangle, RxDisposable, UniverInstanceType } from '@univerjs/core';+import { DisposableCollection, Inject, IPermissionService, IUniverInstanceService, Optional, RANGE_TYPE, Rectangle, RxDisposable, UniverInstanceType } from '@univerjs/core';import { UnitAction } from '@univerjs/protocol';import { getSheetCommandTarget, RangeProtectionCache, RangeProtectionRuleModel, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission } from '@univerjs/sheets';@@ -30,7 +30,6 @@ type ICellPermission = Record<UnitAction, boolean> & { ruleId?: string; ranges?:export const SHEET_PERMISSION_PASTE_PLUGIN = 'SHEET_PERMISSION_PASTE_PLUGIN';-@OnLifecycle(LifecycleStages.Steady, SheetPermissionInterceptorCanvasRenderController)export class SheetPermissionInterceptorCanvasRenderController extends RxDisposable implements IRenderModule {disposableCollection = new DisposableCollection();@@ -51,7 +50,6 @@ export class SheetPermissionInterceptorCanvasRenderController extends RxDisposabthis._initHeaderResizePermissionInterceptor();this._initRangeFillPermissionInterceptor();this._initRangeMovePermissionInterceptor();- // this._initFreezePermissionInterceptor();}private _initHeaderMovePermissionInterceptor() {diff --git a/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-clipboard.controller.ts b/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-clipboard.controller.tsindex b1da1efb9f..e5fc5b4fc0 100644--- a/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-clipboard.controller.ts+++ b/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-clipboard.controller.ts@@ -15,9 +15,9 @@*/import type { ICellDataForSheetInterceptor, IRange, Workbook } from '@univerjs/core';-import { Disposable, DisposableCollection, Inject, IUniverInstanceService, LifecycleStages, LocaleService, OnLifecycle, UniverInstanceType } from '@univerjs/core';-import { SheetsSelectionsService } from '@univerjs/sheets';+import { Disposable, DisposableCollection, Inject, IUniverInstanceService, LocaleService, UniverInstanceType } from '@univerjs/core';import { UnitAction } from '@univerjs/protocol';+import { SheetsSelectionsService } from '@univerjs/sheets';import { ISheetClipboardService } from '../../services/clipboard/clipboard.service';import { virtualizeDiscreteRanges } from '../utils/range-tools';import { SheetPermissionInterceptorBaseController } from './sheet-permission-interceptor-base.controller';@@ -25,7 +25,6 @@ import { SheetPermissionInterceptorBaseController } from './sheet-permission-inttype ICellPermission = Record<UnitAction, boolean> & { ruleId?: string; ranges?: IRange[] };export const SHEET_PERMISSION_PASTE_PLUGIN = 'SHEET_PERMISSION_PASTE_PLUGIN';-@OnLifecycle(LifecycleStages.Steady, SheetPermissionInterceptorClipboardController)export class SheetPermissionInterceptorClipboardController extends Disposable {disposableCollection = new DisposableCollection();diff --git a/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-formula-render.controller.ts b/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-formula-render.controller.tsindex d0cbc1d655..b4ecacb8d2 100644--- a/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-formula-render.controller.ts+++ b/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-formula-render.controller.ts@@ -16,25 +16,22 @@import type { Workbook } from '@univerjs/core';import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';-import { DisposableCollection, Inject, Injector, IPermissionService, IUniverInstanceService, LifecycleStages, OnLifecycle, RxDisposable } from '@univerjs/core';+import { DisposableCollection, Inject, IPermissionService, IUniverInstanceService, RxDisposable } from '@univerjs/core';import { NullValueObject } from '@univerjs/engine-formula';import { UnitAction } from '@univerjs/protocol';-import { getSheetCommandTarget, RangeProtectionCache, RangeProtectionRenderModel, WorksheetViewPermission } from '@univerjs/sheets';+import { getSheetCommandTarget, RangeProtectionCache, WorksheetViewPermission } from '@univerjs/sheets';import { StatusBarController } from '../status-bar.controller';export const SHEET_PERMISSION_PASTE_PLUGIN = 'SHEET_PERMISSION_PASTE_PLUGIN';-@OnLifecycle(LifecycleStages.Steady, SheetPermissionInterceptorFormulaRenderController)export class SheetPermissionInterceptorFormulaRenderController extends RxDisposable implements IRenderModule {disposableCollection = new DisposableCollection();constructor(private readonly _context: IRenderContext<Workbook>,- @Inject(Injector) private readonly _injector: Injector,@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,@IPermissionService private readonly _permissionService: IPermissionService,@Inject(StatusBarController) private readonly _statusBarController: StatusBarController,- @Inject(RangeProtectionRenderModel) private _rangeProtectionRenderModel: RangeProtectionRenderModel,@Inject(RangeProtectionCache) private _rangeProtectionCache: RangeProtectionCache) {super();diff --git a/packages/sheets-ui/src/controllers/permission/sheet-permission-render.controller.ts b/packages/sheets-ui/src/controllers/permission/sheet-permission-render.controller.tsindex 7b82b7dd19..7597913660 100644--- a/packages/sheets-ui/src/controllers/permission/sheet-permission-render.controller.ts+++ b/packages/sheets-ui/src/controllers/permission/sheet-permission-render.controller.ts@@ -14,19 +14,19 @@* limitations under the License.*/-import { Disposable, Inject, IPermissionService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';+import type { IRenderContext, IRenderModule, Spreadsheet } from '@univerjs/engine-render';import type { MenuConfig } from '@univerjs/ui';-import { ComponentManager } from '@univerjs/ui';+import { Disposable, Inject, IPermissionService, IUniverInstanceService } from '@univerjs/core';+import { IRenderManagerService } from '@univerjs/engine-render';import { CheckMarkSingle, DeleteSingle, LockSingle, ProtectSingle, WriteSingle } from '@univerjs/icons';import { RangeProtectionRuleModel, WorksheetProtectionRuleModel } from '@univerjs/sheets';-import type { IRenderContext, IRenderModule, Spreadsheet } from '@univerjs/engine-render';-import { IRenderManagerService } from '@univerjs/engine-render';+import { ComponentManager } from '@univerjs/ui';import { merge, throttleTime } from 'rxjs';import { permissionCheckIconKey, permissionDeleteIconKey, permissionEditIconKey, permissionLockIconKey, permissionMenuIconKey, UNIVER_SHEET_PERMISSION_DIALOG, UNIVER_SHEET_PERMISSION_PANEL, UNIVER_SHEET_PERMISSION_PANEL_FOOTER, UNIVER_SHEET_PERMISSION_USER_DIALOG } from '../../consts/permission';+import { SheetSkeletonManagerService } from '../../services/sheet-skeleton-manager.service';import { SheetPermissionDialog, SheetPermissionPanel, SheetPermissionPanelFooter, SheetPermissionUserDialog } from '../../views/permission';-import { UNIVER_SHEET_PERMISSION_ALERT_DIALOG } from '../../views/permission/error-msg-dialog/interface';import { AlertDialog } from '../../views/permission/error-msg-dialog';-import { SheetSkeletonManagerService } from '../../services/sheet-skeleton-manager.service';+import { UNIVER_SHEET_PERMISSION_ALERT_DIALOG } from '../../views/permission/error-msg-dialog/interface';import { RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY, RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY, RangeProtectionCanNotViewRenderExtension, RangeProtectionCanViewRenderExtension } from '../../views/permission/extensions/range-protection.render';import { worksheetProtectionKey, WorksheetProtectionRenderExtension } from '../../views/permission/extensions/worksheet-permission.render';@@ -132,21 +132,13 @@ export class WorksheetProtectionRenderController extends Disposable implements I}private _initRender() {- const register = (renderId: string) => {- const render = renderId && this._renderManagerService.getRenderById(renderId);- const spreadsheetRender = render && render.mainComponent as Spreadsheet;- if (spreadsheetRender) {- if (!spreadsheetRender.getExtensionByKey(worksheetProtectionKey)) {- spreadsheetRender.register(this._worksheetProtectionRenderExtension);- }+ const renderId = this._context.unitId;+ const render = renderId && this._renderManagerService.getRenderById(renderId);+ const spreadsheetRender = render && render.mainComponent as Spreadsheet;+ if (spreadsheetRender) {+ if (!spreadsheetRender.getExtensionByKey(worksheetProtectionKey)) {+ spreadsheetRender.register(this._worksheetProtectionRenderExtension);}- };- this.disposeWithMe(this._renderManagerService.currentRender$.subscribe((renderId) => {- renderId && register(renderId);- }));- const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)!;- if (workbook) {- register(workbook.getUnitId());}}diff --git a/packages/sheets-ui/src/controllers/render-controllers/skeleton.render-controller.ts b/packages/sheets-ui/src/controllers/render-controllers/skeleton.render-controller.tsindex 50da73fd7e..abbdeff9fa 100644--- a/packages/sheets-ui/src/controllers/render-controllers/skeleton.render-controller.ts+++ b/packages/sheets-ui/src/controllers/render-controllers/skeleton.render-controller.ts@@ -15,22 +15,17 @@*/import type { Workbook } from '@univerjs/core';-import { Disposable, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';-import type { IRenderContext } from '@univerjs/engine-render';+import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';+import { Disposable, Inject } from '@univerjs/core';import { SheetSkeletonManagerService } from '../../services/sheet-skeleton-manager.service';-@OnLifecycle(LifecycleStages.Ready, SheetSkeletonRenderController)-export class SheetSkeletonRenderController extends Disposable {+export class SheetSkeletonRenderController extends Disposable implements IRenderModule {constructor(private readonly _context: IRenderContext<Workbook>,@Inject(SheetSkeletonManagerService) private readonly _sheetSkeletonManagerService: SheetSkeletonManagerService) {super();- this._initRemoveSheet();- }-- private _initRemoveSheet() {this.disposeWithMe(this._context.unit.sheetDisposed$.subscribe((sheet) => {this._sheetSkeletonManagerService.disposeSkeleton({sheetId: sheet.getSheetId(),diff --git a/packages/sheets-ui/src/controllers/render-controllers/zoom.render-controller.ts b/packages/sheets-ui/src/controllers/render-controllers/zoom.render-controller.tsindex 33f5d8bdaf..7ca1bead4d 100644--- a/packages/sheets-ui/src/controllers/render-controllers/zoom.render-controller.ts+++ b/packages/sheets-ui/src/controllers/render-controllers/zoom.render-controller.ts@@ -14,9 +14,9 @@* limitations under the License.*/-import { Disposable, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, FOCUSING_SHEET, ICommandService, IContextService, Inject } from '@univerjs/core';import type { Workbook } from '@univerjs/core';import type { IRenderContext, IRenderModule, IWheelEvent } from '@univerjs/engine-render';+import { Disposable, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, FOCUSING_SHEET, ICommandService, IContextService, Inject, Optional } from '@univerjs/core';import { SetZoomRatioCommand } from '../../commands/commands/set-zoom-ratio.command';import { IEditorBridgeService } from '../../services/editor-bridge.service';import { SheetSkeletonManagerService } from '../../services/sheet-skeleton-manager.service';@@ -28,7 +28,7 @@ export class SheetsZoomRenderController extends Disposable implements IRenderMod@Inject(SheetSkeletonManagerService) private readonly _sheetSkeletonManagerService: SheetSkeletonManagerService,@ICommandService private readonly _commandService: ICommandService,@IContextService private readonly _contextService: IContextService,- @IEditorBridgeService private readonly _editorBridgeService: IEditorBridgeService+ @Optional(IEditorBridgeService) private readonly _editorBridgeService?: IEditorBridgeService) {super();@@ -57,9 +57,11 @@ export class SheetsZoomRenderController extends Disposable implements IRenderModreturn;}- const state = this._editorBridgeService.isVisible();- if ((state.unitId === this._context.unitId || state.unitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) && state.visible) {- return;+ if (this._editorBridgeService) {+ const state = this._editorBridgeService.isVisible();+ if ((state.unitId === this._context.unitId || state.unitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) && state.visible) {+ return;+ }}const deltaFactor = Math.abs(e.deltaX);diff --git a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts b/packages/sheets-ui/src/controllers/sheet-ui.controller.tsindex 6a11be131d..2500b5f064 100644--- a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts+++ b/packages/sheets-ui/src/controllers/sheet-ui.controller.ts@@ -15,7 +15,7 @@*/import type { IUniverSheetsUIConfig } from './config.schema';-import { connectInjector, Disposable, ICommandService, IConfigService, Inject, Injector, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';+import { connectInjector, Disposable, ICommandService, IConfigService, Inject, Injector, UniverInstanceType } from '@univerjs/core';import { DocSelectionRenderService } from '@univerjs/docs-ui';import { IRenderManagerService } from '@univerjs/engine-render';@@ -158,7 +158,6 @@ import {ZoomOutShortcutItem,} from './shortcuts/view.shortcut';-@OnLifecycle(LifecycleStages.Ready, SheetUIController)export class SheetUIController extends Disposable {constructor(@Inject(Injector) protected readonly _injector: Injector,diff --git a/packages/sheets-ui/src/controllers/status-bar.controller.ts b/packages/sheets-ui/src/controllers/status-bar.controller.tsindex 5e3170ea76..333155080b 100644--- a/packages/sheets-ui/src/controllers/status-bar.controller.ts+++ b/packages/sheets-ui/src/controllers/status-bar.controller.ts@@ -14,6 +14,12 @@* limitations under the License.*/+import type { ICellData, ICommandInfo, IRange, ISelectionCell, Nullable, Workbook, Worksheet } from '@univerjs/core';+import type { ArrayValueObject, ISheetData } from '@univerjs/engine-formula';+import type {+ ISelectionWithStyle,+} from '@univerjs/sheets';+import type { IStatusBarServiceStatus } from '../services/status-bar.service';import {CellValueType,createInterceptorKey,@@ -23,33 +29,23 @@ import {Inject,InterceptorManager,IUniverInstanceService,- LifecycleStages,ObjectMatrix,- OnLifecycle,RANGE_TYPE,splitIntoGrid,toDisposable,UniverInstanceType,} from '@univerjs/core';+import {- FormulaDataModel,FUNCTION_NAMES_MATH,FUNCTION_NAMES_STATISTICAL,- IFunctionService,} from '@univerjs/engine-formula';import {INumfmtService,SetRangeValuesMutation,SheetsSelectionsService,} from '@univerjs/sheets';-import type { ICellData, ICommandInfo, IRange, ISelectionCell, Nullable, Workbook, Worksheet } from '@univerjs/core';-import type { ArrayValueObject, ISheetData } from '@univerjs/engine-formula';--import type {- ISelectionWithStyle,-} from '@univerjs/sheets';import { IStatusBarService } from '../services/status-bar.service';-import type { IStatusBarServiceStatus } from '../services/status-bar.service';export const STATUS_BAR_PERMISSION_CORRECT = createInterceptorKey<ArrayValueObject[], ArrayValueObject[]>('statusBarPermissionCorrect');@@ -115,19 +111,14 @@ function calculateValues(valueSet: CalculateValueSet) {];}-@OnLifecycle(LifecycleStages.Ready, StatusBarController)export class StatusBarController extends Disposable {- private _calculateTimeout: number | NodeJS.Timeout = -1;-public interceptor = new InterceptorManager({ STATUS_BAR_PERMISSION_CORRECT });constructor(@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,@Inject(SheetsSelectionsService) private readonly _selectionManagerService: SheetsSelectionsService,- @IFunctionService private readonly _functionService: IFunctionService,@IStatusBarService private readonly _statusBarService: IStatusBarService,@ICommandService private readonly _commandService: ICommandService,- @Inject(FormulaDataModel) private readonly _formulaDataModel: FormulaDataModel,@Inject(INumfmtService) private _numfmtService: INumfmtService) {super();diff --git a/packages/sheets-ui/src/mobile-sheets-ui-plugin.ts b/packages/sheets-ui/src/mobile-sheets-ui-plugin.tsindex a23828157c..4dad681b6a 100644--- a/packages/sheets-ui/src/mobile-sheets-ui-plugin.ts+++ b/packages/sheets-ui/src/mobile-sheets-ui-plugin.ts@@ -15,60 +15,60 @@*/import type { Dependency, Workbook } from '@univerjs/core';+import type { IUniverSheetsUIConfig } from './controllers/config.schema';import { DependentOn, Inject, Injector, IUniverInstanceService, Plugin, UniverInstanceType } from '@univerjs/core';-import { filter } from 'rxjs/operators';import { IRenderManagerService } from '@univerjs/engine-render';import { UniverSheetsPlugin } from '@univerjs/sheets';import { UniverMobileUIPlugin } from '@univerjs/ui';+import { filter } from 'rxjs/operators';import { ActiveWorksheetController } from './controllers/active-worksheet/active-worksheet.controller';import { AutoHeightController } from './controllers/auto-height.controller';+import { CellAlertRenderController } from './controllers/cell-alert.controller';+import { CellCustomRenderController } from './controllers/cell-custom-render.controller';import { SheetClipboardController } from './controllers/clipboard/clipboard.controller';+import { defaultPluginConfig } from './controllers/config.schema';+import { ForceStringAlertRenderController } from './controllers/force-string-alert-render.controller';+import { ForceStringRenderController } from './controllers/force-string-render.controller';+import { HoverRenderController } from './controllers/hover-render.controller';+import { MarkSelectionRenderController } from './controllers/mark-selection.controller';import { FormatPainterRenderController } from './controllers/render-controllers/format-painter.render-controller';import { HeaderFreezeRenderController } from './controllers/render-controllers/freeze.render-controller';import { HeaderMoveRenderController } from './controllers/render-controllers/header-move.render-controller';-import { MarkSelectionRenderController } from './controllers/mark-selection.controller';-import { SheetsRenderService } from './services/sheets-render.service';+import { MobileSheetsScrollRenderController } from './controllers/render-controllers/mobile/mobile-scroll.render-controller';+import { SheetsZoomRenderController } from './controllers/render-controllers/zoom.render-controller';import { StatusBarController } from './controllers/status-bar.controller';import { AutoFillService, IAutoFillService } from './services/auto-fill/auto-fill.service';+import { SheetCanvasPopManagerService } from './services/canvas-pop-manager.service';+import { CellAlertManagerService } from './services/cell-alert-manager.service';import { ISheetClipboardService, SheetClipboardService } from './services/clipboard/clipboard.service';import { FormatPainterService, IFormatPainterService } from './services/format-painter/format-painter.service';+import { HoverManagerService } from './services/hover-manager.service';import { IMarkSelectionService, MarkSelectionService } from './services/mark-selection/mark-selection.service';import { SheetScrollManagerService } from './services/scroll-manager.service';import { ISheetBarService, SheetBarService } from './services/sheet-bar/sheet-bar.service';import { SheetSkeletonManagerService } from './services/sheet-skeleton-manager.service';+import { SheetsRenderService } from './services/sheets-render.service';import { ShortcutExperienceService } from './services/shortcut-experience.service';import { IStatusBarService, StatusBarService } from './services/status-bar.service';-import { HoverRenderController } from './controllers/hover-render.controller';-import { HoverManagerService } from './services/hover-manager.service';-import { CellAlertManagerService } from './services/cell-alert-manager.service';-import { CellAlertRenderController } from './controllers/cell-alert.controller';-import { CellCustomRenderController } from './controllers/cell-custom-render.controller';-import { SheetCanvasPopManagerService } from './services/canvas-pop-manager.service';-import { ForceStringRenderController } from './controllers/force-string-render.controller';-import { ForceStringAlertRenderController } from './controllers/force-string-alert-render.controller';-import { SheetsZoomRenderController } from './controllers/render-controllers/zoom.render-controller';-import { MobileSheetsScrollRenderController } from './controllers/render-controllers/mobile/mobile-scroll.render-controller';// import { SheetContextMenuRenderController } from './controllers/render-controllers/contextmenu.render-controller';import { DragRenderController } from './controllers/drag-render.controller';-import { DragManagerService } from './services/drag-manager.service';-import { SheetPermissionInterceptorClipboardController } from './controllers/permission/sheet-permission-interceptor-clipboard.controller';-import { SheetPermissionInterceptorBaseController } from './controllers/permission/sheet-permission-interceptor-base.controller';+import { SheetUIMobileController } from './controllers/mobile/mobile-sheet-ui.controller';import { SheetPermissionInitController } from './controllers/permission/sheet-permission-init.controller';-import { SheetPermissionRenderController, SheetPermissionRenderManagerController, WorksheetProtectionRenderController } from './controllers/permission/sheet-permission-render.controller';+import { SheetPermissionInterceptorBaseController } from './controllers/permission/sheet-permission-interceptor-base.controller';import { SheetPermissionInterceptorCanvasRenderController } from './controllers/permission/sheet-permission-interceptor-canvas-render.controller';+import { SheetPermissionInterceptorClipboardController } from './controllers/permission/sheet-permission-interceptor-clipboard.controller';import { SheetPermissionInterceptorFormulaRenderController } from './controllers/permission/sheet-permission-interceptor-formula-render.controller';+import { SheetPermissionRenderController, SheetPermissionRenderManagerController, WorksheetProtectionRenderController } from './controllers/permission/sheet-permission-render.controller';+import { SheetContextMenuMobileRenderController } from './controllers/render-controllers/mobile/mobile-contextmenu.render-controller';+import { SheetRenderController } from './controllers/render-controllers/sheet.render-controller';+import { DragManagerService } from './services/drag-manager.service';import { SheetPermissionPanelModel } from './services/permission/sheet-permission-panel.model';import { SheetPermissionUserManagerService } from './services/permission/sheet-permission-user-list.service';import { SheetPrintInterceptorService } from './services/print-interceptor.service';-import { SheetUIMobileController } from './controllers/mobile/mobile-sheet-ui.controller';-import { SheetContextMenuMobileRenderController } from './controllers/render-controllers/mobile/mobile-contextmenu.render-controller';-import { SheetRenderController } from './controllers/render-controllers/sheet.render-controller';-import { MobileSheetsSelectionRenderService } from './services/selection/mobile-selection-render.service';-import { ISheetSelectionRenderService } from './services/selection/base-selection-render.service';import { SelectAllService } from './services/select-all/select-all.service';-import type { IUniverSheetsUIConfig } from './controllers/config.schema';-import { defaultPluginConfig } from './controllers/config.schema';+import { ISheetSelectionRenderService } from './services/selection/base-selection-render.service';+import { MobileSheetsSelectionRenderService } from './services/selection/mobile-selection-render.service';/*** @ignore@@ -127,6 +127,8 @@ export class UniverSheetsMobileUIPlugin extends Plugin {override onReady(): void {this._markSheetAsFocused();this._registerRenderBasics();++ this._injector.get(SheetUIMobileController);}override onRendered(): void {diff --git a/packages/sheets-ui/src/services/auto-fill/auto-fill.service.ts b/packages/sheets-ui/src/services/auto-fill/auto-fill.service.tsindex c977ab405c..63347d6c54 100644--- a/packages/sheets-ui/src/services/auto-fill/auto-fill.service.ts+++ b/packages/sheets-ui/src/services/auto-fill/auto-fill.service.ts@@ -15,6 +15,10 @@*/import type { IDisposable, IMutationInfo, IRange, Nullable, Workbook } from '@univerjs/core';+import type { RenderManagerService } from '@univerjs/engine-render';+import type { ISetRangeValuesMutationParams, ISetWorksheetRowAutoHeightMutationParams } from '@univerjs/sheets';+import type { Observable } from 'rxjs';+import type { IAutoFillLocation, IAutoFillRule, ISheetAutoFillHook } from './type';import { createIdentifier, Direction,Disposable,ICommandService,@@ -22,23 +26,18 @@ import { createIdentifier, Direction,Injector,IUndoRedoService,IUniverInstanceService,- LifecycleStages,ObjectMatrix,- OnLifecycle,RANGE_TYPE,Rectangle,toDisposable,UniverInstanceType,} from '@univerjs/core';-import type { ISetRangeValuesMutationParams, ISetWorksheetRowAutoHeightMutationParams } from '@univerjs/sheets';-import { SetRangeValuesMutation, SetSelectionsOperation, SetWorksheetRowAutoHeightMutation, SetWorksheetRowAutoHeightMutationFactory, SheetsSelectionsService } from '@univerjs/sheets';-import type { Observable } from 'rxjs';-import { BehaviorSubject } from 'rxjs';-import type { RenderManagerService } from '@univerjs/engine-render';import { IRenderManagerService } from '@univerjs/engine-render';-import { discreteRangeToRange } from '../../controllers/utils/range-tools';+import { SetRangeValuesMutation, SetSelectionsOperation, SetWorksheetRowAutoHeightMutation, SetWorksheetRowAutoHeightMutationFactory, SheetsSelectionsService } from '@univerjs/sheets';+import { BehaviorSubject } from 'rxjs';import { AFFECT_LAYOUT_STYLES } from '../../controllers/auto-height.controller';+import { discreteRangeToRange } from '../../controllers/utils/range-tools';import { SheetSkeletonManagerService } from '../sheet-skeleton-manager.service';import {chnNumberRule,@@ -50,7 +49,6 @@ import {numberRule,otherRule,} from './rules';-import type { IAutoFillLocation, IAutoFillRule, ISheetAutoFillHook } from './type';import { APPLY_TYPE, AutoFillHookType } from './type';export interface IAutoFillService {@@ -90,7 +88,6 @@ export interface IApplyMenuItem {disable: boolean;}-@OnLifecycle(LifecycleStages.Rendered, AutoFillService)export class AutoFillService extends Disposable implements IAutoFillService {private _rules: IAutoFillRule[] = [];private _hooks: ISheetAutoFillHook[] = [];diff --git a/packages/sheets-ui/src/services/permission/sheet-permission-panel.model.ts b/packages/sheets-ui/src/services/permission/sheet-permission-panel.model.tsindex 060f6fe96a..41bfe4fe1e 100644--- a/packages/sheets-ui/src/services/permission/sheet-permission-panel.model.ts+++ b/packages/sheets-ui/src/services/permission/sheet-permission-panel.model.ts@@ -15,9 +15,8 @@*/import type { IRange, Nullable } from '@univerjs/core';-import { LifecycleStages, OnLifecycle } from '@univerjs/core';-import { UnitObject } from '@univerjs/protocol';import type { IRangeProtectionRule, IWorksheetProtectionRule } from '@univerjs/sheets';+import { UnitObject } from '@univerjs/protocol';import { BehaviorSubject } from 'rxjs';const DEFAULT_RANGE_RULE: IRangeProtectionRule = {@@ -44,7 +43,6 @@ type IPermissionPanelBaseRule = IRangeProtectionRule | IWorksheetProtectionRule;export type IPermissionPanelRule = IPermissionPanelBaseRule & { viewStatus?: viewState; editStatus?: editState; ranges: IRange[] };-@OnLifecycle(LifecycleStages.Starting, SheetPermissionPanelModel)export class SheetPermissionPanelModel {private _rule: IPermissionPanelRule = DEFAULT_RANGE_RULE;private _rule$ = new BehaviorSubject(this._rule);diff --git a/packages/sheets-ui/src/services/sheets-render.service.ts b/packages/sheets-ui/src/services/sheets-render.service.tsindex bd14644f9a..6edf254f9c 100644--- a/packages/sheets-ui/src/services/sheets-render.service.ts+++ b/packages/sheets-ui/src/services/sheets-render.service.ts@@ -18,8 +18,6 @@ import type { IDisposable, Workbook } from '@univerjs/core';import {IContextService,IUniverInstanceService,- LifecycleStages,- OnLifecycle,RxDisposable,toDisposable,UniverInstanceType,@@ -30,7 +28,6 @@ import { distinctUntilChanged, takeUntil } from 'rxjs';/*** This controller is responsible for managing units of a specific kind to be rendered on the canvas.*/-@OnLifecycle(LifecycleStages.Ready, SheetsRenderService)export class SheetsRenderService extends RxDisposable {private _skeletonChangeMutations = new Set<string>();@@ -76,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));diff --git a/packages/sheets-ui/src/sheets-ui-plugin.ts b/packages/sheets-ui/src/sheets-ui-plugin.tsindex fccc9d9440..6304633042 100644--- a/packages/sheets-ui/src/sheets-ui-plugin.ts+++ b/packages/sheets-ui/src/sheets-ui-plugin.ts@@ -150,6 +150,8 @@ export class UniverSheetsUIPlugin extends Plugin {[SheetPermissionInitController],[SheetPermissionRenderManagerController],] as Dependency[], this._config.override).forEach((d) => this._injector.add(d));++ this._injector.get(SheetPermissionPanelModel);}override onReady(): void {@@ -158,12 +160,29 @@ export class UniverSheetsUIPlugin extends Plugin {}this._registerRenderBasics();++ this._injector.get(SheetUIController);+ this._injector.get(SheetsRenderService);+ this._injector.get(ActiveWorksheetController);+ this._injector.get(SheetPermissionInterceptorBaseController);}override onRendered(): void {this._registerRenderModules();+ this._injector.get(SheetPermissionInitController);this._injector.get(SheetPermissionRenderManagerController);+ this._injector.get(SheetClipboardController);+ this._injector.get(FormulaEditorController);+ this._injector.get(SheetsDefinedNameController);+ this._injector.get(StatusBarController);+ this._injector.get(AutoHeightController);+ }++ override onSteady(): void {+ this._injector.get(FormatPainterController);+ this._injector.get(AutoFillController);+ this._injector.get(SheetPermissionInterceptorClipboardController);}private _registerRenderBasics(): void {diff --git a/packages/sheets-zen-editor/src/controllers/zen-editor-ui.controller.ts b/packages/sheets-zen-editor/src/controllers/zen-editor-ui.controller.tsindex f2d4044459..61141efb66 100644--- a/packages/sheets-zen-editor/src/controllers/zen-editor-ui.controller.ts+++ b/packages/sheets-zen-editor/src/controllers/zen-editor-ui.controller.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, ICommandService } from '@univerjs/core';import { IMenuManagerService, IShortcutService, IZenZoneService } from '@univerjs/ui';import { CancelZenEditCommand, ConfirmZenEditCommand, OpenZenEditorCommand } from '../commands/commands/zen-editor.command';@@ -22,10 +22,8 @@ import { ZEN_EDITOR_COMPONENT, ZenEditor } from '../views/zen-editor';import { menuSchema } from './menu.schema';import { ZenEditorCancelShortcut, ZenEditorConfirmShortcut } from './shortcuts/zen-editor.shortcut';-@OnLifecycle(LifecycleStages.Rendered, ZenEditorUIController)export class ZenEditorUIController extends Disposable {constructor(- @Inject(Injector) private readonly _injector: Injector,@IZenZoneService private readonly _zenZoneService: IZenZoneService,@ICommandService private readonly _commandService: ICommandService,@IMenuManagerService private readonly _menuManagerService: IMenuManagerService,diff --git a/packages/sheets-zen-editor/src/controllers/zen-editor.controller.ts b/packages/sheets-zen-editor/src/controllers/zen-editor.controller.tsindex 9a8d0d16cf..f7cfe12e44 100644--- a/packages/sheets-zen-editor/src/controllers/zen-editor.controller.ts+++ b/packages/sheets-zen-editor/src/controllers/zen-editor.controller.ts@@ -19,8 +19,6 @@ import type { IDocObjectParam } from '@univerjs/docs-ui';import type { Viewport } from '@univerjs/engine-render';import {DOCS_ZEN_EDITOR_UNIT_ID_KEY,- LifecycleStages,- OnLifecycle,RxDisposable,} from '@univerjs/core';import { VIEWPORT_KEY as DOC_VIEWPORT_KEY, DocBackScrollRenderController } from '@univerjs/docs-ui';@@ -30,7 +28,6 @@ import { getEditorObject } from '@univerjs/sheets-ui';import { takeUntil } from 'rxjs';import { IZenEditorManagerService } from '../services/zen-editor.service';-@OnLifecycle(LifecycleStages.Steady, ZenEditorController)export class ZenEditorController extends RxDisposable {constructor(@IZenEditorManagerService private readonly _zenEditorManagerService: IZenEditorManagerService,diff --git a/packages/sheets-zen-editor/src/plugin.ts b/packages/sheets-zen-editor/src/plugin.tsindex a616da9513..eff01e7bf0 100644--- a/packages/sheets-zen-editor/src/plugin.ts+++ b/packages/sheets-zen-editor/src/plugin.ts@@ -53,4 +53,12 @@ export class UniverSheetsZenEditorPlugin extends Plugin {dependencies.forEach((dependency) => injector.add(dependency));}++ override onReady(): void {+ this._injector.get(ZenEditorUIController);+ }++ override onSteady(): void {+ this._injector.get(ZenEditorController);+ }}diff --git a/packages/sheets/src/commands/commands/__tests__/create-command-test-bed.ts b/packages/sheets/src/commands/commands/__tests__/create-command-test-bed.tsindex 18cb9e930a..56c0623024 100644--- a/packages/sheets/src/commands/commands/__tests__/create-command-test-bed.ts+++ b/packages/sheets/src/commands/commands/__tests__/create-command-test-bed.ts@@ -29,14 +29,14 @@ import {Univer,UniverInstanceType,} from '@univerjs/core';-import { WorkbookPermissionService } from '../../../services/permission/workbook-permission/workbook-permission.service';-import { WorksheetPermissionService } from '../../../services/permission/worksheet-permission/worksheet-permission.service';import enUS from '../../../locale/en-US';+import { RangeProtectionRuleModel } from '../../../model/range-protection-rule.model';import { BorderStyleManagerService } from '../../../services/border-style-manager.service';+import { WorkbookPermissionService } from '../../../services/permission/workbook-permission/workbook-permission.service';+import { WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '../../../services/permission/worksheet-permission';+import { WorksheetPermissionService } from '../../../services/permission/worksheet-permission/worksheet-permission.service';import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';import { SheetInterceptorService } from '../../../services/sheet-interceptor/sheet-interceptor.service';-import { WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '../../../services/permission/worksheet-permission';-import { RangeProtectionRuleModel } from '../../../model/range-protection-rule.model';const TEST_WORKBOOK_DATA_DEMO: IWorkbookData = {id: 'test',@@ -106,6 +106,10 @@ export function createCommandTestBed(workbookData?: IWorkbookData, dependencies?injector.add([SheetInterceptorService]);dependencies?.forEach((d) => injector.add(d));++ this._injector.get(SheetInterceptorService);+ this._injector.get(WorkbookPermissionService);+ this._injector.get(WorksheetPermissionService);}}diff --git a/packages/sheets/src/commands/commands/__tests__/set-range-values.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-range-values.command.spec.tsindex df96216d3c..3fc9b53e61 100644--- a/packages/sheets/src/commands/commands/__tests__/set-range-values.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-range-values.command.spec.ts@@ -14,6 +14,8 @@* limitations under the License.*/+import type { ICellData, IDocumentData, Injector, IStyleData, IWorkbookData, Nullable, Univer, Workbook } from '@univerjs/core';+import type { ISetRangeValuesCommandParams } from '../set-range-values.command';import {BooleanNumber,CellValueType,@@ -28,13 +30,10 @@ import {} from '@univerjs/core';import { DEFAULT_TEXT_FORMAT } from '@univerjs/engine-numfmt';import { afterEach, beforeEach, describe, expect, it } from 'vitest';--import type { ICellData, IDocumentData, Injector, IStyleData, IWorkbookData, Nullable, Univer, Workbook } from '@univerjs/core';import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';import { SetRangeValuesMutation } from '../../mutations/set-range-values.mutation';import { SetRangeValuesCommand } from '../set-range-values.command';import { createCommandTestBed } from './create-command-test-bed';-import type { ISetRangeValuesCommandParams } from '../set-range-values.command';const getTestWorkbookDataDemo = (): IWorkbookData => ({id: 'test',diff --git a/packages/sheets/src/controllers/basic-worksheet.controller.ts b/packages/sheets/src/controllers/basic-worksheet.controller.tsindex b5db318e43..f6d14a4b2e 100644--- a/packages/sheets/src/controllers/basic-worksheet.controller.ts+++ b/packages/sheets/src/controllers/basic-worksheet.controller.ts@@ -15,15 +15,18 @@*/import type { IDisposable, IMutation, IStyleData } from '@univerjs/core';-import { Disposable, ICommandService, IConfigService, LifecycleStages, OnLifecycle, Optional } from '@univerjs/core';+import { Disposable, ICommandService, IConfigService, Optional } from '@univerjs/core';import { DataSyncPrimaryController } from '@univerjs/rpc';+import { AddRangeProtectionCommand } from '../commands/commands/add-range-protection.command';import { ClearSelectionAllCommand } from '../commands/commands/clear-selection-all.command';import { ClearSelectionContentCommand } from '../commands/commands/clear-selection-content.command';import { ClearSelectionFormatCommand } from '../commands/commands/clear-selection-format.command';import { CopySheetCommand } from '../commands/commands/copy-worksheet.command';import { DeleteRangeMoveLeftCommand } from '../commands/commands/delete-range-move-left.command';import { DeleteRangeMoveUpCommand } from '../commands/commands/delete-range-move-up.command';+import { DeleteRangeProtectionCommand } from '../commands/commands/delete-range-protection.command';+import { InsertDefinedNameCommand } from '../commands/commands/insert-defined-name.command';import { InsertRangeMoveDownCommand } from '../commands/commands/insert-range-move-down.command';import { InsertRangeMoveRightCommand } from '../commands/commands/insert-range-move-right.command';import {@@ -37,9 +40,11 @@ import {import { InsertSheetCommand } from '../commands/commands/insert-sheet.command';import { MoveRangeCommand } from '../commands/commands/move-range.command';import { MoveColsCommand, MoveRowsCommand } from '../commands/commands/move-rows-cols.command';+import { RemoveDefinedNameCommand } from '../commands/commands/remove-defined-name.command';import { RemoveColCommand, RemoveRowCommand } from '../commands/commands/remove-row-col.command';import { RemoveSheetCommand } from '../commands/commands/remove-sheet.command';import { RemoveWorksheetMergeCommand } from '../commands/commands/remove-worksheet-merge.command';+import { ReorderRangeCommand } from '../commands/commands/reorder-range.command';import {SetBorderBasicCommand,SetBorderColorCommand,@@ -52,8 +57,10 @@ import {SetSelectedColsVisibleCommand,SetSpecificColsVisibleCommand,} from '../commands/commands/set-col-visible.command';+import { SetDefinedNameCommand } from '../commands/commands/set-defined-name.command';import { SetFrozenCommand } from '../commands/commands/set-frozen.command';import { SetFrozenCancelCommand } from '../commands/commands/set-frozen-cancel.command';+import { SetRangeProtectionCommand } from '../commands/commands/set-range-protection.command';import { SetRangeValuesCommand } from '../commands/commands/set-range-values.command';import {SetRowHiddenCommand,@@ -72,17 +79,25 @@ import {SetVerticalTextAlignCommand,} from '../commands/commands/set-style.command';import { SetTabColorCommand } from '../commands/commands/set-tab-color.command';+import { SetWorkbookNameCommand } from '../commands/commands/set-workbook-name.command';import { SetWorksheetActivateCommand } from '../commands/commands/set-worksheet-activate.command';import { DeltaColumnWidthCommand, SetColWidthCommand } from '../commands/commands/set-worksheet-col-width.command';import { SetWorksheetHideCommand } from '../commands/commands/set-worksheet-hide.command';import { SetWorksheetNameCommand } from '../commands/commands/set-worksheet-name.command';import { SetWorksheetOrderCommand } from '../commands/commands/set-worksheet-order.command';+import { SetWorksheetPermissionPointsCommand } from '../commands/commands/set-worksheet-permission-points.command';import {DeltaRowHeightCommand,SetRowHeightCommand,SetWorksheetRowIsAutoHeightCommand,} from '../commands/commands/set-worksheet-row-height.command';import { SetWorksheetShowCommand } from '../commands/commands/set-worksheet-show.command';+import { AddRangeProtectionMutation } from '../commands/mutations/add-range-protection.mutation';+import { AddWorksheetMergeMutation } from '../commands/mutations/add-worksheet-merge.mutation';+import { AddWorksheetProtectionMutation } from '../commands/mutations/add-worksheet-protection.mutation';+import { DeleteRangeProtectionMutation } from '../commands/mutations/delete-range-protection.mutation';+import { DeleteWorksheetProtectionMutation } from '../commands/mutations/delete-worksheet-protection.mutation';+import { EmptyMutation } from '../commands/mutations/empty.mutation';import { InsertColMutation, InsertRowMutation } from '../commands/mutations/insert-row-col.mutation';import { InsertSheetMutation } from '../commands/mutations/insert-sheet.mutation';import { MoveRangeMutation } from '../commands/mutations/move-range.mutation';@@ -91,47 +106,30 @@ import { RemoveNumfmtMutation, SetNumfmtMutation } from '../commands/mutations/nimport { RemoveColMutation, RemoveRowMutation } from '../commands/mutations/remove-row-col.mutation';import { RemoveSheetMutation } from '../commands/mutations/remove-sheet.mutation';import { RemoveWorksheetMergeMutation } from '../commands/mutations/remove-worksheet-merge.mutation';+import { ReorderRangeMutation } from '../commands/mutations/reorder-range.mutation';import { SetColHiddenMutation, SetColVisibleMutation } from '../commands/mutations/set-col-visible.mutation';import { SetFrozenMutation } from '../commands/mutations/set-frozen.mutation';+import { SetRangeProtectionMutation } from '../commands/mutations/set-range-protection.mutation';import { SetRangeValuesMutation } from '../commands/mutations/set-range-values.mutation';import { SetRowHiddenMutation, SetRowVisibleMutation } from '../commands/mutations/set-row-visible.mutation';import { SetTabColorMutation } from '../commands/mutations/set-tab-color.mutation';+import { SetWorkbookNameMutation } from '../commands/mutations/set-workbook-name.mutation';import { SetWorksheetColWidthMutation } from '../commands/mutations/set-worksheet-col-width.mutation';import { SetWorksheetHideMutation } from '../commands/mutations/set-worksheet-hide.mutation';import { SetWorksheetNameMutation } from '../commands/mutations/set-worksheet-name.mutation';import { SetWorksheetOrderMutation } from '../commands/mutations/set-worksheet-order.mutation';+import { SetWorksheetPermissionPointsMutation } from '../commands/mutations/set-worksheet-permission-points.mutation';+import { SetWorksheetProtectionMutation } from '../commands/mutations/set-worksheet-protection.mutation';import {SetWorksheetRowAutoHeightMutation,SetWorksheetRowHeightMutation,SetWorksheetRowIsAutoHeightMutation,} from '../commands/mutations/set-worksheet-row-height.mutation';+import { ScrollToCellOperation } from '../commands/operations/scroll-to-cell.operation';import { SetSelectionsOperation } from '../commands/operations/selection.operation';import { SetWorksheetActiveOperation } from '../commands/operations/set-worksheet-active.operation';-import { EmptyMutation } from '../commands/mutations/empty.mutation';-import { InsertDefinedNameCommand } from '../commands/commands/insert-defined-name.command';-import { RemoveDefinedNameCommand } from '../commands/commands/remove-defined-name.command';-import { SetDefinedNameCommand } from '../commands/commands/set-defined-name.command';-import { ScrollToCellOperation } from '../commands/operations/scroll-to-cell.operation';-import { SetWorkbookNameCommand } from '../commands/commands/set-workbook-name.command';-import { SetWorkbookNameMutation } from '../commands/mutations/set-workbook-name.mutation';-import { AddWorksheetProtectionMutation } from '../commands/mutations/add-worksheet-protection.mutation';-import { SetWorksheetProtectionMutation } from '../commands/mutations/set-worksheet-protection.mutation';-import { DeleteWorksheetProtectionMutation } from '../commands/mutations/delete-worksheet-protection.mutation';-import { SetWorksheetPermissionPointsMutation } from '../commands/mutations/set-worksheet-permission-points.mutation';-import { SetWorksheetPermissionPointsCommand } from '../commands/commands/set-worksheet-permission-points.command';--import { AddRangeProtectionCommand } from '../commands/commands/add-range-protection.command';-import { DeleteRangeProtectionCommand } from '../commands/commands/delete-range-protection.command';-import { SetRangeProtectionCommand } from '../commands/commands/set-range-protection.command';--import { AddRangeProtectionMutation } from '../commands/mutations/add-range-protection.mutation';-import { DeleteRangeProtectionMutation } from '../commands/mutations/delete-range-protection.mutation';-import { SetRangeProtectionMutation } from '../commands/mutations/set-range-protection.mutation';-import { AddWorksheetMergeMutation } from '../commands/mutations/add-worksheet-merge.mutation';-import { ReorderRangeCommand } from '../commands/commands/reorder-range.command';-import { ReorderRangeMutation } from '../commands/mutations/reorder-range.mutation';-import { MAX_CELL_PER_SHEET_DEFAULT, MAX_CELL_PER_SHEET_KEY } from './config/config';import { ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY } from './config';+import { MAX_CELL_PER_SHEET_DEFAULT, MAX_CELL_PER_SHEET_KEY } from './config/config';export interface IStyleTypeValue<T> {type: keyof IStyleData;@@ -141,7 +139,6 @@ export interface IStyleTypeValue<T> {/*** The controller to provide the most basic sheet CRUD methods to other modules of sheet modules.*/-@OnLifecycle(LifecycleStages.Starting, BasicWorksheetController)export class BasicWorksheetController extends Disposable implements IDisposable {// eslint-disable-next-line max-lines-per-functionconstructor(diff --git a/packages/sheets/src/controllers/calculate-result-apply.controller.ts b/packages/sheets/src/controllers/calculate-result-apply.controller.tsindex e261a4a657..5411e70797 100644--- a/packages/sheets/src/controllers/calculate-result-apply.controller.ts+++ b/packages/sheets/src/controllers/calculate-result-apply.controller.ts@@ -16,12 +16,11 @@import type { ICellData, ICommandInfo, IObjectMatrixPrimitiveType, Nullable } from '@univerjs/core';import type { ISetFormulaCalculationResultMutation } from '@univerjs/engine-formula';-import { Disposable, ICommandService, Inject, IUniverInstanceService, LifecycleStages, ObjectMatrix, OnLifecycle } from '@univerjs/core';+import { Disposable, ICommandService, Inject, IUniverInstanceService, ObjectMatrix } from '@univerjs/core';import { handleNumfmtInCell, SetFormulaCalculationResultMutation } from '@univerjs/engine-formula';import { SetRangeValuesMutation } from '../commands/mutations/set-range-values.mutation';-@OnLifecycle(LifecycleStages.Ready, CalculateResultApplyController)export class CalculateResultApplyController extends Disposable {constructor(@Inject(IUniverInstanceService) private _univerInstanceService: IUniverInstanceService,diff --git a/packages/sheets/src/controllers/defined-name-data.controller.ts b/packages/sheets/src/controllers/defined-name-data.controller.tsindex e94690a54a..59a9bbcd78 100644--- a/packages/sheets/src/controllers/defined-name-data.controller.ts+++ b/packages/sheets/src/controllers/defined-name-data.controller.ts@@ -14,19 +14,16 @@* limitations under the License.*/+import type { IDefinedNameMapItem } from '@univerjs/engine-formula';import {Disposable,IResourceManagerService,- LifecycleStages,- OnLifecycle,UniverInstanceType,} from '@univerjs/core';-import type { IDefinedNameMapItem } from '@univerjs/engine-formula';import { IDefinedNamesService } from '@univerjs/engine-formula';const SHEET_DEFINED_NAME_PLUGIN = 'SHEET_DEFINED_NAME_PLUGIN';-@OnLifecycle(LifecycleStages.Ready, DefinedNameDataController)export class DefinedNameDataController extends Disposable {constructor(@IDefinedNamesService private readonly _definedNamesService: IDefinedNamesService,diff --git a/packages/sheets/src/controllers/number-cell.controller.ts b/packages/sheets/src/controllers/number-cell.controller.tsindex 4a07ef8b90..dd98180d09 100644--- a/packages/sheets/src/controllers/number-cell.controller.ts+++ b/packages/sheets/src/controllers/number-cell.controller.ts@@ -14,12 +14,11 @@* limitations under the License.*/-import { CellValueType, Disposable, Inject, InterceptorEffectEnum, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { CellValueType, Disposable, Inject, InterceptorEffectEnum } from '@univerjs/core';import { stripErrorMargin } from '@univerjs/engine-formula';import { INTERCEPTOR_POINT } from '../services/sheet-interceptor/interceptor-const';import { SheetInterceptorService } from '../services/sheet-interceptor/sheet-interceptor.service';-@OnLifecycle(LifecycleStages.Ready, NumberCellDisplayController)export class NumberCellDisplayController extends Disposable {constructor(@Inject(SheetInterceptorService) private _sheetInterceptorService: SheetInterceptorService) {diff --git a/packages/sheets/src/model/range-protection-render.model.ts b/packages/sheets/src/model/range-protection-render.model.tsindex 371693c9bc..e6c810c0e6 100644--- a/packages/sheets/src/model/range-protection-render.model.ts+++ b/packages/sheets/src/model/range-protection-render.model.ts@@ -14,20 +14,17 @@* limitations under the License.*/-import { Inject, IPermissionService, LifecycleStages, LRUMap, OnLifecycle, Range } from '@univerjs/core';-import { UnitObject } from '@univerjs/protocol';-import { filter, map } from 'rxjs/operators';import type { IRange } from '@univerjs/core';-import type { UnitAction } from '@univerjs/protocol';+import type { getDefaultRangePermission, IRangePermissionPoint } from '../services/permission/range-permission/util';+import { Inject, IPermissionService, LRUMap, Range } from '@univerjs/core';+import { UnitObject } from '@univerjs/protocol';+import { filter, map } from 'rxjs/operators';import { getAllRangePermissionPoint } from '../services/permission/range-permission/util';import { RangeProtectionRuleModel } from './range-protection-rule.model';-import type { getDefaultRangePermission, IRangePermissionPoint } from '../services/permission/range-permission/util';-export type ICellPermission = Record<UnitAction, boolean> & { ruleId?: string; ranges?: IRange[] };-@OnLifecycle(LifecycleStages.Ready, RangeProtectionRenderModel)export class RangeProtectionRenderModel {private _cache = new LRUMap<string, ICellPermission[]>(10000);constructor(diff --git a/packages/sheets/src/model/range-protection-rule.model.ts b/packages/sheets/src/model/range-protection-rule.model.tsindex a75f4a95d9..d9302d3fdb 100644--- a/packages/sheets/src/model/range-protection-rule.model.ts+++ b/packages/sheets/src/model/range-protection-rule.model.ts@@ -16,7 +16,7 @@import type { IRange } from '@univerjs/core';import type { UnitObject } from '@univerjs/protocol';-import { LifecycleStages, OnLifecycle, Tools } from '@univerjs/core';+import { Tools } from '@univerjs/core';import { BehaviorSubject, Subject } from 'rxjs';@@ -43,7 +43,6 @@ export interface IRuleChange {}type IRuleChangeType = 'add' | 'set' | 'delete';-@OnLifecycle(LifecycleStages.Starting, RangeProtectionRuleModel)export class RangeProtectionRuleModel {/**diff --git a/packages/sheets/src/services/numfmt/type.ts b/packages/sheets/src/services/numfmt/type.tsindex 39719b696b..cfb0fbd447 100644--- a/packages/sheets/src/services/numfmt/type.ts+++ b/packages/sheets/src/services/numfmt/type.ts@@ -15,7 +15,7 @@*/import type { ICellData, IRange, Nullable, ObjectMatrix } from '@univerjs/core';-import { createIdentifier, LifecycleStages, runOnLifecycle } from '@univerjs/core';+import { createIdentifier } from '@univerjs/core';// eslint-disable-next-line ts/consistent-type-definitionsexport type INumfmtItem = {@@ -46,6 +46,7 @@ export interface INumfmtItemWithCache {pattern: string;}+export const INumfmtService = createIdentifier<INumfmtService>('INumfmtService');export interface INumfmtService {getValue(unitId: string,@@ -61,6 +62,3 @@ export interface INumfmtService {): void;deleteValues(unitId: string, subUnitId: string, values: IRange[]): void;}--export const INumfmtService = createIdentifier<INumfmtService>('INumfmtService');-runOnLifecycle(LifecycleStages.Ready, INumfmtService);diff --git a/packages/sheets/src/services/permission/range-permission/range-protection.ref-range.ts b/packages/sheets/src/services/permission/range-permission/range-protection.ref-range.tsindex 424ba85b56..c05a15d047 100644--- a/packages/sheets/src/services/permission/range-permission/range-protection.ref-range.ts+++ b/packages/sheets/src/services/permission/range-permission/range-protection.ref-range.ts@@ -30,7 +30,7 @@ import type { IDeleteSelectionProtectionMutationParams } from '../../../commandsimport type { ISetRangeProtectionMutationParams } from '../../../commands/mutations/set-range-protection.mutation';import type { IRangeProtectionRule } from '../../../model/range-protection-rule.model';import type { EffectRefRangeParams } from '../../../services/ref-range/type';-import { Disposable, DisposableCollection, ICommandService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, Rectangle, Tools, UniverInstanceType } from '@univerjs/core';+import { Disposable, DisposableCollection, ICommandService, Inject, IUniverInstanceService, Rectangle, Tools, UniverInstanceType } from '@univerjs/core';import { InsertColCommand, InsertRowCommand } from '../../../commands/commands/insert-row-col.command';import {MoveColsCommand,@@ -59,7 +59,6 @@ const mutationIdArrByMove = [MoveRowsMutation.id, MoveColsMutation.id];type IMoveRowsOrColsMutationParams = IMoveRowsMutationParams;-@OnLifecycle(LifecycleStages.Ready, RangeProtectionRefRangeService)export class RangeProtectionRefRangeService extends Disposable {disposableCollection = new DisposableCollection();diff --git a/packages/sheets/src/services/permission/workbook-permission/workbook-permission.service.ts b/packages/sheets/src/services/permission/workbook-permission/workbook-permission.service.tsindex c84d22b304..f42b569d18 100644--- a/packages/sheets/src/services/permission/workbook-permission/workbook-permission.service.ts+++ b/packages/sheets/src/services/permission/workbook-permission/workbook-permission.service.ts@@ -14,15 +14,13 @@* limitations under the License.*/-import { Disposable, Inject, IPermissionService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';import type { Workbook } from '@univerjs/core';--import { getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel } from '../worksheet-permission/utils';+import { Disposable, Inject, IPermissionService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { RangeProtectionRuleModel } from '../../../model/range-protection-rule.model';import { RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint } from '../permission-point';+import { getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel } from '../worksheet-permission/utils';import { getAllWorkbookPermissionPoint } from './util';-@OnLifecycle(LifecycleStages.Starting, WorkbookPermissionService)export class WorkbookPermissionService extends Disposable {constructor(@Inject(IPermissionService) private _permissionService: IPermissionService,diff --git a/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission-point.model.ts b/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission-point.model.tsindex eea0481d4b..cee54ab442 100644--- a/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission-point.model.ts+++ b/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission-point.model.ts@@ -14,11 +14,9 @@* limitations under the License.*/-import { Subject } from 'rxjs';-import { LifecycleStages, OnLifecycle } from '@univerjs/core';import type { IObjectPointModel, IPointRuleModel, IWorksheetProtectionPointRule } from '../type';+import { Subject } from 'rxjs';-@OnLifecycle(LifecycleStages.Starting, WorksheetProtectionPointModel)export class WorksheetProtectionPointModel {private _model: IPointRuleModel = new Map();diff --git a/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission-rule.model.ts b/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission-rule.model.tsindex d097e0e2ce..af794a00ac 100644--- a/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission-rule.model.ts+++ b/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission-rule.model.ts@@ -14,13 +14,11 @@* limitations under the License.*/-import { BehaviorSubject, Subject } from 'rxjs';-import { LifecycleStages, OnLifecycle } from '@univerjs/core';import type { IModel, IObjectModel, IWorksheetProtectionRule } from '../type';+import { BehaviorSubject, Subject } from 'rxjs';type IRuleChangeType = 'add' | 'set' | 'delete';-@OnLifecycle(LifecycleStages.Starting, WorksheetProtectionRuleModel)export class WorksheetProtectionRuleModel {/***diff --git a/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission.service.ts b/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission.service.tsindex c0a42b38b0..32619b1cbf 100644--- a/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission.service.ts+++ b/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission.service.ts@@ -15,21 +15,20 @@*/import type { Workbook, Worksheet } from '@univerjs/core';-import { Inject, Injector, IPermissionService, IResourceManagerService, IUniverInstanceService, LifecycleStages, OnLifecycle, RxDisposable, UniverInstanceType } from '@univerjs/core';-import { takeUntil } from 'rxjs/operators';+import type { IObjectModel, IObjectPointModel } from '../type';+import { Inject, Injector, IPermissionService, IResourceManagerService, IUniverInstanceService, RxDisposable, UniverInstanceType } from '@univerjs/core';import { UniverType } from '@univerjs/protocol';-import type { IObjectModel, IObjectPointModel } from '../type';-import { RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint } from '../permission-point';+import { takeUntil } from 'rxjs/operators';import { RangeProtectionRuleModel } from '../../../model/range-protection-rule.model';-import { WorksheetProtectionRuleModel } from './worksheet-permission-rule.model';+import { RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint } from '../permission-point';import { getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel } from './utils';import { WorksheetProtectionPointModel } from './worksheet-permission-point.model';+import { WorksheetProtectionRuleModel } from './worksheet-permission-rule.model';export const RULE_MODEL_PLUGIN_NAME = 'SHEET_WORKSHEET_PROTECTION_PLUGIN';export const POINT_MODEL_PLUGIN_NAME = 'SHEET_WORKSHEET_PROTECTION_POINT_PLUGIN';-@OnLifecycle(LifecycleStages.Starting, WorksheetPermissionService)export class WorksheetPermissionService extends RxDisposable {constructor(@Inject(IPermissionService) private _permissionService: IPermissionService,diff --git a/packages/sheets/src/services/ref-range/ref-range.service.ts b/packages/sheets/src/services/ref-range/ref-range.service.tsindex 0caeb5499d..a9715a182a 100644--- a/packages/sheets/src/services/ref-range/ref-range.service.ts+++ b/packages/sheets/src/services/ref-range/ref-range.service.ts@@ -15,6 +15,10 @@*/import type { IDisposable, IMutationInfo, IRange, Nullable, Workbook } from '@univerjs/core';+import type { IMoveRangeMutationParams } from '../../commands/mutations/move-range.mutation';++import type { ISheetCommandSharedParams } from '../../commands/utils/interface';+import type { EffectRefRangeParams } from './type';import {CommandType,createInterceptorKey,@@ -23,21 +27,15 @@ import {Inject,InterceptorManager,IUniverInstanceService,- LifecycleStages,- OnLifecycle,RANGE_TYPE,Rectangle,toDisposable,UniverInstanceType,} from '@univerjs/core';--import { SheetsSelectionsService } from '../selections/selection-manager.service';-import { SheetInterceptorService } from '../sheet-interceptor/sheet-interceptor.service';-import type { ISheetCommandSharedParams } from '../../commands/utils/interface';-import type { IMoveRangeMutationParams } from '../../commands/mutations/move-range.mutation';import { MoveRangeMutation } from '../../commands/mutations/move-range.mutation';import { RemoveSheetMutation } from '../../commands/mutations/remove-sheet.mutation';-import type { EffectRefRangeParams } from './type';+import { SheetsSelectionsService } from '../selections/selection-manager.service';+import { SheetInterceptorService } from '../sheet-interceptor/sheet-interceptor.service';import { EffectRefRangId } from './type';import { adjustRangeOnMutation, getEffectedRangesOnMutation } from './util';@@ -108,7 +106,6 @@ class WatchRange extends Disposable {/*** Collect side effects caused by ref range change*/-@OnLifecycle(LifecycleStages.Ready, RefRangeService)export class RefRangeService extends Disposable {interceptor = new InterceptorManager({ MERGE_REDO, MERGE_UNDO });diff --git a/packages/sheets/src/sheets-plugin.ts b/packages/sheets/src/sheets-plugin.tsindex 0a320426ca..360863a0aa 100644--- a/packages/sheets/src/sheets-plugin.ts+++ b/packages/sheets/src/sheets-plugin.ts@@ -116,6 +116,25 @@ export class UniverSheetsPlugin extends Plugin {}override onStarting(): void {+ this._injector.get(BasicWorksheetController);this._injector.get(MergeCellController);+ this._injector.get(WorkbookPermissionService);+ this._injector.get(WorksheetPermissionService);+ }++ override onRendered(): void {+ this._injector.get(INumfmtService);+ }++ override onReady(): void {+ if (!this._config?.notExecuteFormula) {+ this._injector.get(CalculateResultApplyController);+ }++ this._injector.get(DefinedNameDataController);+ this._injector.get(NumberCellDisplayController);+ this._injector.get(RangeProtectionRenderModel);+ this._injector.get(RangeProtectionRefRangeService);+ this._injector.get(RefRangeService);}}diff --git a/packages/slides-ui/src/controllers/canvas-view.ts b/packages/slides-ui/src/controllers/canvas-view.tsindex 3cb89c936f..7047fff6aa 100644--- a/packages/slides-ui/src/controllers/canvas-view.ts+++ b/packages/slides-ui/src/controllers/canvas-view.ts@@ -15,20 +15,18 @@*/import type { IPageElement, Nullable } from '@univerjs/core';-import { LifecycleStages, OnLifecycle, RxDisposable } from '@univerjs/core';import type {BaseObject,IRenderModule,} from '@univerjs/engine-render';+import type { PageID } from '../type';+import { RxDisposable } from '@univerjs/core';+import {IRenderManagerService,} from '@univerjs/engine-render';--import type { PageID } from '../type';import { SlideRenderController } from './slide.render-controller';-// export const ICanvasView = createIdentifier<IUniverInstanceService>('univer.slide.canvas-view');-@OnLifecycle(LifecycleStages.Ready, CanvasView)export class CanvasView extends RxDisposable implements IRenderModule {constructor(// this controller needs by commands. root injector. Tdiff --git a/packages/slides-ui/src/controllers/popup-menu.controller.ts b/packages/slides-ui/src/controllers/popup-menu.controller.tsindex 37ad96eba1..b7bb93faa1 100644--- a/packages/slides-ui/src/controllers/popup-menu.controller.ts+++ b/packages/slides-ui/src/controllers/popup-menu.controller.ts@@ -15,19 +15,17 @@*/import type { IDisposable, Nullable, SlideDataModel } from '@univerjs/core';-import { FOCUSING_COMMON_DRAWINGS, ICommandService, IContextService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, RxDisposable, toDisposable, UniverInstanceType } from '@univerjs/core';import type { BaseObject, ObjectType, Scene } from '@univerjs/engine-render';+import { FOCUSING_COMMON_DRAWINGS, ICommandService, IContextService, Inject, IUniverInstanceService, RxDisposable, toDisposable, UniverInstanceType } from '@univerjs/core';import { IRenderManagerService } from '@univerjs/engine-render';import { ISidebarService } from '@univerjs/ui';--import { SlideCanvasPopMangerService } from '../services/slide-popup-manager.service';-import { COMPONENT_SLIDE_IMAGE_POPUP_MENU } from '../components/image-popup-menu/component-name';import { DeleteSlideElementOperation } from '../commands/operations/delete-element.operation';import { ToggleSlideEditSidebarOperation } from '../commands/operations/insert-shape.operation';import { UpdateSlideElementOperation } from '../commands/operations/update-element.operation';+import { COMPONENT_SLIDE_IMAGE_POPUP_MENU } from '../components/image-popup-menu/component-name';+import { SlideCanvasPopMangerService } from '../services/slide-popup-manager.service';import { CanvasView } from './canvas-view';-@OnLifecycle(LifecycleStages.Steady, SlidePopupMenuController)export class SlidePopupMenuController extends RxDisposable {private _initImagePopupMenu = new Set<string>();@@ -46,16 +44,9 @@ export class SlidePopupMenuController extends RxDisposable {}private _init(): void {- // this._univerInstanceService.getCurrentTypeOfUnit$<Workbook>(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._create(workbook));- // this._univerInstanceService.getTypeOfUnitDisposed$<Workbook>(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._dispose(workbook));this._univerInstanceService.getAllUnitsForType<SlideDataModel>(UniverInstanceType.UNIVER_SLIDE).forEach((slide) => this._create(slide));}- private _dispose(workbook: SlideDataModel) {- // const unitId = workbook.getUnitId();- // this._renderManagerService.removeRender(unitId);- }-private _create(slide: Nullable<SlideDataModel>) {if (!slide) {return;diff --git a/packages/slides-ui/src/controllers/slide-ui.controller.ts b/packages/slides-ui/src/controllers/slide-ui.controller.tsindex 912ea4caea..7700a153b5 100644--- a/packages/slides-ui/src/controllers/slide-ui.controller.ts+++ b/packages/slides-ui/src/controllers/slide-ui.controller.ts@@ -14,33 +14,32 @@* limitations under the License.*/-import { connectInjector, Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { connectInjector, Disposable, ICommandService, Inject, Injector } from '@univerjs/core';import { AddImageSingle, GraphSingle, TextSingle } from '@univerjs/icons';import { BuiltInUIPart, ComponentManager, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui';import { ActivateSlidePageOperation } from '../commands/operations/activate.operation';+import { AppendSlideOperation } from '../commands/operations/append-slide.operation';import { DeleteSlideElementOperation } from '../commands/operations/delete-element.operation';import { InsertSlideFloatImageCommand } from '../commands/operations/insert-image.operation';import { InsertSlideShapeRectangleCommand, InsertSlideShapeRectangleOperation, ToggleSlideEditSidebarOperation } from '../commands/operations/insert-shape.operation';import { SlideAddTextCommand, SlideAddTextOperation } from '../commands/operations/insert-text.operation';import { SetSlidePageThumbOperation } from '../commands/operations/set-thumb.operation';import { SetTextEditArrowOperation } from '../commands/operations/text-edit.operation';-import { SlideImagePopupMenu } from '../components/image-popup-menu/ImagePopupMenu';+import { UpdateSlideElementOperation } from '../commands/operations/update-element.operation';import { COMPONENT_SLIDE_IMAGE_POPUP_MENU } from '../components/image-popup-menu/component-name';-import { SlideEditorContainer } from '../views/editor-container';-import { SlideSideBar } from '../components/slide-bar/SlideBar';+import { SlideImagePopupMenu } from '../components/image-popup-menu/ImagePopupMenu';import Sidebar, { COMPONENT_SLIDE_SIDEBAR } from '../components/sidebar/Sidebar';-import { AppendSlideOperation } from '../commands/operations/append-slide.operation';-import { UpdateSlideElementOperation } from '../commands/operations/update-element.operation';+import { SlideSideBar } from '../components/slide-bar/SlideBar';+import { SlideEditorContainer } from '../views/editor-container';import { IMAGE_UPLOAD_ICON } from './image.menu';+import { menuSchema } from './menu.schema';import { GRAPH_SINGLE_ICON } from './shape.menu';import { EditorDeleteLeftShortcut, generateArrowSelectionShortCutItem } from './shortcuts/editor.shortcuts';import { TEXT_ICON_ID } from './text.menu';-import { menuSchema } from './menu.schema';/*** This controller registers UI parts of slide workbench to the base-ui workbench.*/-@OnLifecycle(LifecycleStages.Ready, SlidesUIController)export class SlidesUIController extends Disposable {constructor(@Inject(Injector) protected readonly _injector: Injector,diff --git a/packages/slides-ui/src/services/slide-render.service.ts b/packages/slides-ui/src/services/slide-render.service.tsindex 2105f94333..78bdd1aec1 100644--- a/packages/slides-ui/src/services/slide-render.service.ts+++ b/packages/slides-ui/src/services/slide-render.service.ts@@ -18,8 +18,6 @@ import type { SlideDataModel, Workbook } from '@univerjs/core';import {IContextService,IUniverInstanceService,- LifecycleStages,- OnLifecycle,RxDisposable,UniverInstanceType,} from '@univerjs/core';@@ -29,7 +27,6 @@ import { takeUntil } from 'rxjs';/*** This controller is responsible for managing units of a specific kind to be rendered on the canvas.*/-@OnLifecycle(LifecycleStages.Ready, SlideRenderService)export class SlideRenderService extends RxDisposable {// private _skeletonChangeMutations = new Set<string>();diff --git a/packages/slides-ui/src/slides-ui-plugin.ts b/packages/slides-ui/src/slides-ui-plugin.tsindex a795d6984d..6d1ad6ccb1 100644--- a/packages/slides-ui/src/slides-ui-plugin.ts+++ b/packages/slides-ui/src/slides-ui-plugin.ts@@ -15,22 +15,20 @@*/import type { Dependency, SlideDataModel } from '@univerjs/core';+import type { IUniverSlidesUIConfig } from './controllers/config.schema';import { IConfigService, Inject, Injector, IUniverInstanceService, mergeOverrideWithDependencies, Plugin, UniverInstanceType } from '@univerjs/core';-import { IRenderManagerService } from '@univerjs/engine-render';--import { SlidesUIController } from './controllers/slide-ui.controller';-import { SlideRenderController } from './controllers/slide.render-controller';+import { CanvasView } from './controllers/canvas-view';+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { SlidePopupMenuController } from './controllers/popup-menu.controller';-import { SlideCanvasPopMangerService } from './services/slide-popup-manager.service';-import { ISlideEditorBridgeService, SlideEditorBridgeService } from './services/slide-editor-bridge.service';+import { SlideRenderController } from './controllers/slide.render-controller';+import { SlideEditingRenderController } from './controllers/slide-editing.render-controller';import { SlideEditorBridgeRenderController } from './controllers/slide-editor-bridge.render-controller';+import { SlidesUIController } from './controllers/slide-ui.controller';+import { ISlideEditorBridgeService, SlideEditorBridgeService } from './services/slide-editor-bridge.service';import { ISlideEditorManagerService, SlideEditorManagerService } from './services/slide-editor-manager.service';-import { SlideEditingRenderController } from './controllers/slide-editing.render-controller';+import { SlideCanvasPopMangerService } from './services/slide-popup-manager.service';import { SlideRenderService } from './services/slide-render.service';-import { CanvasView } from './controllers/canvas-view';-import type { IUniverSlidesUIConfig } from './controllers/config.schema';-import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';export const SLIDE_UI_PLUGIN_NAME = 'SLIDE_UI';@@ -74,6 +72,7 @@ export class UniverSlidesUIPlugin extends Plugin {] as Dependency[]).forEach((m) => {this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SLIDE, m));});+mergeOverrideWithDependencies([[CanvasView],// cannot register in _renderManagerService now.@@ -89,7 +88,9 @@ export class UniverSlidesUIPlugin extends Plugin {] as Dependency[], this._config.override).forEach((m) => {this._injector.add(m);});+this._injector.get(CanvasView);+ this._injector.get(SlideRenderService);}override onRendered(): void {@@ -98,13 +99,18 @@ export class UniverSlidesUIPlugin extends Plugin {// need TextSelectionRenderService which init by EditorContainer[SlideEditorBridgeRenderController],[SlideEditingRenderController],-] as Dependency[]).forEach((m) => {// find all renderMap and register module to each item in renderMapthis.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SLIDE, m));});this._markSlideAsFocused();++ this._injector.get(SlidesUIController);+ }++ override onSteady(): void {+ this._injector.get(SlidePopupMenuController);}private _markSlideAsFocused() {diff --git a/packages/thread-comment/src/controllers/tc-resource.controller.ts b/packages/thread-comment/src/controllers/tc-resource.controller.tsindex 470d4a872c..bf8204e5ec 100644--- a/packages/thread-comment/src/controllers/tc-resource.controller.ts+++ b/packages/thread-comment/src/controllers/tc-resource.controller.ts@@ -14,16 +14,15 @@* limitations under the License.*/-import { Disposable, Inject, IResourceManagerService, LifecycleStages, OnLifecycle } from '@univerjs/core';+import type { IThreadComment } from '../types/interfaces/i-thread-comment';+import { Disposable, Inject, IResourceManagerService } from '@univerjs/core';import { UniverType } from '@univerjs/protocol';import { ThreadCommentModel } from '../models/thread-comment.model';-import { TC_PLUGIN_NAME } from '../types/const';-import type { IThreadComment } from '../types/interfaces/i-thread-comment';import { IThreadCommentDataSourceService } from '../services/tc-datasource.service';+import { TC_PLUGIN_NAME } from '../types/const';export type UnitThreadCommentJSON = Record<string, IThreadComment[]>;-@OnLifecycle(LifecycleStages.Starting, ThreadCommentResourceController)export class ThreadCommentResourceController extends Disposable {constructor(@IResourceManagerService private readonly _resourceManagerService: IResourceManagerService,diff --git a/packages/thread-comment/src/plugin.ts b/packages/thread-comment/src/plugin.tsindex 1be7104d4c..8952d65522 100644--- a/packages/thread-comment/src/plugin.ts+++ b/packages/thread-comment/src/plugin.ts@@ -15,15 +15,15 @@*/import type { Dependency } from '@univerjs/core';+import type { IUniverThreadCommentConfig } from './controllers/config.schema';import { ICommandService, IConfigService, Inject, Injector, mergeOverrideWithDependencies, Plugin, UniverInstanceType } from '@univerjs/core';-import { ThreadCommentModel } from './models/thread-comment.model';-import { ThreadCommentResourceController } from './controllers/tc-resource.controller';-import { TC_PLUGIN_NAME } from './types/const';-import { AddCommentMutation, DeleteCommentMutation, ResolveCommentMutation, UpdateCommentMutation, UpdateCommentRefMutation } from './commands/mutations/comment.mutation';import { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, ResolveCommentCommand, UpdateCommentCommand } from './commands/commands/comment.command';-import { IThreadCommentDataSourceService, ThreadCommentDataSourceService } from './services/tc-datasource.service';-import type { IUniverThreadCommentConfig } from './controllers/config.schema';+import { AddCommentMutation, DeleteCommentMutation, ResolveCommentMutation, UpdateCommentMutation, UpdateCommentRefMutation } from './commands/mutations/comment.mutation';import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';+import { ThreadCommentResourceController } from './controllers/tc-resource.controller';+import { ThreadCommentModel } from './models/thread-comment.model';+import { IThreadCommentDataSourceService, ThreadCommentDataSourceService } from './services/tc-datasource.service';+import { TC_PLUGIN_NAME } from './types/const';export class UniverThreadCommentPlugin extends Plugin {static override pluginName = TC_PLUGIN_NAME;@@ -68,5 +68,7 @@ export class UniverThreadCommentPlugin extends Plugin {].forEach((command) => {this._commandService.registerCommand(command);});++ this._injector.get(ThreadCommentResourceController);}}diff --git a/packages/ui/src/controllers/error/error.controller.ts b/packages/ui/src/controllers/error/error.controller.tsindex 12b628e84e..3c745ec48d 100644--- a/packages/ui/src/controllers/error/error.controller.ts+++ b/packages/ui/src/controllers/error/error.controller.ts@@ -14,12 +14,11 @@* limitations under the License.*/-import { Disposable, ErrorService, Inject, LifecycleStages, OnLifecycle, toDisposable } from '@univerjs/core';+import { Disposable, ErrorService, Inject } from '@univerjs/core';import { MessageType } from '@univerjs/design';import { IMessageService } from '../../services/message/message.service';-@OnLifecycle(LifecycleStages.Starting, ErrorController)export class ErrorController extends Disposable {constructor(@Inject(ErrorService) private readonly _errorService: ErrorService,@@ -27,15 +26,11 @@ export class ErrorController extends Disposable {) {super();- this.disposeWithMe(- toDisposable(- this._errorService.error$.subscribe((error) => {- this._messageService.show({- content: error.errorKey,- type: MessageType.Error,- });- })- )- );+ this.disposeWithMe(this._errorService.error$.subscribe((error) => {+ this._messageService.show({+ content: error.errorKey,+ type: MessageType.Error,+ });+ }));}}diff --git a/packages/ui/src/controllers/shared-shortcut.controller.ts b/packages/ui/src/controllers/shared-shortcut.controller.tsindex 2c19c49570..043f8041f4 100644--- a/packages/ui/src/controllers/shared-shortcut.controller.ts+++ b/packages/ui/src/controllers/shared-shortcut.controller.ts@@ -15,13 +15,13 @@*/import type { IContextService } from '@univerjs/core';-import { Disposable, FOCUSING_UNIVER_EDITOR, ICommandService, LifecycleStages, OnLifecycle, RedoCommand, UndoCommand } from '@univerjs/core';+import type { IShortcutItem } from '../services/shortcut/shortcut.service';+import { Disposable, FOCUSING_UNIVER_EDITOR, ICommandService, RedoCommand, UndoCommand } from '@univerjs/core';+import { SetEditorResizeOperation } from '../commands/operations/editor/set-editor-resize.operation';import { CopyCommand, CutCommand, PasteCommand } from '../services/clipboard/clipboard.command';import { KeyCode, MetaKeys } from '../services/shortcut/keycode';-import type { IShortcutItem } from '../services/shortcut/shortcut.service';import { IShortcutService } from '../services/shortcut/shortcut.service';-import { SetEditorResizeOperation } from '../commands/operations/editor/set-editor-resize.operation';// Not that the clipboard shortcut items would only be invoked when the browser fully supports clipboard API.// If not, the corresponding shortcut would not be triggered and we will perform clipboard operations@@ -87,7 +87,6 @@ export const RedoShortcutItem: IShortcutItem = {/*** Define shared UI behavior across Univer business. Including undo / redo and clipboard operations.*/-@OnLifecycle(LifecycleStages.Ready, SharedController)export class SharedController extends Disposable {constructor(@IShortcutService private readonly _shortcutService: IShortcutService,diff --git a/packages/ui/src/controllers/shortcut-display/shortcut-panel.controller.ts b/packages/ui/src/controllers/shortcut-display/shortcut-panel.controller.tsindex cae861c491..b8ce3c7579 100644--- a/packages/ui/src/controllers/shortcut-display/shortcut-panel.controller.ts+++ b/packages/ui/src/controllers/shortcut-display/shortcut-panel.controller.ts@@ -14,18 +14,17 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';-+import type { IShortcutItem } from '../../services/shortcut/shortcut.service';+import { Disposable, ICommandService, Inject, Injector } from '@univerjs/core';import {ShortcutPanelComponentName,ToggleShortcutPanelOperation,} from '../../commands/operations/toggle-shortcut-panel.operation';import { ComponentManager } from '../../common/component-manager';-import { ShortcutPanel } from '../../views/components/shortcut-panel/ShortcutPanel';-import type { IShortcutItem } from '../../services/shortcut/shortcut.service';-import { IShortcutService } from '../../services/shortcut/shortcut.service';-import { KeyCode, MetaKeys } from '../../services/shortcut/keycode';import { IMenuManagerService } from '../../services/menu/menu-manager.service';+import { KeyCode, MetaKeys } from '../../services/shortcut/keycode';+import { IShortcutService } from '../../services/shortcut/shortcut.service';+import { ShortcutPanel } from '../../views/components/shortcut-panel/ShortcutPanel';const ToggleShortcutPanelShortcut: IShortcutItem = {id: ToggleShortcutPanelOperation.id,@@ -37,7 +36,6 @@ const ToggleShortcutPanelShortcut: IShortcutItem = {/*** This controller add a side panel to the application to display the shortcuts.*/-@OnLifecycle(LifecycleStages.Steady, ShortcutPanelController)export class ShortcutPanelController extends Disposable {constructor(@Inject(Injector) injector: Injector,diff --git a/packages/ui/src/controllers/ui/ui-desktop.controller.tsx b/packages/ui/src/controllers/ui/ui-desktop.controller.tsxindex f7aaa6caf9..6dda7128b9 100644--- a/packages/ui/src/controllers/ui/ui-desktop.controller.tsx+++ b/packages/ui/src/controllers/ui/ui-desktop.controller.tsx@@ -14,13 +14,16 @@* limitations under the License.*/-import { connectInjector, Disposable, Inject, Injector, isInternalEditorID, IUniverInstanceService, LifecycleService, LifecycleStages, OnLifecycle, 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 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';@@ -28,15 +31,13 @@ import { FloatDom } from '../../views/components/dom/FloatDom';import { CanvasPopup } from '../../views/components/popup/CanvasPopup';import { DesktopWorkbench } from '../../views/workbench/Workbench';import { menuSchema } from '../menus/menu.schema';-import type { IUniverUIConfig } from '../config.schema';-import type { IWorkbenchOptions } from './ui.controller';const STEADY_TIMEOUT = 3000;-@OnLifecycle(LifecycleStages.Ready, DesktopUIController)export class DesktopUIController extends Disposable {private _steadyTimeout: NodeJS.Timeout;private _renderTimeout: NodeJS.Timeout;+constructor(private readonly _config: IUniverUIConfig,@IRenderManagerService private readonly _renderManagerService: IRenderManagerService,@@ -51,8 +52,7 @@ export class DesktopUIController extends Disposable {this._initBuiltinComponents();this._initMenus();-- Promise.resolve().then(() => this._bootstrapWorkbench());+ this._bootstrapWorkbench();}private _initMenus(): void {@@ -61,7 +61,6 @@ export class DesktopUIController extends Disposable {private _bootstrapWorkbench(): void {this.disposeWithMe(this._instanceSrv.unitDisposed$.subscribe((_unit: UnitModel) => {- clearTimeout(this._renderTimeout);clearTimeout(this._steadyTimeout);}));@@ -82,19 +81,21 @@ export class DesktopUIController extends Disposable {}});- 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);- }-- this._lifecycleService.stage = LifecycleStages.Rendered;- this._steadyTimeout = setTimeout(() => {- this._lifecycleService.stage = LifecycleStages.Steady;- }, STEADY_TIMEOUT);- }, 300);+ 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);+ }++ this._lifecycleService.stage = LifecycleStages.Rendered;+ this._steadyTimeout = setTimeout(() => {+ this._lifecycleService.stage = LifecycleStages.Steady;+ }, STEADY_TIMEOUT);+ }, 300);+ }));}));}diff --git a/packages/ui/src/controllers/ui/ui.controller.ts b/packages/ui/src/controllers/ui/ui.controller.tsindex 6a8ca4c9d6..276aea2357 100644--- a/packages/ui/src/controllers/ui/ui.controller.ts+++ b/packages/ui/src/controllers/ui/ui.controller.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { createIdentifier, LifecycleStages, runOnLifecycle } from '@univerjs/core';+import { createIdentifier } from '@univerjs/core';export interface IWorkbenchOptions {container?: string | HTMLElement;@@ -27,4 +27,3 @@ export interface IWorkbenchOptions {export interface IUIController {}export const IUIController = createIdentifier<IUIController>('univer.ui.ui-controller');-runOnLifecycle(LifecycleStages.Ready, IUIController);diff --git a/packages/ui/src/mobile-ui-plugin.ts b/packages/ui/src/mobile-ui-plugin.tsindex 61b8ba53c5..0c0fc1f49c 100644--- a/packages/ui/src/mobile-ui-plugin.ts+++ b/packages/ui/src/mobile-ui-plugin.ts@@ -14,9 +14,10 @@* limitations under the License.*/+import type { Dependency } from '@univerjs/core';+import type { IUniverUIConfig } from './controllers/config.schema';import { DependentOn, ILocalStorageService, Inject, Injector, mergeOverrideWithDependencies, Plugin } from '@univerjs/core';import { UniverRenderEnginePlugin } from '@univerjs/engine-render';-import type { Dependency } from '@univerjs/core';import { ComponentManager } from './common/component-manager';import { ZIndexManager } from './common/z-index-manager';import { ErrorController } from './controllers/error/error.controller';@@ -51,7 +52,6 @@ import { DesktopSidebarService } from './services/sidebar/desktop-sidebar.servicimport { ISidebarService } from './services/sidebar/sidebar.service';import { DesktopZenZoneService } from './services/zen-zone/desktop-zen-zone.service';import { IZenZoneService } from './services/zen-zone/zen-zone.service';-import type { IUniverUIConfig } from './controllers/config.schema';export const UNIVER_MOBILE_UI_PLUGIN_NAME = 'UNIVER_MOBILE_UI_PLUGIN';@@ -109,5 +109,8 @@ export class UniverMobileUIPlugin extends Plugin {], this._config.override);dependencies.forEach((dependency) => this._injector.add(dependency));++ this._injector.get(IUIController);+ this._injector.get(ErrorController);}}diff --git a/packages/ui/src/services/confirm/confirm.service.ts b/packages/ui/src/services/confirm/confirm.service.tsindex ce0173f535..d1236bea8e 100644--- a/packages/ui/src/services/confirm/confirm.service.ts+++ b/packages/ui/src/services/confirm/confirm.service.ts@@ -15,14 +15,12 @@*/import type { IDisposable } from '@univerjs/core';-import { createIdentifier, LifecycleStages, runOnLifecycle } from '@univerjs/core';import type { Subject } from 'rxjs';-import type { IConfirmPartMethodOptions } from '../../views/components/confirm-part/interface';-export const IConfirmService = createIdentifier<IConfirmService>('univer.confirm-service');+import { createIdentifier } from '@univerjs/core';-runOnLifecycle(LifecycleStages.Rendered, IConfirmService);+export const IConfirmService = createIdentifier<IConfirmService>('univer.confirm-service');export interface IConfirmService {readonly confirmOptions$: Subject<IConfirmPartMethodOptions[]>;diff --git a/packages/ui/src/services/layout/layout.service.ts b/packages/ui/src/services/layout/layout.service.tsindex 0ec1c64290..88de2c34c5 100644--- a/packages/ui/src/services/layout/layout.service.ts+++ b/packages/ui/src/services/layout/layout.service.ts@@ -14,9 +14,9 @@* limitations under the License.*/-import { createIdentifier, Disposable, DocumentDataModel, FOCUSING_UNIVER_EDITOR, IContextService, IUniverInstanceService, LifecycleStages, OnLifecycle, remove, SlideDataModel, toDisposable, UniverInstanceType, Workbook } from '@univerjs/core';-import { fromEvent } from 'rxjs';import type { ContextService, IDisposable, Nullable } from '@univerjs/core';+import { createIdentifier, Disposable, DocumentDataModel, FOCUSING_UNIVER_EDITOR, IContextService, IUniverInstanceService, remove, SlideDataModel, toDisposable, UniverInstanceType, Workbook } from '@univerjs/core';+import { fromEvent } from 'rxjs';type FocusHandlerFn = (unitId: string) => void;@@ -58,7 +58,6 @@ export const ILayoutService = createIdentifier<ILayoutService>('ui.layout-servic* This service is responsible for storing layout information of the current* Univer application instance.*/-@OnLifecycle(LifecycleStages.Ready, ILayoutService)export class DesktopLayoutService extends Disposable implements ILayoutService {private _rootContainerElement: Nullable<HTMLElement> = null;private _isFocused = false;diff --git a/packages/ui/src/ui-plugin.ts b/packages/ui/src/ui-plugin.tsindex 98f17736d2..7bde95ecd6 100644--- a/packages/ui/src/ui-plugin.ts+++ b/packages/ui/src/ui-plugin.ts@@ -14,10 +14,11 @@* limitations under the License.*/-import { DependentOn, IConfigService, IContextService, ILocalStorageService, Inject, Injector, mergeOverrideWithDependencies, Plugin } from '@univerjs/core';-import { UniverRenderEnginePlugin } from '@univerjs/engine-render';import type { Dependency } from '@univerjs/core';+import type { IUniverUIConfig } from './controllers/config.schema';+import { DependentOn, IConfigService, IContextService, ILocalStorageService, Inject, Injector, mergeOverrideWithDependencies, Plugin } from '@univerjs/core';+import { UniverRenderEnginePlugin } from '@univerjs/engine-render';import { ComponentManager } from './common/component-manager';import { ZIndexManager } from './common/z-index-manager';import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';@@ -56,7 +57,6 @@ import { DesktopSidebarService } from './services/sidebar/desktop-sidebar.servicimport { ISidebarService } from './services/sidebar/sidebar.service';import { DesktopZenZoneService } from './services/zen-zone/desktop-zen-zone.service';import { IZenZoneService } from './services/zen-zone/zen-zone.service';-import type { IUniverUIConfig } from './controllers/config.schema';export const UNIVER_UI_PLUGIN_NAME = 'UNIVER_UI_PLUGIN';@@ -92,7 +92,6 @@ export class UniverUIPlugin extends Plugin {const dependencies: Dependency[] = mergeOverrideWithDependencies([[ComponentManager],[ZIndexManager],-[ShortcutPanelService],[IUIPartsService, { useClass: UIPartsService }],[ILayoutService, { useClass: DesktopLayoutService }],@@ -118,12 +117,22 @@ export class UniverUIPlugin extends Plugin {[IUIController, {useFactory: (injector: Injector) => injector.createInstance(DesktopUIController, this._config),deps: [Injector],- },- ],+ }],[SharedController],[ErrorController],[ShortcutPanelController],], this._config.override);dependencies.forEach((dependency) => this._injector.add(dependency));++ this._injector.get(IUIController);+ this._injector.get(ErrorController);+ }++ override onReady(): void {+ this._injector.get(SharedController);+ }++ override onSteady(): void {+ this._injector.get(ShortcutPanelController);}}diff --git a/packages/uniscript/src/controllers/uniscript.controller.ts b/packages/uniscript/src/controllers/uniscript.controller.tsindex ef99154988..68eff132e2 100644--- a/packages/uniscript/src/controllers/uniscript.controller.ts+++ b/packages/uniscript/src/controllers/uniscript.controller.ts@@ -14,14 +14,13 @@* limitations under the License.*/-import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Disposable, ICommandService, Inject } from '@univerjs/core';import { ComponentManager, IMenuManagerService } from '@univerjs/ui';import { ScriptPanelComponentName, ToggleScriptPanelOperation } from '../commands/operations/panel.operation';import { ScriptEditorPanel } from '../views/components/ScriptEditorPanel';import { menuSchema } from './menu.schema';-@OnLifecycle(LifecycleStages.Steady, UniscriptController)export class UniscriptController extends Disposable {constructor(@IMenuManagerService private readonly _menuManagerService: IMenuManagerService,diff --git a/packages/uniscript/src/plugin.ts b/packages/uniscript/src/plugin.tsindex 0816d477c4..3093eb0a78 100644--- a/packages/uniscript/src/plugin.ts+++ b/packages/uniscript/src/plugin.ts@@ -14,15 +14,14 @@* limitations under the License.*/-import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core';import type { Dependency } from '@univerjs/core';-+import type { IUniverUniscriptConfig } from './controllers/config.schema';+import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core';+import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';import { UniscriptController } from './controllers/uniscript.controller';import { ScriptEditorService } from './services/script-editor.service';import { IUniscriptExecutionService, UniscriptExecutionService } from './services/script-execution.service';import { ScriptPanelService } from './services/script-panel.service';-import type { IUniverUniscriptConfig } from './controllers/config.schema';-import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';const PLUGIN_NAME = 'UNIVER_UNISCRIPT_PLUGIN';@@ -57,6 +56,10 @@ export class UniverUniscriptPlugin extends Plugin {this.registerExecution();}+ override onSteady(): void {+ this._injector.get(UniscriptController);+ }+/*** Allows being overridden, replacing with a new UniscriptExecutionService.*/