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(sheet-numfmt-plugin):numfmt plugin optimization
eiji-th5ce7eeac766c
diff --git a/packages/sheets-plugin-numfmt/src/Const/PLUGIN_NAME.ts b/packages/sheets-plugin-numfmt/src/Const/PLUGIN_NAME.tsnew file mode 100644index 0000000000..ffb4c1c1d0--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/Const/PLUGIN_NAME.ts@@ -0,0 +1 @@+export const NUMFMT_PLUGIN_NAME = 'NUMFMT_PLUGIN_NAME';diff --git a/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.ts b/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.tsindex c6cf98a702..63a3368e59 100644--- a/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.ts+++ b/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.ts@@ -1,14 +1,14 @@+import { Plugin } from '@univer/core';import { NumfmtModel, NumfmtValue } from '../Model/NumfmtModel';export class NumfmtController {protected _model: NumfmtModel;- constructor() {- this._model = new NumfmtModel();- }+ protected _plugin: Plugin;- setNumfmt(row: number, column: number, numfmt: string): void {- this._model.setNumfmtValue(row, column, new NumfmtValue(numfmt));+ constructor(plugin: Plugin) {+ this._model = new NumfmtModel();+ this._plugin = plugin;}getColor(row: number, column: number): string {@@ -20,4 +20,8 @@ export class NumfmtController {const numfmt = this._model.getNumfmtValue(row, column);return numfmt ? numfmt.getValue() : String();}++ setNumfmt(row: number, column: number, numfmt: string): void {+ this._model.setNumfmtValue(row, column, new NumfmtValue(numfmt));+ }}diff --git a/packages/sheets-plugin-numfmt/src/Model/Apply/SetNumfmt.ts b/packages/sheets-plugin-numfmt/src/Model/Apply/SetNumfmt.tsindex 2f52b4bac0..1f8eb4c723 100644--- a/packages/sheets-plugin-numfmt/src/Model/Apply/SetNumfmt.ts+++ b/packages/sheets-plugin-numfmt/src/Model/Apply/SetNumfmt.ts@@ -1 +1 @@-export function SetNumfmt() {}+export function SetNumfmt(row: number, column: number) {}diff --git a/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts b/packages/sheets-plugin-numfmt/src/NumfmtPlugin.tsindex de4ff4ce6e..1a838a5129 100644--- a/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts+++ b/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts@@ -1,11 +1,16 @@import { Context, Plugin } from '@univer/core';+import { NUMFMT_PLUGIN_NAME } from './Const/PLUGIN_NAME';import { NumfmtController } from './Controller/NumfmtController';export class NumfmtPlugin extends Plugin {protected _controller: NumfmtController;+ constructor() {+ super(NUMFMT_PLUGIN_NAME);+ }+onMounted(ctx: Context): void {- this._controller = new NumfmtController();+ this._controller = new NumfmtController(this);}getValue(row: number, column: number): string {