@leankylin-sheet/react 5.2.74 → 5.2.76
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/index.esm.js +100 -99
- package/dist/index.js +100 -99
- package/dist/index.umd.js +15350 -15349
- package/dist/index.umd.min.js +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defaultContext, defaultSettings, getSheetIndex, colLocationByIndex, fixPositionOnFrozenCells, colLocation, getFlowdata, isAllowEdit, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleContextMenu, selectTitlesMap, selectTitlesRange, fixColumnStyleOverflowInFreeze, rowLocationByIndex, rowLocation, handleRowHeaderMouseDown, handleRowSizeHandleMouseDown, handleRowFreezeHandleMouseDown, fixRowStyleOverflowInFreeze, functionHTMLGenerate, locale, getCellValue, createRangeHightlight, isInlineStringCell, getInlineStringHTML, valueShowEs, escapeHTMLTag, escapeScriptTag, isShowHidenCR, cancelNormalSelected, moveHighlightCell, updateCell, israngeseleciton, handleFormulaInput, onSearchDialogMoveStart, replaceAll, replace, searchAll, searchNext, changeSheet, normalizeSelection, scrollToHighlightCell, chatatABC, isLinkValid, getRangetxt, goToLink, replaceHtml, removeHyperlink, onRangeSelectionModalMoveStart, saveHyperlink, createFilterOptions, onImageMoveStart, onImageResizeStart, showComments, setEditingComment, onCommentBoxMoveStart, onCommentBoxResizeStart, confirmMessage, getRangeByTxt, getDropdownList, setCellValue, setConditionRules, mergeBorder, setDropcownValue, handleCellAreaMouseDown, handleCellAreaMouseMove, handleCellAreaDragOver, handleCellDrop, handleCellAreaDoubleClick, selectAll, showLinkCard, getCellRowColumn, getCellHyperlink, handleOverlayMouseMove, handleOverlayMouseUp, handleKeydownForZoom, handleOverlayTouchStart, handleOverlayTouchMove, handleOverlayTouchEnd, onCellsMoveStart, createDropCellRange, handleDropCellDoubleClick, updateContextWithSheetData, updateContextWithCanvas, initFreeze, Canvas, handleGlobalWheel, setCaretPosition, getDataArr, updateMoreCell, getRegStr, getOptionValue, getSelectRange, applyLocation, updateItem, update, normalizedCellAttr, updateFormat, handleTextSize, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, showImgChooser, insertImage, editComment, deleteComment, showHideComment, showHideAllComments, newComment, handleSum, autoSelectionFormula, handleMerge, handleBorder, handleFreeze, handleSort, createFilter, clearFilter, 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, inverseRowColOptions, ensureSheetIndex, initSheetIndex, handleGlobalKeyDown, handlePasteByLeanklin, groupValuesRefresh } from '@leankylin-sheet/core';
|
|
2
|
+
import { useInViewport, useMemoizedFn, useThrottleFn } from 'ahooks';
|
|
2
3
|
import React, { useContext, useRef, useState, useMemo, useCallback, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
|
|
3
4
|
import produce, { applyPatches, enablePatches, produceWithPatches } from 'immer';
|
|
4
5
|
import _ from 'lodash';
|
|
5
|
-
import { useInViewport, useMemoizedFn, useThrottleFn } from 'ahooks';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
|
|
8
8
|
function _iterableToArrayLimit(r, l) {
|
|
@@ -7864,7 +7864,7 @@ var FxEditor = function FxEditor() {
|
|
|
7864
7864
|
},
|
|
7865
7865
|
tabIndex: 0,
|
|
7866
7866
|
allowEdit: allowEdit
|
|
7867
|
-
}),
|
|
7867
|
+
}), settings === null || settings === void 0 ? void 0 : settings.fxContainer, /*#__PURE__*/React.createElement(CalcInfo, null), focused && ( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormulaSearch, {
|
|
7868
7868
|
style: {
|
|
7869
7869
|
top: inputContainerRef.current.clientHeight
|
|
7870
7870
|
}
|
|
@@ -11958,6 +11958,7 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
11958
11958
|
_useState2 = _slicedToArray(_useState, 2),
|
|
11959
11959
|
context = _useState2[0],
|
|
11960
11960
|
setContext = _useState2[1];
|
|
11961
|
+
var contextRef = useRef(context);
|
|
11961
11962
|
var _useState3 = useState(null),
|
|
11962
11963
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
11963
11964
|
moreToolbarItems = _useState4[0],
|
|
@@ -12062,116 +12063,116 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
12062
12063
|
}
|
|
12063
12064
|
return cellData;
|
|
12064
12065
|
}
|
|
12065
|
-
var setContextWithProduce =
|
|
12066
|
+
var setContextWithProduce = useMemoizedFn(function (recipe) {
|
|
12066
12067
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
});
|
|
12086
|
-
if (target) {
|
|
12087
|
-
var index = getSheetIndex(ctx_, options.deleteSheetOp.id);
|
|
12088
|
-
options.deletedSheet = {
|
|
12089
|
-
id: options.deleteSheetOp.id,
|
|
12090
|
-
index: index,
|
|
12091
|
-
value: _.cloneDeep(ctx_.luckysheetfile[index])
|
|
12092
|
-
};
|
|
12093
|
-
options.deletedSheet.value.celldata = dataToCelldata(options.deletedSheet.value.data);
|
|
12094
|
-
delete options.deletedSheet.value.data;
|
|
12095
|
-
options.deletedSheet.value.status = 0;
|
|
12096
|
-
filteredInversePatches = [{
|
|
12097
|
-
op: "add",
|
|
12098
|
-
path: ["luckysheetfile", 0],
|
|
12099
|
-
value: options.deletedSheet.value
|
|
12100
|
-
}];
|
|
12101
|
-
}
|
|
12102
|
-
} else if (options.addSheetOp) {
|
|
12103
|
-
options.addSheet = {};
|
|
12104
|
-
options.addSheet.id = result.luckysheetfile[result.luckysheetfile.length - 1].id;
|
|
12105
|
-
}
|
|
12106
|
-
globalCache.current.undoList.push({
|
|
12107
|
-
patches: filteredPatches,
|
|
12108
|
-
inversePatches: filteredInversePatches,
|
|
12109
|
-
options: options
|
|
12068
|
+
var ctx_ = contextRef.current;
|
|
12069
|
+
var _produceWithPatches = produceWithPatches(ctx_, concatProducer(recipe, triggerGroupValuesRefresh)),
|
|
12070
|
+
_produceWithPatches2 = _slicedToArray(_produceWithPatches, 3),
|
|
12071
|
+
result = _produceWithPatches2[0],
|
|
12072
|
+
patches = _produceWithPatches2[1],
|
|
12073
|
+
inversePatches = _produceWithPatches2[2];
|
|
12074
|
+
if (patches.length > 0 && !options.noHistory) {
|
|
12075
|
+
if (options.logPatch) {
|
|
12076
|
+
console.info("patch", patches);
|
|
12077
|
+
}
|
|
12078
|
+
var filteredPatches = filterPatch(patches);
|
|
12079
|
+
var filteredInversePatches = filterPatch(inversePatches);
|
|
12080
|
+
if (filteredInversePatches.length > 0) {
|
|
12081
|
+
options.id = ctx_.currentSheetId;
|
|
12082
|
+
if (options.deleteSheetOp) {
|
|
12083
|
+
var target = ctx_.luckysheetfile.filter(function (sheet) {
|
|
12084
|
+
var _options$deleteSheetO;
|
|
12085
|
+
return sheet.id === ((_options$deleteSheetO = options.deleteSheetOp) === null || _options$deleteSheetO === void 0 ? void 0 : _options$deleteSheetO.id);
|
|
12110
12086
|
});
|
|
12111
|
-
|
|
12112
|
-
|
|
12113
|
-
|
|
12114
|
-
|
|
12115
|
-
|
|
12116
|
-
|
|
12117
|
-
|
|
12087
|
+
if (target) {
|
|
12088
|
+
var index = getSheetIndex(ctx_, options.deleteSheetOp.id);
|
|
12089
|
+
options.deletedSheet = {
|
|
12090
|
+
id: options.deleteSheetOp.id,
|
|
12091
|
+
index: index,
|
|
12092
|
+
value: _.cloneDeep(ctx_.luckysheetfile[index])
|
|
12093
|
+
};
|
|
12094
|
+
options.deletedSheet.value.celldata = dataToCelldata(options.deletedSheet.value.data);
|
|
12095
|
+
delete options.deletedSheet.value.data;
|
|
12096
|
+
options.deletedSheet.value.status = 0;
|
|
12097
|
+
filteredInversePatches = [{
|
|
12098
|
+
op: "add",
|
|
12099
|
+
path: ["luckysheetfile", 0],
|
|
12100
|
+
value: options.deletedSheet.value
|
|
12101
|
+
}];
|
|
12102
|
+
}
|
|
12103
|
+
} else if (options.addSheetOp) {
|
|
12104
|
+
options.addSheet = {};
|
|
12105
|
+
options.addSheet.id = result.luckysheetfile[result.luckysheetfile.length - 1].id;
|
|
12118
12106
|
}
|
|
12107
|
+
globalCache.current.undoList.push({
|
|
12108
|
+
patches: filteredPatches,
|
|
12109
|
+
inversePatches: filteredInversePatches,
|
|
12110
|
+
options: options
|
|
12111
|
+
});
|
|
12112
|
+
globalCache.current.redoList = [];
|
|
12113
|
+
emitOp(result, filteredPatches, options);
|
|
12119
12114
|
}
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
|
|
12115
|
+
} else {
|
|
12116
|
+
var _patches$, _patches$$value, _ctx_$luckysheetfile;
|
|
12117
|
+
if ((patches === null || patches === void 0 ? void 0 : (_patches$ = patches[0]) === null || _patches$ === void 0 ? void 0 : (_patches$$value = _patches$.value) === null || _patches$$value === void 0 ? void 0 : _patches$$value.length) < (ctx_ === null || ctx_ === void 0 ? void 0 : (_ctx_$luckysheetfile = ctx_.luckysheetfile) === null || _ctx_$luckysheetfile === void 0 ? void 0 : _ctx_$luckysheetfile.length)) {
|
|
12118
|
+
reduceUndoList(result, ctx_);
|
|
12119
|
+
}
|
|
12120
|
+
}
|
|
12121
|
+
contextRef.current = result;
|
|
12122
|
+
setContext(result);
|
|
12123
|
+
});
|
|
12123
12124
|
var handleUndo = useCallback(function () {
|
|
12124
12125
|
var history = globalCache.current.undoList.pop();
|
|
12125
12126
|
if (history) {
|
|
12126
|
-
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
|
|
12140
|
-
|
|
12141
|
-
});
|
|
12127
|
+
var _history$options, _history$options3;
|
|
12128
|
+
var ctx_ = contextRef.current;
|
|
12129
|
+
if ((_history$options = history.options) === null || _history$options === void 0 ? void 0 : _history$options.deleteSheetOp) {
|
|
12130
|
+
var _history$options$dele, _history$options$dele2;
|
|
12131
|
+
history.inversePatches[0].path[1] = ctx_.luckysheetfile.length;
|
|
12132
|
+
var order = (_history$options$dele = history.options.deletedSheet) === null || _history$options$dele === void 0 ? void 0 : (_history$options$dele2 = _history$options$dele.value) === null || _history$options$dele2 === void 0 ? void 0 : _history$options$dele2.order;
|
|
12133
|
+
var sheetsRight = ctx_.luckysheetfile.filter(function (sheet) {
|
|
12134
|
+
var _history$options2, _history$options2$del;
|
|
12135
|
+
return (sheet === null || sheet === void 0 ? void 0 : sheet.order) >= order && sheet.id !== (history === null || history === void 0 ? void 0 : (_history$options2 = history.options) === null || _history$options2 === void 0 ? void 0 : (_history$options2$del = _history$options2.deleteSheetOp) === null || _history$options2$del === void 0 ? void 0 : _history$options2$del.id);
|
|
12136
|
+
});
|
|
12137
|
+
_.forEach(sheetsRight, function (sheet) {
|
|
12138
|
+
history.inversePatches.push({
|
|
12139
|
+
op: "replace",
|
|
12140
|
+
path: ["luckysheetfile", getSheetIndex(ctx_, sheet.id), "order"],
|
|
12141
|
+
value: (sheet === null || sheet === void 0 ? void 0 : sheet.order) + 1
|
|
12142
12142
|
});
|
|
12143
|
-
}
|
|
12144
|
-
|
|
12145
|
-
|
|
12146
|
-
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
|
|
12152
|
-
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
12162
|
-
|
|
12163
|
-
|
|
12143
|
+
});
|
|
12144
|
+
}
|
|
12145
|
+
var newContext = applyPatches(ctx_, history.inversePatches);
|
|
12146
|
+
globalCache.current.redoList.push(history);
|
|
12147
|
+
var inversedOptions = inverseRowColOptions(history.options);
|
|
12148
|
+
if (inversedOptions === null || inversedOptions === void 0 ? void 0 : inversedOptions.insertRowColOp) {
|
|
12149
|
+
inversedOptions.restoreDeletedCells = true;
|
|
12150
|
+
}
|
|
12151
|
+
if ((_history$options3 = history.options) === null || _history$options3 === void 0 ? void 0 : _history$options3.addSheetOp) {
|
|
12152
|
+
var _inversedOptions$addS;
|
|
12153
|
+
var index = getSheetIndex(ctx_, history.options.addSheet.id);
|
|
12154
|
+
inversedOptions.addSheet = {
|
|
12155
|
+
id: history.options.addSheet.id,
|
|
12156
|
+
index: index,
|
|
12157
|
+
value: _.cloneDeep(ctx_.luckysheetfile[index])
|
|
12158
|
+
};
|
|
12159
|
+
inversedOptions.addSheet.value.celldata = dataToCelldata((_inversedOptions$addS = inversedOptions.addSheet.value) === null || _inversedOptions$addS === void 0 ? void 0 : _inversedOptions$addS.data);
|
|
12160
|
+
delete inversedOptions.addSheet.value.data;
|
|
12161
|
+
}
|
|
12162
|
+
emitOp(newContext, history.inversePatches, inversedOptions, true);
|
|
12163
|
+
contextRef.current = newContext;
|
|
12164
|
+
setContext(newContext);
|
|
12164
12165
|
}
|
|
12165
12166
|
}, [emitOp]);
|
|
12166
12167
|
var handleRedo = useCallback(function () {
|
|
12167
12168
|
var history = globalCache.current.redoList.pop();
|
|
12168
12169
|
if (history) {
|
|
12169
|
-
|
|
12170
|
-
|
|
12171
|
-
|
|
12172
|
-
|
|
12173
|
-
|
|
12174
|
-
|
|
12170
|
+
var ctx_ = contextRef.current;
|
|
12171
|
+
var newContext = applyPatches(ctx_, history.patches);
|
|
12172
|
+
globalCache.current.undoList.push(history);
|
|
12173
|
+
emitOp(newContext, history.patches, history.options);
|
|
12174
|
+
contextRef.current = newContext;
|
|
12175
|
+
setContext(newContext);
|
|
12175
12176
|
}
|
|
12176
12177
|
}, [emitOp]);
|
|
12177
12178
|
useEffect(function () {
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var core = require('@leankylin-sheet/core');
|
|
6
|
+
var ahooks = require('ahooks');
|
|
6
7
|
var React = require('react');
|
|
7
8
|
var produce = require('immer');
|
|
8
9
|
var _ = require('lodash');
|
|
9
|
-
var ahooks = require('ahooks');
|
|
10
10
|
var reactDom = require('react-dom');
|
|
11
11
|
|
|
12
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -7874,7 +7874,7 @@ var FxEditor = function FxEditor() {
|
|
|
7874
7874
|
},
|
|
7875
7875
|
tabIndex: 0,
|
|
7876
7876
|
allowEdit: allowEdit
|
|
7877
|
-
}),
|
|
7877
|
+
}), settings === null || settings === void 0 ? void 0 : settings.fxContainer, /*#__PURE__*/React__default['default'].createElement(CalcInfo, null), focused && ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(FormulaSearch, {
|
|
7878
7878
|
style: {
|
|
7879
7879
|
top: inputContainerRef.current.clientHeight
|
|
7880
7880
|
}
|
|
@@ -11968,6 +11968,7 @@ var Workbook = /*#__PURE__*/React__default['default'].forwardRef(function (_ref,
|
|
|
11968
11968
|
_useState2 = _slicedToArray(_useState, 2),
|
|
11969
11969
|
context = _useState2[0],
|
|
11970
11970
|
setContext = _useState2[1];
|
|
11971
|
+
var contextRef = React.useRef(context);
|
|
11971
11972
|
var _useState3 = React.useState(null),
|
|
11972
11973
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
11973
11974
|
moreToolbarItems = _useState4[0],
|
|
@@ -12072,116 +12073,116 @@ var Workbook = /*#__PURE__*/React__default['default'].forwardRef(function (_ref,
|
|
|
12072
12073
|
}
|
|
12073
12074
|
return cellData;
|
|
12074
12075
|
}
|
|
12075
|
-
var setContextWithProduce =
|
|
12076
|
+
var setContextWithProduce = ahooks.useMemoizedFn(function (recipe) {
|
|
12076
12077
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
|
|
12086
|
-
|
|
12087
|
-
|
|
12088
|
-
|
|
12089
|
-
|
|
12090
|
-
|
|
12091
|
-
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
|
|
12095
|
-
});
|
|
12096
|
-
if (target) {
|
|
12097
|
-
var index = core.getSheetIndex(ctx_, options.deleteSheetOp.id);
|
|
12098
|
-
options.deletedSheet = {
|
|
12099
|
-
id: options.deleteSheetOp.id,
|
|
12100
|
-
index: index,
|
|
12101
|
-
value: ___default['default'].cloneDeep(ctx_.luckysheetfile[index])
|
|
12102
|
-
};
|
|
12103
|
-
options.deletedSheet.value.celldata = dataToCelldata(options.deletedSheet.value.data);
|
|
12104
|
-
delete options.deletedSheet.value.data;
|
|
12105
|
-
options.deletedSheet.value.status = 0;
|
|
12106
|
-
filteredInversePatches = [{
|
|
12107
|
-
op: "add",
|
|
12108
|
-
path: ["luckysheetfile", 0],
|
|
12109
|
-
value: options.deletedSheet.value
|
|
12110
|
-
}];
|
|
12111
|
-
}
|
|
12112
|
-
} else if (options.addSheetOp) {
|
|
12113
|
-
options.addSheet = {};
|
|
12114
|
-
options.addSheet.id = result.luckysheetfile[result.luckysheetfile.length - 1].id;
|
|
12115
|
-
}
|
|
12116
|
-
globalCache.current.undoList.push({
|
|
12117
|
-
patches: filteredPatches,
|
|
12118
|
-
inversePatches: filteredInversePatches,
|
|
12119
|
-
options: options
|
|
12078
|
+
var ctx_ = contextRef.current;
|
|
12079
|
+
var _produceWithPatches = produce.produceWithPatches(ctx_, concatProducer(recipe, triggerGroupValuesRefresh)),
|
|
12080
|
+
_produceWithPatches2 = _slicedToArray(_produceWithPatches, 3),
|
|
12081
|
+
result = _produceWithPatches2[0],
|
|
12082
|
+
patches = _produceWithPatches2[1],
|
|
12083
|
+
inversePatches = _produceWithPatches2[2];
|
|
12084
|
+
if (patches.length > 0 && !options.noHistory) {
|
|
12085
|
+
if (options.logPatch) {
|
|
12086
|
+
console.info("patch", patches);
|
|
12087
|
+
}
|
|
12088
|
+
var filteredPatches = core.filterPatch(patches);
|
|
12089
|
+
var filteredInversePatches = core.filterPatch(inversePatches);
|
|
12090
|
+
if (filteredInversePatches.length > 0) {
|
|
12091
|
+
options.id = ctx_.currentSheetId;
|
|
12092
|
+
if (options.deleteSheetOp) {
|
|
12093
|
+
var target = ctx_.luckysheetfile.filter(function (sheet) {
|
|
12094
|
+
var _options$deleteSheetO;
|
|
12095
|
+
return sheet.id === ((_options$deleteSheetO = options.deleteSheetOp) === null || _options$deleteSheetO === void 0 ? void 0 : _options$deleteSheetO.id);
|
|
12120
12096
|
});
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
|
|
12097
|
+
if (target) {
|
|
12098
|
+
var index = core.getSheetIndex(ctx_, options.deleteSheetOp.id);
|
|
12099
|
+
options.deletedSheet = {
|
|
12100
|
+
id: options.deleteSheetOp.id,
|
|
12101
|
+
index: index,
|
|
12102
|
+
value: ___default['default'].cloneDeep(ctx_.luckysheetfile[index])
|
|
12103
|
+
};
|
|
12104
|
+
options.deletedSheet.value.celldata = dataToCelldata(options.deletedSheet.value.data);
|
|
12105
|
+
delete options.deletedSheet.value.data;
|
|
12106
|
+
options.deletedSheet.value.status = 0;
|
|
12107
|
+
filteredInversePatches = [{
|
|
12108
|
+
op: "add",
|
|
12109
|
+
path: ["luckysheetfile", 0],
|
|
12110
|
+
value: options.deletedSheet.value
|
|
12111
|
+
}];
|
|
12112
|
+
}
|
|
12113
|
+
} else if (options.addSheetOp) {
|
|
12114
|
+
options.addSheet = {};
|
|
12115
|
+
options.addSheet.id = result.luckysheetfile[result.luckysheetfile.length - 1].id;
|
|
12128
12116
|
}
|
|
12117
|
+
globalCache.current.undoList.push({
|
|
12118
|
+
patches: filteredPatches,
|
|
12119
|
+
inversePatches: filteredInversePatches,
|
|
12120
|
+
options: options
|
|
12121
|
+
});
|
|
12122
|
+
globalCache.current.redoList = [];
|
|
12123
|
+
emitOp(result, filteredPatches, options);
|
|
12129
12124
|
}
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
|
|
12125
|
+
} else {
|
|
12126
|
+
var _patches$, _patches$$value, _ctx_$luckysheetfile;
|
|
12127
|
+
if ((patches === null || patches === void 0 ? void 0 : (_patches$ = patches[0]) === null || _patches$ === void 0 ? void 0 : (_patches$$value = _patches$.value) === null || _patches$$value === void 0 ? void 0 : _patches$$value.length) < (ctx_ === null || ctx_ === void 0 ? void 0 : (_ctx_$luckysheetfile = ctx_.luckysheetfile) === null || _ctx_$luckysheetfile === void 0 ? void 0 : _ctx_$luckysheetfile.length)) {
|
|
12128
|
+
reduceUndoList(result, ctx_);
|
|
12129
|
+
}
|
|
12130
|
+
}
|
|
12131
|
+
contextRef.current = result;
|
|
12132
|
+
setContext(result);
|
|
12133
|
+
});
|
|
12133
12134
|
var handleUndo = React.useCallback(function () {
|
|
12134
12135
|
var history = globalCache.current.undoList.pop();
|
|
12135
12136
|
if (history) {
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
|
|
12140
|
-
|
|
12141
|
-
|
|
12142
|
-
|
|
12143
|
-
|
|
12144
|
-
|
|
12145
|
-
|
|
12146
|
-
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
});
|
|
12137
|
+
var _history$options, _history$options3;
|
|
12138
|
+
var ctx_ = contextRef.current;
|
|
12139
|
+
if ((_history$options = history.options) === null || _history$options === void 0 ? void 0 : _history$options.deleteSheetOp) {
|
|
12140
|
+
var _history$options$dele, _history$options$dele2;
|
|
12141
|
+
history.inversePatches[0].path[1] = ctx_.luckysheetfile.length;
|
|
12142
|
+
var order = (_history$options$dele = history.options.deletedSheet) === null || _history$options$dele === void 0 ? void 0 : (_history$options$dele2 = _history$options$dele.value) === null || _history$options$dele2 === void 0 ? void 0 : _history$options$dele2.order;
|
|
12143
|
+
var sheetsRight = ctx_.luckysheetfile.filter(function (sheet) {
|
|
12144
|
+
var _history$options2, _history$options2$del;
|
|
12145
|
+
return (sheet === null || sheet === void 0 ? void 0 : sheet.order) >= order && sheet.id !== (history === null || history === void 0 ? void 0 : (_history$options2 = history.options) === null || _history$options2 === void 0 ? void 0 : (_history$options2$del = _history$options2.deleteSheetOp) === null || _history$options2$del === void 0 ? void 0 : _history$options2$del.id);
|
|
12146
|
+
});
|
|
12147
|
+
___default['default'].forEach(sheetsRight, function (sheet) {
|
|
12148
|
+
history.inversePatches.push({
|
|
12149
|
+
op: "replace",
|
|
12150
|
+
path: ["luckysheetfile", core.getSheetIndex(ctx_, sheet.id), "order"],
|
|
12151
|
+
value: (sheet === null || sheet === void 0 ? void 0 : sheet.order) + 1
|
|
12152
12152
|
});
|
|
12153
|
-
}
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
12162
|
-
|
|
12163
|
-
|
|
12164
|
-
|
|
12165
|
-
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
|
|
12171
|
-
|
|
12172
|
-
|
|
12173
|
-
|
|
12153
|
+
});
|
|
12154
|
+
}
|
|
12155
|
+
var newContext = produce.applyPatches(ctx_, history.inversePatches);
|
|
12156
|
+
globalCache.current.redoList.push(history);
|
|
12157
|
+
var inversedOptions = core.inverseRowColOptions(history.options);
|
|
12158
|
+
if (inversedOptions === null || inversedOptions === void 0 ? void 0 : inversedOptions.insertRowColOp) {
|
|
12159
|
+
inversedOptions.restoreDeletedCells = true;
|
|
12160
|
+
}
|
|
12161
|
+
if ((_history$options3 = history.options) === null || _history$options3 === void 0 ? void 0 : _history$options3.addSheetOp) {
|
|
12162
|
+
var _inversedOptions$addS;
|
|
12163
|
+
var index = core.getSheetIndex(ctx_, history.options.addSheet.id);
|
|
12164
|
+
inversedOptions.addSheet = {
|
|
12165
|
+
id: history.options.addSheet.id,
|
|
12166
|
+
index: index,
|
|
12167
|
+
value: ___default['default'].cloneDeep(ctx_.luckysheetfile[index])
|
|
12168
|
+
};
|
|
12169
|
+
inversedOptions.addSheet.value.celldata = dataToCelldata((_inversedOptions$addS = inversedOptions.addSheet.value) === null || _inversedOptions$addS === void 0 ? void 0 : _inversedOptions$addS.data);
|
|
12170
|
+
delete inversedOptions.addSheet.value.data;
|
|
12171
|
+
}
|
|
12172
|
+
emitOp(newContext, history.inversePatches, inversedOptions, true);
|
|
12173
|
+
contextRef.current = newContext;
|
|
12174
|
+
setContext(newContext);
|
|
12174
12175
|
}
|
|
12175
12176
|
}, [emitOp]);
|
|
12176
12177
|
var handleRedo = React.useCallback(function () {
|
|
12177
12178
|
var history = globalCache.current.redoList.pop();
|
|
12178
12179
|
if (history) {
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
|
|
12180
|
+
var ctx_ = contextRef.current;
|
|
12181
|
+
var newContext = produce.applyPatches(ctx_, history.patches);
|
|
12182
|
+
globalCache.current.undoList.push(history);
|
|
12183
|
+
emitOp(newContext, history.patches, history.options);
|
|
12184
|
+
contextRef.current = newContext;
|
|
12185
|
+
setContext(newContext);
|
|
12185
12186
|
}
|
|
12186
12187
|
}, [emitOp]);
|
|
12187
12188
|
React.useEffect(function () {
|