@fileverse-dev/fortune-core 1.2.63 → 1.2.64-linkPasteFix-patch-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/paste.js +118 -27
- package/es/locale/en.js +21 -0
- package/es/modules/cell.js +51 -6
- package/lib/events/paste.js +118 -27
- package/lib/locale/en.js +21 -0
- package/lib/modules/cell.js +51 -6
- package/package.json +2 -2
package/es/events/paste.js
CHANGED
|
@@ -354,12 +354,21 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
354
354
|
expandRowsAndColumns(d, addr, addc);
|
|
355
355
|
}
|
|
356
356
|
if (!d) return;
|
|
357
|
+
var getUrlFromText = function getUrlFromText(text) {
|
|
358
|
+
var t = String(text).trim();
|
|
359
|
+
if (!t || /[\s\r\n]/.test(t)) return null;
|
|
360
|
+
if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
|
|
361
|
+
return t.startsWith("http") ? t : "https://".concat(t);
|
|
362
|
+
};
|
|
357
363
|
for (var r = 0; r < rlen; r += 1) {
|
|
358
364
|
var x = d[r + curR];
|
|
359
365
|
for (var c = 0; c < clen; c += 1) {
|
|
360
366
|
var originCell = x[c + curC];
|
|
361
367
|
var value = dataChe[r][c];
|
|
362
|
-
|
|
368
|
+
var originalValueStr = String(value);
|
|
369
|
+
var url = getUrlFromText(originalValueStr);
|
|
370
|
+
var isUrl = url !== null;
|
|
371
|
+
if (!isUrl && isRealNum(value)) {
|
|
363
372
|
if (originCell && originCell.ct && originCell.ct.fa === "@") {
|
|
364
373
|
value = String(value);
|
|
365
374
|
} else if (!/^0x?[a-fA-F0-9]+$/.test(value)) {
|
|
@@ -367,26 +376,59 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
367
376
|
}
|
|
368
377
|
}
|
|
369
378
|
if (originCell) {
|
|
370
|
-
originCell.v = value;
|
|
379
|
+
originCell.v = isUrl ? originalValueStr : value;
|
|
371
380
|
if (originCell.ct != null && originCell.ct.fa != null) {
|
|
372
|
-
originCell.m = update(originCell.ct.fa,
|
|
381
|
+
originCell.m = update(originCell.ct.fa, originCell.v);
|
|
373
382
|
} else {
|
|
374
|
-
originCell.m =
|
|
383
|
+
originCell.m = typeof originCell.v === "boolean" ? String(originCell.v) : originCell.v;
|
|
375
384
|
}
|
|
376
385
|
if (originCell.f != null && originCell.f.length > 0) {
|
|
377
386
|
originCell.f = "";
|
|
378
387
|
}
|
|
388
|
+
if (isUrl && url) {
|
|
389
|
+
var targetRow = r + curR;
|
|
390
|
+
var targetCol = c + curC;
|
|
391
|
+
saveHyperlink(ctx, targetRow, targetCol, url, "webpage", originalValueStr);
|
|
392
|
+
originCell.hl = {
|
|
393
|
+
r: targetRow,
|
|
394
|
+
c: targetCol,
|
|
395
|
+
id: ctx.currentSheetId
|
|
396
|
+
};
|
|
397
|
+
originCell.fc = originCell.fc || "rgb(0, 0, 255)";
|
|
398
|
+
originCell.un = originCell.un !== undefined ? originCell.un : 1;
|
|
399
|
+
}
|
|
379
400
|
} else {
|
|
380
401
|
var cell = {};
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
cell.m = value;
|
|
402
|
+
if (isUrl) {
|
|
403
|
+
cell.v = originalValueStr;
|
|
404
|
+
cell.m = originalValueStr;
|
|
385
405
|
cell.ct = {
|
|
386
406
|
fa: "@",
|
|
387
407
|
t: "s"
|
|
388
408
|
};
|
|
389
|
-
|
|
409
|
+
} else {
|
|
410
|
+
var mask = genarate(value);
|
|
411
|
+
_a = mask, cell.m = _a[0], cell.ct = _a[1], cell.v = _a[2];
|
|
412
|
+
if (/^0x?[a-fA-F0-9]+$/.test(value)) {
|
|
413
|
+
cell.m = value;
|
|
414
|
+
cell.ct = {
|
|
415
|
+
fa: "@",
|
|
416
|
+
t: "s"
|
|
417
|
+
};
|
|
418
|
+
cell.v = value;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (isUrl && url) {
|
|
422
|
+
var targetRow = r + curR;
|
|
423
|
+
var targetCol = c + curC;
|
|
424
|
+
saveHyperlink(ctx, targetRow, targetCol, url, "webpage", originalValueStr);
|
|
425
|
+
cell.hl = {
|
|
426
|
+
r: targetRow,
|
|
427
|
+
c: targetCol,
|
|
428
|
+
id: ctx.currentSheetId
|
|
429
|
+
};
|
|
430
|
+
cell.fc = cell.fc || "rgb(0, 0, 255)";
|
|
431
|
+
cell.un = cell.un !== undefined ? cell.un : 1;
|
|
390
432
|
}
|
|
391
433
|
x[c + curC] = cell;
|
|
392
434
|
}
|
|
@@ -786,7 +828,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
|
|
|
786
828
|
}
|
|
787
829
|
}
|
|
788
830
|
function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
789
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
831
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
790
832
|
var allowEdit = isAllowEdit(ctx);
|
|
791
833
|
if (!allowEdit || ctx.isFlvReadOnly) return;
|
|
792
834
|
if (!copyRange) return;
|
|
@@ -1085,21 +1127,64 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1085
1127
|
file.luckysheet_conditionformat_save = cdformat;
|
|
1086
1128
|
file.dataVerification = __assign(__assign({}, file.dataVerification), dataVerification);
|
|
1087
1129
|
if (((_l = ctx.luckysheet_select_save) === null || _l === void 0 ? void 0 : _l.length) === 1 && ((_m = ctx.luckysheet_copy_save) === null || _m === void 0 ? void 0 : _m.copyRange.length) === 1) {
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1130
|
+
var srcIndex = getSheetIndex(ctx, (_o = ctx.luckysheet_copy_save) === null || _o === void 0 ? void 0 : _o.dataSheetId);
|
|
1131
|
+
var targetSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
1132
|
+
var srcHyperlinks = ctx.luckysheetfile[srcIndex].hyperlink;
|
|
1133
|
+
var srcData = ctx.luckysheetfile[srcIndex].data;
|
|
1134
|
+
if (!ctx.luckysheetfile[targetSheetIndex].hyperlink) {
|
|
1135
|
+
ctx.luckysheetfile[targetSheetIndex].hyperlink = {};
|
|
1136
|
+
}
|
|
1137
|
+
var targetHyperlinks = ctx.luckysheetfile[targetSheetIndex].hyperlink;
|
|
1138
|
+
var isSingleCell = copyh === 1 && copyc === 1;
|
|
1139
|
+
var cachedSrcLinkKey = isSingleCell ? "".concat(c_r1, "_").concat(c_c1) : null;
|
|
1140
|
+
var cachedSrcLink = isSingleCell && srcHyperlinks ? srcHyperlinks[cachedSrcLinkKey] : null;
|
|
1141
|
+
var cachedSrcCell = isSingleCell && srcData ? (_p = srcData[c_r1]) === null || _p === void 0 ? void 0 : _p[c_c1] : null;
|
|
1142
|
+
for (var th = 1; th <= timesH; th += 1) {
|
|
1143
|
+
for (var tc = 1; tc <= timesC; tc += 1) {
|
|
1144
|
+
var linkMth = minh + (th - 1) * copyh;
|
|
1145
|
+
var linkMtc = minc + (tc - 1) * copyc;
|
|
1146
|
+
var linkMaxRow = minh + th * copyh;
|
|
1147
|
+
var linkMaxCol = minc + tc * copyc;
|
|
1148
|
+
for (var h = linkMth; h < linkMaxRow; h += 1) {
|
|
1149
|
+
for (var c = linkMtc; c < linkMaxCol; c += 1) {
|
|
1150
|
+
var srcLink = void 0;
|
|
1151
|
+
if (isSingleCell && cachedSrcLink) {
|
|
1152
|
+
srcLink = cachedSrcLink;
|
|
1153
|
+
} else {
|
|
1154
|
+
var srcRow = c_r1 + (h - linkMth);
|
|
1155
|
+
var srcCol = c_c1 + (c - linkMtc);
|
|
1156
|
+
srcLink = srcHyperlinks === null || srcHyperlinks === void 0 ? void 0 : srcHyperlinks["".concat(srcRow, "_").concat(srcCol)];
|
|
1157
|
+
}
|
|
1158
|
+
if (!srcLink) continue;
|
|
1159
|
+
var targetKey = "".concat(h, "_").concat(c);
|
|
1160
|
+
targetHyperlinks[targetKey] = srcLink;
|
|
1161
|
+
var cell = (_q = d[h]) === null || _q === void 0 ? void 0 : _q[c];
|
|
1162
|
+
if (cell) {
|
|
1163
|
+
var srcCell = void 0;
|
|
1164
|
+
if (isSingleCell && cachedSrcCell) {
|
|
1165
|
+
srcCell = cachedSrcCell;
|
|
1166
|
+
} else {
|
|
1167
|
+
var srcRow = c_r1 + (h - linkMth);
|
|
1168
|
+
var srcCol = c_c1 + (c - linkMtc);
|
|
1169
|
+
srcCell = (_r = srcData === null || srcData === void 0 ? void 0 : srcData[srcRow]) === null || _r === void 0 ? void 0 : _r[srcCol];
|
|
1170
|
+
}
|
|
1171
|
+
cell.hl = {
|
|
1172
|
+
r: h,
|
|
1173
|
+
c: c,
|
|
1174
|
+
id: ctx.currentSheetId
|
|
1175
|
+
};
|
|
1176
|
+
if (srcCell) {
|
|
1177
|
+
if (srcCell.fc) cell.fc = srcCell.fc;
|
|
1178
|
+
if (srcCell.un !== undefined) cell.un = srcCell.un;
|
|
1179
|
+
} else {
|
|
1180
|
+
cell.fc = cell.fc || "rgb(0, 0, 255)";
|
|
1181
|
+
cell.un = cell.un !== undefined ? cell.un : 1;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1100
1185
|
}
|
|
1101
1186
|
}
|
|
1102
|
-
}
|
|
1187
|
+
}
|
|
1103
1188
|
}
|
|
1104
1189
|
if (copyRowlChange || addr > 0 || addc > 0) {
|
|
1105
1190
|
jfrefreshgrid(ctx, d, ctx.luckysheet_select_save);
|
|
@@ -1136,11 +1221,17 @@ export function parseAsLinkIfUrl(txtdata, ctx) {
|
|
|
1136
1221
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1137
1222
|
var urlRegex = /^(https?:\/\/[^\s]+)/;
|
|
1138
1223
|
if (urlRegex.test(txtdata)) {
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
var
|
|
1142
|
-
var colIndex = (_g = (_e = last.column_focus) !== null && _e !== void 0 ? _e : (_f = last.column) === null || _f === void 0 ? void 0 : _f[0]) !== null && _g !== void 0 ? _g : 0;
|
|
1224
|
+
if (ctx.luckysheetCellUpdate.length === 2) {
|
|
1225
|
+
var rowIndex = ctx.luckysheetCellUpdate[0];
|
|
1226
|
+
var colIndex = ctx.luckysheetCellUpdate[1];
|
|
1143
1227
|
saveHyperlink(ctx, rowIndex, colIndex, txtdata, "webpage", txtdata);
|
|
1228
|
+
} else {
|
|
1229
|
+
var last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
|
|
1230
|
+
if (last) {
|
|
1231
|
+
var rowIndex = (_d = (_b = last.row_focus) !== null && _b !== void 0 ? _b : (_c = last.row) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : 0;
|
|
1232
|
+
var colIndex = (_g = (_e = last.column_focus) !== null && _e !== void 0 ? _e : (_f = last.column) === null || _f === void 0 ? void 0 : _f[0]) !== null && _g !== void 0 ? _g : 0;
|
|
1233
|
+
saveHyperlink(ctx, rowIndex, colIndex, txtdata, "webpage", txtdata);
|
|
1234
|
+
}
|
|
1144
1235
|
}
|
|
1145
1236
|
}
|
|
1146
1237
|
}
|
package/es/locale/en.js
CHANGED
|
@@ -2935,6 +2935,27 @@ export default {
|
|
|
2935
2935
|
repeat: "n",
|
|
2936
2936
|
type: "rangeall"
|
|
2937
2937
|
}]
|
|
2938
|
+
}, {
|
|
2939
|
+
n: "EPOCHTODATE",
|
|
2940
|
+
t: 2,
|
|
2941
|
+
d: "Converts a Unix epoch timestamp in seconds, milliseconds, or microseconds to a datetime in UTC.",
|
|
2942
|
+
a: "Vertical lookup.",
|
|
2943
|
+
m: [3, 4],
|
|
2944
|
+
p: [{
|
|
2945
|
+
name: "timestamp",
|
|
2946
|
+
detail: "A Unix epoch timestamp in seconds, milliseconds, or microseconds.",
|
|
2947
|
+
example: "1655906568893",
|
|
2948
|
+
require: "m",
|
|
2949
|
+
repeat: "n",
|
|
2950
|
+
type: "rangeall"
|
|
2951
|
+
}, {
|
|
2952
|
+
name: "time_unit",
|
|
2953
|
+
detail: "The unit of time in which the timestamp is expressed. 1 (default) indicates the time unit is seconds. 2 indicates the time unit is milliseconds. 3 indicates the time unit is microseconds.",
|
|
2954
|
+
example: "2",
|
|
2955
|
+
require: "o",
|
|
2956
|
+
repeat: "n",
|
|
2957
|
+
type: "rangeall"
|
|
2958
|
+
}]
|
|
2938
2959
|
}, {
|
|
2939
2960
|
n: "HLOOKUP",
|
|
2940
2961
|
t: 2,
|
package/es/modules/cell.js
CHANGED
|
@@ -538,14 +538,32 @@ export function cancelNormalSelected(ctx) {
|
|
|
538
538
|
ctx.formulaCache.rangedrag_row_start = false;
|
|
539
539
|
}
|
|
540
540
|
export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
541
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
541
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
542
542
|
if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
|
|
543
543
|
var inputText = $input === null || $input === void 0 ? void 0 : $input.innerText;
|
|
544
544
|
var inputHtml = $input === null || $input === void 0 ? void 0 : $input.innerHTML;
|
|
545
|
+
var trimmedInputText = (inputText !== null && inputText !== void 0 ? inputText : "").trim();
|
|
546
|
+
var isSingleToken = trimmedInputText.length > 0 && !/[\s\r\n]/.test(trimmedInputText);
|
|
547
|
+
var isUrlPastedInEditor = isSingleToken && /^(https?:\/\/|www\.)\S+$/i.test(trimmedInputText);
|
|
548
|
+
var normalizedUrl = null;
|
|
549
|
+
if (isUrlPastedInEditor) {
|
|
550
|
+
if (trimmedInputText.startsWith("http")) {
|
|
551
|
+
normalizedUrl = trimmedInputText;
|
|
552
|
+
} else {
|
|
553
|
+
normalizedUrl = "https://".concat(trimmedInputText);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
545
556
|
var flowdata = getFlowdata(ctx);
|
|
546
557
|
if (!flowdata) return;
|
|
547
558
|
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
548
559
|
var dataVerification = ctx.luckysheetfile[index].dataVerification;
|
|
560
|
+
var sheetFile = ctx.luckysheetfile[index];
|
|
561
|
+
var getUrlFromText = function getUrlFromText(text) {
|
|
562
|
+
var t = (text !== null && text !== void 0 ? text : "").trim();
|
|
563
|
+
if (!t || /[\s\r\n]/.test(t)) return null;
|
|
564
|
+
if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
|
|
565
|
+
return t.startsWith("http") ? t : "https://".concat(t);
|
|
566
|
+
};
|
|
549
567
|
if (!_.isNil(dataVerification)) {
|
|
550
568
|
var dvItem = dataVerification["".concat(r, "_").concat(c)];
|
|
551
569
|
if (!_.isNil(dvItem) && dvItem.prohibitInput && !validateCellData(ctx, dvItem, inputText)) {
|
|
@@ -558,7 +576,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
558
576
|
var curv = flowdata[r][c];
|
|
559
577
|
var oldValue = _.cloneDeep(curv);
|
|
560
578
|
var isPrevInline = isInlineStringCell(curv);
|
|
561
|
-
var isCurInline = (inputText === null || inputText === void 0 ? void 0 : inputText.slice(0, 1)) !== "=" && (inputHtml === null || inputHtml === void 0 ? void 0 : inputHtml.substring(0, 5)) === "<span";
|
|
579
|
+
var isCurInline = (inputText === null || inputText === void 0 ? void 0 : inputText.slice(0, 1)) !== "=" && ((inputHtml === null || inputHtml === void 0 ? void 0 : inputHtml.substring(0, 5)) === "<span" || isUrlPastedInEditor);
|
|
562
580
|
var isCopyVal = false;
|
|
563
581
|
if (!isCurInline && inputText && inputText.length > 0) {
|
|
564
582
|
var splitArr = inputText.replace(/\r\n/g, "_x000D_").replace(/ /g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_").split("_x000D_");
|
|
@@ -586,7 +604,17 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
586
604
|
curv.tb = "1";
|
|
587
605
|
}
|
|
588
606
|
curv.ct.t = "inlineStr";
|
|
589
|
-
|
|
607
|
+
if (isUrlPastedInEditor && normalizedUrl) {
|
|
608
|
+
curv.ct.s = [{
|
|
609
|
+
v: trimmedInputText,
|
|
610
|
+
fs: fontSize,
|
|
611
|
+
l: {
|
|
612
|
+
target: normalizedUrl
|
|
613
|
+
}
|
|
614
|
+
}];
|
|
615
|
+
} else {
|
|
616
|
+
curv.ct.s = convertSpanToShareString($input.querySelectorAll("span"), curv);
|
|
617
|
+
}
|
|
590
618
|
delete curv.fs;
|
|
591
619
|
delete curv.f;
|
|
592
620
|
delete curv.v;
|
|
@@ -803,13 +831,30 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
803
831
|
} catch (e) {
|
|
804
832
|
console.log("[updateCell] spill failed; falling back", e);
|
|
805
833
|
}
|
|
834
|
+
var url = getUrlFromText($input === null || $input === void 0 ? void 0 : $input.innerText);
|
|
835
|
+
if (url && _typeof(value) === "object" && value) {
|
|
836
|
+
value.hl = 1;
|
|
837
|
+
if (!sheetFile.hyperlink) sheetFile.hyperlink = {};
|
|
838
|
+
sheetFile.hyperlink["".concat(r, "_").concat(c)] = {
|
|
839
|
+
linkType: "webpage",
|
|
840
|
+
linkAddress: url
|
|
841
|
+
};
|
|
842
|
+
if (typeof value.v !== "string") {
|
|
843
|
+
value.v = (_r = $input === null || $input === void 0 ? void 0 : $input.innerText) !== null && _r !== void 0 ? _r : url;
|
|
844
|
+
}
|
|
845
|
+
if (value.m == null) {
|
|
846
|
+
value.m = value.v;
|
|
847
|
+
}
|
|
848
|
+
if (value.fc == null) value.fc = "rgb(0, 0, 255)";
|
|
849
|
+
if (value.un == null) value.un = 1;
|
|
850
|
+
}
|
|
806
851
|
setCellValue(ctx, r, c, d, value);
|
|
807
852
|
cancelNormalSelected(ctx);
|
|
808
853
|
if ((curv === null || curv === void 0 ? void 0 : curv.tb) === "2" && curv.v || isInlineStringCell(d[r][c])) {
|
|
809
854
|
var defaultrowlen = ctx.defaultrowlen;
|
|
810
855
|
var cfg = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].config || {};
|
|
811
|
-
if (!(((
|
|
812
|
-
var cellWidth = ((
|
|
856
|
+
if (!(((_s = cfg.columnlen) === null || _s === void 0 ? void 0 : _s[c]) && ((_t = cfg.rowlen) === null || _t === void 0 ? void 0 : _t[r]))) {
|
|
857
|
+
var cellWidth = ((_u = cfg.columnlen) === null || _u === void 0 ? void 0 : _u[c]) || ctx.defaultcollen;
|
|
813
858
|
var textInfo = canvas ? getCellTextInfo(d[r][c], canvas, ctx, {
|
|
814
859
|
r: r,
|
|
815
860
|
c: c,
|
|
@@ -820,7 +865,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
820
865
|
currentRowLen = textInfo.textHeightAll + 2;
|
|
821
866
|
}
|
|
822
867
|
var previousRowHeight = getRowHeight(ctx, [r])[r];
|
|
823
|
-
if (currentRowLen > defaultrowlen && !((
|
|
868
|
+
if (currentRowLen > defaultrowlen && !((_v = cfg.customHeight) === null || _v === void 0 ? void 0 : _v[r]) && previousRowHeight < currentRowLen) {
|
|
824
869
|
if (_.isNil(cfg.rowlen)) cfg.rowlen = {};
|
|
825
870
|
cfg.rowlen[r] = currentRowLen;
|
|
826
871
|
}
|
package/lib/events/paste.js
CHANGED
|
@@ -367,12 +367,21 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
367
367
|
(0, _sheet.expandRowsAndColumns)(d, addr, addc);
|
|
368
368
|
}
|
|
369
369
|
if (!d) return;
|
|
370
|
+
var getUrlFromText = function getUrlFromText(text) {
|
|
371
|
+
var t = String(text).trim();
|
|
372
|
+
if (!t || /[\s\r\n]/.test(t)) return null;
|
|
373
|
+
if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
|
|
374
|
+
return t.startsWith("http") ? t : "https://".concat(t);
|
|
375
|
+
};
|
|
370
376
|
for (var r = 0; r < rlen; r += 1) {
|
|
371
377
|
var x = d[r + curR];
|
|
372
378
|
for (var c = 0; c < clen; c += 1) {
|
|
373
379
|
var originCell = x[c + curC];
|
|
374
380
|
var value = dataChe[r][c];
|
|
375
|
-
|
|
381
|
+
var originalValueStr = String(value);
|
|
382
|
+
var url = getUrlFromText(originalValueStr);
|
|
383
|
+
var isUrl = url !== null;
|
|
384
|
+
if (!isUrl && (0, _validation.isRealNum)(value)) {
|
|
376
385
|
if (originCell && originCell.ct && originCell.ct.fa === "@") {
|
|
377
386
|
value = String(value);
|
|
378
387
|
} else if (!/^0x?[a-fA-F0-9]+$/.test(value)) {
|
|
@@ -380,26 +389,59 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
380
389
|
}
|
|
381
390
|
}
|
|
382
391
|
if (originCell) {
|
|
383
|
-
originCell.v = value;
|
|
392
|
+
originCell.v = isUrl ? originalValueStr : value;
|
|
384
393
|
if (originCell.ct != null && originCell.ct.fa != null) {
|
|
385
|
-
originCell.m = (0, _format.update)(originCell.ct.fa,
|
|
394
|
+
originCell.m = (0, _format.update)(originCell.ct.fa, originCell.v);
|
|
386
395
|
} else {
|
|
387
|
-
originCell.m =
|
|
396
|
+
originCell.m = typeof originCell.v === "boolean" ? String(originCell.v) : originCell.v;
|
|
388
397
|
}
|
|
389
398
|
if (originCell.f != null && originCell.f.length > 0) {
|
|
390
399
|
originCell.f = "";
|
|
391
400
|
}
|
|
401
|
+
if (isUrl && url) {
|
|
402
|
+
var targetRow = r + curR;
|
|
403
|
+
var targetCol = c + curC;
|
|
404
|
+
(0, _modules.saveHyperlink)(ctx, targetRow, targetCol, url, "webpage", originalValueStr);
|
|
405
|
+
originCell.hl = {
|
|
406
|
+
r: targetRow,
|
|
407
|
+
c: targetCol,
|
|
408
|
+
id: ctx.currentSheetId
|
|
409
|
+
};
|
|
410
|
+
originCell.fc = originCell.fc || "rgb(0, 0, 255)";
|
|
411
|
+
originCell.un = originCell.un !== undefined ? originCell.un : 1;
|
|
412
|
+
}
|
|
392
413
|
} else {
|
|
393
414
|
var cell = {};
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
cell.m = value;
|
|
415
|
+
if (isUrl) {
|
|
416
|
+
cell.v = originalValueStr;
|
|
417
|
+
cell.m = originalValueStr;
|
|
398
418
|
cell.ct = {
|
|
399
419
|
fa: "@",
|
|
400
420
|
t: "s"
|
|
401
421
|
};
|
|
402
|
-
|
|
422
|
+
} else {
|
|
423
|
+
var mask = (0, _format.genarate)(value);
|
|
424
|
+
_a = mask, cell.m = _a[0], cell.ct = _a[1], cell.v = _a[2];
|
|
425
|
+
if (/^0x?[a-fA-F0-9]+$/.test(value)) {
|
|
426
|
+
cell.m = value;
|
|
427
|
+
cell.ct = {
|
|
428
|
+
fa: "@",
|
|
429
|
+
t: "s"
|
|
430
|
+
};
|
|
431
|
+
cell.v = value;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
if (isUrl && url) {
|
|
435
|
+
var targetRow = r + curR;
|
|
436
|
+
var targetCol = c + curC;
|
|
437
|
+
(0, _modules.saveHyperlink)(ctx, targetRow, targetCol, url, "webpage", originalValueStr);
|
|
438
|
+
cell.hl = {
|
|
439
|
+
r: targetRow,
|
|
440
|
+
c: targetCol,
|
|
441
|
+
id: ctx.currentSheetId
|
|
442
|
+
};
|
|
443
|
+
cell.fc = cell.fc || "rgb(0, 0, 255)";
|
|
444
|
+
cell.un = cell.un !== undefined ? cell.un : 1;
|
|
403
445
|
}
|
|
404
446
|
x[c + curC] = cell;
|
|
405
447
|
}
|
|
@@ -799,7 +841,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
|
|
|
799
841
|
}
|
|
800
842
|
}
|
|
801
843
|
function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
802
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
844
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
803
845
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
804
846
|
if (!allowEdit || ctx.isFlvReadOnly) return;
|
|
805
847
|
if (!copyRange) return;
|
|
@@ -1098,21 +1140,64 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1098
1140
|
file.luckysheet_conditionformat_save = cdformat;
|
|
1099
1141
|
file.dataVerification = __assign(__assign({}, file.dataVerification), dataVerification);
|
|
1100
1142
|
if (((_l = ctx.luckysheet_select_save) === null || _l === void 0 ? void 0 : _l.length) === 1 && ((_m = ctx.luckysheet_copy_save) === null || _m === void 0 ? void 0 : _m.copyRange.length) === 1) {
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1143
|
+
var srcIndex = (0, _utils.getSheetIndex)(ctx, (_o = ctx.luckysheet_copy_save) === null || _o === void 0 ? void 0 : _o.dataSheetId);
|
|
1144
|
+
var targetSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
1145
|
+
var srcHyperlinks = ctx.luckysheetfile[srcIndex].hyperlink;
|
|
1146
|
+
var srcData = ctx.luckysheetfile[srcIndex].data;
|
|
1147
|
+
if (!ctx.luckysheetfile[targetSheetIndex].hyperlink) {
|
|
1148
|
+
ctx.luckysheetfile[targetSheetIndex].hyperlink = {};
|
|
1149
|
+
}
|
|
1150
|
+
var targetHyperlinks = ctx.luckysheetfile[targetSheetIndex].hyperlink;
|
|
1151
|
+
var isSingleCell = copyh === 1 && copyc === 1;
|
|
1152
|
+
var cachedSrcLinkKey = isSingleCell ? "".concat(c_r1, "_").concat(c_c1) : null;
|
|
1153
|
+
var cachedSrcLink = isSingleCell && srcHyperlinks ? srcHyperlinks[cachedSrcLinkKey] : null;
|
|
1154
|
+
var cachedSrcCell = isSingleCell && srcData ? (_p = srcData[c_r1]) === null || _p === void 0 ? void 0 : _p[c_c1] : null;
|
|
1155
|
+
for (var th = 1; th <= timesH; th += 1) {
|
|
1156
|
+
for (var tc = 1; tc <= timesC; tc += 1) {
|
|
1157
|
+
var linkMth = minh + (th - 1) * copyh;
|
|
1158
|
+
var linkMtc = minc + (tc - 1) * copyc;
|
|
1159
|
+
var linkMaxRow = minh + th * copyh;
|
|
1160
|
+
var linkMaxCol = minc + tc * copyc;
|
|
1161
|
+
for (var h = linkMth; h < linkMaxRow; h += 1) {
|
|
1162
|
+
for (var c = linkMtc; c < linkMaxCol; c += 1) {
|
|
1163
|
+
var srcLink = void 0;
|
|
1164
|
+
if (isSingleCell && cachedSrcLink) {
|
|
1165
|
+
srcLink = cachedSrcLink;
|
|
1166
|
+
} else {
|
|
1167
|
+
var srcRow = c_r1 + (h - linkMth);
|
|
1168
|
+
var srcCol = c_c1 + (c - linkMtc);
|
|
1169
|
+
srcLink = srcHyperlinks === null || srcHyperlinks === void 0 ? void 0 : srcHyperlinks["".concat(srcRow, "_").concat(srcCol)];
|
|
1170
|
+
}
|
|
1171
|
+
if (!srcLink) continue;
|
|
1172
|
+
var targetKey = "".concat(h, "_").concat(c);
|
|
1173
|
+
targetHyperlinks[targetKey] = srcLink;
|
|
1174
|
+
var cell = (_q = d[h]) === null || _q === void 0 ? void 0 : _q[c];
|
|
1175
|
+
if (cell) {
|
|
1176
|
+
var srcCell = void 0;
|
|
1177
|
+
if (isSingleCell && cachedSrcCell) {
|
|
1178
|
+
srcCell = cachedSrcCell;
|
|
1179
|
+
} else {
|
|
1180
|
+
var srcRow = c_r1 + (h - linkMth);
|
|
1181
|
+
var srcCol = c_c1 + (c - linkMtc);
|
|
1182
|
+
srcCell = (_r = srcData === null || srcData === void 0 ? void 0 : srcData[srcRow]) === null || _r === void 0 ? void 0 : _r[srcCol];
|
|
1183
|
+
}
|
|
1184
|
+
cell.hl = {
|
|
1185
|
+
r: h,
|
|
1186
|
+
c: c,
|
|
1187
|
+
id: ctx.currentSheetId
|
|
1188
|
+
};
|
|
1189
|
+
if (srcCell) {
|
|
1190
|
+
if (srcCell.fc) cell.fc = srcCell.fc;
|
|
1191
|
+
if (srcCell.un !== undefined) cell.un = srcCell.un;
|
|
1192
|
+
} else {
|
|
1193
|
+
cell.fc = cell.fc || "rgb(0, 0, 255)";
|
|
1194
|
+
cell.un = cell.un !== undefined ? cell.un : 1;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1113
1198
|
}
|
|
1114
1199
|
}
|
|
1115
|
-
}
|
|
1200
|
+
}
|
|
1116
1201
|
}
|
|
1117
1202
|
if (copyRowlChange || addr > 0 || addc > 0) {
|
|
1118
1203
|
(0, _refresh.jfrefreshgrid)(ctx, d, ctx.luckysheet_select_save);
|
|
@@ -1149,11 +1234,17 @@ function parseAsLinkIfUrl(txtdata, ctx) {
|
|
|
1149
1234
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1150
1235
|
var urlRegex = /^(https?:\/\/[^\s]+)/;
|
|
1151
1236
|
if (urlRegex.test(txtdata)) {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
var
|
|
1155
|
-
var colIndex = (_g = (_e = last.column_focus) !== null && _e !== void 0 ? _e : (_f = last.column) === null || _f === void 0 ? void 0 : _f[0]) !== null && _g !== void 0 ? _g : 0;
|
|
1237
|
+
if (ctx.luckysheetCellUpdate.length === 2) {
|
|
1238
|
+
var rowIndex = ctx.luckysheetCellUpdate[0];
|
|
1239
|
+
var colIndex = ctx.luckysheetCellUpdate[1];
|
|
1156
1240
|
(0, _modules.saveHyperlink)(ctx, rowIndex, colIndex, txtdata, "webpage", txtdata);
|
|
1241
|
+
} else {
|
|
1242
|
+
var last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
|
|
1243
|
+
if (last) {
|
|
1244
|
+
var rowIndex = (_d = (_b = last.row_focus) !== null && _b !== void 0 ? _b : (_c = last.row) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : 0;
|
|
1245
|
+
var colIndex = (_g = (_e = last.column_focus) !== null && _e !== void 0 ? _e : (_f = last.column) === null || _f === void 0 ? void 0 : _f[0]) !== null && _g !== void 0 ? _g : 0;
|
|
1246
|
+
(0, _modules.saveHyperlink)(ctx, rowIndex, colIndex, txtdata, "webpage", txtdata);
|
|
1247
|
+
}
|
|
1157
1248
|
}
|
|
1158
1249
|
}
|
|
1159
1250
|
}
|
package/lib/locale/en.js
CHANGED
|
@@ -2941,6 +2941,27 @@ var _default = exports.default = {
|
|
|
2941
2941
|
repeat: "n",
|
|
2942
2942
|
type: "rangeall"
|
|
2943
2943
|
}]
|
|
2944
|
+
}, {
|
|
2945
|
+
n: "EPOCHTODATE",
|
|
2946
|
+
t: 2,
|
|
2947
|
+
d: "Converts a Unix epoch timestamp in seconds, milliseconds, or microseconds to a datetime in UTC.",
|
|
2948
|
+
a: "Vertical lookup.",
|
|
2949
|
+
m: [3, 4],
|
|
2950
|
+
p: [{
|
|
2951
|
+
name: "timestamp",
|
|
2952
|
+
detail: "A Unix epoch timestamp in seconds, milliseconds, or microseconds.",
|
|
2953
|
+
example: "1655906568893",
|
|
2954
|
+
require: "m",
|
|
2955
|
+
repeat: "n",
|
|
2956
|
+
type: "rangeall"
|
|
2957
|
+
}, {
|
|
2958
|
+
name: "time_unit",
|
|
2959
|
+
detail: "The unit of time in which the timestamp is expressed. 1 (default) indicates the time unit is seconds. 2 indicates the time unit is milliseconds. 3 indicates the time unit is microseconds.",
|
|
2960
|
+
example: "2",
|
|
2961
|
+
require: "o",
|
|
2962
|
+
repeat: "n",
|
|
2963
|
+
type: "rangeall"
|
|
2964
|
+
}]
|
|
2944
2965
|
}, {
|
|
2945
2966
|
n: "HLOOKUP",
|
|
2946
2967
|
t: 2,
|
package/lib/modules/cell.js
CHANGED
|
@@ -571,14 +571,32 @@ function cancelNormalSelected(ctx) {
|
|
|
571
571
|
ctx.formulaCache.rangedrag_row_start = false;
|
|
572
572
|
}
|
|
573
573
|
function updateCell(ctx, r, c, $input, value, canvas) {
|
|
574
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
574
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
575
575
|
if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
|
|
576
576
|
var inputText = $input === null || $input === void 0 ? void 0 : $input.innerText;
|
|
577
577
|
var inputHtml = $input === null || $input === void 0 ? void 0 : $input.innerHTML;
|
|
578
|
+
var trimmedInputText = (inputText !== null && inputText !== void 0 ? inputText : "").trim();
|
|
579
|
+
var isSingleToken = trimmedInputText.length > 0 && !/[\s\r\n]/.test(trimmedInputText);
|
|
580
|
+
var isUrlPastedInEditor = isSingleToken && /^(https?:\/\/|www\.)\S+$/i.test(trimmedInputText);
|
|
581
|
+
var normalizedUrl = null;
|
|
582
|
+
if (isUrlPastedInEditor) {
|
|
583
|
+
if (trimmedInputText.startsWith("http")) {
|
|
584
|
+
normalizedUrl = trimmedInputText;
|
|
585
|
+
} else {
|
|
586
|
+
normalizedUrl = "https://".concat(trimmedInputText);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
578
589
|
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
579
590
|
if (!flowdata) return;
|
|
580
591
|
var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
581
592
|
var dataVerification = ctx.luckysheetfile[index].dataVerification;
|
|
593
|
+
var sheetFile = ctx.luckysheetfile[index];
|
|
594
|
+
var getUrlFromText = function getUrlFromText(text) {
|
|
595
|
+
var t = (text !== null && text !== void 0 ? text : "").trim();
|
|
596
|
+
if (!t || /[\s\r\n]/.test(t)) return null;
|
|
597
|
+
if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
|
|
598
|
+
return t.startsWith("http") ? t : "https://".concat(t);
|
|
599
|
+
};
|
|
582
600
|
if (!_lodash.default.isNil(dataVerification)) {
|
|
583
601
|
var dvItem = dataVerification["".concat(r, "_").concat(c)];
|
|
584
602
|
if (!_lodash.default.isNil(dvItem) && dvItem.prohibitInput && !(0, _dataVerification.validateCellData)(ctx, dvItem, inputText)) {
|
|
@@ -591,7 +609,7 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
591
609
|
var curv = flowdata[r][c];
|
|
592
610
|
var oldValue = _lodash.default.cloneDeep(curv);
|
|
593
611
|
var isPrevInline = (0, _inlineString.isInlineStringCell)(curv);
|
|
594
|
-
var isCurInline = (inputText === null || inputText === void 0 ? void 0 : inputText.slice(0, 1)) !== "=" && (inputHtml === null || inputHtml === void 0 ? void 0 : inputHtml.substring(0, 5)) === "<span";
|
|
612
|
+
var isCurInline = (inputText === null || inputText === void 0 ? void 0 : inputText.slice(0, 1)) !== "=" && ((inputHtml === null || inputHtml === void 0 ? void 0 : inputHtml.substring(0, 5)) === "<span" || isUrlPastedInEditor);
|
|
595
613
|
var isCopyVal = false;
|
|
596
614
|
if (!isCurInline && inputText && inputText.length > 0) {
|
|
597
615
|
var splitArr = inputText.replace(/\r\n/g, "_x000D_").replace(/ /g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_").split("_x000D_");
|
|
@@ -619,7 +637,17 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
619
637
|
curv.tb = "1";
|
|
620
638
|
}
|
|
621
639
|
curv.ct.t = "inlineStr";
|
|
622
|
-
|
|
640
|
+
if (isUrlPastedInEditor && normalizedUrl) {
|
|
641
|
+
curv.ct.s = [{
|
|
642
|
+
v: trimmedInputText,
|
|
643
|
+
fs: fontSize,
|
|
644
|
+
l: {
|
|
645
|
+
target: normalizedUrl
|
|
646
|
+
}
|
|
647
|
+
}];
|
|
648
|
+
} else {
|
|
649
|
+
curv.ct.s = (0, _inlineString.convertSpanToShareString)($input.querySelectorAll("span"), curv);
|
|
650
|
+
}
|
|
623
651
|
delete curv.fs;
|
|
624
652
|
delete curv.f;
|
|
625
653
|
delete curv.v;
|
|
@@ -836,13 +864,30 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
836
864
|
} catch (e) {
|
|
837
865
|
console.log("[updateCell] spill failed; falling back", e);
|
|
838
866
|
}
|
|
867
|
+
var url = getUrlFromText($input === null || $input === void 0 ? void 0 : $input.innerText);
|
|
868
|
+
if (url && _typeof(value) === "object" && value) {
|
|
869
|
+
value.hl = 1;
|
|
870
|
+
if (!sheetFile.hyperlink) sheetFile.hyperlink = {};
|
|
871
|
+
sheetFile.hyperlink["".concat(r, "_").concat(c)] = {
|
|
872
|
+
linkType: "webpage",
|
|
873
|
+
linkAddress: url
|
|
874
|
+
};
|
|
875
|
+
if (typeof value.v !== "string") {
|
|
876
|
+
value.v = (_r = $input === null || $input === void 0 ? void 0 : $input.innerText) !== null && _r !== void 0 ? _r : url;
|
|
877
|
+
}
|
|
878
|
+
if (value.m == null) {
|
|
879
|
+
value.m = value.v;
|
|
880
|
+
}
|
|
881
|
+
if (value.fc == null) value.fc = "rgb(0, 0, 255)";
|
|
882
|
+
if (value.un == null) value.un = 1;
|
|
883
|
+
}
|
|
839
884
|
setCellValue(ctx, r, c, d, value);
|
|
840
885
|
cancelNormalSelected(ctx);
|
|
841
886
|
if ((curv === null || curv === void 0 ? void 0 : curv.tb) === "2" && curv.v || (0, _inlineString.isInlineStringCell)(d[r][c])) {
|
|
842
887
|
var defaultrowlen = ctx.defaultrowlen;
|
|
843
888
|
var cfg = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].config || {};
|
|
844
|
-
if (!(((
|
|
845
|
-
var cellWidth = ((
|
|
889
|
+
if (!(((_s = cfg.columnlen) === null || _s === void 0 ? void 0 : _s[c]) && ((_t = cfg.rowlen) === null || _t === void 0 ? void 0 : _t[r]))) {
|
|
890
|
+
var cellWidth = ((_u = cfg.columnlen) === null || _u === void 0 ? void 0 : _u[c]) || ctx.defaultcollen;
|
|
846
891
|
var textInfo = canvas ? (0, _text.getCellTextInfo)(d[r][c], canvas, ctx, {
|
|
847
892
|
r: r,
|
|
848
893
|
c: c,
|
|
@@ -853,7 +898,7 @@ function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
853
898
|
currentRowLen = textInfo.textHeightAll + 2;
|
|
854
899
|
}
|
|
855
900
|
var previousRowHeight = (0, _api.getRowHeight)(ctx, [r])[r];
|
|
856
|
-
if (currentRowLen > defaultrowlen && !((
|
|
901
|
+
if (currentRowLen > defaultrowlen && !((_v = cfg.customHeight) === null || _v === void 0 ? void 0 : _v[r]) && previousRowHeight < currentRowLen) {
|
|
857
902
|
if (_lodash.default.isNil(cfg.rowlen)) cfg.rowlen = {};
|
|
858
903
|
cfg.rowlen[r] = currentRowLen;
|
|
859
904
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fileverse-dev/fortune-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.64-linkPasteFix-patch-2",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "es/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dev": "father-build --watch"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@fileverse-dev/formula-parser": "0.2.
|
|
18
|
+
"@fileverse-dev/formula-parser": "0.2.87",
|
|
19
19
|
"dayjs": "^1.11.0",
|
|
20
20
|
"immer": "^9.0.12",
|
|
21
21
|
"lodash": "^4.17.21",
|