-
-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: copy number with text format to a cell with text format #475
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @gazedreamily
Let's make it more general rather than being specific to ".fa === '@'"
Check if the cell has ct
, if so, use update
to generate the mask, otherwise, use generate
59ca1d3
to
454e2d7
Compare
Thaks for your advice! |
@gazedreamily I don't think you get what I mean. diff --git a/packages/core/src/events/paste.ts b/packages/core/src/events/paste.ts
index 54641b0..8c51af7 100644
--- a/packages/core/src/events/paste.ts
+++ b/packages/core/src/events/paste.ts
@@ -318,6 +318,14 @@ function pasteHandler(ctx: Context, data: any, borderInfo?: any) {
value = data[h - minh][c - minc];
}
+ if (x[c]?.ct?.fa != null && x[c]?.ct?.fa !== value.ct?.fa) {
+ value.m = update(x[c]?.ct?.fa!, value.raw || value.v);
+ value.ct = x[c]?.ct;
+ if (x[c]?.ct?.t === "s" && value.raw) {
+ value.v = value.raw;
+ }
+ }
+ delete value.raw;
x[c] = value;
if (value != null && x?.[c]?.mc) {
@@ -1782,6 +1790,8 @@ export function _handlePaste(ctx: Context, htmlText?: string, plainText?: string
[cell.m, cell.ct, cell.v] = mask;
}
+ // @ts-ignore
+ cell.raw = txt;
const styleString =
typeof allStyleList[`.${className}`] === "string"
? allStyleList[`.${className}`] |
454e2d7
to
25e0525
Compare
@zyc9012 I think that we shouldn't change the format which the user set to the cell. I do the steps in Excel.
|
@gazedreamily We are talking about paste here. Try pasting a string to the |
@zyc9012 It is still |
@gazedreamily I tried several scenarios
|
@zyc9012 change the type of the cell before copy a value into it |
@gazedreamily That's exactly what I did |
@zyc9012 Oh! My fault, you are right! |
25e0525
to
f296b24
Compare
471416d
to
829cacb
Compare
copy number with text format to a cell with text format will not auto generate cell type
before:
When we copy "001" to a cell with text format, the cell will be convert to a number type and the value will be "1".
after
The cell will stay text format and the number will still stay "001".