@leankylin-sheet/core 4.0.3 → 4.0.5
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/api/sheet.d.ts +2 -1
- package/dist/index.esm.js +23 -12
- package/dist/index.js +23 -12
- package/dist/settings.d.ts +1 -0
- package/package.json +2 -2
package/dist/api/sheet.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { getSheet } from "./common";
|
|
2
2
|
import { Context } from "../context";
|
|
3
3
|
import { CellMatrix, Sheet } from "../types";
|
|
4
|
+
import { Hooks } from "..";
|
|
4
5
|
export declare function getAllSheets(ctx: Context): Sheet[];
|
|
5
6
|
export { getSheet };
|
|
6
7
|
export declare function initSheetData(draftCtx: Context, index: number, newData: Sheet): CellMatrix | null;
|
|
7
8
|
export declare function hideSheet(ctx: Context, sheetId: string): void;
|
|
8
9
|
export declare function showSheet(ctx: Context, sheetId: string): void;
|
|
9
|
-
export declare function copySheet(ctx: Context, sheetId: string): void;
|
|
10
|
+
export declare function copySheet(ctx: Context, sheetId: string, hooks: Hooks): void;
|
|
10
11
|
export declare function calculateSheetFromula(ctx: Context, id: string): void;
|
package/dist/index.esm.js
CHANGED
|
@@ -46387,7 +46387,8 @@ function generateCopySheetName(ctx, sheetId) {
|
|
|
46387
46387
|
} while (sheetNames.indexOf(sheetCopyName) !== -1);
|
|
46388
46388
|
return sheetCopyName;
|
|
46389
46389
|
}
|
|
46390
|
-
function copySheet(ctx, sheetId) {
|
|
46390
|
+
function copySheet(ctx, sheetId, hooks) {
|
|
46391
|
+
var _hooks$onCopySheet;
|
|
46391
46392
|
var index$1 = getSheetIndex(ctx, sheetId);
|
|
46392
46393
|
var order = ctx.luckysheetfile[index$1].order + 1;
|
|
46393
46394
|
var sheetName = generateCopySheetName(ctx, sheetId);
|
|
@@ -46396,10 +46397,12 @@ function copySheet(ctx, sheetId) {
|
|
|
46396
46397
|
delete sheetData.status;
|
|
46397
46398
|
sheetData.celldata = dataToCelldata(sheetData.data);
|
|
46398
46399
|
delete sheetData.data;
|
|
46399
|
-
|
|
46400
|
+
var copyId = v4();
|
|
46401
|
+
addSheet$1(ctx, undefined, copyId, ctx.luckysheetfile[index$1].isPivotTable, sheetName, sheetData);
|
|
46400
46402
|
var sheetOrderList = {};
|
|
46401
46403
|
sheetOrderList[ctx.luckysheetfile[ctx.luckysheetfile.length - 1].id] = order;
|
|
46402
46404
|
setSheetOrder(ctx, sheetOrderList);
|
|
46405
|
+
(_hooks$onCopySheet = hooks.onCopySheet) === null || _hooks$onCopySheet === void 0 ? void 0 : _hooks$onCopySheet.call(hooks, sheetId, copyId);
|
|
46403
46406
|
}
|
|
46404
46407
|
function calculateSheetFromula(ctx, id) {
|
|
46405
46408
|
var index$1 = getSheetIndex(ctx, id);
|
|
@@ -56416,7 +56419,6 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
|
|
|
56416
56419
|
function handleGlobalWheel(ctx, e, cache, scrollbarX, scrollbarY) {
|
|
56417
56420
|
var _cache$searchDialog;
|
|
56418
56421
|
if (((_cache$searchDialog = cache.searchDialog) === null || _cache$searchDialog === void 0 ? void 0 : _cache$searchDialog.mouseEnter) && ctx.showSearch && ctx.showReplace) return;
|
|
56419
|
-
if (ctx.filterContextMenu != null) return;
|
|
56420
56422
|
var scrollLeft = scrollbarX.scrollLeft;
|
|
56421
56423
|
var scrollTop = scrollbarY.scrollTop;
|
|
56422
56424
|
if (e.deltaY !== 0) {
|
|
@@ -56935,8 +56937,6 @@ function handleCellAreaMouseMove(ctx, globalCache, e, container) {
|
|
|
56935
56937
|
if (!afterCellMouseMove) {
|
|
56936
56938
|
return;
|
|
56937
56939
|
}
|
|
56938
|
-
ctx.contextMenu = {};
|
|
56939
|
-
ctx.filterContextMenu = undefined;
|
|
56940
56940
|
var flowdata = getFlowdata(ctx);
|
|
56941
56941
|
if (!flowdata) return;
|
|
56942
56942
|
var rect = container.getBoundingClientRect();
|
|
@@ -59751,11 +59751,14 @@ function getClipboardData(ctx, e, copyRich, startRow, startCol) {
|
|
|
59751
59751
|
var rows = htmlDoc.querySelectorAll("tbody tr");
|
|
59752
59752
|
if (!rows || rows.length < 1) {
|
|
59753
59753
|
return {
|
|
59754
|
-
data: [[clipboardData.getData("text")]]
|
|
59754
|
+
data: [[clipboardData.getData("text")]],
|
|
59755
|
+
borderInfo: [],
|
|
59756
|
+
merge: {}
|
|
59755
59757
|
};
|
|
59756
59758
|
}
|
|
59757
59759
|
var result = [];
|
|
59758
59760
|
var borderInfo = [];
|
|
59761
|
+
var merge = {};
|
|
59759
59762
|
var startOffColIndexMap = {};
|
|
59760
59763
|
for (var index = 0; index < (rows === null || rows === void 0 ? void 0 : rows.length); index += 1) {
|
|
59761
59764
|
var row = rows[index];
|
|
@@ -59787,6 +59790,7 @@ function getClipboardData(ctx, e, copyRich, startRow, startCol) {
|
|
|
59787
59790
|
r: index + startRow,
|
|
59788
59791
|
c: _colIndex
|
|
59789
59792
|
};
|
|
59793
|
+
merge["".concat(index + startRow, "_").concat(_colIndex)] = mainCell.mc;
|
|
59790
59794
|
borderInfo.push.apply(borderInfo, _toConsumableArray(getCellMcBorder(ctx, style, index + startRow, _colIndex, mainCell.mc)));
|
|
59791
59795
|
} else {
|
|
59792
59796
|
isFirstNoRs = true;
|
|
@@ -59833,7 +59837,8 @@ function getClipboardData(ctx, e, copyRich, startRow, startCol) {
|
|
|
59833
59837
|
}
|
|
59834
59838
|
return {
|
|
59835
59839
|
data: result,
|
|
59836
|
-
borderInfo: borderInfo
|
|
59840
|
+
borderInfo: borderInfo,
|
|
59841
|
+
merge: merge
|
|
59837
59842
|
};
|
|
59838
59843
|
}
|
|
59839
59844
|
function handlePasteByLeanklin(_x2, _x3, _x4) {
|
|
@@ -59842,7 +59847,7 @@ function handlePasteByLeanklin(_x2, _x3, _x4) {
|
|
|
59842
59847
|
function _handlePasteByLeanklin() {
|
|
59843
59848
|
_handlePasteByLeanklin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ctx, e, copyRich) {
|
|
59844
59849
|
var _ctx$luckysheet_selec8, _data$0$;
|
|
59845
|
-
var allowEdit, selectRange, rows, columns, _getClipboardData, copyData, borderInfo, _ctx$config$borderInf, index, data, copyOne, pasteData, r, rIndex, c, row, column, range;
|
|
59850
|
+
var allowEdit, selectRange, rows, columns, _getClipboardData, copyData, borderInfo, merge, _ctx$config$borderInf, index, data, copyOne, pasteData, r, rIndex, c, row, column, range;
|
|
59846
59851
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
59847
59852
|
while (1) switch (_context2.prev = _context2.next) {
|
|
59848
59853
|
case 0:
|
|
@@ -59862,13 +59867,19 @@ function _handlePasteByLeanklin() {
|
|
|
59862
59867
|
case 6:
|
|
59863
59868
|
rows = selectRange.row;
|
|
59864
59869
|
columns = selectRange.column;
|
|
59865
|
-
_getClipboardData = getClipboardData(ctx, e, copyRich, rows[0], columns[0]), copyData = _getClipboardData.data, borderInfo = _getClipboardData.borderInfo;
|
|
59870
|
+
_getClipboardData = getClipboardData(ctx, e, copyRich, rows[0], columns[0]), copyData = _getClipboardData.data, borderInfo = _getClipboardData.borderInfo, merge = _getClipboardData.merge;
|
|
59866
59871
|
if (!ctx.config.borderInfo) {
|
|
59867
59872
|
ctx.config.borderInfo = [];
|
|
59868
59873
|
}
|
|
59869
59874
|
if (copyRich) {
|
|
59870
59875
|
(_ctx$config$borderInf = ctx.config.borderInfo).push.apply(_ctx$config$borderInf, _toConsumableArray(borderInfo));
|
|
59871
59876
|
}
|
|
59877
|
+
if (!ctx.config.merge) {
|
|
59878
|
+
ctx.config.merge = {};
|
|
59879
|
+
}
|
|
59880
|
+
if (copyRich) {
|
|
59881
|
+
ctx.config.merge = Object.assign(ctx.config.merge, merge);
|
|
59882
|
+
}
|
|
59872
59883
|
index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
59873
59884
|
ctx.luckysheetfile[index].config = ctx.config;
|
|
59874
59885
|
data = copyData;
|
|
@@ -59890,14 +59901,14 @@ function _handlePasteByLeanklin() {
|
|
|
59890
59901
|
column: column
|
|
59891
59902
|
};
|
|
59892
59903
|
if (isAllowEdit(ctx, [range])) {
|
|
59893
|
-
_context2.next =
|
|
59904
|
+
_context2.next = 24;
|
|
59894
59905
|
break;
|
|
59895
59906
|
}
|
|
59896
59907
|
return _context2.abrupt("return");
|
|
59897
|
-
case
|
|
59908
|
+
case 24:
|
|
59898
59909
|
setCellValuesByRange(ctx, pasteData, range, null);
|
|
59899
59910
|
ctx.luckysheet_select_save = [range];
|
|
59900
|
-
case
|
|
59911
|
+
case 26:
|
|
59901
59912
|
case "end":
|
|
59902
59913
|
return _context2.stop();
|
|
59903
59914
|
}
|
package/dist/index.js
CHANGED
|
@@ -46397,7 +46397,8 @@ function generateCopySheetName(ctx, sheetId) {
|
|
|
46397
46397
|
} while (sheetNames.indexOf(sheetCopyName) !== -1);
|
|
46398
46398
|
return sheetCopyName;
|
|
46399
46399
|
}
|
|
46400
|
-
function copySheet(ctx, sheetId) {
|
|
46400
|
+
function copySheet(ctx, sheetId, hooks) {
|
|
46401
|
+
var _hooks$onCopySheet;
|
|
46401
46402
|
var index$1 = getSheetIndex(ctx, sheetId);
|
|
46402
46403
|
var order = ctx.luckysheetfile[index$1].order + 1;
|
|
46403
46404
|
var sheetName = generateCopySheetName(ctx, sheetId);
|
|
@@ -46406,10 +46407,12 @@ function copySheet(ctx, sheetId) {
|
|
|
46406
46407
|
delete sheetData.status;
|
|
46407
46408
|
sheetData.celldata = dataToCelldata(sheetData.data);
|
|
46408
46409
|
delete sheetData.data;
|
|
46409
|
-
|
|
46410
|
+
var copyId = uuid.v4();
|
|
46411
|
+
addSheet$1(ctx, undefined, copyId, ctx.luckysheetfile[index$1].isPivotTable, sheetName, sheetData);
|
|
46410
46412
|
var sheetOrderList = {};
|
|
46411
46413
|
sheetOrderList[ctx.luckysheetfile[ctx.luckysheetfile.length - 1].id] = order;
|
|
46412
46414
|
setSheetOrder(ctx, sheetOrderList);
|
|
46415
|
+
(_hooks$onCopySheet = hooks.onCopySheet) === null || _hooks$onCopySheet === void 0 ? void 0 : _hooks$onCopySheet.call(hooks, sheetId, copyId);
|
|
46413
46416
|
}
|
|
46414
46417
|
function calculateSheetFromula(ctx, id) {
|
|
46415
46418
|
var index$1 = getSheetIndex(ctx, id);
|
|
@@ -56426,7 +56429,6 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
|
|
|
56426
56429
|
function handleGlobalWheel(ctx, e, cache, scrollbarX, scrollbarY) {
|
|
56427
56430
|
var _cache$searchDialog;
|
|
56428
56431
|
if (((_cache$searchDialog = cache.searchDialog) === null || _cache$searchDialog === void 0 ? void 0 : _cache$searchDialog.mouseEnter) && ctx.showSearch && ctx.showReplace) return;
|
|
56429
|
-
if (ctx.filterContextMenu != null) return;
|
|
56430
56432
|
var scrollLeft = scrollbarX.scrollLeft;
|
|
56431
56433
|
var scrollTop = scrollbarY.scrollTop;
|
|
56432
56434
|
if (e.deltaY !== 0) {
|
|
@@ -56945,8 +56947,6 @@ function handleCellAreaMouseMove(ctx, globalCache, e, container) {
|
|
|
56945
56947
|
if (!afterCellMouseMove) {
|
|
56946
56948
|
return;
|
|
56947
56949
|
}
|
|
56948
|
-
ctx.contextMenu = {};
|
|
56949
|
-
ctx.filterContextMenu = undefined;
|
|
56950
56950
|
var flowdata = getFlowdata(ctx);
|
|
56951
56951
|
if (!flowdata) return;
|
|
56952
56952
|
var rect = container.getBoundingClientRect();
|
|
@@ -59761,11 +59761,14 @@ function getClipboardData(ctx, e, copyRich, startRow, startCol) {
|
|
|
59761
59761
|
var rows = htmlDoc.querySelectorAll("tbody tr");
|
|
59762
59762
|
if (!rows || rows.length < 1) {
|
|
59763
59763
|
return {
|
|
59764
|
-
data: [[clipboardData.getData("text")]]
|
|
59764
|
+
data: [[clipboardData.getData("text")]],
|
|
59765
|
+
borderInfo: [],
|
|
59766
|
+
merge: {}
|
|
59765
59767
|
};
|
|
59766
59768
|
}
|
|
59767
59769
|
var result = [];
|
|
59768
59770
|
var borderInfo = [];
|
|
59771
|
+
var merge = {};
|
|
59769
59772
|
var startOffColIndexMap = {};
|
|
59770
59773
|
for (var index = 0; index < (rows === null || rows === void 0 ? void 0 : rows.length); index += 1) {
|
|
59771
59774
|
var row = rows[index];
|
|
@@ -59797,6 +59800,7 @@ function getClipboardData(ctx, e, copyRich, startRow, startCol) {
|
|
|
59797
59800
|
r: index + startRow,
|
|
59798
59801
|
c: _colIndex
|
|
59799
59802
|
};
|
|
59803
|
+
merge["".concat(index + startRow, "_").concat(_colIndex)] = mainCell.mc;
|
|
59800
59804
|
borderInfo.push.apply(borderInfo, _toConsumableArray(getCellMcBorder(ctx, style, index + startRow, _colIndex, mainCell.mc)));
|
|
59801
59805
|
} else {
|
|
59802
59806
|
isFirstNoRs = true;
|
|
@@ -59843,7 +59847,8 @@ function getClipboardData(ctx, e, copyRich, startRow, startCol) {
|
|
|
59843
59847
|
}
|
|
59844
59848
|
return {
|
|
59845
59849
|
data: result,
|
|
59846
|
-
borderInfo: borderInfo
|
|
59850
|
+
borderInfo: borderInfo,
|
|
59851
|
+
merge: merge
|
|
59847
59852
|
};
|
|
59848
59853
|
}
|
|
59849
59854
|
function handlePasteByLeanklin(_x2, _x3, _x4) {
|
|
@@ -59852,7 +59857,7 @@ function handlePasteByLeanklin(_x2, _x3, _x4) {
|
|
|
59852
59857
|
function _handlePasteByLeanklin() {
|
|
59853
59858
|
_handlePasteByLeanklin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ctx, e, copyRich) {
|
|
59854
59859
|
var _ctx$luckysheet_selec8, _data$0$;
|
|
59855
|
-
var allowEdit, selectRange, rows, columns, _getClipboardData, copyData, borderInfo, _ctx$config$borderInf, index, data, copyOne, pasteData, r, rIndex, c, row, column, range;
|
|
59860
|
+
var allowEdit, selectRange, rows, columns, _getClipboardData, copyData, borderInfo, merge, _ctx$config$borderInf, index, data, copyOne, pasteData, r, rIndex, c, row, column, range;
|
|
59856
59861
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
59857
59862
|
while (1) switch (_context2.prev = _context2.next) {
|
|
59858
59863
|
case 0:
|
|
@@ -59872,13 +59877,19 @@ function _handlePasteByLeanklin() {
|
|
|
59872
59877
|
case 6:
|
|
59873
59878
|
rows = selectRange.row;
|
|
59874
59879
|
columns = selectRange.column;
|
|
59875
|
-
_getClipboardData = getClipboardData(ctx, e, copyRich, rows[0], columns[0]), copyData = _getClipboardData.data, borderInfo = _getClipboardData.borderInfo;
|
|
59880
|
+
_getClipboardData = getClipboardData(ctx, e, copyRich, rows[0], columns[0]), copyData = _getClipboardData.data, borderInfo = _getClipboardData.borderInfo, merge = _getClipboardData.merge;
|
|
59876
59881
|
if (!ctx.config.borderInfo) {
|
|
59877
59882
|
ctx.config.borderInfo = [];
|
|
59878
59883
|
}
|
|
59879
59884
|
if (copyRich) {
|
|
59880
59885
|
(_ctx$config$borderInf = ctx.config.borderInfo).push.apply(_ctx$config$borderInf, _toConsumableArray(borderInfo));
|
|
59881
59886
|
}
|
|
59887
|
+
if (!ctx.config.merge) {
|
|
59888
|
+
ctx.config.merge = {};
|
|
59889
|
+
}
|
|
59890
|
+
if (copyRich) {
|
|
59891
|
+
ctx.config.merge = Object.assign(ctx.config.merge, merge);
|
|
59892
|
+
}
|
|
59882
59893
|
index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
59883
59894
|
ctx.luckysheetfile[index].config = ctx.config;
|
|
59884
59895
|
data = copyData;
|
|
@@ -59900,14 +59911,14 @@ function _handlePasteByLeanklin() {
|
|
|
59900
59911
|
column: column
|
|
59901
59912
|
};
|
|
59902
59913
|
if (isAllowEdit(ctx, [range])) {
|
|
59903
|
-
_context2.next =
|
|
59914
|
+
_context2.next = 24;
|
|
59904
59915
|
break;
|
|
59905
59916
|
}
|
|
59906
59917
|
return _context2.abrupt("return");
|
|
59907
|
-
case
|
|
59918
|
+
case 24:
|
|
59908
59919
|
setCellValuesByRange(ctx, pasteData, range, null);
|
|
59909
59920
|
ctx.luckysheet_select_save = [range];
|
|
59910
|
-
case
|
|
59921
|
+
case 26:
|
|
59911
59922
|
case "end":
|
|
59912
59923
|
return _context2.stop();
|
|
59913
59924
|
}
|
package/dist/settings.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Sheet, Selection, CellMatrix, Cell } from "./types";
|
|
3
3
|
export type Hooks = {
|
|
4
|
+
onCopySheet?: (oldSheetId: string, newSheetId: string) => void;
|
|
4
5
|
commentsPreRender?: (r: number, c: number) => any;
|
|
5
6
|
showCommentsMenu?: (item: {
|
|
6
7
|
text: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leankylin-sheet/core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.esm.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"build": "father-build"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@leankylin-sheet/formula-parser": "4.0.
|
|
16
|
+
"@leankylin-sheet/formula-parser": "4.0.5",
|
|
17
17
|
"dayjs": "^1.11.0",
|
|
18
18
|
"immer": "^9.0.12",
|
|
19
19
|
"lodash": "^4.17.21",
|