@fileverse-dev/fortune-core 1.1.25 → 1.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1899,7 +1899,7 @@ export function fixColumnStyleOverflowInFreeze(ctx, c1, c2, freeze) {
1899
1899
  return ret;
1900
1900
  }
1901
1901
  export function calcSelectionInfo(ctx, lang) {
1902
- var _a, _b, _c;
1902
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1903
1903
  var selection = ctx.luckysheet_select_save;
1904
1904
  var numberC = 0;
1905
1905
  var count = 0;
@@ -1913,8 +1913,16 @@ export function calcSelectionInfo(ctx, lang) {
1913
1913
  if (r >= data.length || c >= data[0].length) break;
1914
1914
  var ct = (_b = (_a = data[r][c]) === null || _a === void 0 ? void 0 : _a.ct) === null || _b === void 0 ? void 0 : _b.t;
1915
1915
  var value = (_c = data[r][c]) === null || _c === void 0 ? void 0 : _c.m;
1916
+ if ((_f = (_e = (_d = data[r][c]) === null || _d === void 0 ? void 0 : _d.ct) === null || _e === void 0 ? void 0 : _e.fa) === null || _f === void 0 ? void 0 : _f.includes("#,##0")) {
1917
+ if ((_h = (_g = data[r][c]) === null || _g === void 0 ? void 0 : _g.ct) === null || _h === void 0 ? void 0 : _h.s) {
1918
+ value = (_l = (_k = (_j = data[r][c]) === null || _j === void 0 ? void 0 : _j.ct) === null || _k === void 0 ? void 0 : _k.s[0]) === null || _l === void 0 ? void 0 : _l.v;
1919
+ } else {
1920
+ value = (_m = data[r][c]) === null || _m === void 0 ? void 0 : _m.v;
1921
+ }
1922
+ }
1916
1923
  if (ct === "n" || ct === "g" && parseFloat(value).toString() !== "NaN") {
1917
- var valueNumber = parseFloat(value);
1924
+ var removeComma = (value === null || value === void 0 ? void 0 : value.replace(/,/g, "")) || "0";
1925
+ var valueNumber = parseFloat(removeComma);
1918
1926
  count += 1;
1919
1927
  sum += valueNumber;
1920
1928
  max = Math.max(valueNumber, max);
@@ -15,8 +15,8 @@ import { showLinkCard } from "./hyperlink";
15
15
  import { cfSplitRange } from "./conditionalFormat";
16
16
  import { getCellTextInfo } from "./text";
17
17
  export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col_ed, canvas) {
18
- var _a, _b;
19
- var _c;
18
+ var _a, _b, _c, _d;
19
+ var _e;
20
20
  if (_.isNil(d) || _.isNil(attr)) {
21
21
  return;
22
22
  }
@@ -29,7 +29,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
29
29
  var cell = d[r][c];
30
30
  var value = void 0;
31
31
  if (_.isPlainObject(cell)) {
32
- value = cell === null || cell === void 0 ? void 0 : cell.v;
32
+ value = (cell === null || cell === void 0 ? void 0 : cell.v) || ((_b = (_a = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _a === void 0 ? void 0 : _a.s[0]) === null || _b === void 0 ? void 0 : _b.v);
33
33
  } else {
34
34
  value = cell;
35
35
  }
@@ -52,6 +52,12 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
52
52
  }
53
53
  cell.ct.fa = foucsStatus;
54
54
  cell.ct.t = type;
55
+ cell.fc = cell.fc || cell.ct.s[0].fc;
56
+ cell.bl = cell.bl || cell.ct.s[0].bl;
57
+ cell.it = cell.it || cell.ct.s[0].it;
58
+ cell.un = cell.un || cell.ct.s[0].un;
59
+ cell.fs = cell.fs || cell.ct.s[0].fs;
60
+ cell.cl = cell.cl || cell.ct.s[0].cl;
55
61
  } else {
56
62
  d[r][c] = {
57
63
  ct: {
@@ -117,9 +123,9 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
117
123
  if (value && _.isPlainObject(value)) {
118
124
  updateInlineStringFormatOutside(value, attr, foucsStatus);
119
125
  value[attr] = foucsStatus;
120
- (_c = ctx.luckysheetfile[sheetIndex]).config || (_c.config = {});
126
+ (_e = ctx.luckysheetfile[sheetIndex]).config || (_e.config = {});
121
127
  var cfg = ctx.luckysheetfile[sheetIndex].config;
122
- var cellWidth = ((_a = cfg.columnlen) === null || _a === void 0 ? void 0 : _a[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
128
+ var cellWidth = ((_c = cfg.columnlen) === null || _c === void 0 ? void 0 : _c[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
123
129
  if (attr === "fs" && canvas) {
124
130
  var textInfo = getCellTextInfo(d[r][c], canvas, ctx, {
125
131
  r: r,
@@ -128,7 +134,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
128
134
  });
129
135
  if (!textInfo) continue;
130
136
  var rowHeight = _.round(textInfo.textHeightAll);
131
- var currentRowHeight = ((_b = cfg.rowlen) === null || _b === void 0 ? void 0 : _b[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
137
+ var currentRowHeight = ((_d = cfg.rowlen) === null || _d === void 0 ? void 0 : _d[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
132
138
  if (!_.isUndefined(rowHeight) && rowHeight > currentRowHeight && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
133
139
  if (_.isUndefined(cfg.rowlen)) cfg.rowlen = {};
134
140
  _.set(cfg, "rowlen.".concat(r), rowHeight);
@@ -1934,7 +1934,7 @@ function fixColumnStyleOverflowInFreeze(ctx, c1, c2, freeze) {
1934
1934
  return ret;
1935
1935
  }
1936
1936
  function calcSelectionInfo(ctx, lang) {
1937
- var _a, _b, _c;
1937
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1938
1938
  var selection = ctx.luckysheet_select_save;
1939
1939
  var numberC = 0;
1940
1940
  var count = 0;
@@ -1948,8 +1948,16 @@ function calcSelectionInfo(ctx, lang) {
1948
1948
  if (r >= data.length || c >= data[0].length) break;
1949
1949
  var ct = (_b = (_a = data[r][c]) === null || _a === void 0 ? void 0 : _a.ct) === null || _b === void 0 ? void 0 : _b.t;
1950
1950
  var value = (_c = data[r][c]) === null || _c === void 0 ? void 0 : _c.m;
1951
+ if ((_f = (_e = (_d = data[r][c]) === null || _d === void 0 ? void 0 : _d.ct) === null || _e === void 0 ? void 0 : _e.fa) === null || _f === void 0 ? void 0 : _f.includes("#,##0")) {
1952
+ if ((_h = (_g = data[r][c]) === null || _g === void 0 ? void 0 : _g.ct) === null || _h === void 0 ? void 0 : _h.s) {
1953
+ value = (_l = (_k = (_j = data[r][c]) === null || _j === void 0 ? void 0 : _j.ct) === null || _k === void 0 ? void 0 : _k.s[0]) === null || _l === void 0 ? void 0 : _l.v;
1954
+ } else {
1955
+ value = (_m = data[r][c]) === null || _m === void 0 ? void 0 : _m.v;
1956
+ }
1957
+ }
1951
1958
  if (ct === "n" || ct === "g" && parseFloat(value).toString() !== "NaN") {
1952
- var valueNumber = parseFloat(value);
1959
+ var removeComma = (value === null || value === void 0 ? void 0 : value.replace(/,/g, "")) || "0";
1960
+ var valueNumber = parseFloat(removeComma);
1953
1961
  count += 1;
1954
1962
  sum += valueNumber;
1955
1963
  max = Math.max(valueNumber, max);
@@ -48,8 +48,8 @@ var _conditionalFormat = require("./conditionalFormat");
48
48
  var _text = require("./text");
49
49
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
50
50
  function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col_ed, canvas) {
51
- var _a, _b;
52
- var _c;
51
+ var _a, _b, _c, _d;
52
+ var _e;
53
53
  if (_lodash.default.isNil(d) || _lodash.default.isNil(attr)) {
54
54
  return;
55
55
  }
@@ -62,7 +62,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
62
62
  var cell = d[r][c];
63
63
  var value = void 0;
64
64
  if (_lodash.default.isPlainObject(cell)) {
65
- value = cell === null || cell === void 0 ? void 0 : cell.v;
65
+ value = (cell === null || cell === void 0 ? void 0 : cell.v) || ((_b = (_a = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _a === void 0 ? void 0 : _a.s[0]) === null || _b === void 0 ? void 0 : _b.v);
66
66
  } else {
67
67
  value = cell;
68
68
  }
@@ -85,6 +85,12 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
85
85
  }
86
86
  cell.ct.fa = foucsStatus;
87
87
  cell.ct.t = type;
88
+ cell.fc = cell.fc || cell.ct.s[0].fc;
89
+ cell.bl = cell.bl || cell.ct.s[0].bl;
90
+ cell.it = cell.it || cell.ct.s[0].it;
91
+ cell.un = cell.un || cell.ct.s[0].un;
92
+ cell.fs = cell.fs || cell.ct.s[0].fs;
93
+ cell.cl = cell.cl || cell.ct.s[0].cl;
88
94
  } else {
89
95
  d[r][c] = {
90
96
  ct: {
@@ -150,9 +156,9 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
150
156
  if (value && _lodash.default.isPlainObject(value)) {
151
157
  (0, _inlineString.updateInlineStringFormatOutside)(value, attr, foucsStatus);
152
158
  value[attr] = foucsStatus;
153
- (_c = ctx.luckysheetfile[sheetIndex]).config || (_c.config = {});
159
+ (_e = ctx.luckysheetfile[sheetIndex]).config || (_e.config = {});
154
160
  var cfg = ctx.luckysheetfile[sheetIndex].config;
155
- var cellWidth = ((_a = cfg.columnlen) === null || _a === void 0 ? void 0 : _a[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
161
+ var cellWidth = ((_c = cfg.columnlen) === null || _c === void 0 ? void 0 : _c[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
156
162
  if (attr === "fs" && canvas) {
157
163
  var textInfo = (0, _text.getCellTextInfo)(d[r][c], canvas, ctx, {
158
164
  r: r,
@@ -161,7 +167,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
161
167
  });
162
168
  if (!textInfo) continue;
163
169
  var rowHeight = _lodash.default.round(textInfo.textHeightAll);
164
- var currentRowHeight = ((_b = cfg.rowlen) === null || _b === void 0 ? void 0 : _b[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
170
+ var currentRowHeight = ((_d = cfg.rowlen) === null || _d === void 0 ? void 0 : _d[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
165
171
  if (!_lodash.default.isUndefined(rowHeight) && rowHeight > currentRowHeight && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
166
172
  if (_lodash.default.isUndefined(cfg.rowlen)) cfg.rowlen = {};
167
173
  _lodash.default.set(cfg, "rowlen.".concat(r), rowHeight);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.1.25",
3
+ "version": "1.1.27",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",