@fileverse-dev/fortune-react 1.3.10-input → 1.3.10-input-2
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.
- package/es/components/ConditionFormat/ConditionRules.js +15 -5
- package/es/components/ConditionFormat/index.js +3 -0
- package/es/components/SheetOverlay/InputBox.js +108 -71
- package/es/components/Workbook/api.d.ts +3 -0
- package/es/components/Workbook/index.d.ts +3 -0
- package/lib/components/ConditionFormat/ConditionRules.js +15 -5
- package/lib/components/ConditionFormat/index.js +3 -0
- package/lib/components/SheetOverlay/InputBox.js +107 -70
- package/lib/components/Workbook/api.d.ts +3 -0
- package/lib/components/Workbook/index.d.ts +3 -0
- package/package.json +2 -2
|
@@ -294,6 +294,10 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
294
294
|
text: "textContains",
|
|
295
295
|
value: "()",
|
|
296
296
|
label: "Text Contains"
|
|
297
|
+
}, {
|
|
298
|
+
text: "empty",
|
|
299
|
+
value: "",
|
|
300
|
+
label: "Empty"
|
|
297
301
|
}, {
|
|
298
302
|
text: "occurrenceDate",
|
|
299
303
|
value: conditionformat.yesterday,
|
|
@@ -334,7 +338,7 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
334
338
|
marginBottom: "16px"
|
|
335
339
|
}
|
|
336
340
|
}, matchedConditionFormatKey.map(function (key) {
|
|
337
|
-
var _a, _b;
|
|
341
|
+
var _a, _b, _c;
|
|
338
342
|
return /*#__PURE__*/React.createElement("div", {
|
|
339
343
|
onClick: function onClick() {
|
|
340
344
|
var _a;
|
|
@@ -385,10 +389,10 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
385
389
|
}, /*#__PURE__*/React.createElement("h3", {
|
|
386
390
|
className: "fortune-condition-rules__heading condition-list-type",
|
|
387
391
|
"data-testid": "condition-rules-heading-".concat(key)
|
|
388
|
-
}, conditionformat[allConditionFormats[key].conditionName], " "
|
|
392
|
+
}, conditionformat[allConditionFormats[key].conditionName], allConditionFormats[key].conditionName !== "empty" && " ".concat((_b = (_a = allConditionFormats[key].conditionValue) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : "")), /*#__PURE__*/React.createElement("p", {
|
|
389
393
|
className: "fortune-condition-rules__para condition-list-range",
|
|
390
394
|
"data-testid": "condition-rules-para-".concat(key)
|
|
391
|
-
}, (
|
|
395
|
+
}, (_c = allConditionFormats[key].cellrange) === null || _c === void 0 ? void 0 : _c.map(function (range) {
|
|
392
396
|
var startCol = numberToColumn(range.column[0] + 1);
|
|
393
397
|
var endCol = numberToColumn(range.column[1] + 1);
|
|
394
398
|
var startRow = range.row[0] + 1;
|
|
@@ -467,6 +471,12 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
467
471
|
}, "Format cells if"), /*#__PURE__*/React.createElement(Select, {
|
|
468
472
|
value: type,
|
|
469
473
|
onValueChange: function onValueChange(value) {
|
|
474
|
+
if (value === "empty" || type === "empty") {
|
|
475
|
+
setContext(function (ctx) {
|
|
476
|
+
ctx.conditionRules.rulesValue = "";
|
|
477
|
+
});
|
|
478
|
+
setEditConditionFormatValue(null);
|
|
479
|
+
}
|
|
470
480
|
setType(value);
|
|
471
481
|
}
|
|
472
482
|
}, /*#__PURE__*/React.createElement(SelectTrigger, null, /*#__PURE__*/React.createElement(SelectValue, null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -804,7 +814,7 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
804
814
|
},
|
|
805
815
|
tabIndex: 0
|
|
806
816
|
}, button.cancel), editConditionFormatKey !== null ? (/*#__PURE__*/React.createElement(Button, {
|
|
807
|
-
disabled: context.conditionRules.rulesValue === "",
|
|
817
|
+
disabled: context.conditionRules.rulesValue === "" && type !== "empty",
|
|
808
818
|
variant: "default",
|
|
809
819
|
style: {
|
|
810
820
|
minWidth: "80px"
|
|
@@ -814,7 +824,7 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
814
824
|
},
|
|
815
825
|
tabIndex: 0
|
|
816
826
|
}, "Update rule")) : (/*#__PURE__*/React.createElement(Button, {
|
|
817
|
-
disabled: context.conditionRules.rulesValue === "",
|
|
827
|
+
disabled: context.conditionRules.rulesValue === "" && type !== "empty",
|
|
818
828
|
variant: "default",
|
|
819
829
|
style: {
|
|
820
830
|
minWidth: "80px"
|
|
@@ -17,50 +17,50 @@ import ContentEditable from "./ContentEditable";
|
|
|
17
17
|
import FormulaSearch from "./FormulaSearch";
|
|
18
18
|
import FormulaHint from "./FormulaHint";
|
|
19
19
|
import usePrevious from "../../hooks/usePrevious";
|
|
20
|
-
import { moveCursorToEnd, getCursorPosition, isLetterNumberPattern, removeLastSpan,
|
|
20
|
+
import { moveCursorToEnd, getCursorPosition, isLetterNumberPattern, removeLastSpan, countCommasBeforeCursor } from "./helper";
|
|
21
21
|
import { LucideIcon } from "./LucideIcon";
|
|
22
22
|
var InputBox = function InputBox() {
|
|
23
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
24
|
-
var
|
|
25
|
-
context =
|
|
26
|
-
setContext =
|
|
27
|
-
refs =
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
24
|
+
var _o = useContext(WorkbookContext),
|
|
25
|
+
context = _o.context,
|
|
26
|
+
setContext = _o.setContext,
|
|
27
|
+
refs = _o.refs;
|
|
28
28
|
var inputRef = useRef(null);
|
|
29
29
|
var lastKeyDownEventRef = useRef(null);
|
|
30
30
|
var prevCellUpdate = usePrevious(context.luckysheetCellUpdate);
|
|
31
31
|
var prevSheetId = usePrevious(context.currentSheetId);
|
|
32
|
-
var _o = useState(false),
|
|
33
|
-
isHidenRC = _o[0],
|
|
34
|
-
setIsHidenRC = _o[1];
|
|
35
32
|
var _p = useState(false),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var _q = useState(
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
isHidenRC = _p[0],
|
|
34
|
+
setIsHidenRC = _p[1];
|
|
35
|
+
var _q = useState(false),
|
|
36
|
+
isInputBoxActive = _q[0],
|
|
37
|
+
setIsInputBoxActive = _q[1];
|
|
41
38
|
var _r = useState(""),
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var _s = useState(
|
|
39
|
+
activeCell = _r[0],
|
|
40
|
+
setActiveCell = _r[1];
|
|
41
|
+
var _s = useState(""),
|
|
42
|
+
activeRefCell = _s[0],
|
|
43
|
+
setActiveRefCell = _s[1];
|
|
44
|
+
var _t = useState({
|
|
45
45
|
left: 0,
|
|
46
46
|
top: 0
|
|
47
47
|
}),
|
|
48
|
-
frozenPosition =
|
|
49
|
-
setFrozenPosition =
|
|
48
|
+
frozenPosition = _t[0],
|
|
49
|
+
setFrozenPosition = _t[1];
|
|
50
50
|
var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
|
|
51
|
-
var
|
|
52
|
-
firstSelectionActiveCell =
|
|
53
|
-
setFirstSelectionActiveCell =
|
|
54
|
-
var
|
|
55
|
-
commaCount =
|
|
56
|
-
setCommaCount =
|
|
51
|
+
var _u = useState({}),
|
|
52
|
+
firstSelectionActiveCell = _u[0],
|
|
53
|
+
setFirstSelectionActiveCell = _u[1];
|
|
54
|
+
var _v = useState(0),
|
|
55
|
+
commaCount = _v[0],
|
|
56
|
+
setCommaCount = _v[1];
|
|
57
57
|
var hideFormulaHintLocal = localStorage.getItem("formulaMore") === "true";
|
|
58
|
-
var
|
|
59
|
-
showFormulaHint =
|
|
60
|
-
setShowFormulaHint =
|
|
61
|
-
var
|
|
62
|
-
showSearchHint =
|
|
63
|
-
setShowSearchHint =
|
|
58
|
+
var _w = useState(!hideFormulaHintLocal),
|
|
59
|
+
showFormulaHint = _w[0],
|
|
60
|
+
setShowFormulaHint = _w[1];
|
|
61
|
+
var _x = useState(false),
|
|
62
|
+
showSearchHint = _x[0],
|
|
63
|
+
setShowSearchHint = _x[1];
|
|
64
64
|
var row_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
|
|
65
65
|
var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
|
|
66
66
|
var preText = useRef("");
|
|
@@ -68,9 +68,9 @@ var InputBox = function InputBox() {
|
|
|
68
68
|
var isComposingRef = useRef(false);
|
|
69
69
|
var ZWSP = "\u200B";
|
|
70
70
|
var inputBoxInnerRef = useRef(null);
|
|
71
|
-
var
|
|
72
|
-
linkSelectionHighlightRects =
|
|
73
|
-
setLinkSelectionHighlightRects =
|
|
71
|
+
var _y = useState([]),
|
|
72
|
+
linkSelectionHighlightRects = _y[0],
|
|
73
|
+
setLinkSelectionHighlightRects = _y[1];
|
|
74
74
|
var ensureNotEmpty = function ensureNotEmpty() {
|
|
75
75
|
var el = inputRef.current;
|
|
76
76
|
if (!el) return;
|
|
@@ -129,6 +129,8 @@ var InputBox = function InputBox() {
|
|
|
129
129
|
var flowdata = getFlowdata(context);
|
|
130
130
|
var cell = (_a = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index]) === null || _a === void 0 ? void 0 : _a[col_index];
|
|
131
131
|
var value_1 = "";
|
|
132
|
+
var wasOverwrite = refs.globalCache.overwriteCell;
|
|
133
|
+
var overwriteFirstChar = refs.globalCache.overwriteCellFirstChar;
|
|
132
134
|
if (cell && !refs.globalCache.overwriteCell) {
|
|
133
135
|
if (isInlineStringCell(cell)) {
|
|
134
136
|
value_1 = getInlineStringHTML(row_index, col_index, flowdata);
|
|
@@ -145,9 +147,15 @@ var InputBox = function InputBox() {
|
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
refs.globalCache.overwriteCell = false;
|
|
148
|
-
|
|
150
|
+
delete refs.globalCache.overwriteCellFirstChar;
|
|
151
|
+
if (wasOverwrite && inputRef.current) {
|
|
152
|
+
inputRef.current.innerText = overwriteFirstChar !== null && overwriteFirstChar !== void 0 ? overwriteFirstChar : "";
|
|
153
|
+
if (overwriteFirstChar) {
|
|
154
|
+
moveToEnd(inputRef.current);
|
|
155
|
+
}
|
|
156
|
+
} else if (!refs.globalCache.ignoreWriteCell && inputRef.current && value_1) {
|
|
149
157
|
inputRef.current.innerHTML = escapeHTMLTag(escapeScriptTag(value_1));
|
|
150
|
-
} else if (!refs.globalCache.ignoreWriteCell && inputRef.current && !value_1) {
|
|
158
|
+
} else if (!refs.globalCache.ignoreWriteCell && inputRef.current && !value_1 && !wasOverwrite) {
|
|
151
159
|
var valueD = getCellValue(row_index, col_index, flowdata, "f");
|
|
152
160
|
inputRef.current.innerText = valueD;
|
|
153
161
|
}
|
|
@@ -270,6 +278,54 @@ var InputBox = function InputBox() {
|
|
|
270
278
|
event.stopPropagation();
|
|
271
279
|
event.preventDefault();
|
|
272
280
|
};
|
|
281
|
+
useEffect(function () {
|
|
282
|
+
var _a, _b;
|
|
283
|
+
var selection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
|
|
284
|
+
var editor = inputRef.current;
|
|
285
|
+
if (!selection || !editor || !isInputBoxActive || ((_b = context.rangeDialog) === null || _b === void 0 ? void 0 : _b.show)) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
var rowSel = selection.row;
|
|
289
|
+
var colSel = selection.column;
|
|
290
|
+
if (!rowSel || !colSel || rowSel.length < 2 || colSel.length < 2) return;
|
|
291
|
+
var rowStart = Math.min(rowSel[0], rowSel[1]);
|
|
292
|
+
var rowEnd = Math.max(rowSel[0], rowSel[1]);
|
|
293
|
+
var colStart = Math.min(colSel[0], colSel[1]);
|
|
294
|
+
var colEnd = Math.max(colSel[0], colSel[1]);
|
|
295
|
+
var startRef = "".concat(indexToColumnChar(colStart)).concat(rowStart + 1);
|
|
296
|
+
var endRef = "".concat(indexToColumnChar(colEnd)).concat(rowEnd + 1);
|
|
297
|
+
var refText = startRef === endRef ? startRef : "".concat(startRef, ":").concat(endRef);
|
|
298
|
+
var editorText = editor.innerText || "";
|
|
299
|
+
if (!editorText.startsWith("=")) return;
|
|
300
|
+
var spans = editor.querySelectorAll("span");
|
|
301
|
+
var lastSpan = spans[spans.length - 1];
|
|
302
|
+
var lastSpanText = (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) || "";
|
|
303
|
+
var isA1RangePattern = /^[a-zA-Z]+\d+:[a-zA-Z]+\d+$/.test(lastSpanText);
|
|
304
|
+
var notFunctionInit = !editorText.includes("(");
|
|
305
|
+
var refNotAllowed = lastSpanText.includes(")") || notFunctionInit && /^[a-zA-Z]+$/.test(lastSpanText) && !_.includes(["="], lastSpanText);
|
|
306
|
+
var shouldHandleRef = (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.classList.contains("fortune-formula-functionrange-cell")) || isLetterNumberPattern(lastSpanText) || isA1RangePattern || (lastSpanText === "(" || lastSpanText === "," || lastSpanText.includes(":") || lastSpanText === "=") && !lastSpanText.includes('"') && !refNotAllowed && !/^[a-zA-Z]+$/.test(lastSpanText);
|
|
307
|
+
if (!shouldHandleRef) return;
|
|
308
|
+
var refSpanHtml = "<span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:#c1232b;\">".concat(refText, "</span>");
|
|
309
|
+
if (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.classList.contains("fortune-formula-functionrange-cell")) {
|
|
310
|
+
if (lastSpan.textContent !== refText) lastSpan.textContent = refText;
|
|
311
|
+
setTimeout(function () {
|
|
312
|
+
return moveCursorToEnd(editor);
|
|
313
|
+
}, 1);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (isLetterNumberPattern(lastSpanText) || isA1RangePattern) {
|
|
317
|
+
var htmlR = removeLastSpan(editor.innerHTML);
|
|
318
|
+
editor.innerHTML = "".concat(htmlR).concat(refSpanHtml);
|
|
319
|
+
setTimeout(function () {
|
|
320
|
+
return moveCursorToEnd(editor);
|
|
321
|
+
}, 1);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
editor.innerHTML = "".concat(editor.innerHTML).concat(refSpanHtml);
|
|
325
|
+
setTimeout(function () {
|
|
326
|
+
return moveCursorToEnd(editor);
|
|
327
|
+
}, 1);
|
|
328
|
+
}, [context.luckysheet_select_save, (_d = context.rangeDialog) === null || _d === void 0 ? void 0 : _d.show, isInputBoxActive]);
|
|
273
329
|
var onKeyDown = useCallback(function (e) {
|
|
274
330
|
var _a, _b;
|
|
275
331
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
@@ -302,37 +358,18 @@ var InputBox = function InputBox() {
|
|
|
302
358
|
}, 5);
|
|
303
359
|
}
|
|
304
360
|
}
|
|
305
|
-
var
|
|
306
|
-
if (e.key === "
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
if ((e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight") && !(getCursorPosition(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) !== (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length) && e.key === "ArrowRight")) {
|
|
316
|
-
var parser = new DOMParser();
|
|
317
|
-
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");
|
|
318
|
-
var spans = doc.querySelectorAll("span");
|
|
319
|
-
var lastSpan = spans[spans.length - 1];
|
|
320
|
-
var notFunctionInit = !((_b = document.getElementById("luckysheet-rich-text-editor")) === null || _b === void 0 ? void 0 : _b.innerText.includes("("));
|
|
321
|
-
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);
|
|
322
|
-
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)) {
|
|
323
|
-
allowListNavigation = false;
|
|
324
|
-
inputRef.current.innerHTML = "".concat(inputRef.current.innerHTML, "<span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:#c1232b;\">").concat(refCell, "</span>");
|
|
325
|
-
setTimeout(function () {
|
|
326
|
-
moveCursorToEnd(inputRef.current);
|
|
327
|
-
}, 1);
|
|
328
|
-
}
|
|
329
|
-
if (isLetterNumberPattern(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
|
|
361
|
+
var isArrowKey = e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight";
|
|
362
|
+
if (isArrowKey && !(getCursorPosition(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) !== (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length) && e.key === "ArrowRight")) {
|
|
363
|
+
var editorText = ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText) || "";
|
|
364
|
+
var lastSpanText = getLastInputSpanText() || "";
|
|
365
|
+
var isA1RangePattern = /^[a-zA-Z]+\d+:[a-zA-Z]+\d+$/.test(lastSpanText);
|
|
366
|
+
var notFunctionInit = !editorText.includes("(");
|
|
367
|
+
var refNotAllowed = lastSpanText.includes(")") || notFunctionInit && /^[a-zA-Z]+$/.test(lastSpanText) && !_.includes(["="], lastSpanText);
|
|
368
|
+
var shouldTreatAsRefNavigation = editorText.startsWith("=") && (Boolean((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.querySelector(".fortune-formula-functionrange-cell")) || isLetterNumberPattern(lastSpanText) || isA1RangePattern || (lastSpanText === "(" || lastSpanText === "," || lastSpanText.includes(":") || lastSpanText === "=") && !lastSpanText.includes('"') && !refNotAllowed && !/^[a-zA-Z]+$/.test(lastSpanText));
|
|
369
|
+
if (shouldTreatAsRefNavigation) {
|
|
330
370
|
allowListNavigation = false;
|
|
331
|
-
var htmlR = removeLastSpan(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerHTML);
|
|
332
|
-
inputRef.current.innerHTML = "".concat(htmlR, "<span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:#c1232b;\">").concat(refCell, "</span>");
|
|
333
|
-
moveCursorToEnd(inputRef.current);
|
|
334
371
|
setTimeout(function () {
|
|
335
|
-
moveCursorToEnd(inputRef.current);
|
|
372
|
+
if (inputRef.current) moveCursorToEnd(inputRef.current);
|
|
336
373
|
}, 1);
|
|
337
374
|
}
|
|
338
375
|
}
|
|
@@ -390,7 +427,7 @@ var InputBox = function InputBox() {
|
|
|
390
427
|
}
|
|
391
428
|
e.preventDefault();
|
|
392
429
|
}
|
|
393
|
-
}, [clearSearchItemActiveClass, context.luckysheetCellUpdate.length, selectActiveFormula, setContext
|
|
430
|
+
}, [clearSearchItemActiveClass, context.luckysheetCellUpdate.length, selectActiveFormula, setContext]);
|
|
394
431
|
var handleHideShowHint = function handleHideShowHint() {
|
|
395
432
|
var _a, _b, _c, _d;
|
|
396
433
|
var searchElFx = (_a = document.getElementsByClassName("fx-search")) === null || _a === void 0 ? void 0 : _a[0];
|
|
@@ -480,7 +517,7 @@ var InputBox = function InputBox() {
|
|
|
480
517
|
zIndex: _.isEmpty(context.luckysheetCellUpdate) ? -1 : 19,
|
|
481
518
|
display: "block"
|
|
482
519
|
};
|
|
483
|
-
}, [firstSelection, (
|
|
520
|
+
}, [firstSelection, (_e = context.rangeDialog) === null || _e === void 0 ? void 0 : _e.show, context.luckysheetCellUpdate, refs.cellArea, isInputBoxActive, frozenPosition, context.scrollLeft, context.scrollTop]);
|
|
484
521
|
useEffect(function () {
|
|
485
522
|
var _a;
|
|
486
523
|
if (firstSelection && !((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show) && !isInputBoxActive && !_.isEmpty(context.luckysheetCellUpdate)) {
|
|
@@ -496,7 +533,7 @@ var InputBox = function InputBox() {
|
|
|
496
533
|
setIsInputBoxActive(true);
|
|
497
534
|
}
|
|
498
535
|
}
|
|
499
|
-
}, [firstSelection, (
|
|
536
|
+
}, [firstSelection, (_f = context.rangeDialog) === null || _f === void 0 ? void 0 : _f.show, context.luckysheetCellUpdate, isInputBoxActive, context.scrollLeft, context.scrollTop, refs.cellArea]);
|
|
500
537
|
var getAddressIndicatorPosition = useCallback(function () {
|
|
501
538
|
var _a;
|
|
502
539
|
if (!firstSelection || ((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show)) {
|
|
@@ -509,7 +546,7 @@ var InputBox = function InputBox() {
|
|
|
509
546
|
left: "0",
|
|
510
547
|
display: "block"
|
|
511
548
|
};
|
|
512
|
-
}, [firstSelection, (
|
|
549
|
+
}, [firstSelection, (_g = context.rangeDialog) === null || _g === void 0 ? void 0 : _g.show]);
|
|
513
550
|
var getCellAddress = useCallback(function () {
|
|
514
551
|
if (!firstSelection) return "";
|
|
515
552
|
var rowIndex = firstSelection.row_focus || 0;
|
|
@@ -559,7 +596,7 @@ var InputBox = function InputBox() {
|
|
|
559
596
|
};
|
|
560
597
|
});
|
|
561
598
|
setLinkSelectionHighlightRects(relative);
|
|
562
|
-
}, [(
|
|
599
|
+
}, [(_h = context.linkCard) === null || _h === void 0 ? void 0 : _h.applyToSelection, (_j = context.linkCard) === null || _j === void 0 ? void 0 : _j.selectionOffsets, (_k = context.linkCard) === null || _k === void 0 ? void 0 : _k.r, (_l = context.linkCard) === null || _l === void 0 ? void 0 : _l.c, context.luckysheetCellUpdate]);
|
|
563
600
|
var wraperGetCell = function wraperGetCell() {
|
|
564
601
|
var cell = getCellAddress();
|
|
565
602
|
placeRef.current = cell;
|
|
@@ -596,7 +633,7 @@ var InputBox = function InputBox() {
|
|
|
596
633
|
onMouseUp: function onMouseUp(e) {
|
|
597
634
|
return e.stopPropagation();
|
|
598
635
|
}
|
|
599
|
-
}, firstSelection && !((
|
|
636
|
+
}, firstSelection && !((_m = context.rangeDialog) === null || _m === void 0 ? void 0 : _m.show) && (/*#__PURE__*/React.createElement("div", {
|
|
600
637
|
className: "luckysheet-cell-address-indicator",
|
|
601
638
|
style: getAddressIndicatorPosition()
|
|
602
639
|
}, wraperGetCell())), /*#__PURE__*/React.createElement("div", {
|
|
@@ -728,6 +728,8 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
|
|
|
728
728
|
conditionformat_equal_title: string;
|
|
729
729
|
conditionformat_textContains: string;
|
|
730
730
|
conditionformat_textContains_title: string;
|
|
731
|
+
conditionformat_empty: string;
|
|
732
|
+
conditionformat_empty_title: string;
|
|
731
733
|
conditionformat_occurrenceDate: string;
|
|
732
734
|
conditionformat_occurrenceDate_title: string;
|
|
733
735
|
conditionformat_duplicateValue: string;
|
|
@@ -830,6 +832,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
|
|
|
830
832
|
between2: string;
|
|
831
833
|
contain: string;
|
|
832
834
|
textContains: string;
|
|
835
|
+
empty: string;
|
|
833
836
|
duplicateValue: string;
|
|
834
837
|
uniqueValue: string;
|
|
835
838
|
top: string;
|
|
@@ -735,6 +735,8 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
735
735
|
conditionformat_equal_title: string;
|
|
736
736
|
conditionformat_textContains: string;
|
|
737
737
|
conditionformat_textContains_title: string;
|
|
738
|
+
conditionformat_empty: string;
|
|
739
|
+
conditionformat_empty_title: string;
|
|
738
740
|
conditionformat_occurrenceDate: string;
|
|
739
741
|
conditionformat_occurrenceDate_title: string;
|
|
740
742
|
conditionformat_duplicateValue: string;
|
|
@@ -837,6 +839,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
837
839
|
between2: string;
|
|
838
840
|
contain: string;
|
|
839
841
|
textContains: string;
|
|
842
|
+
empty: string;
|
|
840
843
|
duplicateValue: string;
|
|
841
844
|
uniqueValue: string;
|
|
842
845
|
top: string;
|
|
@@ -303,6 +303,10 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
303
303
|
text: "textContains",
|
|
304
304
|
value: "()",
|
|
305
305
|
label: "Text Contains"
|
|
306
|
+
}, {
|
|
307
|
+
text: "empty",
|
|
308
|
+
value: "",
|
|
309
|
+
label: "Empty"
|
|
306
310
|
}, {
|
|
307
311
|
text: "occurrenceDate",
|
|
308
312
|
value: conditionformat.yesterday,
|
|
@@ -343,7 +347,7 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
343
347
|
marginBottom: "16px"
|
|
344
348
|
}
|
|
345
349
|
}, matchedConditionFormatKey.map(function (key) {
|
|
346
|
-
var _a, _b;
|
|
350
|
+
var _a, _b, _c;
|
|
347
351
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
348
352
|
onClick: function onClick() {
|
|
349
353
|
var _a;
|
|
@@ -394,10 +398,10 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
394
398
|
}, /*#__PURE__*/_react.default.createElement("h3", {
|
|
395
399
|
className: "fortune-condition-rules__heading condition-list-type",
|
|
396
400
|
"data-testid": "condition-rules-heading-".concat(key)
|
|
397
|
-
}, conditionformat[allConditionFormats[key].conditionName], " "
|
|
401
|
+
}, conditionformat[allConditionFormats[key].conditionName], allConditionFormats[key].conditionName !== "empty" && " ".concat((_b = (_a = allConditionFormats[key].conditionValue) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : "")), /*#__PURE__*/_react.default.createElement("p", {
|
|
398
402
|
className: "fortune-condition-rules__para condition-list-range",
|
|
399
403
|
"data-testid": "condition-rules-para-".concat(key)
|
|
400
|
-
}, (
|
|
404
|
+
}, (_c = allConditionFormats[key].cellrange) === null || _c === void 0 ? void 0 : _c.map(function (range) {
|
|
401
405
|
var startCol = (0, _helper.numberToColumn)(range.column[0] + 1);
|
|
402
406
|
var endCol = (0, _helper.numberToColumn)(range.column[1] + 1);
|
|
403
407
|
var startRow = range.row[0] + 1;
|
|
@@ -476,6 +480,12 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
476
480
|
}, "Format cells if"), /*#__PURE__*/_react.default.createElement(_ui.Select, {
|
|
477
481
|
value: type,
|
|
478
482
|
onValueChange: function onValueChange(value) {
|
|
483
|
+
if (value === "empty" || type === "empty") {
|
|
484
|
+
setContext(function (ctx) {
|
|
485
|
+
ctx.conditionRules.rulesValue = "";
|
|
486
|
+
});
|
|
487
|
+
setEditConditionFormatValue(null);
|
|
488
|
+
}
|
|
479
489
|
setType(value);
|
|
480
490
|
}
|
|
481
491
|
}, /*#__PURE__*/_react.default.createElement(_ui.SelectTrigger, null, /*#__PURE__*/_react.default.createElement(_ui.SelectValue, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -813,7 +823,7 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
813
823
|
},
|
|
814
824
|
tabIndex: 0
|
|
815
825
|
}, button.cancel), editConditionFormatKey !== null ? (/*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
816
|
-
disabled: context.conditionRules.rulesValue === "",
|
|
826
|
+
disabled: context.conditionRules.rulesValue === "" && type !== "empty",
|
|
817
827
|
variant: "default",
|
|
818
828
|
style: {
|
|
819
829
|
minWidth: "80px"
|
|
@@ -823,7 +833,7 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
823
833
|
},
|
|
824
834
|
tabIndex: 0
|
|
825
835
|
}, "Update rule")) : (/*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
826
|
-
disabled: context.conditionRules.rulesValue === "",
|
|
836
|
+
disabled: context.conditionRules.rulesValue === "" && type !== "empty",
|
|
827
837
|
variant: "default",
|
|
828
838
|
style: {
|
|
829
839
|
minWidth: "80px"
|
|
@@ -29,47 +29,47 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
29
29
|
return __assign.apply(this, arguments);
|
|
30
30
|
};
|
|
31
31
|
var InputBox = function InputBox() {
|
|
32
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
33
|
-
var
|
|
34
|
-
context =
|
|
35
|
-
setContext =
|
|
36
|
-
refs =
|
|
32
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
33
|
+
var _o = (0, _react.useContext)(_context.default),
|
|
34
|
+
context = _o.context,
|
|
35
|
+
setContext = _o.setContext,
|
|
36
|
+
refs = _o.refs;
|
|
37
37
|
var inputRef = (0, _react.useRef)(null);
|
|
38
38
|
var lastKeyDownEventRef = (0, _react.useRef)(null);
|
|
39
39
|
var prevCellUpdate = (0, _usePrevious.default)(context.luckysheetCellUpdate);
|
|
40
40
|
var prevSheetId = (0, _usePrevious.default)(context.currentSheetId);
|
|
41
|
-
var _o = (0, _react.useState)(false),
|
|
42
|
-
isHidenRC = _o[0],
|
|
43
|
-
setIsHidenRC = _o[1];
|
|
44
41
|
var _p = (0, _react.useState)(false),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var _q = (0, _react.useState)(
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
isHidenRC = _p[0],
|
|
43
|
+
setIsHidenRC = _p[1];
|
|
44
|
+
var _q = (0, _react.useState)(false),
|
|
45
|
+
isInputBoxActive = _q[0],
|
|
46
|
+
setIsInputBoxActive = _q[1];
|
|
50
47
|
var _r = (0, _react.useState)(""),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var _s = (0, _react.useState)(
|
|
48
|
+
activeCell = _r[0],
|
|
49
|
+
setActiveCell = _r[1];
|
|
50
|
+
var _s = (0, _react.useState)(""),
|
|
51
|
+
activeRefCell = _s[0],
|
|
52
|
+
setActiveRefCell = _s[1];
|
|
53
|
+
var _t = (0, _react.useState)({
|
|
54
54
|
left: 0,
|
|
55
55
|
top: 0
|
|
56
56
|
}),
|
|
57
|
-
frozenPosition =
|
|
58
|
-
setFrozenPosition =
|
|
57
|
+
frozenPosition = _t[0],
|
|
58
|
+
setFrozenPosition = _t[1];
|
|
59
59
|
var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
|
|
60
|
-
var
|
|
61
|
-
firstSelectionActiveCell =
|
|
62
|
-
setFirstSelectionActiveCell =
|
|
63
|
-
var
|
|
64
|
-
commaCount =
|
|
65
|
-
setCommaCount =
|
|
60
|
+
var _u = (0, _react.useState)({}),
|
|
61
|
+
firstSelectionActiveCell = _u[0],
|
|
62
|
+
setFirstSelectionActiveCell = _u[1];
|
|
63
|
+
var _v = (0, _react.useState)(0),
|
|
64
|
+
commaCount = _v[0],
|
|
65
|
+
setCommaCount = _v[1];
|
|
66
66
|
var hideFormulaHintLocal = localStorage.getItem("formulaMore") === "true";
|
|
67
|
-
var
|
|
68
|
-
showFormulaHint =
|
|
69
|
-
setShowFormulaHint =
|
|
70
|
-
var
|
|
71
|
-
showSearchHint =
|
|
72
|
-
setShowSearchHint =
|
|
67
|
+
var _w = (0, _react.useState)(!hideFormulaHintLocal),
|
|
68
|
+
showFormulaHint = _w[0],
|
|
69
|
+
setShowFormulaHint = _w[1];
|
|
70
|
+
var _x = (0, _react.useState)(false),
|
|
71
|
+
showSearchHint = _x[0],
|
|
72
|
+
setShowSearchHint = _x[1];
|
|
73
73
|
var row_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
|
|
74
74
|
var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
|
|
75
75
|
var preText = (0, _react.useRef)("");
|
|
@@ -77,9 +77,9 @@ var InputBox = function InputBox() {
|
|
|
77
77
|
var isComposingRef = (0, _react.useRef)(false);
|
|
78
78
|
var ZWSP = "\u200B";
|
|
79
79
|
var inputBoxInnerRef = (0, _react.useRef)(null);
|
|
80
|
-
var
|
|
81
|
-
linkSelectionHighlightRects =
|
|
82
|
-
setLinkSelectionHighlightRects =
|
|
80
|
+
var _y = (0, _react.useState)([]),
|
|
81
|
+
linkSelectionHighlightRects = _y[0],
|
|
82
|
+
setLinkSelectionHighlightRects = _y[1];
|
|
83
83
|
var ensureNotEmpty = function ensureNotEmpty() {
|
|
84
84
|
var el = inputRef.current;
|
|
85
85
|
if (!el) return;
|
|
@@ -138,6 +138,8 @@ var InputBox = function InputBox() {
|
|
|
138
138
|
var flowdata = (0, _fortuneCore.getFlowdata)(context);
|
|
139
139
|
var cell = (_a = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row_index]) === null || _a === void 0 ? void 0 : _a[col_index];
|
|
140
140
|
var value_1 = "";
|
|
141
|
+
var wasOverwrite = refs.globalCache.overwriteCell;
|
|
142
|
+
var overwriteFirstChar = refs.globalCache.overwriteCellFirstChar;
|
|
141
143
|
if (cell && !refs.globalCache.overwriteCell) {
|
|
142
144
|
if ((0, _fortuneCore.isInlineStringCell)(cell)) {
|
|
143
145
|
value_1 = (0, _fortuneCore.getInlineStringHTML)(row_index, col_index, flowdata);
|
|
@@ -154,9 +156,15 @@ var InputBox = function InputBox() {
|
|
|
154
156
|
}
|
|
155
157
|
}
|
|
156
158
|
refs.globalCache.overwriteCell = false;
|
|
157
|
-
|
|
159
|
+
delete refs.globalCache.overwriteCellFirstChar;
|
|
160
|
+
if (wasOverwrite && inputRef.current) {
|
|
161
|
+
inputRef.current.innerText = overwriteFirstChar !== null && overwriteFirstChar !== void 0 ? overwriteFirstChar : "";
|
|
162
|
+
if (overwriteFirstChar) {
|
|
163
|
+
(0, _fortuneCore.moveToEnd)(inputRef.current);
|
|
164
|
+
}
|
|
165
|
+
} else if (!refs.globalCache.ignoreWriteCell && inputRef.current && value_1) {
|
|
158
166
|
inputRef.current.innerHTML = (0, _fortuneCore.escapeHTMLTag)((0, _fortuneCore.escapeScriptTag)(value_1));
|
|
159
|
-
} else if (!refs.globalCache.ignoreWriteCell && inputRef.current && !value_1) {
|
|
167
|
+
} else if (!refs.globalCache.ignoreWriteCell && inputRef.current && !value_1 && !wasOverwrite) {
|
|
160
168
|
var valueD = (0, _fortuneCore.getCellValue)(row_index, col_index, flowdata, "f");
|
|
161
169
|
inputRef.current.innerText = valueD;
|
|
162
170
|
}
|
|
@@ -279,6 +287,54 @@ var InputBox = function InputBox() {
|
|
|
279
287
|
event.stopPropagation();
|
|
280
288
|
event.preventDefault();
|
|
281
289
|
};
|
|
290
|
+
(0, _react.useEffect)(function () {
|
|
291
|
+
var _a, _b;
|
|
292
|
+
var selection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
|
|
293
|
+
var editor = inputRef.current;
|
|
294
|
+
if (!selection || !editor || !isInputBoxActive || ((_b = context.rangeDialog) === null || _b === void 0 ? void 0 : _b.show)) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
var rowSel = selection.row;
|
|
298
|
+
var colSel = selection.column;
|
|
299
|
+
if (!rowSel || !colSel || rowSel.length < 2 || colSel.length < 2) return;
|
|
300
|
+
var rowStart = Math.min(rowSel[0], rowSel[1]);
|
|
301
|
+
var rowEnd = Math.max(rowSel[0], rowSel[1]);
|
|
302
|
+
var colStart = Math.min(colSel[0], colSel[1]);
|
|
303
|
+
var colEnd = Math.max(colSel[0], colSel[1]);
|
|
304
|
+
var startRef = "".concat((0, _fortuneCore.indexToColumnChar)(colStart)).concat(rowStart + 1);
|
|
305
|
+
var endRef = "".concat((0, _fortuneCore.indexToColumnChar)(colEnd)).concat(rowEnd + 1);
|
|
306
|
+
var refText = startRef === endRef ? startRef : "".concat(startRef, ":").concat(endRef);
|
|
307
|
+
var editorText = editor.innerText || "";
|
|
308
|
+
if (!editorText.startsWith("=")) return;
|
|
309
|
+
var spans = editor.querySelectorAll("span");
|
|
310
|
+
var lastSpan = spans[spans.length - 1];
|
|
311
|
+
var lastSpanText = (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText) || "";
|
|
312
|
+
var isA1RangePattern = /^[a-zA-Z]+\d+:[a-zA-Z]+\d+$/.test(lastSpanText);
|
|
313
|
+
var notFunctionInit = !editorText.includes("(");
|
|
314
|
+
var refNotAllowed = lastSpanText.includes(")") || notFunctionInit && /^[a-zA-Z]+$/.test(lastSpanText) && !_lodash.default.includes(["="], lastSpanText);
|
|
315
|
+
var shouldHandleRef = (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.classList.contains("fortune-formula-functionrange-cell")) || (0, _helper.isLetterNumberPattern)(lastSpanText) || isA1RangePattern || (lastSpanText === "(" || lastSpanText === "," || lastSpanText.includes(":") || lastSpanText === "=") && !lastSpanText.includes('"') && !refNotAllowed && !/^[a-zA-Z]+$/.test(lastSpanText);
|
|
316
|
+
if (!shouldHandleRef) return;
|
|
317
|
+
var refSpanHtml = "<span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:#c1232b;\">".concat(refText, "</span>");
|
|
318
|
+
if (lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.classList.contains("fortune-formula-functionrange-cell")) {
|
|
319
|
+
if (lastSpan.textContent !== refText) lastSpan.textContent = refText;
|
|
320
|
+
setTimeout(function () {
|
|
321
|
+
return (0, _helper.moveCursorToEnd)(editor);
|
|
322
|
+
}, 1);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if ((0, _helper.isLetterNumberPattern)(lastSpanText) || isA1RangePattern) {
|
|
326
|
+
var htmlR = (0, _helper.removeLastSpan)(editor.innerHTML);
|
|
327
|
+
editor.innerHTML = "".concat(htmlR).concat(refSpanHtml);
|
|
328
|
+
setTimeout(function () {
|
|
329
|
+
return (0, _helper.moveCursorToEnd)(editor);
|
|
330
|
+
}, 1);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
editor.innerHTML = "".concat(editor.innerHTML).concat(refSpanHtml);
|
|
334
|
+
setTimeout(function () {
|
|
335
|
+
return (0, _helper.moveCursorToEnd)(editor);
|
|
336
|
+
}, 1);
|
|
337
|
+
}, [context.luckysheet_select_save, (_d = context.rangeDialog) === null || _d === void 0 ? void 0 : _d.show, isInputBoxActive]);
|
|
282
338
|
var onKeyDown = (0, _react.useCallback)(function (e) {
|
|
283
339
|
var _a, _b;
|
|
284
340
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
@@ -311,37 +367,18 @@ var InputBox = function InputBox() {
|
|
|
311
367
|
}, 5);
|
|
312
368
|
}
|
|
313
369
|
}
|
|
314
|
-
var
|
|
315
|
-
if (e.key === "
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
if ((e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight") && !((0, _helper.getCursorPosition)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) !== (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length) && e.key === "ArrowRight")) {
|
|
325
|
-
var parser = new DOMParser();
|
|
326
|
-
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");
|
|
327
|
-
var spans = doc.querySelectorAll("span");
|
|
328
|
-
var lastSpan = spans[spans.length - 1];
|
|
329
|
-
var notFunctionInit = !((_b = document.getElementById("luckysheet-rich-text-editor")) === null || _b === void 0 ? void 0 : _b.innerText.includes("("));
|
|
330
|
-
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);
|
|
331
|
-
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)) {
|
|
332
|
-
allowListNavigation = false;
|
|
333
|
-
inputRef.current.innerHTML = "".concat(inputRef.current.innerHTML, "<span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:#c1232b;\">").concat(refCell, "</span>");
|
|
334
|
-
setTimeout(function () {
|
|
335
|
-
(0, _helper.moveCursorToEnd)(inputRef.current);
|
|
336
|
-
}, 1);
|
|
337
|
-
}
|
|
338
|
-
if ((0, _helper.isLetterNumberPattern)(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText)) {
|
|
370
|
+
var isArrowKey = e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight";
|
|
371
|
+
if (isArrowKey && !((0, _helper.getCursorPosition)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) !== (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length) && e.key === "ArrowRight")) {
|
|
372
|
+
var editorText = ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText) || "";
|
|
373
|
+
var lastSpanText = getLastInputSpanText() || "";
|
|
374
|
+
var isA1RangePattern = /^[a-zA-Z]+\d+:[a-zA-Z]+\d+$/.test(lastSpanText);
|
|
375
|
+
var notFunctionInit = !editorText.includes("(");
|
|
376
|
+
var refNotAllowed = lastSpanText.includes(")") || notFunctionInit && /^[a-zA-Z]+$/.test(lastSpanText) && !_lodash.default.includes(["="], lastSpanText);
|
|
377
|
+
var shouldTreatAsRefNavigation = editorText.startsWith("=") && (Boolean((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.querySelector(".fortune-formula-functionrange-cell")) || (0, _helper.isLetterNumberPattern)(lastSpanText) || isA1RangePattern || (lastSpanText === "(" || lastSpanText === "," || lastSpanText.includes(":") || lastSpanText === "=") && !lastSpanText.includes('"') && !refNotAllowed && !/^[a-zA-Z]+$/.test(lastSpanText));
|
|
378
|
+
if (shouldTreatAsRefNavigation) {
|
|
339
379
|
allowListNavigation = false;
|
|
340
|
-
var htmlR = (0, _helper.removeLastSpan)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerHTML);
|
|
341
|
-
inputRef.current.innerHTML = "".concat(htmlR, "<span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:#c1232b;\">").concat(refCell, "</span>");
|
|
342
|
-
(0, _helper.moveCursorToEnd)(inputRef.current);
|
|
343
380
|
setTimeout(function () {
|
|
344
|
-
(0, _helper.moveCursorToEnd)(inputRef.current);
|
|
381
|
+
if (inputRef.current) (0, _helper.moveCursorToEnd)(inputRef.current);
|
|
345
382
|
}, 1);
|
|
346
383
|
}
|
|
347
384
|
}
|
|
@@ -399,7 +436,7 @@ var InputBox = function InputBox() {
|
|
|
399
436
|
}
|
|
400
437
|
e.preventDefault();
|
|
401
438
|
}
|
|
402
|
-
}, [clearSearchItemActiveClass, context.luckysheetCellUpdate.length, selectActiveFormula, setContext
|
|
439
|
+
}, [clearSearchItemActiveClass, context.luckysheetCellUpdate.length, selectActiveFormula, setContext]);
|
|
403
440
|
var handleHideShowHint = function handleHideShowHint() {
|
|
404
441
|
var _a, _b, _c, _d;
|
|
405
442
|
var searchElFx = (_a = document.getElementsByClassName("fx-search")) === null || _a === void 0 ? void 0 : _a[0];
|
|
@@ -489,7 +526,7 @@ var InputBox = function InputBox() {
|
|
|
489
526
|
zIndex: _lodash.default.isEmpty(context.luckysheetCellUpdate) ? -1 : 19,
|
|
490
527
|
display: "block"
|
|
491
528
|
};
|
|
492
|
-
}, [firstSelection, (
|
|
529
|
+
}, [firstSelection, (_e = context.rangeDialog) === null || _e === void 0 ? void 0 : _e.show, context.luckysheetCellUpdate, refs.cellArea, isInputBoxActive, frozenPosition, context.scrollLeft, context.scrollTop]);
|
|
493
530
|
(0, _react.useEffect)(function () {
|
|
494
531
|
var _a;
|
|
495
532
|
if (firstSelection && !((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show) && !isInputBoxActive && !_lodash.default.isEmpty(context.luckysheetCellUpdate)) {
|
|
@@ -505,7 +542,7 @@ var InputBox = function InputBox() {
|
|
|
505
542
|
setIsInputBoxActive(true);
|
|
506
543
|
}
|
|
507
544
|
}
|
|
508
|
-
}, [firstSelection, (
|
|
545
|
+
}, [firstSelection, (_f = context.rangeDialog) === null || _f === void 0 ? void 0 : _f.show, context.luckysheetCellUpdate, isInputBoxActive, context.scrollLeft, context.scrollTop, refs.cellArea]);
|
|
509
546
|
var getAddressIndicatorPosition = (0, _react.useCallback)(function () {
|
|
510
547
|
var _a;
|
|
511
548
|
if (!firstSelection || ((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show)) {
|
|
@@ -518,7 +555,7 @@ var InputBox = function InputBox() {
|
|
|
518
555
|
left: "0",
|
|
519
556
|
display: "block"
|
|
520
557
|
};
|
|
521
|
-
}, [firstSelection, (
|
|
558
|
+
}, [firstSelection, (_g = context.rangeDialog) === null || _g === void 0 ? void 0 : _g.show]);
|
|
522
559
|
var getCellAddress = (0, _react.useCallback)(function () {
|
|
523
560
|
if (!firstSelection) return "";
|
|
524
561
|
var rowIndex = firstSelection.row_focus || 0;
|
|
@@ -568,7 +605,7 @@ var InputBox = function InputBox() {
|
|
|
568
605
|
};
|
|
569
606
|
});
|
|
570
607
|
setLinkSelectionHighlightRects(relative);
|
|
571
|
-
}, [(
|
|
608
|
+
}, [(_h = context.linkCard) === null || _h === void 0 ? void 0 : _h.applyToSelection, (_j = context.linkCard) === null || _j === void 0 ? void 0 : _j.selectionOffsets, (_k = context.linkCard) === null || _k === void 0 ? void 0 : _k.r, (_l = context.linkCard) === null || _l === void 0 ? void 0 : _l.c, context.luckysheetCellUpdate]);
|
|
572
609
|
var wraperGetCell = function wraperGetCell() {
|
|
573
610
|
var cell = getCellAddress();
|
|
574
611
|
placeRef.current = cell;
|
|
@@ -605,7 +642,7 @@ var InputBox = function InputBox() {
|
|
|
605
642
|
onMouseUp: function onMouseUp(e) {
|
|
606
643
|
return e.stopPropagation();
|
|
607
644
|
}
|
|
608
|
-
}, firstSelection && !((
|
|
645
|
+
}, firstSelection && !((_m = context.rangeDialog) === null || _m === void 0 ? void 0 : _m.show) && (/*#__PURE__*/_react.default.createElement("div", {
|
|
609
646
|
className: "luckysheet-cell-address-indicator",
|
|
610
647
|
style: getAddressIndicatorPosition()
|
|
611
648
|
}, wraperGetCell())), /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -728,6 +728,8 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
|
|
|
728
728
|
conditionformat_equal_title: string;
|
|
729
729
|
conditionformat_textContains: string;
|
|
730
730
|
conditionformat_textContains_title: string;
|
|
731
|
+
conditionformat_empty: string;
|
|
732
|
+
conditionformat_empty_title: string;
|
|
731
733
|
conditionformat_occurrenceDate: string;
|
|
732
734
|
conditionformat_occurrenceDate_title: string;
|
|
733
735
|
conditionformat_duplicateValue: string;
|
|
@@ -830,6 +832,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
|
|
|
830
832
|
between2: string;
|
|
831
833
|
contain: string;
|
|
832
834
|
textContains: string;
|
|
835
|
+
empty: string;
|
|
833
836
|
duplicateValue: string;
|
|
834
837
|
uniqueValue: string;
|
|
835
838
|
top: string;
|
|
@@ -735,6 +735,8 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
735
735
|
conditionformat_equal_title: string;
|
|
736
736
|
conditionformat_textContains: string;
|
|
737
737
|
conditionformat_textContains_title: string;
|
|
738
|
+
conditionformat_empty: string;
|
|
739
|
+
conditionformat_empty_title: string;
|
|
738
740
|
conditionformat_occurrenceDate: string;
|
|
739
741
|
conditionformat_occurrenceDate_title: string;
|
|
740
742
|
conditionformat_duplicateValue: string;
|
|
@@ -837,6 +839,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
837
839
|
between2: string;
|
|
838
840
|
contain: string;
|
|
839
841
|
textContains: string;
|
|
842
|
+
empty: string;
|
|
840
843
|
duplicateValue: string;
|
|
841
844
|
uniqueValue: string;
|
|
842
845
|
top: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fileverse-dev/fortune-react",
|
|
3
|
-
"version": "1.3.10-input",
|
|
3
|
+
"version": "1.3.10-input-2",
|
|
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.3.10-input",
|
|
19
|
+
"@fileverse-dev/fortune-core": "1.3.10-input-2",
|
|
20
20
|
"@fileverse/ui": "5.0.0",
|
|
21
21
|
"@tippyjs/react": "^4.2.6",
|
|
22
22
|
"@types/regenerator-runtime": "^0.13.6",
|