@fileverse-dev/fortune-core 1.3.12 → 1.3.13

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.
Files changed (43) hide show
  1. package/es/events/keyboard.js +60 -37
  2. package/es/events/mouse.js +1 -0
  3. package/es/events/paste.js +47 -28
  4. package/es/locale/en.d.ts +3 -0
  5. package/es/locale/en.js +3 -0
  6. package/es/locale/es.d.ts +3 -0
  7. package/es/locale/es.js +3 -0
  8. package/es/locale/hi.d.ts +3 -0
  9. package/es/locale/hi.js +3 -0
  10. package/es/locale/index.d.ts +3 -0
  11. package/es/locale/zh.d.ts +3 -0
  12. package/es/locale/zh.js +3 -0
  13. package/es/locale/zh_tw.d.ts +3 -0
  14. package/es/locale/zh_tw.js +3 -0
  15. package/es/modules/ConditionFormat.js +26 -0
  16. package/es/modules/cell.js +1 -1
  17. package/es/modules/format.js +12 -7
  18. package/es/modules/selection.js +9 -3
  19. package/es/modules/validation.js +6 -3
  20. package/es/paste-table-helpers.js +39 -1
  21. package/es/types.d.ts +2 -0
  22. package/lib/events/keyboard.js +60 -37
  23. package/lib/events/mouse.js +1 -0
  24. package/lib/events/paste.js +45 -26
  25. package/lib/locale/en.d.ts +3 -0
  26. package/lib/locale/en.js +3 -0
  27. package/lib/locale/es.d.ts +3 -0
  28. package/lib/locale/es.js +3 -0
  29. package/lib/locale/hi.d.ts +3 -0
  30. package/lib/locale/hi.js +3 -0
  31. package/lib/locale/index.d.ts +3 -0
  32. package/lib/locale/zh.d.ts +3 -0
  33. package/lib/locale/zh.js +3 -0
  34. package/lib/locale/zh_tw.d.ts +3 -0
  35. package/lib/locale/zh_tw.js +3 -0
  36. package/lib/modules/ConditionFormat.js +26 -0
  37. package/lib/modules/cell.js +1 -1
  38. package/lib/modules/format.js +12 -7
  39. package/lib/modules/selection.js +9 -3
  40. package/lib/modules/validation.js +6 -3
  41. package/lib/paste-table-helpers.js +39 -1
  42. package/lib/types.d.ts +2 -0
  43. package/package.json +1 -1
@@ -1221,7 +1221,7 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
1221
1221
  cpdata += "<tr height=".concat(rowLen, "px >");
1222
1222
  var _loop_3 = function _loop_3(j) {
1223
1223
  var c = colIndexArr[j];
1224
- var column = '<td ${span} style="${style}">';
1224
+ var column = '<td ${span} style="${style}" data-fortune-cell="${cellData}">';
1225
1225
  var cell = (_f = d[r]) === null || _f === void 0 ? void 0 : _f[c];
1226
1226
  if (cell != null) {
1227
1227
  var style = "";
@@ -1432,9 +1432,14 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
1432
1432
  }
1433
1433
  }
1434
1434
  }
1435
+ var cellData = encodeURIComponent(JSON.stringify(__assign(__assign({}, cell), {
1436
+ _srcRow: r,
1437
+ _srcCol: c
1438
+ })));
1435
1439
  column = (0, _utils.replaceHtml)(column, {
1436
1440
  style: style,
1437
- span: span
1441
+ span: span,
1442
+ cellData: cellData
1438
1443
  });
1439
1444
  if (_lodash.default.isNil(c_value)) {
1440
1445
  c_value = (0, _cell.getCellValue)(r, c, d);
@@ -1484,7 +1489,8 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
1484
1489
  }
1485
1490
  column = (0, _utils.replaceHtml)(column, {
1486
1491
  style: style,
1487
- span: ""
1492
+ span: "",
1493
+ cellData: ""
1488
1494
  });
1489
1495
  column += "";
1490
1496
  }
@@ -84,6 +84,7 @@ var MONTH_NAME_MAP = {
84
84
  };
85
85
  var MONTH_NAMES_RE = "january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|oct|nov|dec";
86
86
  var MONTH_ABBR_RE = "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec";
87
+ var MONTH_ABBR_SET = new Set(MONTH_ABBR_RE.split("|"));
87
88
  function isValidDateParts(year, month, day) {
88
89
  if (year < 1900) return false;
89
90
  if (month < 1 || month > 12) return false;
@@ -298,6 +299,7 @@ function detectDateFormat(str) {
298
299
  var d = +m[2];
299
300
  var y = +m[3];
300
301
  if (mo && isValidDateParts(y, mo, d)) {
302
+ var isAbbr = MONTH_ABBR_SET.has(m[1].toLowerCase());
301
303
  return {
302
304
  year: y,
303
305
  month: mo,
@@ -305,7 +307,7 @@ function detectDateFormat(str) {
305
307
  hours: 0,
306
308
  minutes: 0,
307
309
  seconds: 0,
308
- formatType: "named"
310
+ formatType: isAbbr ? "named-mdy-abbr" : "named-mdy-full"
309
311
  };
310
312
  }
311
313
  }
@@ -315,6 +317,7 @@ function detectDateFormat(str) {
315
317
  var mo = MONTH_NAME_MAP[m[2].toLowerCase()];
316
318
  var y = +m[3];
317
319
  if (mo && isValidDateParts(y, mo, d)) {
320
+ var isAbbr = MONTH_ABBR_SET.has(m[2].toLowerCase());
318
321
  return {
319
322
  year: y,
320
323
  month: mo,
@@ -322,7 +325,7 @@ function detectDateFormat(str) {
322
325
  hours: 0,
323
326
  minutes: 0,
324
327
  seconds: 0,
325
- formatType: "named"
328
+ formatType: isAbbr ? "named-dmy-abbr" : "named-dmy-full"
326
329
  };
327
330
  }
328
331
  }
@@ -339,7 +342,7 @@ function detectDateFormat(str) {
339
342
  hours: 0,
340
343
  minutes: 0,
341
344
  seconds: 0,
342
- formatType: "named"
345
+ formatType: "named-abbr-dashes"
343
346
  };
344
347
  }
345
348
  }
@@ -10,6 +10,7 @@ var _locale = require("./locale");
10
10
  var _modules = require("./modules");
11
11
  var _utils = require("./utils");
12
12
  var _api = require("./api");
13
+ var _paste = require("./events/paste");
13
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
15
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
15
16
  var __assign = void 0 && (void 0).__assign || function () {
@@ -22,6 +23,14 @@ var __assign = void 0 && (void 0).__assign || function () {
22
23
  };
23
24
  return __assign.apply(this, arguments);
24
25
  };
26
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
27
+ var t = {};
28
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
30
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
31
+ }
32
+ return t;
33
+ };
25
34
  var DEFAULT_FONT_SIZE = exports.DEFAULT_FONT_SIZE = 12;
26
35
  var parseStylesheetPairs = function parseStylesheetPairs(styleInner) {
27
36
  var patternReg = /{([^}]*)}/g;
@@ -135,6 +144,28 @@ function brToNewline(str) {
135
144
  }
136
145
  var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
137
146
  var _a, _b, _c, _d;
147
+ var fortuneCellAttr = td.getAttribute("data-fortune-cell");
148
+ if (fortuneCellAttr) {
149
+ try {
150
+ var _e = JSON.parse(decodeURIComponent(fortuneCellAttr)),
151
+ _srcRow = _e._srcRow,
152
+ _srcCol = _e._srcCol,
153
+ parsed = __rest(_e, ["_srcRow", "_srcCol"]);
154
+ var cell_1 = parsed;
155
+ delete cell_1.mc;
156
+ delete cell_1.hl;
157
+ var rowspan_1 = parseInt(td.getAttribute("rowspan") || "1", 10);
158
+ var colspan_1 = parseInt(td.getAttribute("colspan") || "1", 10);
159
+ return {
160
+ cell: cell_1,
161
+ rowspan: Number.isNaN(rowspan_1) ? 1 : rowspan_1,
162
+ colspan: Number.isNaN(colspan_1) ? 1 : colspan_1,
163
+ hyperlink: detectHyperlink(td),
164
+ srcRow: _srcRow,
165
+ srcCol: _srcCol
166
+ };
167
+ } catch (_f) {}
168
+ }
138
169
  var cell = {};
139
170
  var rawText = (td.innerText || td.innerHTML || "").trim();
140
171
  var isLineBreak = rawText.includes("<br />");
@@ -285,10 +316,17 @@ function handlePastedTable(ctx, html, pasteHandler) {
285
316
  cell = _a.cell,
286
317
  rowspan = _a.rowspan,
287
318
  colspan = _a.colspan,
288
- hyperlink = _a.hyperlink;
319
+ hyperlink = _a.hyperlink,
320
+ srcRow = _a.srcRow,
321
+ srcCol = _a.srcCol;
289
322
  var anchorCol = ctx.luckysheet_select_save[0].column[0];
290
323
  var absoluteRow = anchorRow + localRowIndex;
291
324
  var absoluteCol = anchorCol + localColIndex;
325
+ if (cell.f && srcRow != null && srcCol != null) {
326
+ try {
327
+ cell.f = (0, _paste.adjustFormulaForPaste)(cell.f, srcCol, srcRow, absoluteCol, absoluteRow);
328
+ } catch (_b) {}
329
+ }
292
330
  pastedMatrix[localRowIndex][localColIndex] = cell;
293
331
  if (hyperlink) {
294
332
  (0, _modules.saveHyperlink)(ctx, absoluteRow, absoluteCol, hyperlink.href, "webpage", hyperlink.display);
package/lib/types.d.ts CHANGED
@@ -328,6 +328,8 @@ export type GlobalCache = {
328
328
  verticalScrollLock?: boolean;
329
329
  horizontalScrollLock?: boolean;
330
330
  overwriteCell?: boolean;
331
+ overwriteCellFirstChar?: string;
332
+ enteredEditByTyping?: boolean;
331
333
  ignoreWriteCell?: boolean;
332
334
  doNotFocus?: boolean;
333
335
  doNotUpdateCell?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.3.12",
3
+ "version": "1.3.13",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",