@fileverse-dev/fortune-react 1.1.51 → 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.
@@ -54,10 +54,17 @@ var InputBox = function InputBox() {
54
54
  var preText = useRef("");
55
55
  var placeRef = useRef("");
56
56
  var inputBoxStyle = useMemo(function () {
57
+ var _a;
57
58
  if (firstSelectionActiveCell && context.luckysheetCellUpdate.length > 0) {
58
59
  var flowdata = getFlowdata(context);
59
60
  if (!flowdata) return {};
60
- return getStyleByCell(context, flowdata, firstSelectionActiveCell.row_focus, firstSelectionActiveCell.column_focus);
61
+ var style = getStyleByCell(context, flowdata, firstSelectionActiveCell.row_focus, firstSelectionActiveCell.column_focus);
62
+ if (((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText.charAt(0)) === "=") {
63
+ style = __assign(__assign({}, style), {
64
+ textAlign: "left"
65
+ });
66
+ }
67
+ return style;
61
68
  }
62
69
  return {};
63
70
  }, [context.luckysheetfile, context.currentSheetId, context.luckysheetCellUpdate, firstSelectionActiveCell]);
@@ -130,6 +137,12 @@ var InputBox = function InputBox() {
130
137
  }, []);
131
138
  var insertSelectedFormula = useCallback(function (formulaName) {
132
139
  var _a;
140
+ if (/^=[a-zA-Z]+$/.test(inputRef.current.innerText)) {
141
+ var ht = "<span dir=\"auto\" class=\"luckysheet-formula-text-color\">=</span><span dir=\"auto\" class=\"luckysheet-formula-text-func\">".concat(formulaName, "</span><span dir=\"auto\" class=\"luckysheet-formula-text-lpar\">(</span>");
142
+ inputRef.current.innerHTML = ht;
143
+ moveCursorToEnd(inputRef.current);
144
+ return;
145
+ }
133
146
  var textEditor = document.getElementById("luckysheet-rich-text-editor");
134
147
  if (!textEditor) return;
135
148
  textEditor.focus();
@@ -219,7 +232,7 @@ var InputBox = function InputBox() {
219
232
  var lastSpan = spans[spans.length - 1];
220
233
  var notFunctionInit = !((_b = document.getElementById("luckysheet-rich-text-editor")) === null || _b === void 0 ? void 0 : _b.innerText.includes("("));
221
234
  var arrowRefNotAllowed = (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);
222
- 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) !== ")") && (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) !== '""' && !isLetterNumberPattern(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) && !arrowRefNotAllowed) {
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) !== ")") && !(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes('"')) && !isLetterNumberPattern(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) && !arrowRefNotAllowed && !/^[a-zA-Z]+$/.test(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
223
236
  allowListNavigation = false;
224
237
  inputRef.current.innerHTML = "".concat(inputRef.current.innerHTML, "<span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:#c1232b;\">").concat(refCell, "</span>");
225
238
  setTimeout(function () {
@@ -10,7 +10,7 @@ export function moveCursorToEnd(editableDiv) {
10
10
  }
11
11
  }
12
12
  export function isLetterNumberPattern(str) {
13
- var regex = /^[a-zA-Z]\d+$/;
13
+ var regex = /^[a-zA-Z]+\d+$/;
14
14
  return regex.test(str);
15
15
  }
16
16
  export function removeLastSpan(htmlString) {
@@ -63,10 +63,17 @@ var InputBox = function InputBox() {
63
63
  var preText = (0, _react.useRef)("");
64
64
  var placeRef = (0, _react.useRef)("");
65
65
  var inputBoxStyle = (0, _react.useMemo)(function () {
66
+ var _a;
66
67
  if (firstSelectionActiveCell && context.luckysheetCellUpdate.length > 0) {
67
68
  var flowdata = (0, _fortuneCore.getFlowdata)(context);
68
69
  if (!flowdata) return {};
69
- return (0, _fortuneCore.getStyleByCell)(context, flowdata, firstSelectionActiveCell.row_focus, firstSelectionActiveCell.column_focus);
70
+ var style = (0, _fortuneCore.getStyleByCell)(context, flowdata, firstSelectionActiveCell.row_focus, firstSelectionActiveCell.column_focus);
71
+ if (((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText.charAt(0)) === "=") {
72
+ style = __assign(__assign({}, style), {
73
+ textAlign: "left"
74
+ });
75
+ }
76
+ return style;
70
77
  }
71
78
  return {};
72
79
  }, [context.luckysheetfile, context.currentSheetId, context.luckysheetCellUpdate, firstSelectionActiveCell]);
@@ -139,6 +146,12 @@ var InputBox = function InputBox() {
139
146
  }, []);
140
147
  var insertSelectedFormula = (0, _react.useCallback)(function (formulaName) {
141
148
  var _a;
149
+ if (/^=[a-zA-Z]+$/.test(inputRef.current.innerText)) {
150
+ var ht = "<span dir=\"auto\" class=\"luckysheet-formula-text-color\">=</span><span dir=\"auto\" class=\"luckysheet-formula-text-func\">".concat(formulaName, "</span><span dir=\"auto\" class=\"luckysheet-formula-text-lpar\">(</span>");
151
+ inputRef.current.innerHTML = ht;
152
+ (0, _helper.moveCursorToEnd)(inputRef.current);
153
+ return;
154
+ }
142
155
  var textEditor = document.getElementById("luckysheet-rich-text-editor");
143
156
  if (!textEditor) return;
144
157
  textEditor.focus();
@@ -228,7 +241,7 @@ var InputBox = function InputBox() {
228
241
  var lastSpan = spans[spans.length - 1];
229
242
  var notFunctionInit = !((_b = document.getElementById("luckysheet-rich-text-editor")) === null || _b === void 0 ? void 0 : _b.innerText.includes("("));
230
243
  var arrowRefNotAllowed = (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(")")) || notFunctionInit && /^[a-zA-Z]+$/.test(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) && !_lodash.default.includes(["="], lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText);
231
- 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) !== ")") && (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) !== '""' && !(0, _helper.isLetterNumberPattern)(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) && !arrowRefNotAllowed) {
244
+ 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) !== ")") && !(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes('"')) && !(0, _helper.isLetterNumberPattern)(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) && !arrowRefNotAllowed && !/^[a-zA-Z]+$/.test(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
232
245
  allowListNavigation = false;
233
246
  inputRef.current.innerHTML = "".concat(inputRef.current.innerHTML, "<span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:#c1232b;\">").concat(refCell, "</span>");
234
247
  setTimeout(function () {
@@ -22,7 +22,7 @@ function moveCursorToEnd(editableDiv) {
22
22
  }
23
23
  }
24
24
  function isLetterNumberPattern(str) {
25
- var regex = /^[a-zA-Z]\d+$/;
25
+ var regex = /^[a-zA-Z]+\d+$/;
26
26
  return regex.test(str);
27
27
  }
28
28
  function removeLastSpan(htmlString) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.1.51",
3
+ "version": "1.1.53-patch-1",
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.51",
19
+ "@fileverse-dev/fortune-core": "1.1.53-patch-1",
20
20
  "@fileverse/ui": "^4.1.7-patch-21",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",