@leankylin-sheet/react 7.0.42 → 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 +44 -0
- package/dist/index.esm.css +44 -0
- package/dist/index.esm.js +172 -35
- package/dist/index.js +170 -33
- package/dist/index.umd.css +44 -0
- package/dist/index.umd.js +170 -33
- 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/index.js
CHANGED
|
@@ -567,6 +567,7 @@ var WorkbookContext = /*#__PURE__*/React__default['default'].createContext({
|
|
|
567
567
|
context: core.defaultContext(defaultRefs),
|
|
568
568
|
setContext: function setContext() {},
|
|
569
569
|
setScrollContext: function setScrollContext() {},
|
|
570
|
+
commitWithMask: function commitWithMask() {},
|
|
570
571
|
settings: core.defaultSettings,
|
|
571
572
|
handleUndo: function handleUndo() {},
|
|
572
573
|
handleRedo: function handleRedo() {},
|
|
@@ -601,11 +602,51 @@ var SVGIcon = function SVGIcon(_ref) {
|
|
|
601
602
|
}));
|
|
602
603
|
};
|
|
603
604
|
|
|
605
|
+
function isBlurCommitContext(ctx) {
|
|
606
|
+
if (ctx.isUpdatingCell) return false;
|
|
607
|
+
if (!ctx.luckysheetCellUpdate || ctx.luckysheetCellUpdate.length === 0) {
|
|
608
|
+
return false;
|
|
609
|
+
}
|
|
610
|
+
if (ctx.active_f) return false;
|
|
611
|
+
var _ctx$formulaCache = ctx.formulaCache,
|
|
612
|
+
rangestart = _ctx$formulaCache.rangestart,
|
|
613
|
+
rangedrag_column_start = _ctx$formulaCache.rangedrag_column_start,
|
|
614
|
+
rangedrag_row_start = _ctx$formulaCache.rangedrag_row_start;
|
|
615
|
+
if (rangestart || rangedrag_column_start || rangedrag_row_start) return false;
|
|
616
|
+
if (core.israngeseleciton(ctx)) return false;
|
|
617
|
+
return true;
|
|
618
|
+
}
|
|
619
|
+
function createCommitWithMask(setContext) {
|
|
620
|
+
return function (recipe, options) {
|
|
621
|
+
reactDom.flushSync(function () {
|
|
622
|
+
setContext(function (ctx) {
|
|
623
|
+
ctx.isUpdatingCell = true;
|
|
624
|
+
}, {
|
|
625
|
+
noHistory: true
|
|
626
|
+
});
|
|
627
|
+
});
|
|
628
|
+
requestAnimationFrame(function () {
|
|
629
|
+
requestAnimationFrame(function () {
|
|
630
|
+
try {
|
|
631
|
+
setContext(recipe, options);
|
|
632
|
+
} finally {
|
|
633
|
+
setContext(function (ctx) {
|
|
634
|
+
ctx.isUpdatingCell = false;
|
|
635
|
+
}, {
|
|
636
|
+
noHistory: true
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
});
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
|
|
604
644
|
var ColumnHeader = function ColumnHeader() {
|
|
605
645
|
var _refs$globalCache$fre2, _settings$renderFreez;
|
|
606
646
|
var _useContext = React.useContext(WorkbookContext),
|
|
607
647
|
context = _useContext.context,
|
|
608
648
|
setContext = _useContext.setContext,
|
|
649
|
+
commitWithMask = _useContext.commitWithMask,
|
|
609
650
|
settings = _useContext.settings,
|
|
610
651
|
refs = _useContext.refs;
|
|
611
652
|
var containerRef = React.useRef(null);
|
|
@@ -669,10 +710,15 @@ var ColumnHeader = function ColumnHeader() {
|
|
|
669
710
|
}, [context, hoverLocation.col_index, refs.globalCache.freezen]);
|
|
670
711
|
var onMouseDown = React.useCallback(function (e) {
|
|
671
712
|
var nativeEvent = e.nativeEvent;
|
|
672
|
-
|
|
713
|
+
var runRecipe = function runRecipe(draftCtx) {
|
|
673
714
|
core.handleColumnHeaderMouseDown(draftCtx, refs.globalCache, nativeEvent, containerRef.current, refs.cellInput.current, refs.fxInput.current);
|
|
674
|
-
}
|
|
675
|
-
|
|
715
|
+
};
|
|
716
|
+
if (isBlurCommitContext(context)) {
|
|
717
|
+
commitWithMask(runRecipe);
|
|
718
|
+
} else {
|
|
719
|
+
setContext(runRecipe);
|
|
720
|
+
}
|
|
721
|
+
}, [context, commitWithMask, refs.globalCache, refs.cellInput, refs.fxInput, setContext]);
|
|
676
722
|
var onMouseLeave = React.useCallback(function () {
|
|
677
723
|
if (context.luckysheet_cols_change_size) {
|
|
678
724
|
return;
|
|
@@ -828,6 +874,7 @@ var RowHeader = function RowHeader() {
|
|
|
828
874
|
var _useContext = React.useContext(WorkbookContext),
|
|
829
875
|
context = _useContext.context,
|
|
830
876
|
setContext = _useContext.setContext,
|
|
877
|
+
commitWithMask = _useContext.commitWithMask,
|
|
831
878
|
settings = _useContext.settings,
|
|
832
879
|
refs = _useContext.refs;
|
|
833
880
|
var rowChangeSizeRef = React.useRef(null);
|
|
@@ -885,10 +932,15 @@ var RowHeader = function RowHeader() {
|
|
|
885
932
|
}, [context.luckysheet_rows_change_size, context.visibledatarow, hoverLocation.row, hoverLocation.row_pre, refs.globalCache.freezen, context.currentSheetId]);
|
|
886
933
|
var onMouseDown = React.useCallback(function (e) {
|
|
887
934
|
var nativeEvent = e.nativeEvent;
|
|
888
|
-
|
|
935
|
+
var runRecipe = function runRecipe(draftCtx) {
|
|
889
936
|
core.handleRowHeaderMouseDown(draftCtx, refs.globalCache, nativeEvent, containerRef.current, refs.cellInput.current, refs.fxInput.current);
|
|
890
|
-
}
|
|
891
|
-
|
|
937
|
+
};
|
|
938
|
+
if (isBlurCommitContext(context)) {
|
|
939
|
+
commitWithMask(runRecipe);
|
|
940
|
+
} else {
|
|
941
|
+
setContext(runRecipe);
|
|
942
|
+
}
|
|
943
|
+
}, [context, commitWithMask, refs.globalCache, refs.cellInput, refs.fxInput, setContext]);
|
|
892
944
|
var onMouseLeave = React.useCallback(function () {
|
|
893
945
|
if (context.luckysheet_rows_change_size) {
|
|
894
946
|
return;
|
|
@@ -1493,6 +1545,7 @@ var InputBox = function InputBox() {
|
|
|
1493
1545
|
var _useContext = React.useContext(WorkbookContext),
|
|
1494
1546
|
context = _useContext.context,
|
|
1495
1547
|
setContext = _useContext.setContext,
|
|
1548
|
+
commitWithMask = _useContext.commitWithMask,
|
|
1496
1549
|
refs = _useContext.refs,
|
|
1497
1550
|
settings = _useContext.settings;
|
|
1498
1551
|
var inputRef = React.useRef(null);
|
|
@@ -1574,6 +1627,11 @@ var InputBox = function InputBox() {
|
|
|
1574
1627
|
var onKeyDown = React.useCallback(function (e) {
|
|
1575
1628
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
1576
1629
|
preText.current = inputRef.current.innerText;
|
|
1630
|
+
if (context.isUpdatingCell) {
|
|
1631
|
+
e.preventDefault();
|
|
1632
|
+
e.stopPropagation();
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1577
1635
|
if (e.key === "Escape" && context.luckysheetCellUpdate.length > 0) {
|
|
1578
1636
|
setContext(function (draftCtx) {
|
|
1579
1637
|
core.cancelNormalSelected(draftCtx);
|
|
@@ -1587,17 +1645,18 @@ var InputBox = function InputBox() {
|
|
|
1587
1645
|
e.stopPropagation();
|
|
1588
1646
|
}
|
|
1589
1647
|
} else if (e.key === "Tab" && context.luckysheetCellUpdate.length > 0) {
|
|
1590
|
-
setContext(function (draftCtx) {
|
|
1591
|
-
core.updateCell(draftCtx, draftCtx.luckysheetCellUpdate[0], draftCtx.luckysheetCellUpdate[1], refs.cellInput.current);
|
|
1592
|
-
core.moveHighlightCell(draftCtx, "right", 1, "rangeOfSelect");
|
|
1593
|
-
});
|
|
1594
1648
|
e.preventDefault();
|
|
1595
1649
|
e.stopPropagation();
|
|
1650
|
+
commitWithMask(function (draftCtx) {
|
|
1651
|
+
core.updateCell(draftCtx, draftCtx.luckysheetCellUpdate[0], draftCtx.luckysheetCellUpdate[1], refs.cellInput.current);
|
|
1652
|
+
core.moveHighlightCell(draftCtx, "right", 1, "rangeOfSelect");
|
|
1653
|
+
}, undefined, refs.cellInput.current);
|
|
1596
1654
|
} else if (e.key === "F4" && context.luckysheetCellUpdate.length > 0) {
|
|
1597
1655
|
e.preventDefault();
|
|
1598
1656
|
}
|
|
1599
|
-
}, [context.luckysheetCellUpdate.length, refs.cellInput, setContext]);
|
|
1657
|
+
}, [context.luckysheetCellUpdate.length, context.isUpdatingCell, commitWithMask, refs.cellInput, setContext]);
|
|
1600
1658
|
var onChange = React.useCallback(function (__, isBlur) {
|
|
1659
|
+
if (context.isUpdatingCell) return;
|
|
1601
1660
|
var e = lastKeyDownEventRef.current;
|
|
1602
1661
|
if (!e) return;
|
|
1603
1662
|
var kcode = e.keyCode;
|
|
@@ -1610,7 +1669,7 @@ var InputBox = function InputBox() {
|
|
|
1610
1669
|
});
|
|
1611
1670
|
}
|
|
1612
1671
|
lastKeyDownEventRef.current = undefined;
|
|
1613
|
-
}, [refs.cellInput, refs.fxInput, setContext]);
|
|
1672
|
+
}, [context.isUpdatingCell, refs.cellInput, refs.fxInput, setContext]);
|
|
1614
1673
|
var onPaste = React.useCallback(function (e) {
|
|
1615
1674
|
if (___default['default'].isEmpty(context.luckysheetCellUpdate)) {
|
|
1616
1675
|
e.preventDefault();
|
|
@@ -1664,7 +1723,7 @@ var InputBox = function InputBox() {
|
|
|
1664
1723
|
onChange: onChange,
|
|
1665
1724
|
onKeyDown: onKeyDown,
|
|
1666
1725
|
onPaste: onPaste,
|
|
1667
|
-
allowEdit: edit ? !isHidenRC : edit
|
|
1726
|
+
allowEdit: edit ? !isHidenRC && !context.isUpdatingCell : edit
|
|
1668
1727
|
})), document.activeElement === inputRef.current && ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].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__default['default'].createElement(FormulaSearch, {
|
|
1669
1728
|
style: {
|
|
1670
1729
|
top: ((firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.height_move) || 0) + 4
|
|
@@ -1676,6 +1735,30 @@ var InputBox = function InputBox() {
|
|
|
1676
1735
|
}))));
|
|
1677
1736
|
};
|
|
1678
1737
|
|
|
1738
|
+
var UpdatingMask = function UpdatingMask() {
|
|
1739
|
+
var _context$luckysheet_s;
|
|
1740
|
+
var _useContext = React.useContext(WorkbookContext),
|
|
1741
|
+
context = _useContext.context;
|
|
1742
|
+
if (!context.isUpdatingCell) return null;
|
|
1743
|
+
var selection = (_context$luckysheet_s = context.luckysheet_select_save) === null || _context$luckysheet_s === void 0 ? void 0 : _context$luckysheet_s[0];
|
|
1744
|
+
if (!selection || selection.left == null || selection.top == null) {
|
|
1745
|
+
return null;
|
|
1746
|
+
}
|
|
1747
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1748
|
+
className: "luckysheet-updating-mask",
|
|
1749
|
+
style: {
|
|
1750
|
+
left: selection.left,
|
|
1751
|
+
top: selection.top,
|
|
1752
|
+
width: selection.width,
|
|
1753
|
+
height: selection.height
|
|
1754
|
+
}
|
|
1755
|
+
}, /*#__PURE__*/React__default['default'].createElement("span", {
|
|
1756
|
+
className: "luckysheet-updating-mask-spinner"
|
|
1757
|
+
}), /*#__PURE__*/React__default['default'].createElement("span", {
|
|
1758
|
+
className: "luckysheet-updating-mask-text"
|
|
1759
|
+
}, core.locale(context).edit.updatingRelatedCells));
|
|
1760
|
+
};
|
|
1761
|
+
|
|
1679
1762
|
var ScrollBar = function ScrollBar(_ref) {
|
|
1680
1763
|
var axis = _ref.axis;
|
|
1681
1764
|
var _useContext = React.useContext(WorkbookContext),
|
|
@@ -4486,6 +4569,7 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
4486
4569
|
var _useContext = React.useContext(WorkbookContext),
|
|
4487
4570
|
context = _useContext.context,
|
|
4488
4571
|
setContext = _useContext.setContext,
|
|
4572
|
+
commitWithMask = _useContext.commitWithMask,
|
|
4489
4573
|
settings = _useContext.settings,
|
|
4490
4574
|
refs = _useContext.refs;
|
|
4491
4575
|
var _useInViewport = ahooks.useInViewport(refs.cellArea),
|
|
@@ -4500,7 +4584,7 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
4500
4584
|
var cellAreaMouseDown = React.useCallback(function (e) {
|
|
4501
4585
|
var nativeEvent = e.nativeEvent;
|
|
4502
4586
|
if (e.button !== 2) {
|
|
4503
|
-
|
|
4587
|
+
var runRecipe = function runRecipe(draftCtx) {
|
|
4504
4588
|
var _draftCtx$luckysheet_;
|
|
4505
4589
|
core.handleCellAreaMouseDown(draftCtx, refs.globalCache, nativeEvent, refs.cellInput.current, refs.cellArea.current, refs.fxInput.current, refs.canvas.current.getContext("2d"));
|
|
4506
4590
|
if (!___default['default'].isEmpty((_draftCtx$luckysheet_ = draftCtx.luckysheet_select_save) === null || _draftCtx$luckysheet_ === void 0 ? void 0 : _draftCtx$luckysheet_[0]) && refs.cellInput.current) {
|
|
@@ -4509,9 +4593,14 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
4509
4593
|
(_refs$cellInput$curre = refs.cellInput.current) === null || _refs$cellInput$curre === void 0 ? void 0 : _refs$cellInput$curre.focus();
|
|
4510
4594
|
});
|
|
4511
4595
|
}
|
|
4512
|
-
}
|
|
4596
|
+
};
|
|
4597
|
+
if (isBlurCommitContext(context)) {
|
|
4598
|
+
commitWithMask(runRecipe);
|
|
4599
|
+
} else {
|
|
4600
|
+
setContext(runRecipe);
|
|
4601
|
+
}
|
|
4513
4602
|
}
|
|
4514
|
-
}, [setContext, refs.globalCache, refs.cellInput, refs.cellArea, refs.fxInput, refs.canvas]);
|
|
4603
|
+
}, [context, commitWithMask, setContext, refs.globalCache, refs.cellInput, refs.cellArea, refs.fxInput, refs.canvas]);
|
|
4515
4604
|
var debounceMouseMove = ahooks.useMemoizedFn(function (e) {
|
|
4516
4605
|
var nativeEvent = e.nativeEvent;
|
|
4517
4606
|
core.handleCellAreaMouseMove(context, refs.globalCache, nativeEvent, refs.cellArea.current);
|
|
@@ -4554,10 +4643,11 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
4554
4643
|
}, [refs.workbookContainer, setContext, settings, refs.cellArea]);
|
|
4555
4644
|
var cellAreaDoubleClick = React.useCallback(function (e) {
|
|
4556
4645
|
var nativeEvent = e.nativeEvent;
|
|
4646
|
+
if (context.isUpdatingCell) return;
|
|
4557
4647
|
setContext(function (draftCtx) {
|
|
4558
4648
|
core.handleCellAreaDoubleClick(draftCtx, refs.globalCache, settings, nativeEvent, refs.cellArea.current);
|
|
4559
4649
|
});
|
|
4560
|
-
}, [refs.cellArea, refs.globalCache, setContext, settings]);
|
|
4650
|
+
}, [context.isUpdatingCell, refs.cellArea, refs.globalCache, setContext, settings]);
|
|
4561
4651
|
var onLeftTopClick = React.useCallback(function () {
|
|
4562
4652
|
setContext(function (draftCtx) {
|
|
4563
4653
|
core.selectAll(draftCtx);
|
|
@@ -4957,7 +5047,7 @@ var SheetOverlay = function SheetOverlay() {
|
|
|
4957
5047
|
getContainer: function getContainer() {
|
|
4958
5048
|
return containerRef.current;
|
|
4959
5049
|
}
|
|
4960
|
-
}), /*#__PURE__*/React__default['default'].createElement(InputBox, null), /*#__PURE__*/React__default['default'].createElement(NotationBoxes, null), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
5050
|
+
}), /*#__PURE__*/React__default['default'].createElement(InputBox, null), /*#__PURE__*/React__default['default'].createElement(UpdatingMask, null), /*#__PURE__*/React__default['default'].createElement(NotationBoxes, null), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4961
5051
|
id: "luckysheet-multipleRange-show"
|
|
4962
5052
|
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4963
5053
|
id: "luckysheet-dynamicArray-hightShow"
|
|
@@ -7902,6 +7992,7 @@ var FxEditor = function FxEditor() {
|
|
|
7902
7992
|
var _useContext = React.useContext(WorkbookContext),
|
|
7903
7993
|
context = _useContext.context,
|
|
7904
7994
|
setContext = _useContext.setContext,
|
|
7995
|
+
commitWithMask = _useContext.commitWithMask,
|
|
7905
7996
|
refs = _useContext.refs,
|
|
7906
7997
|
settings = _useContext.settings;
|
|
7907
7998
|
var _useState = React.useState(false),
|
|
@@ -7982,6 +8073,9 @@ var FxEditor = function FxEditor() {
|
|
|
7982
8073
|
if (context.allowEdit === false) {
|
|
7983
8074
|
return;
|
|
7984
8075
|
}
|
|
8076
|
+
if (context.isUpdatingCell) {
|
|
8077
|
+
return;
|
|
8078
|
+
}
|
|
7985
8079
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
7986
8080
|
var key = e.key;
|
|
7987
8081
|
recentText.current = refs.fxInput.current.innerText;
|
|
@@ -7991,7 +8085,7 @@ var FxEditor = function FxEditor() {
|
|
|
7991
8085
|
if (!["Enter", "Escape", "ArrowLeft", "ArrowRight"].includes(key)) {
|
|
7992
8086
|
return;
|
|
7993
8087
|
}
|
|
7994
|
-
|
|
8088
|
+
var runRecipe = function runRecipe(draftCtx) {
|
|
7995
8089
|
if (context.luckysheetCellUpdate.length > 0) {
|
|
7996
8090
|
switch (key) {
|
|
7997
8091
|
case "Enter":
|
|
@@ -8005,8 +8099,6 @@ var FxEditor = function FxEditor() {
|
|
|
8005
8099
|
column_focus: lastCellUpdate[1]
|
|
8006
8100
|
}];
|
|
8007
8101
|
core.moveHighlightCell(draftCtx, "down", 1, "rangeOfSelect");
|
|
8008
|
-
e.preventDefault();
|
|
8009
|
-
e.stopPropagation();
|
|
8010
8102
|
break;
|
|
8011
8103
|
}
|
|
8012
8104
|
case "Escape":
|
|
@@ -8029,8 +8121,15 @@ var FxEditor = function FxEditor() {
|
|
|
8029
8121
|
}
|
|
8030
8122
|
}
|
|
8031
8123
|
}
|
|
8032
|
-
}
|
|
8033
|
-
|
|
8124
|
+
};
|
|
8125
|
+
if (key === "Enter" && context.luckysheetCellUpdate.length > 0) {
|
|
8126
|
+
e.preventDefault();
|
|
8127
|
+
e.stopPropagation();
|
|
8128
|
+
commitWithMask(runRecipe, undefined, refs.fxInput.current);
|
|
8129
|
+
return;
|
|
8130
|
+
}
|
|
8131
|
+
setContext(runRecipe);
|
|
8132
|
+
}, [context.allowEdit, context.luckysheetCellUpdate.length, context.isUpdatingCell, commitWithMask, refs.fxInput, setContext]);
|
|
8034
8133
|
var onChange = React.useCallback(function () {
|
|
8035
8134
|
var e = lastKeyDownEventRef.current;
|
|
8036
8135
|
if (!e) return;
|
|
@@ -8049,11 +8148,14 @@ var FxEditor = function FxEditor() {
|
|
|
8049
8148
|
if (isHidenRC) {
|
|
8050
8149
|
return false;
|
|
8051
8150
|
}
|
|
8151
|
+
if (context.isUpdatingCell) {
|
|
8152
|
+
return false;
|
|
8153
|
+
}
|
|
8052
8154
|
if (!core.isAllowEdit(context, context.luckysheet_select_save)) {
|
|
8053
8155
|
return false;
|
|
8054
8156
|
}
|
|
8055
8157
|
return true;
|
|
8056
|
-
}, [context.config, context.luckysheet_select_save, context.luckysheetfile, context.currentSheetId, isHidenRC]);
|
|
8158
|
+
}, [context.config, context.luckysheet_select_save, context.luckysheetfile, context.currentSheetId, context.isUpdatingCell, isHidenRC]);
|
|
8057
8159
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
8058
8160
|
className: "leankylin-fx-editor"
|
|
8059
8161
|
}, /*#__PURE__*/React__default['default'].createElement(LocationBox, null), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
@@ -12625,6 +12727,19 @@ var Workbook = /*#__PURE__*/React__default['default'].forwardRef(function (_ref,
|
|
|
12625
12727
|
return result;
|
|
12626
12728
|
});
|
|
12627
12729
|
});
|
|
12730
|
+
var commitWithMask = ahooks.useMemoizedFn(function (recipe, options, $input, force) {
|
|
12731
|
+
var _ctx$luckysheetCellUp;
|
|
12732
|
+
var ctx = contextRef.current;
|
|
12733
|
+
var _ref2 = (_ctx$luckysheetCellUp = ctx.luckysheetCellUpdate) !== null && _ctx$luckysheetCellUp !== void 0 ? _ctx$luckysheetCellUp : [],
|
|
12734
|
+
_ref3 = _slicedToArray(_ref2, 2),
|
|
12735
|
+
r = _ref3[0],
|
|
12736
|
+
c = _ref3[1];
|
|
12737
|
+
if (!force && (___default['default'].isNil(r) || ___default['default'].isNil(c) || core.isCellEditUnchanged(ctx, r, c, $input !== null && $input !== void 0 ? $input : cellInput.current, undefined, ctx.currentSheetId))) {
|
|
12738
|
+
setContextWithProduce(recipe, options);
|
|
12739
|
+
return;
|
|
12740
|
+
}
|
|
12741
|
+
createCommitWithMask(setContextWithProduce)(recipe, options);
|
|
12742
|
+
});
|
|
12628
12743
|
var handleUndo = React.useCallback(function () {
|
|
12629
12744
|
var history = globalCache.current.undoList.pop();
|
|
12630
12745
|
if (history) {
|
|
@@ -12698,12 +12813,13 @@ var Workbook = /*#__PURE__*/React__default['default'].forwardRef(function (_ref,
|
|
|
12698
12813
|
context: context,
|
|
12699
12814
|
setContext: setContextWithProduce,
|
|
12700
12815
|
setScrollContext: setScrollContext,
|
|
12816
|
+
commitWithMask: commitWithMask,
|
|
12701
12817
|
settings: mergedSettings,
|
|
12702
12818
|
handleUndo: handleUndo,
|
|
12703
12819
|
handleRedo: handleRedo,
|
|
12704
12820
|
refs: refs
|
|
12705
12821
|
};
|
|
12706
|
-
}, [context, handleRedo, handleUndo, mergedSettings, refs, setContextWithProduce, setScrollContext]);
|
|
12822
|
+
}, [context, handleRedo, handleUndo, mergedSettings, refs, setContextWithProduce, setScrollContext, commitWithMask]);
|
|
12707
12823
|
React.useEffect(function () {
|
|
12708
12824
|
if (!___default['default'].isEmpty(context.luckysheetfile)) {
|
|
12709
12825
|
onChange === null || onChange === void 0 ? void 0 : onChange(context.luckysheetfile);
|
|
@@ -12854,21 +12970,42 @@ var Workbook = /*#__PURE__*/React__default['default'].forwardRef(function (_ref,
|
|
|
12854
12970
|
e.preventDefault();
|
|
12855
12971
|
return;
|
|
12856
12972
|
}
|
|
12857
|
-
|
|
12973
|
+
var runRecipe = function runRecipe(draftCtx) {
|
|
12858
12974
|
core.handleGlobalKeyDown(draftCtx, cellInput.current, fxInput.current, nativeEvent, globalCache.current, handleUndo, handleRedo, canvas.current.getContext("2d"), refs);
|
|
12859
|
-
}
|
|
12860
|
-
|
|
12975
|
+
};
|
|
12976
|
+
if (nativeEvent.key === "Enter" && !nativeEvent.altKey && !nativeEvent.metaKey && !contextRef.current.isUpdatingCell && contextRef.current.luckysheetCellUpdate.length > 0) {
|
|
12977
|
+
nativeEvent.preventDefault();
|
|
12978
|
+
commitWithMask(runRecipe);
|
|
12979
|
+
return;
|
|
12980
|
+
}
|
|
12981
|
+
setContextWithProduce(runRecipe);
|
|
12982
|
+
}, [handleRedo, handleUndo, setContextWithProduce, commitWithMask, mergedSettings.disabledKeyboardCodes]);
|
|
12861
12983
|
var onPaste = React.useCallback(function (e) {
|
|
12862
|
-
if (isFocusRef.current && ___default['default'].isEmpty(
|
|
12863
|
-
|
|
12984
|
+
if (isFocusRef.current && ___default['default'].isEmpty(contextRef.current.luckysheetCellUpdate)) {
|
|
12985
|
+
var _e$clipboardData$getD, _e$clipboardData, _e$clipboardData$getD2, _e$clipboardData2, _e$clipboardData$getD3, _e$clipboardData3;
|
|
12986
|
+
var snapshot = {
|
|
12987
|
+
"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 : "",
|
|
12988
|
+
"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 : "",
|
|
12989
|
+
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 : ""
|
|
12990
|
+
};
|
|
12991
|
+
var hasText = Boolean(snapshot["text/html"] || snapshot["text/plain"] || snapshot.text);
|
|
12992
|
+
var snapshotEvent = {
|
|
12993
|
+
clipboardData: {
|
|
12994
|
+
getData: function getData(type) {
|
|
12995
|
+
var _snapshot$type;
|
|
12996
|
+
return (_snapshot$type = snapshot[type]) !== null && _snapshot$type !== void 0 ? _snapshot$type : "";
|
|
12997
|
+
}
|
|
12998
|
+
}
|
|
12999
|
+
};
|
|
13000
|
+
commitWithMask(function (draftCtx) {
|
|
12864
13001
|
try {
|
|
12865
|
-
core.handlePasteByLeanklin(draftCtx,
|
|
13002
|
+
core.handlePasteByLeanklin(draftCtx, snapshotEvent, mergedSettings.copyRich);
|
|
12866
13003
|
} catch (err) {
|
|
12867
13004
|
console.error(err);
|
|
12868
13005
|
}
|
|
12869
|
-
});
|
|
13006
|
+
}, undefined, undefined, hasText);
|
|
12870
13007
|
}
|
|
12871
|
-
}, [
|
|
13008
|
+
}, [commitWithMask, mergedSettings.copyRich]);
|
|
12872
13009
|
var onMoreToolbarItemsClose = React.useCallback(function () {
|
|
12873
13010
|
setMoreToolbarItems(null);
|
|
12874
13011
|
}, []);
|
package/dist/index.umd.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
|
}
|