@fileverse-dev/fortune-core 1.1.52 → 1.1.53-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.
@@ -355,7 +355,7 @@ export function handleArrowKey(ctx, e) {
355
355
  var spans = doc.querySelectorAll("span");
356
356
  var lastSpan = spans[spans.length - 1];
357
357
  var notFunctionInit = !((_b = document.getElementById("luckysheet-rich-text-editor")) === null || _b === void 0 ? void 0 : _b.innerText.includes("("));
358
- if ((lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(")")) || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes('"')) || notFunctionInit && /^[a-zA-Z]+$/.test(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) && !_.includes(["="], lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
358
+ if ((lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(")")) || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes('"')) || notFunctionInit && /^[a-zA-Z]+$/.test(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) && !_.includes(["="], lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) || /^[a-zA-Z]+$/.test(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
359
359
  return;
360
360
  }
361
361
  }
@@ -178,7 +178,7 @@ export function handleCellAreaMouseDown(ctx, globalCache, e, cellInput, containe
178
178
  var spans = doc.querySelectorAll("span");
179
179
  var firstSpan = spans[0];
180
180
  var lastSpan = spans[spans.length - 1];
181
- if (ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || israngeseleciton(ctx) || (firstSpan === null || firstSpan === void 0 ? void 0 : firstSpan.innerText.includes("=")) && !(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(")"))) {
181
+ if ((ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || israngeseleciton(ctx) || (firstSpan === null || firstSpan === void 0 ? void 0 : firstSpan.innerText.includes("=")) && !(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(")"))) && lastSpan && ctx.luckysheetCellUpdate.length === 2) {
182
182
  var rowseleted = [row_index, row_index_ed];
183
183
  var columnseleted = [col_index, col_index_ed];
184
184
  var left = col_pre;
@@ -10,10 +10,10 @@ var __assign = this && this.__assign || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import _ from "lodash";
13
+ import { pasteHtmlTableAndAutoFit } from "../paste-table-helpers";
13
14
  import { getFlowdata } from "../context";
14
- import { locale } from "../locale";
15
15
  import { execfunction, functionCopy } from "../modules/formula";
16
- import { getdatabyselection, getQKBorder } from "../modules/cell";
16
+ import { getdatabyselection } from "../modules/cell";
17
17
  import { genarate, update } from "../modules/format";
18
18
  import { normalizeSelection, selectionCache } from "../modules/selection";
19
19
  import { getSheetIndex, isAllowEdit } from "../utils";
@@ -21,8 +21,7 @@ import { hasPartMC, isRealNum } from "../modules/validation";
21
21
  import { getBorderInfoCompute } from "../modules/border";
22
22
  import { expandRowsAndColumns, storeSheetParamALL } from "../modules/sheet";
23
23
  import { jfrefreshgrid } from "../modules/refresh";
24
- import { setRowHeight } from "../api";
25
- import { CFSplitRange, sanitizeDuneUrl, saveHyperlink } from "../modules";
24
+ import { CFSplitRange, getCellTextInfo, sanitizeDuneUrl, saveHyperlink } from "../modules";
26
25
  import clipboard from "../modules/clipboard";
27
26
  function postPasteCut(ctx, source, target, RowlChange) {
28
27
  var execF_rc = {};
@@ -1010,9 +1009,75 @@ export function parseAsLinkIfUrl(txtdata, ctx) {
1010
1009
  }
1011
1010
  }
1012
1011
  }
1012
+ function autoFitUsingGetCellTextInfo(ctx, sheetId, r1, r2, c1, c2, maxColWidth) {
1013
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1014
+ var _k, _l;
1015
+ if (maxColWidth === void 0) {
1016
+ maxColWidth = 1200;
1017
+ }
1018
+ var sheetIdx = getSheetIndex(ctx, sheetId);
1019
+ if (sheetIdx == null) return;
1020
+ var file = ctx.luckysheetfile[sheetIdx];
1021
+ file.config || (file.config = {});
1022
+ var rowlen = (_k = file.config).rowlen || (_k.rowlen = {});
1023
+ var columnlen = (_l = file.config).columnlen || (_l.columnlen = {});
1024
+ var defaultRowH = (_a = file.defaultRowHeight) !== null && _a !== void 0 ? _a : 19;
1025
+ var defaultColW = (_b = ctx.defaultcollen) !== null && _b !== void 0 ? _b : 73;
1026
+ var d = getFlowdata(ctx) || file.data;
1027
+ var measureCtx = ctx.__offscreenMeasureCtx || document.createElement("canvas").getContext("2d");
1028
+ ctx.__offscreenMeasureCtx = measureCtx;
1029
+ var H_PAD = 8;
1030
+ for (var c = c1; c <= c2; c++) {
1031
+ var curW = (_c = columnlen[c]) !== null && _c !== void 0 ? _c : defaultColW;
1032
+ var wantW = curW;
1033
+ for (var r = r1; r <= r2; r++) {
1034
+ var cell = (_d = d === null || d === void 0 ? void 0 : d[r]) === null || _d === void 0 ? void 0 : _d[c];
1035
+ if ((cell === null || cell === void 0 ? void 0 : cell.mc) && cell.mc.rs == null) continue;
1036
+ var tb = cell === null || cell === void 0 ? void 0 : cell.tb;
1037
+ if (tb === 2 || tb === "2") continue;
1038
+ var info = getCellTextInfo(cell, measureCtx, ctx, {
1039
+ r: r,
1040
+ c: c
1041
+ }, ctx);
1042
+ var w = (_e = info === null || info === void 0 ? void 0 : info.textWidthAll) !== null && _e !== void 0 ? _e : 0;
1043
+ if (w + H_PAD > wantW) wantW = w + H_PAD;
1044
+ }
1045
+ if (wantW > curW) {
1046
+ columnlen[c] = Math.min(Math.ceil(wantW), maxColWidth);
1047
+ }
1048
+ }
1049
+ var V_PAD = 4;
1050
+ for (var r = r1; r <= r2; r++) {
1051
+ var curH = (_f = rowlen[r]) !== null && _f !== void 0 ? _f : defaultRowH;
1052
+ var needH = curH;
1053
+ for (var c = c1; c <= c2; c++) {
1054
+ var cell = (_g = d === null || d === void 0 ? void 0 : d[r]) === null || _g === void 0 ? void 0 : _g[c];
1055
+ if ((cell === null || cell === void 0 ? void 0 : cell.mc) && cell.mc.rs == null) continue;
1056
+ var widthForCell = (_h = columnlen[c]) !== null && _h !== void 0 ? _h : defaultColW;
1057
+ var info = getCellTextInfo(cell, measureCtx, ctx, {
1058
+ r: r,
1059
+ c: c,
1060
+ cellWidth: widthForCell,
1061
+ cellHeight: curH
1062
+ }, ctx);
1063
+ var h = (_j = info === null || info === void 0 ? void 0 : info.textHeightAll) !== null && _j !== void 0 ? _j : 0;
1064
+ if (h + V_PAD > needH) needH = Math.ceil(h + V_PAD);
1065
+ }
1066
+ if (needH > curH) {
1067
+ rowlen[r] = needH;
1068
+ }
1069
+ }
1070
+ if (typeof window.jfrefreshgrid === "function") {
1071
+ window.jfrefreshgrid(ctx, null, [{
1072
+ row: [r1, r2],
1073
+ column: [c1, c2]
1074
+ }], true, undefined, "resize");
1075
+ }
1076
+ }
1013
1077
  export function handlePaste(ctx, e) {
1014
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
1078
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
1015
1079
  var allowEdit = isAllowEdit(ctx);
1080
+ console.log("handlePaste -> allowEdit", "jjjj");
1016
1081
  if (!allowEdit) return;
1017
1082
  if (selectionCache.isPasteAction) {
1018
1083
  ctx.luckysheetCellUpdate = [];
@@ -1096,7 +1161,6 @@ export function handlePaste(ctx, e) {
1096
1161
  }
1097
1162
  }
1098
1163
  }
1099
- var locale_fontjson_1 = locale(ctx).fontjson;
1100
1164
  if (((_o = (_m = ctx.hooks).beforePaste) === null || _o === void 0 ? void 0 : _o.call(_m, ctx.luckysheet_select_save, txtdata)) === false) {
1101
1165
  return;
1102
1166
  }
@@ -1108,256 +1172,35 @@ export function handlePaste(ctx, e) {
1108
1172
  } else {
1109
1173
  pasteHandlerOfCopyPaste(ctx, ctx.luckysheet_copy_save);
1110
1174
  }
1175
+ var last = (_q = ctx.luckysheet_select_save) === null || _q === void 0 ? void 0 : _q[ctx.luckysheet_select_save.length - 1];
1176
+ if (last) {
1177
+ autoFitUsingGetCellTextInfo(ctx, ctx.currentSheetId, last.row[0], last.row[1], last.column[0], last.column[1]);
1178
+ }
1111
1179
  } else if (txtdata.indexOf("fortune-copy-action-image") > -1) {} else {
1112
1180
  if (txtdata.indexOf("table") > -1) {
1113
- var ele = document.createElement("div");
1114
- ele.innerHTML = txtdata;
1115
- var trList = ele.querySelectorAll("table tr");
1116
- if (trList.length === 0) {
1117
- ele.remove();
1118
- return;
1119
- }
1120
- var data_1 = new Array(trList.length);
1121
- var colLen_1 = 0;
1122
- _.forEach(trList[0].querySelectorAll("td, th"), function (td) {
1123
- var colspan = td.colSpan;
1124
- if (Number.isNaN(colspan)) {
1125
- colspan = 1;
1126
- }
1127
- colLen_1 += colspan;
1128
- });
1129
- for (var i = 0; i < data_1.length; i += 1) {
1130
- data_1[i] = new Array(colLen_1);
1131
- }
1132
- var r_1 = 0;
1133
- var borderInfo_1 = {};
1134
- var styleInner = ((_q = ele.querySelectorAll("style")[0]) === null || _q === void 0 ? void 0 : _q.innerHTML) || "";
1135
- var patternReg = /{([^}]*)}/g;
1136
- var patternStyle = styleInner.match(patternReg);
1137
- var nameReg = /^[^\t].*/gm;
1138
- var patternName = _.initial(styleInner.match(nameReg));
1139
- var allStyleList_1 = patternName.length === (patternStyle === null || patternStyle === void 0 ? void 0 : patternStyle.length) && _typeof(patternName) === _typeof(patternStyle) ? _.fromPairs(_.zip(patternName, patternStyle)) : {};
1140
- var index_1 = getSheetIndex(ctx, ctx.currentSheetId);
1141
- if (!_.isNil(index_1)) {
1142
- if (_.isNil(ctx.luckysheetfile[index_1].config)) {
1143
- ctx.luckysheetfile[index_1].config = {};
1144
- }
1145
- if (_.isNil(ctx.luckysheetfile[index_1].config.rowlen)) {
1146
- ctx.luckysheetfile[index_1].config.rowlen = {};
1147
- }
1148
- var rowHeightList_1 = ctx.luckysheetfile[index_1].config.rowlen;
1149
- _.forEach(trList, function (tr) {
1150
- var c = 0;
1151
- var targetR = ctx.luckysheet_select_save[0].row[0] + r_1;
1152
- var targetRowHeight = !_.isNil(tr.getAttribute("height")) ? parseInt(tr.getAttribute("height"), 10) : null;
1153
- if (_.has(ctx.luckysheetfile[index_1].config.rowlen, targetR) && ctx.luckysheetfile[index_1].config.rowlen[targetR] !== targetRowHeight || !_.has(ctx.luckysheetfile[index_1].config.rowlen, targetR) && ctx.luckysheetfile[index_1].defaultRowHeight !== targetRowHeight) {
1154
- rowHeightList_1[targetR] = targetRowHeight;
1155
- }
1156
- _.forEach(tr.querySelectorAll("td, th"), function (element) {
1157
- var td = element;
1158
- var className = td.className;
1159
- var cell = {};
1160
- var txt = td.innerText || td.innerHTML;
1161
- if (_.trim(txt).length === 0) {
1162
- cell.v = undefined;
1163
- cell.m = "";
1164
- } else {
1165
- var mask = genarate(txt);
1166
- cell.m = mask[0], cell.ct = mask[1], cell.v = mask[2];
1167
- if (/^0x?[a-fA-F0-9]+$/.test(txt)) {
1168
- cell.ct = {
1169
- fa: "@",
1170
- t: "s"
1171
- };
1172
- cell.m = txt;
1173
- cell.v = txt;
1174
- }
1175
- }
1176
- var styleString = typeof allStyleList_1[".".concat(className)] === "string" ? allStyleList_1[".".concat(className)].substring(1, allStyleList_1[".".concat(className)].length - 1).split("\n\t") : [];
1177
- var styles = {};
1178
- _.forEach(styleString, function (s) {
1179
- var styleList = s.split(":");
1180
- styles[styleList[0]] = styleList === null || styleList === void 0 ? void 0 : styleList[1].replace(";", "");
1181
- });
1182
- if (!_.isNil(styles.border)) td.style.border = styles.border;
1183
- var bg = td.style.backgroundColor || styles.background;
1184
- if (bg === "rgba(0, 0, 0, 0)" || _.isEmpty(bg)) {
1185
- bg = undefined;
1186
- }
1187
- cell.bg = bg;
1188
- var fontWight = td.style.fontWeight;
1189
- cell.bl = (fontWight.toString() === "400" || fontWight === "normal" || _.isEmpty(fontWight)) && !_.includes(styles["font-style"], "bold") && (!styles["font-weight"] || styles["font-weight"] === "400") ? 0 : 1;
1190
- cell.it = (td.style.fontStyle === "normal" || _.isEmpty(td.style.fontStyle)) && !_.includes(styles["font-style"], "italic") ? 0 : 1;
1191
- cell.un = !_.includes(styles["text-decoration"], "underline") ? undefined : 1;
1192
- cell.cl = !_.includes(td.innerHTML, "<s>") ? undefined : 1;
1193
- var ff = td.style.fontFamily || styles["font-family"] || "";
1194
- var ffs = ff.split(",");
1195
- for (var i = 0; i < ffs.length; i += 1) {
1196
- var fa = _.trim(ffs[i].toLowerCase());
1197
- fa = locale_fontjson_1[fa];
1198
- if (_.isNil(fa)) {
1199
- cell.ff = 0;
1200
- } else {
1201
- cell.ff = fa;
1202
- break;
1203
- }
1204
- }
1205
- var fs = Math.round(styles["font-size"] ? parseInt(styles["font-size"].replace("pt", ""), 10) : parseInt(td.style.fontSize || "13", 10) * 72 / 96);
1206
- cell.fs = fs;
1207
- cell.fc = td.style.color || styles.color;
1208
- var ht = td.style.textAlign || styles["text-align"] || "left";
1209
- if (ht === "center") {
1210
- cell.ht = 0;
1211
- } else if (ht === "right") {
1212
- cell.ht = 2;
1213
- } else {
1214
- cell.ht = 1;
1215
- }
1216
- var regex = /vertical-align:\s*(.*?);/;
1217
- var vt = td.style.verticalAlign || styles["vertical-align"] || !_.isNil(allStyleList_1.td) && allStyleList_1.td.match(regex).length > 0 && allStyleList_1.td.match(regex)[1] || "top";
1218
- if (vt === "middle") {
1219
- cell.vt = 0;
1220
- } else if (vt === "top" || vt === "text-top") {
1221
- cell.vt = 1;
1222
- } else {
1223
- cell.vt = 2;
1224
- }
1225
- if ("mso-rotate" in styles) {
1226
- var rt = styles["mso-rotate"];
1227
- cell.rt = parseFloat(rt);
1228
- }
1229
- while (c < colLen_1 && !_.isNil(data_1[r_1][c])) {
1230
- c += 1;
1231
- }
1232
- if (c === colLen_1) {
1233
- return true;
1234
- }
1235
- if (_.isNil(data_1[r_1][c])) {
1236
- data_1[r_1][c] = cell;
1237
- var rowspan = parseInt(td.getAttribute("rowspan"), 10);
1238
- var colspan = parseInt(td.getAttribute("colspan"), 10);
1239
- if (Number.isNaN(rowspan)) {
1240
- rowspan = 1;
1241
- }
1242
- if (Number.isNaN(colspan)) {
1243
- colspan = 1;
1244
- }
1245
- var r_ab = ctx.luckysheet_select_save[0].row[0] + r_1;
1246
- var c_ab = ctx.luckysheet_select_save[0].column[0] + c;
1247
- for (var rp = 0; rp < rowspan; rp += 1) {
1248
- for (var cp = 0; cp < colspan; cp += 1) {
1249
- if (rp === 0) {
1250
- var bt = td.style.borderTop;
1251
- if (!_.isEmpty(bt) && bt.substring(0, 3).toLowerCase() !== "0px") {
1252
- var width = td.style.borderTopWidth;
1253
- var type = td.style.borderTopStyle;
1254
- var color = td.style.borderTopColor;
1255
- var borderconfig = getQKBorder(width, type, color);
1256
- if (!borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)]) {
1257
- borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)] = {};
1258
- }
1259
- borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)].t = {
1260
- style: borderconfig[0],
1261
- color: borderconfig[1]
1262
- };
1263
- }
1264
- }
1265
- if (rp === rowspan - 1) {
1266
- var bb = td.style.borderBottom;
1267
- if (!_.isEmpty(bb) && bb.substring(0, 3).toLowerCase() !== "0px") {
1268
- var width = td.style.borderBottomWidth;
1269
- var type = td.style.borderBottomStyle;
1270
- var color = td.style.borderBottomColor;
1271
- var borderconfig = getQKBorder(width, type, color);
1272
- if (!borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)]) {
1273
- borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)] = {};
1274
- }
1275
- borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)].b = {
1276
- style: borderconfig[0],
1277
- color: borderconfig[1]
1278
- };
1279
- }
1280
- }
1281
- if (cp === 0) {
1282
- var bl = td.style.borderLeft;
1283
- if (!_.isEmpty(bl) && bl.substring(0, 3).toLowerCase() !== "0px") {
1284
- var width = td.style.borderLeftWidth;
1285
- var type = td.style.borderLeftStyle;
1286
- var color = td.style.borderLeftColor;
1287
- var borderconfig = getQKBorder(width, type, color);
1288
- if (!borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)]) {
1289
- borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)] = {};
1290
- }
1291
- borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)].l = {
1292
- style: borderconfig[0],
1293
- color: borderconfig[1]
1294
- };
1295
- }
1296
- }
1297
- if (cp === colspan - 1) {
1298
- var br = td.style.borderLeft;
1299
- if (!_.isEmpty(br) && br.substring(0, 3).toLowerCase() !== "0px") {
1300
- var width = td.style.borderRightWidth;
1301
- var type = td.style.borderRightStyle;
1302
- var color = td.style.borderRightColor;
1303
- var borderconfig = getQKBorder(width, type, color);
1304
- if (!borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)]) {
1305
- borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)] = {};
1306
- }
1307
- borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)].r = {
1308
- style: borderconfig[0],
1309
- color: borderconfig[1]
1310
- };
1311
- }
1312
- }
1313
- if (rp === 0 && cp === 0) {
1314
- continue;
1315
- }
1316
- data_1[r_1 + rp][c + cp] = {
1317
- mc: {
1318
- r: r_ab,
1319
- c: c_ab
1320
- }
1321
- };
1322
- }
1323
- }
1324
- if (rowspan > 1 || colspan > 1) {
1325
- var first = {
1326
- rs: rowspan,
1327
- cs: colspan,
1328
- r: r_ab,
1329
- c: c_ab
1330
- };
1331
- data_1[r_1][c].mc = first;
1332
- }
1333
- }
1334
- c += 1;
1335
- if (c === colLen_1) {
1336
- return true;
1337
- }
1338
- return true;
1339
- });
1340
- r_1 += 1;
1341
- });
1342
- setRowHeight(ctx, rowHeightList_1);
1343
- }
1344
- ctx.luckysheet_selection_range = [];
1345
- pasteHandler(ctx, data_1, borderInfo_1);
1346
- ele.remove();
1181
+ pasteHtmlTableAndAutoFit(ctx, txtdata, pasteHandler);
1347
1182
  } else if (clipboardData.files.length === 1 && clipboardData.files[0].type.indexOf("image") > -1) {} else {
1348
1183
  txtdata = clipboardData.getData("text/plain");
1349
1184
  var isExcelFormula = txtdata.startsWith("=");
1350
1185
  if (isExcelFormula) {
1351
1186
  handleFormulaStringPaste(ctx, txtdata);
1187
+ var last = (_r = ctx.luckysheet_select_save) === null || _r === void 0 ? void 0 : _r[ctx.luckysheet_select_save.length - 1];
1188
+ if (last) {
1189
+ autoFitUsingGetCellTextInfo(ctx, ctx.currentSheetId, last.row[0], last.row[1], last.column[0], last.column[1]);
1190
+ }
1352
1191
  } else {
1353
1192
  pasteHandler(ctx, txtdata);
1193
+ var last = (_s = ctx.luckysheet_select_save) === null || _s === void 0 ? void 0 : _s[ctx.luckysheet_select_save.length - 1];
1194
+ if (last) {
1195
+ autoFitUsingGetCellTextInfo(ctx, ctx.currentSheetId, last.row[0], last.row[1], last.column[0], last.column[1]);
1196
+ }
1354
1197
  var _txtdata = clipboardData.getData("text/html") || clipboardData.getData("text/plain");
1355
1198
  var embedUrl = sanitizeDuneUrl(_txtdata);
1356
1199
  if (embedUrl) {
1357
- var last = (_r = ctx.luckysheet_select_save) === null || _r === void 0 ? void 0 : _r[ctx.luckysheet_select_save.length - 1];
1358
- if (last) {
1359
- var rowIndex = (_u = (_s = last.row_focus) !== null && _s !== void 0 ? _s : (_t = last.row) === null || _t === void 0 ? void 0 : _t[0]) !== null && _u !== void 0 ? _u : 0;
1360
- var colIndex = (_x = (_v = last.column_focus) !== null && _v !== void 0 ? _v : (_w = last.column) === null || _w === void 0 ? void 0 : _w[0]) !== null && _x !== void 0 ? _x : 0;
1200
+ var _last = (_t = ctx.luckysheet_select_save) === null || _t === void 0 ? void 0 : _t[ctx.luckysheet_select_save.length - 1];
1201
+ if (_last) {
1202
+ var rowIndex = (_w = (_u = _last.row_focus) !== null && _u !== void 0 ? _u : (_v = _last.row) === null || _v === void 0 ? void 0 : _v[0]) !== null && _w !== void 0 ? _w : 0;
1203
+ var colIndex = (_z = (_x = _last.column_focus) !== null && _x !== void 0 ? _x : (_y = _last.column) === null || _y === void 0 ? void 0 : _y[0]) !== null && _z !== void 0 ? _z : 0;
1361
1204
  var left = colIndex === 0 ? 0 : ctx.visibledatacolumn[colIndex - 1];
1362
1205
  var top_1 = rowIndex === 0 ? 0 : ctx.visibledatarow[rowIndex + 5];
1363
1206
  ctx.showDunePreview = {
@@ -28,6 +28,7 @@ import { locale } from "../locale";
28
28
  import { colors } from "./color";
29
29
  import { colLocation, mousePosition, rowLocation } from "./location";
30
30
  import { cancelFunctionrangeSelected, seletedHighlistByindex, spillSortResult } from ".";
31
+ import { isLetterNumberPattern, removeLastSpan } from "../utils/index";
31
32
  var functionHTMLIndex = 0;
32
33
  var rangeIndexes = [];
33
34
  var operatorPriority = {
@@ -1246,7 +1247,9 @@ export function setCaretPosition(ctx, textDom, children, pos) {
1246
1247
  el.focus();
1247
1248
  } catch (err) {
1248
1249
  console.error(err);
1249
- moveCursorToEnd(textDom);
1250
+ setTimeout(function () {
1251
+ moveCursorToEnd(textDom);
1252
+ }, 10);
1250
1253
  }
1251
1254
  }
1252
1255
  function functionRange(ctx, obj, v, vp) {
@@ -1948,6 +1951,14 @@ export function functionStrChange(txt, type, rc, orient, stindex, step) {
1948
1951
  }
1949
1952
  export function rangeSetValue(ctx, cellInput, selected, fxInput) {
1950
1953
  var _a, _b, _c, _d, _e;
1954
+ var parser = new DOMParser();
1955
+ var doc = parser.parseFromString("<div>".concat(cellInput.innerHTML, "</div>"), "text/html");
1956
+ var spans = doc.querySelectorAll("span");
1957
+ var lastSpan = spans[spans.length - 1];
1958
+ if (lastSpan && isLetterNumberPattern(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
1959
+ var htmlR = removeLastSpan(cellInput.innerHTML);
1960
+ cellInput.innerHTML = "".concat(htmlR);
1961
+ }
1951
1962
  var $editor = cellInput;
1952
1963
  var $copyTo = fxInput;
1953
1964
  if (((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.id) === "luckysheet-functionbox-cell") {
@@ -0,0 +1,2 @@
1
+ import { Context } from "./context";
2
+ export declare function pasteHtmlTableAndAutoFit(ctx: Context, html: string, pasteHandler: (context: Context, data: any, borderInfo?: any) => void): void;