@fileverse-dev/fortune-core 1.2.63 → 1.2.64-linkPasteFix-patch-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.
@@ -786,7 +786,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
786
786
  }
787
787
  }
788
788
  function pasteHandlerOfCopyPaste(ctx, copyRange) {
789
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
789
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
790
790
  var allowEdit = isAllowEdit(ctx);
791
791
  if (!allowEdit || ctx.isFlvReadOnly) return;
792
792
  if (!copyRange) return;
@@ -1085,21 +1085,64 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1085
1085
  file.luckysheet_conditionformat_save = cdformat;
1086
1086
  file.dataVerification = __assign(__assign({}, file.dataVerification), dataVerification);
1087
1087
  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
- _.forEach((_o = ctx.luckysheet_copy_save) === null || _o === void 0 ? void 0 : _o.copyRange, function (range) {
1089
- var _a, _b, _c;
1090
- var srcIndex = getSheetIndex(ctx, (_a = ctx.luckysheet_copy_save) === null || _a === void 0 ? void 0 : _a.dataSheetId);
1091
- for (var r = 0; r <= range.row[1] - range.row[0]; r += 1) {
1092
- for (var c = 0; c <= range.column[1] - range.column[0]; c += 1) {
1093
- var srcRow = r + range.row[0];
1094
- var srcCol = c + range.column[0];
1095
- var srcLink = (_b = ctx.luckysheetfile[srcIndex].hyperlink) === null || _b === void 0 ? void 0 : _b["".concat(srcRow, "_").concat(srcCol)];
1096
- if (!srcLink) continue;
1097
- var targetR = r + ctx.luckysheet_select_save[0].row[0];
1098
- var targetC = c + ctx.luckysheet_select_save[0].column[0];
1099
- setCellHyperlink(ctx, (_c = ctx.luckysheet_copy_save) === null || _c === void 0 ? void 0 : _c.dataSheetId, targetR, targetC, srcLink);
1088
+ var srcIndex = getSheetIndex(ctx, (_o = ctx.luckysheet_copy_save) === null || _o === void 0 ? void 0 : _o.dataSheetId);
1089
+ var targetSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
1090
+ var srcHyperlinks = ctx.luckysheetfile[srcIndex].hyperlink;
1091
+ var srcData = ctx.luckysheetfile[srcIndex].data;
1092
+ if (!ctx.luckysheetfile[targetSheetIndex].hyperlink) {
1093
+ ctx.luckysheetfile[targetSheetIndex].hyperlink = {};
1094
+ }
1095
+ var targetHyperlinks = ctx.luckysheetfile[targetSheetIndex].hyperlink;
1096
+ var isSingleCell = copyh === 1 && copyc === 1;
1097
+ var cachedSrcLinkKey = isSingleCell ? "".concat(c_r1, "_").concat(c_c1) : null;
1098
+ var cachedSrcLink = isSingleCell && srcHyperlinks ? srcHyperlinks[cachedSrcLinkKey] : null;
1099
+ var cachedSrcCell = isSingleCell && srcData ? (_p = srcData[c_r1]) === null || _p === void 0 ? void 0 : _p[c_c1] : null;
1100
+ for (var th = 1; th <= timesH; th += 1) {
1101
+ for (var tc = 1; tc <= timesC; tc += 1) {
1102
+ var linkMth = minh + (th - 1) * copyh;
1103
+ var linkMtc = minc + (tc - 1) * copyc;
1104
+ var linkMaxRow = minh + th * copyh;
1105
+ var linkMaxCol = minc + tc * copyc;
1106
+ for (var h = linkMth; h < linkMaxRow; h += 1) {
1107
+ for (var c = linkMtc; c < linkMaxCol; c += 1) {
1108
+ var srcLink = void 0;
1109
+ if (isSingleCell && cachedSrcLink) {
1110
+ srcLink = cachedSrcLink;
1111
+ } else {
1112
+ var srcRow = c_r1 + (h - linkMth);
1113
+ var srcCol = c_c1 + (c - linkMtc);
1114
+ srcLink = srcHyperlinks === null || srcHyperlinks === void 0 ? void 0 : srcHyperlinks["".concat(srcRow, "_").concat(srcCol)];
1115
+ }
1116
+ if (!srcLink) continue;
1117
+ var targetKey = "".concat(h, "_").concat(c);
1118
+ targetHyperlinks[targetKey] = srcLink;
1119
+ var cell = (_q = d[h]) === null || _q === void 0 ? void 0 : _q[c];
1120
+ if (cell) {
1121
+ var srcCell = void 0;
1122
+ if (isSingleCell && cachedSrcCell) {
1123
+ srcCell = cachedSrcCell;
1124
+ } else {
1125
+ var srcRow = c_r1 + (h - linkMth);
1126
+ var srcCol = c_c1 + (c - linkMtc);
1127
+ srcCell = (_r = srcData === null || srcData === void 0 ? void 0 : srcData[srcRow]) === null || _r === void 0 ? void 0 : _r[srcCol];
1128
+ }
1129
+ cell.hl = {
1130
+ r: h,
1131
+ c: c,
1132
+ id: ctx.currentSheetId
1133
+ };
1134
+ if (srcCell) {
1135
+ if (srcCell.fc) cell.fc = srcCell.fc;
1136
+ if (srcCell.un !== undefined) cell.un = srcCell.un;
1137
+ } else {
1138
+ cell.fc = cell.fc || "rgb(0, 0, 255)";
1139
+ cell.un = cell.un !== undefined ? cell.un : 1;
1140
+ }
1141
+ }
1142
+ }
1100
1143
  }
1101
1144
  }
1102
- });
1145
+ }
1103
1146
  }
1104
1147
  if (copyRowlChange || addr > 0 || addc > 0) {
1105
1148
  jfrefreshgrid(ctx, d, ctx.luckysheet_select_save);
@@ -1136,11 +1179,17 @@ export function parseAsLinkIfUrl(txtdata, ctx) {
1136
1179
  var _a, _b, _c, _d, _e, _f, _g;
1137
1180
  var urlRegex = /^(https?:\/\/[^\s]+)/;
1138
1181
  if (urlRegex.test(txtdata)) {
1139
- var last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
1140
- if (last) {
1141
- 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;
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;
1182
+ if (ctx.luckysheetCellUpdate.length === 2) {
1183
+ var rowIndex = ctx.luckysheetCellUpdate[0];
1184
+ var colIndex = ctx.luckysheetCellUpdate[1];
1143
1185
  saveHyperlink(ctx, rowIndex, colIndex, txtdata, "webpage", txtdata);
1186
+ } else {
1187
+ var last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
1188
+ if (last) {
1189
+ 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;
1190
+ 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;
1191
+ saveHyperlink(ctx, rowIndex, colIndex, txtdata, "webpage", txtdata);
1192
+ }
1144
1193
  }
1145
1194
  }
1146
1195
  }
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,
@@ -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(/&#13;&#10;/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
- curv.ct.s = convertSpanToShareString($input.querySelectorAll("span"), curv);
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 (!(((_r = cfg.columnlen) === null || _r === void 0 ? void 0 : _r[c]) && ((_s = cfg.rowlen) === null || _s === void 0 ? void 0 : _s[r]))) {
812
- var cellWidth = ((_t = cfg.columnlen) === null || _t === void 0 ? void 0 : _t[c]) || ctx.defaultcollen;
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 && !((_u = cfg.customHeight) === null || _u === void 0 ? void 0 : _u[r]) && previousRowHeight < currentRowLen) {
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
  }
@@ -799,7 +799,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
799
799
  }
800
800
  }
801
801
  function pasteHandlerOfCopyPaste(ctx, copyRange) {
802
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
802
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
803
803
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
804
804
  if (!allowEdit || ctx.isFlvReadOnly) return;
805
805
  if (!copyRange) return;
@@ -1098,21 +1098,64 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1098
1098
  file.luckysheet_conditionformat_save = cdformat;
1099
1099
  file.dataVerification = __assign(__assign({}, file.dataVerification), dataVerification);
1100
1100
  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
- _lodash.default.forEach((_o = ctx.luckysheet_copy_save) === null || _o === void 0 ? void 0 : _o.copyRange, function (range) {
1102
- var _a, _b, _c;
1103
- var srcIndex = (0, _utils.getSheetIndex)(ctx, (_a = ctx.luckysheet_copy_save) === null || _a === void 0 ? void 0 : _a.dataSheetId);
1104
- for (var r = 0; r <= range.row[1] - range.row[0]; r += 1) {
1105
- for (var c = 0; c <= range.column[1] - range.column[0]; c += 1) {
1106
- var srcRow = r + range.row[0];
1107
- var srcCol = c + range.column[0];
1108
- var srcLink = (_b = ctx.luckysheetfile[srcIndex].hyperlink) === null || _b === void 0 ? void 0 : _b["".concat(srcRow, "_").concat(srcCol)];
1109
- if (!srcLink) continue;
1110
- var targetR = r + ctx.luckysheet_select_save[0].row[0];
1111
- var targetC = c + ctx.luckysheet_select_save[0].column[0];
1112
- setCellHyperlink(ctx, (_c = ctx.luckysheet_copy_save) === null || _c === void 0 ? void 0 : _c.dataSheetId, targetR, targetC, srcLink);
1101
+ var srcIndex = (0, _utils.getSheetIndex)(ctx, (_o = ctx.luckysheet_copy_save) === null || _o === void 0 ? void 0 : _o.dataSheetId);
1102
+ var targetSheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
1103
+ var srcHyperlinks = ctx.luckysheetfile[srcIndex].hyperlink;
1104
+ var srcData = ctx.luckysheetfile[srcIndex].data;
1105
+ if (!ctx.luckysheetfile[targetSheetIndex].hyperlink) {
1106
+ ctx.luckysheetfile[targetSheetIndex].hyperlink = {};
1107
+ }
1108
+ var targetHyperlinks = ctx.luckysheetfile[targetSheetIndex].hyperlink;
1109
+ var isSingleCell = copyh === 1 && copyc === 1;
1110
+ var cachedSrcLinkKey = isSingleCell ? "".concat(c_r1, "_").concat(c_c1) : null;
1111
+ var cachedSrcLink = isSingleCell && srcHyperlinks ? srcHyperlinks[cachedSrcLinkKey] : null;
1112
+ var cachedSrcCell = isSingleCell && srcData ? (_p = srcData[c_r1]) === null || _p === void 0 ? void 0 : _p[c_c1] : null;
1113
+ for (var th = 1; th <= timesH; th += 1) {
1114
+ for (var tc = 1; tc <= timesC; tc += 1) {
1115
+ var linkMth = minh + (th - 1) * copyh;
1116
+ var linkMtc = minc + (tc - 1) * copyc;
1117
+ var linkMaxRow = minh + th * copyh;
1118
+ var linkMaxCol = minc + tc * copyc;
1119
+ for (var h = linkMth; h < linkMaxRow; h += 1) {
1120
+ for (var c = linkMtc; c < linkMaxCol; c += 1) {
1121
+ var srcLink = void 0;
1122
+ if (isSingleCell && cachedSrcLink) {
1123
+ srcLink = cachedSrcLink;
1124
+ } else {
1125
+ var srcRow = c_r1 + (h - linkMth);
1126
+ var srcCol = c_c1 + (c - linkMtc);
1127
+ srcLink = srcHyperlinks === null || srcHyperlinks === void 0 ? void 0 : srcHyperlinks["".concat(srcRow, "_").concat(srcCol)];
1128
+ }
1129
+ if (!srcLink) continue;
1130
+ var targetKey = "".concat(h, "_").concat(c);
1131
+ targetHyperlinks[targetKey] = srcLink;
1132
+ var cell = (_q = d[h]) === null || _q === void 0 ? void 0 : _q[c];
1133
+ if (cell) {
1134
+ var srcCell = void 0;
1135
+ if (isSingleCell && cachedSrcCell) {
1136
+ srcCell = cachedSrcCell;
1137
+ } else {
1138
+ var srcRow = c_r1 + (h - linkMth);
1139
+ var srcCol = c_c1 + (c - linkMtc);
1140
+ srcCell = (_r = srcData === null || srcData === void 0 ? void 0 : srcData[srcRow]) === null || _r === void 0 ? void 0 : _r[srcCol];
1141
+ }
1142
+ cell.hl = {
1143
+ r: h,
1144
+ c: c,
1145
+ id: ctx.currentSheetId
1146
+ };
1147
+ if (srcCell) {
1148
+ if (srcCell.fc) cell.fc = srcCell.fc;
1149
+ if (srcCell.un !== undefined) cell.un = srcCell.un;
1150
+ } else {
1151
+ cell.fc = cell.fc || "rgb(0, 0, 255)";
1152
+ cell.un = cell.un !== undefined ? cell.un : 1;
1153
+ }
1154
+ }
1155
+ }
1113
1156
  }
1114
1157
  }
1115
- });
1158
+ }
1116
1159
  }
1117
1160
  if (copyRowlChange || addr > 0 || addc > 0) {
1118
1161
  (0, _refresh.jfrefreshgrid)(ctx, d, ctx.luckysheet_select_save);
@@ -1149,11 +1192,17 @@ function parseAsLinkIfUrl(txtdata, ctx) {
1149
1192
  var _a, _b, _c, _d, _e, _f, _g;
1150
1193
  var urlRegex = /^(https?:\/\/[^\s]+)/;
1151
1194
  if (urlRegex.test(txtdata)) {
1152
- var last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
1153
- if (last) {
1154
- 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;
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;
1195
+ if (ctx.luckysheetCellUpdate.length === 2) {
1196
+ var rowIndex = ctx.luckysheetCellUpdate[0];
1197
+ var colIndex = ctx.luckysheetCellUpdate[1];
1156
1198
  (0, _modules.saveHyperlink)(ctx, rowIndex, colIndex, txtdata, "webpage", txtdata);
1199
+ } else {
1200
+ var last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
1201
+ if (last) {
1202
+ 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;
1203
+ 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;
1204
+ (0, _modules.saveHyperlink)(ctx, rowIndex, colIndex, txtdata, "webpage", txtdata);
1205
+ }
1157
1206
  }
1158
1207
  }
1159
1208
  }
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,
@@ -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(/&#13;&#10;/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
- curv.ct.s = (0, _inlineString.convertSpanToShareString)($input.querySelectorAll("span"), curv);
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 (!(((_r = cfg.columnlen) === null || _r === void 0 ? void 0 : _r[c]) && ((_s = cfg.rowlen) === null || _s === void 0 ? void 0 : _s[r]))) {
845
- var cellWidth = ((_t = cfg.columnlen) === null || _t === void 0 ? void 0 : _t[c]) || ctx.defaultcollen;
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 && !((_u = cfg.customHeight) === null || _u === void 0 ? void 0 : _u[r]) && previousRowHeight < currentRowLen) {
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.63",
3
+ "version": "1.2.64-linkPasteFix-patch-1",
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.86",
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",