@fileverse-dev/fortune-core 1.1.43 → 1.1.45

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.
@@ -177,7 +177,8 @@ export function handleCellAreaMouseDown(ctx, globalCache, e, cellInput, containe
177
177
  var doc = parser.parseFromString("<div>".concat((_g = document.getElementById("luckysheet-rich-text-editor")) === null || _g === void 0 ? void 0 : _g.innerHTML, "</div>"), "text/html");
178
178
  var spans = doc.querySelectorAll("span");
179
179
  var firstSpan = spans[0];
180
- if (ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || israngeseleciton(ctx) || (firstSpan === null || firstSpan === void 0 ? void 0 : firstSpan.innerText.includes("="))) {
180
+ var lastSpan = spans[spans.length - 1];
181
+ if (ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || israngeseleciton(ctx) || (firstSpan === null || firstSpan === void 0 ? void 0 : firstSpan.innerText.includes("=")) && !(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(")"))) {
181
182
  var rowseleted = [row_index, row_index_ed];
182
183
  var columnseleted = [col_index, col_index_ed];
183
184
  var left = col_pre;
@@ -126,6 +126,14 @@ export function setCellValue(ctx, r, c, d, v) {
126
126
  } else {
127
127
  vupdate = v;
128
128
  }
129
+ var commaPresent = false;
130
+ if (vupdate && typeof vupdate === "string" && vupdate.includes(",")) {
131
+ commaPresent = vupdate.includes(",");
132
+ var removeCommasValidated = function removeCommasValidated(str) {
133
+ return /^[\d,]+$/.test(str) ? str === null || str === void 0 ? void 0 : str.replace(/,/g, "") : str;
134
+ };
135
+ vupdate = removeCommasValidated(vupdate);
136
+ }
129
137
  if (isRealNull(vupdate)) {
130
138
  if (_.isPlainObject(cell)) {
131
139
  delete cell.m;
@@ -263,8 +271,18 @@ export function setCellValue(ctx, r, c, d, v) {
263
271
  }
264
272
  }
265
273
  cell.v = vupdate;
274
+ var format = void 0;
275
+ if (String(vupdate).includes(".")) {
276
+ format = "#,##0.00";
277
+ } else if (commaPresent) {
278
+ format = "#,##0.00";
279
+ } else {
280
+ format = "0";
281
+ }
282
+ cell.m = update(format, cell.v);
283
+ cell.ht = 2;
266
284
  cell.ct = {
267
- fa: "General",
285
+ fa: format,
268
286
  t: "n"
269
287
  };
270
288
  if (cell.v === Infinity || cell.v === -Infinity) {
@@ -196,7 +196,8 @@ function handleCellAreaMouseDown(ctx, globalCache, e, cellInput, container, fxIn
196
196
  var doc = parser.parseFromString("<div>".concat((_g = document.getElementById("luckysheet-rich-text-editor")) === null || _g === void 0 ? void 0 : _g.innerHTML, "</div>"), "text/html");
197
197
  var spans = doc.querySelectorAll("span");
198
198
  var firstSpan = spans[0];
199
- if (ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || (0, _modules.israngeseleciton)(ctx) || (firstSpan === null || firstSpan === void 0 ? void 0 : firstSpan.innerText.includes("="))) {
199
+ var lastSpan = spans[spans.length - 1];
200
+ if (ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || (0, _modules.israngeseleciton)(ctx) || (firstSpan === null || firstSpan === void 0 ? void 0 : firstSpan.innerText.includes("=")) && !(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(")"))) {
200
201
  var rowseleted = [row_index, row_index_ed];
201
202
  var columnseleted = [col_index, col_index_ed];
202
203
  var left = col_pre;
@@ -156,6 +156,14 @@ function setCellValue(ctx, r, c, d, v) {
156
156
  } else {
157
157
  vupdate = v;
158
158
  }
159
+ var commaPresent = false;
160
+ if (vupdate && typeof vupdate === "string" && vupdate.includes(",")) {
161
+ commaPresent = vupdate.includes(",");
162
+ var removeCommasValidated = function removeCommasValidated(str) {
163
+ return /^[\d,]+$/.test(str) ? str === null || str === void 0 ? void 0 : str.replace(/,/g, "") : str;
164
+ };
165
+ vupdate = removeCommasValidated(vupdate);
166
+ }
159
167
  if ((0, _validation.isRealNull)(vupdate)) {
160
168
  if (_lodash.default.isPlainObject(cell)) {
161
169
  delete cell.m;
@@ -293,8 +301,18 @@ function setCellValue(ctx, r, c, d, v) {
293
301
  }
294
302
  }
295
303
  cell.v = vupdate;
304
+ var format = void 0;
305
+ if (String(vupdate).includes(".")) {
306
+ format = "#,##0.00";
307
+ } else if (commaPresent) {
308
+ format = "#,##0.00";
309
+ } else {
310
+ format = "0";
311
+ }
312
+ cell.m = (0, _format.update)(format, cell.v);
313
+ cell.ht = 2;
296
314
  cell.ct = {
297
- fa: "General",
315
+ fa: format,
298
316
  t: "n"
299
317
  };
300
318
  if (cell.v === Infinity || cell.v === -Infinity) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.1.43",
3
+ "version": "1.1.45",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",