@fileverse-dev/fortune-core 1.3.11-mixed → 1.3.12-copyPaste-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -169,72 +169,63 @@ function moveToEdge(sheetData, key, curr, rowDelta, colDelta, startR, endR, star
169
169
  return colDelta === 0 ? r : c;
170
170
  }
171
171
  function handleControlPlusArrowKey(ctx, e, shiftPressed) {
172
- var _a, _b, _c, _d;
172
+ if (ctx.luckysheetCellUpdate.length > 0) return;
173
173
  var idx = getSheetIndex(ctx, ctx.currentSheetId);
174
174
  if (_.isNil(idx)) return;
175
175
  var file = ctx.luckysheetfile[idx];
176
+ if (!file || !file.row || !file.column) return;
176
177
  var maxRow = file.row;
177
178
  var maxCol = file.column;
178
- if (_.isNil(maxRow) || _.isNil(maxCol)) return;
179
- var last = ctx.luckysheet_select_save && ctx.luckysheet_select_save.length > 0 ? ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1] : undefined;
179
+ var last;
180
+ if (ctx.luckysheet_select_save && ctx.luckysheet_select_save.length > 0) last = ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1];
180
181
  if (!last) return;
181
182
  var currR = last.row_focus;
182
183
  var currC = last.column_focus;
183
184
  if (_.isNil(currR) || _.isNil(currC)) return;
184
- var startR = (_a = last.row) === null || _a === void 0 ? void 0 : _a[0];
185
- var endR = (_b = last.row) === null || _b === void 0 ? void 0 : _b[1];
186
- var startC = (_c = last.column) === null || _c === void 0 ? void 0 : _c[0];
187
- var endC = (_d = last.column) === null || _d === void 0 ? void 0 : _d[1];
188
- if (_.isNil(startR) || _.isNil(endR) || _.isNil(startC) || _.isNil(endC)) {
189
- return;
190
- }
185
+ var startR = last.row[0];
186
+ var endR = last.row[1];
187
+ var startC = last.column[0];
188
+ var endC = last.column[1];
191
189
  var horizontalOffset = currC - endC !== 0 ? currC - endC : currC - startC;
192
190
  var verticalOffset = currR - endR !== 0 ? currR - endR : currR - startR;
193
191
  var sheetData = file.data;
194
192
  if (!sheetData) return;
193
+ var selectedLimit;
195
194
  switch (e.key) {
196
195
  case "ArrowUp":
197
- {
198
- var selectedLimit = moveToEdge(sheetData, e.key, currC, -1, 0, startR, endR, startC, endC, maxRow, maxCol);
199
- if (shiftPressed) {
200
- moveHighlightRange(ctx, "down", verticalOffset, "rangeOfSelect");
201
- moveHighlightRange(ctx, "down", selectedLimit - currR, "rangeOfSelect");
202
- } else {
203
- moveHighlightCell(ctx, "down", selectedLimit - currR, "rangeOfSelect");
204
- }
196
+ selectedLimit = moveToEdge(sheetData, e.key, currC, -1, 0, startR, endR, startC, endC, maxRow, maxCol);
197
+ if (shiftPressed) {
198
+ moveHighlightRange(ctx, "down", verticalOffset, "rangeOfSelect");
199
+ moveHighlightRange(ctx, "down", selectedLimit - currR, "rangeOfSelect");
200
+ } else {
201
+ moveHighlightCell(ctx, "down", selectedLimit - currR, "rangeOfSelect");
205
202
  }
206
203
  break;
207
204
  case "ArrowDown":
208
- {
209
- var selectedLimit = moveToEdge(sheetData, e.key, currC, 1, 0, startR, endR, startC, endC, maxRow, maxCol);
210
- if (shiftPressed) {
211
- moveHighlightRange(ctx, "down", verticalOffset, "rangeOfSelect");
212
- moveHighlightRange(ctx, "down", selectedLimit - currR, "rangeOfSelect");
213
- } else {
214
- moveHighlightCell(ctx, "down", selectedLimit - currR, "rangeOfSelect");
215
- }
205
+ selectedLimit = moveToEdge(sheetData, e.key, currC, 1, 0, startR, endR, startC, endC, maxRow, maxCol);
206
+ if (shiftPressed) {
207
+ moveHighlightRange(ctx, "down", verticalOffset, "rangeOfSelect");
208
+ moveHighlightRange(ctx, "down", selectedLimit - currR, "rangeOfSelect");
209
+ } else {
210
+ moveHighlightCell(ctx, "down", selectedLimit - currR, "rangeOfSelect");
216
211
  }
217
212
  break;
218
213
  case "ArrowLeft":
219
- {
220
- var selectedLimit = moveToEdge(sheetData, e.key, currR, 0, -1, startR, endR, startC, endC, maxRow, maxCol);
221
- if (shiftPressed) {
222
- moveHighlightRange(ctx, "right", horizontalOffset, "rangeOfSelect");
223
- moveHighlightRange(ctx, "right", selectedLimit - currC, "rangeOfSelect");
224
- } else {
225
- moveHighlightCell(ctx, "right", selectedLimit - currC, "rangeOfSelect");
226
- }
214
+ selectedLimit = moveToEdge(sheetData, e.key, currR, 0, -1, startR, endR, startC, endC, maxRow, maxCol);
215
+ if (shiftPressed) {
216
+ moveHighlightRange(ctx, "right", horizontalOffset, "rangeOfSelect");
217
+ moveHighlightRange(ctx, "right", selectedLimit - currC, "rangeOfSelect");
218
+ } else {
219
+ moveHighlightCell(ctx, "right", selectedLimit - currC, "rangeOfSelect");
227
220
  }
228
221
  break;
229
222
  case "ArrowRight":
230
- {
231
- var selectedLimit = moveToEdge(sheetData, e.key, currR, 0, 1, startR, endR, startC, endC, maxRow, maxCol);
232
- if (shiftPressed) {
233
- moveHighlightRange(ctx, "right", horizontalOffset, "rangeOfSelect");
234
- moveHighlightRange(ctx, "right", selectedLimit - currC, "rangeOfSelect");
235
- } else {
236
- moveHighlightCell(ctx, "right", selectedLimit - currC, "rangeOfSelect");
237
- }
223
+ selectedLimit = moveToEdge(sheetData, e.key, currR, 0, 1, startR, endR, startC, endC, maxRow, maxCol);
224
+ if (shiftPressed) {
225
+ moveHighlightRange(ctx, "right", horizontalOffset, "rangeOfSelect");
226
+ moveHighlightRange(ctx, "right", selectedLimit - currC, "rangeOfSelect");
227
+ } else {
228
+ moveHighlightCell(ctx, "right", selectedLimit - currC, "rangeOfSelect");
238
229
  }
239
230
  break;
240
231
  default:
@@ -387,10 +378,10 @@ export function handleArrowKey(ctx, e) {
387
378
  }
388
379
  }
389
380
  export function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, handleRedo, canvas) {
390
- var _a, _b, _c, _d;
381
+ var _a, _b, _c;
391
382
  return __awaiter(this, void 0, void 0, function () {
392
- var handledFlvShortcut, kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, isEditing, inputText, isFormulaEdit, enteredByTyping, last, row_index, col_index;
393
- return __generator(this, function (_e) {
383
+ var handledFlvShortcut, kcode, kstr, allowEdit, isFxInput, ignoredKeys, restCod, last, row_index, col_index, last, row_index, col_index;
384
+ return __generator(this, function (_d) {
394
385
  if (e.shiftKey && e.code === "Space") {
395
386
  e.stopImmediatePropagation();
396
387
  e.stopPropagation();
@@ -498,18 +489,7 @@ export function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUnd
498
489
  jfrefreshgrid(ctx, null, undefined);
499
490
  e.preventDefault();
500
491
  } else if (kstr === "ArrowUp" || kstr === "ArrowDown" || kstr === "ArrowLeft" || kstr === "ArrowRight") {
501
- isEditing = ctx.luckysheetCellUpdate.length > 0;
502
- inputText = (_d = cellInput === null || cellInput === void 0 ? void 0 : cellInput.innerText) !== null && _d !== void 0 ? _d : "";
503
- isFormulaEdit = isEditing && inputText.trim().startsWith("=");
504
- enteredByTyping = cache.enteredEditByTyping === true;
505
- if (isEditing && !isFormulaEdit && enteredByTyping) {
506
- updateCell(ctx, ctx.luckysheetCellUpdate[0], ctx.luckysheetCellUpdate[1], cellInput, undefined, canvas);
507
- cache.enteredEditByTyping = false;
508
- handleArrowKey(ctx, e);
509
- e.preventDefault();
510
- } else {
511
- handleArrowKey(ctx, e);
512
- }
492
+ handleArrowKey(ctx, e);
513
493
  } else if (!(kcode >= 112 && kcode <= 123 || kcode <= 46 || kcode === 144 || kcode === 108 || e.ctrlKey || e.altKey || e.shiftKey && (kcode === 37 || kcode === 38 || kcode === 39 || kcode === 40)) || kcode === 8 || kcode === 32 || kcode === 46 || kcode === 0 || e.ctrlKey && kcode === 86) {
514
494
  if (!allowEdit) return [2];
515
495
  if (String.fromCharCode(kcode) != null && !_.isEmpty(ctx.luckysheet_select_save) && kstr !== "CapsLock" && kstr !== "Win" && kcode !== 18) {
@@ -518,10 +498,7 @@ export function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUnd
518
498
  col_index = last.column_focus;
519
499
  ctx.luckysheetCellUpdate = [row_index, col_index];
520
500
  cache.overwriteCell = true;
521
- cache.overwriteCellFirstChar = e.key;
522
- cache.enteredEditByTyping = true;
523
501
  handleFormulaInput(ctx, fxInput, cellInput, kcode);
524
- e.preventDefault();
525
502
  }
526
503
  }
527
504
  }
@@ -487,7 +487,6 @@ export function handleCellAreaDoubleClick(ctx, globalCache, settings, e, contain
487
487
  row_index = row_focus;
488
488
  col_index = column_focus;
489
489
  }
490
- globalCache.enteredEditByTyping = false;
491
490
  luckysheetUpdateCell(ctx, row_index, col_index);
492
491
  }
493
492
  export function handleContextMenu(ctx, settings, e, workbookContainer, container, area) {
package/es/locale/en.d.ts CHANGED
@@ -530,8 +530,6 @@ declare const _default: {
530
530
  conditionformat_equal_title: string;
531
531
  conditionformat_textContains: string;
532
532
  conditionformat_textContains_title: string;
533
- conditionformat_empty: string;
534
- conditionformat_empty_title: string;
535
533
  conditionformat_occurrenceDate: string;
536
534
  conditionformat_occurrenceDate_title: string;
537
535
  conditionformat_duplicateValue: string;
@@ -635,7 +633,6 @@ declare const _default: {
635
633
  between2: string;
636
634
  contain: string;
637
635
  textContains: string;
638
- empty: string;
639
636
  duplicateValue: string;
640
637
  uniqueValue: string;
641
638
  top: string;
package/es/locale/en.js CHANGED
@@ -9628,8 +9628,6 @@ export default {
9628
9628
  conditionformat_equal_title: "Format cells equal to",
9629
9629
  conditionformat_textContains: "Conditional format - Text Contains",
9630
9630
  conditionformat_textContains_title: "Format cells containing the following text",
9631
- conditionformat_empty: "Conditional format - Empty",
9632
- conditionformat_empty_title: "Format cells that are empty",
9633
9631
  conditionformat_occurrenceDate: "Conditional format - Occurrence Date",
9634
9632
  conditionformat_occurrenceDate_title: "Format cells containing the following dates",
9635
9633
  conditionformat_duplicateValue: "Conditional format - Duplicate Value",
@@ -9733,7 +9731,6 @@ export default {
9733
9731
  between2: "",
9734
9732
  contain: "Contain",
9735
9733
  textContains: "Text contains",
9736
- empty: "Empty",
9737
9734
  duplicateValue: "Duplicate value",
9738
9735
  uniqueValue: "Unique value",
9739
9736
  top: "Top",
package/es/locale/es.d.ts CHANGED
@@ -688,8 +688,6 @@ declare const _default: {
688
688
  conditionformat_equal_title: string;
689
689
  conditionformat_textContains: string;
690
690
  conditionformat_textContains_title: string;
691
- conditionformat_empty: string;
692
- conditionformat_empty_title: string;
693
691
  conditionformat_occurrenceDate: string;
694
692
  conditionformat_occurrenceDate_title: string;
695
693
  conditionformat_duplicateValue: string;
@@ -791,7 +789,6 @@ declare const _default: {
791
789
  between2: string;
792
790
  contain: string;
793
791
  textContains: string;
794
- empty: string;
795
792
  duplicateValue: string;
796
793
  uniqueValue: string;
797
794
  top: string;
package/es/locale/es.js CHANGED
@@ -9565,8 +9565,6 @@ export default {
9565
9565
  conditionformat_equal_title: "Dar formato a celdas iguales a",
9566
9566
  conditionformat_textContains: "Conditionformat-TextContains",
9567
9567
  conditionformat_textContains_title: "Dar formato a las celdas que contienen el siguiente texto",
9568
- conditionformat_empty: "Conditional format - Empty",
9569
- conditionformat_empty_title: "Dar formato a las celdas vacías",
9570
9568
  conditionformat_occurrenceDate: "Conditionformat-OccurrenceDate",
9571
9569
  conditionformat_occurrenceDate_title: "Dar formato a celdas que contienen las siguientes fechas",
9572
9570
  conditionformat_duplicateValue: "Conditionformat-DuplicateValue",
@@ -9668,7 +9666,6 @@ export default {
9668
9666
  between2: "",
9669
9667
  contain: "Contiene",
9670
9668
  textContains: "Texto contiene",
9671
- empty: "Vacío",
9672
9669
  duplicateValue: "Valor duplicado",
9673
9670
  uniqueValue: "Valor Unico",
9674
9671
  top: "Mejor",
package/es/locale/hi.d.ts CHANGED
@@ -563,8 +563,6 @@ declare const _default: {
563
563
  conditionformat_equal_title: string;
564
564
  conditionformat_textContains: string;
565
565
  conditionformat_textContains_title: string;
566
- conditionformat_empty: string;
567
- conditionformat_empty_title: string;
568
566
  conditionformat_occurrenceDate: string;
569
567
  conditionformat_occurrenceDate_title: string;
570
568
  conditionformat_duplicateValue: string;
@@ -666,7 +664,6 @@ declare const _default: {
666
664
  between2: string;
667
665
  contain: string;
668
666
  textContains: string;
669
- empty: string;
670
667
  duplicateValue: string;
671
668
  uniqueValue: string;
672
669
  top: string;
package/es/locale/hi.js CHANGED
@@ -10078,8 +10078,6 @@ export default {
10078
10078
  conditionformat_equal_title: "के बराबर कोशिकाओं को प्रारूपित करें",
10079
10079
  conditionformat_textContains: "Conditionformat-TextContains",
10080
10080
  conditionformat_textContains_title: "निम्नलिखित पाठ वाली कोशिकाओं को प्रारूपित करें",
10081
- conditionformat_empty: "Conditional format - Empty",
10082
- conditionformat_empty_title: "खाली कोशिकाओं को प्रारूपित करें",
10083
10081
  conditionformat_occurrenceDate: "Conditionformat-OccurrenceDate",
10084
10082
  conditionformat_occurrenceDate_title: "निम्नलिखित तिथियों वाली कोशिकाओं को प्रारूपित करें",
10085
10083
  conditionformat_duplicateValue: "Conditionformat-DuplicateValue",
@@ -10181,7 +10179,6 @@ export default {
10181
10179
  between2: "",
10182
10180
  contain: "शामिल",
10183
10181
  textContains: "पाठ शामिल है",
10184
- empty: "खाली",
10185
10182
  duplicateValue: "डुप्लिकेट मान",
10186
10183
  uniqueValue: "अद्वितीय मान",
10187
10184
  top: "शीर्ष",
@@ -583,8 +583,6 @@ declare function locale(ctx: Context): {
583
583
  conditionformat_equal_title: string;
584
584
  conditionformat_textContains: string;
585
585
  conditionformat_textContains_title: string;
586
- conditionformat_empty: string;
587
- conditionformat_empty_title: string;
588
586
  conditionformat_occurrenceDate: string;
589
587
  conditionformat_occurrenceDate_title: string;
590
588
  conditionformat_duplicateValue: string;
@@ -687,7 +685,6 @@ declare function locale(ctx: Context): {
687
685
  between2: string;
688
686
  contain: string;
689
687
  textContains: string;
690
- empty: string;
691
688
  duplicateValue: string;
692
689
  uniqueValue: string;
693
690
  top: string;
package/es/locale/zh.d.ts CHANGED
@@ -582,8 +582,6 @@ declare const _default: {
582
582
  conditionformat_equal_title: string;
583
583
  conditionformat_textContains: string;
584
584
  conditionformat_textContains_title: string;
585
- conditionformat_empty: string;
586
- conditionformat_empty_title: string;
587
585
  conditionformat_occurrenceDate: string;
588
586
  conditionformat_occurrenceDate_title: string;
589
587
  conditionformat_duplicateValue: string;
@@ -686,7 +684,6 @@ declare const _default: {
686
684
  between2: string;
687
685
  contain: string;
688
686
  textContains: string;
689
- empty: string;
690
687
  duplicateValue: string;
691
688
  uniqueValue: string;
692
689
  top: string;
package/es/locale/zh.js CHANGED
@@ -10097,8 +10097,6 @@ export default {
10097
10097
  conditionformat_equal_title: "为等于以下值的单元格设置格式",
10098
10098
  conditionformat_textContains: "条件格式——文本包含",
10099
10099
  conditionformat_textContains_title: "为包含以下文本的单元格设置格式",
10100
- conditionformat_empty: "条件格式——空值",
10101
- conditionformat_empty_title: "为空单元格设置格式",
10102
10100
  conditionformat_occurrenceDate: "条件格式——发生日期",
10103
10101
  conditionformat_occurrenceDate_title: "为包含以下日期的单元格设置格式",
10104
10102
  conditionformat_duplicateValue: "条件格式——重复值",
@@ -10201,7 +10199,6 @@ export default {
10201
10199
  between2: "之间",
10202
10200
  contain: "包含",
10203
10201
  textContains: "文本包含",
10204
- empty: "空值",
10205
10202
  duplicateValue: "重复值",
10206
10203
  uniqueValue: "唯一值",
10207
10204
  top: "前",
@@ -726,8 +726,6 @@ declare const _default: {
726
726
  conditionformat_equal_title: string;
727
727
  conditionformat_textContains: string;
728
728
  conditionformat_textContains_title: string;
729
- conditionformat_empty: string;
730
- conditionformat_empty_title: string;
731
729
  conditionformat_occurrenceDate: string;
732
730
  conditionformat_occurrenceDate_title: string;
733
731
  conditionformat_duplicateValue: string;
@@ -830,7 +828,6 @@ declare const _default: {
830
828
  between2: string;
831
829
  contain: string;
832
830
  textContains: string;
833
- empty: string;
834
831
  duplicateValue: string;
835
832
  uniqueValue: string;
836
833
  top: string;
@@ -9612,8 +9612,6 @@ export default {
9612
9612
  conditionformat_equal_title: "為等於以下值的儲存格設定格式",
9613
9613
  conditionformat_textContains: "條件格式——文字包含",
9614
9614
  conditionformat_textContains_title: "為包含以下文字的儲存格設定格式",
9615
- conditionformat_empty: "條件格式——空值",
9616
- conditionformat_empty_title: "為空儲存格設定格式",
9617
9615
  conditionformat_occurrenceDate: "條件格式——發生日期",
9618
9616
  conditionformat_occurrenceDate_title: "為包含以下日期的儲存格設定格式",
9619
9617
  conditionformat_duplicateValue: "條件格式——重複值",
@@ -9716,7 +9714,6 @@ export default {
9716
9714
  between2: "之間",
9717
9715
  contain: "包含",
9718
9716
  textContains: "文字包含",
9719
- empty: "空值",
9720
9717
  duplicateValue: "重複值",
9721
9718
  uniqueValue: "唯一值",
9722
9719
  top: "前",
@@ -691,32 +691,6 @@ export function compute(ctx, ruleArr, d) {
691
691
  }
692
692
  }
693
693
  }
694
- } else if (conditionName === "empty") {
695
- for (var r = cellrange[s].row[0]; r <= cellrange[s].row[1]; r += 1) {
696
- for (var c = cellrange[s].column[0]; c <= cellrange[s].column[1]; c += 1) {
697
- var cell = _.isNil(d[r]) || _.isNil(d[r][c]) ? null : d[r][c];
698
- var isEmpty = _.isNil(cell) || _.isNil(cell.v) || isRealNull(cell.v);
699
- if (isEmpty) {
700
- if ("".concat(r, "_").concat(c) in computeMap) {
701
- computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
702
- computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
703
- computeMap["".concat(r, "_").concat(c)].bold = bold_1;
704
- computeMap["".concat(r, "_").concat(c)].italic = italic_1;
705
- computeMap["".concat(r, "_").concat(c)].underline = underline_1;
706
- computeMap["".concat(r, "_").concat(c)].strikethrough = strikethrough_1;
707
- } else {
708
- computeMap["".concat(r, "_").concat(c)] = {
709
- textColor: textColor_1,
710
- cellColor: cellColor_1,
711
- bold: bold_1,
712
- italic: italic_1,
713
- underline: underline_1,
714
- strikethrough: strikethrough_1
715
- };
716
- }
717
- }
718
- }
719
- }
720
694
  } else if (conditionName === "between") {
721
695
  for (var r = cellrange[s].row[0]; r <= cellrange[s].row[1]; r += 1) {
722
696
  for (var c = cellrange[s].column[0]; c <= cellrange[s].column[1]; c += 1) {
@@ -1041,7 +1041,7 @@ export function getFontStyleByCell(cell, checksAF, checksCF, isCheck) {
1041
1041
  if (key === "it" && valueNum !== 0) {
1042
1042
  style.fontStyle = "italic";
1043
1043
  }
1044
- if (key === "fs" && valueNum !== 10) {
1044
+ if (key === "fs" && !_.isNil(value)) {
1045
1045
  style.fontSize = "".concat(valueNum, "pt");
1046
1046
  }
1047
1047
  if (key === "fc" && value !== "#000000" || ((_a = checksAF === null || checksAF === void 0 ? void 0 : checksAF.length) !== null && _a !== void 0 ? _a : 0) > 0 || (checksCF === null || checksCF === void 0 ? void 0 : checksCF.textColor)) {
@@ -291,6 +291,9 @@ function extendCssText(origin, cover, isLimit) {
291
291
  }
292
292
  return newCss;
293
293
  }
294
+ function escapeHtmlAttr(s) {
295
+ return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
296
+ }
294
297
  export function updateInlineStringFormat(ctx, attr, value, cellInput) {
295
298
  var _a, _b, _c;
296
299
  var w = window.getSelection();
@@ -298,6 +301,34 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
298
301
  if (w.rangeCount === 0) return;
299
302
  var range = w.getRangeAt(0);
300
303
  var $textEditor = cellInput;
304
+ if (range.startContainer === $textEditor && range.endContainer === $textEditor && range.collapsed === false) {
305
+ var start = range.startOffset;
306
+ var end = range.endOffset;
307
+ var children = Array.from($textEditor.childNodes).slice(start, end);
308
+ children.forEach(function (node) {
309
+ var _a, _b;
310
+ if (node.nodeType === Node.ELEMENT_NODE) {
311
+ var el = node;
312
+ if (el.tagName === "SPAN") {
313
+ var cssText = getCssText(el.style.cssText, attr, value);
314
+ el.setAttribute("style", cssText);
315
+ }
316
+ } else if (node.nodeType === Node.TEXT_NODE) {
317
+ var text = (_a = node.textContent) !== null && _a !== void 0 ? _a : "";
318
+ if (text.length === 0) return;
319
+ var wrapper = document.createElement("span");
320
+ var cssText = getCssText("", attr, value);
321
+ wrapper.setAttribute("style", cssText);
322
+ wrapper.textContent = text;
323
+ (_b = node.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(wrapper, node);
324
+ }
325
+ });
326
+ var newRange = document.createRange();
327
+ newRange.selectNodeContents($textEditor);
328
+ w.removeAllRanges();
329
+ w.addRange(newRange);
330
+ return;
331
+ }
301
332
  if (range.collapsed === true) {
302
333
  return;
303
334
  }
@@ -335,7 +366,7 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
335
366
  cssText = extendCssText(box.style.cssText, cssText);
336
367
  }
337
368
  }
338
- cont += "<span style='".concat(cssText, "'>").concat(left, "</span>");
369
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(left, "</span>");
339
370
  }
340
371
  if (mid !== "") {
341
372
  var cssText = getCssText(span.style.cssText, attr, value);
@@ -345,7 +376,7 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
345
376
  cssText = extendCssText(box.style.cssText, cssText);
346
377
  }
347
378
  }
348
- cont += "<span style='".concat(cssText, "'>").concat(mid, "</span>");
379
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(mid, "</span>");
349
380
  }
350
381
  if (right !== "") {
351
382
  var cssText = span.style.cssText;
@@ -355,7 +386,7 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
355
386
  cssText = extendCssText(box.style.cssText, cssText);
356
387
  }
357
388
  }
358
- cont += "<span style='".concat(cssText, "'>").concat(right, "</span>");
389
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(right, "</span>");
359
390
  }
360
391
  if (((_a = startContainer.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) === "SPAN") {
361
392
  spanIndex = _.indexOf($textEditor.querySelectorAll("span"), span);
@@ -398,33 +429,33 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
398
429
  for (var i = 0; i < startSpanIndex; i += 1) {
399
430
  var span = spans[i];
400
431
  var content = span.innerHTML;
401
- cont += "<span style='".concat(span.style.cssText, "'>").concat(content, "</span>");
432
+ cont += "<span style=\"".concat(escapeHtmlAttr(span.style.cssText), "\">").concat(content, "</span>");
402
433
  }
403
434
  if (sleft !== "") {
404
- cont += "<span style='".concat(startSpan.style.cssText, "'>").concat(sleft, "</span>");
435
+ cont += "<span style=\"".concat(escapeHtmlAttr(startSpan.style.cssText), "\">").concat(sleft, "</span>");
405
436
  }
406
437
  if (sright !== "") {
407
438
  var cssText = getCssText(startSpan.style.cssText, attr, value);
408
- cont += "<span style='".concat(cssText, "'>").concat(sright, "</span>");
439
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(sright, "</span>");
409
440
  }
410
441
  if (startSpanIndex < endSpanIndex) {
411
442
  for (var i = startSpanIndex + 1; i < endSpanIndex; i += 1) {
412
443
  var span = spans[i];
413
444
  var content = span.innerHTML;
414
- cont += "<span style='".concat(span.style.cssText, "'>").concat(content, "</span>");
445
+ cont += "<span style=\"".concat(escapeHtmlAttr(span.style.cssText), "\">").concat(content, "</span>");
415
446
  }
416
447
  }
417
448
  if (eleft !== "") {
418
449
  var cssText = getCssText(endSpan.style.cssText, attr, value);
419
- cont += "<span style='".concat(cssText, "'>").concat(eleft, "</span>");
450
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\">").concat(eleft, "</span>");
420
451
  }
421
452
  if (eright !== "") {
422
- cont += "<span style='".concat(endSpan.style.cssText, "'>").concat(eright, "</span>");
453
+ cont += "<span style=\"".concat(escapeHtmlAttr(endSpan.style.cssText), "\">").concat(eright, "</span>");
423
454
  }
424
455
  for (var i = endSpanIndex + 1; i < spans.length; i += 1) {
425
456
  var span = spans[i];
426
457
  var content = span.innerHTML;
427
- cont += "<span style='".concat(span.style.cssText, "'>").concat(content, "</span>");
458
+ cont += "<span style=\"".concat(escapeHtmlAttr(span.style.cssText), "\">").concat(content, "</span>");
428
459
  }
429
460
  $textEditor.innerHTML = cont;
430
461
  var startSeletedNodeIndex = void 0;
@@ -442,13 +473,10 @@ export function updateInlineStringFormat(ctx, attr, value, cellInput) {
442
473
  }
443
474
  }
444
475
  }
445
- function escapeHtmlAttr(s) {
446
- return s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
447
- }
448
476
  function getLinkDataAttrs(span) {
449
477
  var _a, _b;
450
478
  if (((_a = span.dataset) === null || _a === void 0 ? void 0 : _a.linkType) && ((_b = span.dataset) === null || _b === void 0 ? void 0 : _b.linkAddress)) {
451
- return " data-link-type='".concat(escapeHtmlAttr(span.dataset.linkType), "' data-link-address='").concat(escapeHtmlAttr(span.dataset.linkAddress), "'");
479
+ return " data-link-type=\"".concat(escapeHtmlAttr(span.dataset.linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(span.dataset.linkAddress), "\"");
452
480
  }
453
481
  return "";
454
482
  }
@@ -486,7 +514,7 @@ export function applyLinkToSelection(cellInput, linkType, linkAddress) {
486
514
  var box = span.closest("#luckysheet-input-box");
487
515
  if (box != null) cssText = extendCssText(box.style.cssText, cssText);
488
516
  }
489
- cont += "<span style='".concat(cssText, "'").concat(dataAttrs, ">").concat(left, "</span>");
517
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\"").concat(dataAttrs, ">").concat(left, "</span>");
490
518
  }
491
519
  if (mid !== "") {
492
520
  var cssText = getLinkStyleCssText(span.style.cssText);
@@ -494,7 +522,7 @@ export function applyLinkToSelection(cellInput, linkType, linkAddress) {
494
522
  var box = span.closest("#luckysheet-input-box");
495
523
  if (box != null) cssText = extendCssText(box.style.cssText, cssText);
496
524
  }
497
- cont += "<span style='".concat(cssText, "' data-link-type='").concat(escapeHtmlAttr(linkType), "' data-link-address='").concat(escapeHtmlAttr(linkAddress), "'>").concat(mid, "</span>");
525
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\" data-link-type=\"").concat(escapeHtmlAttr(linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(linkAddress), "\">").concat(mid, "</span>");
498
526
  }
499
527
  if (right !== "") {
500
528
  var cssText = span.style.cssText;
@@ -502,7 +530,7 @@ export function applyLinkToSelection(cellInput, linkType, linkAddress) {
502
530
  var box = span.closest("#luckysheet-input-box");
503
531
  if (box != null) cssText = extendCssText(box.style.cssText, cssText);
504
532
  }
505
- cont += "<span style='".concat(cssText, "'").concat(dataAttrs, ">").concat(right, "</span>");
533
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\"").concat(dataAttrs, ">").concat(right, "</span>");
506
534
  }
507
535
  if (((_a = startContainer.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) === "SPAN") {
508
536
  span.outerHTML = cont;
@@ -532,32 +560,32 @@ export function applyLinkToSelection(cellInput, linkType, linkAddress) {
532
560
  var cont = "";
533
561
  for (var i = 0; i < startSpanIndex; i += 1) {
534
562
  var sp = spans[i];
535
- cont += "<span style='".concat(sp.style.cssText, "'").concat(getLinkDataAttrs(sp), ">").concat(sp.innerHTML, "</span>");
563
+ cont += "<span style=\"".concat(escapeHtmlAttr(sp.style.cssText), "\"").concat(getLinkDataAttrs(sp), ">").concat(sp.innerHTML, "</span>");
536
564
  }
537
565
  if (sleft !== "") {
538
- cont += "<span style='".concat(startSpan.style.cssText, "'").concat(getLinkDataAttrs(startSpan), ">").concat(sleft, "</span>");
566
+ cont += "<span style=\"".concat(escapeHtmlAttr(startSpan.style.cssText), "\"").concat(getLinkDataAttrs(startSpan), ">").concat(sleft, "</span>");
539
567
  }
540
568
  if (sright !== "") {
541
569
  var cssText = getLinkStyleCssText(startSpan.style.cssText);
542
- cont += "<span style='".concat(cssText, "' data-link-type='").concat(escapeHtmlAttr(linkType), "' data-link-address='").concat(escapeHtmlAttr(linkAddress), "'>").concat(sright, "</span>");
570
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\" data-link-type=\"").concat(escapeHtmlAttr(linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(linkAddress), "\">").concat(sright, "</span>");
543
571
  }
544
572
  if (startSpanIndex < endSpanIndex) {
545
573
  for (var i = startSpanIndex + 1; i < endSpanIndex; i += 1) {
546
574
  var sp = spans[i];
547
575
  var cssText = getLinkStyleCssText(sp.style.cssText);
548
- cont += "<span style='".concat(cssText, "' data-link-type='").concat(escapeHtmlAttr(linkType), "' data-link-address='").concat(escapeHtmlAttr(linkAddress), "'>").concat(sp.innerHTML, "</span>");
576
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\" data-link-type=\"").concat(escapeHtmlAttr(linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(linkAddress), "\">").concat(sp.innerHTML, "</span>");
549
577
  }
550
578
  }
551
579
  if (eleft !== "") {
552
580
  var cssText = getLinkStyleCssText(endSpan.style.cssText);
553
- cont += "<span style='".concat(cssText, "' data-link-type='").concat(escapeHtmlAttr(linkType), "' data-link-address='").concat(escapeHtmlAttr(linkAddress), "'>").concat(eleft, "</span>");
581
+ cont += "<span style=\"".concat(escapeHtmlAttr(cssText), "\" data-link-type=\"").concat(escapeHtmlAttr(linkType), "\" data-link-address=\"").concat(escapeHtmlAttr(linkAddress), "\">").concat(eleft, "</span>");
554
582
  }
555
583
  if (eright !== "") {
556
- cont += "<span style='".concat(endSpan.style.cssText, "'").concat(getLinkDataAttrs(endSpan), ">").concat(eright, "</span>");
584
+ cont += "<span style=\"".concat(escapeHtmlAttr(endSpan.style.cssText), "\"").concat(getLinkDataAttrs(endSpan), ">").concat(eright, "</span>");
557
585
  }
558
586
  for (var i = endSpanIndex + 1; i < spans.length; i += 1) {
559
587
  var sp = spans[i];
560
- cont += "<span style='".concat(sp.style.cssText, "'").concat(getLinkDataAttrs(sp), ">").concat(sp.innerHTML, "</span>");
588
+ cont += "<span style=\"".concat(escapeHtmlAttr(sp.style.cssText), "\"").concat(getLinkDataAttrs(sp), ">").concat(sp.innerHTML, "</span>");
561
589
  }
562
590
  $textEditor.innerHTML = cont;
563
591
  spans = $textEditor.querySelectorAll("span");
@@ -1186,7 +1186,7 @@ export function rangeValueToHtml(ctx, sheetId, ranges) {
1186
1186
  cpdata += "<tr height=".concat(rowLen, "px >");
1187
1187
  var _loop_3 = function _loop_3(j) {
1188
1188
  var c = colIndexArr[j];
1189
- var column = '<td ${span} style="${style}">';
1189
+ var column = '<td ${span} style="${style}" data-fortune-cell="${cellData}">';
1190
1190
  var cell = (_f = d[r]) === null || _f === void 0 ? void 0 : _f[c];
1191
1191
  if (cell != null) {
1192
1192
  var style = "";
@@ -1397,9 +1397,14 @@ export function rangeValueToHtml(ctx, sheetId, ranges) {
1397
1397
  }
1398
1398
  }
1399
1399
  }
1400
+ var cellData = encodeURIComponent(JSON.stringify(__assign(__assign({}, cell), {
1401
+ _srcRow: r,
1402
+ _srcCol: c
1403
+ })));
1400
1404
  column = replaceHtml(column, {
1401
1405
  style: style,
1402
- span: span
1406
+ span: span,
1407
+ cellData: cellData
1403
1408
  });
1404
1409
  if (_.isNil(c_value)) {
1405
1410
  c_value = getCellValue(r, c, d);
@@ -1449,7 +1454,8 @@ export function rangeValueToHtml(ctx, sheetId, ranges) {
1449
1454
  }
1450
1455
  column = replaceHtml(column, {
1451
1456
  style: style,
1452
- span: ""
1457
+ span: "",
1458
+ cellData: ""
1453
1459
  });
1454
1460
  column += "";
1455
1461
  }