From 59f455e4618f3cb175061924de9225e0245fbd6a Mon Sep 17 00:00:00 2001 From: Dushusir <1414556676@qq.com> Date: Thu, 21 Nov 2024 20:12:54 +0800 Subject: [PATCH] fix(formula): init trigger calculation controller on rendered --- .../uni-formula-ui/src/uni-formula-ui.plugin.ts | 2 -- packages/sheets-formula/src/sheets-formula.plugin.ts | 9 ++++++++- 2 files changed, 8 insertions(+), 3 deletions(-) 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.ts index 32f9bd618b20..e0d86948ceb7 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 @@ -16,7 +16,6 @@ import type { Dependency } from '@univerjs/core'; import { DependentOn, Inject, Injector, Plugin, touchDependencies, UniverInstanceType } from '@univerjs/core'; -import { TriggerCalculationController } from '@univerjs/sheets-formula'; import { IUniFormulaService, UniverDocUniFormulaPlugin } from '@univerjs/uni-formula'; import { DOC_FORMULA_UI_PLUGIN_NAME } from './const'; @@ -53,7 +52,6 @@ export class UniverDocUniFormulaUIPlugin extends Plugin { override onReady(): void { touchDependencies(this._injector, [ [IUniFormulaService], - [TriggerCalculationController], ]); } diff --git a/packages/sheets-formula/src/sheets-formula.plugin.ts b/packages/sheets-formula/src/sheets-formula.plugin.ts index f6d2e7b52e95..a13f46c5a288 100644 --- a/packages/sheets-formula/src/sheets-formula.plugin.ts +++ b/packages/sheets-formula/src/sheets-formula.plugin.ts @@ -125,7 +125,7 @@ export class UniverSheetsFormulaPlugin extends Plugin { [UpdateDefinedNameController], ]); - // The nodejs environment needs to be initialized, otherwise it has been initialized in FormulaUIController + // There is no rendering in the nodejs environment, so initialize it here if (isNodeEnv()) { touchDependencies(this._injector, [ [TriggerCalculationController], @@ -137,5 +137,12 @@ export class UniverSheetsFormulaPlugin extends Plugin { touchDependencies(this._injector, [ [DefinedNameController], ]); + + // Wait for rendering to complete before initializing formula calculation + if (!isNodeEnv()) { + touchDependencies(this._injector, [ + [TriggerCalculationController], + ]); + } } }