@fileverse-dev/fortune-core 1.2.56-patch-2 → 1.2.58-sm-fix-patch-1

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.
@@ -1150,12 +1150,9 @@ function resizePastedCellsToContent(ctx) {
1150
1150
  updateSheetCellSizes(ctx, sheetIdx, rangeCellSize);
1151
1151
  }
1152
1152
  export function handlePaste(ctx, e) {
1153
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
1153
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
1154
1154
  var allowEdit = isAllowEdit(ctx);
1155
1155
  if (!allowEdit || ctx.isFlvReadOnly) return;
1156
- if (!selectionCache.isPasteAction) {
1157
- return;
1158
- }
1159
1156
  if (selectionCache.isPasteAction) {
1160
1157
  ctx.luckysheetCellUpdate = [];
1161
1158
  selectionCache.isPasteAction = false;
@@ -1186,11 +1183,11 @@ export function handlePaste(ctx, e) {
1186
1183
  }
1187
1184
  cpDataArr.push(cpRowArr);
1188
1185
  }
1189
- var copy_r1 = (_c = (_b = ctx.luckysheet_copy_save) === null || _b === void 0 ? void 0 : _b.copyRange[0]) === null || _c === void 0 ? void 0 : _c.row[0];
1190
- var copy_r2 = (_e = (_d = ctx.luckysheet_copy_save) === null || _d === void 0 ? void 0 : _d.copyRange[0]) === null || _e === void 0 ? void 0 : _e.row[1];
1191
- var copy_c1 = (_g = (_f = ctx.luckysheet_copy_save) === null || _f === void 0 ? void 0 : _f.copyRange[0]) === null || _g === void 0 ? void 0 : _g.column[0];
1192
- var copy_c2 = (_j = (_h = ctx.luckysheet_copy_save) === null || _h === void 0 ? void 0 : _h.copyRange[0]) === null || _j === void 0 ? void 0 : _j.column[1];
1193
- var copy_index = ctx.luckysheet_copy_save.dataSheetId || ctx.currentSheetId;
1186
+ var copy_r1 = ctx.luckysheet_copy_save.copyRange[0].row[0];
1187
+ var copy_r2 = ctx.luckysheet_copy_save.copyRange[0].row[1];
1188
+ var copy_c1 = ctx.luckysheet_copy_save.copyRange[0].column[0];
1189
+ var copy_c2 = ctx.luckysheet_copy_save.copyRange[0].column[1];
1190
+ var copy_index = ctx.luckysheet_copy_save.dataSheetId;
1194
1191
  var d = void 0;
1195
1192
  if (copy_index === ctx.currentSheetId) {
1196
1193
  d = getFlowdata(ctx);
@@ -1212,15 +1209,15 @@ export function handlePaste(ctx, e) {
1212
1209
  }
1213
1210
  var v = void 0;
1214
1211
  if (!_.isNil(cell)) {
1215
- if (((_m = (_l = (_k = cell.ct) === null || _k === void 0 ? void 0 : _k.fa) === null || _l === void 0 ? void 0 : _l.indexOf("w")) !== null && _m !== void 0 ? _m : -1) > -1) {
1216
- v = (_p = (_o = d[r]) === null || _o === void 0 ? void 0 : _o[c]) === null || _p === void 0 ? void 0 : _p.v;
1212
+ if (((_d = (_c = (_b = cell.ct) === null || _b === void 0 ? void 0 : _b.fa) === null || _c === void 0 ? void 0 : _c.indexOf("w")) !== null && _d !== void 0 ? _d : -1) > -1) {
1213
+ v = (_f = (_e = d[r]) === null || _e === void 0 ? void 0 : _e[c]) === null || _f === void 0 ? void 0 : _f.v;
1217
1214
  } else {
1218
- v = (_r = (_q = d[r]) === null || _q === void 0 ? void 0 : _q[c]) === null || _r === void 0 ? void 0 : _r.m;
1215
+ v = (_h = (_g = d[r]) === null || _g === void 0 ? void 0 : _g[c]) === null || _h === void 0 ? void 0 : _h.m;
1219
1216
  }
1220
1217
  } else {
1221
1218
  v = "";
1222
1219
  }
1223
- if (_.isNil(v) && ((_u = (_t = (_s = d[r]) === null || _s === void 0 ? void 0 : _s[c]) === null || _t === void 0 ? void 0 : _t.ct) === null || _u === void 0 ? void 0 : _u.t) === "inlineStr") {
1220
+ if (_.isNil(v) && ((_l = (_k = (_j = d[r]) === null || _j === void 0 ? void 0 : _j[c]) === null || _k === void 0 ? void 0 : _k.ct) === null || _l === void 0 ? void 0 : _l.t) === "inlineStr") {
1224
1221
  v = d[r][c].ct.s.map(function (val) {
1225
1222
  return val.v;
1226
1223
  }).join("");
@@ -1238,10 +1235,10 @@ export function handlePaste(ctx, e) {
1238
1235
  }
1239
1236
  }
1240
1237
  }
1241
- if (((_w = (_v = ctx.hooks).beforePaste) === null || _w === void 0 ? void 0 : _w.call(_v, ctx.luckysheet_select_save, txtdata)) === false) {
1238
+ if (((_o = (_m = ctx.hooks).beforePaste) === null || _o === void 0 ? void 0 : _o.call(_m, ctx.luckysheet_select_save, txtdata)) === false) {
1242
1239
  return;
1243
1240
  }
1244
- if (txtdata.indexOf("fortune-copy-action-table") > -1 && ((_x = ctx.luckysheet_copy_save) === null || _x === void 0 ? void 0 : _x.copyRange) != null && ctx.luckysheet_copy_save.copyRange.length > 0 && isEqual) {
1241
+ if (txtdata.indexOf("fortune-copy-action-table") > -1 && ((_p = ctx.luckysheet_copy_save) === null || _p === void 0 ? void 0 : _p.copyRange) != null && ctx.luckysheet_copy_save.copyRange.length > 0 && isEqual) {
1245
1242
  if (ctx.luckysheet_paste_iscut) {
1246
1243
  ctx.luckysheet_paste_iscut = false;
1247
1244
  pasteHandlerOfCutPaste(ctx, ctx.luckysheet_copy_save);
@@ -1264,10 +1261,10 @@ export function handlePaste(ctx, e) {
1264
1261
  var _txtdata = clipboardData.getData("text/html") || clipboardData.getData("text/plain");
1265
1262
  var embedUrl = sanitizeDuneUrl(_txtdata);
1266
1263
  if (embedUrl) {
1267
- var last = (_y = ctx.luckysheet_select_save) === null || _y === void 0 ? void 0 : _y[ctx.luckysheet_select_save.length - 1];
1264
+ var last = (_q = ctx.luckysheet_select_save) === null || _q === void 0 ? void 0 : _q[ctx.luckysheet_select_save.length - 1];
1268
1265
  if (last) {
1269
- var rowIndex = (_1 = (_z = last.row_focus) !== null && _z !== void 0 ? _z : (_0 = last.row) === null || _0 === void 0 ? void 0 : _0[0]) !== null && _1 !== void 0 ? _1 : 0;
1270
- var colIndex = (_4 = (_2 = last.column_focus) !== null && _2 !== void 0 ? _2 : (_3 = last.column) === null || _3 === void 0 ? void 0 : _3[0]) !== null && _4 !== void 0 ? _4 : 0;
1266
+ var rowIndex = (_t = (_r = last.row_focus) !== null && _r !== void 0 ? _r : (_s = last.row) === null || _s === void 0 ? void 0 : _s[0]) !== null && _t !== void 0 ? _t : 0;
1267
+ var colIndex = (_w = (_u = last.column_focus) !== null && _u !== void 0 ? _u : (_v = last.column) === null || _v === void 0 ? void 0 : _v[0]) !== null && _w !== void 0 ? _w : 0;
1271
1268
  var left = colIndex === 0 ? 0 : ctx.visibledatacolumn[colIndex - 1];
1272
1269
  var top_1 = rowIndex === 0 ? 0 : ctx.visibledatarow[rowIndex + 5];
1273
1270
  ctx.showDunePreview = {
@@ -59,18 +59,14 @@ export function normalizedCellAttr(cell, attr, defaultFontSize) {
59
59
  }
60
60
  export function normalizedAttr(data, r, c, attr) {
61
61
  if (!data || !data[r]) {
62
+ console.warn("cell (%d, %d) is null", r, c);
62
63
  return null;
63
64
  }
64
65
  var cell = data[r][c];
65
66
  if (!cell) return undefined;
66
67
  return normalizedCellAttr(cell, attr);
67
68
  }
68
- function newlinesToBr(text) {
69
- if (!text) return "";
70
- return text.replace(/\r\n|\r|\n/g, "<br />");
71
- }
72
69
  export function getCellValue(r, c, data, attr) {
73
- var _a;
74
70
  if (!attr) {
75
71
  attr = "v";
76
72
  }
@@ -100,9 +96,6 @@ export function getCellValue(r, c, data, attr) {
100
96
  } else if (d && d.ct && d.ct.t === "d") {
101
97
  retv = d.m;
102
98
  }
103
- if ((d === null || d === void 0 ? void 0 : d.ct) && isInlineStringCT(d.ct) && (attr === "v" || attr === "m")) {
104
- retv = newlinesToBr((_a = d.ct.s[0]) === null || _a === void 0 ? void 0 : _a.v);
105
- }
106
99
  }
107
100
  if (retv === undefined) {
108
101
  retv = null;
@@ -1046,8 +1039,6 @@ export function getStyleByCell(ctx, d, r, c) {
1046
1039
  } else {
1047
1040
  style.background = "".concat(value);
1048
1041
  }
1049
- } else {
1050
- style.background = "".concat(value);
1051
1042
  }
1052
1043
  }
1053
1044
  if ("ht" in cell) {
@@ -1056,18 +1047,8 @@ export function getStyleByCell(ctx, d, r, c) {
1056
1047
  style.textAlign = "center";
1057
1048
  } else if (Number(value) === 2) {
1058
1049
  style.textAlign = "right";
1059
- style.overflowWrap = "anywhere";
1060
1050
  }
1061
1051
  }
1062
- if ("tb" in cell) {
1063
- if (Number(cell.tb) === 2) {
1064
- style.overflowWrap = "anywhere";
1065
- }
1066
- }
1067
- if ("ff" in cell) {
1068
- var value = normalizedCellAttr(cell, "ff");
1069
- style.fontFamily = value;
1070
- }
1071
1052
  if ("vt" in cell) {
1072
1053
  var value = normalizedCellAttr(cell, "vt");
1073
1054
  if (Number(value) === 0) {
@@ -1129,7 +1129,7 @@ function getHtmlBorderStyle(type, color) {
1129
1129
  return "".concat(style + color, ";");
1130
1130
  }
1131
1131
  export function rangeValueToHtml(ctx, sheetId, ranges) {
1132
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1132
+ var _a, _b, _c;
1133
1133
  var idx = getSheetIndex(ctx, sheetId);
1134
1134
  if (idx == null) return "";
1135
1135
  var sheet = ctx.luckysheetfile[idx];
@@ -1162,12 +1162,11 @@ export function rangeValueToHtml(ctx, sheetId, ranges) {
1162
1162
  var colgroup = "";
1163
1163
  for (var i = 0; i < rowIndexArr.length; i += 1) {
1164
1164
  var r = rowIndexArr[i];
1165
- var rowLen = (_e = (_d = (_c = sheet.config) === null || _c === void 0 ? void 0 : _c.rowlen) === null || _d === void 0 ? void 0 : _d[r.toString()]) !== null && _e !== void 0 ? _e : sheet.defaultRowHeight;
1166
- cpdata += "<tr height=".concat(rowLen, "px >");
1165
+ cpdata += "<tr>";
1167
1166
  var _loop_3 = function _loop_3(j) {
1168
1167
  var c = colIndexArr[j];
1169
1168
  var column = '<td ${span} style="${style}">';
1170
- var cell = (_f = d[r]) === null || _f === void 0 ? void 0 : _f[c];
1169
+ var cell = (_c = d[r]) === null || _c === void 0 ? void 0 : _c[c];
1171
1170
  if (cell != null) {
1172
1171
  var style = "";
1173
1172
  var span = "";
@@ -1179,14 +1178,11 @@ export function rangeValueToHtml(ctx, sheetId, ranges) {
1179
1178
  }
1180
1179
  }
1181
1180
  if (c === colIndexArr[0]) {
1182
- var rowLenValue = (_h = (_g = sheet.config) === null || _g === void 0 ? void 0 : _g.rowlen) === null || _h === void 0 ? void 0 : _h[r.toString()];
1183
- var colLen = (_k = (_j = sheet.config) === null || _j === void 0 ? void 0 : _j.columnlen) === null || _k === void 0 ? void 0 : _k[c.toString()];
1184
- if (_.isNil(rowLenValue)) {
1181
+ if (_.isNil(sheet.config) || _.isNil(sheet.config.rowlen) || _.isNil(sheet.config.rowlen[r.toString()])) {
1185
1182
  style += "height:19px;";
1186
1183
  } else {
1187
- style += "height:".concat(rowLenValue, "px;");
1184
+ style += "height:".concat(sheet.config.rowlen[r.toString()], "px;");
1188
1185
  }
1189
- style += "width:".concat(colLen !== null && colLen !== void 0 ? colLen : sheet.defaultColWidth, "px;");
1190
1186
  }
1191
1187
  var reg = /^(w|W)((0?)|(0\.0+))$/;
1192
1188
  var c_value = void 0;
@@ -1489,7 +1485,6 @@ export function copy(ctx) {
1489
1485
  HasMC: HasMC
1490
1486
  };
1491
1487
  var cpdata = rangeValueToHtml(ctx, ctx.currentSheetId, ctx.luckysheet_select_save);
1492
- cpdata = cpdata === null ? cpdata : cpdata.replace('<td style="', '<td style="white-space: pre-line;"');
1493
1488
  if (cpdata) {
1494
1489
  ctx.iscopyself = true;
1495
1490
  clipboard.writeHtml(cpdata);
package/es/modules/ssf.js CHANGED
@@ -967,7 +967,7 @@ var make_ssf = function make_ssf(SSF) {
967
967
  if (v < 0) return "";
968
968
  if (dt == null) {
969
969
  dt = parse_date_code(v, opts);
970
- if (dt == null) return "#####";
970
+ if (dt == null) return v;
971
971
  }
972
972
  o = c;
973
973
  while (++i < fmt.length && fmt.charAt(i).toLowerCase() === c) o += c;
@@ -1360,6 +1360,22 @@ var make_ssf = function make_ssf(SSF) {
1360
1360
  }
1361
1361
  return [l, ff];
1362
1362
  }
1363
+ function checkUnixTimestampAndUnit(n) {
1364
+ if (typeof n !== "number" || !Number.isFinite(n)) return null;
1365
+ if (!Number.isInteger(n)) return null;
1366
+ if (n < 0) return null;
1367
+ var minSec = 0; // 1970-01-01
1368
+ var maxSec = 4102444800; // ~2100-01-01
1369
+ var minMs = minSec * 1000;
1370
+ var maxMs = maxSec * 1000;
1371
+ if (n >= minSec && n <= maxSec) {
1372
+ return "seconds";
1373
+ }
1374
+ if (n >= minMs && n <= maxMs) {
1375
+ return "milliseconds";
1376
+ }
1377
+ return null;
1378
+ }
1363
1379
  function format(fmt, v, o) {
1364
1380
  if (o == null) o = {};
1365
1381
  var sfmt = "";
@@ -1374,6 +1390,16 @@ var make_ssf = function make_ssf(SSF) {
1374
1390
  break;
1375
1391
  }
1376
1392
 
1393
+ //unix timestamp detection
1394
+ if (typeof v === "number" && fmt_is_date && fmt_is_date(sfmt)) {
1395
+ var unit = checkUnixTimestampAndUnit(v);
1396
+ if (unit === "seconds") {
1397
+ v = new Date(v * 1000);
1398
+ } else if (unit === "milliseconds") {
1399
+ v = new Date(v);
1400
+ }
1401
+ }
1402
+
1377
1403
  //new runze 增加万 亿 格式
1378
1404
  //注:"w":2万2500 "w0":2万2500 "w0.0":2万2500.2 "w0.00":2万2500.23......自定义精确度
1379
1405
  var reg = /^(w|W)((0?)|(0\.0+))$/;
@@ -1,20 +1,9 @@
1
1
  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); }
2
- var __assign = this && this.__assign || function () {
3
- __assign = Object.assign || function (t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
2
  import _ from "lodash";
13
3
  import { locale } from "./locale";
14
4
  import { getQKBorder, saveHyperlink } from "./modules";
15
5
  import { genarate } from "./modules/format";
16
6
  import { getSheetIndex } from "./utils";
17
- import { setRowHeight } from "./api";
18
7
  export var DEFAULT_FONT_SIZE = 12;
19
8
  var parseStylesheetPairs = function parseStylesheetPairs(styleInner) {
20
9
  var patternReg = /{([^}]*)}/g;
@@ -123,28 +112,14 @@ var detectHyperlink = function detectHyperlink(td) {
123
112
  }
124
113
  return null;
125
114
  };
126
- function brToNewline(str) {
127
- return str.replace(/<br\s*\/?>/gi, "\n");
128
- }
129
115
  var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
130
116
  var _a;
131
- var _b, _c, _d;
117
+ var _b, _c;
132
118
  var cell = {};
133
119
  var rawText = (td.innerText || td.innerHTML || "").trim();
134
- var isLineBreak = rawText.includes("<br />");
135
120
  if (!rawText) {
136
121
  cell.v = undefined;
137
122
  cell.m = "";
138
- } else if (isLineBreak) {
139
- var value = brToNewline(rawText);
140
- cell = __assign(__assign({}, cell), {
141
- ct: __assign(__assign({}, cell.ct), {
142
- t: "inlineStr",
143
- s: [{
144
- v: value
145
- }]
146
- })
147
- });
148
123
  } else {
149
124
  var mask = genarate(rawText);
150
125
  _a = mask || [], cell.m = _a[0], cell.ct = _a[1], cell.v = _a[2];
@@ -191,11 +166,7 @@ var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
191
166
  } else {
192
167
  cell.vt = 2;
193
168
  }
194
- if (((_d = td === null || td === void 0 ? void 0 : td.style) === null || _d === void 0 ? void 0 : _d["overflow-wrap"]) === "anywhere") {
195
- cell.tb = "2";
196
- } else {
197
- cell.tb = "2";
198
- }
169
+ cell.tb = "1";
199
170
  if ("mso-rotate" in styles) cell.rt = parseFloat(styles["mso-rotate"]);
200
171
  var rowspan = parseInt(td.getAttribute("rowspan") || "1", 10);
201
172
  var colspan = parseInt(td.getAttribute("colspan") || "1", 10);
@@ -247,19 +218,17 @@ export function handlePastedTable(ctx, html, pasteHandler) {
247
218
  var localRowIndex = 0;
248
219
  tableRows.forEach(function (tr) {
249
220
  var _a;
250
- var _b;
251
221
  var localColIndex = 0;
252
222
  var anchorRow = ctx.luckysheet_select_save[0].row[0];
253
223
  var targetRowIndex = anchorRow + localRowIndex;
254
224
  var explicitRowHeightAttr = tr.getAttribute("height");
255
225
  if (!_.isNil(explicitRowHeightAttr)) {
256
226
  var explicitRowHeight = parseInt(explicitRowHeightAttr, 10);
257
- var hasCustomRowHeight = _.has((_b = sheetFile.config) === null || _b === void 0 ? void 0 : _b.rowlen, targetRowIndex);
227
+ var hasCustomRowHeight = _.has((_a = sheetFile.config) === null || _a === void 0 ? void 0 : _a.rowlen, targetRowIndex);
258
228
  var currentRowHeight = hasCustomRowHeight ? sheetFile.config.rowlen[targetRowIndex] : sheetFile.defaultRowHeight;
259
229
  if (currentRowHeight !== explicitRowHeight) {
260
230
  rowHeightsConfig[targetRowIndex] = explicitRowHeight;
261
231
  }
262
- setRowHeight(ctx, (_a = {}, _a[String(targetRowIndex)] = explicitRowHeight, _a));
263
232
  }
264
233
  tr.querySelectorAll("td, th").forEach(function (node) {
265
234
  var tdElement = node;
@@ -1163,12 +1163,9 @@ function resizePastedCellsToContent(ctx) {
1163
1163
  (0, _calculateRangeCellSize.updateSheetCellSizes)(ctx, sheetIdx, rangeCellSize);
1164
1164
  }
1165
1165
  function handlePaste(ctx, e) {
1166
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
1166
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
1167
1167
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
1168
1168
  if (!allowEdit || ctx.isFlvReadOnly) return;
1169
- if (!_selection.selectionCache.isPasteAction) {
1170
- return;
1171
- }
1172
1169
  if (_selection.selectionCache.isPasteAction) {
1173
1170
  ctx.luckysheetCellUpdate = [];
1174
1171
  _selection.selectionCache.isPasteAction = false;
@@ -1199,11 +1196,11 @@ function handlePaste(ctx, e) {
1199
1196
  }
1200
1197
  cpDataArr.push(cpRowArr);
1201
1198
  }
1202
- var copy_r1 = (_c = (_b = ctx.luckysheet_copy_save) === null || _b === void 0 ? void 0 : _b.copyRange[0]) === null || _c === void 0 ? void 0 : _c.row[0];
1203
- var copy_r2 = (_e = (_d = ctx.luckysheet_copy_save) === null || _d === void 0 ? void 0 : _d.copyRange[0]) === null || _e === void 0 ? void 0 : _e.row[1];
1204
- var copy_c1 = (_g = (_f = ctx.luckysheet_copy_save) === null || _f === void 0 ? void 0 : _f.copyRange[0]) === null || _g === void 0 ? void 0 : _g.column[0];
1205
- var copy_c2 = (_j = (_h = ctx.luckysheet_copy_save) === null || _h === void 0 ? void 0 : _h.copyRange[0]) === null || _j === void 0 ? void 0 : _j.column[1];
1206
- var copy_index = ctx.luckysheet_copy_save.dataSheetId || ctx.currentSheetId;
1199
+ var copy_r1 = ctx.luckysheet_copy_save.copyRange[0].row[0];
1200
+ var copy_r2 = ctx.luckysheet_copy_save.copyRange[0].row[1];
1201
+ var copy_c1 = ctx.luckysheet_copy_save.copyRange[0].column[0];
1202
+ var copy_c2 = ctx.luckysheet_copy_save.copyRange[0].column[1];
1203
+ var copy_index = ctx.luckysheet_copy_save.dataSheetId;
1207
1204
  var d = void 0;
1208
1205
  if (copy_index === ctx.currentSheetId) {
1209
1206
  d = (0, _context.getFlowdata)(ctx);
@@ -1225,15 +1222,15 @@ function handlePaste(ctx, e) {
1225
1222
  }
1226
1223
  var v = void 0;
1227
1224
  if (!_lodash.default.isNil(cell)) {
1228
- if (((_m = (_l = (_k = cell.ct) === null || _k === void 0 ? void 0 : _k.fa) === null || _l === void 0 ? void 0 : _l.indexOf("w")) !== null && _m !== void 0 ? _m : -1) > -1) {
1229
- v = (_p = (_o = d[r]) === null || _o === void 0 ? void 0 : _o[c]) === null || _p === void 0 ? void 0 : _p.v;
1225
+ if (((_d = (_c = (_b = cell.ct) === null || _b === void 0 ? void 0 : _b.fa) === null || _c === void 0 ? void 0 : _c.indexOf("w")) !== null && _d !== void 0 ? _d : -1) > -1) {
1226
+ v = (_f = (_e = d[r]) === null || _e === void 0 ? void 0 : _e[c]) === null || _f === void 0 ? void 0 : _f.v;
1230
1227
  } else {
1231
- v = (_r = (_q = d[r]) === null || _q === void 0 ? void 0 : _q[c]) === null || _r === void 0 ? void 0 : _r.m;
1228
+ v = (_h = (_g = d[r]) === null || _g === void 0 ? void 0 : _g[c]) === null || _h === void 0 ? void 0 : _h.m;
1232
1229
  }
1233
1230
  } else {
1234
1231
  v = "";
1235
1232
  }
1236
- if (_lodash.default.isNil(v) && ((_u = (_t = (_s = d[r]) === null || _s === void 0 ? void 0 : _s[c]) === null || _t === void 0 ? void 0 : _t.ct) === null || _u === void 0 ? void 0 : _u.t) === "inlineStr") {
1233
+ if (_lodash.default.isNil(v) && ((_l = (_k = (_j = d[r]) === null || _j === void 0 ? void 0 : _j[c]) === null || _k === void 0 ? void 0 : _k.ct) === null || _l === void 0 ? void 0 : _l.t) === "inlineStr") {
1237
1234
  v = d[r][c].ct.s.map(function (val) {
1238
1235
  return val.v;
1239
1236
  }).join("");
@@ -1251,10 +1248,10 @@ function handlePaste(ctx, e) {
1251
1248
  }
1252
1249
  }
1253
1250
  }
1254
- if (((_w = (_v = ctx.hooks).beforePaste) === null || _w === void 0 ? void 0 : _w.call(_v, ctx.luckysheet_select_save, txtdata)) === false) {
1251
+ if (((_o = (_m = ctx.hooks).beforePaste) === null || _o === void 0 ? void 0 : _o.call(_m, ctx.luckysheet_select_save, txtdata)) === false) {
1255
1252
  return;
1256
1253
  }
1257
- if (txtdata.indexOf("fortune-copy-action-table") > -1 && ((_x = ctx.luckysheet_copy_save) === null || _x === void 0 ? void 0 : _x.copyRange) != null && ctx.luckysheet_copy_save.copyRange.length > 0 && isEqual) {
1254
+ if (txtdata.indexOf("fortune-copy-action-table") > -1 && ((_p = ctx.luckysheet_copy_save) === null || _p === void 0 ? void 0 : _p.copyRange) != null && ctx.luckysheet_copy_save.copyRange.length > 0 && isEqual) {
1258
1255
  if (ctx.luckysheet_paste_iscut) {
1259
1256
  ctx.luckysheet_paste_iscut = false;
1260
1257
  pasteHandlerOfCutPaste(ctx, ctx.luckysheet_copy_save);
@@ -1277,10 +1274,10 @@ function handlePaste(ctx, e) {
1277
1274
  var _txtdata = clipboardData.getData("text/html") || clipboardData.getData("text/plain");
1278
1275
  var embedUrl = (0, _modules.sanitizeDuneUrl)(_txtdata);
1279
1276
  if (embedUrl) {
1280
- var last = (_y = ctx.luckysheet_select_save) === null || _y === void 0 ? void 0 : _y[ctx.luckysheet_select_save.length - 1];
1277
+ var last = (_q = ctx.luckysheet_select_save) === null || _q === void 0 ? void 0 : _q[ctx.luckysheet_select_save.length - 1];
1281
1278
  if (last) {
1282
- var rowIndex = (_1 = (_z = last.row_focus) !== null && _z !== void 0 ? _z : (_0 = last.row) === null || _0 === void 0 ? void 0 : _0[0]) !== null && _1 !== void 0 ? _1 : 0;
1283
- var colIndex = (_4 = (_2 = last.column_focus) !== null && _2 !== void 0 ? _2 : (_3 = last.column) === null || _3 === void 0 ? void 0 : _3[0]) !== null && _4 !== void 0 ? _4 : 0;
1279
+ var rowIndex = (_t = (_r = last.row_focus) !== null && _r !== void 0 ? _r : (_s = last.row) === null || _s === void 0 ? void 0 : _s[0]) !== null && _t !== void 0 ? _t : 0;
1280
+ var colIndex = (_w = (_u = last.column_focus) !== null && _u !== void 0 ? _u : (_v = last.column) === null || _v === void 0 ? void 0 : _v[0]) !== null && _w !== void 0 ? _w : 0;
1284
1281
  var left = colIndex === 0 ? 0 : ctx.visibledatacolumn[colIndex - 1];
1285
1282
  var top_1 = rowIndex === 0 ? 0 : ctx.visibledatarow[rowIndex + 5];
1286
1283
  ctx.showDunePreview = {
@@ -92,18 +92,14 @@ function normalizedCellAttr(cell, attr, defaultFontSize) {
92
92
  }
93
93
  function normalizedAttr(data, r, c, attr) {
94
94
  if (!data || !data[r]) {
95
+ console.warn("cell (%d, %d) is null", r, c);
95
96
  return null;
96
97
  }
97
98
  var cell = data[r][c];
98
99
  if (!cell) return undefined;
99
100
  return normalizedCellAttr(cell, attr);
100
101
  }
101
- function newlinesToBr(text) {
102
- if (!text) return "";
103
- return text.replace(/\r\n|\r|\n/g, "<br />");
104
- }
105
102
  function getCellValue(r, c, data, attr) {
106
- var _a;
107
103
  if (!attr) {
108
104
  attr = "v";
109
105
  }
@@ -133,9 +129,6 @@ function getCellValue(r, c, data, attr) {
133
129
  } else if (d && d.ct && d.ct.t === "d") {
134
130
  retv = d.m;
135
131
  }
136
- if ((d === null || d === void 0 ? void 0 : d.ct) && (0, _inlineString.isInlineStringCT)(d.ct) && (attr === "v" || attr === "m")) {
137
- retv = newlinesToBr((_a = d.ct.s[0]) === null || _a === void 0 ? void 0 : _a.v);
138
- }
139
132
  }
140
133
  if (retv === undefined) {
141
134
  retv = null;
@@ -1079,8 +1072,6 @@ function getStyleByCell(ctx, d, r, c) {
1079
1072
  } else {
1080
1073
  style.background = "".concat(value);
1081
1074
  }
1082
- } else {
1083
- style.background = "".concat(value);
1084
1075
  }
1085
1076
  }
1086
1077
  if ("ht" in cell) {
@@ -1089,18 +1080,8 @@ function getStyleByCell(ctx, d, r, c) {
1089
1080
  style.textAlign = "center";
1090
1081
  } else if (Number(value) === 2) {
1091
1082
  style.textAlign = "right";
1092
- style.overflowWrap = "anywhere";
1093
1083
  }
1094
1084
  }
1095
- if ("tb" in cell) {
1096
- if (Number(cell.tb) === 2) {
1097
- style.overflowWrap = "anywhere";
1098
- }
1099
- }
1100
- if ("ff" in cell) {
1101
- var value = normalizedCellAttr(cell, "ff");
1102
- style.fontFamily = value;
1103
- }
1104
1085
  if ("vt" in cell) {
1105
1086
  var value = normalizedCellAttr(cell, "vt");
1106
1087
  if (Number(value) === 0) {
@@ -1164,7 +1164,7 @@ function getHtmlBorderStyle(type, color) {
1164
1164
  return "".concat(style + color, ";");
1165
1165
  }
1166
1166
  function rangeValueToHtml(ctx, sheetId, ranges) {
1167
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1167
+ var _a, _b, _c;
1168
1168
  var idx = (0, _utils.getSheetIndex)(ctx, sheetId);
1169
1169
  if (idx == null) return "";
1170
1170
  var sheet = ctx.luckysheetfile[idx];
@@ -1197,12 +1197,11 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
1197
1197
  var colgroup = "";
1198
1198
  for (var i = 0; i < rowIndexArr.length; i += 1) {
1199
1199
  var r = rowIndexArr[i];
1200
- var rowLen = (_e = (_d = (_c = sheet.config) === null || _c === void 0 ? void 0 : _c.rowlen) === null || _d === void 0 ? void 0 : _d[r.toString()]) !== null && _e !== void 0 ? _e : sheet.defaultRowHeight;
1201
- cpdata += "<tr height=".concat(rowLen, "px >");
1200
+ cpdata += "<tr>";
1202
1201
  var _loop_3 = function _loop_3(j) {
1203
1202
  var c = colIndexArr[j];
1204
1203
  var column = '<td ${span} style="${style}">';
1205
- var cell = (_f = d[r]) === null || _f === void 0 ? void 0 : _f[c];
1204
+ var cell = (_c = d[r]) === null || _c === void 0 ? void 0 : _c[c];
1206
1205
  if (cell != null) {
1207
1206
  var style = "";
1208
1207
  var span = "";
@@ -1214,14 +1213,11 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
1214
1213
  }
1215
1214
  }
1216
1215
  if (c === colIndexArr[0]) {
1217
- var rowLenValue = (_h = (_g = sheet.config) === null || _g === void 0 ? void 0 : _g.rowlen) === null || _h === void 0 ? void 0 : _h[r.toString()];
1218
- var colLen = (_k = (_j = sheet.config) === null || _j === void 0 ? void 0 : _j.columnlen) === null || _k === void 0 ? void 0 : _k[c.toString()];
1219
- if (_lodash.default.isNil(rowLenValue)) {
1216
+ if (_lodash.default.isNil(sheet.config) || _lodash.default.isNil(sheet.config.rowlen) || _lodash.default.isNil(sheet.config.rowlen[r.toString()])) {
1220
1217
  style += "height:19px;";
1221
1218
  } else {
1222
- style += "height:".concat(rowLenValue, "px;");
1219
+ style += "height:".concat(sheet.config.rowlen[r.toString()], "px;");
1223
1220
  }
1224
- style += "width:".concat(colLen !== null && colLen !== void 0 ? colLen : sheet.defaultColWidth, "px;");
1225
1221
  }
1226
1222
  var reg = /^(w|W)((0?)|(0\.0+))$/;
1227
1223
  var c_value = void 0;
@@ -1524,7 +1520,6 @@ function copy(ctx) {
1524
1520
  HasMC: HasMC
1525
1521
  };
1526
1522
  var cpdata = rangeValueToHtml(ctx, ctx.currentSheetId, ctx.luckysheet_select_save);
1527
- cpdata = cpdata === null ? cpdata : cpdata.replace('<td style="', '<td style="white-space: pre-line;"');
1528
1523
  if (cpdata) {
1529
1524
  ctx.iscopyself = true;
1530
1525
  _clipboard.default.writeHtml(cpdata);
@@ -973,7 +973,7 @@ var make_ssf = function make_ssf(SSF) {
973
973
  if (v < 0) return "";
974
974
  if (dt == null) {
975
975
  dt = parse_date_code(v, opts);
976
- if (dt == null) return "#####";
976
+ if (dt == null) return v;
977
977
  }
978
978
  o = c;
979
979
  while (++i < fmt.length && fmt.charAt(i).toLowerCase() === c) o += c;
@@ -1366,6 +1366,22 @@ var make_ssf = function make_ssf(SSF) {
1366
1366
  }
1367
1367
  return [l, ff];
1368
1368
  }
1369
+ function checkUnixTimestampAndUnit(n) {
1370
+ if (typeof n !== "number" || !Number.isFinite(n)) return null;
1371
+ if (!Number.isInteger(n)) return null;
1372
+ if (n < 0) return null;
1373
+ var minSec = 0; // 1970-01-01
1374
+ var maxSec = 4102444800; // ~2100-01-01
1375
+ var minMs = minSec * 1000;
1376
+ var maxMs = maxSec * 1000;
1377
+ if (n >= minSec && n <= maxSec) {
1378
+ return "seconds";
1379
+ }
1380
+ if (n >= minMs && n <= maxMs) {
1381
+ return "milliseconds";
1382
+ }
1383
+ return null;
1384
+ }
1369
1385
  function format(fmt, v, o) {
1370
1386
  if (o == null) o = {};
1371
1387
  var sfmt = "";
@@ -1380,6 +1396,16 @@ var make_ssf = function make_ssf(SSF) {
1380
1396
  break;
1381
1397
  }
1382
1398
 
1399
+ //unix timestamp detection
1400
+ if (typeof v === "number" && fmt_is_date && fmt_is_date(sfmt)) {
1401
+ var unit = checkUnixTimestampAndUnit(v);
1402
+ if (unit === "seconds") {
1403
+ v = new Date(v * 1000);
1404
+ } else if (unit === "milliseconds") {
1405
+ v = new Date(v);
1406
+ }
1407
+ }
1408
+
1383
1409
  //new runze 增加万 亿 格式
1384
1410
  //注:"w":2万2500 "w0":2万2500 "w0.0":2万2500.2 "w0.00":2万2500.23......自定义精确度
1385
1411
  var reg = /^(w|W)((0?)|(0\.0+))$/;
@@ -10,19 +10,8 @@ var _locale = require("./locale");
10
10
  var _modules = require("./modules");
11
11
  var _format = require("./modules/format");
12
12
  var _utils = require("./utils");
13
- var _api = require("./api");
14
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
14
  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); }
16
- var __assign = void 0 && (void 0).__assign || function () {
17
- __assign = Object.assign || function (t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
15
  var DEFAULT_FONT_SIZE = exports.DEFAULT_FONT_SIZE = 12;
27
16
  var parseStylesheetPairs = function parseStylesheetPairs(styleInner) {
28
17
  var patternReg = /{([^}]*)}/g;
@@ -131,28 +120,14 @@ var detectHyperlink = function detectHyperlink(td) {
131
120
  }
132
121
  return null;
133
122
  };
134
- function brToNewline(str) {
135
- return str.replace(/<br\s*\/?>/gi, "\n");
136
- }
137
123
  var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
138
124
  var _a;
139
- var _b, _c, _d;
125
+ var _b, _c;
140
126
  var cell = {};
141
127
  var rawText = (td.innerText || td.innerHTML || "").trim();
142
- var isLineBreak = rawText.includes("<br />");
143
128
  if (!rawText) {
144
129
  cell.v = undefined;
145
130
  cell.m = "";
146
- } else if (isLineBreak) {
147
- var value = brToNewline(rawText);
148
- cell = __assign(__assign({}, cell), {
149
- ct: __assign(__assign({}, cell.ct), {
150
- t: "inlineStr",
151
- s: [{
152
- v: value
153
- }]
154
- })
155
- });
156
131
  } else {
157
132
  var mask = (0, _format.genarate)(rawText);
158
133
  _a = mask || [], cell.m = _a[0], cell.ct = _a[1], cell.v = _a[2];
@@ -199,11 +174,7 @@ var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
199
174
  } else {
200
175
  cell.vt = 2;
201
176
  }
202
- if (((_d = td === null || td === void 0 ? void 0 : td.style) === null || _d === void 0 ? void 0 : _d["overflow-wrap"]) === "anywhere") {
203
- cell.tb = "2";
204
- } else {
205
- cell.tb = "2";
206
- }
177
+ cell.tb = "1";
207
178
  if ("mso-rotate" in styles) cell.rt = parseFloat(styles["mso-rotate"]);
208
179
  var rowspan = parseInt(td.getAttribute("rowspan") || "1", 10);
209
180
  var colspan = parseInt(td.getAttribute("colspan") || "1", 10);
@@ -255,19 +226,17 @@ function handlePastedTable(ctx, html, pasteHandler) {
255
226
  var localRowIndex = 0;
256
227
  tableRows.forEach(function (tr) {
257
228
  var _a;
258
- var _b;
259
229
  var localColIndex = 0;
260
230
  var anchorRow = ctx.luckysheet_select_save[0].row[0];
261
231
  var targetRowIndex = anchorRow + localRowIndex;
262
232
  var explicitRowHeightAttr = tr.getAttribute("height");
263
233
  if (!_lodash.default.isNil(explicitRowHeightAttr)) {
264
234
  var explicitRowHeight = parseInt(explicitRowHeightAttr, 10);
265
- var hasCustomRowHeight = _lodash.default.has((_b = sheetFile.config) === null || _b === void 0 ? void 0 : _b.rowlen, targetRowIndex);
235
+ var hasCustomRowHeight = _lodash.default.has((_a = sheetFile.config) === null || _a === void 0 ? void 0 : _a.rowlen, targetRowIndex);
266
236
  var currentRowHeight = hasCustomRowHeight ? sheetFile.config.rowlen[targetRowIndex] : sheetFile.defaultRowHeight;
267
237
  if (currentRowHeight !== explicitRowHeight) {
268
238
  rowHeightsConfig[targetRowIndex] = explicitRowHeight;
269
239
  }
270
- (0, _api.setRowHeight)(ctx, (_a = {}, _a[String(targetRowIndex)] = explicitRowHeight, _a));
271
240
  }
272
241
  tr.querySelectorAll("td, th").forEach(function (node) {
273
242
  var tdElement = node;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.2.56-patch-2",
3
+ "version": "1.2.58-sm-fix-patch-1",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",