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
feat(sheets): action extension
Dushusir37367b158b9b
diff --git a/packages/core/src/Command/ActionExtension/FormatActionExtension.ts b/packages/core/src/Command/ActionExtension/FormatActionExtension.tsdeleted file mode 100644index d11df94191..0000000000--- a/packages/core/src/Command/ActionExtension/FormatActionExtension.ts+++ /dev/null@@ -1,53 +0,0 @@-import { ACTION_NAMES } from '../../Const';-import { ISetRangeDataActionData } from '../../Sheets/Action';-import { ISheetActionData } from '../SheetAction';-import {- BaseActionExtension,- BaseActionExtensionFactory,-} from '../ActionExtensionFactory';--export class FormatActionExtension extends BaseActionExtension<ISetRangeDataActionData> {- setValue() {- const rangeData = this.actionData.rangeData;- const cellValue = this.actionData.cellValue;- const { startRow, endRow, startColumn, endColumn } = rangeData;- for (let r = startRow; r <= endRow; r++) {- for (let c = startColumn; c <= endColumn; c++) {- const cell = cellValue[r][c];- // TODO format from format-plugin- cell.m = '100%';- cell.v = 1;- }- }- }-- execute() {- this.setValue();- }-}--export class FormatActionExtensionFactory extends BaseActionExtensionFactory<ISetRangeDataActionData> {- get zIndex(): number {- return 2;- }-- get actionName(): ACTION_NAMES {- return ACTION_NAMES.SET_RANGE_DATA_ACTION;- }-- create(- actionData: ISetRangeDataActionData,- actionDataList: ISheetActionData[]- ): BaseActionExtension<ISetRangeDataActionData> {- return new FormatActionExtension(actionData, actionDataList);- }-- // check(actionData: ISetRangeDataActionData, actionDataList: ISheetActionData[]) {- // // Determine whether it is a setFormattedValueAction- // if (actionData.actionName !== this.actionName) {- // return false;- // }-- // return this.create(actionData, actionDataList);- // }-}diff --git a/packages/core/src/Command/ActionExtension/FormulaActionExtension.ts b/packages/core/src/Command/ActionExtension/FormulaActionExtension.tsdeleted file mode 100644index ff9b437a2d..0000000000--- a/packages/core/src/Command/ActionExtension/FormulaActionExtension.ts+++ /dev/null@@ -1,55 +0,0 @@-import { ACTION_NAMES } from '../../Const';-import { ISetRangeDataActionData } from '../../Sheets/Action';-import { ISheetActionData } from '../SheetAction';-import {- BaseActionExtension,- BaseActionExtensionFactory,-} from '../ActionExtensionFactory';--export class FormulaActionExtension extends BaseActionExtension<ISetRangeDataActionData> {- setValue() {- const rangeData = this.actionData.rangeData;- const cellValue = this.actionData.cellValue;- const { startRow, endRow, startColumn, endColumn } = rangeData;- for (let r = startRow; r <= endRow; r++) {- for (let c = startColumn; c <= endColumn; c++) {- const cell = cellValue[r][c];- // TODO change from formula-plugin- cell.m = '1';- cell.v = 1;- }- }- }-- execute() {- console.info('Formula exec');- this.setValue();- }-}--export class FormulaActionExtensionFactory extends BaseActionExtensionFactory<ISetRangeDataActionData> {- get zIndex(): number {- return 1;- }-- // TODO 插件可能重名,采用symble 或者class来check- get actionName(): ACTION_NAMES {- return ACTION_NAMES.SET_RANGE_DATA_ACTION;- }-- create(- actionData: ISetRangeDataActionData,- actionDataList: ISheetActionData[]- ): BaseActionExtension<ISetRangeDataActionData> {- return new FormulaActionExtension(actionData, actionDataList);- }-- // check(actionData: ISetRangeDataActionData, actionDataList: ISheetActionData[]) {- // // Determine whether it is a setFormattedValueAction- // if (actionData.actionName !== this.actionName) {- // return false;- // }-- // return this.create(actionData, actionDataList);- // }-}diff --git a/packages/core/src/Command/ActionExtension/index.ts b/packages/core/src/Command/ActionExtension/index.tsdeleted file mode 100644index 13c2388e0c..0000000000--- a/packages/core/src/Command/ActionExtension/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from './FormatActionExtension';-export * from './FormulaActionExtension';diff --git a/packages/core/src/Command/ActionExtensionFactory.ts b/packages/core/src/Command/ActionExtensionFactory.tsindex 6edd142730..48a4690837 100644--- a/packages/core/src/Command/ActionExtensionFactory.ts+++ b/packages/core/src/Command/ActionExtensionFactory.ts@@ -1,11 +1,19 @@import { ACTION_NAMES } from '../Const';import { IActionData } from './ActionBase';+import { Plugin } from '../Plugin';/*** Manipulate the list of actions in a command*/-export class BaseActionExtension<T extends IActionData = IActionData> {- constructor(protected actionData: T, protected actionDataList: IActionData[]) {}+export class BaseActionExtension<+ T extends IActionData = IActionData,+ P extends Plugin = Plugin+> {+ constructor(+ protected actionData: T,+ protected actionDataList: IActionData[],+ protected _plugin: P+ ) {}getActionData(): T {return this.actionData;@@ -37,7 +45,12 @@ export class BaseActionExtension<T extends IActionData = IActionData> {/*** Determine whether to intercept and create BaseActionExtension*/-export class BaseActionExtensionFactory<T extends IActionData> {+export class BaseActionExtensionFactory<+ T extends IActionData,+ P extends Plugin = Plugin+> {+ constructor(protected _plugin: P) {}+get zIndex() {return 0;}@@ -53,7 +66,7 @@ export class BaseActionExtensionFactory<T extends IActionData> {* @returns*/create(actionData: T, actionDataList: IActionData[]): BaseActionExtension<T> {- return new BaseActionExtension(actionData, actionDataList);+ return new BaseActionExtension(actionData, actionDataList, this._plugin);}/**diff --git a/packages/core/src/Command/ActionExtensionRegister.ts b/packages/core/src/Command/ActionExtensionRegister.tsindex a3c51eedb1..c3f9e69d4c 100644--- a/packages/core/src/Command/ActionExtensionRegister.ts+++ b/packages/core/src/Command/ActionExtensionRegister.ts@@ -2,7 +2,6 @@ import { sortRules } from '../Shared';import { BaseActionExtensionFactory } from './ActionExtensionFactory';import { REGISTRY_ACTION_FACTORY } from './RegistryFactory';-import './ActionExtension/index';import { IActionData } from './ActionBase';export class ActionExtensionRegister {diff --git a/packages/core/src/Command/RegisterActionExtension.ts b/packages/core/src/Command/RegisterActionExtension.tsdeleted file mode 100644index 2208197479..0000000000--- a/packages/core/src/Command/RegisterActionExtension.ts+++ /dev/null@@ -1,9 +0,0 @@-import { ActionExtensionManager } from './ActionExtensionManager';--const register = ActionExtensionManager.create();--register- .add- // new FormatActionExtensionFactory(),- // new FormulaActionExtensionFactory()- ();diff --git a/packages/core/src/Command/index.ts b/packages/core/src/Command/index.tsindex 79d6d23a21..f54666c944 100644--- a/packages/core/src/Command/index.ts+++ b/packages/core/src/Command/index.ts@@ -12,6 +12,5 @@ export * from './ActionOperation';/* eslint-disable import/first */import './RegisterAction';-import './RegisterActionExtension';// @endindexdiff --git a/packages/core/src/Shared/Common.ts b/packages/core/src/Shared/Common.tsindex f830cc1409..d858c67daf 100644--- a/packages/core/src/Shared/Common.ts+++ b/packages/core/src/Shared/Common.ts@@ -1,3 +1,4 @@+import { Tools } from './Tools';import { Nullable } from '.';import { ICellInfo, ISelection, ICellData, IColorStyle } from '../Interfaces';import { ColorBuilder } from '../Sheets/Domain';@@ -73,3 +74,7 @@ export function getColorStyle(color: Nullable<IColorStyle>): Nullable<string> {}return null;}++export function isFormulaString(value: any): boolean {+ return Tools.isString(value) && value.indexOf('=') === 0;+}diff --git a/packages/sheets-plugin-formula/src/Basic/DEFAULT_FORMULA_DATA.ts b/packages/sheets-plugin-formula/src/Basic/Const/DEFAULT_FORMULA_DATA.tssimilarity index 94%rename from packages/sheets-plugin-formula/src/Basic/DEFAULT_FORMULA_DATA.tsrename to packages/sheets-plugin-formula/src/Basic/Const/DEFAULT_FORMULA_DATA.tsindex d8c586b15e..26c5f280b0 100644--- a/packages/sheets-plugin-formula/src/Basic/DEFAULT_FORMULA_DATA.ts+++ b/packages/sheets-plugin-formula/src/Basic/Const/DEFAULT_FORMULA_DATA.ts@@ -1,4 +1,4 @@-import { IFormulaConfig } from './IFormula';+import { IFormulaConfig } from '../Interfaces/IFormula';export const DEFAULT_FORMULA_DATA: IFormulaConfig = {formulaData: {diff --git a/packages/sheets-plugin-formula/src/Const/functionlist.ts b/packages/sheets-plugin-formula/src/Basic/Const/FunctionList.tssimilarity index 100%rename from packages/sheets-plugin-formula/src/Const/functionlist.tsrename to packages/sheets-plugin-formula/src/Basic/Const/FunctionList.tsdiff --git a/packages/sheets-plugin-formula/src/Basic/PLUGIN_NAME.ts b/packages/sheets-plugin-formula/src/Basic/Const/PLUGIN_NAME.tssimilarity index 100%rename from packages/sheets-plugin-formula/src/Basic/PLUGIN_NAME.tsrename to packages/sheets-plugin-formula/src/Basic/Const/PLUGIN_NAME.tsdiff --git a/packages/sheets-plugin-formula/src/Basic/State.ts b/packages/sheets-plugin-formula/src/Basic/Const/State.tssimilarity index 100%rename from packages/sheets-plugin-formula/src/Basic/State.tsrename to packages/sheets-plugin-formula/src/Basic/Const/State.tsdiff --git a/packages/sheets-plugin-formula/src/Basic/Const/index.ts b/packages/sheets-plugin-formula/src/Basic/Const/index.tsnew file mode 100644index 0000000000..42ea0e3a9f--- /dev/null+++ b/packages/sheets-plugin-formula/src/Basic/Const/index.ts@@ -0,0 +1,6 @@+// @index('./*.ts', f => `export * from '${f.path}'`)+export * from './DEFAULT_FORMULA_DATA';+export * from './FunctionList';+export * from './PLUGIN_NAME';+export * from './State';+// @endindexdiff --git a/packages/sheets-plugin-formula/src/Basic/Enum/ACTION_NAMES.ts b/packages/sheets-plugin-formula/src/Basic/Enum/ACTION_NAMES.tsnew file mode 100644index 0000000000..2a7d39f37c--- /dev/null+++ b/packages/sheets-plugin-formula/src/Basic/Enum/ACTION_NAMES.ts@@ -0,0 +1,3 @@+export enum ACTION_NAMES {+ SET_FORMULA_RANGE_DATA_ACTION = 'SetFormulaRangeDataAction',+}diff --git a/packages/sheets-plugin-formula/src/Basic/Enum/index.ts b/packages/sheets-plugin-formula/src/Basic/Enum/index.tsnew file mode 100644index 0000000000..355ae80973--- /dev/null+++ b/packages/sheets-plugin-formula/src/Basic/Enum/index.ts@@ -0,0 +1,3 @@+// @index('./*.ts', f => `export * from '${f.path}'`)+export * from './ACTION_NAMES';+// @endindexdiff --git a/packages/sheets-plugin-formula/src/Basic/IFormula.ts b/packages/sheets-plugin-formula/src/Basic/Interfaces/IFormula.tssimilarity index 100%rename from packages/sheets-plugin-formula/src/Basic/IFormula.tsrename to packages/sheets-plugin-formula/src/Basic/Interfaces/IFormula.tsdiff --git a/packages/sheets-plugin-formula/src/Basic/Interfaces/index.ts b/packages/sheets-plugin-formula/src/Basic/Interfaces/index.tsnew file mode 100644index 0000000000..af5abb7203--- /dev/null+++ b/packages/sheets-plugin-formula/src/Basic/Interfaces/index.ts@@ -0,0 +1,3 @@+// @index('./*.ts', f => `export * from '${f.path}'`)+export * from './IFormula';+// @endindexdiff --git a/packages/sheets-plugin-formula/src/Basic/Register/FormulaActionExtension.ts b/packages/sheets-plugin-formula/src/Basic/Register/FormulaActionExtension.tsnew file mode 100644index 0000000000..ade00954db--- /dev/null+++ b/packages/sheets-plugin-formula/src/Basic/Register/FormulaActionExtension.ts@@ -0,0 +1,92 @@+import { IFormulaData } from '@univer/base-formula-engine';+import {+ ACTION_NAMES,+ BaseActionExtension,+ BaseActionExtensionFactory,+ ContextBase,+ ICellData,+ ISetRangeDataActionData,+ isFormulaString,+ ISheetActionData,+ IUnitRange,+ ObjectMatrix,+ ObjectMatrixPrimitiveType,+ Plugin,+ Tools,+} from '@univer/core';+import { IActionData } from '@univer/core/src/Command/ActionBase';+import { FormulaPlugin } from '../../FormulaPlugin';++export class FormulaActionExtension extends BaseActionExtension<ISetRangeDataActionData, FormulaPlugin> {+ execute() {+ const engine = this._plugin.getFormulaEngine();+ const formulaData = Tools.deepClone(this._plugin.getFormulaController().getDataModel().getFormulaData());+ const unitId = this._plugin.getContext().getWorkBook().getUnitId();+ const sheetId = this.actionData.sheetId;+ const rangeData = this.actionData.rangeData;+ let cellValue = this.actionData.cellValue;++ const cellData: IFormulaData = formulaData[unitId][sheetId];++ // a range+ if (!isNaN(parseInt(Object.keys(cellValue)[0]))) {+ const rangeMatrix = new ObjectMatrix(cellValue as ObjectMatrixPrimitiveType<ICellData>);++ // update formula string+ rangeMatrix.forValue((r, c, cell) => {+ const formulaString = cell.v;+ if (cellData[r] && cellData[r]._array[c] && isFormulaString(formulaString)) {+ cellData[r]._array[c].formula = formulaString;+ }+ });+ }+ // a cell+ else {+ const { startRow: r, startColumn: c } = rangeData;+ let cell: ICellData = cellValue;+ const formulaString = cell.v;+ if (cellData[r] && cellData[r]._array[c] && isFormulaString(formulaString)) {+ cellData[r]._array[c].formula = formulaString;+ }+ }++ console.log('formulaData=====', formulaData);++ const unitRange: IUnitRange[] = [+ {+ unitId,+ sheetId,+ rangeData,+ },+ ];+ engine.execute(unitId, formulaData, undefined, undefined, unitRange).then((sheetData) => {+ console.log('sheetData---', sheetData);+ });++ // const setNumfmtRangeDataAction = {+ // actionName: ACTION_NAMES,+ // sheetId: this.actionData.sheetId,+ // rangeData: this.actionData.rangeData,+ // cellValue: formulaMatrix.toJSON(),+ // };+ // this.push(setNumfmtRangeDataAction);+ }+}++export class FormulaActionExtensionFactory extends BaseActionExtensionFactory<ISetRangeDataActionData, FormulaPlugin> {+ get zIndex(): number {+ return 1;+ }++ get actionName(): ACTION_NAMES {+ return ACTION_NAMES.SET_RANGE_DATA_ACTION;+ }++ create(actionData: ISetRangeDataActionData, actionDataList: ISheetActionData[]): BaseActionExtension<ISetRangeDataActionData> {+ return new FormulaActionExtension(actionData, actionDataList, this._plugin);+ }++ check(actionData: ISetRangeDataActionData, actionDataList: IActionData[]): false | BaseActionExtension<ISetRangeDataActionData, Plugin<any, ContextBase>> {+ return false;+ }+}diff --git a/packages/sheets-plugin-formula/src/Basic/Register/index.ts b/packages/sheets-plugin-formula/src/Basic/Register/index.tsindex 87f7140319..33f16a664e 100644--- a/packages/sheets-plugin-formula/src/Basic/Register/index.ts+++ b/packages/sheets-plugin-formula/src/Basic/Register/index.ts@@ -1,2 +1,5 @@-/* eslint-disable import/first */-import './RegisterExtension';+// @index('./*.ts', f => `export * from '${f.path}'`)+export * from './FormulaActionExtension';+export * from './FormulaCellEditExtension';+export * from './FormulaCellInputExtension';+// @endindexdiff --git a/packages/sheets-plugin-formula/src/Basic/index.ts b/packages/sheets-plugin-formula/src/Basic/index.tsindex 17b7b8c43f..3378950908 100644--- a/packages/sheets-plugin-formula/src/Basic/index.ts+++ b/packages/sheets-plugin-formula/src/Basic/index.ts@@ -1,3 +1,3 @@export * from './Cache';-export * from './State';-export * from './PLUGIN_NAME';+export * from './Const/State';+export * from './Const/PLUGIN_NAME';diff --git a/packages/sheets-plugin-formula/src/Controller/FormulaController.ts b/packages/sheets-plugin-formula/src/Controller/FormulaController.tsindex b3b48bd918..b7bded919e 100644--- a/packages/sheets-plugin-formula/src/Controller/FormulaController.ts+++ b/packages/sheets-plugin-formula/src/Controller/FormulaController.ts@@ -1,6 +1,7 @@import { FormulaEnginePlugin, IInterpreterDatasetConfig, SheetDataType, UnitDataType, SheetNameMapType } from '@univer/base-formula-engine';-import { SheetContext, Plugin } from '@univer/core';-import { IFormulaConfig } from '../Basic/IFormula';+import { SheetContext } from '@univer/core';+import { IFormulaConfig } from '../Basic/Interfaces/IFormula';+import { FormulaPlugin } from '../FormulaPlugin';import { FormulaDataModel } from '../Model/FormulaDataModel';export class FormulaController {@@ -12,7 +13,7 @@ export class FormulaController {private _interpreterCalculatePropsCache: IInterpreterDatasetConfig;- constructor(private _plugin: Plugin, config?: IFormulaConfig) {+ constructor(private _plugin: FormulaPlugin, config?: IFormulaConfig) {this._formulaDataModel = new FormulaDataModel(config);this._context = this._plugin.getContext();diff --git a/packages/sheets-plugin-formula/src/FormulaPlugin.tsx b/packages/sheets-plugin-formula/src/FormulaPlugin.tsxindex 289076b866..fc2fbcbb54 100644--- a/packages/sheets-plugin-formula/src/FormulaPlugin.tsx+++ b/packages/sheets-plugin-formula/src/FormulaPlugin.tsx@@ -1,17 +1,17 @@-import { SheetContext, IOCContainer, UniverSheet, Plugin, PLUGIN_NAMES } from '@univer/core';-import { CellEditExtensionManager, CellInputExtensionManager, SheetPlugin } from '@univer/base-sheets';+import { SheetContext, IOCContainer, UniverSheet, Plugin, IKeyValue, ActionExtensionManager } from '@univer/core';+import { CellEditExtensionManager, CellInputExtensionManager } from '@univer/base-sheets';import { FormulaEnginePlugin } from '@univer/base-formula-engine';-import { FormulaButton } from './UI/FormulaButton';import { zh, en } from './Locale';-import { IConfig, IFormulaConfig } from './Basic/IFormula';-import { FORMULA_PLUGIN_NAME } from './Basic/PLUGIN_NAME';+import { IConfig, IFormulaConfig } from './Basic/Interfaces/IFormula';+import { FORMULA_PLUGIN_NAME } from './Basic/Const/PLUGIN_NAME';import { FormulaController } from './Controller/FormulaController';import { firstLoader } from './Controller/FirstLoader';import { FormulaCellEditExtensionFactory } from './Basic/Register/FormulaCellEditExtension';import { FormulaCellInputExtensionFactory } from './Basic/Register/FormulaCellInputExtension';+import { FormulaActionExtensionFactory } from './Basic/Register';-export class FormulaPlugin extends Plugin<any, SheetContext> {+export class FormulaPlugin extends Plugin<IKeyValue, SheetContext> {private _formulaController: FormulaController;constructor(private _config?: IFormulaConfig) {@@ -52,13 +52,13 @@ export class FormulaPlugin extends Plugin<any, SheetContext> {const config: IConfig = { context };- const item = {- locale: FORMULA_PLUGIN_NAME,- type: 0,- show: true,- label: <FormulaButton config={config} />,- };- context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addToolButton(item);+ // const item = {+ // locale: FORMULA_PLUGIN_NAME,+ // type: 0,+ // show: true,+ // label: <FormulaButton config={config} />,+ // };+ // context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addToolButton(item);this.registerExtension();}@@ -73,12 +73,13 @@ export class FormulaPlugin extends Plugin<any, SheetContext> {registerExtension() {const cellEditRegister = CellEditExtensionManager.create();-cellEditRegister.add(new FormulaCellEditExtensionFactory(this));const cellInputRegister = CellInputExtensionManager.create();-cellInputRegister.add(new FormulaCellInputExtensionFactory(this));++ const actionRegister = ActionExtensionManager.create();+ actionRegister.add(new FormulaActionExtensionFactory(this));}getFormulaEngine() {diff --git a/packages/sheets-plugin-formula/src/Model/Action/SetFormulaRangeDataAction.ts b/packages/sheets-plugin-formula/src/Model/Action/SetFormulaRangeDataAction.tsnew file mode 100644index 0000000000..93fd49e8c0--- /dev/null+++ b/packages/sheets-plugin-formula/src/Model/Action/SetFormulaRangeDataAction.ts@@ -0,0 +1,36 @@+import { IFormulaData } from '@univer/base-formula-engine';+import { SheetAction, ActionObservers, ISheetActionData, ObjectMatrixPrimitiveType, Workbook } from '@univer/core';+import { SetFormulaRangeData } from '../Apply/SetFormulaRangeData';++export interface ISetFormulaRangeActionData extends ISheetActionData {+ formulaData: IFormulaData;+}++export class SetFormulaRangeDataAction extends SheetAction<ISetFormulaRangeActionData, IFormulaData> {+ constructor(actionData: ISetFormulaRangeActionData, workbook: Workbook, observers: ActionObservers) {+ super(actionData, workbook, observers);+ this._doActionData = {+ ...actionData,+ };+ this._oldActionData = {+ ...actionData,+ formulaData: this.do(),+ };+ }++ do(): ObjectMatrixPrimitiveType<string> {+ return this.redo();+ }++ redo(): IFormulaData {+ return SetFormulaRangeData();+ }++ undo(): void {+ SetFormulaRangeData();+ }++ validate(): boolean {+ return false;+ }+}diff --git a/packages/sheets-plugin-formula/src/Model/Apply/SetFormulaRangeData.ts b/packages/sheets-plugin-formula/src/Model/Apply/SetFormulaRangeData.tsnew file mode 100644index 0000000000..f8d64686cc--- /dev/null+++ b/packages/sheets-plugin-formula/src/Model/Apply/SetFormulaRangeData.ts@@ -0,0 +1,5 @@+import { IFormulaData } from '@univer/base-formula-engine';++export function SetFormulaRangeData(): IFormulaData {+ return {};+}diff --git a/packages/sheets-plugin-formula/src/Model/FormulaActionExtensionFactory.ts b/packages/sheets-plugin-formula/src/Model/FormulaActionExtensionFactory.tsdeleted file mode 100644index a155b31aaf..0000000000--- a/packages/sheets-plugin-formula/src/Model/FormulaActionExtensionFactory.ts+++ /dev/null@@ -1,26 +0,0 @@-import { ACTION_NAMES, Plugin, BaseActionExtension, BaseActionExtensionFactory, ISetRangeDataActionData, ISheetActionData } from '@univer/core';--export class FormulaActionExtension extends BaseActionExtension<ISetRangeDataActionData> {- execute() {}-}--export class FormulaActionExtensionFactory extends BaseActionExtensionFactory<ISetRangeDataActionData> {- private _plugin: Plugin;-- get zIndex(): number {- return 2;- }-- get actionName(): ACTION_NAMES {- return ACTION_NAMES.SET_RANGE_DATA_ACTION;- }-- constructor(plugin: Plugin) {- super();- this._plugin = plugin;- }-- create(actionData: ISetRangeDataActionData, actionDataList: ISheetActionData[]): BaseActionExtension<ISetRangeDataActionData> {- return new FormulaActionExtension(actionData, actionDataList);- }-}diff --git a/packages/sheets-plugin-formula/src/Model/FormulaDataModel.ts b/packages/sheets-plugin-formula/src/Model/FormulaDataModel.tsindex b9191b0042..efd6ef9c3d 100644--- a/packages/sheets-plugin-formula/src/Model/FormulaDataModel.ts+++ b/packages/sheets-plugin-formula/src/Model/FormulaDataModel.ts@@ -1,5 +1,5 @@import { FormulaDataType } from '@univer/base-formula-engine';-import { IFormulaConfig, RecalculationModeType } from '../Basic/IFormula';+import { IFormulaConfig, RecalculationModeType } from '../Basic/Interfaces/IFormula';export class FormulaDataModel {private _formulaData: FormulaDataType = {};diff --git a/packages/sheets-plugin-formula/src/Model/RegisterAction.ts b/packages/sheets-plugin-formula/src/Model/RegisterAction.tsnew file mode 100644index 0000000000..89a29b3219--- /dev/null+++ b/packages/sheets-plugin-formula/src/Model/RegisterAction.ts@@ -0,0 +1,5 @@+import { CommandManager } from '@univer/core';+import { ACTION_NAMES } from '../Basic/Enum/ACTION_NAMES';+import { SetFormulaRangeDataAction } from './Action/SetFormulaRangeDataAction';++CommandManager.register(ACTION_NAMES.SET_FORMULA_RANGE_DATA_ACTION, SetFormulaRangeDataAction);diff --git a/packages/sheets-plugin-formula/src/View/Event.ts b/packages/sheets-plugin-formula/src/View/Event.tsdeleted file mode 100644index 8c34a9ab4c..0000000000--- a/packages/sheets-plugin-formula/src/View/Event.ts+++ /dev/null@@ -1 +0,0 @@-export class Event {}diff --git a/packages/sheets-plugin-formula/src/View/ObserverList.ts b/packages/sheets-plugin-formula/src/View/ObserverList.tsdeleted file mode 100644index a1b96aa311..0000000000--- a/packages/sheets-plugin-formula/src/View/ObserverList.ts+++ /dev/null@@ -1 +0,0 @@-export class ObserverList {}diff --git a/packages/sheets-plugin-formula/src/View/Render.ts b/packages/sheets-plugin-formula/src/View/Render.tsdeleted file mode 100644index faca95e82e..0000000000--- a/packages/sheets-plugin-formula/src/View/Render.ts+++ /dev/null@@ -1 +0,0 @@-export class Render {}diff --git a/packages/sheets-plugin-formula/src/Basic/Register/RegisterExtension.ts b/packages/sheets-plugin-formula/src/View/Render/index.tssimilarity index 100%rename from packages/sheets-plugin-formula/src/Basic/Register/RegisterExtension.tsrename to packages/sheets-plugin-formula/src/View/Render/index.tsdiff --git a/packages/sheets-plugin-formula/src/UI/FormulaButton.tsx b/packages/sheets-plugin-formula/src/View/UI/FormulaButton.tsxsimilarity index 96%rename from packages/sheets-plugin-formula/src/UI/FormulaButton.tsxrename to packages/sheets-plugin-formula/src/View/UI/FormulaButton.tsxindex 14df20f2fa..690fefa64d 100644--- a/packages/sheets-plugin-formula/src/UI/FormulaButton.tsx+++ b/packages/sheets-plugin-formula/src/View/UI/FormulaButton.tsx@@ -1,7 +1,8 @@-import { BaseComponentSheet, BaseIconProps, BaseSelectProps, Component, FunctionComponent, ISelectButton, IToolBarItemProps, ISlotElement } from '@univer/base-component';+import { BaseComponentSheet, BaseIconProps, BaseSelectProps, Component, FunctionComponent, ISelectButton, ISlotElement } from '@univer/base-component';+import { IToolBarItemProps } from '@univer/base-sheets';import { Nullable, Observer, Workbook } from '@univer/core';-import { FORMULA_CHILDREN } from '../Basic';-import { IProps } from '../Basic/IFormula';+import { FORMULA_CHILDREN } from '../../Basic';+import { IProps } from '../../Basic/Interfaces';import { IfGenerate } from './IfGenerate';import { SearchFormulaModal } from './SearchFormulaModal';diff --git a/packages/sheets-plugin-formula/src/UI/IfGenerate/ifGenerate.tsx b/packages/sheets-plugin-formula/src/View/UI/IfGenerate/ifGenerate.tsxsimilarity index 98%rename from packages/sheets-plugin-formula/src/UI/IfGenerate/ifGenerate.tsxrename to packages/sheets-plugin-formula/src/View/UI/IfGenerate/ifGenerate.tsxindex 8443b9dc87..f1c4988a0f 100644--- a/packages/sheets-plugin-formula/src/UI/IfGenerate/ifGenerate.tsx+++ b/packages/sheets-plugin-formula/src/View/UI/IfGenerate/ifGenerate.tsx@@ -1,6 +1,6 @@import { BaseButtonProps, BaseComponentSheet, BaseModalProps, BaseSelectProps, Component, FunctionComponent } from '@univer/base-component';import { Nullable, Observer, Workbook } from '@univer/core';-import { IConfig } from '../../Basic/IFormula';+import { IConfig } from '../../Basic/Interfaces/IFormula';import styles from './index.module.less';interface IProps {diff --git a/packages/sheets-plugin-formula/src/UI/IfGenerate/index.module.less b/packages/sheets-plugin-formula/src/View/UI/IfGenerate/index.module.lesssimilarity index 100%rename from packages/sheets-plugin-formula/src/UI/IfGenerate/index.module.lessrename to packages/sheets-plugin-formula/src/View/UI/IfGenerate/index.module.lessdiff --git a/packages/sheets-plugin-formula/src/UI/IfGenerate/index.ts b/packages/sheets-plugin-formula/src/View/UI/IfGenerate/index.tssimilarity index 100%rename from packages/sheets-plugin-formula/src/UI/IfGenerate/index.tsrename to packages/sheets-plugin-formula/src/View/UI/IfGenerate/index.tsdiff --git a/packages/sheets-plugin-formula/src/UI/SearchFormulaModal/SearchFormulaModal.tsx b/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaModal.tsxsimilarity index 98%rename from packages/sheets-plugin-formula/src/UI/SearchFormulaModal/SearchFormulaModal.tsxrename to packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaModal.tsxindex 217d95cc4e..1d7cefcecf 100644--- a/packages/sheets-plugin-formula/src/UI/SearchFormulaModal/SearchFormulaModal.tsx+++ b/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaModal.tsx@@ -1,7 +1,7 @@import { BaseButtonProps, BaseComponentSheet, BaseModalProps, BaseSelectProps, Component, createRef, FunctionComponent } from '@univer/base-component';import { Nullable, Observer, Workbook } from '@univer/core';-import * as func from '../../Const/FunctionList'; // 全部公式数组-import { IConfig } from '../../Basic/IFormula';+import * as func from '../../Basic/Const/FunctionList'; // 全部公式数组+import { IConfig } from '../../Basic/Interfaces/IFormula';import styles from './index.module.less';interface IProps {diff --git a/packages/sheets-plugin-formula/src/UI/SearchFormulaModal/index.module.less b/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/index.module.lesssimilarity index 100%rename from packages/sheets-plugin-formula/src/UI/SearchFormulaModal/index.module.lessrename to packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/index.module.lessdiff --git a/packages/sheets-plugin-formula/src/UI/SearchFormulaModal/index.ts b/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/index.tssimilarity index 100%rename from packages/sheets-plugin-formula/src/UI/SearchFormulaModal/index.tsrename to packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/index.tsdiff --git a/packages/sheets-plugin-formula/src/View/index.ts b/packages/sheets-plugin-formula/src/View/index.tsdeleted file mode 100644index 732247fef5..0000000000--- a/packages/sheets-plugin-formula/src/View/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export * from './Event';-export * from './ObserverList';-export * from './Render';diff --git a/packages/sheets-plugin-formula/src/index.ts b/packages/sheets-plugin-formula/src/index.tsindex 502c79567a..684586a557 100644--- a/packages/sheets-plugin-formula/src/index.ts+++ b/packages/sheets-plugin-formula/src/index.ts@@ -1,3 +1,3 @@export * from './FormulaPlugin';-export * from './Basic/DEFAULT_FORMULA_DATA';-export * from './Basic/PLUGIN_NAME';+export * from './Basic/Const/DEFAULT_FORMULA_DATA';+export * from './Basic/Const/PLUGIN_NAME';diff --git a/packages/sheets-plugin-numfmt/src/Const/DEFAULT_DATA.ts b/packages/sheets-plugin-numfmt/src/Basic/Const/DEFAULT_DATA.tssimilarity index 100%rename from packages/sheets-plugin-numfmt/src/Const/DEFAULT_DATA.tsrename to packages/sheets-plugin-numfmt/src/Basic/Const/DEFAULT_DATA.tsdiff --git a/packages/sheets-plugin-numfmt/src/Const/FORMATDETAIL.ts b/packages/sheets-plugin-numfmt/src/Basic/Const/FORMATDETAIL.tssimilarity index 100%rename from packages/sheets-plugin-numfmt/src/Const/FORMATDETAIL.tsrename to packages/sheets-plugin-numfmt/src/Basic/Const/FORMATDETAIL.tsdiff --git a/packages/sheets-plugin-numfmt/src/Const/PLUGIN_NAME.ts b/packages/sheets-plugin-numfmt/src/Basic/Const/PLUGIN_NAME.tssimilarity index 100%rename from packages/sheets-plugin-numfmt/src/Const/PLUGIN_NAME.tsrename to packages/sheets-plugin-numfmt/src/Basic/Const/PLUGIN_NAME.tsdiff --git a/packages/sheets-plugin-numfmt/src/Basic/Const/index.ts b/packages/sheets-plugin-numfmt/src/Basic/Const/index.tsnew file mode 100644index 0000000000..59d17bb2ce--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/Basic/Const/index.ts@@ -0,0 +1,5 @@+// @index('./*.ts', f => `export * from '${f.path}'`)+export * from './DEFAULT_DATA';+export * from './FORMATDETAIL';+export * from './PLUGIN_NAME';+// @endindexdiff --git a/packages/sheets-plugin-numfmt/src/Const/ACTION_NAMES.ts b/packages/sheets-plugin-numfmt/src/Basic/Enum/ACTION_NAMES.tssimilarity index 100%rename from packages/sheets-plugin-numfmt/src/Const/ACTION_NAMES.tsrename to packages/sheets-plugin-numfmt/src/Basic/Enum/ACTION_NAMES.tsdiff --git a/packages/sheets-plugin-numfmt/src/Basic/Enum/index.ts b/packages/sheets-plugin-numfmt/src/Basic/Enum/index.tsnew file mode 100644index 0000000000..355ae80973--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/Basic/Enum/index.ts@@ -0,0 +1,3 @@+// @index('./*.ts', f => `export * from '${f.path}'`)+export * from './ACTION_NAMES';+// @endindexdiff --git a/packages/sheets-plugin-numfmt/src/NumfmtActionExtensionFactory.ts b/packages/sheets-plugin-numfmt/src/Basic/Register/NumfmtActionExtension.tssimilarity index 74%rename from packages/sheets-plugin-numfmt/src/NumfmtActionExtensionFactory.tsrename to packages/sheets-plugin-numfmt/src/Basic/Register/NumfmtActionExtension.tsindex 5f3ce04564..c678e06496 100644--- a/packages/sheets-plugin-numfmt/src/NumfmtActionExtensionFactory.ts+++ b/packages/sheets-plugin-numfmt/src/Basic/Register/NumfmtActionExtension.ts@@ -1,14 +1,16 @@-import { ACTION_NAMES, Plugin, BaseActionExtension, BaseActionExtensionFactory, ISetRangeDataActionData, ObjectMatrix, ISheetActionData, ObjectMatrixPrimitiveType } from '@univer/core';+import { ACTION_NAMES, BaseActionExtension, BaseActionExtensionFactory, ISetRangeDataActionData, ObjectMatrix, ISheetActionData, ObjectMatrixPrimitiveType } from '@univer/core';import { numfmt } from '@univer/base-numfmt-engine';import { ICellData } from '@univer/core/src/Interfaces/ICellData';-import { ACTION_NAMES as PLUGIN_ACTION_NAMES } from './Const';+import { ACTION_NAMES as PLUGIN_ACTION_NAMES } from '../Enum';+import { NumfmtPlugin } from '../../NumfmtPlugin';-export class NumfmtActionExtension extends BaseActionExtension<ISetRangeDataActionData> {+export class NumfmtActionExtension extends BaseActionExtension<ISetRangeDataActionData, NumfmtPlugin> {// constructor(protected actionData: ISetRangeDataActionData) {// super(actionData);// }execute() {+ // TODOconst numfmtMatrix = new ObjectMatrix<string>();let cellValue = this.actionData.cellValue;// a range@@ -47,9 +49,7 @@ export class NumfmtActionExtension extends BaseActionExtension<ISetRangeDataActi}}-export class NumfmtActionExtensionFactory extends BaseActionExtensionFactory<ISetRangeDataActionData> {- private _plugin: Plugin;-+export class NumfmtActionExtensionFactory extends BaseActionExtensionFactory<ISetRangeDataActionData, NumfmtPlugin> {get zIndex(): number {return 2;}@@ -58,21 +58,7 @@ export class NumfmtActionExtensionFactory extends BaseActionExtensionFactory<ISereturn ACTION_NAMES.SET_RANGE_DATA_ACTION;}- constructor(plugin: Plugin) {- super();- this._plugin = plugin;- }-create(actionData: ISetRangeDataActionData, actionDataList: ISheetActionData[]): BaseActionExtension<ISetRangeDataActionData> {- return new NumfmtActionExtension(actionData, actionDataList);+ return new NumfmtActionExtension(actionData, actionDataList, this._plugin);}-- // check(actionData: ISheetActionData) {- // // Determine whether it is a setFormattedValueAction- // if (actionData.actionName !== this.actionName) {- // return false;- // }-- // return this.create(actionData as ISetRangeDataActionData);- // }}diff --git a/packages/sheets-plugin-numfmt/src/Basic/Register/index.ts b/packages/sheets-plugin-numfmt/src/Basic/Register/index.tsnew file mode 100644index 0000000000..87bfeee9b5--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/Basic/Register/index.ts@@ -0,0 +1,3 @@+// @index('./*.ts', f => `export * from '${f.path}'`)+export * from './NumfmtActionExtension';+// @endindexdiff --git a/packages/sheets-plugin-numfmt/src/Const/index.ts b/packages/sheets-plugin-numfmt/src/Const/index.tsdeleted file mode 100644index a1f79b393d..0000000000--- a/packages/sheets-plugin-numfmt/src/Const/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from './ACTION_NAMES';-export * from './PLUGIN_NAME';diff --git a/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.ts b/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.tsindex 219c60e631..dd5f712eda 100644--- a/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.ts+++ b/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.ts@@ -2,8 +2,8 @@ import { SheetCommand, Range, IRangeData, ObjectMatrix, ObjectMatrixPrimitiveTypimport { BaseComponentRender, BaseComponentSheet } from '@univer/base-component';import { IToolBarItemProps, SheetPlugin } from '@univer/base-sheets';import { NumfmtModel } from '../Model/NumfmtModel';-import { NUMFMT_PLUGIN_NAME } from '../Const';-import { DEFAULT_DATA } from '../Const/DEFAULT_DATA';+import { NUMFMT_PLUGIN_NAME } from '../Basic/Const';+import { DEFAULT_DATA } from '../Basic/Const/DEFAULT_DATA';import { NumfmtPlugin } from '../NumfmtPlugin';export class NumfmtController {diff --git a/packages/sheets-plugin-numfmt/src/Controller/NumfmtModalController.ts b/packages/sheets-plugin-numfmt/src/Controller/NumfmtModalController.tsindex 71825b7ce3..803315f2ea 100644--- a/packages/sheets-plugin-numfmt/src/Controller/NumfmtModalController.ts+++ b/packages/sheets-plugin-numfmt/src/Controller/NumfmtModalController.ts@@ -1,8 +1,8 @@import { ComponentChildren } from '@univer/base-component';import { SheetPlugin } from '@univer/base-sheets';import { PLUGIN_NAMES } from '@univer/core';-import { NUMFMT_PLUGIN_NAME } from '../Const';-import { CURRENCYDETAIL, DATEFMTLISG } from '../Const/FORMATDETAIL';+import { NUMFMT_PLUGIN_NAME } from '../Basic/Const';+import { CURRENCYDETAIL, DATEFMTLISG } from '../Basic/Const/FORMATDETAIL';import { NumfmtPlugin } from '../NumfmtPlugin';import { FormatContent } from '../View/UI/FormatContent';import { NumfmtModal } from '../View/UI/NumfmtModal';@@ -27,7 +27,7 @@ export interface ModalDataProps {modal?: ComponentChildren; // 渲染的组件}-export class NumftmModalController {+export class NumfmtModalController {private _plugin: NumfmtPlugin;private _sheetPlugin: SheetPlugin;diff --git a/packages/sheets-plugin-numfmt/src/Model/Apply/SetNumfmtRangeData.ts b/packages/sheets-plugin-numfmt/src/Model/Apply/SetNumfmtRangeData.tsindex f9c497512c..f504bba5a0 100644--- a/packages/sheets-plugin-numfmt/src/Model/Apply/SetNumfmtRangeData.ts+++ b/packages/sheets-plugin-numfmt/src/Model/Apply/SetNumfmtRangeData.ts@@ -1,5 +1,5 @@import { ObjectMatrix, ObjectMatrixPrimitiveType, Workbook } from '@univer/core';-import { NUMFMT_PLUGIN_NAME } from '../../Const';+import { NUMFMT_PLUGIN_NAME } from '../../Basic/Const';import { NumfmtPlugin } from '../../NumfmtPlugin';export function SetNumfmtRangeData(workbook: Workbook, sheetId: string, numfmtPrimitiveMatrix: ObjectMatrixPrimitiveType<string>): ObjectMatrixPrimitiveType<string> {diff --git a/packages/sheets-plugin-numfmt/src/Model/RegisterAction.ts b/packages/sheets-plugin-numfmt/src/Model/RegisterAction.tsindex 919a5c6c2a..276c81f3eb 100644--- a/packages/sheets-plugin-numfmt/src/Model/RegisterAction.ts+++ b/packages/sheets-plugin-numfmt/src/Model/RegisterAction.ts@@ -1,5 +1,5 @@import { CommandManager } from '@univer/core';-import { ACTION_NAMES } from '../Const';+import { ACTION_NAMES } from '../Basic/Enum';import { SetNumfmtRangeDataAction } from './Action/SetNumfmtRangeDataAction';CommandManager.register(ACTION_NAMES.SET_NUMFMT_RANGE_DATA_ACTION, SetNumfmtRangeDataAction);diff --git a/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts b/packages/sheets-plugin-numfmt/src/NumfmtPlugin.tsindex 14e3a3fb1e..1be958d437 100644--- a/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts+++ b/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts@@ -1,15 +1,15 @@import { ActionExtensionManager, SheetContext, IRangeData, ObjectMatrixPrimitiveType, Plugin } from '@univer/core';import { NumfmtPluginObserve, install } from './Basic/Observer';-import { NUMFMT_PLUGIN_NAME } from './Const/PLUGIN_NAME';+import { NUMFMT_PLUGIN_NAME } from './Basic/Const/PLUGIN_NAME';import { NumfmtController } from './Controller/NumfmtController';-import { NumftmModalController } from './Controller/NumfmtModalController';+import { NumfmtModalController } from './Controller/NumfmtModalController';import { en, zh } from './Locale';-import { NumfmtActionExtensionFactory } from './NumfmtActionExtensionFactory';+import { NumfmtActionExtensionFactory } from './Basic/Register/NumfmtActionExtension';export class NumfmtPlugin extends Plugin<NumfmtPluginObserve, SheetContext> {protected _controller: NumfmtController;- private _numftmModalController: NumftmModalController;+ private _NumfmtModalController: NumfmtModalController;protected _numfmtActionExtensionFactory: NumfmtActionExtensionFactory;@@ -26,7 +26,7 @@ export class NumfmtPlugin extends Plugin<NumfmtPluginObserve, SheetContext> {});this._numfmtActionExtensionFactory = new NumfmtActionExtensionFactory(this);- this._numftmModalController = new NumftmModalController(this);+ this._NumfmtModalController = new NumfmtModalController(this);this._controller = new NumfmtController(this);ActionExtensionManager.create().add(this._numfmtActionExtensionFactory);}@@ -49,6 +49,6 @@ export class NumfmtPlugin extends Plugin<NumfmtPluginObserve, SheetContext> {}getNumfmtModalController() {- return this._numftmModalController;+ return this._NumfmtModalController;}}diff --git a/packages/sheets-plugin-numfmt/src/View/UI/NumfmtModal.tsx b/packages/sheets-plugin-numfmt/src/View/UI/NumfmtModal.tsxindex 4f5af715c2..2f238ac470 100644--- a/packages/sheets-plugin-numfmt/src/View/UI/NumfmtModal.tsx+++ b/packages/sheets-plugin-numfmt/src/View/UI/NumfmtModal.tsx@@ -1,7 +1,7 @@import { BaseComponentProps, BaseComponentRender, BaseComponentSheet, Component } from '@univer/base-component';import { SheetPlugin } from '@univer/base-sheets';import { PLUGIN_NAMES } from '@univer/core';-import { NUMFMT_PLUGIN_NAME } from '../../Const';+import { NUMFMT_PLUGIN_NAME } from '../../Basic/Const';import { ModalDataProps } from '../../Controller/NumfmtModalController';import { NumfmtPlugin } from '../../NumfmtPlugin';