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
chore: add multi units playground (#4666)
Wenzhao Hu3f5b60c5c981
diff --git a/examples/esbuild.config.ts b/examples/esbuild.config.tsindex 35052805a4..941d826fa6 100644--- a/examples/esbuild.config.ts+++ b/examples/esbuild.config.ts@@ -202,6 +202,9 @@ const entryPoints = [// sheets-multi'./src/sheets-multi/main.tsx',+ // sheets-multi-units+ './src/sheets-multi-units/main.ts',+// sheets-uniscript'./src/sheets-uniscript/main.ts',diff --git a/examples/src/main.tsx b/examples/src/main.tsxindex a7ef0f2105..2e4a5a13c9 100644--- a/examples/src/main.tsx+++ b/examples/src/main.tsx@@ -49,6 +49,9 @@ function Examples() {}, {title: '🗂️ Sheets Multi Instance',href: './sheets-multi/',+ }, {+ title: '🏡 Sheets Multi Units',+ href: './sheets-multi-units/',}, {title: '📄 Sheets Uniscript',href: './sheets-uniscript/',diff --git a/examples/src/sheets-multi-units/lazy.ts b/examples/src/sheets-multi-units/lazy.tsnew file mode 100644index 0000000000..88bdbc0fac--- /dev/null+++ b/examples/src/sheets-multi-units/lazy.ts@@ -0,0 +1,30 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * 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 { Plugin, PluginCtor } from '@univerjs/core';+import { UniverSheetsConditionalFormattingUIPlugin } from '@univerjs/sheets-conditional-formatting-ui';+import { UniverSheetsDataValidationUIPlugin } from '@univerjs/sheets-data-validation-ui';+import { UniverSheetsDrawingUIPlugin } from '@univerjs/sheets-drawing-ui';+import { UniverSheetsFilterUIPlugin } from '@univerjs/sheets-filter-ui';++export default function getLazyPlugins(): Array<[PluginCtor<Plugin>] | [PluginCtor<Plugin>, unknown]> {+ return [+ [UniverSheetsDataValidationUIPlugin],+ [UniverSheetsConditionalFormattingUIPlugin],+ [UniverSheetsFilterUIPlugin, { useRemoteFilterValuesGenerator: false }],+ [UniverSheetsDrawingUIPlugin],+ ];+}diff --git a/examples/src/sheets-multi-units/main.ts b/examples/src/sheets-multi-units/main.tsnew file mode 100644index 0000000000..c3cacc8a29--- /dev/null+++ b/examples/src/sheets-multi-units/main.ts@@ -0,0 +1,201 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * 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 { LocaleType, LogLevel, Univer, UserManagerService } from '@univerjs/core';+import { FUniver } from '@univerjs/core/facade';+import { defaultTheme } from '@univerjs/design';+import { UniverDocsPlugin } from '@univerjs/docs';+import { UniverDocsDrawingUIPlugin } from '@univerjs/docs-drawing-ui';+import { UniverDocsMentionUIPlugin } from '@univerjs/docs-mention-ui';+import { UniverDocsUIPlugin } from '@univerjs/docs-ui';+import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';+import { UniverRenderEnginePlugin } from '@univerjs/engine-render';+import { UniverRPCMainThreadPlugin } from '@univerjs/rpc';+import { UniverSheetsPlugin } from '@univerjs/sheets';+import { UniverSheetsConditionalFormattingPlugin } from '@univerjs/sheets-conditional-formatting';+import { UniverSheetsDataValidationPlugin } from '@univerjs/sheets-data-validation';+import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';+import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula';+import { UniverSheetsFormulaUIPlugin } from '@univerjs/sheets-formula-ui';+import { UniverSheetsHyperLinkPlugin } from '@univerjs/sheets-hyper-link';+import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt';+import { UniverSheetsNumfmtUIPlugin } from '@univerjs/sheets-numfmt-ui';+import { UniverSheetsSortPlugin } from '@univerjs/sheets-sort';+import { UniverSheetsBindingSourcePlugin } from '@univerjs/sheets-source-binding';+import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment';+import { UniverSheetsThreadCommentUIPlugin } from '@univerjs/sheets-thread-comment-ui';+import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui';+import { UniverSheetsZenEditorPlugin } from '@univerjs/sheets-zen-editor';+import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';+import { UniverUIPlugin } from '@univerjs/ui';++import { enUS, faIR, frFR, ruRU, viVN, zhCN, zhTW } from '../locales';++import '@univerjs/sheets/facade';+import '@univerjs/ui/facade';+import '@univerjs/docs-ui/facade';+import '@univerjs/sheets-ui/facade';+import '@univerjs/sheets-data-validation/facade';+import '@univerjs/engine-formula/facade';+import '@univerjs/sheets-filter/facade';+import '@univerjs/sheets-formula/facade';+import '@univerjs/sheets-numfmt/facade';+import '@univerjs/sheets-hyper-link-ui/facade';+import '@univerjs/sheets-thread-comment/facade';+import '@univerjs/sheets-conditional-formatting/facade';+import '@univerjs/sheets-find-replace/facade';+import '@univerjs/sheets-drawing-ui/facade';+import '@univerjs/sheets-zen-editor/facade';+import '@univerjs/sheets-source-binding/facade';+import '@univerjs/sheets-crosshair-highlight/facade';+import '@univerjs/sheets-sort/facade';++import '../global.css';+import './styles';++const LOAD_LAZY_PLUGINS_TIMEOUT = 100;+const LOAD_VERY_LAZY_PLUGINS_TIMEOUT = 1_000;++export const mockUser = {+ userID: 'Owner_qxVnhPbQ',+ name: 'Owner',+ avatar: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAInSURBVHgBtZU9TxtBEIbfWRzFSIdkikhBSqRQkJqkCKTCFkqVInSUSaT0wC8w/gXxD4gU2nRJkXQWhAZowDUUWKIwEgWWbEEB3mVmx3dn4DA2nB/ppNuPeWd29mMIPXDr+RxwtgRHeW6+guNPRxogqnL7Dwz9psJ27S4NShaeZTH3kwXy6I81dlRKcmRui88swdq9AcSFL7Buz1Vmlns64MiLsCjzwnIYHLH57tbfFbs7KRaXyEU8FVZofqccOfA5l7Q8LPIkGrwnb2RPNEXWFVMUF3L+kDCk0btDDAMzOm5YfAHDwp4tG74wnzAsiOYMnJ3GoDybA7IT98/jm5+JNnfiIzAS6LlqHQBN/i6b2t/cV1Hh6BfwYlHnHP4AXi5q/8kmMMpOs8+BixZw/Fd6xUEHEbnkgclvQP2fGp7uShRKnQ3G32rkjV1th8JhIGG7tR/JyjGteSOZELwGMmNqIIigRCLRh2OZIE6BjItdd7pCW6Uhm1zzkUtungSxwEUzNpQ+GQumtH1ej1MqgmNT6vwmhCq5yuwq56EYTbgeQUz3yvrpV1b4ok3nYJ+eYhgYmjRUqErx2EDq0Fr8FhG++iqVGqxlUJI/70Ar0UgJaWHj6hYVHJrfKssAHot1JfqwE9WVWzXZVd5z2Ws/4PnmtEjkXeKJDvxUecLbWOXH/DP6QQ4J72NS0adedp1aseBfXP8odlZFfPvBF7SN/8hky1TYuPOAXAEipMx15u5ToAAAAABJRU5ErkJggg==',+ anonymous: false,+ canBindAnonymous: false,+};++ // univer+const univer = new Univer({+ theme: defaultTheme,+ locale: LocaleType.ZH_CN,+ locales: {+ [LocaleType.ZH_CN]: zhCN,+ [LocaleType.EN_US]: enUS,+ [LocaleType.FR_FR]: frFR,+ [LocaleType.RU_RU]: ruRU,+ [LocaleType.ZH_TW]: zhTW,+ [LocaleType.VI_VN]: viVN,+ [LocaleType.FA_IR]: faIR,+ },+ logLevel: LogLevel.VERBOSE,+});++const worker = new Worker(new URL('./worker.js', import.meta.url), { type: 'module' });+univer.registerPlugin(UniverRPCMainThreadPlugin, { workerURL: worker });++univer.registerPlugin(UniverDocsPlugin);+univer.registerPlugin(UniverRenderEnginePlugin);+univer.registerPlugin(UniverUIPlugin, { container: 'app' });+univer.registerPlugin(UniverDocsUIPlugin);+univer.registerPlugin(UniverDocsDrawingUIPlugin);+univer.registerPlugin(UniverDocsMentionUIPlugin);++univer.registerPlugin(UniverSheetsPlugin, { notExecuteFormula: false });+univer.registerPlugin(UniverSheetsUIPlugin);+univer.registerPlugin(UniverSheetsNumfmtPlugin);+univer.registerPlugin(UniverSheetsZenEditorPlugin);+univer.registerPlugin(UniverFormulaEnginePlugin, { notExecuteFormula: false });+univer.registerPlugin(UniverSheetsNumfmtUIPlugin);+univer.registerPlugin(UniverSheetsFormulaPlugin, { notExecuteFormula: false });+univer.registerPlugin(UniverSheetsFormulaUIPlugin);+univer.registerPlugin(UniverSheetsDataValidationPlugin);+univer.registerPlugin(UniverSheetsConditionalFormattingPlugin);+univer.registerPlugin(UniverSheetsFilterPlugin);+univer.registerPlugin(UniverSheetsSortPlugin);+univer.registerPlugin(UniverSheetsHyperLinkPlugin);+univer.registerPlugin(UniverThreadCommentUIPlugin);+univer.registerPlugin(UniverSheetsThreadCommentPlugin);+univer.registerPlugin(UniverSheetsThreadCommentUIPlugin);+univer.registerPlugin(UniverSheetsBindingSourcePlugin);++const injector = univer.__getInjector();+const userManagerService = injector.get(UserManagerService);+userManagerService.setCurrentUser(mockUser);++ // create univer sheet instances++setTimeout(() => {+ import('./lazy').then((lazy) => {+ const plugins = lazy.default();+ plugins.forEach((p) => univer.registerPlugin(p[0], p[1]));+ });+}, LOAD_LAZY_PLUGINS_TIMEOUT);++setTimeout(() => {+ import('./very-lazy').then((lazy) => {+ const plugins = lazy.default();+ plugins.forEach((p) => univer.registerPlugin(p[0], p[1]));+ });+}, LOAD_VERY_LAZY_PLUGINS_TIMEOUT);++univer.onDispose(() => {+ worker.terminate();+ window.univer = undefined;+ window.univerAPI = undefined;+});++window.univer = univer;+const univerAPI = window.univerAPI = FUniver.newAPI(univer);++univerAPI.createWorkbook({+ id: 'workbook1',+ sheetOrder: ['sheet-01'],+ sheets: {+ 'sheet-01': {+ id: 'sheet-01',+ name: 'Sheet 01',+ rowCount: 10,+ columnCount: 5,+ cellData: { 0: { 0: { f: "=SUM('[workbook2]Sheet 01'!A1:B2)" } } },+ },+ },+});++univerAPI.createWorkbook(+ {+ id: 'workbook2',+ sheetOrder: ['sheet-01'],+ sheets: {+ 'sheet-01': {+ id: 'sheet-01',+ name: 'Sheet 01',+ rowCount: 10,+ columnCount: 5,+ cellData: {+ 0: {+ 0: { v: 1 },+ 1: { v: 2 },+ },+ 1: {+ 0: { v: 3 },+ 1: { v: 1 },+ },+ },+ },+ },+ },+ {+ makeCurrent: false,+ }+);++declare global {+ // eslint-disable-next-line ts/naming-convention+ interface Window {+ univer?: Univer;+ univerAPI?: ReturnType<typeof FUniver.newAPI>;+ }+}diff --git a/examples/src/sheets-multi-units/styles.ts b/examples/src/sheets-multi-units/styles.tsnew file mode 100644index 0000000000..49f3d222f9--- /dev/null+++ b/examples/src/sheets-multi-units/styles.ts@@ -0,0 +1,32 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * 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 '@univerjs/sheets-ui/lib/index.css';+import '@univerjs/ui/lib/index.css';+import '@univerjs/design/lib/index.css';+import '@univerjs/docs-ui/lib/index.css';+import '@univerjs/sheets-formula-ui/lib/index.css';+import '@univerjs/sheets-numfmt-ui/lib/index.css';+import '@univerjs/drawing-ui/lib/index.css';+import '@univerjs/docs-drawing-ui/lib/index.css';+import '@univerjs/sheets-data-validation-ui/lib/index.css';+import '@univerjs/sheets-filter-ui/lib/index.css';+import '@univerjs/find-replace/lib/index.css';+import '@univerjs/sheets-hyper-link-ui/lib/index.css';+import '@univerjs/sheets-sort-ui/lib/index.css';+import '@univerjs/thread-comment-ui/lib/index.css';+import '@univerjs/sheets-zen-editor/lib/index.css';+import '@univerjs/uniscript/lib/index.css';diff --git a/examples/src/sheets-multi-units/very-lazy.ts b/examples/src/sheets-multi-units/very-lazy.tsnew file mode 100644index 0000000000..acd4513022--- /dev/null+++ b/examples/src/sheets-multi-units/very-lazy.ts@@ -0,0 +1,63 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * 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 { Plugin, PluginCtor } from '@univerjs/core';+import { UniverActionRecorderPlugin } from '@univerjs/action-recorder';+import { UniverDebuggerPlugin } from '@univerjs/debugger';+import { UniverSheetsCrosshairHighlightPlugin } from '@univerjs/sheets-crosshair-highlight';+import { UniverSheetsFindReplacePlugin } from '@univerjs/sheets-find-replace';+import { UniverSheetsHyperLinkUIPlugin } from '@univerjs/sheets-hyper-link-ui';+import { UniverSheetsSortUIPlugin } from '@univerjs/sheets-sort-ui';+import { UniverUniscriptPlugin } from '@univerjs/uniscript';+import { UniverWatermarkPlugin } from '@univerjs/watermark';++/* eslint-disable-next-line node/prefer-global/process */+const IS_E2E: boolean = !!process.env.IS_E2E;++export default function getVeryLazyPlugins() {+ const plugins: Array<[PluginCtor<Plugin>] | [PluginCtor<Plugin>, unknown]> = [++ [UniverActionRecorderPlugin],+ [UniverSheetsHyperLinkUIPlugin],+ [UniverSheetsSortUIPlugin],+ [UniverSheetsCrosshairHighlightPlugin],+ [UniverSheetsFindReplacePlugin],+ [UniverWatermarkPlugin],+ ];++ if (!IS_E2E) {+ plugins.push([UniverDebuggerPlugin]);+ plugins.push([UniverUniscriptPlugin, {+ getWorkerUrl(_: string, label: string) {+ if (label === 'json') {+ return '/vs/language/json/json.worker.js';+ }+ if (label === 'css' || label === 'scss' || label === 'less') {+ return '/vs/language/css/css.worker.js';+ }+ if (label === 'html' || label === 'handlebars' || label === 'razor') {+ return '/vs/language/html/html.worker.js';+ }+ if (label === 'typescript' || label === 'javascript') {+ return '/vs/language/typescript/ts.worker.js';+ }+ return '/vs/editor/editor.worker.js';+ },+ }]);+ }++ return plugins;+}diff --git a/packages/engine-formula/src/services/calculate-formula.service.ts b/packages/engine-formula/src/services/calculate-formula.service.tsindex 23f5bf4a26..8acd129ff7 100644--- a/packages/engine-formula/src/services/calculate-formula.service.ts+++ b/packages/engine-formula/src/services/calculate-formula.service.ts@@ -26,6 +26,7 @@ import type {import type { IUniverEngineFormulaConfig } from '../controller/config.schema';import type { LexerNode } from '../engine/analysis/lexer-node';+import type { FunctionVariantType } from '../engine/reference-object/base-reference-object';import type { IAllRuntimeData, IExecutionInProgressParams } from './runtime.service';import {createIdentifier,@@ -44,7 +45,9 @@ import { AstTreeBuilder } from '../engine/analysis/parser';import { ErrorNode } from '../engine/ast-node/base-ast-node';import { IFormulaDependencyGenerator } 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 { FORMULA_REF_TO_ARRAY_CACHE } from '../engine/reference-object/base-reference-object';+import { ErrorValueObjectCache } from '../engine/value-object/base-value-object';+import { StringValueObjectCache } from '../engine/value-object/primitive-object';import { IFormulaCurrentConfigService } from './current-data.service';import { FormulaExecuteStageType, IFormulaRuntimeService } from './runtime.service';@@ -92,6 +95,17 @@ export class CalculateFormulaService extends Disposable {super();}+ override dispose() {+ super.dispose();++ this._executionInProgressListener$.complete();+ this._executionCompleteListener$.complete();+ FORMULA_REF_TO_ARRAY_CACHE.clear();+ CELL_INVERTED_INDEX_CACHE.clear();+ ErrorValueObjectCache.clear();+ StringValueObjectCache.clear();+ }+/*** Stop the execution of the formula.*/diff --git a/packages/engine-formula/src/services/current-data.service.ts b/packages/engine-formula/src/services/current-data.service.tsindex cdaf5328c3..25e4443449 100644--- a/packages/engine-formula/src/services/current-data.service.ts+++ b/packages/engine-formula/src/services/current-data.service.ts@@ -150,19 +150,21 @@ export class FormulaCurrentConfigService extends Disposable implements IFormulaC}override dispose(): void {+ super.dispose();this._unitData = {};this._unitStylesData = {};- this._formulaData = {};this._arrayFormulaCellData = {};this._arrayFormulaRange = {};+ this._formulaData = {};this._sheetNameMap = {};+ this._clearDependencyTreeCache = {};this._dirtyRanges = [];this._dirtyNameMap = {};this._dirtyDefinedNameMap = {};this._dirtyUnitFeatureMap = {};+ this._dirtyUnitOtherFormulaMap = {};this._excludedCell = {};this._sheetIdToNameMap = {};- this._dirtyUnitOtherFormulaMap = {};}getExecuteUnitId() {diff --git a/packages/engine-formula/src/services/defined-names.service.ts b/packages/engine-formula/src/services/defined-names.service.tsindex c3508cc0ba..a430ab92c7 100644--- a/packages/engine-formula/src/services/defined-names.service.ts+++ b/packages/engine-formula/src/services/defined-names.service.ts@@ -104,8 +104,12 @@ export class DefinedNamesService extends Disposable implements IDefinedNamesServ}override dispose(): void {+ super.dispose();this._definedNameMap = {};- this._nameCacheMap = {}; // Clear cache+ this._nameCacheMap = {};+ this._update$.complete();+ this._currentRange$.complete();+ this._focusRange$.complete();}getWorksheetByRef(unitId: string, ref: string) {diff --git a/packages/engine-formula/src/services/dependency-manager.service.ts b/packages/engine-formula/src/services/dependency-manager.service.tsindex 9bce2f0313..967bc95405 100644--- a/packages/engine-formula/src/services/dependency-manager.service.ts+++ b/packages/engine-formula/src/services/dependency-manager.service.ts@@ -225,6 +225,7 @@ export class DependencyManagerService extends DependencyManagerBaseService impleprotected _allTreeMap: Map<number, IFormulaDependencyTree> = new Map();override dispose(): void {+ super.dispose();this.reset();}@@ -325,11 +326,11 @@ export class DependencyManagerService extends DependencyManagerBaseService implethis._otherFormulaData.clear();this._featureFormulaData.clear();this._formulaData.clear();+ this._definedNameMap.clear();+ this._otherFormulaDataMainData.clear();this._dependencyRTreeCache.clear();this._allTreeMap.clear();this._restDependencyTreeId();-- this._otherFormulaDataMainData.clear();}override addOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string, dependencyTree: IFormulaDependencyTree) {diff --git a/packages/engine-formula/src/services/feature-calculation-manager.service.ts b/packages/engine-formula/src/services/feature-calculation-manager.service.tsindex 681a921be2..125472b1fd 100644--- a/packages/engine-formula/src/services/feature-calculation-manager.service.ts+++ b/packages/engine-formula/src/services/feature-calculation-manager.service.ts@@ -15,14 +15,14 @@*/import type { IUnitRange, Nullable } from '@univerjs/core';-import { createIdentifier, Disposable } from '@univerjs/core';-import type { Observable } from 'rxjs';-import { Subject } from 'rxjs';+import type { IFeatureDirtyRangeType, IRuntimeUnitDataType } from '../basics/common';import type { IRemoveFeatureCalculationMutationParam } from '../commands/mutations/set-feature-calculation.mutation';-import type { IAllRuntimeData } from './runtime.service';import type { IFormulaDirtyData } from './current-data.service';+import type { IAllRuntimeData } from './runtime.service';+import { createIdentifier, Disposable } from '@univerjs/core';+import { Subject } from 'rxjs';export interface IFeatureCalculationManagerParam {unitId: string;@@ -63,7 +63,9 @@ export class FeatureCalculationManagerService extends Disposable implements IFeareadonly onChanged$ = this._onChanged$.asObservable();override dispose(): void {+ super.dispose();this._referenceExecutorMap.clear();+ this._onChanged$.complete();}remove(unitId: string, subUnitId: string, featureIds: string[]) {diff --git a/packages/engine-formula/src/services/function.service.ts b/packages/engine-formula/src/services/function.service.tsindex 774187640d..ace2b144e9 100644--- a/packages/engine-formula/src/services/function.service.ts+++ b/packages/engine-formula/src/services/function.service.ts@@ -15,10 +15,10 @@*/import type { IDisposable, Nullable } from '@univerjs/core';-import { createIdentifier, Disposable, toDisposable } from '@univerjs/core';-import type { IFunctionInfo, IFunctionNames } from '../basics/function';+import type { BaseFunction } from '../functions/base-function';+import { createIdentifier, Disposable, toDisposable } from '@univerjs/core';export interface IFunctionService {/**@@ -62,6 +62,7 @@ export class FunctionService extends Disposable implements IFunctionService {private _functionDescriptions: Map<IFunctionNames, IFunctionInfo> = new Map();override dispose(): void {+ super.dispose();this._functionExecutors.clear();this._functionDescriptions.clear();}diff --git a/packages/engine-formula/src/services/global-computing-status.service.ts b/packages/engine-formula/src/services/global-computing-status.service.tsindex ebf9900b53..64ae9b63dd 100644--- a/packages/engine-formula/src/services/global-computing-status.service.ts+++ b/packages/engine-formula/src/services/global-computing-status.service.ts@@ -38,6 +38,9 @@ export class GlobalComputingStatusService extends Disposable {this._computingStatus$.next(true);this._computingStatus$.complete();+ this._allSubjects.forEach((subject) => {+ subject.complete();+ });}pushComputingStatusSubject(subject: BehaviorSubject<ComputingStatus>): IDisposable {diff --git a/packages/engine-formula/src/services/other-formula-manager.service.ts b/packages/engine-formula/src/services/other-formula-manager.service.tsindex 06f2f9d926..e05bb3395b 100644--- a/packages/engine-formula/src/services/other-formula-manager.service.ts+++ b/packages/engine-formula/src/services/other-formula-manager.service.ts@@ -57,6 +57,7 @@ export class OtherFormulaManagerService extends Disposable implements IOtherFormprivate _otherFormulaData: IOtherFormulaData = {};override dispose(): void {+ super.dispose();this._otherFormulaData = {};}diff --git a/packages/engine-formula/src/services/super-table.service.ts b/packages/engine-formula/src/services/super-table.service.tsindex f0a5f2a143..9b5fd93837 100644--- a/packages/engine-formula/src/services/super-table.service.ts+++ b/packages/engine-formula/src/services/super-table.service.ts@@ -15,10 +15,10 @@*/import type { Nullable } from '@univerjs/core';-import { createIdentifier, Disposable } from '@univerjs/core';-import type { ISuperTable, TableOptionType } from '../basics/common';+import { createIdentifier, Disposable } from '@univerjs/core';+export interface ISuperTableOptionParam {tableOption: string;tableOptionType: TableOptionType;@@ -44,8 +44,9 @@ export class SuperTableService extends Disposable implements ISuperTableServiceprivate _tableOptionMap: Map<string, TableOptionType> = new Map();override dispose(): void {- this._tableMap.clear();+ super.dispose();+ this._tableMap.clear();this._tableOptionMap.clear();}diff --git a/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts b/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.tsindex bd0d55111f..32633d62e1 100644--- a/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts+++ b/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts@@ -62,7 +62,7 @@ export class UniverSheetsFormulaUIPlugin extends Plugin {if (menu) {this._configService.setConfig('menu', menu, { merge: true });}- this._configService.setConfig(PLUGIN_CONFIG_KEY_BASE, rest);+ this._configService.setConfig(PLUGIN_CONFIG_KEY_BASE, rest, { merge: true });}override onStarting(): void {diff --git a/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts b/packages/sheets-formula/src/controllers/trigger-calculation.controller.tsindex 1e690b83d0..9f5235db6d 100644--- a/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts+++ b/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts@@ -88,8 +88,6 @@ export class TriggerCalculationController extends Disposable {private _restartCalculation = false;- private _calculationMode: CalculationMode = CalculationMode.WHEN_EMPTY;-/*** The mark of forced calculation. If a new mutation triggers dirty area calculation during the forced calculation process, forced calculation is still required.*/@@ -149,9 +147,6 @@ export class TriggerCalculationController extends Disposable {) {super();- const config = this._configService.getConfig<IUniverSheetsFormulaBaseConfig>(PLUGIN_CONFIG_KEY_BASE);- this._calculationMode = config?.initialFormulaComputing ?? CalculationMode.WHEN_EMPTY;-this._commandExecutedListener();this._initialExecuteFormulaProcessListener();this._initialExecuteFormula();@@ -166,6 +161,11 @@ export class TriggerCalculationController extends Disposable {clearTimeout(this._setTimeoutKey);}+ private _getCalculationMode(): CalculationMode {+ const config = this._configService.getConfig<IUniverSheetsFormulaBaseConfig>(PLUGIN_CONFIG_KEY_BASE);+ return config?.initialFormulaComputing ?? CalculationMode.WHEN_EMPTY;+ }+private _commandExecutedListener() {this.disposeWithMe(this._commandService.onCommandExecuted((command: ICommandInfo, options) => {@@ -391,11 +391,6 @@ export class TriggerCalculationController extends Disposable {} = params.stageInfo;if (stage === FormulaExecuteStageType.START) {- // In NO_CALCULATION mode, the following processes will not be triggered, so there is no need to start- if (this._calculationMode === CalculationMode.NO_CALCULATION) {- return;- }-// When calculations are started multiple times in succession, only the first time is recognizedif (calculationProcessCount === 0) {this._startExecutionTime = performance.now();@@ -519,7 +514,8 @@ export class TriggerCalculationController extends Disposable {}private _initialExecuteFormula() {- const params = this._getDirtyDataByCalculationMode(this._calculationMode);+ const calculationMode = this._getCalculationMode();+ const params = this._getDirtyDataByCalculationMode(calculationMode);this._commandService.executeCommand(SetFormulaCalculationStartMutation.id, params, lo);this._registerOtherFormulaService.calculateStarted$.next(true);diff --git a/packages/sheets-formula/src/facade/f-formula.ts b/packages/sheets-formula/src/facade/f-formula.tsindex 847a18ce7b..fd9e4c1456 100644--- a/packages/sheets-formula/src/facade/f-formula.ts+++ b/packages/sheets-formula/src/facade/f-formula.ts@@ -312,6 +312,7 @@ export class FFormulaSheetsMixin extends FFormula implements IFFormulaSheetsMixiconst config = configService.getConfig<Partial<IUniverSheetsFormulaBaseConfig>>(PLUGIN_CONFIG_KEY_BASE);if (!config) {+ configService.setConfig(PLUGIN_CONFIG_KEY_BASE, { initialFormulaComputing: calculationMode });return;}diff --git a/packages/sheets-formula/src/sheets-formula.plugin.ts b/packages/sheets-formula/src/sheets-formula.plugin.tsindex 1907002b1f..a75f317e1d 100644--- a/packages/sheets-formula/src/sheets-formula.plugin.ts+++ b/packages/sheets-formula/src/sheets-formula.plugin.ts@@ -93,7 +93,7 @@ export class UniverSheetsFormulaPlugin extends Plugin {defaultPluginBaseConfig,this._config);- this._configService.setConfig(PLUGIN_CONFIG_KEY_BASE, rest);+ this._configService.setConfig(PLUGIN_CONFIG_KEY_BASE, rest, { merge: true });}override onStarting(): void {