Skip to content

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.

fix(base-sheets): number format test

Dushusir017bfa1c4431
diff --git a/packages/base-sheets/package.json b/packages/base-sheets/package.json
index 4e09313945..be640a6afa 100644
--- a/packages/base-sheets/package.json
+++ b/packages/base-sheets/package.json
@@ -24,7 +24,7 @@
"test": "jest",
"test:play": "npx playwright test",
"test:debug": "PWDEBUG=1 npx playwright test",
- "dev": "tsc && vite",
+ "dev": "vite",
"build": "tsc && vite build",
"serve": "vite preview"
},
@@ -53,6 +53,7 @@
"@univer/core": "workspace:^0.0.1",
"@univer/sheets-plugin-clipboard": "workspace:^0.0.1",
"@univer/sheets-plugin-formula": "workspace:^0.0.1",
+ "@univer/sheets-plugin-numfmt": "workspace:^0.0.1",
"@univer/style-universheet": "workspace:^0.0.1",
"css-vars-ponyfill": "^2.4.6",
"nanoid": "4.0.0",
diff --git a/packages/base-sheets/src/Controller/CellEditorController.ts b/packages/base-sheets/src/Controller/CellEditorController.ts
index 3ce96dc32b..8f02fcb69f 100644
--- a/packages/base-sheets/src/Controller/CellEditorController.ts
+++ b/packages/base-sheets/src/Controller/CellEditorController.ts
@@ -13,12 +13,6 @@ const CELL_EDIT_HIDDEN_TOP = -10000;
*
* TODO:
*
- * 1. 注册机制,type='prefix | suffix | regex',
- * type='prefix' pattern='=',注册为公式
- * type='prefix' pattern='$' 注册为货币
- * type='suffix' pattern='%' 注册为百分比
- * type='regex' pattern='/*-*-/g' 注册为日期
- *
* 2. p存储的富文本字符数少于50的情况下,存一份到v,便于vlookup公式计算
*/
export class CellEditorController {
@@ -95,7 +89,6 @@ export class CellEditorController {
?.add((e) => {
const main = this._plugin.getMainComponent();
- // TODO 应该接受selection obs,便于外部注册拦截
main.onDblclickObserver.add((evt: IPointerEvent | IMouseEvent) => {
this.enterEditMode();
});
diff --git a/packages/base-sheets/src/main.tsx b/packages/base-sheets/src/main.tsx
index 7528026bbb..b4c3e8849e 100644
--- a/packages/base-sheets/src/main.tsx
+++ b/packages/base-sheets/src/main.tsx
@@ -4,6 +4,7 @@ import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';
import { UniverComponentSheet } from '@univer/style-universheet';
import { ClipboardPlugin } from '@univer/sheets-plugin-clipboard';
import { DEFAULT_FORMULA_DATA, FormulaPlugin } from '@univer/sheets-plugin-formula';
+import { NumfmtPlugin } from '@univer/sheets-plugin-numfmt';
const uiDefaultConfigUp = {
container: 'universheet-demo-up',
@@ -29,7 +30,9 @@ FormulaPlugin.create(DEFAULT_FORMULA_DATA).installTo(univerSheetUp);
import('./SpreadsheetPlugin').then(({ SpreadsheetPlugin }) => {
let spreadsheetPlugin = new SpreadsheetPlugin(uiDefaultConfigUp);
let clipboardPlugin = new ClipboardPlugin();
+ let numfmtPlugin = new NumfmtPlugin();
univerSheetUp.installPlugin(spreadsheetPlugin);
univerSheetUp.installPlugin(clipboardPlugin);
(window as any).spreadsheetPlugin = spreadsheetPlugin;
+ univerSheetUp.installPlugin(numfmtPlugin);
});
diff --git a/packages/core/src/Command/RegisterActionExtension.ts b/packages/core/src/Command/RegisterActionExtension.ts
index 841b670b66..2208197479 100644
--- a/packages/core/src/Command/RegisterActionExtension.ts
+++ b/packages/core/src/Command/RegisterActionExtension.ts
@@ -1,10 +1,9 @@
-import { FormulaActionExtensionFactory } from './ActionExtension';
-
import { ActionExtensionManager } from './ActionExtensionManager';
const register = ActionExtensionManager.create();
-register.add(
+register
+ .add
// new FormatActionExtensionFactory(),
- new FormulaActionExtensionFactory()
-);
+ // new FormulaActionExtensionFactory()
+ ();
diff --git a/packages/sheets-plugin-numfmt/index.ts b/packages/sheets-plugin-numfmt/index.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/sheets-plugin-numfmt/src/index.d.ts b/packages/sheets-plugin-numfmt/src/index.d.ts
new file mode 100644
index 0000000000..9d20f3e8f2
--- /dev/null
+++ b/packages/sheets-plugin-numfmt/src/index.d.ts
@@ -0,0 +1,2 @@
+export * from './index';
+declare module '@univer/sheets-plugin-numfmt' {}
diff --git a/packages/sheets-plugin-numfmt/src/index.ts b/packages/sheets-plugin-numfmt/src/index.ts
new file mode 100644
index 0000000000..49b33757d2
--- /dev/null
+++ b/packages/sheets-plugin-numfmt/src/index.ts
@@ -0,0 +1 @@
+export * from './NumfmtPlugin';
diff --git a/tsconfig.json b/tsconfig.json
index e21b80af40..a953a681bb 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -15,6 +15,7 @@
{ "path": "./packages/style-universheet/tsconfig.ref.json" },
{ "path": "./packages/sheets-plugin-sort/tsconfig.ref.json" },
{ "path": "./packages/sheets-plugin-filter/tsconfig.ref.json" },
- { "path": "./packages/sheets-plugin-find/tsconfig.ref.json" }
+ { "path": "./packages/sheets-plugin-find/tsconfig.ref.json" },
+ { "path": "./packages/sheets-plugin-numfmt/tsconfig.ref.json" }
]
}