@fileverse-dev/fortune-core 1.3.12 → 1.3.13-create-2

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 (65) hide show
  1. package/es/events/keyboard.d.ts +2 -2
  2. package/es/events/keyboard.js +204 -30
  3. package/es/events/mouse.js +79 -44
  4. package/es/events/paste.js +240 -56
  5. package/es/locale/en.d.ts +3 -0
  6. package/es/locale/en.js +3 -0
  7. package/es/locale/es.d.ts +3 -0
  8. package/es/locale/es.js +3 -0
  9. package/es/locale/hi.d.ts +3 -0
  10. package/es/locale/hi.js +3 -0
  11. package/es/locale/index.d.ts +3 -0
  12. package/es/locale/zh.d.ts +3 -0
  13. package/es/locale/zh.js +3 -0
  14. package/es/locale/zh_tw.d.ts +3 -0
  15. package/es/locale/zh_tw.js +3 -0
  16. package/es/modules/ConditionFormat.js +26 -0
  17. package/es/modules/cell.d.ts +5 -1
  18. package/es/modules/cell.js +182 -38
  19. package/es/modules/clipboard.js +111 -2
  20. package/es/modules/format.js +12 -7
  21. package/es/modules/formula.d.ts +23 -0
  22. package/es/modules/formula.js +610 -51
  23. package/es/modules/hyperlink.js +18 -6
  24. package/es/modules/inline-string.js +61 -8
  25. package/es/modules/moveCells.js +52 -9
  26. package/es/modules/selection.d.ts +1 -0
  27. package/es/modules/selection.js +102 -16
  28. package/es/modules/validation.js +6 -3
  29. package/es/paste-helpers/calculate-range-cell-size.js +5 -4
  30. package/es/paste-table-helpers.d.ts +1 -1
  31. package/es/paste-table-helpers.js +170 -21
  32. package/es/types.d.ts +3 -0
  33. package/lib/events/keyboard.d.ts +2 -2
  34. package/lib/events/keyboard.js +203 -29
  35. package/lib/events/mouse.js +78 -43
  36. package/lib/events/paste.js +238 -54
  37. package/lib/locale/en.d.ts +3 -0
  38. package/lib/locale/en.js +3 -0
  39. package/lib/locale/es.d.ts +3 -0
  40. package/lib/locale/es.js +3 -0
  41. package/lib/locale/hi.d.ts +3 -0
  42. package/lib/locale/hi.js +3 -0
  43. package/lib/locale/index.d.ts +3 -0
  44. package/lib/locale/zh.d.ts +3 -0
  45. package/lib/locale/zh.js +3 -0
  46. package/lib/locale/zh_tw.d.ts +3 -0
  47. package/lib/locale/zh_tw.js +3 -0
  48. package/lib/modules/ConditionFormat.js +26 -0
  49. package/lib/modules/cell.d.ts +5 -1
  50. package/lib/modules/cell.js +180 -36
  51. package/lib/modules/clipboard.js +111 -2
  52. package/lib/modules/format.js +12 -7
  53. package/lib/modules/formula.d.ts +23 -0
  54. package/lib/modules/formula.js +623 -51
  55. package/lib/modules/hyperlink.js +18 -6
  56. package/lib/modules/inline-string.js +61 -8
  57. package/lib/modules/moveCells.js +52 -9
  58. package/lib/modules/selection.d.ts +1 -0
  59. package/lib/modules/selection.js +101 -15
  60. package/lib/modules/validation.js +6 -3
  61. package/lib/paste-helpers/calculate-range-cell-size.js +5 -4
  62. package/lib/paste-table-helpers.d.ts +1 -1
  63. package/lib/paste-table-helpers.js +170 -21
  64. package/lib/types.d.ts +3 -0
  65. package/package.json +1 -1
@@ -49,10 +49,24 @@ function getCellRowColumn(ctx, e, container, scrollX, scrollY) {
49
49
  };
50
50
  }
51
51
  function getCellHyperlink(ctx, r, c) {
52
- var _a;
52
+ var _a, _b, _c, _d;
53
53
  var sheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
54
54
  if (sheetIndex != null) {
55
- return (_a = ctx.luckysheetfile[sheetIndex].hyperlink) === null || _a === void 0 ? void 0 : _a["".concat(r, "_").concat(c)];
55
+ var cellLink = (_a = ctx.luckysheetfile[sheetIndex].hyperlink) === null || _a === void 0 ? void 0 : _a["".concat(r, "_").concat(c)];
56
+ if (cellLink) return cellLink;
57
+ var cell = (_c = (_b = (0, _context.getFlowdata)(ctx)) === null || _b === void 0 ? void 0 : _b[r]) === null || _c === void 0 ? void 0 : _c[c];
58
+ if (((_d = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _d === void 0 ? void 0 : _d.t) === "inlineStr" && Array.isArray(cell.ct.s)) {
59
+ var seg = cell.ct.s.find(function (s) {
60
+ var _a;
61
+ return (_a = s.link) === null || _a === void 0 ? void 0 : _a.linkAddress;
62
+ });
63
+ if (seg) {
64
+ return {
65
+ linkType: seg.link.linkType,
66
+ linkAddress: seg.link.linkAddress
67
+ };
68
+ }
69
+ }
56
70
  }
57
71
  return undefined;
58
72
  }
@@ -230,12 +244,10 @@ function showLinkCard(ctx, r, c, options, isEditing, isMouseDown) {
230
244
  }
231
245
  }
232
246
  function goToLink(ctx, r, c, linkType, linkAddress, scrollbarX, scrollbarY) {
233
- var _a;
234
247
  var currSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
235
248
  if (currSheetIndex == null) return;
236
- if (((_a = ctx.luckysheetfile[currSheetIndex].hyperlink) === null || _a === void 0 ? void 0 : _a["".concat(r, "_").concat(c)]) == null) {
237
- return;
238
- }
249
+ var link = getCellHyperlink(ctx, r, c);
250
+ if (link == null) return;
239
251
  if (linkType === "webpage") {
240
252
  if (!/^http[s]?:\/\//.test(linkAddress)) {
241
253
  linkAddress = "https://".concat(linkAddress);
@@ -101,8 +101,13 @@ function convertCssToStyleList(cssText, originCell) {
101
101
  if (key === "color") {
102
102
  styleList.fc = value;
103
103
  }
104
- if (key === "text-decoration") {
105
- styleList.cl = 1;
104
+ if (key === "text-decoration" || key === "text-decoration-line") {
105
+ if (value.includes("underline")) {
106
+ styleList.un = 1;
107
+ }
108
+ if (value.includes("line-through")) {
109
+ styleList.cl = 1;
110
+ }
106
111
  }
107
112
  if (key === "border-bottom") {
108
113
  styleList.un = 1;
@@ -247,9 +252,12 @@ function getCssText(cssText, attr, value) {
247
252
  styleObj._color = fontColor;
248
253
  }
249
254
  var s = (0, _cell.getFontStyleByCell)(styleObj, undefined, undefined, false);
255
+ cssText = removeClassWidthCss(cssText, attr);
256
+ if (_lodash.default.isEmpty(s)) {
257
+ return cssText;
258
+ }
250
259
  var ukey = _lodash.default.kebabCase(Object.keys(s)[0]);
251
260
  var uvalue = Object.values(s)[0];
252
- cssText = removeClassWidthCss(cssText, attr);
253
261
  cssText = upsetClassWithCss(cssText, ukey, uvalue);
254
262
  return cssText;
255
263
  }
@@ -311,16 +319,31 @@ function escapeHtmlAttr(s) {
311
319
  return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
312
320
  }
313
321
  function updateInlineStringFormat(ctx, attr, value, cellInput) {
314
- var _a, _b, _c;
322
+ var _a, _b, _c, _d, _e, _f, _g, _h;
315
323
  var w = window.getSelection();
316
324
  if (!w) return;
317
325
  if (w.rangeCount === 0) return;
318
326
  var range = w.getRangeAt(0);
319
327
  var $textEditor = cellInput;
328
+ var editorText = ((_b = (_a = $textEditor.innerText) !== null && _a !== void 0 ? _a : $textEditor.textContent) !== null && _b !== void 0 ? _b : "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
329
+ var selectedText = ((_c = range.toString()) !== null && _c !== void 0 ? _c : "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
330
+ if (range.collapsed === false && editorText.length > 0 && selectedText === editorText) {
331
+ $textEditor.innerHTML = "";
332
+ var wrapper = document.createElement("span");
333
+ wrapper.setAttribute("style", getCssText("", attr, value));
334
+ wrapper.textContent = editorText;
335
+ $textEditor.appendChild(wrapper);
336
+ var newRange = document.createRange();
337
+ newRange.selectNodeContents($textEditor);
338
+ w.removeAllRanges();
339
+ w.addRange(newRange);
340
+ return;
341
+ }
320
342
  if (range.startContainer === $textEditor && range.endContainer === $textEditor && range.collapsed === false) {
321
343
  var start = range.startOffset;
322
344
  var end = range.endOffset;
323
345
  var children = Array.from($textEditor.childNodes).slice(start, end);
346
+ var hasUnsupportedElementSelection_1 = false;
324
347
  children.forEach(function (node) {
325
348
  var _a, _b;
326
349
  if (node.nodeType === Node.ELEMENT_NODE) {
@@ -328,6 +351,16 @@ function updateInlineStringFormat(ctx, attr, value, cellInput) {
328
351
  if (el.tagName === "SPAN") {
329
352
  var cssText = getCssText(el.style.cssText, attr, value);
330
353
  el.setAttribute("style", cssText);
354
+ } else {
355
+ var nestedSpans = el.querySelectorAll("span");
356
+ if (nestedSpans.length > 0) {
357
+ nestedSpans.forEach(function (nestedSpan) {
358
+ var cssText = getCssText(nestedSpan.style.cssText, attr, value);
359
+ nestedSpan.setAttribute("style", cssText);
360
+ });
361
+ } else {
362
+ hasUnsupportedElementSelection_1 = true;
363
+ }
331
364
  }
332
365
  } else if (node.nodeType === Node.TEXT_NODE) {
333
366
  var text = (_a = node.textContent) !== null && _a !== void 0 ? _a : "";
@@ -339,6 +372,14 @@ function updateInlineStringFormat(ctx, attr, value, cellInput) {
339
372
  (_b = node.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(wrapper, node);
340
373
  }
341
374
  });
375
+ if (hasUnsupportedElementSelection_1) {
376
+ var fullText = (_e = (_d = $textEditor.innerText) !== null && _d !== void 0 ? _d : $textEditor.textContent) !== null && _e !== void 0 ? _e : "";
377
+ $textEditor.innerHTML = "";
378
+ var wrapper = document.createElement("span");
379
+ wrapper.setAttribute("style", getCssText("", attr, value));
380
+ wrapper.textContent = fullText;
381
+ $textEditor.appendChild(wrapper);
382
+ }
342
383
  var newRange = document.createRange();
343
384
  newRange.selectNodeContents($textEditor);
344
385
  w.removeAllRanges();
@@ -367,8 +408,20 @@ function updateInlineStringFormat(ctx, attr, value, cellInput) {
367
408
  var mid = "";
368
409
  var right = "";
369
410
  var s1 = 0;
370
- var s2 = startOffset;
371
- var s3 = endOffset;
411
+ var htmlPre = 0;
412
+ if (startContainer.nodeType === Node.TEXT_NODE && span.childNodes.length > 1) {
413
+ for (var i = 0; i < span.childNodes.length; i += 1) {
414
+ var child = span.childNodes[i];
415
+ if (child === startContainer) break;
416
+ if (child.nodeType === Node.TEXT_NODE) {
417
+ htmlPre += (child.textContent || "").length;
418
+ } else if (child.nodeType === Node.ELEMENT_NODE) {
419
+ htmlPre += child.outerHTML.length;
420
+ }
421
+ }
422
+ }
423
+ var s2 = htmlPre + startOffset;
424
+ var s3 = htmlPre + endOffset;
372
425
  var s4 = content.length;
373
426
  left = content.substring(s1, s2);
374
427
  mid = content.substring(s2, s3);
@@ -404,7 +457,7 @@ function updateInlineStringFormat(ctx, attr, value, cellInput) {
404
457
  }
405
458
  cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(right, "</span>");
406
459
  }
407
- if (((_a = startContainer.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) === "SPAN") {
460
+ if (((_f = startContainer.parentElement) === null || _f === void 0 ? void 0 : _f.tagName) === "SPAN") {
408
461
  spanIndex = _lodash.default.indexOf($textEditor.querySelectorAll("span"), span);
409
462
  span.outerHTML = cont;
410
463
  } else {
@@ -420,7 +473,7 @@ function updateInlineStringFormat(ctx, attr, value, cellInput) {
420
473
  (0, _cursor.selectTextContent)($textEditor.querySelectorAll("span")[seletedNodeIndex]);
421
474
  }
422
475
  } else {
423
- if (((_b = startContainer.parentElement) === null || _b === void 0 ? void 0 : _b.tagName) === "SPAN" && ((_c = endContainer.parentElement) === null || _c === void 0 ? void 0 : _c.tagName) === "SPAN") {
476
+ if (((_g = startContainer.parentElement) === null || _g === void 0 ? void 0 : _g.tagName) === "SPAN" && ((_h = endContainer.parentElement) === null || _h === void 0 ? void 0 : _h.tagName) === "SPAN") {
424
477
  var startSpan = startContainer.parentNode;
425
478
  var endSpan = endContainer.parentNode;
426
479
  var allSpans = $textEditor.querySelectorAll("span");
@@ -18,6 +18,7 @@ var _utils = require("../utils");
18
18
  var _conditionalFormat = require("./conditionalFormat");
19
19
  var _refresh = require("./refresh");
20
20
  var _ConditionFormat = require("./ConditionFormat");
21
+ var _formula = require("./formula");
21
22
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
23
  var dragCellThreshold = 8;
23
24
  function getCellLocationByMouse(ctx, e, scrollbarX, scrollbarY, container) {
@@ -131,7 +132,7 @@ function onCellsMove(ctx, globalCache, e, scrollbarX, scrollbarY, container) {
131
132
  ele.style.display = "block";
132
133
  }
133
134
  function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container) {
134
- var _a, _b, _c, _d, _e;
135
+ var _a, _b, _c, _d, _e, _f;
135
136
  if (!ctx.luckysheet_cell_selected_move) return;
136
137
  ctx.luckysheet_cell_selected_move = false;
137
138
  var ele = document.getElementById("fortune-cell-selected-move");
@@ -140,17 +141,17 @@ function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container)
140
141
  globalCache.dragCellStartPos = undefined;
141
142
  return;
142
143
  }
143
- var _f = (0, _location.mousePosition)(e.pageX, e.pageY, ctx),
144
- x = _f[0],
145
- y = _f[1];
144
+ var _g = (0, _location.mousePosition)(e.pageX, e.pageY, ctx),
145
+ x = _g[0],
146
+ y = _g[1];
146
147
  var rect = container.getBoundingClientRect();
147
148
  var winH = rect.height - 20 * ctx.zoomRatio;
148
149
  var winW = rect.width - 60 * ctx.zoomRatio;
149
- var _g = getCellLocationByMouse(ctx, e, scrollbarX, scrollbarY, container),
150
- _h = _g.row,
151
- row_index = _h[2],
152
- _j = _g.column,
153
- col_index = _j[2];
150
+ var _h = getCellLocationByMouse(ctx, e, scrollbarX, scrollbarY, container),
151
+ _j = _h.row,
152
+ row_index = _j[2],
153
+ _k = _h.column,
154
+ col_index = _k[2];
154
155
  var allowEdit = (0, _utils.isAllowEdit)(ctx, [{
155
156
  row: [row_index, row_index],
156
157
  column: [col_index, col_index]
@@ -379,5 +380,47 @@ function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container)
379
380
  if (cellChanges.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
380
381
  ctx.hooks.updateCellYdoc(cellChanges);
381
382
  }
383
+ var sourceRect = {
384
+ rowStart: range[0].row[0],
385
+ rowEnd: range[0].row[1],
386
+ colStart: range[0].column[0],
387
+ colEnd: range[0].column[1]
388
+ };
389
+ var targetRowStart = row_s;
390
+ var targetColStart = col_s;
391
+ var movedSheet = ctx.luckysheetfile[index];
392
+ var movedSheetName = (movedSheet === null || movedSheet === void 0 ? void 0 : movedSheet.name) || "";
393
+ var refCellChanges = [];
394
+ for (var si = 0; si < ctx.luckysheetfile.length; si += 1) {
395
+ var sheet = ctx.luckysheetfile[si];
396
+ var sheetData = sheet.data;
397
+ if (!sheetData || !sheet.name) continue;
398
+ for (var r = 0; r < sheetData.length; r += 1) {
399
+ var rowData = sheetData[r];
400
+ if (!rowData) continue;
401
+ for (var c = 0; c < rowData.length; c += 1) {
402
+ var cell = rowData[c];
403
+ if (!(cell === null || cell === void 0 ? void 0 : cell.f)) continue;
404
+ var nextF = "=".concat((0, _formula.functionMoveReference)(cell.f, sheet.name, movedSheetName, sourceRect, targetRowStart, targetColStart));
405
+ if (nextF !== cell.f) {
406
+ cell.f = nextF;
407
+ refCellChanges.push({
408
+ sheetId: sheet.id || ctx.currentSheetId,
409
+ path: ["celldata"],
410
+ value: {
411
+ r: r,
412
+ c: c,
413
+ v: cell
414
+ },
415
+ key: "".concat(r, "_").concat(c),
416
+ type: "update"
417
+ });
418
+ }
419
+ }
420
+ }
421
+ }
422
+ if (refCellChanges.length > 0 && ((_f = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _f === void 0 ? void 0 : _f.updateCellYdoc)) {
423
+ ctx.hooks.updateCellYdoc(refCellChanges);
424
+ }
382
425
  (0, _refresh.jfrefreshgrid)(ctx, d, range);
383
426
  }
@@ -2,6 +2,7 @@ import type { Sheet as SheetType, Freezen, Range } from "../types";
2
2
  import { Context } from "../context";
3
3
  export declare const selectionCache: {
4
4
  isPasteAction: boolean;
5
+ isPasteValuesOnly: boolean;
5
6
  };
6
7
  export declare function scrollToHighlightCell(ctx: Context, r: number, c: number): void;
7
8
  export declare function seletedHighlistByindex(ctx: Context, r1: number, r2: number, c1: number, c2: number): {
@@ -34,12 +34,14 @@ exports.textFormat = textFormat;
34
34
  var _lodash = _interopRequireWildcard(require("lodash"));
35
35
  var _context = require("../context");
36
36
  var _cell = require("./cell");
37
+ var _inlineString = require("./inline-string");
37
38
  var _formula = require("./formula");
38
39
  var _clipboard = _interopRequireDefault(require("./clipboard"));
39
40
  var _border = require("./border");
40
41
  var _utils = require("../utils");
41
42
  var _validation = require("./validation");
42
43
  var _format = require("./format");
44
+ var _locale = require("../locale");
43
45
  var _ConditionFormat = require("./ConditionFormat");
44
46
  var _errorStateHelpers = require("./error-state-helpers");
45
47
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -56,7 +58,8 @@ var __assign = void 0 && (void 0).__assign || function () {
56
58
  return __assign.apply(this, arguments);
57
59
  };
58
60
  var selectionCache = exports.selectionCache = {
59
- isPasteAction: false
61
+ isPasteAction: false,
62
+ isPasteValuesOnly: false
60
63
  };
61
64
  function scrollToHighlightCell(ctx, r, c) {
62
65
  var _a, _b, _c, _d;
@@ -1221,7 +1224,7 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
1221
1224
  cpdata += "<tr height=".concat(rowLen, "px >");
1222
1225
  var _loop_3 = function _loop_3(j) {
1223
1226
  var c = colIndexArr[j];
1224
- var column = '<td ${span} style="${style}">';
1227
+ var column = '<td ${span} style="${style}" data-fortune-cell="${cellData}">';
1225
1228
  var cell = (_f = d[r]) === null || _f === void 0 ? void 0 : _f[c];
1226
1229
  if (cell != null) {
1227
1230
  var style = "";
@@ -1251,9 +1254,22 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
1251
1254
  c_value = (0, _cell.getCellValue)(r, c, d, "m");
1252
1255
  }
1253
1256
  var styleObj = (0, _cell.getStyleByCell)(ctx, d, r, c);
1254
- style += _lodash.default.map(styleObj, function (v, key) {
1257
+ if (styleObj.borderBottom) {
1258
+ var existing = styleObj.textDecoration;
1259
+ var decorations = new Set(existing ? existing.split(/\s+/).filter(Boolean) : []);
1260
+ decorations.add("underline");
1261
+ styleObj.textDecoration = Array.from(decorations).join(" ");
1262
+ styleObj.textDecorationSkipInk = "none";
1263
+ delete styleObj.borderBottom;
1264
+ }
1265
+ style += _lodash.default.toPairs(styleObj).filter(function (_a) {
1266
+ var v = _a[1];
1267
+ return !_lodash.default.isNil(v) && v !== "" && v !== "undefined";
1268
+ }).map(function (_a) {
1269
+ var key = _a[0],
1270
+ v = _a[1];
1255
1271
  return "".concat(_lodash.default.kebabCase(key), ":").concat(_lodash.default.isNumber(v) ? "".concat(v, "px") : v, ";");
1256
- }).join("");
1272
+ }).join(" ");
1257
1273
  if (cell.mc) {
1258
1274
  if ("rs" in cell.mc) {
1259
1275
  span = "rowspan=\"".concat(cell.mc.rs, "\" colspan=\"").concat(cell.mc.cs, "\"");
@@ -1432,17 +1448,31 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
1432
1448
  }
1433
1449
  }
1434
1450
  }
1451
+ var cellData = encodeURIComponent(JSON.stringify(__assign(__assign({}, cell), {
1452
+ _srcRow: r,
1453
+ _srcCol: c
1454
+ })));
1435
1455
  column = (0, _utils.replaceHtml)(column, {
1436
1456
  style: style,
1437
- span: span
1457
+ span: span,
1458
+ cellData: cellData
1438
1459
  });
1439
- if (_lodash.default.isNil(c_value)) {
1440
- c_value = (0, _cell.getCellValue)(r, c, d);
1441
- }
1442
- if (_lodash.default.isNil(c_value)) {
1443
- c_value = "";
1460
+ var cellHtml = "";
1461
+ if (cell && (0, _inlineString.isInlineStringCell)(cell)) {
1462
+ cellHtml = (0, _cell.getInlineStringHTML)(r, c, d, {
1463
+ useSemanticMarkup: true,
1464
+ inheritedStyle: styleObj
1465
+ });
1466
+ } else {
1467
+ if (_lodash.default.isNil(c_value)) {
1468
+ c_value = (0, _cell.getCellValue)(r, c, d);
1469
+ }
1470
+ if (_lodash.default.isNil(c_value)) {
1471
+ c_value = "";
1472
+ }
1473
+ cellHtml = (0, _utils.escapeHTMLTag)(String(c_value)).replace(/&lt;br\s*\/?&gt;/g, "<br>");
1444
1474
  }
1445
- column += (0, _utils.escapeHTMLTag)(c_value);
1475
+ column += cellHtml;
1446
1476
  } else {
1447
1477
  var style = "";
1448
1478
  if (borderInfoCompute && borderInfoCompute["".concat(r, "_").concat(c)]) {
@@ -1484,7 +1514,8 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
1484
1514
  }
1485
1515
  column = (0, _utils.replaceHtml)(column, {
1486
1516
  style: style,
1487
- span: ""
1517
+ span: "",
1518
+ cellData: ""
1488
1519
  });
1489
1520
  column += "";
1490
1521
  }
@@ -1499,7 +1530,7 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
1499
1530
  return "<table data-type=\"fortune-copy-action-table\">".concat(colgroup).concat(cpdata, "</table>");
1500
1531
  }
1501
1532
  function copy(ctx) {
1502
- var _a, _b, _c, _d;
1533
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1503
1534
  var flowdata = (0, _context.getFlowdata)(ctx);
1504
1535
  ctx.luckysheet_selection_range = [];
1505
1536
  var copyRange = [];
@@ -1543,8 +1574,63 @@ function copy(ctx) {
1543
1574
  RowlChange: RowlChange,
1544
1575
  HasMC: HasMC
1545
1576
  };
1546
- var cpdata = rangeValueToHtml(ctx, ctx.currentSheetId, ctx.luckysheet_select_save);
1547
- cpdata = cpdata === null ? cpdata : cpdata.replace('<td style="', '<td style="white-space: pre-line;"');
1577
+ var cpdata;
1578
+ var sel = ctx.luckysheet_select_save;
1579
+ var isSingleCell = (sel === null || sel === void 0 ? void 0 : sel.length) === 1 && sel[0].row[0] === sel[0].row[1] && sel[0].column[0] === sel[0].column[1];
1580
+ if (isSingleCell) {
1581
+ var r = sel[0].row[0];
1582
+ var c = sel[0].column[0];
1583
+ var fontarray = (0, _locale.locale)(ctx).fontarray;
1584
+ var defaultStyle = {
1585
+ color: "#000000",
1586
+ fontFamily: (_e = fontarray[0]) !== null && _e !== void 0 ? _e : "Arial",
1587
+ fontSize: "11pt",
1588
+ fontWeight: "400",
1589
+ fontStyle: "normal",
1590
+ textAlign: "left",
1591
+ backgroundColor: "transparent"
1592
+ };
1593
+ var cell = (_f = flowdata[r]) === null || _f === void 0 ? void 0 : _f[c];
1594
+ var isRichText_1 = cell != null && (0, _inlineString.isInlineStringCell)(cell);
1595
+ var styleObj = (0, _cell.getStyleByCell)(ctx, flowdata, r, c);
1596
+ if (styleObj.borderBottom) {
1597
+ var existing = styleObj.textDecoration;
1598
+ var decorations = new Set(existing ? existing.split(/\s+/).filter(Boolean) : []);
1599
+ decorations.add("underline");
1600
+ styleObj.textDecoration = Array.from(decorations).join(" ");
1601
+ styleObj.textDecorationSkipInk = "none";
1602
+ delete styleObj.borderBottom;
1603
+ }
1604
+ var mergedStyle = __assign(__assign({}, defaultStyle), styleObj);
1605
+ var TEXT_LEVEL_KEYS_1 = new Set(["color", "fontFamily", "fontSize", "fontWeight", "fontStyle", "textDecoration", "textDecorationSkipInk"]);
1606
+ var styleStr = _lodash.default.toPairs(mergedStyle).filter(function (_a) {
1607
+ var k = _a[0],
1608
+ v = _a[1];
1609
+ return !_lodash.default.isNil(v) && v !== "" && v !== "undefined" && !(isRichText_1 && TEXT_LEVEL_KEYS_1.has(k));
1610
+ }).map(function (_a) {
1611
+ var key = _a[0],
1612
+ v = _a[1];
1613
+ return "".concat(_lodash.default.kebabCase(key), ":").concat(_lodash.default.isNumber(v) ? "".concat(v, "px") : v, ";");
1614
+ }).join(" ");
1615
+ var innerContent = void 0;
1616
+ if (isRichText_1) {
1617
+ innerContent = (0, _cell.getInlineStringHTML)(r, c, flowdata, {
1618
+ useSemanticMarkup: true,
1619
+ inheritedStyle: mergedStyle
1620
+ });
1621
+ } else {
1622
+ var displayValue = (_h = (_g = (0, _cell.getCellValue)(r, c, flowdata, "m")) !== null && _g !== void 0 ? _g : (0, _cell.getCellValue)(r, c, flowdata)) !== null && _h !== void 0 ? _h : "";
1623
+ innerContent = (0, _utils.escapeHTMLTag)(String(displayValue)).replace(/&lt;br\s*\/?&gt;/g, "<br>");
1624
+ }
1625
+ var cellData = encodeURIComponent(JSON.stringify(__assign(__assign({}, cell !== null && cell !== void 0 ? cell : {}), {
1626
+ _srcRow: r,
1627
+ _srcCol: c
1628
+ })));
1629
+ cpdata = "<table data-type=\"fortune-copy-action-table\"><tr><td style=\"white-space: pre-line; ".concat(styleStr, "\" data-fortune-cell=\"").concat(cellData, "\">").concat(innerContent, "</td></tr></table>");
1630
+ } else {
1631
+ cpdata = rangeValueToHtml(ctx, ctx.currentSheetId, ctx.luckysheet_select_save);
1632
+ cpdata = cpdata === null ? cpdata : cpdata.replace('<td style="', '<td style="white-space: pre-line; ');
1633
+ }
1548
1634
  if (cpdata) {
1549
1635
  ctx.iscopyself = true;
1550
1636
  _clipboard.default.writeHtml(cpdata);
@@ -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
  }
@@ -16,9 +16,6 @@ var getColumnWidth = function getColumnWidth(colIndex, ctx, sheetFile) {
16
16
  var defaultColumnWidth = (_a = ctx.defaultcollen) !== null && _a !== void 0 ? _a : 73;
17
17
  return (_d = (_c = (_b = sheetFile.config) === null || _b === void 0 ? void 0 : _b.columnlen) === null || _c === void 0 ? void 0 : _c[colIndex]) !== null && _d !== void 0 ? _d : defaultColumnWidth;
18
18
  };
19
- var isCellWrapped = function isCellWrapped(cell) {
20
- return Number(cell === null || cell === void 0 ? void 0 : cell.tb) === 1;
21
- };
22
19
  var getCellDisplayText = function getCellDisplayText(cell) {
23
20
  var _a, _b;
24
21
  var text = (_a = cell === null || cell === void 0 ? void 0 : cell.m) !== null && _a !== void 0 ? _a : cell === null || cell === void 0 ? void 0 : cell.v;
@@ -29,6 +26,10 @@ var getCellDisplayText = function getCellDisplayText(cell) {
29
26
  }
30
27
  return text == null ? "" : String(text);
31
28
  };
29
+ var isCellWrapped = function isCellWrapped(cell) {
30
+ var _a;
31
+ return Number(cell === null || cell === void 0 ? void 0 : cell.tb) === 2 || ((_a = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _a === void 0 ? void 0 : _a.t) === "inlineStr" || /[\r\n]/.test(getCellDisplayText(cell));
32
+ };
32
33
  var applyFontOnMeasurer = function applyFontOnMeasurer(cell, cellSizeMeasurer) {
33
34
  var _a, _b;
34
35
  var fontSizePx = (_a = cell === null || cell === void 0 ? void 0 : cell.fs) !== null && _a !== void 0 ? _a : _pasteTableHelpers.DEFAULT_FONT_SIZE;
@@ -92,7 +93,7 @@ function calculateRangeCellSize(ctx, sheetId, startRow, endRow, startCol, endCol
92
93
  var fontSizePx = applyFontOnMeasurer(cell, cellSizeMeasurer);
93
94
  if (isCellWrapped(cell)) {
94
95
  var finalColumnWidth = Math.max(getColumnWidth(col, ctx, sheetFile), maxColumnWidths[col] || 0);
95
- cellSizeMeasurer.style.whiteSpace = "normal";
96
+ cellSizeMeasurer.style.whiteSpace = /[\r\n]/.test(text) ? "pre-wrap" : "normal";
96
97
  cellSizeMeasurer.style.width = "".concat(Math.max(5, finalColumnWidth - 8), "px");
97
98
  cellSizeMeasurer.textContent = text;
98
99
  var wrappedHeight = Math.ceil(cellSizeMeasurer.scrollHeight + 6);
@@ -1,3 +1,3 @@
1
1
  import { Context } from "./context";
2
- export declare const DEFAULT_FONT_SIZE = 12;
2
+ export declare const DEFAULT_FONT_SIZE = 10;
3
3
  export declare function handlePastedTable(ctx: Context, html: string, pasteHandler: (context: Context, data: any, borderInfo?: any) => void): void;