@fileverse-dev/fortune-core 1.3.12 → 1.3.13-create-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.
- package/es/events/keyboard.d.ts +2 -2
- package/es/events/keyboard.js +204 -30
- package/es/events/mouse.js +79 -44
- package/es/events/paste.js +177 -56
- package/es/locale/en.d.ts +3 -0
- package/es/locale/en.js +3 -0
- package/es/locale/es.d.ts +3 -0
- package/es/locale/es.js +3 -0
- package/es/locale/hi.d.ts +3 -0
- package/es/locale/hi.js +3 -0
- package/es/locale/index.d.ts +3 -0
- package/es/locale/zh.d.ts +3 -0
- package/es/locale/zh.js +3 -0
- package/es/locale/zh_tw.d.ts +3 -0
- package/es/locale/zh_tw.js +3 -0
- package/es/modules/ConditionFormat.js +26 -0
- package/es/modules/cell.d.ts +4 -1
- package/es/modules/cell.js +124 -15
- package/es/modules/clipboard.js +111 -2
- package/es/modules/format.js +12 -7
- package/es/modules/formula.d.ts +23 -0
- package/es/modules/formula.js +610 -51
- package/es/modules/hyperlink.js +18 -6
- package/es/modules/inline-string.js +21 -4
- package/es/modules/moveCells.js +52 -9
- package/es/modules/selection.d.ts +1 -0
- package/es/modules/selection.js +102 -16
- package/es/modules/validation.js +6 -3
- package/es/paste-helpers/calculate-range-cell-size.js +5 -4
- package/es/paste-table-helpers.d.ts +1 -1
- package/es/paste-table-helpers.js +170 -21
- package/es/types.d.ts +3 -0
- package/lib/events/keyboard.d.ts +2 -2
- package/lib/events/keyboard.js +203 -29
- package/lib/events/mouse.js +78 -43
- package/lib/events/paste.js +175 -54
- package/lib/locale/en.d.ts +3 -0
- package/lib/locale/en.js +3 -0
- package/lib/locale/es.d.ts +3 -0
- package/lib/locale/es.js +3 -0
- package/lib/locale/hi.d.ts +3 -0
- package/lib/locale/hi.js +3 -0
- package/lib/locale/index.d.ts +3 -0
- package/lib/locale/zh.d.ts +3 -0
- package/lib/locale/zh.js +3 -0
- package/lib/locale/zh_tw.d.ts +3 -0
- package/lib/locale/zh_tw.js +3 -0
- package/lib/modules/ConditionFormat.js +26 -0
- package/lib/modules/cell.d.ts +4 -1
- package/lib/modules/cell.js +123 -14
- package/lib/modules/clipboard.js +111 -2
- package/lib/modules/format.js +12 -7
- package/lib/modules/formula.d.ts +23 -0
- package/lib/modules/formula.js +623 -51
- package/lib/modules/hyperlink.js +18 -6
- package/lib/modules/inline-string.js +21 -4
- package/lib/modules/moveCells.js +52 -9
- package/lib/modules/selection.d.ts +1 -0
- package/lib/modules/selection.js +101 -15
- package/lib/modules/validation.js +6 -3
- package/lib/paste-helpers/calculate-range-cell-size.js +5 -4
- package/lib/paste-table-helpers.d.ts +1 -1
- package/lib/paste-table-helpers.js +170 -21
- package/lib/types.d.ts +3 -0
- package/package.json +1 -1
package/lib/modules/hyperlink.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
237
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -367,8 +372,20 @@ function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
|
367
372
|
var mid = "";
|
|
368
373
|
var right = "";
|
|
369
374
|
var s1 = 0;
|
|
370
|
-
var
|
|
371
|
-
|
|
375
|
+
var htmlPre = 0;
|
|
376
|
+
if (startContainer.nodeType === Node.TEXT_NODE && span.childNodes.length > 1) {
|
|
377
|
+
for (var i = 0; i < span.childNodes.length; i += 1) {
|
|
378
|
+
var child = span.childNodes[i];
|
|
379
|
+
if (child === startContainer) break;
|
|
380
|
+
if (child.nodeType === Node.TEXT_NODE) {
|
|
381
|
+
htmlPre += (child.textContent || "").length;
|
|
382
|
+
} else if (child.nodeType === Node.ELEMENT_NODE) {
|
|
383
|
+
htmlPre += child.outerHTML.length;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
var s2 = htmlPre + startOffset;
|
|
388
|
+
var s3 = htmlPre + endOffset;
|
|
372
389
|
var s4 = content.length;
|
|
373
390
|
left = content.substring(s1, s2);
|
|
374
391
|
mid = content.substring(s2, s3);
|
package/lib/modules/moveCells.js
CHANGED
|
@@ -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
|
|
144
|
-
x =
|
|
145
|
-
y =
|
|
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
|
|
150
|
-
|
|
151
|
-
row_index =
|
|
152
|
-
|
|
153
|
-
col_index =
|
|
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): {
|
package/lib/modules/selection.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
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(/<br\s*\/?>/g, "<br>");
|
|
1444
1474
|
}
|
|
1445
|
-
column +=
|
|
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
|
|
1547
|
-
|
|
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(/<br\s*\/?>/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 =
|
|
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;
|