@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.
- 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 +240 -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 +5 -1
- package/es/modules/cell.js +182 -38
- 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 +61 -8
- 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 +238 -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 +5 -1
- package/lib/modules/cell.js +180 -36
- 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 +61 -8
- 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/es/modules/hyperlink.js
CHANGED
|
@@ -33,10 +33,24 @@ export function getCellRowColumn(ctx, e, container, scrollX, scrollY) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
export function getCellHyperlink(ctx, r, c) {
|
|
36
|
-
var _a;
|
|
36
|
+
var _a, _b, _c, _d;
|
|
37
37
|
var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
38
38
|
if (sheetIndex != null) {
|
|
39
|
-
|
|
39
|
+
var cellLink = (_a = ctx.luckysheetfile[sheetIndex].hyperlink) === null || _a === void 0 ? void 0 : _a["".concat(r, "_").concat(c)];
|
|
40
|
+
if (cellLink) return cellLink;
|
|
41
|
+
var cell = (_c = (_b = getFlowdata(ctx)) === null || _b === void 0 ? void 0 : _b[r]) === null || _c === void 0 ? void 0 : _c[c];
|
|
42
|
+
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)) {
|
|
43
|
+
var seg = cell.ct.s.find(function (s) {
|
|
44
|
+
var _a;
|
|
45
|
+
return (_a = s.link) === null || _a === void 0 ? void 0 : _a.linkAddress;
|
|
46
|
+
});
|
|
47
|
+
if (seg) {
|
|
48
|
+
return {
|
|
49
|
+
linkType: seg.link.linkType,
|
|
50
|
+
linkAddress: seg.link.linkAddress
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
40
54
|
}
|
|
41
55
|
return undefined;
|
|
42
56
|
}
|
|
@@ -214,12 +228,10 @@ export function showLinkCard(ctx, r, c, options, isEditing, isMouseDown) {
|
|
|
214
228
|
}
|
|
215
229
|
}
|
|
216
230
|
export function goToLink(ctx, r, c, linkType, linkAddress, scrollbarX, scrollbarY) {
|
|
217
|
-
var _a;
|
|
218
231
|
var currSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
219
232
|
if (currSheetIndex == null) return;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
233
|
+
var link = getCellHyperlink(ctx, r, c);
|
|
234
|
+
if (link == null) return;
|
|
223
235
|
if (linkType === "webpage") {
|
|
224
236
|
if (!/^http[s]?:\/\//.test(linkAddress)) {
|
|
225
237
|
linkAddress = "https://".concat(linkAddress);
|
|
@@ -85,8 +85,13 @@ export function convertCssToStyleList(cssText, originCell) {
|
|
|
85
85
|
if (key === "color") {
|
|
86
86
|
styleList.fc = value;
|
|
87
87
|
}
|
|
88
|
-
if (key === "text-decoration") {
|
|
89
|
-
|
|
88
|
+
if (key === "text-decoration" || key === "text-decoration-line") {
|
|
89
|
+
if (value.includes("underline")) {
|
|
90
|
+
styleList.un = 1;
|
|
91
|
+
}
|
|
92
|
+
if (value.includes("line-through")) {
|
|
93
|
+
styleList.cl = 1;
|
|
94
|
+
}
|
|
90
95
|
}
|
|
91
96
|
if (key === "border-bottom") {
|
|
92
97
|
styleList.un = 1;
|
|
@@ -231,9 +236,12 @@ function getCssText(cssText, attr, value) {
|
|
|
231
236
|
styleObj._color = fontColor;
|
|
232
237
|
}
|
|
233
238
|
var s = getFontStyleByCell(styleObj, undefined, undefined, false);
|
|
239
|
+
cssText = removeClassWidthCss(cssText, attr);
|
|
240
|
+
if (_.isEmpty(s)) {
|
|
241
|
+
return cssText;
|
|
242
|
+
}
|
|
234
243
|
var ukey = _.kebabCase(Object.keys(s)[0]);
|
|
235
244
|
var uvalue = Object.values(s)[0];
|
|
236
|
-
cssText = removeClassWidthCss(cssText, attr);
|
|
237
245
|
cssText = upsetClassWithCss(cssText, ukey, uvalue);
|
|
238
246
|
return cssText;
|
|
239
247
|
}
|
|
@@ -295,16 +303,31 @@ function escapeHtmlAttr(s) {
|
|
|
295
303
|
return s.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
296
304
|
}
|
|
297
305
|
export function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
298
|
-
var _a, _b, _c;
|
|
306
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
299
307
|
var w = window.getSelection();
|
|
300
308
|
if (!w) return;
|
|
301
309
|
if (w.rangeCount === 0) return;
|
|
302
310
|
var range = w.getRangeAt(0);
|
|
303
311
|
var $textEditor = cellInput;
|
|
312
|
+
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");
|
|
313
|
+
var selectedText = ((_c = range.toString()) !== null && _c !== void 0 ? _c : "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
314
|
+
if (range.collapsed === false && editorText.length > 0 && selectedText === editorText) {
|
|
315
|
+
$textEditor.innerHTML = "";
|
|
316
|
+
var wrapper = document.createElement("span");
|
|
317
|
+
wrapper.setAttribute("style", getCssText("", attr, value));
|
|
318
|
+
wrapper.textContent = editorText;
|
|
319
|
+
$textEditor.appendChild(wrapper);
|
|
320
|
+
var newRange = document.createRange();
|
|
321
|
+
newRange.selectNodeContents($textEditor);
|
|
322
|
+
w.removeAllRanges();
|
|
323
|
+
w.addRange(newRange);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
304
326
|
if (range.startContainer === $textEditor && range.endContainer === $textEditor && range.collapsed === false) {
|
|
305
327
|
var start = range.startOffset;
|
|
306
328
|
var end = range.endOffset;
|
|
307
329
|
var children = Array.from($textEditor.childNodes).slice(start, end);
|
|
330
|
+
var hasUnsupportedElementSelection_1 = false;
|
|
308
331
|
children.forEach(function (node) {
|
|
309
332
|
var _a, _b;
|
|
310
333
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
@@ -312,6 +335,16 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
|
312
335
|
if (el.tagName === "SPAN") {
|
|
313
336
|
var cssText = getCssText(el.style.cssText, attr, value);
|
|
314
337
|
el.setAttribute("style", cssText);
|
|
338
|
+
} else {
|
|
339
|
+
var nestedSpans = el.querySelectorAll("span");
|
|
340
|
+
if (nestedSpans.length > 0) {
|
|
341
|
+
nestedSpans.forEach(function (nestedSpan) {
|
|
342
|
+
var cssText = getCssText(nestedSpan.style.cssText, attr, value);
|
|
343
|
+
nestedSpan.setAttribute("style", cssText);
|
|
344
|
+
});
|
|
345
|
+
} else {
|
|
346
|
+
hasUnsupportedElementSelection_1 = true;
|
|
347
|
+
}
|
|
315
348
|
}
|
|
316
349
|
} else if (node.nodeType === Node.TEXT_NODE) {
|
|
317
350
|
var text = (_a = node.textContent) !== null && _a !== void 0 ? _a : "";
|
|
@@ -323,6 +356,14 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
|
323
356
|
(_b = node.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(wrapper, node);
|
|
324
357
|
}
|
|
325
358
|
});
|
|
359
|
+
if (hasUnsupportedElementSelection_1) {
|
|
360
|
+
var fullText = (_e = (_d = $textEditor.innerText) !== null && _d !== void 0 ? _d : $textEditor.textContent) !== null && _e !== void 0 ? _e : "";
|
|
361
|
+
$textEditor.innerHTML = "";
|
|
362
|
+
var wrapper = document.createElement("span");
|
|
363
|
+
wrapper.setAttribute("style", getCssText("", attr, value));
|
|
364
|
+
wrapper.textContent = fullText;
|
|
365
|
+
$textEditor.appendChild(wrapper);
|
|
366
|
+
}
|
|
326
367
|
var newRange = document.createRange();
|
|
327
368
|
newRange.selectNodeContents($textEditor);
|
|
328
369
|
w.removeAllRanges();
|
|
@@ -351,8 +392,20 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
|
351
392
|
var mid = "";
|
|
352
393
|
var right = "";
|
|
353
394
|
var s1 = 0;
|
|
354
|
-
var
|
|
355
|
-
|
|
395
|
+
var htmlPre = 0;
|
|
396
|
+
if (startContainer.nodeType === Node.TEXT_NODE && span.childNodes.length > 1) {
|
|
397
|
+
for (var i = 0; i < span.childNodes.length; i += 1) {
|
|
398
|
+
var child = span.childNodes[i];
|
|
399
|
+
if (child === startContainer) break;
|
|
400
|
+
if (child.nodeType === Node.TEXT_NODE) {
|
|
401
|
+
htmlPre += (child.textContent || "").length;
|
|
402
|
+
} else if (child.nodeType === Node.ELEMENT_NODE) {
|
|
403
|
+
htmlPre += child.outerHTML.length;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
var s2 = htmlPre + startOffset;
|
|
408
|
+
var s3 = htmlPre + endOffset;
|
|
356
409
|
var s4 = content.length;
|
|
357
410
|
left = content.substring(s1, s2);
|
|
358
411
|
mid = content.substring(s2, s3);
|
|
@@ -388,7 +441,7 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
|
388
441
|
}
|
|
389
442
|
cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(right, "</span>");
|
|
390
443
|
}
|
|
391
|
-
if (((
|
|
444
|
+
if (((_f = startContainer.parentElement) === null || _f === void 0 ? void 0 : _f.tagName) === "SPAN") {
|
|
392
445
|
spanIndex = _.indexOf($textEditor.querySelectorAll("span"), span);
|
|
393
446
|
span.outerHTML = cont;
|
|
394
447
|
} else {
|
|
@@ -404,7 +457,7 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
|
404
457
|
selectTextContent($textEditor.querySelectorAll("span")[seletedNodeIndex]);
|
|
405
458
|
}
|
|
406
459
|
} else {
|
|
407
|
-
if (((
|
|
460
|
+
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") {
|
|
408
461
|
var startSpan = startContainer.parentNode;
|
|
409
462
|
var endSpan = endContainer.parentNode;
|
|
410
463
|
var allSpans = $textEditor.querySelectorAll("span");
|
package/es/modules/moveCells.js
CHANGED
|
@@ -10,6 +10,7 @@ import { getSheetIndex, isAllowEdit } from "../utils";
|
|
|
10
10
|
import { cfSplitRange } from "./conditionalFormat";
|
|
11
11
|
import { jfrefreshgrid } from "./refresh";
|
|
12
12
|
import { CFSplitRange } from "./ConditionFormat";
|
|
13
|
+
import { functionMoveReference } from "./formula";
|
|
13
14
|
var dragCellThreshold = 8;
|
|
14
15
|
function getCellLocationByMouse(ctx, e, scrollbarX, scrollbarY, container) {
|
|
15
16
|
var rect = container.getBoundingClientRect();
|
|
@@ -122,7 +123,7 @@ export function onCellsMove(ctx, globalCache, e, scrollbarX, scrollbarY, contain
|
|
|
122
123
|
ele.style.display = "block";
|
|
123
124
|
}
|
|
124
125
|
export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, container) {
|
|
125
|
-
var _a, _b, _c, _d, _e;
|
|
126
|
+
var _a, _b, _c, _d, _e, _f;
|
|
126
127
|
if (!ctx.luckysheet_cell_selected_move) return;
|
|
127
128
|
ctx.luckysheet_cell_selected_move = false;
|
|
128
129
|
var ele = document.getElementById("fortune-cell-selected-move");
|
|
@@ -131,17 +132,17 @@ export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, cont
|
|
|
131
132
|
globalCache.dragCellStartPos = undefined;
|
|
132
133
|
return;
|
|
133
134
|
}
|
|
134
|
-
var
|
|
135
|
-
x =
|
|
136
|
-
y =
|
|
135
|
+
var _g = mousePosition(e.pageX, e.pageY, ctx),
|
|
136
|
+
x = _g[0],
|
|
137
|
+
y = _g[1];
|
|
137
138
|
var rect = container.getBoundingClientRect();
|
|
138
139
|
var winH = rect.height - 20 * ctx.zoomRatio;
|
|
139
140
|
var winW = rect.width - 60 * ctx.zoomRatio;
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
row_index =
|
|
143
|
-
|
|
144
|
-
col_index =
|
|
141
|
+
var _h = getCellLocationByMouse(ctx, e, scrollbarX, scrollbarY, container),
|
|
142
|
+
_j = _h.row,
|
|
143
|
+
row_index = _j[2],
|
|
144
|
+
_k = _h.column,
|
|
145
|
+
col_index = _k[2];
|
|
145
146
|
var allowEdit = isAllowEdit(ctx, [{
|
|
146
147
|
row: [row_index, row_index],
|
|
147
148
|
column: [col_index, col_index]
|
|
@@ -370,5 +371,47 @@ export function onCellsMoveEnd(ctx, globalCache, e, scrollbarX, scrollbarY, cont
|
|
|
370
371
|
if (cellChanges.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
|
|
371
372
|
ctx.hooks.updateCellYdoc(cellChanges);
|
|
372
373
|
}
|
|
374
|
+
var sourceRect = {
|
|
375
|
+
rowStart: range[0].row[0],
|
|
376
|
+
rowEnd: range[0].row[1],
|
|
377
|
+
colStart: range[0].column[0],
|
|
378
|
+
colEnd: range[0].column[1]
|
|
379
|
+
};
|
|
380
|
+
var targetRowStart = row_s;
|
|
381
|
+
var targetColStart = col_s;
|
|
382
|
+
var movedSheet = ctx.luckysheetfile[index];
|
|
383
|
+
var movedSheetName = (movedSheet === null || movedSheet === void 0 ? void 0 : movedSheet.name) || "";
|
|
384
|
+
var refCellChanges = [];
|
|
385
|
+
for (var si = 0; si < ctx.luckysheetfile.length; si += 1) {
|
|
386
|
+
var sheet = ctx.luckysheetfile[si];
|
|
387
|
+
var sheetData = sheet.data;
|
|
388
|
+
if (!sheetData || !sheet.name) continue;
|
|
389
|
+
for (var r = 0; r < sheetData.length; r += 1) {
|
|
390
|
+
var rowData = sheetData[r];
|
|
391
|
+
if (!rowData) continue;
|
|
392
|
+
for (var c = 0; c < rowData.length; c += 1) {
|
|
393
|
+
var cell = rowData[c];
|
|
394
|
+
if (!(cell === null || cell === void 0 ? void 0 : cell.f)) continue;
|
|
395
|
+
var nextF = "=".concat(functionMoveReference(cell.f, sheet.name, movedSheetName, sourceRect, targetRowStart, targetColStart));
|
|
396
|
+
if (nextF !== cell.f) {
|
|
397
|
+
cell.f = nextF;
|
|
398
|
+
refCellChanges.push({
|
|
399
|
+
sheetId: sheet.id || ctx.currentSheetId,
|
|
400
|
+
path: ["celldata"],
|
|
401
|
+
value: {
|
|
402
|
+
r: r,
|
|
403
|
+
c: c,
|
|
404
|
+
v: cell
|
|
405
|
+
},
|
|
406
|
+
key: "".concat(r, "_").concat(c),
|
|
407
|
+
type: "update"
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
if (refCellChanges.length > 0 && ((_f = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _f === void 0 ? void 0 : _f.updateCellYdoc)) {
|
|
414
|
+
ctx.hooks.updateCellYdoc(refCellChanges);
|
|
415
|
+
}
|
|
373
416
|
jfrefreshgrid(ctx, d, range);
|
|
374
417
|
}
|
|
@@ -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/es/modules/selection.js
CHANGED
|
@@ -11,17 +11,20 @@ var __assign = this && this.__assign || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import _, { isPlainObject } from "lodash";
|
|
13
13
|
import { getFlowdata } from "../context";
|
|
14
|
-
import { getCellValue, getdatabyselection, getDataBySelectionNoCopy, getStyleByCell, mergeBorder, mergeMoveMain } from "./cell";
|
|
14
|
+
import { getCellValue, getdatabyselection, getDataBySelectionNoCopy, getStyleByCell, getInlineStringHTML, mergeBorder, mergeMoveMain } from "./cell";
|
|
15
|
+
import { isInlineStringCell } from "./inline-string";
|
|
15
16
|
import { delFunctionGroup } from "./formula";
|
|
16
17
|
import clipboard from "./clipboard";
|
|
17
18
|
import { getBorderInfoCompute } from "./border";
|
|
18
19
|
import { escapeHTMLTag, getSheetIndex, isAllowEdit, replaceHtml } from "../utils";
|
|
19
20
|
import { hasPartMC } from "./validation";
|
|
20
21
|
import { update } from "./format";
|
|
22
|
+
import { locale } from "../locale";
|
|
21
23
|
import { CFSplitRange } from "./ConditionFormat";
|
|
22
24
|
import { clearCellError } from "./error-state-helpers";
|
|
23
25
|
export var selectionCache = {
|
|
24
|
-
isPasteAction: false
|
|
26
|
+
isPasteAction: false,
|
|
27
|
+
isPasteValuesOnly: false
|
|
25
28
|
};
|
|
26
29
|
export function scrollToHighlightCell(ctx, r, c) {
|
|
27
30
|
var _a, _b, _c, _d;
|
|
@@ -1186,7 +1189,7 @@ export function rangeValueToHtml(ctx, sheetId, ranges) {
|
|
|
1186
1189
|
cpdata += "<tr height=".concat(rowLen, "px >");
|
|
1187
1190
|
var _loop_3 = function _loop_3(j) {
|
|
1188
1191
|
var c = colIndexArr[j];
|
|
1189
|
-
var column = '<td ${span} style="${style}">';
|
|
1192
|
+
var column = '<td ${span} style="${style}" data-fortune-cell="${cellData}">';
|
|
1190
1193
|
var cell = (_f = d[r]) === null || _f === void 0 ? void 0 : _f[c];
|
|
1191
1194
|
if (cell != null) {
|
|
1192
1195
|
var style = "";
|
|
@@ -1216,9 +1219,22 @@ export function rangeValueToHtml(ctx, sheetId, ranges) {
|
|
|
1216
1219
|
c_value = getCellValue(r, c, d, "m");
|
|
1217
1220
|
}
|
|
1218
1221
|
var styleObj = getStyleByCell(ctx, d, r, c);
|
|
1219
|
-
|
|
1222
|
+
if (styleObj.borderBottom) {
|
|
1223
|
+
var existing = styleObj.textDecoration;
|
|
1224
|
+
var decorations = new Set(existing ? existing.split(/\s+/).filter(Boolean) : []);
|
|
1225
|
+
decorations.add("underline");
|
|
1226
|
+
styleObj.textDecoration = Array.from(decorations).join(" ");
|
|
1227
|
+
styleObj.textDecorationSkipInk = "none";
|
|
1228
|
+
delete styleObj.borderBottom;
|
|
1229
|
+
}
|
|
1230
|
+
style += _.toPairs(styleObj).filter(function (_a) {
|
|
1231
|
+
var v = _a[1];
|
|
1232
|
+
return !_.isNil(v) && v !== "" && v !== "undefined";
|
|
1233
|
+
}).map(function (_a) {
|
|
1234
|
+
var key = _a[0],
|
|
1235
|
+
v = _a[1];
|
|
1220
1236
|
return "".concat(_.kebabCase(key), ":").concat(_.isNumber(v) ? "".concat(v, "px") : v, ";");
|
|
1221
|
-
}).join("");
|
|
1237
|
+
}).join(" ");
|
|
1222
1238
|
if (cell.mc) {
|
|
1223
1239
|
if ("rs" in cell.mc) {
|
|
1224
1240
|
span = "rowspan=\"".concat(cell.mc.rs, "\" colspan=\"").concat(cell.mc.cs, "\"");
|
|
@@ -1397,17 +1413,31 @@ export function rangeValueToHtml(ctx, sheetId, ranges) {
|
|
|
1397
1413
|
}
|
|
1398
1414
|
}
|
|
1399
1415
|
}
|
|
1416
|
+
var cellData = encodeURIComponent(JSON.stringify(__assign(__assign({}, cell), {
|
|
1417
|
+
_srcRow: r,
|
|
1418
|
+
_srcCol: c
|
|
1419
|
+
})));
|
|
1400
1420
|
column = replaceHtml(column, {
|
|
1401
1421
|
style: style,
|
|
1402
|
-
span: span
|
|
1422
|
+
span: span,
|
|
1423
|
+
cellData: cellData
|
|
1403
1424
|
});
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1425
|
+
var cellHtml = "";
|
|
1426
|
+
if (cell && isInlineStringCell(cell)) {
|
|
1427
|
+
cellHtml = getInlineStringHTML(r, c, d, {
|
|
1428
|
+
useSemanticMarkup: true,
|
|
1429
|
+
inheritedStyle: styleObj
|
|
1430
|
+
});
|
|
1431
|
+
} else {
|
|
1432
|
+
if (_.isNil(c_value)) {
|
|
1433
|
+
c_value = getCellValue(r, c, d);
|
|
1434
|
+
}
|
|
1435
|
+
if (_.isNil(c_value)) {
|
|
1436
|
+
c_value = "";
|
|
1437
|
+
}
|
|
1438
|
+
cellHtml = escapeHTMLTag(String(c_value)).replace(/<br\s*\/?>/g, "<br>");
|
|
1409
1439
|
}
|
|
1410
|
-
column +=
|
|
1440
|
+
column += cellHtml;
|
|
1411
1441
|
} else {
|
|
1412
1442
|
var style = "";
|
|
1413
1443
|
if (borderInfoCompute && borderInfoCompute["".concat(r, "_").concat(c)]) {
|
|
@@ -1449,7 +1479,8 @@ export function rangeValueToHtml(ctx, sheetId, ranges) {
|
|
|
1449
1479
|
}
|
|
1450
1480
|
column = replaceHtml(column, {
|
|
1451
1481
|
style: style,
|
|
1452
|
-
span: ""
|
|
1482
|
+
span: "",
|
|
1483
|
+
cellData: ""
|
|
1453
1484
|
});
|
|
1454
1485
|
column += "";
|
|
1455
1486
|
}
|
|
@@ -1464,7 +1495,7 @@ export function rangeValueToHtml(ctx, sheetId, ranges) {
|
|
|
1464
1495
|
return "<table data-type=\"fortune-copy-action-table\">".concat(colgroup).concat(cpdata, "</table>");
|
|
1465
1496
|
}
|
|
1466
1497
|
export function copy(ctx) {
|
|
1467
|
-
var _a, _b, _c, _d;
|
|
1498
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1468
1499
|
var flowdata = getFlowdata(ctx);
|
|
1469
1500
|
ctx.luckysheet_selection_range = [];
|
|
1470
1501
|
var copyRange = [];
|
|
@@ -1508,8 +1539,63 @@ export function copy(ctx) {
|
|
|
1508
1539
|
RowlChange: RowlChange,
|
|
1509
1540
|
HasMC: HasMC
|
|
1510
1541
|
};
|
|
1511
|
-
var cpdata
|
|
1512
|
-
|
|
1542
|
+
var cpdata;
|
|
1543
|
+
var sel = ctx.luckysheet_select_save;
|
|
1544
|
+
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];
|
|
1545
|
+
if (isSingleCell) {
|
|
1546
|
+
var r = sel[0].row[0];
|
|
1547
|
+
var c = sel[0].column[0];
|
|
1548
|
+
var fontarray = locale(ctx).fontarray;
|
|
1549
|
+
var defaultStyle = {
|
|
1550
|
+
color: "#000000",
|
|
1551
|
+
fontFamily: (_e = fontarray[0]) !== null && _e !== void 0 ? _e : "Arial",
|
|
1552
|
+
fontSize: "11pt",
|
|
1553
|
+
fontWeight: "400",
|
|
1554
|
+
fontStyle: "normal",
|
|
1555
|
+
textAlign: "left",
|
|
1556
|
+
backgroundColor: "transparent"
|
|
1557
|
+
};
|
|
1558
|
+
var cell = (_f = flowdata[r]) === null || _f === void 0 ? void 0 : _f[c];
|
|
1559
|
+
var isRichText_1 = cell != null && isInlineStringCell(cell);
|
|
1560
|
+
var styleObj = getStyleByCell(ctx, flowdata, r, c);
|
|
1561
|
+
if (styleObj.borderBottom) {
|
|
1562
|
+
var existing = styleObj.textDecoration;
|
|
1563
|
+
var decorations = new Set(existing ? existing.split(/\s+/).filter(Boolean) : []);
|
|
1564
|
+
decorations.add("underline");
|
|
1565
|
+
styleObj.textDecoration = Array.from(decorations).join(" ");
|
|
1566
|
+
styleObj.textDecorationSkipInk = "none";
|
|
1567
|
+
delete styleObj.borderBottom;
|
|
1568
|
+
}
|
|
1569
|
+
var mergedStyle = __assign(__assign({}, defaultStyle), styleObj);
|
|
1570
|
+
var TEXT_LEVEL_KEYS_1 = new Set(["color", "fontFamily", "fontSize", "fontWeight", "fontStyle", "textDecoration", "textDecorationSkipInk"]);
|
|
1571
|
+
var styleStr = _.toPairs(mergedStyle).filter(function (_a) {
|
|
1572
|
+
var k = _a[0],
|
|
1573
|
+
v = _a[1];
|
|
1574
|
+
return !_.isNil(v) && v !== "" && v !== "undefined" && !(isRichText_1 && TEXT_LEVEL_KEYS_1.has(k));
|
|
1575
|
+
}).map(function (_a) {
|
|
1576
|
+
var key = _a[0],
|
|
1577
|
+
v = _a[1];
|
|
1578
|
+
return "".concat(_.kebabCase(key), ":").concat(_.isNumber(v) ? "".concat(v, "px") : v, ";");
|
|
1579
|
+
}).join(" ");
|
|
1580
|
+
var innerContent = void 0;
|
|
1581
|
+
if (isRichText_1) {
|
|
1582
|
+
innerContent = getInlineStringHTML(r, c, flowdata, {
|
|
1583
|
+
useSemanticMarkup: true,
|
|
1584
|
+
inheritedStyle: mergedStyle
|
|
1585
|
+
});
|
|
1586
|
+
} else {
|
|
1587
|
+
var displayValue = (_h = (_g = getCellValue(r, c, flowdata, "m")) !== null && _g !== void 0 ? _g : getCellValue(r, c, flowdata)) !== null && _h !== void 0 ? _h : "";
|
|
1588
|
+
innerContent = escapeHTMLTag(String(displayValue)).replace(/<br\s*\/?>/g, "<br>");
|
|
1589
|
+
}
|
|
1590
|
+
var cellData = encodeURIComponent(JSON.stringify(__assign(__assign({}, cell !== null && cell !== void 0 ? cell : {}), {
|
|
1591
|
+
_srcRow: r,
|
|
1592
|
+
_srcCol: c
|
|
1593
|
+
})));
|
|
1594
|
+
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>");
|
|
1595
|
+
} else {
|
|
1596
|
+
cpdata = rangeValueToHtml(ctx, ctx.currentSheetId, ctx.luckysheet_select_save);
|
|
1597
|
+
cpdata = cpdata === null ? cpdata : cpdata.replace('<td style="', '<td style="white-space: pre-line; ');
|
|
1598
|
+
}
|
|
1513
1599
|
if (cpdata) {
|
|
1514
1600
|
ctx.iscopyself = true;
|
|
1515
1601
|
clipboard.writeHtml(cpdata);
|
package/es/modules/validation.js
CHANGED
|
@@ -66,6 +66,7 @@ var MONTH_NAME_MAP = {
|
|
|
66
66
|
};
|
|
67
67
|
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";
|
|
68
68
|
var MONTH_ABBR_RE = "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec";
|
|
69
|
+
var MONTH_ABBR_SET = new Set(MONTH_ABBR_RE.split("|"));
|
|
69
70
|
function isValidDateParts(year, month, day) {
|
|
70
71
|
if (year < 1900) return false;
|
|
71
72
|
if (month < 1 || month > 12) return false;
|
|
@@ -280,6 +281,7 @@ export function detectDateFormat(str) {
|
|
|
280
281
|
var d = +m[2];
|
|
281
282
|
var y = +m[3];
|
|
282
283
|
if (mo && isValidDateParts(y, mo, d)) {
|
|
284
|
+
var isAbbr = MONTH_ABBR_SET.has(m[1].toLowerCase());
|
|
283
285
|
return {
|
|
284
286
|
year: y,
|
|
285
287
|
month: mo,
|
|
@@ -287,7 +289,7 @@ export function detectDateFormat(str) {
|
|
|
287
289
|
hours: 0,
|
|
288
290
|
minutes: 0,
|
|
289
291
|
seconds: 0,
|
|
290
|
-
formatType: "named"
|
|
292
|
+
formatType: isAbbr ? "named-mdy-abbr" : "named-mdy-full"
|
|
291
293
|
};
|
|
292
294
|
}
|
|
293
295
|
}
|
|
@@ -297,6 +299,7 @@ export function detectDateFormat(str) {
|
|
|
297
299
|
var mo = MONTH_NAME_MAP[m[2].toLowerCase()];
|
|
298
300
|
var y = +m[3];
|
|
299
301
|
if (mo && isValidDateParts(y, mo, d)) {
|
|
302
|
+
var isAbbr = MONTH_ABBR_SET.has(m[2].toLowerCase());
|
|
300
303
|
return {
|
|
301
304
|
year: y,
|
|
302
305
|
month: mo,
|
|
@@ -304,7 +307,7 @@ export function detectDateFormat(str) {
|
|
|
304
307
|
hours: 0,
|
|
305
308
|
minutes: 0,
|
|
306
309
|
seconds: 0,
|
|
307
|
-
formatType: "named"
|
|
310
|
+
formatType: isAbbr ? "named-dmy-abbr" : "named-dmy-full"
|
|
308
311
|
};
|
|
309
312
|
}
|
|
310
313
|
}
|
|
@@ -321,7 +324,7 @@ export function detectDateFormat(str) {
|
|
|
321
324
|
hours: 0,
|
|
322
325
|
minutes: 0,
|
|
323
326
|
seconds: 0,
|
|
324
|
-
formatType: "named"
|
|
327
|
+
formatType: "named-abbr-dashes"
|
|
325
328
|
};
|
|
326
329
|
}
|
|
327
330
|
}
|
|
@@ -8,9 +8,6 @@ var getColumnWidth = function getColumnWidth(colIndex, ctx, sheetFile) {
|
|
|
8
8
|
var defaultColumnWidth = (_a = ctx.defaultcollen) !== null && _a !== void 0 ? _a : 73;
|
|
9
9
|
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;
|
|
10
10
|
};
|
|
11
|
-
var isCellWrapped = function isCellWrapped(cell) {
|
|
12
|
-
return Number(cell === null || cell === void 0 ? void 0 : cell.tb) === 1;
|
|
13
|
-
};
|
|
14
11
|
var getCellDisplayText = function getCellDisplayText(cell) {
|
|
15
12
|
var _a, _b;
|
|
16
13
|
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;
|
|
@@ -21,6 +18,10 @@ var getCellDisplayText = function getCellDisplayText(cell) {
|
|
|
21
18
|
}
|
|
22
19
|
return text == null ? "" : String(text);
|
|
23
20
|
};
|
|
21
|
+
var isCellWrapped = function isCellWrapped(cell) {
|
|
22
|
+
var _a;
|
|
23
|
+
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));
|
|
24
|
+
};
|
|
24
25
|
var applyFontOnMeasurer = function applyFontOnMeasurer(cell, cellSizeMeasurer) {
|
|
25
26
|
var _a, _b;
|
|
26
27
|
var fontSizePx = (_a = cell === null || cell === void 0 ? void 0 : cell.fs) !== null && _a !== void 0 ? _a : DEFAULT_FONT_SIZE;
|
|
@@ -84,7 +85,7 @@ export function calculateRangeCellSize(ctx, sheetId, startRow, endRow, startCol,
|
|
|
84
85
|
var fontSizePx = applyFontOnMeasurer(cell, cellSizeMeasurer);
|
|
85
86
|
if (isCellWrapped(cell)) {
|
|
86
87
|
var finalColumnWidth = Math.max(getColumnWidth(col, ctx, sheetFile), maxColumnWidths[col] || 0);
|
|
87
|
-
cellSizeMeasurer.style.whiteSpace = "normal";
|
|
88
|
+
cellSizeMeasurer.style.whiteSpace = /[\r\n]/.test(text) ? "pre-wrap" : "normal";
|
|
88
89
|
cellSizeMeasurer.style.width = "".concat(Math.max(5, finalColumnWidth - 8), "px");
|
|
89
90
|
cellSizeMeasurer.textContent = text;
|
|
90
91
|
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;
|