@fileverse-dev/fortune-react 1.2.86 → 1.2.88
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/SheetOverlay/InputBox.js +74 -8
- package/es/components/Workbook/api.d.ts +1 -0
- package/es/components/Workbook/api.js +6 -0
- package/es/components/Workbook/index.d.ts +1 -0
- package/es/components/Workbook/index.js +42 -5
- package/lib/components/SheetOverlay/InputBox.js +73 -7
- package/lib/components/Workbook/api.d.ts +1 -0
- package/lib/components/Workbook/api.js +6 -0
- package/lib/components/Workbook/index.d.ts +1 -0
- package/lib/components/Workbook/index.js +42 -5
- package/package.json +2 -2
|
@@ -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,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);
|
|
69
|
+
var isComposingRef = useRef(false);
|
|
70
|
+
var placeCursorAtEnd = function placeCursorAtEnd(el) {
|
|
71
|
+
var range = document.createRange();
|
|
72
|
+
var sel = window.getSelection();
|
|
73
|
+
range.selectNodeContents(el);
|
|
74
|
+
range.collapse(false);
|
|
75
|
+
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
|
|
76
|
+
sel === null || sel === void 0 ? void 0 : sel.addRange(range);
|
|
77
|
+
};
|
|
78
|
+
var ensureNotEmpty = function ensureNotEmpty() {
|
|
79
|
+
var el = rootRef.current;
|
|
80
|
+
if (!el) return;
|
|
81
|
+
if (el.textContent === "") {
|
|
82
|
+
el.innerHTML = "\u200B";
|
|
83
|
+
placeCursorAtEnd(el);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
68
86
|
var handleShowFormulaHint = function handleShowFormulaHint() {
|
|
69
87
|
localStorage.setItem("formulaMore", String(showFormulaHint));
|
|
70
88
|
setShowFormulaHint(!showFormulaHint);
|
|
@@ -130,7 +148,7 @@ var InputBox = function InputBox() {
|
|
|
130
148
|
}
|
|
131
149
|
}
|
|
132
150
|
refs.globalCache.overwriteCell = false;
|
|
133
|
-
if (!refs.globalCache.ignoreWriteCell) inputRef.current.innerHTML = escapeHTMLTag(escapeScriptTag(value_1));
|
|
151
|
+
if (!refs.globalCache.ignoreWriteCell && inputRef.current) inputRef.current.innerHTML = escapeHTMLTag(escapeScriptTag(value_1));
|
|
134
152
|
refs.globalCache.ignoreWriteCell = false;
|
|
135
153
|
if (!refs.globalCache.doNotFocus) {
|
|
136
154
|
setTimeout(function () {
|
|
@@ -152,6 +170,7 @@ var InputBox = function InputBox() {
|
|
|
152
170
|
}, [context.luckysheet_select_save]);
|
|
153
171
|
useEffect(function () {
|
|
154
172
|
var _a;
|
|
173
|
+
if (isComposingRef.current) return;
|
|
155
174
|
if (!firstSelection || ((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show) || _.isEmpty(context.luckysheetCellUpdate)) {
|
|
156
175
|
setIsInputBoxActive(false);
|
|
157
176
|
}
|
|
@@ -161,6 +180,7 @@ var InputBox = function InputBox() {
|
|
|
161
180
|
}, []);
|
|
162
181
|
var insertSelectedFormula = useCallback(function (formulaName) {
|
|
163
182
|
var _a;
|
|
183
|
+
if (isComposingRef.current) return;
|
|
164
184
|
if (/^=[a-zA-Z]+$/.test(inputRef.current.innerText)) {
|
|
165
185
|
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
186
|
inputRef.current.innerHTML = ht;
|
|
@@ -225,6 +245,7 @@ var InputBox = function InputBox() {
|
|
|
225
245
|
}, [getActiveFormula]);
|
|
226
246
|
var selectActiveFormula = useCallback(function (e) {
|
|
227
247
|
var _a, _b;
|
|
248
|
+
if (isComposingRef.current) return;
|
|
228
249
|
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
250
|
var lastSpanText = getLastInputSpanText();
|
|
230
251
|
if (formulaName && !isLetterNumberPattern(lastSpanText)) {
|
|
@@ -235,6 +256,7 @@ var InputBox = function InputBox() {
|
|
|
235
256
|
}, [getActiveFormula, insertSelectedFormula]);
|
|
236
257
|
var selectActiveFormulaOnClick = useCallback(function (e) {
|
|
237
258
|
var _a, _b;
|
|
259
|
+
if (isComposingRef.current || !inputRef.current) return;
|
|
238
260
|
if (e.target.className.includes("sign-fortune")) return;
|
|
239
261
|
preText.current = inputRef.current.innerText;
|
|
240
262
|
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 +273,10 @@ var InputBox = function InputBox() {
|
|
|
251
273
|
};
|
|
252
274
|
var onKeyDown = useCallback(function (e) {
|
|
253
275
|
var _a, _b;
|
|
276
|
+
if (isComposingRef.current || !inputRef.current) {
|
|
277
|
+
ensureNotEmpty();
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
254
280
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
255
281
|
preText.current = inputRef.current.innerText;
|
|
256
282
|
if (e.metaKey) {
|
|
@@ -268,8 +294,10 @@ var InputBox = function InputBox() {
|
|
|
268
294
|
stopPropagation(e);
|
|
269
295
|
}
|
|
270
296
|
}
|
|
271
|
-
|
|
272
|
-
|
|
297
|
+
if (!isComposingRef.current) {
|
|
298
|
+
var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
299
|
+
setCommaCount(currentCommaCount);
|
|
300
|
+
}
|
|
273
301
|
var allowListNavigation = true;
|
|
274
302
|
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)) {
|
|
275
303
|
setTimeout(function () {
|
|
@@ -386,6 +414,9 @@ var InputBox = function InputBox() {
|
|
|
386
414
|
};
|
|
387
415
|
var onChange = useCallback(function (__, isBlur) {
|
|
388
416
|
var _a;
|
|
417
|
+
if (isComposingRef.current) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
389
420
|
if (context.isFlvReadOnly) return;
|
|
390
421
|
handleHideShowHint();
|
|
391
422
|
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())) {
|
|
@@ -393,8 +424,10 @@ var InputBox = function InputBox() {
|
|
|
393
424
|
} else {
|
|
394
425
|
setShowSearchHint(false);
|
|
395
426
|
}
|
|
396
|
-
|
|
397
|
-
|
|
427
|
+
if (!isComposingRef.current) {
|
|
428
|
+
var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
429
|
+
setCommaCount(currentCommaCount);
|
|
430
|
+
}
|
|
398
431
|
var e = lastKeyDownEventRef.current;
|
|
399
432
|
if (!e) return;
|
|
400
433
|
var kcode = e.keyCode;
|
|
@@ -410,6 +443,7 @@ var InputBox = function InputBox() {
|
|
|
410
443
|
}
|
|
411
444
|
}, [refs.cellInput, refs.fxInput, setContext]);
|
|
412
445
|
var onPaste = useCallback(function (e) {
|
|
446
|
+
if (isComposingRef.current) return;
|
|
413
447
|
if (_.isEmpty(context.luckysheetCellUpdate)) {
|
|
414
448
|
e.preventDefault();
|
|
415
449
|
}
|
|
@@ -555,12 +589,44 @@ var InputBox = function InputBox() {
|
|
|
555
589
|
minHeight: firstSelection.height
|
|
556
590
|
}, inputBoxStyle) : {}
|
|
557
591
|
}, /*#__PURE__*/React.createElement(ContentEditable, {
|
|
592
|
+
onCompositionStart: function onCompositionStart() {
|
|
593
|
+
isComposingRef.current = true;
|
|
594
|
+
console.log("onCompositionStart");
|
|
595
|
+
},
|
|
596
|
+
onCompositionUpdate: function onCompositionUpdate(e) {
|
|
597
|
+
window.CompositData = e.currentTarget.innerText;
|
|
598
|
+
isComposingRef.current = true;
|
|
599
|
+
console.log("onCompositionUpdate", e.currentTarget.innerText);
|
|
600
|
+
},
|
|
601
|
+
onCompositionEnd: function onCompositionEnd(e) {
|
|
602
|
+
ensureNotEmpty();
|
|
603
|
+
var rowIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus) || 0;
|
|
604
|
+
var colIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus) || 0;
|
|
605
|
+
console.log("onCompositionEnd", e.currentTarget.innerText, getCellAddress(), rowIndex, colIndex, setCellValue);
|
|
606
|
+
window.CompositData = e.currentTarget.innerText;
|
|
607
|
+
setContext(function (draftCtx) {
|
|
608
|
+
setCellValue(draftCtx, rowIndex, colIndex, null, window.CompositData);
|
|
609
|
+
window.CompositData = "";
|
|
610
|
+
});
|
|
611
|
+
isComposingRef.current = false;
|
|
612
|
+
},
|
|
558
613
|
onMouseUp: function onMouseUp() {
|
|
614
|
+
if (isComposingRef.current) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
559
617
|
handleHideShowHint();
|
|
560
|
-
|
|
561
|
-
|
|
618
|
+
if (!isComposingRef.current) {
|
|
619
|
+
var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
620
|
+
setCommaCount(currentCommaCount);
|
|
621
|
+
}
|
|
562
622
|
},
|
|
563
623
|
innerRef: function innerRef(e) {
|
|
624
|
+
rootRef.current = e;
|
|
625
|
+
if (isComposingRef.current) {
|
|
626
|
+
inputRef.current = null;
|
|
627
|
+
refs.cellInput.current = null;
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
564
630
|
inputRef.current = e;
|
|
565
631
|
refs.cellInput.current = e;
|
|
566
632
|
},
|
|
@@ -140,6 +140,7 @@ 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;
|
|
143
144
|
dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
|
|
144
145
|
celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
|
|
145
146
|
insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: () => void) => void;
|
|
@@ -389,6 +389,12 @@ 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
|
+
},
|
|
392
398
|
dataToCelldata: function dataToCelldata(data) {
|
|
393
399
|
return api.dataToCelldata(data);
|
|
394
400
|
},
|
|
@@ -147,6 +147,7 @@ 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;
|
|
150
151
|
dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
|
|
151
152
|
celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number | undefined, colCount?: number | undefined) => CellMatrix | null;
|
|
152
153
|
insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: (() => void) | undefined) => void;
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
var __assign = this && this.__assign || function () {
|
|
2
|
+
__assign = Object.assign || function (t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
6
|
+
}
|
|
7
|
+
return t;
|
|
8
|
+
};
|
|
9
|
+
return __assign.apply(this, arguments);
|
|
10
|
+
};
|
|
1
11
|
var __rest = this && this.__rest || function (s, e) {
|
|
2
12
|
var t = {};
|
|
3
13
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -252,7 +262,11 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
252
262
|
var history = globalCache.current.undoList.pop();
|
|
253
263
|
if (history) {
|
|
254
264
|
setContext(function (ctx_) {
|
|
255
|
-
var _a, _b, _c, _d, _e;
|
|
265
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
266
|
+
var isBorderUndo = history.patches.some(function (onePatch) {
|
|
267
|
+
var _a;
|
|
268
|
+
return (_a = onePatch.value) === null || _a === void 0 ? void 0 : _a.borderInfo;
|
|
269
|
+
});
|
|
256
270
|
if ((_a = history.options) === null || _a === void 0 ? void 0 : _a.deleteSheetOp) {
|
|
257
271
|
history.inversePatches[0].path[1] = ctx_.luckysheetfile.length;
|
|
258
272
|
var order_1 = (_c = (_b = history.options.deletedSheet) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.order;
|
|
@@ -285,21 +299,44 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
285
299
|
delete inversedOptions.addSheet.value.data;
|
|
286
300
|
}
|
|
287
301
|
emitOp(newContext, history.inversePatches, inversedOptions, true);
|
|
288
|
-
|
|
302
|
+
var nw = __assign({}, newContext);
|
|
303
|
+
if (isBorderUndo) {
|
|
304
|
+
var nwborderlist = (_g = (_f = nw === null || nw === void 0 ? void 0 : nw.config) === null || _f === void 0 ? void 0 : _f.borderInfo) === null || _g === void 0 ? void 0 : _g.slice(0, -1);
|
|
305
|
+
nw = __assign(__assign({}, nw), {
|
|
306
|
+
config: __assign(__assign({}, nw.config), {
|
|
307
|
+
borderInfo: nwborderlist
|
|
308
|
+
})
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
return isBorderUndo ? nw : newContext;
|
|
289
312
|
});
|
|
290
313
|
}
|
|
291
|
-
}, [emitOp]);
|
|
314
|
+
}, [emitOp, globalCache]);
|
|
292
315
|
var handleRedo = useCallback(function () {
|
|
293
316
|
var history = globalCache.current.redoList.pop();
|
|
294
317
|
if (history) {
|
|
295
318
|
setContext(function (ctx_) {
|
|
319
|
+
var _a, _b, _c;
|
|
296
320
|
var newContext = applyPatches(ctx_, history.patches);
|
|
321
|
+
var isBorderUndo = history.patches.some(function (onePatch) {
|
|
322
|
+
var _a;
|
|
323
|
+
return (_a = onePatch.value) === null || _a === void 0 ? void 0 : _a.borderInfo;
|
|
324
|
+
});
|
|
297
325
|
globalCache.current.undoList.push(history);
|
|
298
326
|
emitOp(newContext, history.patches, history.options);
|
|
299
|
-
|
|
327
|
+
var nw = __assign({}, newContext);
|
|
328
|
+
if (isBorderUndo) {
|
|
329
|
+
var nwborderlist = ((_b = (_a = nw === null || nw === void 0 ? void 0 : nw.config) === null || _a === void 0 ? void 0 : _a.borderInfo) !== null && _b !== void 0 ? _b : []).concat((_c = history.patches[0].value) === null || _c === void 0 ? void 0 : _c.borderInfo[0]);
|
|
330
|
+
nw = __assign(__assign({}, nw), {
|
|
331
|
+
config: __assign(__assign({}, nw.config), {
|
|
332
|
+
borderInfo: nwborderlist
|
|
333
|
+
})
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
return isBorderUndo ? nw : newContext;
|
|
300
337
|
});
|
|
301
338
|
}
|
|
302
|
-
}, [emitOp]);
|
|
339
|
+
}, [emitOp, globalCache]);
|
|
303
340
|
useEffect(function () {
|
|
304
341
|
var _a, _b;
|
|
305
342
|
(_b = (_a = mergedSettings.hooks) === null || _a === void 0 ? void 0 : _a.afterActivateSheet) === null || _b === void 0 ? void 0 : _b.call(_a, context.currentSheetId);
|
|
@@ -74,6 +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);
|
|
78
|
+
var isComposingRef = (0, _react.useRef)(false);
|
|
79
|
+
var placeCursorAtEnd = function placeCursorAtEnd(el) {
|
|
80
|
+
var range = document.createRange();
|
|
81
|
+
var sel = window.getSelection();
|
|
82
|
+
range.selectNodeContents(el);
|
|
83
|
+
range.collapse(false);
|
|
84
|
+
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
|
|
85
|
+
sel === null || sel === void 0 ? void 0 : sel.addRange(range);
|
|
86
|
+
};
|
|
87
|
+
var ensureNotEmpty = function ensureNotEmpty() {
|
|
88
|
+
var el = rootRef.current;
|
|
89
|
+
if (!el) return;
|
|
90
|
+
if (el.textContent === "") {
|
|
91
|
+
el.innerHTML = "\u200B";
|
|
92
|
+
placeCursorAtEnd(el);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
77
95
|
var handleShowFormulaHint = function handleShowFormulaHint() {
|
|
78
96
|
localStorage.setItem("formulaMore", String(showFormulaHint));
|
|
79
97
|
setShowFormulaHint(!showFormulaHint);
|
|
@@ -139,7 +157,7 @@ var InputBox = function InputBox() {
|
|
|
139
157
|
}
|
|
140
158
|
}
|
|
141
159
|
refs.globalCache.overwriteCell = false;
|
|
142
|
-
if (!refs.globalCache.ignoreWriteCell) inputRef.current.innerHTML = (0, _fortuneCore.escapeHTMLTag)((0, _fortuneCore.escapeScriptTag)(value_1));
|
|
160
|
+
if (!refs.globalCache.ignoreWriteCell && inputRef.current) inputRef.current.innerHTML = (0, _fortuneCore.escapeHTMLTag)((0, _fortuneCore.escapeScriptTag)(value_1));
|
|
143
161
|
refs.globalCache.ignoreWriteCell = false;
|
|
144
162
|
if (!refs.globalCache.doNotFocus) {
|
|
145
163
|
setTimeout(function () {
|
|
@@ -161,6 +179,7 @@ var InputBox = function InputBox() {
|
|
|
161
179
|
}, [context.luckysheet_select_save]);
|
|
162
180
|
(0, _react.useEffect)(function () {
|
|
163
181
|
var _a;
|
|
182
|
+
if (isComposingRef.current) return;
|
|
164
183
|
if (!firstSelection || ((_a = context.rangeDialog) === null || _a === void 0 ? void 0 : _a.show) || _lodash.default.isEmpty(context.luckysheetCellUpdate)) {
|
|
165
184
|
setIsInputBoxActive(false);
|
|
166
185
|
}
|
|
@@ -170,6 +189,7 @@ var InputBox = function InputBox() {
|
|
|
170
189
|
}, []);
|
|
171
190
|
var insertSelectedFormula = (0, _react.useCallback)(function (formulaName) {
|
|
172
191
|
var _a;
|
|
192
|
+
if (isComposingRef.current) return;
|
|
173
193
|
if (/^=[a-zA-Z]+$/.test(inputRef.current.innerText)) {
|
|
174
194
|
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
195
|
inputRef.current.innerHTML = ht;
|
|
@@ -234,6 +254,7 @@ var InputBox = function InputBox() {
|
|
|
234
254
|
}, [getActiveFormula]);
|
|
235
255
|
var selectActiveFormula = (0, _react.useCallback)(function (e) {
|
|
236
256
|
var _a, _b;
|
|
257
|
+
if (isComposingRef.current) return;
|
|
237
258
|
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
259
|
var lastSpanText = getLastInputSpanText();
|
|
239
260
|
if (formulaName && !(0, _helper.isLetterNumberPattern)(lastSpanText)) {
|
|
@@ -244,6 +265,7 @@ var InputBox = function InputBox() {
|
|
|
244
265
|
}, [getActiveFormula, insertSelectedFormula]);
|
|
245
266
|
var selectActiveFormulaOnClick = (0, _react.useCallback)(function (e) {
|
|
246
267
|
var _a, _b;
|
|
268
|
+
if (isComposingRef.current || !inputRef.current) return;
|
|
247
269
|
if (e.target.className.includes("sign-fortune")) return;
|
|
248
270
|
preText.current = inputRef.current.innerText;
|
|
249
271
|
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 +282,10 @@ var InputBox = function InputBox() {
|
|
|
260
282
|
};
|
|
261
283
|
var onKeyDown = (0, _react.useCallback)(function (e) {
|
|
262
284
|
var _a, _b;
|
|
285
|
+
if (isComposingRef.current || !inputRef.current) {
|
|
286
|
+
ensureNotEmpty();
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
263
289
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
264
290
|
preText.current = inputRef.current.innerText;
|
|
265
291
|
if (e.metaKey) {
|
|
@@ -277,8 +303,10 @@ var InputBox = function InputBox() {
|
|
|
277
303
|
stopPropagation(e);
|
|
278
304
|
}
|
|
279
305
|
}
|
|
280
|
-
|
|
281
|
-
|
|
306
|
+
if (!isComposingRef.current) {
|
|
307
|
+
var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
308
|
+
setCommaCount(currentCommaCount);
|
|
309
|
+
}
|
|
282
310
|
var allowListNavigation = true;
|
|
283
311
|
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)) {
|
|
284
312
|
setTimeout(function () {
|
|
@@ -395,6 +423,9 @@ var InputBox = function InputBox() {
|
|
|
395
423
|
};
|
|
396
424
|
var onChange = (0, _react.useCallback)(function (__, isBlur) {
|
|
397
425
|
var _a;
|
|
426
|
+
if (isComposingRef.current) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
398
429
|
if (context.isFlvReadOnly) return;
|
|
399
430
|
handleHideShowHint();
|
|
400
431
|
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())) {
|
|
@@ -402,8 +433,10 @@ var InputBox = function InputBox() {
|
|
|
402
433
|
} else {
|
|
403
434
|
setShowSearchHint(false);
|
|
404
435
|
}
|
|
405
|
-
|
|
406
|
-
|
|
436
|
+
if (!isComposingRef.current) {
|
|
437
|
+
var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
438
|
+
setCommaCount(currentCommaCount);
|
|
439
|
+
}
|
|
407
440
|
var e = lastKeyDownEventRef.current;
|
|
408
441
|
if (!e) return;
|
|
409
442
|
var kcode = e.keyCode;
|
|
@@ -419,6 +452,7 @@ var InputBox = function InputBox() {
|
|
|
419
452
|
}
|
|
420
453
|
}, [refs.cellInput, refs.fxInput, setContext]);
|
|
421
454
|
var onPaste = (0, _react.useCallback)(function (e) {
|
|
455
|
+
if (isComposingRef.current) return;
|
|
422
456
|
if (_lodash.default.isEmpty(context.luckysheetCellUpdate)) {
|
|
423
457
|
e.preventDefault();
|
|
424
458
|
}
|
|
@@ -564,12 +598,44 @@ var InputBox = function InputBox() {
|
|
|
564
598
|
minHeight: firstSelection.height
|
|
565
599
|
}, inputBoxStyle) : {}
|
|
566
600
|
}, /*#__PURE__*/_react.default.createElement(_ContentEditable.default, {
|
|
601
|
+
onCompositionStart: function onCompositionStart() {
|
|
602
|
+
isComposingRef.current = true;
|
|
603
|
+
console.log("onCompositionStart");
|
|
604
|
+
},
|
|
605
|
+
onCompositionUpdate: function onCompositionUpdate(e) {
|
|
606
|
+
window.CompositData = e.currentTarget.innerText;
|
|
607
|
+
isComposingRef.current = true;
|
|
608
|
+
console.log("onCompositionUpdate", e.currentTarget.innerText);
|
|
609
|
+
},
|
|
610
|
+
onCompositionEnd: function onCompositionEnd(e) {
|
|
611
|
+
ensureNotEmpty();
|
|
612
|
+
var rowIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus) || 0;
|
|
613
|
+
var colIndex = (firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus) || 0;
|
|
614
|
+
console.log("onCompositionEnd", e.currentTarget.innerText, getCellAddress(), rowIndex, colIndex, _fortuneCore.setCellValue);
|
|
615
|
+
window.CompositData = e.currentTarget.innerText;
|
|
616
|
+
setContext(function (draftCtx) {
|
|
617
|
+
(0, _fortuneCore.setCellValue)(draftCtx, rowIndex, colIndex, null, window.CompositData);
|
|
618
|
+
window.CompositData = "";
|
|
619
|
+
});
|
|
620
|
+
isComposingRef.current = false;
|
|
621
|
+
},
|
|
567
622
|
onMouseUp: function onMouseUp() {
|
|
623
|
+
if (isComposingRef.current) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
568
626
|
handleHideShowHint();
|
|
569
|
-
|
|
570
|
-
|
|
627
|
+
if (!isComposingRef.current) {
|
|
628
|
+
var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
629
|
+
setCommaCount(currentCommaCount);
|
|
630
|
+
}
|
|
571
631
|
},
|
|
572
632
|
innerRef: function innerRef(e) {
|
|
633
|
+
rootRef.current = e;
|
|
634
|
+
if (isComposingRef.current) {
|
|
635
|
+
inputRef.current = null;
|
|
636
|
+
refs.cellInput.current = null;
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
573
639
|
inputRef.current = e;
|
|
574
640
|
refs.cellInput.current = e;
|
|
575
641
|
},
|
|
@@ -140,6 +140,7 @@ 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;
|
|
143
144
|
dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
|
|
144
145
|
celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
|
|
145
146
|
insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: () => void) => void;
|
|
@@ -396,6 +396,12 @@ 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
|
+
},
|
|
399
405
|
dataToCelldata: function dataToCelldata(data) {
|
|
400
406
|
return _fortuneCore.api.dataToCelldata(data);
|
|
401
407
|
},
|
|
@@ -147,6 +147,7 @@ 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;
|
|
150
151
|
dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
|
|
151
152
|
celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number | undefined, colCount?: number | undefined) => CellMatrix | null;
|
|
152
153
|
insertFunction: (selectedFuncIndex: number, filteredFunctionList: any[], callback?: (() => void) | undefined) => void;
|
|
@@ -26,6 +26,16 @@ var _SheetList = _interopRequireDefault(require("../SheetList"));
|
|
|
26
26
|
var _DunePreview = _interopRequireDefault(require("../DunePreview/DunePreview"));
|
|
27
27
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
28
28
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
29
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
30
|
+
__assign = Object.assign || function (t) {
|
|
31
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
32
|
+
s = arguments[i];
|
|
33
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
34
|
+
}
|
|
35
|
+
return t;
|
|
36
|
+
};
|
|
37
|
+
return __assign.apply(this, arguments);
|
|
38
|
+
};
|
|
29
39
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
30
40
|
var t = {};
|
|
31
41
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -261,7 +271,11 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
|
|
|
261
271
|
var history = globalCache.current.undoList.pop();
|
|
262
272
|
if (history) {
|
|
263
273
|
setContext(function (ctx_) {
|
|
264
|
-
var _a, _b, _c, _d, _e;
|
|
274
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
275
|
+
var isBorderUndo = history.patches.some(function (onePatch) {
|
|
276
|
+
var _a;
|
|
277
|
+
return (_a = onePatch.value) === null || _a === void 0 ? void 0 : _a.borderInfo;
|
|
278
|
+
});
|
|
265
279
|
if ((_a = history.options) === null || _a === void 0 ? void 0 : _a.deleteSheetOp) {
|
|
266
280
|
history.inversePatches[0].path[1] = ctx_.luckysheetfile.length;
|
|
267
281
|
var order_1 = (_c = (_b = history.options.deletedSheet) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.order;
|
|
@@ -294,21 +308,44 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
|
|
|
294
308
|
delete inversedOptions.addSheet.value.data;
|
|
295
309
|
}
|
|
296
310
|
emitOp(newContext, history.inversePatches, inversedOptions, true);
|
|
297
|
-
|
|
311
|
+
var nw = __assign({}, newContext);
|
|
312
|
+
if (isBorderUndo) {
|
|
313
|
+
var nwborderlist = (_g = (_f = nw === null || nw === void 0 ? void 0 : nw.config) === null || _f === void 0 ? void 0 : _f.borderInfo) === null || _g === void 0 ? void 0 : _g.slice(0, -1);
|
|
314
|
+
nw = __assign(__assign({}, nw), {
|
|
315
|
+
config: __assign(__assign({}, nw.config), {
|
|
316
|
+
borderInfo: nwborderlist
|
|
317
|
+
})
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
return isBorderUndo ? nw : newContext;
|
|
298
321
|
});
|
|
299
322
|
}
|
|
300
|
-
}, [emitOp]);
|
|
323
|
+
}, [emitOp, globalCache]);
|
|
301
324
|
var handleRedo = (0, _react.useCallback)(function () {
|
|
302
325
|
var history = globalCache.current.redoList.pop();
|
|
303
326
|
if (history) {
|
|
304
327
|
setContext(function (ctx_) {
|
|
328
|
+
var _a, _b, _c;
|
|
305
329
|
var newContext = (0, _immer.applyPatches)(ctx_, history.patches);
|
|
330
|
+
var isBorderUndo = history.patches.some(function (onePatch) {
|
|
331
|
+
var _a;
|
|
332
|
+
return (_a = onePatch.value) === null || _a === void 0 ? void 0 : _a.borderInfo;
|
|
333
|
+
});
|
|
306
334
|
globalCache.current.undoList.push(history);
|
|
307
335
|
emitOp(newContext, history.patches, history.options);
|
|
308
|
-
|
|
336
|
+
var nw = __assign({}, newContext);
|
|
337
|
+
if (isBorderUndo) {
|
|
338
|
+
var nwborderlist = ((_b = (_a = nw === null || nw === void 0 ? void 0 : nw.config) === null || _a === void 0 ? void 0 : _a.borderInfo) !== null && _b !== void 0 ? _b : []).concat((_c = history.patches[0].value) === null || _c === void 0 ? void 0 : _c.borderInfo[0]);
|
|
339
|
+
nw = __assign(__assign({}, nw), {
|
|
340
|
+
config: __assign(__assign({}, nw.config), {
|
|
341
|
+
borderInfo: nwborderlist
|
|
342
|
+
})
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
return isBorderUndo ? nw : newContext;
|
|
309
346
|
});
|
|
310
347
|
}
|
|
311
|
-
}, [emitOp]);
|
|
348
|
+
}, [emitOp, globalCache]);
|
|
312
349
|
(0, _react.useEffect)(function () {
|
|
313
350
|
var _a, _b;
|
|
314
351
|
(_b = (_a = mergedSettings.hooks) === null || _a === void 0 ? void 0 : _a.afterActivateSheet) === null || _b === void 0 ? void 0 : _b.call(_a, context.currentSheetId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fileverse-dev/fortune-react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.88",
|
|
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.
|
|
19
|
+
"@fileverse-dev/fortune-core": "1.2.88",
|
|
20
20
|
"@fileverse/ui": "^4.1.7-patch-40",
|
|
21
21
|
"@tippyjs/react": "^4.2.6",
|
|
22
22
|
"@types/regenerator-runtime": "^0.13.6",
|