@fileverse-dev/fortune-react 1.2.86-pinyin → 1.2.86-pinyin-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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFlowdata, cancelNormalSelected, getCellValue, updateCell, getInlineStringNoStyle, isInlineStringCell, escapeScriptTag, moveHighlightCell, handleFormulaInput, rangeHightlightselected, valueShowEs, isShowHidenCR, escapeHTMLTag, isAllowEdit
|
|
1
|
+
import { getFlowdata, cancelNormalSelected, getCellValue, updateCell, getInlineStringNoStyle, isInlineStringCell, escapeScriptTag, moveHighlightCell, handleFormulaInput, rangeHightlightselected, valueShowEs, isShowHidenCR, escapeHTMLTag, isAllowEdit } from "@fileverse-dev/fortune-core";
|
|
2
2
|
import React, { useContext, useState, useCallback, useEffect, useRef, useMemo } from "react";
|
|
3
3
|
import "./index.css";
|
|
4
4
|
import _ from "lodash";
|
|
@@ -35,7 +35,6 @@ var FxEditor = function FxEditor() {
|
|
|
35
35
|
var prevFirstSelection = usePrevious(firstSelection);
|
|
36
36
|
var prevSheetId = usePrevious(context.currentSheetId);
|
|
37
37
|
var recentText = useRef("");
|
|
38
|
-
var isComposingRef = useRef(false);
|
|
39
38
|
var handleShowFormulaHint = function handleShowFormulaHint() {
|
|
40
39
|
localStorage.setItem("formulaMore", String(showFormulaHint));
|
|
41
40
|
setShowFormulaHint(!showFormulaHint);
|
|
@@ -69,9 +68,6 @@ var FxEditor = function FxEditor() {
|
|
|
69
68
|
}, [context.luckysheetfile, context.currentSheetId, context.luckysheet_select_save]);
|
|
70
69
|
var onFocus = useCallback(function () {
|
|
71
70
|
var _a, _b;
|
|
72
|
-
if (isComposingRef.current) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
71
|
if (context.allowEdit === false) {
|
|
76
72
|
return;
|
|
77
73
|
}
|
|
@@ -194,13 +190,8 @@ var FxEditor = function FxEditor() {
|
|
|
194
190
|
switch (key) {
|
|
195
191
|
case "Enter":
|
|
196
192
|
{
|
|
197
|
-
if (isComposingRef.current) {
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
193
|
var lastCellUpdate = _.clone(draftCtx.luckysheetCellUpdate);
|
|
201
|
-
|
|
202
|
-
updateCell(draftCtx, draftCtx.luckysheetCellUpdate[0], draftCtx.luckysheetCellUpdate[1], refs.fxInput.current);
|
|
203
|
-
}
|
|
194
|
+
updateCell(draftCtx, draftCtx.luckysheetCellUpdate[0], draftCtx.luckysheetCellUpdate[1], refs.fxInput.current);
|
|
204
195
|
draftCtx.luckysheet_select_save = [{
|
|
205
196
|
row: [lastCellUpdate[0], lastCellUpdate[0]],
|
|
206
197
|
column: [lastCellUpdate[1], lastCellUpdate[1]],
|
|
@@ -222,12 +213,12 @@ var FxEditor = function FxEditor() {
|
|
|
222
213
|
}
|
|
223
214
|
case "ArrowLeft":
|
|
224
215
|
{
|
|
225
|
-
|
|
216
|
+
rangeHightlightselected(draftCtx, refs.fxInput.current);
|
|
226
217
|
break;
|
|
227
218
|
}
|
|
228
219
|
case "ArrowRight":
|
|
229
220
|
{
|
|
230
|
-
|
|
221
|
+
rangeHightlightselected(draftCtx, refs.fxInput.current);
|
|
231
222
|
break;
|
|
232
223
|
}
|
|
233
224
|
default:
|
|
@@ -257,7 +248,6 @@ var FxEditor = function FxEditor() {
|
|
|
257
248
|
};
|
|
258
249
|
var onChange = useCallback(function () {
|
|
259
250
|
var _a, _b, _c;
|
|
260
|
-
if (isComposingRef.current) return;
|
|
261
251
|
if (context.isFlvReadOnly) return;
|
|
262
252
|
handleHideShowHint();
|
|
263
253
|
if (((_b = (_a = refs.fxInput) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.innerText.includes("=")) && /^=?[A-Za-z]*$/.test(getLastInputSpanText())) {
|
|
@@ -353,25 +343,6 @@ var FxEditor = function FxEditor() {
|
|
|
353
343
|
ref: inputContainerRef,
|
|
354
344
|
className: "fortune-fx-input-container"
|
|
355
345
|
}, /*#__PURE__*/React.createElement(ContentEditable, {
|
|
356
|
-
onCompositionStart: function onCompositionStart() {
|
|
357
|
-
isComposingRef.current = true;
|
|
358
|
-
console.log("onCompositionStart");
|
|
359
|
-
},
|
|
360
|
-
onCompositionUpdate: function onCompositionUpdate(e) {
|
|
361
|
-
window.CompositData = e.currentTarget.innerText;
|
|
362
|
-
isComposingRef.current = true;
|
|
363
|
-
console.log("onCompositionUpdate", e.currentTarget.innerText);
|
|
364
|
-
},
|
|
365
|
-
onCompositionEnd: function onCompositionEnd(e) {
|
|
366
|
-
var rowIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus) || 0;
|
|
367
|
-
var colIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus) || 0;
|
|
368
|
-
window.CompositData = e.currentTarget.innerText;
|
|
369
|
-
setContext(function (draftCtx) {
|
|
370
|
-
setCellValue(draftCtx, rowIndex, colIndex, null, window.CompositData);
|
|
371
|
-
window.CompositData = "";
|
|
372
|
-
});
|
|
373
|
-
isComposingRef.current = false;
|
|
374
|
-
},
|
|
375
346
|
onMouseUp: function onMouseUp() {
|
|
376
347
|
var _a;
|
|
377
348
|
handleHideShowHint();
|
|
@@ -379,10 +350,6 @@ var FxEditor = function FxEditor() {
|
|
|
379
350
|
setCommaCount(currentCommaCount);
|
|
380
351
|
},
|
|
381
352
|
innerRef: function innerRef(e) {
|
|
382
|
-
if (isComposingRef.current) {
|
|
383
|
-
refs.fxInput.current = null;
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
353
|
refs.fxInput.current = e;
|
|
387
354
|
},
|
|
388
355
|
className: "fortune-fx-input",
|
|
@@ -239,7 +239,7 @@ var InputBox = function InputBox() {
|
|
|
239
239
|
}, [getActiveFormula, insertSelectedFormula]);
|
|
240
240
|
var selectActiveFormulaOnClick = useCallback(function (e) {
|
|
241
241
|
var _a, _b;
|
|
242
|
-
if (isComposingRef.current) return;
|
|
242
|
+
if (isComposingRef.current || !inputRef.current) return;
|
|
243
243
|
if (e.target.className.includes("sign-fortune")) return;
|
|
244
244
|
preText.current = inputRef.current.innerText;
|
|
245
245
|
var formulaName = (_b = (_a = getActiveFormula()) === null || _a === void 0 ? void 0 : _a.querySelector(".luckysheet-formula-search-func")) === null || _b === void 0 ? void 0 : _b.textContent;
|
|
@@ -256,7 +256,7 @@ var InputBox = function InputBox() {
|
|
|
256
256
|
};
|
|
257
257
|
var onKeyDown = useCallback(function (e) {
|
|
258
258
|
var _a, _b;
|
|
259
|
-
if (isComposingRef.current) return;
|
|
259
|
+
if (isComposingRef.current || !inputRef.current) return;
|
|
260
260
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
261
261
|
preText.current = inputRef.current.innerText;
|
|
262
262
|
if (e.metaKey) {
|
|
@@ -274,8 +274,10 @@ var InputBox = function InputBox() {
|
|
|
274
274
|
stopPropagation(e);
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
if (!isComposingRef.current) {
|
|
278
|
+
var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
279
|
+
setCommaCount(currentCommaCount);
|
|
280
|
+
}
|
|
279
281
|
var allowListNavigation = true;
|
|
280
282
|
if ((e.key === "Delete" || e.key === "Backspace") && getCursorPosition(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length)) {
|
|
281
283
|
setTimeout(function () {
|
|
@@ -402,8 +404,10 @@ var InputBox = function InputBox() {
|
|
|
402
404
|
} else {
|
|
403
405
|
setShowSearchHint(false);
|
|
404
406
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
+
if (!isComposingRef.current) {
|
|
408
|
+
var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
409
|
+
setCommaCount(currentCommaCount);
|
|
410
|
+
}
|
|
407
411
|
var e = lastKeyDownEventRef.current;
|
|
408
412
|
if (!e) return;
|
|
409
413
|
var kcode = e.keyCode;
|
|
@@ -590,8 +594,10 @@ var InputBox = function InputBox() {
|
|
|
590
594
|
return;
|
|
591
595
|
}
|
|
592
596
|
handleHideShowHint();
|
|
593
|
-
|
|
594
|
-
|
|
597
|
+
if (!isComposingRef.current) {
|
|
598
|
+
var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
599
|
+
setCommaCount(currentCommaCount);
|
|
600
|
+
}
|
|
595
601
|
},
|
|
596
602
|
innerRef: function innerRef(e) {
|
|
597
603
|
if (isComposingRef.current) {
|
|
@@ -44,7 +44,6 @@ var FxEditor = function FxEditor() {
|
|
|
44
44
|
var prevFirstSelection = (0, _usePrevious.default)(firstSelection);
|
|
45
45
|
var prevSheetId = (0, _usePrevious.default)(context.currentSheetId);
|
|
46
46
|
var recentText = (0, _react.useRef)("");
|
|
47
|
-
var isComposingRef = (0, _react.useRef)(false);
|
|
48
47
|
var handleShowFormulaHint = function handleShowFormulaHint() {
|
|
49
48
|
localStorage.setItem("formulaMore", String(showFormulaHint));
|
|
50
49
|
setShowFormulaHint(!showFormulaHint);
|
|
@@ -78,9 +77,6 @@ var FxEditor = function FxEditor() {
|
|
|
78
77
|
}, [context.luckysheetfile, context.currentSheetId, context.luckysheet_select_save]);
|
|
79
78
|
var onFocus = (0, _react.useCallback)(function () {
|
|
80
79
|
var _a, _b;
|
|
81
|
-
if (isComposingRef.current) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
80
|
if (context.allowEdit === false) {
|
|
85
81
|
return;
|
|
86
82
|
}
|
|
@@ -203,13 +199,8 @@ var FxEditor = function FxEditor() {
|
|
|
203
199
|
switch (key) {
|
|
204
200
|
case "Enter":
|
|
205
201
|
{
|
|
206
|
-
if (isComposingRef.current) {
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
202
|
var lastCellUpdate = _lodash.default.clone(draftCtx.luckysheetCellUpdate);
|
|
210
|
-
|
|
211
|
-
(0, _fortuneCore.updateCell)(draftCtx, draftCtx.luckysheetCellUpdate[0], draftCtx.luckysheetCellUpdate[1], refs.fxInput.current);
|
|
212
|
-
}
|
|
203
|
+
(0, _fortuneCore.updateCell)(draftCtx, draftCtx.luckysheetCellUpdate[0], draftCtx.luckysheetCellUpdate[1], refs.fxInput.current);
|
|
213
204
|
draftCtx.luckysheet_select_save = [{
|
|
214
205
|
row: [lastCellUpdate[0], lastCellUpdate[0]],
|
|
215
206
|
column: [lastCellUpdate[1], lastCellUpdate[1]],
|
|
@@ -231,12 +222,12 @@ var FxEditor = function FxEditor() {
|
|
|
231
222
|
}
|
|
232
223
|
case "ArrowLeft":
|
|
233
224
|
{
|
|
234
|
-
|
|
225
|
+
(0, _fortuneCore.rangeHightlightselected)(draftCtx, refs.fxInput.current);
|
|
235
226
|
break;
|
|
236
227
|
}
|
|
237
228
|
case "ArrowRight":
|
|
238
229
|
{
|
|
239
|
-
|
|
230
|
+
(0, _fortuneCore.rangeHightlightselected)(draftCtx, refs.fxInput.current);
|
|
240
231
|
break;
|
|
241
232
|
}
|
|
242
233
|
default:
|
|
@@ -266,7 +257,6 @@ var FxEditor = function FxEditor() {
|
|
|
266
257
|
};
|
|
267
258
|
var onChange = (0, _react.useCallback)(function () {
|
|
268
259
|
var _a, _b, _c;
|
|
269
|
-
if (isComposingRef.current) return;
|
|
270
260
|
if (context.isFlvReadOnly) return;
|
|
271
261
|
handleHideShowHint();
|
|
272
262
|
if (((_b = (_a = refs.fxInput) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.innerText.includes("=")) && /^=?[A-Za-z]*$/.test(getLastInputSpanText())) {
|
|
@@ -362,25 +352,6 @@ var FxEditor = function FxEditor() {
|
|
|
362
352
|
ref: inputContainerRef,
|
|
363
353
|
className: "fortune-fx-input-container"
|
|
364
354
|
}, /*#__PURE__*/_react.default.createElement(_ContentEditable.default, {
|
|
365
|
-
onCompositionStart: function onCompositionStart() {
|
|
366
|
-
isComposingRef.current = true;
|
|
367
|
-
console.log("onCompositionStart");
|
|
368
|
-
},
|
|
369
|
-
onCompositionUpdate: function onCompositionUpdate(e) {
|
|
370
|
-
window.CompositData = e.currentTarget.innerText;
|
|
371
|
-
isComposingRef.current = true;
|
|
372
|
-
console.log("onCompositionUpdate", e.currentTarget.innerText);
|
|
373
|
-
},
|
|
374
|
-
onCompositionEnd: function onCompositionEnd(e) {
|
|
375
|
-
var rowIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus) || 0;
|
|
376
|
-
var colIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus) || 0;
|
|
377
|
-
window.CompositData = e.currentTarget.innerText;
|
|
378
|
-
setContext(function (draftCtx) {
|
|
379
|
-
(0, _fortuneCore.setCellValue)(draftCtx, rowIndex, colIndex, null, window.CompositData);
|
|
380
|
-
window.CompositData = "";
|
|
381
|
-
});
|
|
382
|
-
isComposingRef.current = false;
|
|
383
|
-
},
|
|
384
355
|
onMouseUp: function onMouseUp() {
|
|
385
356
|
var _a;
|
|
386
357
|
handleHideShowHint();
|
|
@@ -388,10 +359,6 @@ var FxEditor = function FxEditor() {
|
|
|
388
359
|
setCommaCount(currentCommaCount);
|
|
389
360
|
},
|
|
390
361
|
innerRef: function innerRef(e) {
|
|
391
|
-
if (isComposingRef.current) {
|
|
392
|
-
refs.fxInput.current = null;
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
362
|
refs.fxInput.current = e;
|
|
396
363
|
},
|
|
397
364
|
className: "fortune-fx-input",
|
|
@@ -248,7 +248,7 @@ var InputBox = function InputBox() {
|
|
|
248
248
|
}, [getActiveFormula, insertSelectedFormula]);
|
|
249
249
|
var selectActiveFormulaOnClick = (0, _react.useCallback)(function (e) {
|
|
250
250
|
var _a, _b;
|
|
251
|
-
if (isComposingRef.current) return;
|
|
251
|
+
if (isComposingRef.current || !inputRef.current) return;
|
|
252
252
|
if (e.target.className.includes("sign-fortune")) return;
|
|
253
253
|
preText.current = inputRef.current.innerText;
|
|
254
254
|
var formulaName = (_b = (_a = getActiveFormula()) === null || _a === void 0 ? void 0 : _a.querySelector(".luckysheet-formula-search-func")) === null || _b === void 0 ? void 0 : _b.textContent;
|
|
@@ -265,7 +265,7 @@ var InputBox = function InputBox() {
|
|
|
265
265
|
};
|
|
266
266
|
var onKeyDown = (0, _react.useCallback)(function (e) {
|
|
267
267
|
var _a, _b;
|
|
268
|
-
if (isComposingRef.current) return;
|
|
268
|
+
if (isComposingRef.current || !inputRef.current) return;
|
|
269
269
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
270
270
|
preText.current = inputRef.current.innerText;
|
|
271
271
|
if (e.metaKey) {
|
|
@@ -283,8 +283,10 @@ var InputBox = function InputBox() {
|
|
|
283
283
|
stopPropagation(e);
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
if (!isComposingRef.current) {
|
|
287
|
+
var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
288
|
+
setCommaCount(currentCommaCount);
|
|
289
|
+
}
|
|
288
290
|
var allowListNavigation = true;
|
|
289
291
|
if ((e.key === "Delete" || e.key === "Backspace") && (0, _helper.getCursorPosition)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length)) {
|
|
290
292
|
setTimeout(function () {
|
|
@@ -411,8 +413,10 @@ var InputBox = function InputBox() {
|
|
|
411
413
|
} else {
|
|
412
414
|
setShowSearchHint(false);
|
|
413
415
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
+
if (!isComposingRef.current) {
|
|
417
|
+
var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
418
|
+
setCommaCount(currentCommaCount);
|
|
419
|
+
}
|
|
416
420
|
var e = lastKeyDownEventRef.current;
|
|
417
421
|
if (!e) return;
|
|
418
422
|
var kcode = e.keyCode;
|
|
@@ -599,8 +603,10 @@ var InputBox = function InputBox() {
|
|
|
599
603
|
return;
|
|
600
604
|
}
|
|
601
605
|
handleHideShowHint();
|
|
602
|
-
|
|
603
|
-
|
|
606
|
+
if (!isComposingRef.current) {
|
|
607
|
+
var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
608
|
+
setCommaCount(currentCommaCount);
|
|
609
|
+
}
|
|
604
610
|
},
|
|
605
611
|
innerRef: function innerRef(e) {
|
|
606
612
|
if (isComposingRef.current) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fileverse-dev/fortune-react",
|
|
3
|
-
"version": "1.2.86-pinyin",
|
|
3
|
+
"version": "1.2.86-pinyin-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.2.86-pinyin",
|
|
19
|
+
"@fileverse-dev/fortune-core": "1.2.86-pinyin-2",
|
|
20
20
|
"@fileverse/ui": "^4.1.7-patch-40",
|
|
21
21
|
"@tippyjs/react": "^4.2.6",
|
|
22
22
|
"@types/regenerator-runtime": "^0.13.6",
|