@fileverse-dev/fortune-core 1.3.11-mixed → 1.3.12-copyPaste-4
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.js +37 -60
- package/es/events/mouse.js +0 -1
- package/es/locale/en.d.ts +0 -3
- package/es/locale/en.js +0 -3
- package/es/locale/es.d.ts +0 -3
- package/es/locale/es.js +0 -3
- package/es/locale/hi.d.ts +0 -3
- package/es/locale/hi.js +0 -3
- package/es/locale/index.d.ts +0 -3
- package/es/locale/zh.d.ts +0 -3
- package/es/locale/zh.js +0 -3
- package/es/locale/zh_tw.d.ts +0 -3
- package/es/locale/zh_tw.js +0 -3
- package/es/modules/ConditionFormat.js +0 -26
- package/es/modules/cell.js +1 -1
- package/es/modules/inline-string.js +52 -24
- package/es/modules/selection.js +9 -3
- package/es/paste-table-helpers.js +39 -1
- package/es/types.d.ts +0 -2
- package/lib/events/keyboard.js +37 -60
- package/lib/events/mouse.js +0 -1
- package/lib/locale/en.d.ts +0 -3
- package/lib/locale/en.js +0 -3
- package/lib/locale/es.d.ts +0 -3
- package/lib/locale/es.js +0 -3
- package/lib/locale/hi.d.ts +0 -3
- package/lib/locale/hi.js +0 -3
- package/lib/locale/index.d.ts +0 -3
- package/lib/locale/zh.d.ts +0 -3
- package/lib/locale/zh.js +0 -3
- package/lib/locale/zh_tw.d.ts +0 -3
- package/lib/locale/zh_tw.js +0 -3
- package/lib/modules/ConditionFormat.js +0 -26
- package/lib/modules/cell.js +1 -1
- package/lib/modules/inline-string.js +52 -24
- package/lib/modules/selection.js +9 -3
- package/lib/paste-table-helpers.js +39 -1
- package/lib/types.d.ts +0 -2
- package/package.json +1 -1
|
@@ -307,6 +307,9 @@ function extendCssText(origin, cover, isLimit) {
|
|
|
307
307
|
}
|
|
308
308
|
return newCss;
|
|
309
309
|
}
|
|
310
|
+
function escapeHtmlAttr(s) {
|
|
311
|
+
return s.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
312
|
+
}
|
|
310
313
|
function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
311
314
|
var _a, _b, _c;
|
|
312
315
|
var w = window.getSelection();
|
|
@@ -314,6 +317,34 @@ function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
|
314
317
|
if (w.rangeCount === 0) return;
|
|
315
318
|
var range = w.getRangeAt(0);
|
|
316
319
|
var $textEditor = cellInput;
|
|
320
|
+
if (range.startContainer === $textEditor && range.endContainer === $textEditor && range.collapsed === false) {
|
|
321
|
+
var start = range.startOffset;
|
|
322
|
+
var end = range.endOffset;
|
|
323
|
+
var children = Array.from($textEditor.childNodes).slice(start, end);
|
|
324
|
+
children.forEach(function (node) {
|
|
325
|
+
var _a, _b;
|
|
326
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
327
|
+
var el = node;
|
|
328
|
+
if (el.tagName === "SPAN") {
|
|
329
|
+
var cssText = getCssText(el.style.cssText, attr, value);
|
|
330
|
+
el.setAttribute("style", cssText);
|
|
331
|
+
}
|
|
332
|
+
} else if (node.nodeType === Node.TEXT_NODE) {
|
|
333
|
+
var text = (_a = node.textContent) !== null && _a !== void 0 ? _a : "";
|
|
334
|
+
if (text.length === 0) return;
|
|
335
|
+
var wrapper = document.createElement("span");
|
|
336
|
+
var cssText = getCssText("", attr, value);
|
|
337
|
+
wrapper.setAttribute("style", cssText);
|
|
338
|
+
wrapper.textContent = text;
|
|
339
|
+
(_b = node.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(wrapper, node);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
var newRange = document.createRange();
|
|
343
|
+
newRange.selectNodeContents($textEditor);
|
|
344
|
+
w.removeAllRanges();
|
|
345
|
+
w.addRange(newRange);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
317
348
|
if (range.collapsed === true) {
|
|
318
349
|
return;
|
|
319
350
|
}
|
|
@@ -351,7 +382,7 @@ function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
|
351
382
|
cssText = extendCssText(box.style.cssText, cssText);
|
|
352
383
|
}
|
|
353
384
|
}
|
|
354
|
-
cont += "<span style
|
|
385
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(left, "</span>");
|
|
355
386
|
}
|
|
356
387
|
if (mid !== "") {
|
|
357
388
|
var cssText = getCssText(span.style.cssText, attr, value);
|
|
@@ -361,7 +392,7 @@ function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
|
361
392
|
cssText = extendCssText(box.style.cssText, cssText);
|
|
362
393
|
}
|
|
363
394
|
}
|
|
364
|
-
cont += "<span style
|
|
395
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(mid, "</span>");
|
|
365
396
|
}
|
|
366
397
|
if (right !== "") {
|
|
367
398
|
var cssText = span.style.cssText;
|
|
@@ -371,7 +402,7 @@ function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
|
371
402
|
cssText = extendCssText(box.style.cssText, cssText);
|
|
372
403
|
}
|
|
373
404
|
}
|
|
374
|
-
cont += "<span style
|
|
405
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(right, "</span>");
|
|
375
406
|
}
|
|
376
407
|
if (((_a = startContainer.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) === "SPAN") {
|
|
377
408
|
spanIndex = _lodash.default.indexOf($textEditor.querySelectorAll("span"), span);
|
|
@@ -414,33 +445,33 @@ function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
|
414
445
|
for (var i = 0; i < startSpanIndex; i += 1) {
|
|
415
446
|
var span = spans[i];
|
|
416
447
|
var content = span.innerHTML;
|
|
417
|
-
cont += "<span style
|
|
448
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(span.style.cssText), "\">").concat(content, "</span>");
|
|
418
449
|
}
|
|
419
450
|
if (sleft !== "") {
|
|
420
|
-
cont += "<span style
|
|
451
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(startSpan.style.cssText), "\">").concat(sleft, "</span>");
|
|
421
452
|
}
|
|
422
453
|
if (sright !== "") {
|
|
423
454
|
var cssText = getCssText(startSpan.style.cssText, attr, value);
|
|
424
|
-
cont += "<span style
|
|
455
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(sright, "</span>");
|
|
425
456
|
}
|
|
426
457
|
if (startSpanIndex < endSpanIndex) {
|
|
427
458
|
for (var i = startSpanIndex + 1; i < endSpanIndex; i += 1) {
|
|
428
459
|
var span = spans[i];
|
|
429
460
|
var content = span.innerHTML;
|
|
430
|
-
cont += "<span style
|
|
461
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(span.style.cssText), "\">").concat(content, "</span>");
|
|
431
462
|
}
|
|
432
463
|
}
|
|
433
464
|
if (eleft !== "") {
|
|
434
465
|
var cssText = getCssText(endSpan.style.cssText, attr, value);
|
|
435
|
-
cont += "<span style
|
|
466
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(eleft, "</span>");
|
|
436
467
|
}
|
|
437
468
|
if (eright !== "") {
|
|
438
|
-
cont += "<span style
|
|
469
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(endSpan.style.cssText), "\">").concat(eright, "</span>");
|
|
439
470
|
}
|
|
440
471
|
for (var i = endSpanIndex + 1; i < spans.length; i += 1) {
|
|
441
472
|
var span = spans[i];
|
|
442
473
|
var content = span.innerHTML;
|
|
443
|
-
cont += "<span style
|
|
474
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(span.style.cssText), "\">").concat(content, "</span>");
|
|
444
475
|
}
|
|
445
476
|
$textEditor.innerHTML = cont;
|
|
446
477
|
var startSeletedNodeIndex = void 0;
|
|
@@ -458,13 +489,10 @@ function updateInlineStringFormat(ctx, attr, value, cellInput) {
|
|
|
458
489
|
}
|
|
459
490
|
}
|
|
460
491
|
}
|
|
461
|
-
function escapeHtmlAttr(s) {
|
|
462
|
-
return s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
463
|
-
}
|
|
464
492
|
function getLinkDataAttrs(span) {
|
|
465
493
|
var _a, _b;
|
|
466
494
|
if (((_a = span.dataset) === null || _a === void 0 ? void 0 : _a.linkType) && ((_b = span.dataset) === null || _b === void 0 ? void 0 : _b.linkAddress)) {
|
|
467
|
-
return " data-link-type
|
|
495
|
+
return " data-link-type=\"".concat(escapeHtmlAttr(span.dataset.linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(span.dataset.linkAddress), "\"");
|
|
468
496
|
}
|
|
469
497
|
return "";
|
|
470
498
|
}
|
|
@@ -502,7 +530,7 @@ function applyLinkToSelection(cellInput, linkType, linkAddress) {
|
|
|
502
530
|
var box = span.closest("#luckysheet-input-box");
|
|
503
531
|
if (box != null) cssText = extendCssText(box.style.cssText, cssText);
|
|
504
532
|
}
|
|
505
|
-
cont += "<span style
|
|
533
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\"").concat(dataAttrs, ">").concat(left, "</span>");
|
|
506
534
|
}
|
|
507
535
|
if (mid !== "") {
|
|
508
536
|
var cssText = getLinkStyleCssText(span.style.cssText);
|
|
@@ -510,7 +538,7 @@ function applyLinkToSelection(cellInput, linkType, linkAddress) {
|
|
|
510
538
|
var box = span.closest("#luckysheet-input-box");
|
|
511
539
|
if (box != null) cssText = extendCssText(box.style.cssText, cssText);
|
|
512
540
|
}
|
|
513
|
-
cont += "<span style
|
|
541
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\" data-link-type=\"").concat(escapeHtmlAttr(linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(linkAddress), "\">").concat(mid, "</span>");
|
|
514
542
|
}
|
|
515
543
|
if (right !== "") {
|
|
516
544
|
var cssText = span.style.cssText;
|
|
@@ -518,7 +546,7 @@ function applyLinkToSelection(cellInput, linkType, linkAddress) {
|
|
|
518
546
|
var box = span.closest("#luckysheet-input-box");
|
|
519
547
|
if (box != null) cssText = extendCssText(box.style.cssText, cssText);
|
|
520
548
|
}
|
|
521
|
-
cont += "<span style
|
|
549
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\"").concat(dataAttrs, ">").concat(right, "</span>");
|
|
522
550
|
}
|
|
523
551
|
if (((_a = startContainer.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) === "SPAN") {
|
|
524
552
|
span.outerHTML = cont;
|
|
@@ -548,32 +576,32 @@ function applyLinkToSelection(cellInput, linkType, linkAddress) {
|
|
|
548
576
|
var cont = "";
|
|
549
577
|
for (var i = 0; i < startSpanIndex; i += 1) {
|
|
550
578
|
var sp = spans[i];
|
|
551
|
-
cont += "<span style
|
|
579
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(sp.style.cssText), "\"").concat(getLinkDataAttrs(sp), ">").concat(sp.innerHTML, "</span>");
|
|
552
580
|
}
|
|
553
581
|
if (sleft !== "") {
|
|
554
|
-
cont += "<span style
|
|
582
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(startSpan.style.cssText), "\"").concat(getLinkDataAttrs(startSpan), ">").concat(sleft, "</span>");
|
|
555
583
|
}
|
|
556
584
|
if (sright !== "") {
|
|
557
585
|
var cssText = getLinkStyleCssText(startSpan.style.cssText);
|
|
558
|
-
cont += "<span style
|
|
586
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\" data-link-type=\"").concat(escapeHtmlAttr(linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(linkAddress), "\">").concat(sright, "</span>");
|
|
559
587
|
}
|
|
560
588
|
if (startSpanIndex < endSpanIndex) {
|
|
561
589
|
for (var i = startSpanIndex + 1; i < endSpanIndex; i += 1) {
|
|
562
590
|
var sp = spans[i];
|
|
563
591
|
var cssText = getLinkStyleCssText(sp.style.cssText);
|
|
564
|
-
cont += "<span style
|
|
592
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\" data-link-type=\"").concat(escapeHtmlAttr(linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(linkAddress), "\">").concat(sp.innerHTML, "</span>");
|
|
565
593
|
}
|
|
566
594
|
}
|
|
567
595
|
if (eleft !== "") {
|
|
568
596
|
var cssText = getLinkStyleCssText(endSpan.style.cssText);
|
|
569
|
-
cont += "<span style
|
|
597
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\" data-link-type=\"").concat(escapeHtmlAttr(linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(linkAddress), "\">").concat(eleft, "</span>");
|
|
570
598
|
}
|
|
571
599
|
if (eright !== "") {
|
|
572
|
-
cont += "<span style
|
|
600
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(endSpan.style.cssText), "\"").concat(getLinkDataAttrs(endSpan), ">").concat(eright, "</span>");
|
|
573
601
|
}
|
|
574
602
|
for (var i = endSpanIndex + 1; i < spans.length; i += 1) {
|
|
575
603
|
var sp = spans[i];
|
|
576
|
-
cont += "<span style
|
|
604
|
+
cont += "<span style=\"".concat(escapeHtmlAttr(sp.style.cssText), "\"").concat(getLinkDataAttrs(sp), ">").concat(sp.innerHTML, "</span>");
|
|
577
605
|
}
|
|
578
606
|
$textEditor.innerHTML = cont;
|
|
579
607
|
spans = $textEditor.querySelectorAll("span");
|
package/lib/modules/selection.js
CHANGED
|
@@ -1221,7 +1221,7 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
|
|
|
1221
1221
|
cpdata += "<tr height=".concat(rowLen, "px >");
|
|
1222
1222
|
var _loop_3 = function _loop_3(j) {
|
|
1223
1223
|
var c = colIndexArr[j];
|
|
1224
|
-
var column = '<td ${span} style="${style}">';
|
|
1224
|
+
var column = '<td ${span} style="${style}" data-fortune-cell="${cellData}">';
|
|
1225
1225
|
var cell = (_f = d[r]) === null || _f === void 0 ? void 0 : _f[c];
|
|
1226
1226
|
if (cell != null) {
|
|
1227
1227
|
var style = "";
|
|
@@ -1432,9 +1432,14 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
|
|
|
1432
1432
|
}
|
|
1433
1433
|
}
|
|
1434
1434
|
}
|
|
1435
|
+
var cellData = encodeURIComponent(JSON.stringify(__assign(__assign({}, cell), {
|
|
1436
|
+
_srcRow: r,
|
|
1437
|
+
_srcCol: c
|
|
1438
|
+
})));
|
|
1435
1439
|
column = (0, _utils.replaceHtml)(column, {
|
|
1436
1440
|
style: style,
|
|
1437
|
-
span: span
|
|
1441
|
+
span: span,
|
|
1442
|
+
cellData: cellData
|
|
1438
1443
|
});
|
|
1439
1444
|
if (_lodash.default.isNil(c_value)) {
|
|
1440
1445
|
c_value = (0, _cell.getCellValue)(r, c, d);
|
|
@@ -1484,7 +1489,8 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
|
|
|
1484
1489
|
}
|
|
1485
1490
|
column = (0, _utils.replaceHtml)(column, {
|
|
1486
1491
|
style: style,
|
|
1487
|
-
span: ""
|
|
1492
|
+
span: "",
|
|
1493
|
+
cellData: ""
|
|
1488
1494
|
});
|
|
1489
1495
|
column += "";
|
|
1490
1496
|
}
|
|
@@ -10,6 +10,7 @@ var _locale = require("./locale");
|
|
|
10
10
|
var _modules = require("./modules");
|
|
11
11
|
var _utils = require("./utils");
|
|
12
12
|
var _api = require("./api");
|
|
13
|
+
var _paste = require("./events/paste");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
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); }
|
|
15
16
|
var __assign = void 0 && (void 0).__assign || function () {
|
|
@@ -22,6 +23,14 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
22
23
|
};
|
|
23
24
|
return __assign.apply(this, arguments);
|
|
24
25
|
};
|
|
26
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
27
|
+
var t = {};
|
|
28
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
30
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
31
|
+
}
|
|
32
|
+
return t;
|
|
33
|
+
};
|
|
25
34
|
var DEFAULT_FONT_SIZE = exports.DEFAULT_FONT_SIZE = 12;
|
|
26
35
|
var parseStylesheetPairs = function parseStylesheetPairs(styleInner) {
|
|
27
36
|
var patternReg = /{([^}]*)}/g;
|
|
@@ -135,6 +144,28 @@ function brToNewline(str) {
|
|
|
135
144
|
}
|
|
136
145
|
var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
|
|
137
146
|
var _a, _b, _c, _d;
|
|
147
|
+
var fortuneCellAttr = td.getAttribute("data-fortune-cell");
|
|
148
|
+
if (fortuneCellAttr) {
|
|
149
|
+
try {
|
|
150
|
+
var _e = JSON.parse(decodeURIComponent(fortuneCellAttr)),
|
|
151
|
+
_srcRow = _e._srcRow,
|
|
152
|
+
_srcCol = _e._srcCol,
|
|
153
|
+
parsed = __rest(_e, ["_srcRow", "_srcCol"]);
|
|
154
|
+
var cell_1 = parsed;
|
|
155
|
+
delete cell_1.mc;
|
|
156
|
+
delete cell_1.hl;
|
|
157
|
+
var rowspan_1 = parseInt(td.getAttribute("rowspan") || "1", 10);
|
|
158
|
+
var colspan_1 = parseInt(td.getAttribute("colspan") || "1", 10);
|
|
159
|
+
return {
|
|
160
|
+
cell: cell_1,
|
|
161
|
+
rowspan: Number.isNaN(rowspan_1) ? 1 : rowspan_1,
|
|
162
|
+
colspan: Number.isNaN(colspan_1) ? 1 : colspan_1,
|
|
163
|
+
hyperlink: detectHyperlink(td),
|
|
164
|
+
srcRow: _srcRow,
|
|
165
|
+
srcCol: _srcCol
|
|
166
|
+
};
|
|
167
|
+
} catch (_f) {}
|
|
168
|
+
}
|
|
138
169
|
var cell = {};
|
|
139
170
|
var rawText = (td.innerText || td.innerHTML || "").trim();
|
|
140
171
|
var isLineBreak = rawText.includes("<br />");
|
|
@@ -285,10 +316,17 @@ function handlePastedTable(ctx, html, pasteHandler) {
|
|
|
285
316
|
cell = _a.cell,
|
|
286
317
|
rowspan = _a.rowspan,
|
|
287
318
|
colspan = _a.colspan,
|
|
288
|
-
hyperlink = _a.hyperlink
|
|
319
|
+
hyperlink = _a.hyperlink,
|
|
320
|
+
srcRow = _a.srcRow,
|
|
321
|
+
srcCol = _a.srcCol;
|
|
289
322
|
var anchorCol = ctx.luckysheet_select_save[0].column[0];
|
|
290
323
|
var absoluteRow = anchorRow + localRowIndex;
|
|
291
324
|
var absoluteCol = anchorCol + localColIndex;
|
|
325
|
+
if (cell.f && srcRow != null && srcCol != null) {
|
|
326
|
+
try {
|
|
327
|
+
cell.f = (0, _paste.adjustFormulaForPaste)(cell.f, srcCol, srcRow, absoluteCol, absoluteRow);
|
|
328
|
+
} catch (_b) {}
|
|
329
|
+
}
|
|
292
330
|
pastedMatrix[localRowIndex][localColIndex] = cell;
|
|
293
331
|
if (hyperlink) {
|
|
294
332
|
(0, _modules.saveHyperlink)(ctx, absoluteRow, absoluteCol, hyperlink.href, "webpage", hyperlink.display);
|
package/lib/types.d.ts
CHANGED
|
@@ -328,8 +328,6 @@ export type GlobalCache = {
|
|
|
328
328
|
verticalScrollLock?: boolean;
|
|
329
329
|
horizontalScrollLock?: boolean;
|
|
330
330
|
overwriteCell?: boolean;
|
|
331
|
-
overwriteCellFirstChar?: string;
|
|
332
|
-
enteredEditByTyping?: boolean;
|
|
333
331
|
ignoreWriteCell?: boolean;
|
|
334
332
|
doNotFocus?: boolean;
|
|
335
333
|
doNotUpdateCell?: boolean;
|