@fileverse-dev/fortune-core 1.2.64-linkPasteFix-patch-2 → 1.2.64-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.
@@ -354,21 +354,12 @@ 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
- };
363
357
  for (var r = 0; r < rlen; r += 1) {
364
358
  var x = d[r + curR];
365
359
  for (var c = 0; c < clen; c += 1) {
366
360
  var originCell = x[c + curC];
367
361
  var value = dataChe[r][c];
368
- var originalValueStr = String(value);
369
- var url = getUrlFromText(originalValueStr);
370
- var isUrl = url !== null;
371
- if (!isUrl && isRealNum(value)) {
362
+ if (isRealNum(value)) {
372
363
  if (originCell && originCell.ct && originCell.ct.fa === "@") {
373
364
  value = String(value);
374
365
  } else if (!/^0x?[a-fA-F0-9]+$/.test(value)) {
@@ -376,59 +367,26 @@ function pasteHandler(ctx, data, borderInfo) {
376
367
  }
377
368
  }
378
369
  if (originCell) {
379
- originCell.v = isUrl ? originalValueStr : value;
370
+ originCell.v = value;
380
371
  if (originCell.ct != null && originCell.ct.fa != null) {
381
- originCell.m = update(originCell.ct.fa, originCell.v);
372
+ originCell.m = update(originCell.ct.fa, value);
382
373
  } else {
383
- originCell.m = typeof originCell.v === "boolean" ? String(originCell.v) : originCell.v;
374
+ originCell.m = value;
384
375
  }
385
376
  if (originCell.f != null && originCell.f.length > 0) {
386
377
  originCell.f = "";
387
378
  }
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
- }
400
379
  } else {
401
380
  var cell = {};
402
- if (isUrl) {
403
- cell.v = originalValueStr;
404
- cell.m = originalValueStr;
381
+ var mask = genarate(value);
382
+ _a = mask, cell.m = _a[0], cell.ct = _a[1], cell.v = _a[2];
383
+ if (/^0x?[a-fA-F0-9]+$/.test(value)) {
384
+ cell.m = value;
405
385
  cell.ct = {
406
386
  fa: "@",
407
387
  t: "s"
408
388
  };
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;
389
+ cell.v = value;
432
390
  }
433
391
  x[c + curC] = cell;
434
392
  }
@@ -828,7 +786,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
828
786
  }
829
787
  }
830
788
  function pasteHandlerOfCopyPaste(ctx, copyRange) {
831
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
789
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
832
790
  var allowEdit = isAllowEdit(ctx);
833
791
  if (!allowEdit || ctx.isFlvReadOnly) return;
834
792
  if (!copyRange) return;
@@ -1127,64 +1085,21 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1127
1085
  file.luckysheet_conditionformat_save = cdformat;
1128
1086
  file.dataVerification = __assign(__assign({}, file.dataVerification), dataVerification);
1129
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) {
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
- }
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);
1185
1100
  }
1186
1101
  }
1187
- }
1102
+ });
1188
1103
  }
1189
1104
  if (copyRowlChange || addr > 0 || addc > 0) {
1190
1105
  jfrefreshgrid(ctx, d, ctx.luckysheet_select_save);
@@ -1221,17 +1136,11 @@ export function parseAsLinkIfUrl(txtdata, ctx) {
1221
1136
  var _a, _b, _c, _d, _e, _f, _g;
1222
1137
  var urlRegex = /^(https?:\/\/[^\s]+)/;
1223
1138
  if (urlRegex.test(txtdata)) {
1224
- if (ctx.luckysheetCellUpdate.length === 2) {
1225
- var rowIndex = ctx.luckysheetCellUpdate[0];
1226
- var colIndex = ctx.luckysheetCellUpdate[1];
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;
1227
1143
  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
- }
1235
1144
  }
1236
1145
  }
1237
1146
  }
@@ -538,32 +538,14 @@ 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, _v;
541
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
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
- }
556
545
  var flowdata = getFlowdata(ctx);
557
546
  if (!flowdata) return;
558
547
  var index = getSheetIndex(ctx, ctx.currentSheetId);
559
548
  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
- };
567
549
  if (!_.isNil(dataVerification)) {
568
550
  var dvItem = dataVerification["".concat(r, "_").concat(c)];
569
551
  if (!_.isNil(dvItem) && dvItem.prohibitInput && !validateCellData(ctx, dvItem, inputText)) {
@@ -576,7 +558,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
576
558
  var curv = flowdata[r][c];
577
559
  var oldValue = _.cloneDeep(curv);
578
560
  var isPrevInline = isInlineStringCell(curv);
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);
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";
580
562
  var isCopyVal = false;
581
563
  if (!isCurInline && inputText && inputText.length > 0) {
582
564
  var splitArr = inputText.replace(/\r\n/g, "_x000D_").replace(/&#13;&#10;/g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_").split("_x000D_");
@@ -604,17 +586,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
604
586
  curv.tb = "1";
605
587
  }
606
588
  curv.ct.t = "inlineStr";
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
- }
589
+ curv.ct.s = convertSpanToShareString($input.querySelectorAll("span"), curv);
618
590
  delete curv.fs;
619
591
  delete curv.f;
620
592
  delete curv.v;
@@ -831,30 +803,13 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
831
803
  } catch (e) {
832
804
  console.log("[updateCell] spill failed; falling back", e);
833
805
  }
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
- }
851
806
  setCellValue(ctx, r, c, d, value);
852
807
  cancelNormalSelected(ctx);
853
808
  if ((curv === null || curv === void 0 ? void 0 : curv.tb) === "2" && curv.v || isInlineStringCell(d[r][c])) {
854
809
  var defaultrowlen = ctx.defaultrowlen;
855
810
  var cfg = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].config || {};
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;
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;
858
813
  var textInfo = canvas ? getCellTextInfo(d[r][c], canvas, ctx, {
859
814
  r: r,
860
815
  c: c,
@@ -865,7 +820,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
865
820
  currentRowLen = textInfo.textHeightAll + 2;
866
821
  }
867
822
  var previousRowHeight = getRowHeight(ctx, [r])[r];
868
- if (currentRowLen > defaultrowlen && !((_v = cfg.customHeight) === null || _v === void 0 ? void 0 : _v[r]) && previousRowHeight < currentRowLen) {
823
+ if (currentRowLen > defaultrowlen && !((_u = cfg.customHeight) === null || _u === void 0 ? void 0 : _u[r]) && previousRowHeight < currentRowLen) {
869
824
  if (_.isNil(cfg.rowlen)) cfg.rowlen = {};
870
825
  cfg.rowlen[r] = currentRowLen;
871
826
  }
@@ -367,21 +367,12 @@ 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
- };
376
370
  for (var r = 0; r < rlen; r += 1) {
377
371
  var x = d[r + curR];
378
372
  for (var c = 0; c < clen; c += 1) {
379
373
  var originCell = x[c + curC];
380
374
  var value = dataChe[r][c];
381
- var originalValueStr = String(value);
382
- var url = getUrlFromText(originalValueStr);
383
- var isUrl = url !== null;
384
- if (!isUrl && (0, _validation.isRealNum)(value)) {
375
+ if ((0, _validation.isRealNum)(value)) {
385
376
  if (originCell && originCell.ct && originCell.ct.fa === "@") {
386
377
  value = String(value);
387
378
  } else if (!/^0x?[a-fA-F0-9]+$/.test(value)) {
@@ -389,59 +380,26 @@ function pasteHandler(ctx, data, borderInfo) {
389
380
  }
390
381
  }
391
382
  if (originCell) {
392
- originCell.v = isUrl ? originalValueStr : value;
383
+ originCell.v = value;
393
384
  if (originCell.ct != null && originCell.ct.fa != null) {
394
- originCell.m = (0, _format.update)(originCell.ct.fa, originCell.v);
385
+ originCell.m = (0, _format.update)(originCell.ct.fa, value);
395
386
  } else {
396
- originCell.m = typeof originCell.v === "boolean" ? String(originCell.v) : originCell.v;
387
+ originCell.m = value;
397
388
  }
398
389
  if (originCell.f != null && originCell.f.length > 0) {
399
390
  originCell.f = "";
400
391
  }
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
- }
413
392
  } else {
414
393
  var cell = {};
415
- if (isUrl) {
416
- cell.v = originalValueStr;
417
- cell.m = originalValueStr;
394
+ var mask = (0, _format.genarate)(value);
395
+ _a = mask, cell.m = _a[0], cell.ct = _a[1], cell.v = _a[2];
396
+ if (/^0x?[a-fA-F0-9]+$/.test(value)) {
397
+ cell.m = value;
418
398
  cell.ct = {
419
399
  fa: "@",
420
400
  t: "s"
421
401
  };
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;
402
+ cell.v = value;
445
403
  }
446
404
  x[c + curC] = cell;
447
405
  }
@@ -841,7 +799,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
841
799
  }
842
800
  }
843
801
  function pasteHandlerOfCopyPaste(ctx, copyRange) {
844
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
802
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
845
803
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
846
804
  if (!allowEdit || ctx.isFlvReadOnly) return;
847
805
  if (!copyRange) return;
@@ -1140,64 +1098,21 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
1140
1098
  file.luckysheet_conditionformat_save = cdformat;
1141
1099
  file.dataVerification = __assign(__assign({}, file.dataVerification), dataVerification);
1142
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) {
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
- }
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);
1198
1113
  }
1199
1114
  }
1200
- }
1115
+ });
1201
1116
  }
1202
1117
  if (copyRowlChange || addr > 0 || addc > 0) {
1203
1118
  (0, _refresh.jfrefreshgrid)(ctx, d, ctx.luckysheet_select_save);
@@ -1234,17 +1149,11 @@ function parseAsLinkIfUrl(txtdata, ctx) {
1234
1149
  var _a, _b, _c, _d, _e, _f, _g;
1235
1150
  var urlRegex = /^(https?:\/\/[^\s]+)/;
1236
1151
  if (urlRegex.test(txtdata)) {
1237
- if (ctx.luckysheetCellUpdate.length === 2) {
1238
- var rowIndex = ctx.luckysheetCellUpdate[0];
1239
- var colIndex = ctx.luckysheetCellUpdate[1];
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;
1240
1156
  (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
- }
1248
1157
  }
1249
1158
  }
1250
1159
  }
@@ -571,32 +571,14 @@ 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, _v;
574
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
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
- }
589
578
  var flowdata = (0, _context.getFlowdata)(ctx);
590
579
  if (!flowdata) return;
591
580
  var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
592
581
  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
- };
600
582
  if (!_lodash.default.isNil(dataVerification)) {
601
583
  var dvItem = dataVerification["".concat(r, "_").concat(c)];
602
584
  if (!_lodash.default.isNil(dvItem) && dvItem.prohibitInput && !(0, _dataVerification.validateCellData)(ctx, dvItem, inputText)) {
@@ -609,7 +591,7 @@ function updateCell(ctx, r, c, $input, value, canvas) {
609
591
  var curv = flowdata[r][c];
610
592
  var oldValue = _lodash.default.cloneDeep(curv);
611
593
  var isPrevInline = (0, _inlineString.isInlineStringCell)(curv);
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);
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";
613
595
  var isCopyVal = false;
614
596
  if (!isCurInline && inputText && inputText.length > 0) {
615
597
  var splitArr = inputText.replace(/\r\n/g, "_x000D_").replace(/&#13;&#10;/g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_").split("_x000D_");
@@ -637,17 +619,7 @@ function updateCell(ctx, r, c, $input, value, canvas) {
637
619
  curv.tb = "1";
638
620
  }
639
621
  curv.ct.t = "inlineStr";
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
- }
622
+ curv.ct.s = (0, _inlineString.convertSpanToShareString)($input.querySelectorAll("span"), curv);
651
623
  delete curv.fs;
652
624
  delete curv.f;
653
625
  delete curv.v;
@@ -864,30 +836,13 @@ function updateCell(ctx, r, c, $input, value, canvas) {
864
836
  } catch (e) {
865
837
  console.log("[updateCell] spill failed; falling back", e);
866
838
  }
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
- }
884
839
  setCellValue(ctx, r, c, d, value);
885
840
  cancelNormalSelected(ctx);
886
841
  if ((curv === null || curv === void 0 ? void 0 : curv.tb) === "2" && curv.v || (0, _inlineString.isInlineStringCell)(d[r][c])) {
887
842
  var defaultrowlen = ctx.defaultrowlen;
888
843
  var cfg = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].config || {};
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;
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;
891
846
  var textInfo = canvas ? (0, _text.getCellTextInfo)(d[r][c], canvas, ctx, {
892
847
  r: r,
893
848
  c: c,
@@ -898,7 +853,7 @@ function updateCell(ctx, r, c, $input, value, canvas) {
898
853
  currentRowLen = textInfo.textHeightAll + 2;
899
854
  }
900
855
  var previousRowHeight = (0, _api.getRowHeight)(ctx, [r])[r];
901
- if (currentRowLen > defaultrowlen && !((_v = cfg.customHeight) === null || _v === void 0 ? void 0 : _v[r]) && previousRowHeight < currentRowLen) {
856
+ if (currentRowLen > defaultrowlen && !((_u = cfg.customHeight) === null || _u === void 0 ? void 0 : _u[r]) && previousRowHeight < currentRowLen) {
902
857
  if (_lodash.default.isNil(cfg.rowlen)) cfg.rowlen = {};
903
858
  cfg.rowlen[r] = currentRowLen;
904
859
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.2.64-linkPasteFix-patch-2",
3
+ "version": "1.2.64-patch-1",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",