@fileverse-dev/fortune-core 1.3.5 → 1.3.6-right

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.
@@ -6,3 +6,4 @@ export declare function getSelectionCharacterOffsets(element: Node): {
6
6
  end: number;
7
7
  } | null;
8
8
  export declare function setSelectionByCharacterOffset(element: HTMLDivElement, start: number, end: number): void;
9
+ export declare function getRangeRectsByCharacterOffset(element: HTMLDivElement, start: number, end: number): DOMRect[];
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.getRangeRectsByCharacterOffset = getRangeRectsByCharacterOffset;
6
7
  exports.getSelectionCharacterOffsets = getSelectionCharacterOffsets;
7
8
  exports.moveToEnd = moveToEnd;
8
9
  exports.selectTextContent = selectTextContent;
@@ -124,4 +125,39 @@ function setSelectionByCharacterOffset(element, start, end) {
124
125
  sel.removeAllRanges();
125
126
  sel.addRange(range);
126
127
  }
128
+ }
129
+ function getRangeRectsByCharacterOffset(element, start, end) {
130
+ if (start >= end) return [];
131
+ var charIndex = 0;
132
+ var startNode = null;
133
+ var startOffset = 0;
134
+ var endNode = null;
135
+ var endOffset = 0;
136
+ function walk(node) {
137
+ if (node.nodeType === Node.TEXT_NODE) {
138
+ var len = (node.textContent || "").length;
139
+ if (startNode == null && charIndex + len > start) {
140
+ startNode = node;
141
+ startOffset = start - charIndex;
142
+ }
143
+ if (endNode == null && charIndex + len >= end) {
144
+ endNode = node;
145
+ endOffset = end - charIndex;
146
+ return true;
147
+ }
148
+ charIndex += len;
149
+ return false;
150
+ }
151
+ for (var i = 0; i < node.childNodes.length; i += 1) {
152
+ if (walk(node.childNodes[i])) return true;
153
+ }
154
+ return false;
155
+ }
156
+ walk(element);
157
+ if (!startNode || !endNode) return [];
158
+ var range = document.createRange();
159
+ range.setStart(startNode, startOffset);
160
+ range.setEnd(endNode, endOffset);
161
+ var rects = range.getClientRects();
162
+ return Array.from(rects);
127
163
  }
@@ -21,29 +21,6 @@ function datenum_local(v, date1904) {
21
21
  if (date1904) epoch -= 1461 * 24 * 60 * 60 * 1000;else if (v >= base1904) epoch += 24 * 60 * 60 * 1000;
22
22
  return (epoch - dnthresh_utc) / (24 * 60 * 60 * 1000);
23
23
  }
24
- var good_pd_date = new Date("2017-02-19T19:06:09.000Z");
25
- if (Number.isNaN(good_pd_date.getFullYear())) good_pd_date = new Date("2/19/17");
26
- var good_pd = good_pd_date.getFullYear() === 2017;
27
- function parseDate(str, fixdate) {
28
- var d = new Date(str);
29
- if (good_pd) {
30
- if (!_lodash.default.isNil(fixdate)) {
31
- if (fixdate > 0) d.setTime(d.getTime() + d.getTimezoneOffset() * 60 * 1000);else if (fixdate < 0) d.setTime(d.getTime() - d.getTimezoneOffset() * 60 * 1000);
32
- }
33
- return d;
34
- }
35
- if (str instanceof Date) return str;
36
- if (good_pd_date.getFullYear() === 1917 && !Number.isNaN(d.getFullYear())) {
37
- var s = d.getFullYear();
38
- if (str.indexOf("".concat(s)) > -1) return d;
39
- d.setFullYear(d.getFullYear() + 100);
40
- return d;
41
- }
42
- var n = str.match(/\d+/g) || ["2017", "2", "19", "0", "0", "0"];
43
- var out = new Date(+n[0], +n[1] - 1, +n[2], +n[3] || 0, +n[4] || 0, +n[5] || 0);
44
- if (str.indexOf("Z") > -1) out = new Date(out.getTime() - out.getTimezoneOffset() * 60 * 1000);
45
- return out;
46
- }
47
24
  function genarate(value) {
48
25
  var m = null;
49
26
  var ct = {};
@@ -267,23 +244,37 @@ function genarate(value) {
267
244
  t: "n"
268
245
  };
269
246
  v = parseFloat(value);
270
- } else if ((0, _validation.isdatetime)(value) && (value.toString().indexOf(".") > -1 || value.toString().indexOf(":") > -1 || value.toString().length < 16)) {
271
- v = datenum_local(parseDate(value.toString().replace(/-/g, "/")));
272
- if (v.toString().indexOf(".") > -1) {
273
- if (value.toString().length > 18) {
274
- ct.fa = "yyyy-MM-dd hh:mm:ss";
275
- } else if (value.toString().length > 11) {
276
- ct.fa = "yyyy-MM-dd hh:mm";
277
- } else {
278
- ct.fa = "yyyy-MM-dd";
279
- }
247
+ } else if (typeof value === "string") {
248
+ var df = (0, _validation.detectDateFormat)(value.toString());
249
+ if (df) {
250
+ var dateObj = new Date(df.year, df.month - 1, df.day, df.hours, df.minutes, df.seconds);
251
+ v = datenum_local(dateObj);
252
+ ct.t = "d";
253
+ var map = {
254
+ "yyyy-MM-dd": "dd/MM/yyyy",
255
+ "yyyy-MM-dd HH:mm": "dd/MM/yyyy",
256
+ "yyyy-MM-ddTHH:mm": "dd/MM/yyyy",
257
+ "yyyy/MM/dd": "dd/MM/yyyy",
258
+ "yyyy/MM/dd HH:mm": "dd/MM/yyyy",
259
+ "yyyy.MM.dd": "yyyy.MM.dd",
260
+ "MM/dd/yyyy h:mm AM/PM": "MM/dd/yyyy h:mm AM/PM",
261
+ "MM/dd/yyyy": "MM/dd/yyyy",
262
+ "M/d/yyyy": "M/d/yyyy",
263
+ "MM/dd/yy": "MM/dd/yy",
264
+ "dd/MM/yyyy": "dd/MM/yyyy",
265
+ "dd-MM-yyyy": "dd/MM/yyyy",
266
+ "dd.MM.yyyy": "dd.MM.yyyy",
267
+ named: "dd/MM/yyyy"
268
+ };
269
+ ct.fa = map[df.formatType] || "dd/MM/yyyy";
270
+ m = _ssf.default.format(ct.fa, v);
280
271
  } else {
281
- ct.fa = "yyyy-MM-dd";
272
+ m = String(value);
273
+ ct.fa = "General";
274
+ ct.t = "g";
282
275
  }
283
- ct.t = "d";
284
- m = _ssf.default.format(ct.fa, v);
285
276
  } else {
286
- m = value;
277
+ m = String(value);
287
278
  ct.fa = "General";
288
279
  ct.t = "g";
289
280
  }
@@ -13,14 +13,14 @@ export declare function saveHyperlink(ctx: Context, r: number, c: number, linkTe
13
13
  cellInput?: HTMLDivElement | null;
14
14
  }): void;
15
15
  export declare function removeHyperlink(ctx: Context, r: number, c: number): void;
16
- export declare function showLinkCard(ctx: Context, r: number, c: number, isEditing?: boolean, isMouseDown?: boolean, options?: {
16
+ export declare function showLinkCard(ctx: Context, r: number, c: number, options?: {
17
17
  applyToSelection?: boolean;
18
18
  originText?: string;
19
19
  selectionOffsets?: {
20
20
  start: number;
21
21
  end: number;
22
22
  };
23
- }): void;
23
+ }, isEditing?: boolean, isMouseDown?: boolean): void;
24
24
  export declare function goToLink(ctx: Context, r: number, c: number, linkType: string, linkAddress: string, scrollbarX: HTMLDivElement, scrollbarY: HTMLDivElement): void;
25
25
  export declare function isLinkValid(ctx: Context, linkType: string, linkAddress: string): {
26
26
  isValid: boolean;
@@ -127,7 +127,7 @@ function removeHyperlink(ctx, r, c) {
127
127
  }
128
128
  ctx.linkCard = undefined;
129
129
  }
130
- function showLinkCard(ctx, r, c, isEditing, isMouseDown, options) {
130
+ function showLinkCard(ctx, r, c, options, isEditing, isMouseDown) {
131
131
  var _a, _b, _c, _d, _e, _f, _g, _h;
132
132
  if (isEditing === void 0) {
133
133
  isEditing = false;
@@ -146,7 +146,11 @@ function showLinkCard(ctx, r, c, isEditing, isMouseDown, options) {
146
146
  if (isEditing || link != null && (!((_f = ctx.linkCard) === null || _f === void 0 ? void 0 : _f.isEditing) || isMouseDown) || ((_g = ctx.linkCard) === null || _g === void 0 ? void 0 : _g.sheetId) !== ctx.currentSheetId) {
147
147
  var col_pre = c - 1 === -1 ? 0 : ctx.visibledatacolumn[c - 1];
148
148
  var row = ctx.visibledatarow[r];
149
- var originText = (options === null || options === void 0 ? void 0 : options.originText) !== undefined ? options.originText : (cell === null || cell === void 0 ? void 0 : cell.v) == null ? "" : "".concat(cell.v);
149
+ var originText = function () {
150
+ if ((options === null || options === void 0 ? void 0 : options.originText) !== undefined) return options.originText;
151
+ if ((cell === null || cell === void 0 ? void 0 : cell.v) == null) return "";
152
+ return "".concat(cell.v);
153
+ }();
150
154
  ctx.linkCard = {
151
155
  sheetId: ctx.currentSheetId,
152
156
  r: r,
@@ -1576,6 +1576,8 @@ function deleteSelectedCellText(ctx) {
1576
1576
  var cell = d[r][c];
1577
1577
  delete cell.m;
1578
1578
  delete cell.v;
1579
+ delete cell.fc;
1580
+ delete cell.un;
1579
1581
  if (cell.f != null) {
1580
1582
  delete cell.f;
1581
1583
  (0, _formula.delFunctionGroup)(ctx, r, c, ctx.currentSheetId);
@@ -1648,6 +1650,8 @@ function deleteSelectedCellFormat(ctx) {
1648
1650
  return "success";
1649
1651
  }
1650
1652
  function fillRightData(ctx) {
1653
+ var _a, _b, _c, _d;
1654
+ var _e, _f, _g;
1651
1655
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
1652
1656
  if (allowEdit === false) {
1653
1657
  return "allowEdit";
@@ -1675,10 +1679,111 @@ function fillRightData(ctx) {
1675
1679
  var r2 = selection[s].row[1];
1676
1680
  var c1 = selection[s].column[0];
1677
1681
  var c2 = selection[s].column[1];
1678
- for (var r = r1; r <= r2; r += 1) {
1679
- for (var c = c1; c <= c2; c += 1) {
1680
- var previousCell = d[r][c - 1];
1681
- d[r][c] = __assign({}, previousCell);
1682
+ var sheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
1683
+ var file = sheetIndex != null ? ctx.luckysheetfile[sheetIndex] : null;
1684
+ var dataVerification = file === null || file === void 0 ? void 0 : file.dataVerification;
1685
+ var hyperlink = file === null || file === void 0 ? void 0 : file.hyperlink;
1686
+ var cdformat = file === null || file === void 0 ? void 0 : file.luckysheet_conditionformat_save;
1687
+ var isSingleCell = r1 === r2 && c1 === c2;
1688
+ if (isSingleCell) {
1689
+ if (c1 - 1 >= 0 && d[r1]) {
1690
+ var srcRow = r1;
1691
+ var srcCol = c1 - 1;
1692
+ var prev = d[r1][c1 - 1];
1693
+ d[r1][c1] = prev != null ? __assign({}, prev) : {};
1694
+ if (file != null) {
1695
+ var srcKey = "".concat(srcRow, "_").concat(srcCol);
1696
+ var tgtKey = "".concat(r1, "_").concat(c1);
1697
+ if (dataVerification != null) {
1698
+ var dv = dataVerification[srcKey];
1699
+ if (dv != null) {
1700
+ console.log("[fillRightData] dataVerification copy from", {
1701
+ row: srcRow,
1702
+ col: srcCol
1703
+ }, "→", {
1704
+ row: r1,
1705
+ col: c1
1706
+ }, dv);
1707
+ file.dataVerification = __assign(__assign({}, file.dataVerification || {}), (_a = {}, _a[tgtKey] = _lodash.default.cloneDeep(dv), _a));
1708
+ }
1709
+ }
1710
+ if (hyperlink != null && hyperlink[srcKey] != null) {
1711
+ file.hyperlink = __assign(__assign({}, file.hyperlink || {}), (_b = {}, _b[tgtKey] = _lodash.default.cloneDeep(hyperlink[srcKey]), _b));
1712
+ var tgtCell = d[r1][c1];
1713
+ if (tgtCell != null) tgtCell.hl = {
1714
+ r: r1,
1715
+ c: c1,
1716
+ id: ctx.currentSheetId
1717
+ };
1718
+ }
1719
+ if (cdformat != null && cdformat.length > 0) {
1720
+ for (var i = 0; i < cdformat.length; i += 1) {
1721
+ var ranges = cdformat[i].cellrange;
1722
+ if (!ranges) continue;
1723
+ for (var j = 0; j < ranges.length; j += 1) {
1724
+ var cr = ranges[j];
1725
+ if (srcRow >= cr.row[0] && srcRow <= cr.row[1] && srcCol >= cr.column[0] && srcCol <= cr.column[1]) {
1726
+ ranges.push({
1727
+ row: [r1, r1],
1728
+ column: [c1, c1]
1729
+ });
1730
+ break;
1731
+ }
1732
+ }
1733
+ }
1734
+ }
1735
+ }
1736
+ }
1737
+ } else {
1738
+ for (var r = r1; r <= r2; r += 1) {
1739
+ var sourceCell = (_e = d[r]) === null || _e === void 0 ? void 0 : _e[c1];
1740
+ for (var c = c1 + 1; c <= c2; c += 1) {
1741
+ if (d[r]) {
1742
+ d[r][c] = sourceCell != null ? __assign({}, sourceCell) : (_f = d[r][c]) !== null && _f !== void 0 ? _f : {};
1743
+ }
1744
+ if (file != null) {
1745
+ var srcKey = "".concat(r, "_").concat(c1);
1746
+ var tgtKey = "".concat(r, "_").concat(c);
1747
+ if (dataVerification != null) {
1748
+ var dv = dataVerification[srcKey];
1749
+ if (dv != null) {
1750
+ console.log("[fillRightData] dataVerification copy from", {
1751
+ row: r,
1752
+ col: c1
1753
+ }, "→", {
1754
+ row: r,
1755
+ col: c
1756
+ }, dv);
1757
+ file.dataVerification = __assign(__assign({}, file.dataVerification || {}), (_c = {}, _c[tgtKey] = _lodash.default.cloneDeep(dv), _c));
1758
+ }
1759
+ }
1760
+ if (hyperlink != null && hyperlink[srcKey] != null) {
1761
+ file.hyperlink = __assign(__assign({}, file.hyperlink || {}), (_d = {}, _d[tgtKey] = _lodash.default.cloneDeep(hyperlink[srcKey]), _d));
1762
+ var tgtCell = (_g = d[r]) === null || _g === void 0 ? void 0 : _g[c];
1763
+ if (tgtCell != null) tgtCell.hl = {
1764
+ r: r,
1765
+ c: c,
1766
+ id: ctx.currentSheetId
1767
+ };
1768
+ }
1769
+ if (cdformat != null && cdformat.length > 0) {
1770
+ for (var i = 0; i < cdformat.length; i += 1) {
1771
+ var ranges = cdformat[i].cellrange;
1772
+ if (!ranges) continue;
1773
+ for (var j = 0; j < ranges.length; j += 1) {
1774
+ var cr = ranges[j];
1775
+ if (r >= cr.row[0] && r <= cr.row[1] && c1 >= cr.column[0] && c1 <= cr.column[1]) {
1776
+ ranges.push({
1777
+ row: [r, r],
1778
+ column: [c, c]
1779
+ });
1780
+ break;
1781
+ }
1782
+ }
1783
+ }
1784
+ }
1785
+ }
1786
+ }
1682
1787
  }
1683
1788
  }
1684
1789
  }
@@ -1686,6 +1791,8 @@ function fillRightData(ctx) {
1686
1791
  return "success";
1687
1792
  }
1688
1793
  function fillDownData(ctx) {
1794
+ var _a, _b, _c, _d;
1795
+ var _e, _f, _g;
1689
1796
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
1690
1797
  if (allowEdit === false) {
1691
1798
  return "allowEdit";
@@ -1713,10 +1820,111 @@ function fillDownData(ctx) {
1713
1820
  var r2 = selection[s].row[1];
1714
1821
  var c1 = selection[s].column[0];
1715
1822
  var c2 = selection[s].column[1];
1716
- for (var r = r1; r <= r2; r += 1) {
1823
+ var sheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
1824
+ var file = sheetIndex != null ? ctx.luckysheetfile[sheetIndex] : null;
1825
+ var dataVerification = file === null || file === void 0 ? void 0 : file.dataVerification;
1826
+ var hyperlink = file === null || file === void 0 ? void 0 : file.hyperlink;
1827
+ var cdformat = file === null || file === void 0 ? void 0 : file.luckysheet_conditionformat_save;
1828
+ var isSingleCell = r1 === r2 && c1 === c2;
1829
+ if (isSingleCell) {
1830
+ if (r1 - 1 >= 0 && d[r1 - 1]) {
1831
+ var srcRow = r1 - 1;
1832
+ var srcCol = c1;
1833
+ var prev = d[r1 - 1][c1];
1834
+ if (!d[r1]) d[r1] = [];
1835
+ d[r1][c1] = prev != null ? __assign({}, prev) : {};
1836
+ if (file != null) {
1837
+ var srcKey = "".concat(srcRow, "_").concat(srcCol);
1838
+ var tgtKey = "".concat(r1, "_").concat(c1);
1839
+ if (dataVerification != null) {
1840
+ var dv = dataVerification[srcKey];
1841
+ if (dv != null) {
1842
+ console.log("[fillDownData] dataVerification copy from", {
1843
+ row: srcRow,
1844
+ col: srcCol
1845
+ }, "→", {
1846
+ row: r1,
1847
+ col: c1
1848
+ }, dv);
1849
+ file.dataVerification = __assign(__assign({}, file.dataVerification || {}), (_a = {}, _a[tgtKey] = _lodash.default.cloneDeep(dv), _a));
1850
+ }
1851
+ }
1852
+ if (hyperlink != null && hyperlink[srcKey] != null) {
1853
+ file.hyperlink = __assign(__assign({}, file.hyperlink || {}), (_b = {}, _b[tgtKey] = _lodash.default.cloneDeep(hyperlink[srcKey]), _b));
1854
+ var tgtCell = d[r1][c1];
1855
+ if (tgtCell != null) tgtCell.hl = {
1856
+ r: r1,
1857
+ c: c1,
1858
+ id: ctx.currentSheetId
1859
+ };
1860
+ }
1861
+ if (cdformat != null && cdformat.length > 0) {
1862
+ for (var i = 0; i < cdformat.length; i += 1) {
1863
+ var ranges = cdformat[i].cellrange;
1864
+ if (!ranges) continue;
1865
+ for (var j = 0; j < ranges.length; j += 1) {
1866
+ var cr = ranges[j];
1867
+ if (srcRow >= cr.row[0] && srcRow <= cr.row[1] && srcCol >= cr.column[0] && srcCol <= cr.column[1]) {
1868
+ ranges.push({
1869
+ row: [r1, r1],
1870
+ column: [c1, c1]
1871
+ });
1872
+ break;
1873
+ }
1874
+ }
1875
+ }
1876
+ }
1877
+ }
1878
+ }
1879
+ } else {
1717
1880
  for (var c = c1; c <= c2; c += 1) {
1718
- var previousCell = d[r - 1][c];
1719
- d[r][c] = __assign({}, previousCell);
1881
+ var sourceCell = (_e = d[r1]) === null || _e === void 0 ? void 0 : _e[c];
1882
+ for (var r = r1 + 1; r <= r2; r += 1) {
1883
+ if (!d[r]) d[r] = [];
1884
+ d[r][c] = sourceCell != null ? __assign({}, sourceCell) : (_f = d[r][c]) !== null && _f !== void 0 ? _f : {};
1885
+ if (file != null) {
1886
+ var srcKey = "".concat(r1, "_").concat(c);
1887
+ var tgtKey = "".concat(r, "_").concat(c);
1888
+ if (dataVerification != null) {
1889
+ var dv = dataVerification[srcKey];
1890
+ if (dv != null) {
1891
+ console.log("[fillDownData] dataVerification copy from", {
1892
+ row: r1,
1893
+ col: c
1894
+ }, "→", {
1895
+ row: r,
1896
+ col: c
1897
+ }, dv);
1898
+ file.dataVerification = __assign(__assign({}, file.dataVerification || {}), (_c = {}, _c[tgtKey] = _lodash.default.cloneDeep(dv), _c));
1899
+ }
1900
+ }
1901
+ if (hyperlink != null && hyperlink[srcKey] != null) {
1902
+ file.hyperlink = __assign(__assign({}, file.hyperlink || {}), (_d = {}, _d[tgtKey] = _lodash.default.cloneDeep(hyperlink[srcKey]), _d));
1903
+ var tgtCell = (_g = d[r]) === null || _g === void 0 ? void 0 : _g[c];
1904
+ if (tgtCell != null) tgtCell.hl = {
1905
+ r: r,
1906
+ c: c,
1907
+ id: ctx.currentSheetId
1908
+ };
1909
+ }
1910
+ if (cdformat != null && cdformat.length > 0) {
1911
+ for (var i = 0; i < cdformat.length; i += 1) {
1912
+ var ranges = cdformat[i].cellrange;
1913
+ if (!ranges) continue;
1914
+ for (var j = 0; j < ranges.length; j += 1) {
1915
+ var cr = ranges[j];
1916
+ if (r1 >= cr.row[0] && r1 <= cr.row[1] && c >= cr.column[0] && c <= cr.column[1]) {
1917
+ ranges.push({
1918
+ row: [r, r],
1919
+ column: [c, c]
1920
+ });
1921
+ break;
1922
+ }
1923
+ }
1924
+ }
1925
+ }
1926
+ }
1927
+ }
1720
1928
  }
1721
1929
  }
1722
1930
  }
@@ -1370,7 +1370,7 @@ var make_ssf = function make_ssf(SSF) {
1370
1370
  if (typeof n !== "number" || !Number.isFinite(n)) return null;
1371
1371
  if (!Number.isInteger(n)) return null;
1372
1372
  if (n < 0) return null;
1373
- var minSec = 0; // 1970-01-01
1373
+ var minSec = 100000; // Excel serial numbers max ~73050 for year 2100; avoids collision
1374
1374
  var maxSec = 4102444800; // ~2100-01-01
1375
1375
  var minMs = minSec * 1000;
1376
1376
  var maxMs = maxSec * 1000;
@@ -36,8 +36,8 @@ var _context = require("../context");
36
36
  var _utils = require("../utils");
37
37
  var _cell = require("./cell");
38
38
  var _color = require("./color");
39
- var _format = require("./format");
40
39
  var _cursor = require("./cursor");
40
+ var _format = require("./format");
41
41
  var _formula2 = require("./formula");
42
42
  var _inlineString = require("./inline-string");
43
43
  var _location = require("./location");
@@ -67,21 +67,42 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
67
67
  } else {
68
68
  value = cell;
69
69
  }
70
+ var type = "n";
71
+ if ((0, _format.is_date)(foucsStatus) || foucsStatus === 14 || foucsStatus === 15 || foucsStatus === 16 || foucsStatus === 17 || foucsStatus === 18 || foucsStatus === 19 || foucsStatus === 20 || foucsStatus === 21 || foucsStatus === 22 || foucsStatus === 45 || foucsStatus === 46 || foucsStatus === 47) {
72
+ type = "d";
73
+ } else if (foucsStatus === "@" || foucsStatus === 49) {
74
+ type = "s";
75
+ }
70
76
  if (_lodash.default.isNil(value)) {
77
+ if (!_lodash.default.isNil(d[r])) {
78
+ if (_lodash.default.isNil(d[r][c])) {
79
+ d[r][c] = {
80
+ ct: {
81
+ fa: foucsStatus,
82
+ t: type
83
+ }
84
+ };
85
+ } else if (_lodash.default.isPlainObject(d[r][c])) {
86
+ if (_lodash.default.isNil(d[r][c].ct)) d[r][c].ct = {};
87
+ d[r][c].ct.fa = foucsStatus;
88
+ d[r][c].ct.t = type;
89
+ }
90
+ }
71
91
  continue;
72
92
  }
73
93
  if (foucsStatus !== "@" && (0, _validation.isRealNum)(value)) {
74
94
  value = Number(value);
95
+ } else if (type === "d" && typeof value === "string") {
96
+ var dateInfo = (0, _validation.detectDateFormat)(value);
97
+ if (dateInfo) {
98
+ var dateObj = new Date(dateInfo.year, dateInfo.month - 1, dateInfo.day, dateInfo.hours, dateInfo.minutes, dateInfo.seconds);
99
+ value = (0, _format.datenum_local)(dateObj);
100
+ }
75
101
  }
76
- var mask = (0, _format.update)(foucsStatus, value);
77
- var type = "n";
78
- if ((0, _format.is_date)(foucsStatus) || foucsStatus === 14 || foucsStatus === 15 || foucsStatus === 16 || foucsStatus === 17 || foucsStatus === 18 || foucsStatus === 19 || foucsStatus === 20 || foucsStatus === 21 || foucsStatus === 22 || foucsStatus === 45 || foucsStatus === 46 || foucsStatus === 47) {
79
- type = "d";
80
- } else if (foucsStatus === "@" || foucsStatus === 49) {
81
- type = "s";
82
- } else if (foucsStatus === "General" || foucsStatus === 0) {
102
+ if (foucsStatus === "General" || foucsStatus === 0) {
83
103
  type = (0, _validation.isRealNum)(value) ? "n" : "g";
84
104
  }
105
+ var mask = (0, _format.update)(foucsStatus, value);
85
106
  if (cell && _lodash.default.isPlainObject(cell)) {
86
107
  cell.m = "".concat(mask);
87
108
  if (_lodash.default.isNil(cell.ct)) {
@@ -89,7 +110,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
89
110
  }
90
111
  cell.ct.fa = foucsStatus;
91
112
  cell.ct.t = type;
92
- cell.v = String(value);
113
+ cell.v = typeof value === "number" ? value : String(value);
93
114
  cell.fc = cell.fc || ((_f = (_e = (_d = cell.ct) === null || _d === void 0 ? void 0 : _d.s) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.fc);
94
115
  cell.bl = cell.bl || ((_j = (_h = (_g = cell.ct) === null || _g === void 0 ? void 0 : _g.s) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.bl);
95
116
  cell.it = cell.it || ((_m = (_l = (_k = cell.ct) === null || _k === void 0 ? void 0 : _k.s) === null || _l === void 0 ? void 0 : _l[0]) === null || _m === void 0 ? void 0 : _m.it);
@@ -102,7 +123,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
102
123
  fa: foucsStatus,
103
124
  t: type
104
125
  },
105
- v: value,
126
+ v: typeof value === "number" ? value : value,
106
127
  m: mask
107
128
  };
108
129
  }
@@ -1028,11 +1049,11 @@ function handleLink(ctx, cellInput) {
1028
1049
  }
1029
1050
  }
1030
1051
  }
1031
- (0, _hyperlink.showLinkCard)(ctx, r, c, true, false, {
1052
+ (0, _hyperlink.showLinkCard)(ctx, r, c, {
1032
1053
  applyToSelection: applyToSelection || undefined,
1033
1054
  originText: originText,
1034
1055
  selectionOffsets: selectionOffsets
1035
- });
1056
+ }, true, false);
1036
1057
  }
1037
1058
  var handlerMap = {
1038
1059
  "currency-format": handleCurrencyFormat,
@@ -15,6 +15,16 @@ export declare function valueIsError(value: string): boolean;
15
15
  export declare function isRealNull(val: any): boolean;
16
16
  export declare function isHexValue(str: string): boolean;
17
17
  export declare function isRealNum(val: any): boolean;
18
+ export type DateFormatInfo = {
19
+ year: number;
20
+ month: number;
21
+ day: number;
22
+ hours: number;
23
+ minutes: number;
24
+ seconds: number;
25
+ formatType: string;
26
+ };
27
+ export declare function detectDateFormat(str: string): DateFormatInfo | null;
18
28
  export declare function isdatetime(s: any): boolean;
19
29
  export declare function diff(now: any, then: any): number;
20
30
  export declare function isdatatypemulti(s: any): any;