@fileverse-dev/fortune-react 1.2.86-maitra-xl-1 → 1.2.86-pinyin
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/FxEditor/index.js +37 -4
- package/es/components/SheetOverlay/InputBox.js +40 -2
- package/es/components/Workbook/api.d.ts +0 -1
- package/es/components/Workbook/api.js +0 -6
- package/es/components/Workbook/index.d.ts +0 -1
- package/es/components/Workbook/index.js +1 -1
- package/lib/components/FxEditor/index.js +36 -3
- package/lib/components/SheetOverlay/InputBox.js +39 -1
- package/lib/components/Workbook/api.d.ts +0 -1
- package/lib/components/Workbook/api.js +0 -6
- package/lib/components/Workbook/index.d.ts +0 -1
- package/lib/components/Workbook/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFlowdata, cancelNormalSelected, getCellValue, updateCell, getInlineStringNoStyle, isInlineStringCell, escapeScriptTag, moveHighlightCell, handleFormulaInput, rangeHightlightselected, valueShowEs, isShowHidenCR, escapeHTMLTag, isAllowEdit } from "@fileverse-dev/fortune-core";
|
|
1
|
+
import { getFlowdata, cancelNormalSelected, getCellValue, updateCell, getInlineStringNoStyle, isInlineStringCell, escapeScriptTag, moveHighlightCell, handleFormulaInput, rangeHightlightselected, valueShowEs, isShowHidenCR, escapeHTMLTag, isAllowEdit, setCellValue } 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,6 +35,7 @@ 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);
|
|
38
39
|
var handleShowFormulaHint = function handleShowFormulaHint() {
|
|
39
40
|
localStorage.setItem("formulaMore", String(showFormulaHint));
|
|
40
41
|
setShowFormulaHint(!showFormulaHint);
|
|
@@ -68,6 +69,9 @@ var FxEditor = function FxEditor() {
|
|
|
68
69
|
}, [context.luckysheetfile, context.currentSheetId, context.luckysheet_select_save]);
|
|
69
70
|
var onFocus = useCallback(function () {
|
|
70
71
|
var _a, _b;
|
|
72
|
+
if (isComposingRef.current) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
71
75
|
if (context.allowEdit === false) {
|
|
72
76
|
return;
|
|
73
77
|
}
|
|
@@ -190,8 +194,13 @@ var FxEditor = function FxEditor() {
|
|
|
190
194
|
switch (key) {
|
|
191
195
|
case "Enter":
|
|
192
196
|
{
|
|
197
|
+
if (isComposingRef.current) {
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
193
200
|
var lastCellUpdate = _.clone(draftCtx.luckysheetCellUpdate);
|
|
194
|
-
|
|
201
|
+
if (!isComposingRef.current) {
|
|
202
|
+
updateCell(draftCtx, draftCtx.luckysheetCellUpdate[0], draftCtx.luckysheetCellUpdate[1], refs.fxInput.current);
|
|
203
|
+
}
|
|
195
204
|
draftCtx.luckysheet_select_save = [{
|
|
196
205
|
row: [lastCellUpdate[0], lastCellUpdate[0]],
|
|
197
206
|
column: [lastCellUpdate[1], lastCellUpdate[1]],
|
|
@@ -213,12 +222,12 @@ var FxEditor = function FxEditor() {
|
|
|
213
222
|
}
|
|
214
223
|
case "ArrowLeft":
|
|
215
224
|
{
|
|
216
|
-
rangeHightlightselected(draftCtx, refs.fxInput.current);
|
|
225
|
+
if (!isComposingRef.current) rangeHightlightselected(draftCtx, refs.fxInput.current);
|
|
217
226
|
break;
|
|
218
227
|
}
|
|
219
228
|
case "ArrowRight":
|
|
220
229
|
{
|
|
221
|
-
rangeHightlightselected(draftCtx, refs.fxInput.current);
|
|
230
|
+
if (!isComposingRef.current) rangeHightlightselected(draftCtx, refs.fxInput.current);
|
|
222
231
|
break;
|
|
223
232
|
}
|
|
224
233
|
default:
|
|
@@ -248,6 +257,7 @@ var FxEditor = function FxEditor() {
|
|
|
248
257
|
};
|
|
249
258
|
var onChange = useCallback(function () {
|
|
250
259
|
var _a, _b, _c;
|
|
260
|
+
if (isComposingRef.current) return;
|
|
251
261
|
if (context.isFlvReadOnly) return;
|
|
252
262
|
handleHideShowHint();
|
|
253
263
|
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())) {
|
|
@@ -343,6 +353,25 @@ var FxEditor = function FxEditor() {
|
|
|
343
353
|
ref: inputContainerRef,
|
|
344
354
|
className: "fortune-fx-input-container"
|
|
345
355
|
}, /*#__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
|
+
},
|
|
346
375
|
onMouseUp: function onMouseUp() {
|
|
347
376
|
var _a;
|
|
348
377
|
handleHideShowHint();
|
|
@@ -350,6 +379,10 @@ var FxEditor = function FxEditor() {
|
|
|
350
379
|
setCommaCount(currentCommaCount);
|
|
351
380
|
},
|
|
352
381
|
innerRef: function innerRef(e) {
|
|
382
|
+
if (isComposingRef.current) {
|
|
383
|
+
refs.fxInput.current = null;
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
353
386
|
refs.fxInput.current = e;
|
|
354
387
|
},
|
|
355
388
|
className: "fortune-fx-input",
|
|
@@ -8,7 +8,7 @@ var __assign = this && this.__assign || function () {
|
|
|
8
8
|
};
|
|
9
9
|
return __assign.apply(this, arguments);
|
|
10
10
|
};
|
|
11
|
-
import { cancelNormalSelected, getCellValue, getInlineStringHTML, getStyleByCell, isInlineStringCell, moveToEnd, getFlowdata, handleFormulaInput, moveHighlightCell, escapeScriptTag, valueShowEs, createRangeHightlight, isShowHidenCR, israngeseleciton, escapeHTMLTag, isAllowEdit, getrangeseleciton, indexToColumnChar, handleBold, handleItalic, handleUnderline, handleStrikeThrough } from "@fileverse-dev/fortune-core";
|
|
11
|
+
import { cancelNormalSelected, getCellValue, getInlineStringHTML, getStyleByCell, isInlineStringCell, moveToEnd, getFlowdata, handleFormulaInput, moveHighlightCell, escapeScriptTag, valueShowEs, createRangeHightlight, isShowHidenCR, israngeseleciton, escapeHTMLTag, isAllowEdit, getrangeseleciton, indexToColumnChar, handleBold, handleItalic, handleUnderline, handleStrikeThrough, setCellValue } from "@fileverse-dev/fortune-core";
|
|
12
12
|
import React, { useContext, useEffect, useMemo, useRef, useCallback, useLayoutEffect, useState } from "react";
|
|
13
13
|
import _ from "lodash";
|
|
14
14
|
import { Tooltip } from "@fileverse/ui";
|
|
@@ -65,6 +65,7 @@ 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 isComposingRef = useRef(false);
|
|
68
69
|
var handleShowFormulaHint = function handleShowFormulaHint() {
|
|
69
70
|
localStorage.setItem("formulaMore", String(showFormulaHint));
|
|
70
71
|
setShowFormulaHint(!showFormulaHint);
|
|
@@ -130,7 +131,7 @@ var InputBox = function InputBox() {
|
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
refs.globalCache.overwriteCell = false;
|
|
133
|
-
if (!refs.globalCache.ignoreWriteCell) inputRef.current.innerHTML = escapeHTMLTag(escapeScriptTag(value_1));
|
|
134
|
+
if (!refs.globalCache.ignoreWriteCell && inputRef.current) inputRef.current.innerHTML = escapeHTMLTag(escapeScriptTag(value_1));
|
|
134
135
|
refs.globalCache.ignoreWriteCell = false;
|
|
135
136
|
if (!refs.globalCache.doNotFocus) {
|
|
136
137
|
setTimeout(function () {
|
|
@@ -152,6 +153,7 @@ var InputBox = function InputBox() {
|
|
|
152
153
|
}, [context.luckysheet_select_save]);
|
|
153
154
|
useEffect(function () {
|
|
154
155
|
var _a;
|
|
156
|
+
if (isComposingRef.current) return;
|
|
155
157
|
if (!firstSelection || ((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show) || _.isEmpty(context.luckysheetCellUpdate)) {
|
|
156
158
|
setIsInputBoxActive(false);
|
|
157
159
|
}
|
|
@@ -161,6 +163,7 @@ var InputBox = function InputBox() {
|
|
|
161
163
|
}, []);
|
|
162
164
|
var insertSelectedFormula = useCallback(function (formulaName) {
|
|
163
165
|
var _a;
|
|
166
|
+
if (isComposingRef.current) return;
|
|
164
167
|
if (/^=[a-zA-Z]+$/.test(inputRef.current.innerText)) {
|
|
165
168
|
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>");
|
|
166
169
|
inputRef.current.innerHTML = ht;
|
|
@@ -225,6 +228,7 @@ var InputBox = function InputBox() {
|
|
|
225
228
|
}, [getActiveFormula]);
|
|
226
229
|
var selectActiveFormula = useCallback(function (e) {
|
|
227
230
|
var _a, _b;
|
|
231
|
+
if (isComposingRef.current) return;
|
|
228
232
|
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;
|
|
229
233
|
var lastSpanText = getLastInputSpanText();
|
|
230
234
|
if (formulaName && !isLetterNumberPattern(lastSpanText)) {
|
|
@@ -235,6 +239,7 @@ var InputBox = function InputBox() {
|
|
|
235
239
|
}, [getActiveFormula, insertSelectedFormula]);
|
|
236
240
|
var selectActiveFormulaOnClick = useCallback(function (e) {
|
|
237
241
|
var _a, _b;
|
|
242
|
+
if (isComposingRef.current) return;
|
|
238
243
|
if (e.target.className.includes("sign-fortune")) return;
|
|
239
244
|
preText.current = inputRef.current.innerText;
|
|
240
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;
|
|
@@ -251,6 +256,7 @@ var InputBox = function InputBox() {
|
|
|
251
256
|
};
|
|
252
257
|
var onKeyDown = useCallback(function (e) {
|
|
253
258
|
var _a, _b;
|
|
259
|
+
if (isComposingRef.current) return;
|
|
254
260
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
255
261
|
preText.current = inputRef.current.innerText;
|
|
256
262
|
if (e.metaKey) {
|
|
@@ -386,6 +392,9 @@ var InputBox = function InputBox() {
|
|
|
386
392
|
};
|
|
387
393
|
var onChange = useCallback(function (__, isBlur) {
|
|
388
394
|
var _a;
|
|
395
|
+
if (isComposingRef.current) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
389
398
|
if (context.isFlvReadOnly) return;
|
|
390
399
|
handleHideShowHint();
|
|
391
400
|
if (((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText.includes("=")) && /^=?[A-Za-z]*$/.test(getLastInputSpanText())) {
|
|
@@ -410,6 +419,7 @@ var InputBox = function InputBox() {
|
|
|
410
419
|
}
|
|
411
420
|
}, [refs.cellInput, refs.fxInput, setContext]);
|
|
412
421
|
var onPaste = useCallback(function (e) {
|
|
422
|
+
if (isComposingRef.current) return;
|
|
413
423
|
if (_.isEmpty(context.luckysheetCellUpdate)) {
|
|
414
424
|
e.preventDefault();
|
|
415
425
|
}
|
|
@@ -555,12 +565,40 @@ var InputBox = function InputBox() {
|
|
|
555
565
|
minHeight: firstSelection.height
|
|
556
566
|
}, inputBoxStyle) : {}
|
|
557
567
|
}, /*#__PURE__*/React.createElement(ContentEditable, {
|
|
568
|
+
onCompositionStart: function onCompositionStart() {
|
|
569
|
+
isComposingRef.current = true;
|
|
570
|
+
console.log("onCompositionStart");
|
|
571
|
+
},
|
|
572
|
+
onCompositionUpdate: function onCompositionUpdate(e) {
|
|
573
|
+
window.CompositData = e.currentTarget.innerText;
|
|
574
|
+
isComposingRef.current = true;
|
|
575
|
+
console.log("onCompositionUpdate", e.currentTarget.innerText);
|
|
576
|
+
},
|
|
577
|
+
onCompositionEnd: function onCompositionEnd(e) {
|
|
578
|
+
var rowIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus) || 0;
|
|
579
|
+
var colIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus) || 0;
|
|
580
|
+
console.log("onCompositionEnd", e.currentTarget.innerText, getCellAddress(), rowIndex, colIndex, setCellValue);
|
|
581
|
+
window.CompositData = e.currentTarget.innerText;
|
|
582
|
+
setContext(function (draftCtx) {
|
|
583
|
+
setCellValue(draftCtx, rowIndex, colIndex, null, window.CompositData);
|
|
584
|
+
window.CompositData = "";
|
|
585
|
+
});
|
|
586
|
+
isComposingRef.current = false;
|
|
587
|
+
},
|
|
558
588
|
onMouseUp: function onMouseUp() {
|
|
589
|
+
if (isComposingRef.current) {
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
559
592
|
handleHideShowHint();
|
|
560
593
|
var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
561
594
|
setCommaCount(currentCommaCount);
|
|
562
595
|
},
|
|
563
596
|
innerRef: function innerRef(e) {
|
|
597
|
+
if (isComposingRef.current) {
|
|
598
|
+
inputRef.current = null;
|
|
599
|
+
refs.cellInput.current = null;
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
564
602
|
inputRef.current = e;
|
|
565
603
|
refs.cellInput.current = e;
|
|
566
604
|
},
|
|
@@ -140,7 +140,6 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
|
|
|
140
140
|
handleRedo: () => void;
|
|
141
141
|
calculateFormula: () => void;
|
|
142
142
|
calculateSubSheetFormula: (id: string) => void;
|
|
143
|
-
calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[]) => void;
|
|
144
143
|
dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
|
|
145
144
|
celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
|
|
146
145
|
insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: () => void) => void;
|
|
@@ -389,12 +389,6 @@ export function generateAPIs(context, setContext, handleUndo, handleRedo, settin
|
|
|
389
389
|
api.calculateSheetFromula(draftCtx, id);
|
|
390
390
|
});
|
|
391
391
|
},
|
|
392
|
-
calculateCellReferencedSubSheetFormula: function calculateCellReferencedSubSheetFormula(id, refCell) {
|
|
393
|
-
console.log("calculateCellReferencedSubSheetFormula", id, refCell);
|
|
394
|
-
setContext(function (draftCtx) {
|
|
395
|
-
api.calculateReferencedCellSheetFromula(draftCtx, id, refCell);
|
|
396
|
-
});
|
|
397
|
-
},
|
|
398
392
|
dataToCelldata: function dataToCelldata(data) {
|
|
399
393
|
return api.dataToCelldata(data);
|
|
400
394
|
},
|
|
@@ -147,7 +147,6 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
147
147
|
handleRedo: () => void;
|
|
148
148
|
calculateFormula: () => void;
|
|
149
149
|
calculateSubSheetFormula: (id: string) => void;
|
|
150
|
-
calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[] | undefined) => void;
|
|
151
150
|
dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
|
|
152
151
|
celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number | undefined, colCount?: number | undefined) => CellMatrix | null;
|
|
153
152
|
insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: (() => void) | undefined) => void;
|
|
@@ -288,7 +288,7 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
288
288
|
return newContext;
|
|
289
289
|
});
|
|
290
290
|
}
|
|
291
|
-
}, [emitOp
|
|
291
|
+
}, [emitOp]);
|
|
292
292
|
var handleRedo = useCallback(function () {
|
|
293
293
|
var history = globalCache.current.redoList.pop();
|
|
294
294
|
if (history) {
|
|
@@ -44,6 +44,7 @@ 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);
|
|
47
48
|
var handleShowFormulaHint = function handleShowFormulaHint() {
|
|
48
49
|
localStorage.setItem("formulaMore", String(showFormulaHint));
|
|
49
50
|
setShowFormulaHint(!showFormulaHint);
|
|
@@ -77,6 +78,9 @@ var FxEditor = function FxEditor() {
|
|
|
77
78
|
}, [context.luckysheetfile, context.currentSheetId, context.luckysheet_select_save]);
|
|
78
79
|
var onFocus = (0, _react.useCallback)(function () {
|
|
79
80
|
var _a, _b;
|
|
81
|
+
if (isComposingRef.current) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
80
84
|
if (context.allowEdit === false) {
|
|
81
85
|
return;
|
|
82
86
|
}
|
|
@@ -199,8 +203,13 @@ var FxEditor = function FxEditor() {
|
|
|
199
203
|
switch (key) {
|
|
200
204
|
case "Enter":
|
|
201
205
|
{
|
|
206
|
+
if (isComposingRef.current) {
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
202
209
|
var lastCellUpdate = _lodash.default.clone(draftCtx.luckysheetCellUpdate);
|
|
203
|
-
|
|
210
|
+
if (!isComposingRef.current) {
|
|
211
|
+
(0, _fortuneCore.updateCell)(draftCtx, draftCtx.luckysheetCellUpdate[0], draftCtx.luckysheetCellUpdate[1], refs.fxInput.current);
|
|
212
|
+
}
|
|
204
213
|
draftCtx.luckysheet_select_save = [{
|
|
205
214
|
row: [lastCellUpdate[0], lastCellUpdate[0]],
|
|
206
215
|
column: [lastCellUpdate[1], lastCellUpdate[1]],
|
|
@@ -222,12 +231,12 @@ var FxEditor = function FxEditor() {
|
|
|
222
231
|
}
|
|
223
232
|
case "ArrowLeft":
|
|
224
233
|
{
|
|
225
|
-
(0, _fortuneCore.rangeHightlightselected)(draftCtx, refs.fxInput.current);
|
|
234
|
+
if (!isComposingRef.current) (0, _fortuneCore.rangeHightlightselected)(draftCtx, refs.fxInput.current);
|
|
226
235
|
break;
|
|
227
236
|
}
|
|
228
237
|
case "ArrowRight":
|
|
229
238
|
{
|
|
230
|
-
(0, _fortuneCore.rangeHightlightselected)(draftCtx, refs.fxInput.current);
|
|
239
|
+
if (!isComposingRef.current) (0, _fortuneCore.rangeHightlightselected)(draftCtx, refs.fxInput.current);
|
|
231
240
|
break;
|
|
232
241
|
}
|
|
233
242
|
default:
|
|
@@ -257,6 +266,7 @@ var FxEditor = function FxEditor() {
|
|
|
257
266
|
};
|
|
258
267
|
var onChange = (0, _react.useCallback)(function () {
|
|
259
268
|
var _a, _b, _c;
|
|
269
|
+
if (isComposingRef.current) return;
|
|
260
270
|
if (context.isFlvReadOnly) return;
|
|
261
271
|
handleHideShowHint();
|
|
262
272
|
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())) {
|
|
@@ -352,6 +362,25 @@ var FxEditor = function FxEditor() {
|
|
|
352
362
|
ref: inputContainerRef,
|
|
353
363
|
className: "fortune-fx-input-container"
|
|
354
364
|
}, /*#__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
|
+
},
|
|
355
384
|
onMouseUp: function onMouseUp() {
|
|
356
385
|
var _a;
|
|
357
386
|
handleHideShowHint();
|
|
@@ -359,6 +388,10 @@ var FxEditor = function FxEditor() {
|
|
|
359
388
|
setCommaCount(currentCommaCount);
|
|
360
389
|
},
|
|
361
390
|
innerRef: function innerRef(e) {
|
|
391
|
+
if (isComposingRef.current) {
|
|
392
|
+
refs.fxInput.current = null;
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
362
395
|
refs.fxInput.current = e;
|
|
363
396
|
},
|
|
364
397
|
className: "fortune-fx-input",
|
|
@@ -74,6 +74,7 @@ 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 isComposingRef = (0, _react.useRef)(false);
|
|
77
78
|
var handleShowFormulaHint = function handleShowFormulaHint() {
|
|
78
79
|
localStorage.setItem("formulaMore", String(showFormulaHint));
|
|
79
80
|
setShowFormulaHint(!showFormulaHint);
|
|
@@ -139,7 +140,7 @@ var InputBox = function InputBox() {
|
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
142
|
refs.globalCache.overwriteCell = false;
|
|
142
|
-
if (!refs.globalCache.ignoreWriteCell) inputRef.current.innerHTML = (0, _fortuneCore.escapeHTMLTag)((0, _fortuneCore.escapeScriptTag)(value_1));
|
|
143
|
+
if (!refs.globalCache.ignoreWriteCell && inputRef.current) inputRef.current.innerHTML = (0, _fortuneCore.escapeHTMLTag)((0, _fortuneCore.escapeScriptTag)(value_1));
|
|
143
144
|
refs.globalCache.ignoreWriteCell = false;
|
|
144
145
|
if (!refs.globalCache.doNotFocus) {
|
|
145
146
|
setTimeout(function () {
|
|
@@ -161,6 +162,7 @@ var InputBox = function InputBox() {
|
|
|
161
162
|
}, [context.luckysheet_select_save]);
|
|
162
163
|
(0, _react.useEffect)(function () {
|
|
163
164
|
var _a;
|
|
165
|
+
if (isComposingRef.current) return;
|
|
164
166
|
if (!firstSelection || ((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show) || _lodash.default.isEmpty(context.luckysheetCellUpdate)) {
|
|
165
167
|
setIsInputBoxActive(false);
|
|
166
168
|
}
|
|
@@ -170,6 +172,7 @@ var InputBox = function InputBox() {
|
|
|
170
172
|
}, []);
|
|
171
173
|
var insertSelectedFormula = (0, _react.useCallback)(function (formulaName) {
|
|
172
174
|
var _a;
|
|
175
|
+
if (isComposingRef.current) return;
|
|
173
176
|
if (/^=[a-zA-Z]+$/.test(inputRef.current.innerText)) {
|
|
174
177
|
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>");
|
|
175
178
|
inputRef.current.innerHTML = ht;
|
|
@@ -234,6 +237,7 @@ var InputBox = function InputBox() {
|
|
|
234
237
|
}, [getActiveFormula]);
|
|
235
238
|
var selectActiveFormula = (0, _react.useCallback)(function (e) {
|
|
236
239
|
var _a, _b;
|
|
240
|
+
if (isComposingRef.current) return;
|
|
237
241
|
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;
|
|
238
242
|
var lastSpanText = getLastInputSpanText();
|
|
239
243
|
if (formulaName && !(0, _helper.isLetterNumberPattern)(lastSpanText)) {
|
|
@@ -244,6 +248,7 @@ var InputBox = function InputBox() {
|
|
|
244
248
|
}, [getActiveFormula, insertSelectedFormula]);
|
|
245
249
|
var selectActiveFormulaOnClick = (0, _react.useCallback)(function (e) {
|
|
246
250
|
var _a, _b;
|
|
251
|
+
if (isComposingRef.current) return;
|
|
247
252
|
if (e.target.className.includes("sign-fortune")) return;
|
|
248
253
|
preText.current = inputRef.current.innerText;
|
|
249
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;
|
|
@@ -260,6 +265,7 @@ var InputBox = function InputBox() {
|
|
|
260
265
|
};
|
|
261
266
|
var onKeyDown = (0, _react.useCallback)(function (e) {
|
|
262
267
|
var _a, _b;
|
|
268
|
+
if (isComposingRef.current) return;
|
|
263
269
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
264
270
|
preText.current = inputRef.current.innerText;
|
|
265
271
|
if (e.metaKey) {
|
|
@@ -395,6 +401,9 @@ var InputBox = function InputBox() {
|
|
|
395
401
|
};
|
|
396
402
|
var onChange = (0, _react.useCallback)(function (__, isBlur) {
|
|
397
403
|
var _a;
|
|
404
|
+
if (isComposingRef.current) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
398
407
|
if (context.isFlvReadOnly) return;
|
|
399
408
|
handleHideShowHint();
|
|
400
409
|
if (((_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.innerText.includes("=")) && /^=?[A-Za-z]*$/.test(getLastInputSpanText())) {
|
|
@@ -419,6 +428,7 @@ var InputBox = function InputBox() {
|
|
|
419
428
|
}
|
|
420
429
|
}, [refs.cellInput, refs.fxInput, setContext]);
|
|
421
430
|
var onPaste = (0, _react.useCallback)(function (e) {
|
|
431
|
+
if (isComposingRef.current) return;
|
|
422
432
|
if (_lodash.default.isEmpty(context.luckysheetCellUpdate)) {
|
|
423
433
|
e.preventDefault();
|
|
424
434
|
}
|
|
@@ -564,12 +574,40 @@ var InputBox = function InputBox() {
|
|
|
564
574
|
minHeight: firstSelection.height
|
|
565
575
|
}, inputBoxStyle) : {}
|
|
566
576
|
}, /*#__PURE__*/_react.default.createElement(_ContentEditable.default, {
|
|
577
|
+
onCompositionStart: function onCompositionStart() {
|
|
578
|
+
isComposingRef.current = true;
|
|
579
|
+
console.log("onCompositionStart");
|
|
580
|
+
},
|
|
581
|
+
onCompositionUpdate: function onCompositionUpdate(e) {
|
|
582
|
+
window.CompositData = e.currentTarget.innerText;
|
|
583
|
+
isComposingRef.current = true;
|
|
584
|
+
console.log("onCompositionUpdate", e.currentTarget.innerText);
|
|
585
|
+
},
|
|
586
|
+
onCompositionEnd: function onCompositionEnd(e) {
|
|
587
|
+
var rowIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus) || 0;
|
|
588
|
+
var colIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus) || 0;
|
|
589
|
+
console.log("onCompositionEnd", e.currentTarget.innerText, getCellAddress(), rowIndex, colIndex, _fortuneCore.setCellValue);
|
|
590
|
+
window.CompositData = e.currentTarget.innerText;
|
|
591
|
+
setContext(function (draftCtx) {
|
|
592
|
+
(0, _fortuneCore.setCellValue)(draftCtx, rowIndex, colIndex, null, window.CompositData);
|
|
593
|
+
window.CompositData = "";
|
|
594
|
+
});
|
|
595
|
+
isComposingRef.current = false;
|
|
596
|
+
},
|
|
567
597
|
onMouseUp: function onMouseUp() {
|
|
598
|
+
if (isComposingRef.current) {
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
568
601
|
handleHideShowHint();
|
|
569
602
|
var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
570
603
|
setCommaCount(currentCommaCount);
|
|
571
604
|
},
|
|
572
605
|
innerRef: function innerRef(e) {
|
|
606
|
+
if (isComposingRef.current) {
|
|
607
|
+
inputRef.current = null;
|
|
608
|
+
refs.cellInput.current = null;
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
573
611
|
inputRef.current = e;
|
|
574
612
|
refs.cellInput.current = e;
|
|
575
613
|
},
|
|
@@ -140,7 +140,6 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
|
|
|
140
140
|
handleRedo: () => void;
|
|
141
141
|
calculateFormula: () => void;
|
|
142
142
|
calculateSubSheetFormula: (id: string) => void;
|
|
143
|
-
calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[]) => void;
|
|
144
143
|
dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
|
|
145
144
|
celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
|
|
146
145
|
insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: () => void) => void;
|
|
@@ -396,12 +396,6 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
|
|
|
396
396
|
_fortuneCore.api.calculateSheetFromula(draftCtx, id);
|
|
397
397
|
});
|
|
398
398
|
},
|
|
399
|
-
calculateCellReferencedSubSheetFormula: function calculateCellReferencedSubSheetFormula(id, refCell) {
|
|
400
|
-
console.log("calculateCellReferencedSubSheetFormula", id, refCell);
|
|
401
|
-
setContext(function (draftCtx) {
|
|
402
|
-
_fortuneCore.api.calculateReferencedCellSheetFromula(draftCtx, id, refCell);
|
|
403
|
-
});
|
|
404
|
-
},
|
|
405
399
|
dataToCelldata: function dataToCelldata(data) {
|
|
406
400
|
return _fortuneCore.api.dataToCelldata(data);
|
|
407
401
|
},
|
|
@@ -147,7 +147,6 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
147
147
|
handleRedo: () => void;
|
|
148
148
|
calculateFormula: () => void;
|
|
149
149
|
calculateSubSheetFormula: (id: string) => void;
|
|
150
|
-
calculateCellReferencedSubSheetFormula: (id: string, refCell?: string[] | undefined) => void;
|
|
151
150
|
dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
|
|
152
151
|
celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number | undefined, colCount?: number | undefined) => CellMatrix | null;
|
|
153
152
|
insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: (() => void) | undefined) => void;
|
|
@@ -297,7 +297,7 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
|
|
|
297
297
|
return newContext;
|
|
298
298
|
});
|
|
299
299
|
}
|
|
300
|
-
}, [emitOp
|
|
300
|
+
}, [emitOp]);
|
|
301
301
|
var handleRedo = (0, _react.useCallback)(function () {
|
|
302
302
|
var history = globalCache.current.redoList.pop();
|
|
303
303
|
if (history) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fileverse-dev/fortune-react",
|
|
3
|
-
"version": "1.2.86-
|
|
3
|
+
"version": "1.2.86-pinyin",
|
|
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-
|
|
19
|
+
"@fileverse-dev/fortune-core": "1.2.86-pinyin",
|
|
20
20
|
"@fileverse/ui": "^4.1.7-patch-40",
|
|
21
21
|
"@tippyjs/react": "^4.2.6",
|
|
22
22
|
"@types/regenerator-runtime": "^0.13.6",
|