@fileverse-dev/fortune-react 1.1.35 → 1.1.37

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.
@@ -33,10 +33,10 @@ var InputBox = function InputBox() {
33
33
  var _j = useState(false),
34
34
  isInputBoxActive = _j[0],
35
35
  setIsInputBoxActive = _j[1];
36
- var _k = useState(''),
36
+ var _k = useState(""),
37
37
  activeCell = _k[0],
38
38
  setActiveCell = _k[1];
39
- var _l = useState(''),
39
+ var _l = useState(""),
40
40
  activeRefCell = _l[0],
41
41
  setActiveRefCell = _l[1];
42
42
  var _m = useState({
@@ -49,7 +49,7 @@ var InputBox = function InputBox() {
49
49
  var row_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
50
50
  var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
51
51
  var preText = useRef("");
52
- var placeRef = useRef('');
52
+ var placeRef = useRef("");
53
53
  useEffect(function () {
54
54
  if (isInputBoxActive) {
55
55
  setActiveCell(getCellAddress());
@@ -200,31 +200,35 @@ var InputBox = function InputBox() {
200
200
  }
201
201
  }, [getActiveFormula, insertSelectedFormula]);
202
202
  var onKeyDown = useCallback(function (e) {
203
- var _a;
203
+ var _a, _b;
204
204
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
205
205
  preText.current = inputRef.current.innerText;
206
- if (e.key !== 'ArrowLeft') {
206
+ if (e.key === "Delete" || e.key === "Backspace") {
207
207
  setTimeout(function () {
208
208
  moveCursorToEnd(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
209
209
  }, 5);
210
210
  }
211
211
  var refCell = placeRef.current;
212
- if (e.key === 'ArrowUp') {
212
+ if (e.key === "ArrowUp") {
213
213
  refCell = decrementRow(placeRef.current);
214
- } else if (e.key === 'ArrowDown') {
214
+ } else if (e.key === "ArrowDown") {
215
215
  refCell = incrementRow(placeRef.current);
216
- } else if (e.key === 'ArrowLeft') {
216
+ } else if (e.key === "ArrowLeft") {
217
217
  refCell = decrementColumn(placeRef.current);
218
- } else if (e.key === 'ArrowRight') {
218
+ } else if (e.key === "ArrowRight") {
219
219
  refCell = incrementColumn(placeRef.current);
220
220
  }
221
- if (e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
221
+ if (e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight") {
222
222
  var parser = new DOMParser();
223
- var doc = parser.parseFromString("<div>".concat((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML, "</div>"), 'text/html');
224
- var spans = doc.querySelectorAll('span');
223
+ var doc = parser.parseFromString("<div>".concat((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML, "</div>"), "text/html");
224
+ var spans = doc.querySelectorAll("span");
225
225
  var lastSpan = spans[spans.length - 1];
226
- if (((lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) === '(' || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) === ',' || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(':')) || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) !== ')') && !isLetterNumberPattern(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
227
- if (!(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes('(')) && (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.length) > 2 || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.length) === 2 && !isLetterNumberPattern(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
226
+ var notFunctionInit = !((_b = document.getElementById("luckysheet-rich-text-editor")) === null || _b === void 0 ? void 0 : _b.innerText.includes("("));
227
+ if ((lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(")")) || notFunctionInit && (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.length) >= 1 && !_.includes(["="], lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
228
+ return;
229
+ }
230
+ if (((lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) === "(" || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) === "," || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(":")) || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) !== ")") && !isLetterNumberPattern(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
231
+ if (!(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.includes("(")) && (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.length) > 2 || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.length) === 2 && !isLetterNumberPattern(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
228
232
  return;
229
233
  }
230
234
  inputRef.current.innerHTML = "".concat(inputRef.current.innerHTML, "<span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:#c1232b;\">").concat(refCell, "</span>");
@@ -14,9 +14,9 @@ export function isLetterNumberPattern(str) {
14
14
  return regex.test(str);
15
15
  }
16
16
  export function removeLastSpan(htmlString) {
17
- var container = document.createElement('div');
17
+ var container = document.createElement("div");
18
18
  container.innerHTML = htmlString;
19
- var spans = container.querySelectorAll('span');
19
+ var spans = container.querySelectorAll("span");
20
20
  if (spans.length > 0) {
21
21
  var lastSpan = spans[spans.length - 1];
22
22
  lastSpan.remove();
@@ -39,7 +39,7 @@ function columnToNumber(colPart) {
39
39
  return colNumber;
40
40
  }
41
41
  function numberToColumn(colNumber) {
42
- var colPart = '';
42
+ var colPart = "";
43
43
  while (colNumber > 0) {
44
44
  colNumber--;
45
45
  colPart = String.fromCharCode(65 + colNumber % 26) + colPart;
@@ -49,7 +49,7 @@ function numberToColumn(colNumber) {
49
49
  }
50
50
  export function incrementColumn(cell) {
51
51
  var parsed = parseCell(cell);
52
- if (!parsed) return '';
52
+ if (!parsed) return "";
53
53
  var colNumber = columnToNumber(parsed.colPart);
54
54
  colNumber += 1;
55
55
  var newColPart = numberToColumn(colNumber);
@@ -57,7 +57,7 @@ export function incrementColumn(cell) {
57
57
  }
58
58
  export function decrementColumn(cell) {
59
59
  var parsed = parseCell(cell);
60
- if (!parsed) return '';
60
+ if (!parsed) return "";
61
61
  var colNumber = columnToNumber(parsed.colPart);
62
62
  colNumber = Math.max(1, colNumber - 1);
63
63
  var newColPart = numberToColumn(colNumber);
@@ -65,13 +65,13 @@ export function decrementColumn(cell) {
65
65
  }
66
66
  export function incrementRow(cell) {
67
67
  var parsed = parseCell(cell);
68
- if (!parsed) return '';
68
+ if (!parsed) return "";
69
69
  var newRowPart = parsed.rowPart + 1;
70
70
  return parsed.colPart + newRowPart;
71
71
  }
72
72
  export function decrementRow(cell) {
73
73
  var parsed = parseCell(cell);
74
- if (!parsed) return '';
74
+ if (!parsed) return "";
75
75
  var newRowPart = Math.max(1, parsed.rowPart - 1);
76
76
  return parsed.colPart + newRowPart;
77
77
  }
@@ -42,10 +42,10 @@ var InputBox = function InputBox() {
42
42
  var _j = (0, _react.useState)(false),
43
43
  isInputBoxActive = _j[0],
44
44
  setIsInputBoxActive = _j[1];
45
- var _k = (0, _react.useState)(''),
45
+ var _k = (0, _react.useState)(""),
46
46
  activeCell = _k[0],
47
47
  setActiveCell = _k[1];
48
- var _l = (0, _react.useState)(''),
48
+ var _l = (0, _react.useState)(""),
49
49
  activeRefCell = _l[0],
50
50
  setActiveRefCell = _l[1];
51
51
  var _m = (0, _react.useState)({
@@ -58,7 +58,7 @@ var InputBox = function InputBox() {
58
58
  var row_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
59
59
  var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
60
60
  var preText = (0, _react.useRef)("");
61
- var placeRef = (0, _react.useRef)('');
61
+ var placeRef = (0, _react.useRef)("");
62
62
  (0, _react.useEffect)(function () {
63
63
  if (isInputBoxActive) {
64
64
  setActiveCell(getCellAddress());
@@ -209,31 +209,35 @@ var InputBox = function InputBox() {
209
209
  }
210
210
  }, [getActiveFormula, insertSelectedFormula]);
211
211
  var onKeyDown = (0, _react.useCallback)(function (e) {
212
- var _a;
212
+ var _a, _b;
213
213
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
214
214
  preText.current = inputRef.current.innerText;
215
- if (e.key !== 'ArrowLeft') {
215
+ if (e.key === "Delete" || e.key === "Backspace") {
216
216
  setTimeout(function () {
217
217
  (0, _helper.moveCursorToEnd)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
218
218
  }, 5);
219
219
  }
220
220
  var refCell = placeRef.current;
221
- if (e.key === 'ArrowUp') {
221
+ if (e.key === "ArrowUp") {
222
222
  refCell = (0, _helper.decrementRow)(placeRef.current);
223
- } else if (e.key === 'ArrowDown') {
223
+ } else if (e.key === "ArrowDown") {
224
224
  refCell = (0, _helper.incrementRow)(placeRef.current);
225
- } else if (e.key === 'ArrowLeft') {
225
+ } else if (e.key === "ArrowLeft") {
226
226
  refCell = (0, _helper.decrementColumn)(placeRef.current);
227
- } else if (e.key === 'ArrowRight') {
227
+ } else if (e.key === "ArrowRight") {
228
228
  refCell = (0, _helper.incrementColumn)(placeRef.current);
229
229
  }
230
- if (e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
230
+ if (e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight") {
231
231
  var parser = new DOMParser();
232
- var doc = parser.parseFromString("<div>".concat((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML, "</div>"), 'text/html');
233
- var spans = doc.querySelectorAll('span');
232
+ var doc = parser.parseFromString("<div>".concat((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML, "</div>"), "text/html");
233
+ var spans = doc.querySelectorAll("span");
234
234
  var lastSpan = spans[spans.length - 1];
235
- if (((lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) === '(' || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) === ',' || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(':')) || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) !== ')') && !(0, _helper.isLetterNumberPattern)(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
236
- if (!(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes('(')) && (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.length) > 2 || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.length) === 2 && !(0, _helper.isLetterNumberPattern)(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
235
+ var notFunctionInit = !((_b = document.getElementById("luckysheet-rich-text-editor")) === null || _b === void 0 ? void 0 : _b.innerText.includes("("));
236
+ if ((lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(")")) || notFunctionInit && (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.length) >= 1 && !_lodash.default.includes(["="], lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
237
+ return;
238
+ }
239
+ if (((lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) === "(" || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) === "," || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(":")) || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) !== ")") && !(0, _helper.isLetterNumberPattern)(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
240
+ if (!(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.includes("(")) && (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.length) > 2 || (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.length) === 2 && !(0, _helper.isLetterNumberPattern)(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
237
241
  return;
238
242
  }
239
243
  inputRef.current.innerHTML = "".concat(inputRef.current.innerHTML, "<span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:#c1232b;\">").concat(refCell, "</span>");
@@ -26,9 +26,9 @@ function isLetterNumberPattern(str) {
26
26
  return regex.test(str);
27
27
  }
28
28
  function removeLastSpan(htmlString) {
29
- var container = document.createElement('div');
29
+ var container = document.createElement("div");
30
30
  container.innerHTML = htmlString;
31
- var spans = container.querySelectorAll('span');
31
+ var spans = container.querySelectorAll("span");
32
32
  if (spans.length > 0) {
33
33
  var lastSpan = spans[spans.length - 1];
34
34
  lastSpan.remove();
@@ -51,7 +51,7 @@ function columnToNumber(colPart) {
51
51
  return colNumber;
52
52
  }
53
53
  function numberToColumn(colNumber) {
54
- var colPart = '';
54
+ var colPart = "";
55
55
  while (colNumber > 0) {
56
56
  colNumber--;
57
57
  colPart = String.fromCharCode(65 + colNumber % 26) + colPart;
@@ -61,7 +61,7 @@ function numberToColumn(colNumber) {
61
61
  }
62
62
  function incrementColumn(cell) {
63
63
  var parsed = parseCell(cell);
64
- if (!parsed) return '';
64
+ if (!parsed) return "";
65
65
  var colNumber = columnToNumber(parsed.colPart);
66
66
  colNumber += 1;
67
67
  var newColPart = numberToColumn(colNumber);
@@ -69,7 +69,7 @@ function incrementColumn(cell) {
69
69
  }
70
70
  function decrementColumn(cell) {
71
71
  var parsed = parseCell(cell);
72
- if (!parsed) return '';
72
+ if (!parsed) return "";
73
73
  var colNumber = columnToNumber(parsed.colPart);
74
74
  colNumber = Math.max(1, colNumber - 1);
75
75
  var newColPart = numberToColumn(colNumber);
@@ -77,13 +77,13 @@ function decrementColumn(cell) {
77
77
  }
78
78
  function incrementRow(cell) {
79
79
  var parsed = parseCell(cell);
80
- if (!parsed) return '';
80
+ if (!parsed) return "";
81
81
  var newRowPart = parsed.rowPart + 1;
82
82
  return parsed.colPart + newRowPart;
83
83
  }
84
84
  function decrementRow(cell) {
85
85
  var parsed = parseCell(cell);
86
- if (!parsed) return '';
86
+ if (!parsed) return "";
87
87
  var newRowPart = Math.max(1, parsed.rowPart - 1);
88
88
  return parsed.colPart + newRowPart;
89
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.1.35",
3
+ "version": "1.1.37",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "module": "es/index.js",
@@ -16,7 +16,7 @@
16
16
  "tsc": "tsc"
17
17
  },
18
18
  "dependencies": {
19
- "@fileverse-dev/fortune-core": "1.1.35",
19
+ "@fileverse-dev/fortune-core": "1.1.37",
20
20
  "@fileverse/ui": "^4.1.7-patch-21",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",