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.

chore: fix paste text should remove f (#5334)

ybzkyd54440e6f186
diff --git a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts
index d21380d0ac..3660aaa2e6 100644
--- a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts
+++ b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts
@@ -61,6 +61,7 @@ import {
isFormulaString,
IUniverInstanceService,
LocaleService,
+ numfmt,
ObjectMatrix,
RxDisposable,
Tools,
@@ -611,6 +612,8 @@ export class SheetClipboardController extends RxDisposable {
[range.rows[0]]: {
[range.cols[0]]: {
p,
+ v: null,
+ f: null,
},
},
};
@@ -620,17 +623,37 @@ export class SheetClipboardController extends RxDisposable {
[range.rows[0]]: {
[range.cols[0]]: {
f: text,
+ v: null,
+ p: null,
},
},
};
} else {
- cellValue = {
- [range.rows[0]]: {
- [range.cols[0]]: {
- v: text,
+ const pattern = numfmt.parseNumber(text);
+ if (pattern?.z) {
+ cellValue = {
+ [range.rows[0]]: {
+ [range.cols[0]]: {
+ v: pattern.v,
+ s: {
+ n: {
+ pattern: pattern.z,
+ },
+ },
+ f: null,
+ },
},
- },
- };
+ };
+ } else {
+ cellValue = {
+ [range.rows[0]]: {
+ [range.cols[0]]: {
+ v: text,
+ f: null,
+ },
+ },
+ };
+ }
}
}