@leankylin-sheet/react 7.0.41 → 7.0.43
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/dist/components/SheetOverlay/UpdatingMask.d.ts +3 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/index.css +45 -1
- package/dist/index.esm.css +45 -1
- package/dist/index.esm.js +173 -39
- package/dist/index.js +171 -37
- package/dist/index.umd.css +45 -1
- package/dist/index.umd.js +171 -37
- package/dist/index.umd.min.css +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/utils/commitWithMask.d.ts +5 -0
- package/package.json +3 -3
package/dist/context/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare const WorkbookContext: React.Context<{
|
|
|
18
18
|
context: Context;
|
|
19
19
|
setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void;
|
|
20
20
|
setScrollContext: (recipe: (ctx: Context) => void) => void;
|
|
21
|
+
commitWithMask: (recipe: (ctx: Context) => void, options?: SetContextOptions, $input?: HTMLDivElement | null, force?: boolean) => void;
|
|
21
22
|
settings: Required<Settings>;
|
|
22
23
|
refs: RefValues;
|
|
23
24
|
handleUndo: () => void;
|
package/dist/index.css
CHANGED
|
@@ -431,6 +431,50 @@ html::-webkit-scrollbar-button {
|
|
|
431
431
|
white-space: pre-wrap;
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
+
/* 选区级「修改中」遮罩:盖住当前选区(提交 / 粘贴后重算期间) */
|
|
435
|
+
.luckysheet-updating-mask {
|
|
436
|
+
position: absolute;
|
|
437
|
+
z-index: 30;
|
|
438
|
+
display: flex;
|
|
439
|
+
align-items: center;
|
|
440
|
+
justify-content: center;
|
|
441
|
+
gap: 6px;
|
|
442
|
+
box-sizing: border-box;
|
|
443
|
+
padding: 0 4px;
|
|
444
|
+
font-size: 12px;
|
|
445
|
+
line-height: 1.4;
|
|
446
|
+
color: #333;
|
|
447
|
+
background-color: rgb(255 255 255 / 70%);
|
|
448
|
+
cursor: progress;
|
|
449
|
+
pointer-events: all;
|
|
450
|
+
-webkit-user-select: none;
|
|
451
|
+
-moz-user-select: none;
|
|
452
|
+
user-select: none;
|
|
453
|
+
overflow: hidden;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.luckysheet-updating-mask-text {
|
|
457
|
+
overflow: hidden;
|
|
458
|
+
white-space: nowrap;
|
|
459
|
+
text-overflow: ellipsis;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.luckysheet-updating-mask-spinner {
|
|
463
|
+
flex: 0 0 auto;
|
|
464
|
+
width: 12px;
|
|
465
|
+
height: 12px;
|
|
466
|
+
border: 2px solid #d9d9d9;
|
|
467
|
+
border-top-color: #5292f7;
|
|
468
|
+
border-radius: 50%;
|
|
469
|
+
animation: luckysheet-updating-mask-spin 0.8s linear infinite;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
@keyframes luckysheet-updating-mask-spin {
|
|
473
|
+
to {
|
|
474
|
+
transform: rotate(360deg);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
434
478
|
.luckysheet-formula-text-color {
|
|
435
479
|
color: black;
|
|
436
480
|
}
|
|
@@ -4127,9 +4171,9 @@ label {
|
|
|
4127
4171
|
width: 100%;
|
|
4128
4172
|
margin-top: 2px;
|
|
4129
4173
|
margin-bottom: 2px;
|
|
4130
|
-
margin-right: 46px;
|
|
4131
4174
|
border-radius: 4px;
|
|
4132
4175
|
cursor: pointer;
|
|
4176
|
+
position: relative;
|
|
4133
4177
|
}
|
|
4134
4178
|
|
|
4135
4179
|
.leankylin-sheet-list-item-name {
|
package/dist/index.esm.css
CHANGED
|
@@ -431,6 +431,50 @@ html::-webkit-scrollbar-button {
|
|
|
431
431
|
white-space: pre-wrap;
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
+
/* 选区级「修改中」遮罩:盖住当前选区(提交 / 粘贴后重算期间) */
|
|
435
|
+
.luckysheet-updating-mask {
|
|
436
|
+
position: absolute;
|
|
437
|
+
z-index: 30;
|
|
438
|
+
display: flex;
|
|
439
|
+
align-items: center;
|
|
440
|
+
justify-content: center;
|
|
441
|
+
gap: 6px;
|
|
442
|
+
box-sizing: border-box;
|
|
443
|
+
padding: 0 4px;
|
|
444
|
+
font-size: 12px;
|
|
445
|
+
line-height: 1.4;
|
|
446
|
+
color: #333;
|
|
447
|
+
background-color: rgb(255 255 255 / 70%);
|
|
448
|
+
cursor: progress;
|
|
449
|
+
pointer-events: all;
|
|
450
|
+
-webkit-user-select: none;
|
|
451
|
+
-moz-user-select: none;
|
|
452
|
+
user-select: none;
|
|
453
|
+
overflow: hidden;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.luckysheet-updating-mask-text {
|
|
457
|
+
overflow: hidden;
|
|
458
|
+
white-space: nowrap;
|
|
459
|
+
text-overflow: ellipsis;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.luckysheet-updating-mask-spinner {
|
|
463
|
+
flex: 0 0 auto;
|
|
464
|
+
width: 12px;
|
|
465
|
+
height: 12px;
|
|
466
|
+
border: 2px solid #d9d9d9;
|
|
467
|
+
border-top-color: #5292f7;
|
|
468
|
+
border-radius: 50%;
|
|
469
|
+
animation: luckysheet-updating-mask-spin 0.8s linear infinite;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
@keyframes luckysheet-updating-mask-spin {
|
|
473
|
+
to {
|
|
474
|
+
transform: rotate(360deg);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
434
478
|
.luckysheet-formula-text-color {
|
|
435
479
|
color: black;
|
|
436
480
|
}
|
|
@@ -4127,9 +4171,9 @@ label {
|
|
|
4127
4171
|
width: 100%;
|
|
4128
4172
|
margin-top: 2px;
|
|
4129
4173
|
margin-bottom: 2px;
|
|
4130
|
-
margin-right: 46px;
|
|
4131
4174
|
border-radius: 4px;
|
|
4132
4175
|
cursor: pointer;
|
|
4176
|
+
position: relative;
|
|
4133
4177
|
}
|
|
4134
4178
|
|
|
4135
4179
|
.leankylin-sheet-list-item-name {
|
package/dist/index.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defaultContext, defaultSettings, getSheetIndex, colLocationByIndex, fixPositionOnFrozenCells, colLocation, getFlowdata, isAllowEdit,
|
|
1
|
+
import { defaultContext, defaultSettings, israngeseleciton, getSheetIndex, colLocationByIndex, fixPositionOnFrozenCells, colLocation, getFlowdata, isAllowEdit, handleColSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleContextMenu, selectTitlesMap, selectTitlesRange, fixColumnStyleOverflowInFreeze, handleColumnHeaderMouseDown, rowLocationByIndex, rowLocation, handleRowSizeHandleMouseDown, handleRowFreezeHandleMouseDown, fixRowStyleOverflowInFreeze, handleRowHeaderMouseDown, functionHTMLGenerate, locale, getCellValue, createRangeHightlight, isInlineStringCell, getInlineStringHTML, valueShowEs, escapeHTMLTag, escapeScriptTag, isShowHidenCR, cancelNormalSelected, moveHighlightCell, updateCell, handleFormulaInput, onSearchDialogMoveStart, replaceAll, replace, searchAll, searchNext, changeSheet, normalizeSelection, scrollToHighlightCell, chatatABC, getCellHyperlink, isLinkValid, getRangetxt, goToLink, replaceHtml, removeHyperlink, onRangeSelectionModalMoveStart, saveHyperlink, createFilterOptions, onImageMoveStart, onImageResizeStart, showComments, setEditingComment, onCommentBoxMoveStart, onCommentBoxResizeStart, confirmMessage, getRangeByTxt, getDropdownList, setCellValue, setConditionRules, mergeBorder, setDropcownValue, handleCellAreaMouseMove, handleCellAreaDragOver, handleCellDrop, handleCellAreaDoubleClick, selectAll, showLinkCard, getCellRowColumn, handleOverlayMouseMove, handleOverlayMouseUp, handleKeydownForZoom, handleOverlayTouchStart, handleOverlayTouchMove, handleOverlayTouchEnd, PAINT_MODEL_CURSOR, onCellsMoveStart, createDropCellRange, handleDropCellDoubleClick, handleCellAreaMouseDown, updateContextWithSheetData, updateContextWithCanvas, initFreeze, Canvas, handleGlobalWheel, setCaretPosition, getDataArr, updateMoreCell, getRegStr, getOptionValue, getSelectRange, applyLocation, updateItem, normalizedCellAttr, update, updateFormat, handleTextSize, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, showImgChooser, insertImage, editComment, deleteComment, showHideComment, showHideAllComments, newComment, handleSum, autoSelectionFormula, handleMerge, handleBorder, handleFreeze, handleSort, createFilter, clearFilter, handleAutoRecalc, toolbarItemSelectedFunc, toolbarItemClickHandler, handleTextColor, handleTextBackground, getDataBySelectionNoCopy, getInlineStringNoStyle, rangeHightlightselected, editSheetName, setNextSheet, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, addSheet, indexToColumnChar, sortSelection, handleCopy, insertRowCol, deleteRowCol, hideSelected, showSelected, api, removeActiveImage, deleteSelectedCellText, jfrefreshgrid, handleLink, deleteSheet, opToPatch, orderbydatafiler, getFilterColumnValues, getFilterColumnColors, saveFilter, cancelActiveImgItem, patchToOp, filterPatch, isCellEditUnchanged, inverseRowColOptions, ensureSheetIndex, initSheetIndex, handlePasteByLeanklin, handleGlobalKeyDown, groupValuesRefresh } from '@leankylin-sheet/core';
|
|
2
2
|
import { useInViewport, useMemoizedFn, useThrottleFn } from 'ahooks';
|
|
3
3
|
import React, { useContext, useRef, useState, useMemo, useCallback, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
|
|
4
4
|
import produce, { applyPatches, enablePatches, produceWithPatches } from 'immer';
|
|
5
5
|
import _ from 'lodash';
|
|
6
|
-
import { createPortal } from 'react-dom';
|
|
6
|
+
import { flushSync, createPortal } from 'react-dom';
|
|
7
7
|
|
|
8
8
|
function _iterableToArrayLimit(r, l) {
|
|
9
9
|
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
@@ -557,6 +557,7 @@ var WorkbookContext = /*#__PURE__*/React.createContext({
|
|
|
557
557
|
context: defaultContext(defaultRefs),
|
|
558
558
|
setContext: function setContext() {},
|
|
559
559
|
setScrollContext: function setScrollContext() {},
|
|
560
|
+
commitWithMask: function commitWithMask() {},
|
|
560
561
|
settings: defaultSettings,
|
|
561
562
|
handleUndo: function handleUndo() {},
|
|
562
563
|
handleRedo: function handleRedo() {},
|
|
@@ -591,11 +592,51 @@ var SVGIcon = function SVGIcon(_ref) {
|
|
|
591
592
|
}));
|
|
592
593
|
};
|
|
593
594
|
|
|
595
|
+
function isBlurCommitContext(ctx) {
|
|
596
|
+
if (ctx.isUpdatingCell) return false;
|
|
597
|
+
if (!ctx.luckysheetCellUpdate || ctx.luckysheetCellUpdate.length === 0) {
|
|
598
|
+
return false;
|
|
599
|
+
}
|
|
600
|
+
if (ctx.active_f) return false;
|
|
601
|
+
var _ctx$formulaCache = ctx.formulaCache,
|
|
602
|
+
rangestart = _ctx$formulaCache.rangestart,
|
|
603
|
+
rangedrag_column_start = _ctx$formulaCache.rangedrag_column_start,
|
|
604
|
+
rangedrag_row_start = _ctx$formulaCache.rangedrag_row_start;
|
|
605
|
+
if (rangestart || rangedrag_column_start || rangedrag_row_start) return false;
|
|
606
|
+
if (israngeseleciton(ctx)) return false;
|
|
607
|
+
return true;
|
|
608
|
+
}
|
|
609
|
+
function createCommitWithMask(setContext) {
|
|
610
|
+
return function (recipe, options) {
|
|
611
|
+
flushSync(function () {
|
|
612
|
+
setContext(function (ctx) {
|
|
613
|
+
ctx.isUpdatingCell = true;
|
|
614
|
+
}, {
|
|
615
|
+
noHistory: true
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
requestAnimationFrame(function () {
|
|
619
|
+
requestAnimationFrame(function () {
|
|
620
|
+
try {
|
|
621
|
+
setContext(recipe, options);
|
|
622
|
+
} finally {
|
|
623
|
+
setContext(function (ctx) {
|
|
624
|
+
ctx.isUpdatingCell = false;
|
|
625
|
+
}, {
|
|
626
|
+
noHistory: true
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
|
|
594
634
|
var ColumnHeader = function ColumnHeader() {
|
|
595
635
|
var _refs$globalCache$fre2, _settings$renderFreez;
|
|
596
636
|
var _useContext = useContext(WorkbookContext),
|
|
597
637
|
context = _useContext.context,
|
|
598
638
|
setContext = _useContext.setContext,
|
|
639
|
+
commitWithMask = _useContext.commitWithMask,
|
|
599
640
|
settings = _useContext.settings,
|
|
600
641
|
refs = _useContext.refs;
|
|
601
642
|
var containerRef = useRef(null);
|
|
@@ -659,10 +700,15 @@ var ColumnHeader = function ColumnHeader() {
|
|
|
659
700
|
}, [context, hoverLocation.col_index, refs.globalCache.freezen]);
|
|
660
701
|
var onMouseDown = useCallback(function (e) {
|
|
661
702
|
var nativeEvent = e.nativeEvent;
|
|
662
|
-
|
|
703
|
+
var runRecipe = function runRecipe(draftCtx) {
|
|
663
704
|
handleColumnHeaderMouseDown(draftCtx, refs.globalCache, nativeEvent, containerRef.current, refs.cellInput.current, refs.fxInput.current);
|
|
664
|
-
}
|
|
665
|
-
|
|
705
|
+
};
|
|
706
|
+
if (isBlurCommitContext(context)) {
|
|
707
|
+
commitWithMask(runRecipe);
|
|
708
|
+
} else {
|
|
709
|
+
setContext(runRecipe);
|
|
710
|
+
}
|
|
711
|
+
}, [context, commitWithMask, refs.globalCache, refs.cellInput, refs.fxInput, setContext]);
|
|
666
712
|
var onMouseLeave = useCallback(function () {
|
|
667
713
|
if (context.luckysheet_cols_change_size) {
|
|
668
714
|
return;
|
|
@@ -818,6 +864,7 @@ var RowHeader = function RowHeader() {
|
|
|
818
864
|
var _useContext = useContext(WorkbookContext),
|
|
819
865
|
context = _useContext.context,
|
|
820
866
|
setContext = _useContext.setContext,
|
|
867
|
+
commitWithMask = _useContext.commitWithMask,
|
|
821
868
|
settings = _useContext.settings,
|
|
822
869
|
refs = _useContext.refs;
|
|
823
870
|
var rowChangeSizeRef = useRef(null);
|
|
@@ -875,10 +922,15 @@ var RowHeader = function RowHeader() {
|
|
|
875
922
|
}, [context.luckysheet_rows_change_size, context.visibledatarow, hoverLocation.row, hoverLocation.row_pre, refs.globalCache.freezen, context.currentSheetId]);
|
|
876
923
|
var onMouseDown = useCallback(function (e) {
|
|
877
924
|
var nativeEvent = e.nativeEvent;
|
|
878
|
-
|
|
925
|
+
var runRecipe = function runRecipe(draftCtx) {
|
|
879
926
|
handleRowHeaderMouseDown(draftCtx, refs.globalCache, nativeEvent, containerRef.current, refs.cellInput.current, refs.fxInput.current);
|
|
880
|
-
}
|
|
881
|
-
|
|
927
|
+
};
|
|
928
|
+
if (isBlurCommitContext(context)) {
|
|
929
|
+
commitWithMask(runRecipe);
|
|
930
|
+
} else {
|
|
931
|
+
setContext(runRecipe);
|
|
932
|
+
}
|
|
933
|
+
}, [context, commitWithMask, refs.globalCache, refs.cellInput, refs.fxInput, setContext]);
|
|
882
934
|
var onMouseLeave = useCallback(function () {
|
|
883
935
|
if (context.luckysheet_rows_change_size) {
|
|
884
936
|
return;
|
|
@@ -1483,6 +1535,7 @@ var InputBox = function InputBox() {
|
|
|
1483
1535
|
var _useContext = useContext(WorkbookContext),
|
|
1484
1536
|
context = _useContext.context,
|
|
1485
1537
|
setContext = _useContext.setContext,
|
|
1538
|
+
commitWithMask = _useContext.commitWithMask,
|
|
1486
1539
|
refs = _useContext.refs,
|
|
1487
1540
|
settings = _useContext.settings;
|
|
1488
1541
|
var inputRef = useRef(null);
|
|
@@ -1564,6 +1617,11 @@ var InputBox = function InputBox() {
|
|
|
1564
1617
|
var onKeyDown = useCallback(function (e) {
|
|
1565
1618
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
1566
1619
|
preText.current = inputRef.current.innerText;
|
|
1620
|
+
if (context.isUpdatingCell) {
|
|
1621
|
+
e.preventDefault();
|
|
1622
|
+
e.stopPropagation();
|
|
1623
|
+
return;
|
|
1624
|
+
}
|
|
1567
1625
|
if (e.key === "Escape" && context.luckysheetCellUpdate.length > 0) {
|
|
1568
1626
|
setContext(function (draftCtx) {
|
|
1569
1627
|
cancelNormalSelected(draftCtx);
|
|
@@ -1577,17 +1635,18 @@ var InputBox = function InputBox() {
|
|
|
1577
1635
|
e.stopPropagation();
|
|
1578
1636
|
}
|
|
1579
1637
|
} else if (e.key === "Tab" && context.luckysheetCellUpdate.length > 0) {
|
|
1580
|
-
setContext(function (draftCtx) {
|
|
1581
|
-
updateCell(draftCtx, draftCtx.luckysheetCellUpdate[0], draftCtx.luckysheetCellUpdate[1], refs.cellInput.current);
|
|
1582
|
-
moveHighlightCell(draftCtx, "right", 1, "rangeOfSelect");
|
|
1583
|
-
});
|
|
1584
1638
|
e.preventDefault();
|
|
1585
1639
|
e.stopPropagation();
|
|
1640
|
+
commitWithMask(function (draftCtx) {
|
|
1641
|
+
updateCell(draftCtx, draftCtx.luckysheetCellUpdate[0], draftCtx.luckysheetCellUpdate[1], refs.cellInput.current);
|
|
1642
|
+
moveHighlightCell(draftCtx, "right", 1, "rangeOfSelect");
|
|
1643
|
+
}, undefined, refs.cellInput.current);
|
|
1586
1644
|
} else if (e.key === "F4" && context.luckysheetCellUpdate.length > 0) {
|
|
1587
1645
|
e.preventDefault();
|
|
1588
1646
|
}
|
|
1589
|
-
}, [context.luckysheetCellUpdate.length, refs.cellInput, setContext]);
|
|
1647
|
+
}, [context.luckysheetCellUpdate.length, context.isUpdatingCell, commitWithMask, refs.cellInput, setContext]);
|
|
1590
1648
|
var onChange = useCallback(function (__, isBlur) {
|
|
1649
|
+
if (context.isUpdatingCell) return;
|
|
1591
1650
|
var e = lastKeyDownEventRef.current;
|
|
1592
1651
|
if (!e) return;
|
|
1593
1652
|
var kcode = e.keyCode;
|
|
@@ -1600,7 +1659,7 @@ var InputBox = function InputBox() {
|
|
|
1600
1659
|
});
|
|
1601
1660
|
}
|
|
1602
1661
|
lastKeyDownEventRef.current = undefined;
|
|
1603
|
-
}, [refs.cellInput, refs.fxInput, setContext]);
|
|
1662
|
+
}, [context.isUpdatingCell, refs.cellInput, refs.fxInput, setContext]);
|
|
1604
1663
|
var onPaste = useCallback(function (e) {
|
|
1605
1664
|
if (_.isEmpty(context.luckysheetCellUpdate)) {
|
|
1606
1665
|
e.preventDefault();
|
|
@@ -1654,7 +1713,7 @@ var InputBox = function InputBox() {
|
|
|
1654
1713
|
onChange: onChange,
|
|
1655
1714
|
onKeyDown: onKeyDown,
|
|
1656
1715
|
onPaste: onPaste,
|
|
1657
|
-
allowEdit: edit ? !isHidenRC : edit
|
|
1716
|
+
allowEdit: edit ? !isHidenRC && !context.isUpdatingCell : edit
|
|
1658
1717
|
})), document.activeElement === inputRef.current && ( /*#__PURE__*/React.createElement(React.Fragment, null, (_settings$renderEdito = settings.renderEditorSelector) === null || _settings$renderEdito === void 0 ? void 0 : _settings$renderEdito.call(settings, inputRef.current, context.functionCandidates, context.functionHint, context.formulaCache.functionlistMap), /*#__PURE__*/React.createElement(FormulaSearch, {
|
|
1659
1718
|
style: {
|
|
1660
1719
|
top: ((firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move) || 0) + 4
|
|
@@ -1666,6 +1725,30 @@ var InputBox = function InputBox() {
|
|
|
1666
1725
|
}))));
|
|
1667
1726
|
};
|
|
1668
1727
|
|
|
1728
|
+
var UpdatingMask = function UpdatingMask() {
|
|
1729
|
+
var _context$luckysheet_s;
|
|
1730
|
+
var _useContext = useContext(WorkbookContext),
|
|
1731
|
+
context = _useContext.context;
|
|
1732
|
+
if (!context.isUpdatingCell) return null;
|
|
1733
|
+
var selection = (_context$luckysheet_s = context.luckysheet_select_save) === null || _context$luckysheet_s === void 0 ? void 0 : _context$luckysheet_s[0];
|
|
1734
|
+
if (!selection || selection.left == null || selection.top == null) {
|
|
1735
|
+
return null;
|
|
1736
|
+
}
|
|
1737
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1738
|
+
className: "luckysheet-updating-mask",
|
|
1739
|
+
style: {
|
|
1740
|
+
left: selection.left,
|
|
1741
|
+
top: selection.top,
|
|
1742
|
+
width: selection.width,
|
|
1743
|
+
height: selection.height
|
|
1744
|
+
}
|
|
1745
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
1746
|
+
className: "luckysheet-updating-mask-spinner"
|
|
1747
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
1748
|
+
className: "luckysheet-updating-mask-text"
|
|
1749
|
+
}, locale(context).edit.updatingRelatedCells));
|
|
1750
|
+
};
|
|
1751
|
+
|
|
1669
1752
|
var ScrollBar = function ScrollBar(_ref) {
|
|
1670
1753
|
var axis = _ref.axis;
|
|
1671
1754
|
var _useContext = useContext(WorkbookContext),
|
|
@@ -4476,6 +4559,7 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
4476
4559
|
var _useContext = useContext(WorkbookContext),
|
|
4477
4560
|
context = _useContext.context,
|
|
4478
4561
|
setContext = _useContext.setContext,
|
|
4562
|
+
commitWithMask = _useContext.commitWithMask,
|
|
4479
4563
|
settings = _useContext.settings,
|
|
4480
4564
|
refs = _useContext.refs;
|
|
4481
4565
|
var _useInViewport = useInViewport(refs.cellArea),
|
|
@@ -4490,7 +4574,7 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
4490
4574
|
var cellAreaMouseDown = useCallback(function (e) {
|
|
4491
4575
|
var nativeEvent = e.nativeEvent;
|
|
4492
4576
|
if (e.button !== 2) {
|
|
4493
|
-
|
|
4577
|
+
var runRecipe = function runRecipe(draftCtx) {
|
|
4494
4578
|
var _draftCtx$luckysheet_;
|
|
4495
4579
|
handleCellAreaMouseDown(draftCtx, refs.globalCache, nativeEvent, refs.cellInput.current, refs.cellArea.current, refs.fxInput.current, refs.canvas.current.getContext("2d"));
|
|
4496
4580
|
if (!_.isEmpty((_draftCtx$luckysheet_ = draftCtx.luckysheet_select_save) === null || _draftCtx$luckysheet_ === void 0 ? void 0 : _draftCtx$luckysheet_[0]) && refs.cellInput.current) {
|
|
@@ -4499,9 +4583,14 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
4499
4583
|
(_refs$cellInput$curre = refs.cellInput.current) === null || _refs$cellInput$curre === void 0 ? void 0 : _refs$cellInput$curre.focus();
|
|
4500
4584
|
});
|
|
4501
4585
|
}
|
|
4502
|
-
}
|
|
4586
|
+
};
|
|
4587
|
+
if (isBlurCommitContext(context)) {
|
|
4588
|
+
commitWithMask(runRecipe);
|
|
4589
|
+
} else {
|
|
4590
|
+
setContext(runRecipe);
|
|
4591
|
+
}
|
|
4503
4592
|
}
|
|
4504
|
-
}, [setContext, refs.globalCache, refs.cellInput, refs.cellArea, refs.fxInput, refs.canvas]);
|
|
4593
|
+
}, [context, commitWithMask, setContext, refs.globalCache, refs.cellInput, refs.cellArea, refs.fxInput, refs.canvas]);
|
|
4505
4594
|
var debounceMouseMove = useMemoizedFn(function (e) {
|
|
4506
4595
|
var nativeEvent = e.nativeEvent;
|
|
4507
4596
|
handleCellAreaMouseMove(context, refs.globalCache, nativeEvent, refs.cellArea.current);
|
|
@@ -4544,10 +4633,11 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
4544
4633
|
}, [refs.workbookContainer, setContext, settings, refs.cellArea]);
|
|
4545
4634
|
var cellAreaDoubleClick = useCallback(function (e) {
|
|
4546
4635
|
var nativeEvent = e.nativeEvent;
|
|
4636
|
+
if (context.isUpdatingCell) return;
|
|
4547
4637
|
setContext(function (draftCtx) {
|
|
4548
4638
|
handleCellAreaDoubleClick(draftCtx, refs.globalCache, settings, nativeEvent, refs.cellArea.current);
|
|
4549
4639
|
});
|
|
4550
|
-
}, [refs.cellArea, refs.globalCache, setContext, settings]);
|
|
4640
|
+
}, [context.isUpdatingCell, refs.cellArea, refs.globalCache, setContext, settings]);
|
|
4551
4641
|
var onLeftTopClick = useCallback(function () {
|
|
4552
4642
|
setContext(function (draftCtx) {
|
|
4553
4643
|
selectAll(draftCtx);
|
|
@@ -4947,7 +5037,7 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
4947
5037
|
getContainer: function getContainer() {
|
|
4948
5038
|
return containerRef.current;
|
|
4949
5039
|
}
|
|
4950
|
-
}), /*#__PURE__*/React.createElement(InputBox, null), /*#__PURE__*/React.createElement(NotationBoxes, null), /*#__PURE__*/React.createElement("div", {
|
|
5040
|
+
}), /*#__PURE__*/React.createElement(InputBox, null), /*#__PURE__*/React.createElement(UpdatingMask, null), /*#__PURE__*/React.createElement(NotationBoxes, null), /*#__PURE__*/React.createElement("div", {
|
|
4951
5041
|
id: "luckysheet-multipleRange-show"
|
|
4952
5042
|
}), /*#__PURE__*/React.createElement("div", {
|
|
4953
5043
|
id: "luckysheet-dynamicArray-hightShow"
|
|
@@ -7892,6 +7982,7 @@ var FxEditor = function FxEditor() {
|
|
|
7892
7982
|
var _useContext = useContext(WorkbookContext),
|
|
7893
7983
|
context = _useContext.context,
|
|
7894
7984
|
setContext = _useContext.setContext,
|
|
7985
|
+
commitWithMask = _useContext.commitWithMask,
|
|
7895
7986
|
refs = _useContext.refs,
|
|
7896
7987
|
settings = _useContext.settings;
|
|
7897
7988
|
var _useState = useState(false),
|
|
@@ -7972,6 +8063,9 @@ var FxEditor = function FxEditor() {
|
|
|
7972
8063
|
if (context.allowEdit === false) {
|
|
7973
8064
|
return;
|
|
7974
8065
|
}
|
|
8066
|
+
if (context.isUpdatingCell) {
|
|
8067
|
+
return;
|
|
8068
|
+
}
|
|
7975
8069
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
7976
8070
|
var key = e.key;
|
|
7977
8071
|
recentText.current = refs.fxInput.current.innerText;
|
|
@@ -7981,7 +8075,7 @@ var FxEditor = function FxEditor() {
|
|
|
7981
8075
|
if (!["Enter", "Escape", "ArrowLeft", "ArrowRight"].includes(key)) {
|
|
7982
8076
|
return;
|
|
7983
8077
|
}
|
|
7984
|
-
|
|
8078
|
+
var runRecipe = function runRecipe(draftCtx) {
|
|
7985
8079
|
if (context.luckysheetCellUpdate.length > 0) {
|
|
7986
8080
|
switch (key) {
|
|
7987
8081
|
case "Enter":
|
|
@@ -7995,8 +8089,6 @@ var FxEditor = function FxEditor() {
|
|
|
7995
8089
|
column_focus: lastCellUpdate[1]
|
|
7996
8090
|
}];
|
|
7997
8091
|
moveHighlightCell(draftCtx, "down", 1, "rangeOfSelect");
|
|
7998
|
-
e.preventDefault();
|
|
7999
|
-
e.stopPropagation();
|
|
8000
8092
|
break;
|
|
8001
8093
|
}
|
|
8002
8094
|
case "Escape":
|
|
@@ -8019,8 +8111,15 @@ var FxEditor = function FxEditor() {
|
|
|
8019
8111
|
}
|
|
8020
8112
|
}
|
|
8021
8113
|
}
|
|
8022
|
-
}
|
|
8023
|
-
|
|
8114
|
+
};
|
|
8115
|
+
if (key === "Enter" && context.luckysheetCellUpdate.length > 0) {
|
|
8116
|
+
e.preventDefault();
|
|
8117
|
+
e.stopPropagation();
|
|
8118
|
+
commitWithMask(runRecipe, undefined, refs.fxInput.current);
|
|
8119
|
+
return;
|
|
8120
|
+
}
|
|
8121
|
+
setContext(runRecipe);
|
|
8122
|
+
}, [context.allowEdit, context.luckysheetCellUpdate.length, context.isUpdatingCell, commitWithMask, refs.fxInput, setContext]);
|
|
8024
8123
|
var onChange = useCallback(function () {
|
|
8025
8124
|
var e = lastKeyDownEventRef.current;
|
|
8026
8125
|
if (!e) return;
|
|
@@ -8039,11 +8138,14 @@ var FxEditor = function FxEditor() {
|
|
|
8039
8138
|
if (isHidenRC) {
|
|
8040
8139
|
return false;
|
|
8041
8140
|
}
|
|
8141
|
+
if (context.isUpdatingCell) {
|
|
8142
|
+
return false;
|
|
8143
|
+
}
|
|
8042
8144
|
if (!isAllowEdit(context, context.luckysheet_select_save)) {
|
|
8043
8145
|
return false;
|
|
8044
8146
|
}
|
|
8045
8147
|
return true;
|
|
8046
|
-
}, [context.config, context.luckysheet_select_save, context.luckysheetfile, context.currentSheetId, isHidenRC]);
|
|
8148
|
+
}, [context.config, context.luckysheet_select_save, context.luckysheetfile, context.currentSheetId, context.isUpdatingCell, isHidenRC]);
|
|
8047
8149
|
return /*#__PURE__*/React.createElement("div", {
|
|
8048
8150
|
className: "leankylin-fx-editor"
|
|
8049
8151
|
}, /*#__PURE__*/React.createElement(LocationBox, null), /*#__PURE__*/React.createElement("div", {
|
|
@@ -12232,10 +12334,7 @@ var SheetHiddenButton = function SheetHiddenButton(_ref) {
|
|
|
12232
12334
|
}, (sheet === null || sheet === void 0 ? void 0 : sheet.hide) === 1 ? ( /*#__PURE__*/React.createElement(SVGIcon, {
|
|
12233
12335
|
name: "hidden",
|
|
12234
12336
|
width: 16,
|
|
12235
|
-
height: 16
|
|
12236
|
-
style: {
|
|
12237
|
-
marginTop: "7px"
|
|
12238
|
-
}
|
|
12337
|
+
height: 16
|
|
12239
12338
|
})) : "");
|
|
12240
12339
|
};
|
|
12241
12340
|
|
|
@@ -12618,6 +12717,19 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
12618
12717
|
return result;
|
|
12619
12718
|
});
|
|
12620
12719
|
});
|
|
12720
|
+
var commitWithMask = useMemoizedFn(function (recipe, options, $input, force) {
|
|
12721
|
+
var _ctx$luckysheetCellUp;
|
|
12722
|
+
var ctx = contextRef.current;
|
|
12723
|
+
var _ref2 = (_ctx$luckysheetCellUp = ctx.luckysheetCellUpdate) !== null && _ctx$luckysheetCellUp !== void 0 ? _ctx$luckysheetCellUp : [],
|
|
12724
|
+
_ref3 = _slicedToArray(_ref2, 2),
|
|
12725
|
+
r = _ref3[0],
|
|
12726
|
+
c = _ref3[1];
|
|
12727
|
+
if (!force && (_.isNil(r) || _.isNil(c) || isCellEditUnchanged(ctx, r, c, $input !== null && $input !== void 0 ? $input : cellInput.current, undefined, ctx.currentSheetId))) {
|
|
12728
|
+
setContextWithProduce(recipe, options);
|
|
12729
|
+
return;
|
|
12730
|
+
}
|
|
12731
|
+
createCommitWithMask(setContextWithProduce)(recipe, options);
|
|
12732
|
+
});
|
|
12621
12733
|
var handleUndo = useCallback(function () {
|
|
12622
12734
|
var history = globalCache.current.undoList.pop();
|
|
12623
12735
|
if (history) {
|
|
@@ -12691,12 +12803,13 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
12691
12803
|
context: context,
|
|
12692
12804
|
setContext: setContextWithProduce,
|
|
12693
12805
|
setScrollContext: setScrollContext,
|
|
12806
|
+
commitWithMask: commitWithMask,
|
|
12694
12807
|
settings: mergedSettings,
|
|
12695
12808
|
handleUndo: handleUndo,
|
|
12696
12809
|
handleRedo: handleRedo,
|
|
12697
12810
|
refs: refs
|
|
12698
12811
|
};
|
|
12699
|
-
}, [context, handleRedo, handleUndo, mergedSettings, refs, setContextWithProduce, setScrollContext]);
|
|
12812
|
+
}, [context, handleRedo, handleUndo, mergedSettings, refs, setContextWithProduce, setScrollContext, commitWithMask]);
|
|
12700
12813
|
useEffect(function () {
|
|
12701
12814
|
if (!_.isEmpty(context.luckysheetfile)) {
|
|
12702
12815
|
onChange === null || onChange === void 0 ? void 0 : onChange(context.luckysheetfile);
|
|
@@ -12847,21 +12960,42 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
12847
12960
|
e.preventDefault();
|
|
12848
12961
|
return;
|
|
12849
12962
|
}
|
|
12850
|
-
|
|
12963
|
+
var runRecipe = function runRecipe(draftCtx) {
|
|
12851
12964
|
handleGlobalKeyDown(draftCtx, cellInput.current, fxInput.current, nativeEvent, globalCache.current, handleUndo, handleRedo, canvas.current.getContext("2d"), refs);
|
|
12852
|
-
}
|
|
12853
|
-
|
|
12965
|
+
};
|
|
12966
|
+
if (nativeEvent.key === "Enter" && !nativeEvent.altKey && !nativeEvent.metaKey && !contextRef.current.isUpdatingCell && contextRef.current.luckysheetCellUpdate.length > 0) {
|
|
12967
|
+
nativeEvent.preventDefault();
|
|
12968
|
+
commitWithMask(runRecipe);
|
|
12969
|
+
return;
|
|
12970
|
+
}
|
|
12971
|
+
setContextWithProduce(runRecipe);
|
|
12972
|
+
}, [handleRedo, handleUndo, setContextWithProduce, commitWithMask, mergedSettings.disabledKeyboardCodes]);
|
|
12854
12973
|
var onPaste = useCallback(function (e) {
|
|
12855
|
-
if (isFocusRef.current && _.isEmpty(
|
|
12856
|
-
|
|
12974
|
+
if (isFocusRef.current && _.isEmpty(contextRef.current.luckysheetCellUpdate)) {
|
|
12975
|
+
var _e$clipboardData$getD, _e$clipboardData, _e$clipboardData$getD2, _e$clipboardData2, _e$clipboardData$getD3, _e$clipboardData3;
|
|
12976
|
+
var snapshot = {
|
|
12977
|
+
"text/html": (_e$clipboardData$getD = (_e$clipboardData = e.clipboardData) === null || _e$clipboardData === void 0 ? void 0 : _e$clipboardData.getData("text/html")) !== null && _e$clipboardData$getD !== void 0 ? _e$clipboardData$getD : "",
|
|
12978
|
+
"text/plain": (_e$clipboardData$getD2 = (_e$clipboardData2 = e.clipboardData) === null || _e$clipboardData2 === void 0 ? void 0 : _e$clipboardData2.getData("text/plain")) !== null && _e$clipboardData$getD2 !== void 0 ? _e$clipboardData$getD2 : "",
|
|
12979
|
+
text: (_e$clipboardData$getD3 = (_e$clipboardData3 = e.clipboardData) === null || _e$clipboardData3 === void 0 ? void 0 : _e$clipboardData3.getData("text")) !== null && _e$clipboardData$getD3 !== void 0 ? _e$clipboardData$getD3 : ""
|
|
12980
|
+
};
|
|
12981
|
+
var hasText = Boolean(snapshot["text/html"] || snapshot["text/plain"] || snapshot.text);
|
|
12982
|
+
var snapshotEvent = {
|
|
12983
|
+
clipboardData: {
|
|
12984
|
+
getData: function getData(type) {
|
|
12985
|
+
var _snapshot$type;
|
|
12986
|
+
return (_snapshot$type = snapshot[type]) !== null && _snapshot$type !== void 0 ? _snapshot$type : "";
|
|
12987
|
+
}
|
|
12988
|
+
}
|
|
12989
|
+
};
|
|
12990
|
+
commitWithMask(function (draftCtx) {
|
|
12857
12991
|
try {
|
|
12858
|
-
handlePasteByLeanklin(draftCtx,
|
|
12992
|
+
handlePasteByLeanklin(draftCtx, snapshotEvent, mergedSettings.copyRich);
|
|
12859
12993
|
} catch (err) {
|
|
12860
12994
|
console.error(err);
|
|
12861
12995
|
}
|
|
12862
|
-
});
|
|
12996
|
+
}, undefined, undefined, hasText);
|
|
12863
12997
|
}
|
|
12864
|
-
}, [
|
|
12998
|
+
}, [commitWithMask, mergedSettings.copyRich]);
|
|
12865
12999
|
var onMoreToolbarItemsClose = useCallback(function () {
|
|
12866
13000
|
setMoreToolbarItems(null);
|
|
12867
13001
|
}, []);
|