@fileverse-dev/fortune-react 1.2.86-pinyin-2 → 1.2.86-pinyin-3
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.
|
@@ -65,7 +65,24 @@ var InputBox = function InputBox() {
|
|
|
65
65
|
var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
|
|
66
66
|
var preText = useRef("");
|
|
67
67
|
var placeRef = useRef("");
|
|
68
|
+
var rootRef = useRef(null);
|
|
68
69
|
var isComposingRef = useRef(false);
|
|
70
|
+
var ensureNotEmpty = function ensureNotEmpty() {
|
|
71
|
+
var el = rootRef.current;
|
|
72
|
+
if (!el) return;
|
|
73
|
+
if (el.textContent === "") {
|
|
74
|
+
el.innerHTML = "\u200B";
|
|
75
|
+
placeCursorAtEnd(el);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var placeCursorAtEnd = function placeCursorAtEnd(el) {
|
|
79
|
+
var range = document.createRange();
|
|
80
|
+
var sel = window.getSelection();
|
|
81
|
+
range.selectNodeContents(el);
|
|
82
|
+
range.collapse(false);
|
|
83
|
+
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
|
|
84
|
+
sel === null || sel === void 0 ? void 0 : sel.addRange(range);
|
|
85
|
+
};
|
|
69
86
|
var handleShowFormulaHint = function handleShowFormulaHint() {
|
|
70
87
|
localStorage.setItem("formulaMore", String(showFormulaHint));
|
|
71
88
|
setShowFormulaHint(!showFormulaHint);
|
|
@@ -256,7 +273,10 @@ var InputBox = function InputBox() {
|
|
|
256
273
|
};
|
|
257
274
|
var onKeyDown = useCallback(function (e) {
|
|
258
275
|
var _a, _b;
|
|
259
|
-
if (isComposingRef.current || !inputRef.current)
|
|
276
|
+
if (isComposingRef.current || !inputRef.current) {
|
|
277
|
+
ensureNotEmpty();
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
260
280
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
261
281
|
preText.current = inputRef.current.innerText;
|
|
262
282
|
if (e.metaKey) {
|
|
@@ -579,6 +599,7 @@ var InputBox = function InputBox() {
|
|
|
579
599
|
console.log("onCompositionUpdate", e.currentTarget.innerText);
|
|
580
600
|
},
|
|
581
601
|
onCompositionEnd: function onCompositionEnd(e) {
|
|
602
|
+
ensureNotEmpty();
|
|
582
603
|
var rowIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus) || 0;
|
|
583
604
|
var colIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus) || 0;
|
|
584
605
|
console.log("onCompositionEnd", e.currentTarget.innerText, getCellAddress(), rowIndex, colIndex, setCellValue);
|
|
@@ -600,6 +621,7 @@ var InputBox = function InputBox() {
|
|
|
600
621
|
}
|
|
601
622
|
},
|
|
602
623
|
innerRef: function innerRef(e) {
|
|
624
|
+
rootRef.current = e;
|
|
603
625
|
if (isComposingRef.current) {
|
|
604
626
|
inputRef.current = null;
|
|
605
627
|
refs.cellInput.current = null;
|
|
@@ -74,7 +74,24 @@ var InputBox = function InputBox() {
|
|
|
74
74
|
var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
|
|
75
75
|
var preText = (0, _react.useRef)("");
|
|
76
76
|
var placeRef = (0, _react.useRef)("");
|
|
77
|
+
var rootRef = (0, _react.useRef)(null);
|
|
77
78
|
var isComposingRef = (0, _react.useRef)(false);
|
|
79
|
+
var ensureNotEmpty = function ensureNotEmpty() {
|
|
80
|
+
var el = rootRef.current;
|
|
81
|
+
if (!el) return;
|
|
82
|
+
if (el.textContent === "") {
|
|
83
|
+
el.innerHTML = "\u200B";
|
|
84
|
+
placeCursorAtEnd(el);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var placeCursorAtEnd = function placeCursorAtEnd(el) {
|
|
88
|
+
var range = document.createRange();
|
|
89
|
+
var sel = window.getSelection();
|
|
90
|
+
range.selectNodeContents(el);
|
|
91
|
+
range.collapse(false);
|
|
92
|
+
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
|
|
93
|
+
sel === null || sel === void 0 ? void 0 : sel.addRange(range);
|
|
94
|
+
};
|
|
78
95
|
var handleShowFormulaHint = function handleShowFormulaHint() {
|
|
79
96
|
localStorage.setItem("formulaMore", String(showFormulaHint));
|
|
80
97
|
setShowFormulaHint(!showFormulaHint);
|
|
@@ -265,7 +282,10 @@ var InputBox = function InputBox() {
|
|
|
265
282
|
};
|
|
266
283
|
var onKeyDown = (0, _react.useCallback)(function (e) {
|
|
267
284
|
var _a, _b;
|
|
268
|
-
if (isComposingRef.current || !inputRef.current)
|
|
285
|
+
if (isComposingRef.current || !inputRef.current) {
|
|
286
|
+
ensureNotEmpty();
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
269
289
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
270
290
|
preText.current = inputRef.current.innerText;
|
|
271
291
|
if (e.metaKey) {
|
|
@@ -588,6 +608,7 @@ var InputBox = function InputBox() {
|
|
|
588
608
|
console.log("onCompositionUpdate", e.currentTarget.innerText);
|
|
589
609
|
},
|
|
590
610
|
onCompositionEnd: function onCompositionEnd(e) {
|
|
611
|
+
ensureNotEmpty();
|
|
591
612
|
var rowIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus) || 0;
|
|
592
613
|
var colIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus) || 0;
|
|
593
614
|
console.log("onCompositionEnd", e.currentTarget.innerText, getCellAddress(), rowIndex, colIndex, _fortuneCore.setCellValue);
|
|
@@ -609,6 +630,7 @@ var InputBox = function InputBox() {
|
|
|
609
630
|
}
|
|
610
631
|
},
|
|
611
632
|
innerRef: function innerRef(e) {
|
|
633
|
+
rootRef.current = e;
|
|
612
634
|
if (isComposingRef.current) {
|
|
613
635
|
inputRef.current = null;
|
|
614
636
|
refs.cellInput.current = null;
|