@fileverse-dev/fortune-core 1.2.90-ydoc-14 → 1.2.91-toast-6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/api/cell.d.ts +1 -1
- package/es/api/cell.js +2 -5
- package/es/api/range.d.ts +1 -1
- package/es/api/range.js +2 -2
- package/es/events/keyboard.js +0 -1
- package/es/events/paste.js +6 -51
- package/es/modules/cell.js +0 -1
- package/es/modules/hyperlink.js +0 -14
- package/es/modules/selection.js +1 -14
- package/es/modules/sheet.js +18 -16
- package/es/modules/toolbar.js +9 -40
- package/es/settings.d.ts +0 -18
- package/lib/api/cell.d.ts +1 -1
- package/lib/api/cell.js +2 -5
- package/lib/api/range.d.ts +1 -1
- package/lib/api/range.js +2 -2
- package/lib/events/keyboard.js +0 -1
- package/lib/events/paste.js +6 -51
- package/lib/modules/cell.js +0 -1
- package/lib/modules/hyperlink.js +0 -14
- package/lib/modules/selection.js +1 -14
- package/lib/modules/sheet.js +18 -16
- package/lib/modules/toolbar.js +9 -40
- package/lib/settings.d.ts +0 -18
- package/package.json +1 -1
package/es/api/cell.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { CommonOptions } from "./common";
|
|
|
4
4
|
export declare function getCellValue(ctx: Context, row: number, column: number, options?: CommonOptions & {
|
|
5
5
|
type?: keyof Cell;
|
|
6
6
|
}): any;
|
|
7
|
-
export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions
|
|
7
|
+
export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions): void;
|
|
8
8
|
export declare function clearCell(ctx: Context, row: number, column: number, options?: CommonOptions): void;
|
|
9
9
|
export declare function setCellFormat(ctx: Context, row: number, column: number, attr: keyof Cell, value: any, options?: CommonOptions): void;
|
|
10
10
|
export declare function autoFillCell(ctx: Context, copyRange: SingleRange, applyRange: SingleRange, direction: "up" | "down" | "left" | "right"): void;
|
package/es/api/cell.js
CHANGED
|
@@ -50,8 +50,8 @@ export function getCellValue(ctx, row, column, options) {
|
|
|
50
50
|
}
|
|
51
51
|
return ret;
|
|
52
52
|
}
|
|
53
|
-
export function setCellValue(ctx, row, column, value, cellInput, options
|
|
54
|
-
var _a
|
|
53
|
+
export function setCellValue(ctx, row, column, value, cellInput, options) {
|
|
54
|
+
var _a;
|
|
55
55
|
if (options === void 0) {
|
|
56
56
|
options = {};
|
|
57
57
|
}
|
|
@@ -127,9 +127,6 @@ export function setCellValue(ctx, row, column, value, cellInput, options, callAf
|
|
|
127
127
|
setCellValueInternal(ctx, row, column, data, value);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
if (callAfterUpdate && ctx.hooks.afterUpdateCell) {
|
|
131
|
-
(_c = (_b = ctx.hooks).afterUpdateCell) === null || _c === void 0 ? void 0 : _c.call(_b, row, column, null, value);
|
|
132
|
-
}
|
|
133
130
|
}
|
|
134
131
|
export function clearCell(ctx, row, column, options) {
|
|
135
132
|
var _a, _b;
|
package/es/api/range.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ export declare function getSelectionCoordinates(ctx: Context): string[];
|
|
|
18
18
|
export declare function getCellsByRange(ctx: Context, range: Selection, options?: CommonOptions): (Cell | null)[][];
|
|
19
19
|
export declare function getHtmlByRange(ctx: Context, range: Range, options?: CommonOptions): string | null;
|
|
20
20
|
export declare function setSelection(ctx: Context, range: Range, options: CommonOptions): void;
|
|
21
|
-
export declare function setCellValuesByRange(ctx: Context, data: any[][], range: SingleRange, cellInput: HTMLDivElement | null, options?: CommonOptions
|
|
21
|
+
export declare function setCellValuesByRange(ctx: Context, data: any[][], range: SingleRange, cellInput: HTMLDivElement | null, options?: CommonOptions): void;
|
|
22
22
|
export declare function setCellFormatByRange(ctx: Context, attr: keyof Cell, value: any, range: Range | SingleRange, options?: CommonOptions): void;
|
package/es/api/range.js
CHANGED
|
@@ -77,7 +77,7 @@ export function setSelection(ctx, range, options) {
|
|
|
77
77
|
ctx.luckysheet_select_save = sheet.luckysheet_select_save;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
export function setCellValuesByRange(ctx, data, range, cellInput, options
|
|
80
|
+
export function setCellValuesByRange(ctx, data, range, cellInput, options) {
|
|
81
81
|
if (options === void 0) {
|
|
82
82
|
options = {};
|
|
83
83
|
}
|
|
@@ -99,7 +99,7 @@ export function setCellValuesByRange(ctx, data, range, cellInput, options, callA
|
|
|
99
99
|
for (var j = 0; j < columnCount; j += 1) {
|
|
100
100
|
var row = range.row[0] + i;
|
|
101
101
|
var column = range.column[0] + j;
|
|
102
|
-
setCellValue(ctx, row, column, data[i][j], cellInput, options
|
|
102
|
+
setCellValue(ctx, row, column, data[i][j], cellInput, options);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
}
|
package/es/events/keyboard.js
CHANGED
|
@@ -466,7 +466,6 @@ export function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUnd
|
|
|
466
466
|
} else if (kstr === "Escape") {
|
|
467
467
|
ctx.contextMenu = {};
|
|
468
468
|
} else if (kstr === "Delete" || kstr === "Backspace") {
|
|
469
|
-
console.log("Delete");
|
|
470
469
|
if (!allowEdit) return [2];
|
|
471
470
|
if (ctx.activeImg != null) {
|
|
472
471
|
removeActiveImage(ctx);
|
package/es/events/paste.js
CHANGED
|
@@ -189,43 +189,28 @@ function postPasteCut(ctx, source, target, RowlChange) {
|
|
|
189
189
|
storeSheetParamALL(ctx);
|
|
190
190
|
}
|
|
191
191
|
var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
|
|
192
|
-
var _a
|
|
193
|
-
var changes = [];
|
|
192
|
+
var _a;
|
|
194
193
|
for (var r = 0; r < d.length; r += 1) {
|
|
195
194
|
var x = d[r];
|
|
196
195
|
for (var c = 0; c < d[0].length; c += 1) {
|
|
197
196
|
var value = isObject(d[r][c]) ? (_a = d[r][c]) === null || _a === void 0 ? void 0 : _a.v : d[r][c];
|
|
198
197
|
if (value && String(value).startsWith("=")) {
|
|
199
198
|
var cell = {};
|
|
200
|
-
var
|
|
201
|
-
v =
|
|
202
|
-
f =
|
|
199
|
+
var _b = execfunction(ctx, String(value), r, c, undefined, undefined, true),
|
|
200
|
+
v = _b[1],
|
|
201
|
+
f = _b[2];
|
|
203
202
|
cell.v = v;
|
|
204
203
|
cell.f = f;
|
|
205
204
|
cell.m = v.toString();
|
|
206
205
|
x[c] = cell;
|
|
207
206
|
}
|
|
208
207
|
d[r] = x;
|
|
209
|
-
changes.push({
|
|
210
|
-
sheetId: ctx.currentSheetId,
|
|
211
|
-
path: ["celldata"],
|
|
212
|
-
value: {
|
|
213
|
-
r: r,
|
|
214
|
-
c: c,
|
|
215
|
-
v: d[r][c]
|
|
216
|
-
},
|
|
217
|
-
key: "".concat(r, "_").concat(c),
|
|
218
|
-
type: "update"
|
|
219
|
-
});
|
|
220
208
|
}
|
|
221
209
|
}
|
|
222
|
-
if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
|
|
223
|
-
(_c = ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc(changes);
|
|
224
|
-
}
|
|
225
210
|
};
|
|
226
211
|
function pasteHandler(ctx, data, borderInfo) {
|
|
227
212
|
var _a;
|
|
228
|
-
var _b, _c, _d, _e, _f, _g
|
|
213
|
+
var _b, _c, _d, _e, _f, _g;
|
|
229
214
|
if (ctx.luckysheet_selection_range) {
|
|
230
215
|
ctx.luckysheet_selection_range = [];
|
|
231
216
|
}
|
|
@@ -273,7 +258,6 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
273
258
|
}
|
|
274
259
|
var RowlChange = false;
|
|
275
260
|
var offsetMC = {};
|
|
276
|
-
var changes = [];
|
|
277
261
|
for (var h = minh; h <= maxh; h += 1) {
|
|
278
262
|
var x = d[h];
|
|
279
263
|
var currentRowLen = ctx.defaultrowlen;
|
|
@@ -321,26 +305,12 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
321
305
|
};
|
|
322
306
|
(_f = cfg.borderInfo) === null || _f === void 0 ? void 0 : _f.push(bd_obj);
|
|
323
307
|
}
|
|
324
|
-
changes.push({
|
|
325
|
-
sheetId: ctx.currentSheetId,
|
|
326
|
-
path: ["celldata"],
|
|
327
|
-
value: {
|
|
328
|
-
r: h,
|
|
329
|
-
c: c,
|
|
330
|
-
v: d[h][c]
|
|
331
|
-
},
|
|
332
|
-
key: "".concat(h, "_").concat(c),
|
|
333
|
-
type: "update"
|
|
334
|
-
});
|
|
335
308
|
}
|
|
336
309
|
d[h] = x;
|
|
337
310
|
if (currentRowLen !== ctx.defaultrowlen) {
|
|
338
311
|
cfg.rowlen[h] = currentRowLen;
|
|
339
312
|
}
|
|
340
313
|
}
|
|
341
|
-
if ((_g = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _g === void 0 ? void 0 : _g.updateCellYdoc) {
|
|
342
|
-
(_h = ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc(changes);
|
|
343
|
-
}
|
|
344
314
|
ctx.luckysheet_select_save = [{
|
|
345
315
|
row: [minh, maxh],
|
|
346
316
|
column: [minc, maxc]
|
|
@@ -365,7 +335,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
365
335
|
}
|
|
366
336
|
var d = getFlowdata(ctx);
|
|
367
337
|
if (!d) return;
|
|
368
|
-
var last = (
|
|
338
|
+
var last = (_g = ctx.luckysheet_select_save) === null || _g === void 0 ? void 0 : _g[ctx.luckysheet_select_save.length - 1];
|
|
369
339
|
if (!last) return;
|
|
370
340
|
var curR = last.row == null ? 0 : last.row[0];
|
|
371
341
|
var curC = last.column == null ? 0 : last.column[0];
|
|
@@ -390,7 +360,6 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
390
360
|
if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
|
|
391
361
|
return t.startsWith("http") ? t : "https://".concat(t);
|
|
392
362
|
};
|
|
393
|
-
var changes = [];
|
|
394
363
|
for (var r = 0; r < rlen; r += 1) {
|
|
395
364
|
var x = d[r + curR];
|
|
396
365
|
for (var c = 0; c < clen; c += 1) {
|
|
@@ -463,23 +432,9 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
463
432
|
}
|
|
464
433
|
x[c + curC] = cell;
|
|
465
434
|
}
|
|
466
|
-
changes.push(changes.push({
|
|
467
|
-
sheetId: ctx.currentSheetId,
|
|
468
|
-
path: ["celldata"],
|
|
469
|
-
value: {
|
|
470
|
-
r: r,
|
|
471
|
-
c: c,
|
|
472
|
-
v: d[r][c]
|
|
473
|
-
},
|
|
474
|
-
key: "".concat(r, "_").concat(c),
|
|
475
|
-
type: "update"
|
|
476
|
-
}));
|
|
477
435
|
}
|
|
478
436
|
d[r + curR] = x;
|
|
479
437
|
}
|
|
480
|
-
if ((_k = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _k === void 0 ? void 0 : _k.updateCellYdoc) {
|
|
481
|
-
(_l = ctx.hooks) === null || _l === void 0 ? void 0 : _l.updateCellYdoc(changes);
|
|
482
|
-
}
|
|
483
438
|
last.row = [curR, curR + rlen - 1];
|
|
484
439
|
last.column = [curC, curC + clen - 1];
|
|
485
440
|
jfrefreshgrid(ctx, null, undefined);
|
package/es/modules/cell.js
CHANGED
|
@@ -111,7 +111,6 @@ export function getCellValue(r, c, data, attr) {
|
|
|
111
111
|
}
|
|
112
112
|
export function setCellValue(ctx, r, c, d, v) {
|
|
113
113
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
114
|
-
console.log("setCellValue", r, c, v);
|
|
115
114
|
if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
|
|
116
115
|
if (_.isNil(d)) {
|
|
117
116
|
d = getFlowdata(ctx);
|
package/es/modules/hyperlink.js
CHANGED
|
@@ -39,7 +39,6 @@ export function getCellHyperlink(ctx, r, c) {
|
|
|
39
39
|
return undefined;
|
|
40
40
|
}
|
|
41
41
|
export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress) {
|
|
42
|
-
var _a, _b;
|
|
43
42
|
var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
44
43
|
var flowdata = getFlowdata(ctx);
|
|
45
44
|
if (sheetIndex != null && flowdata != null && linkType && linkAddress) {
|
|
@@ -60,19 +59,6 @@ export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress) {
|
|
|
60
59
|
};
|
|
61
60
|
flowdata[r][c] = cell;
|
|
62
61
|
ctx.linkCard = undefined;
|
|
63
|
-
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
|
|
64
|
-
(_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc([{
|
|
65
|
-
sheetId: ctx.currentSheetId,
|
|
66
|
-
path: ["celldata"],
|
|
67
|
-
value: {
|
|
68
|
-
r: r,
|
|
69
|
-
c: c,
|
|
70
|
-
v: cell
|
|
71
|
-
},
|
|
72
|
-
key: "".concat(r, "_").concat(c),
|
|
73
|
-
type: "update"
|
|
74
|
-
}]);
|
|
75
|
-
}
|
|
76
62
|
}
|
|
77
63
|
}
|
|
78
64
|
export function removeHyperlink(ctx, r, c) {
|
package/es/modules/selection.js
CHANGED
|
@@ -1496,7 +1496,7 @@ export function copy(ctx) {
|
|
|
1496
1496
|
}
|
|
1497
1497
|
}
|
|
1498
1498
|
export function deleteSelectedCellText(ctx) {
|
|
1499
|
-
var _a, _b, _c
|
|
1499
|
+
var _a, _b, _c;
|
|
1500
1500
|
var allowEdit = isAllowEdit(ctx);
|
|
1501
1501
|
if (allowEdit === false || ctx.isFlvReadOnly) {
|
|
1502
1502
|
return "allowEdit";
|
|
@@ -1525,7 +1525,6 @@ export function deleteSelectedCellText(ctx) {
|
|
|
1525
1525
|
var r2 = selection[s].row[1];
|
|
1526
1526
|
var c1 = selection[s].column[0];
|
|
1527
1527
|
var c2 = selection[s].column[1];
|
|
1528
|
-
var changes = [];
|
|
1529
1528
|
for (var r = r1; r <= r2; r += 1) {
|
|
1530
1529
|
for (var c = c1; c <= c2; c += 1) {
|
|
1531
1530
|
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
@@ -1554,18 +1553,6 @@ export function deleteSelectedCellText(ctx) {
|
|
|
1554
1553
|
if (hyperlinkMap && hyperlinkMap["".concat(r, "_").concat(c)]) {
|
|
1555
1554
|
delete hyperlinkMap["".concat(r, "_").concat(c)];
|
|
1556
1555
|
}
|
|
1557
|
-
if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.afterUpdateCell) {
|
|
1558
|
-
ctx.hooks.afterUpdateCell(r, c, null, d[r][c]);
|
|
1559
|
-
}
|
|
1560
|
-
changes.push({
|
|
1561
|
-
sheetId: ctx.currentSheetId,
|
|
1562
|
-
path: ["celldata"],
|
|
1563
|
-
value: {
|
|
1564
|
-
r: r,
|
|
1565
|
-
c: c,
|
|
1566
|
-
v: d[r][c]
|
|
1567
|
-
}
|
|
1568
|
-
});
|
|
1569
1556
|
}
|
|
1570
1557
|
}
|
|
1571
1558
|
}
|
package/es/modules/sheet.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
var __assign = this && this.__assign || function () {
|
|
2
|
-
__assign = Object.assign || function (t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
6
|
-
}
|
|
7
|
-
return t;
|
|
8
|
-
};
|
|
9
|
-
return __assign.apply(this, arguments);
|
|
10
|
-
};
|
|
11
1
|
import _ from "lodash";
|
|
12
2
|
import { v4 as uuidv4 } from "uuid";
|
|
13
3
|
import { initSheetData } from "../api/sheet";
|
|
@@ -29,7 +19,7 @@ export function storeSheetParamALL(ctx) {
|
|
|
29
19
|
ctx.luckysheetfile[index].config = ctx.config;
|
|
30
20
|
}
|
|
31
21
|
export function changeSheet(ctx, id, isPivotInitial, isNewSheet, isCopySheet) {
|
|
32
|
-
var _a, _b
|
|
22
|
+
var _a, _b;
|
|
33
23
|
if (id === ctx.currentSheetId) {
|
|
34
24
|
return;
|
|
35
25
|
}
|
|
@@ -45,11 +35,14 @@ export function changeSheet(ctx, id, isPivotInitial, isNewSheet, isCopySheet) {
|
|
|
45
35
|
ctx.luckysheetcurrentisPivotTable = false;
|
|
46
36
|
}
|
|
47
37
|
if (ctx.hooks.afterActivateSheet) {
|
|
48
|
-
(
|
|
38
|
+
setTimeout(function () {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
(_b = (_a = ctx.hooks).afterActivateSheet) === null || _b === void 0 ? void 0 : _b.call(_a, id);
|
|
41
|
+
});
|
|
49
42
|
}
|
|
50
43
|
}
|
|
51
44
|
export function addSheet(ctx, settings, newSheetID, isPivotTable, sheetName, sheetData) {
|
|
52
|
-
var _a, _b
|
|
45
|
+
var _a, _b;
|
|
53
46
|
if (newSheetID === void 0) {
|
|
54
47
|
newSheetID = undefined;
|
|
55
48
|
}
|
|
@@ -93,12 +86,18 @@ export function addSheet(ctx, settings, newSheetID, isPivotTable, sheetName, she
|
|
|
93
86
|
return;
|
|
94
87
|
}
|
|
95
88
|
ctx.luckysheetfile.push(sheetconfig);
|
|
89
|
+
if (!newSheetID) {
|
|
90
|
+
changeSheet(ctx, id, isPivotTable, true);
|
|
91
|
+
}
|
|
96
92
|
if (ctx.hooks.afterAddSheet) {
|
|
97
|
-
(
|
|
93
|
+
setTimeout(function () {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
(_b = (_a = ctx.hooks).afterAddSheet) === null || _b === void 0 ? void 0 : _b.call(_a, sheetconfig);
|
|
96
|
+
});
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
export function deleteSheet(ctx, id) {
|
|
101
|
-
var _a, _b, _c
|
|
100
|
+
var _a, _b, _c;
|
|
102
101
|
if (ctx.allowEdit === false) {
|
|
103
102
|
return;
|
|
104
103
|
}
|
|
@@ -124,7 +123,10 @@ export function deleteSheet(ctx, id) {
|
|
|
124
123
|
ctx.currentSheetId = (_c = orderSheets === null || orderSheets === void 0 ? void 0 : orderSheets[0]) === null || _c === void 0 ? void 0 : _c.id;
|
|
125
124
|
}
|
|
126
125
|
if (ctx.hooks.afterDeleteSheet) {
|
|
127
|
-
(
|
|
126
|
+
setTimeout(function () {
|
|
127
|
+
var _a, _b;
|
|
128
|
+
(_b = (_a = ctx.hooks).afterDeleteSheet) === null || _b === void 0 ? void 0 : _b.call(_a, id);
|
|
129
|
+
});
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
export function updateSheet(ctx, newData) {
|
package/es/modules/toolbar.js
CHANGED
|
@@ -15,14 +15,12 @@ import { showLinkCard } from "./hyperlink";
|
|
|
15
15
|
import { cfSplitRange } from "./conditionalFormat";
|
|
16
16
|
import { clearMeasureTextCache, getCellTextInfo } from "./text";
|
|
17
17
|
export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col_ed, canvas) {
|
|
18
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6
|
|
19
|
-
var
|
|
20
|
-
console.log("updateFormatCell", row_st, row_ed, col_st, col_ed);
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
|
|
19
|
+
var _7;
|
|
21
20
|
if (_.isNil(d) || _.isNil(attr)) {
|
|
22
21
|
return;
|
|
23
22
|
}
|
|
24
23
|
if (attr === "ct") {
|
|
25
|
-
var changes = [];
|
|
26
24
|
for (var r = row_st; r <= row_ed; r += 1) {
|
|
27
25
|
if (!_.isNil(ctx.config.rowhidden) && !_.isNil(ctx.config.rowhidden[r])) {
|
|
28
26
|
continue;
|
|
@@ -74,20 +72,6 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
74
72
|
m: mask
|
|
75
73
|
};
|
|
76
74
|
}
|
|
77
|
-
changes.push({
|
|
78
|
-
sheetId: ctx.currentSheetId,
|
|
79
|
-
path: ["celldata"],
|
|
80
|
-
value: {
|
|
81
|
-
r: r,
|
|
82
|
-
c: c,
|
|
83
|
-
v: d[r][c]
|
|
84
|
-
},
|
|
85
|
-
key: "".concat(r, "_").concat(c),
|
|
86
|
-
type: "update"
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
if ((_x = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _x === void 0 ? void 0 : _x.updateCellYdoc) {
|
|
90
|
-
(_y = ctx.hooks) === null || _y === void 0 ? void 0 : _y.updateCellYdoc(changes);
|
|
91
75
|
}
|
|
92
76
|
}
|
|
93
77
|
} else {
|
|
@@ -134,7 +118,6 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
134
118
|
if (sheetIndex == null) {
|
|
135
119
|
return;
|
|
136
120
|
}
|
|
137
|
-
var changes = [];
|
|
138
121
|
for (var r = row_st; r <= row_ed; r += 1) {
|
|
139
122
|
if (!_.isNil(ctx.config.rowhidden) && !_.isNil(ctx.config.rowhidden[r])) {
|
|
140
123
|
continue;
|
|
@@ -144,11 +127,11 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
144
127
|
if (value && _.isPlainObject(value)) {
|
|
145
128
|
updateInlineStringFormatOutside(value, attr, foucsStatus);
|
|
146
129
|
value[attr] = foucsStatus;
|
|
147
|
-
(
|
|
130
|
+
(_7 = ctx.luckysheetfile[sheetIndex]).config || (_7.config = {});
|
|
148
131
|
var cfg = ctx.luckysheetfile[sheetIndex].config;
|
|
149
|
-
var cellWidth = ((
|
|
132
|
+
var cellWidth = ((_x = cfg.columnlen) === null || _x === void 0 ? void 0 : _x[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
|
|
150
133
|
if (attr === "tb" && canvas && foucsStatus === "2") {
|
|
151
|
-
var currentColWidth_1 = ((
|
|
134
|
+
var currentColWidth_1 = ((_y = cfg.columnlen) === null || _y === void 0 ? void 0 : _y[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
|
|
152
135
|
var lineCount_1 = 1;
|
|
153
136
|
var fontString_1 = "10px Arial";
|
|
154
137
|
if (value.fs) {
|
|
@@ -161,9 +144,9 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
161
144
|
lineCount_1 = getLineCount(value.m, currentColWidth_1, fontString_1);
|
|
162
145
|
var hOffset = lineCount_1 < 4 ? 1.9 : 1.7;
|
|
163
146
|
lineCount_1 = lineCount_1 * hOffset + 1;
|
|
164
|
-
} else if ((
|
|
147
|
+
} else if ((_1 = (_0 = (_z = value === null || value === void 0 ? void 0 : value.ct) === null || _z === void 0 ? void 0 : _z.s) === null || _0 === void 0 ? void 0 : _0[0]) === null || _1 === void 0 ? void 0 : _1.v) {
|
|
165
148
|
lineCount_1 -= 1;
|
|
166
|
-
var line = (
|
|
149
|
+
var line = (_4 = (_3 = (_2 = value === null || value === void 0 ? void 0 : value.ct) === null || _2 === void 0 ? void 0 : _2.s) === null || _3 === void 0 ? void 0 : _3[0]) === null || _4 === void 0 ? void 0 : _4.v.split("\n");
|
|
167
150
|
line.forEach(function (item) {
|
|
168
151
|
var subLineCount = getLineCount(item, currentColWidth_1, fontString_1);
|
|
169
152
|
lineCount_1 += subLineCount;
|
|
@@ -183,7 +166,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
183
166
|
});
|
|
184
167
|
if (!textInfo) return "continue";
|
|
185
168
|
var rowHeight = _.round(textInfo.textHeightAll);
|
|
186
|
-
var currentRowHeight = ((
|
|
169
|
+
var currentRowHeight = ((_5 = cfg.rowlen) === null || _5 === void 0 ? void 0 : _5[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
|
|
187
170
|
if (!_.isUndefined(rowHeight) && rowHeight > currentRowHeight && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
|
|
188
171
|
if (_.isUndefined(cfg.rowlen)) cfg.rowlen = {};
|
|
189
172
|
_.set(cfg, "rowlen.".concat(r), rowHeight);
|
|
@@ -198,7 +181,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
198
181
|
});
|
|
199
182
|
if (!textInfo) return "continue";
|
|
200
183
|
var newHeight = _.round(textInfo.textHeightAll);
|
|
201
|
-
var oldHeight = ((
|
|
184
|
+
var oldHeight = ((_6 = cfg.rowlen) === null || _6 === void 0 ? void 0 : _6[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
|
|
202
185
|
var shouldResize = foucsStatus === "2" ? newHeight > oldHeight : true;
|
|
203
186
|
if (shouldResize && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
|
|
204
187
|
var padding = 12;
|
|
@@ -213,25 +196,11 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
213
196
|
};
|
|
214
197
|
d[r][c][attr] = foucsStatus;
|
|
215
198
|
}
|
|
216
|
-
changes.push({
|
|
217
|
-
sheetId: ctx.currentSheetId,
|
|
218
|
-
path: ["celldata"],
|
|
219
|
-
value: {
|
|
220
|
-
r: r,
|
|
221
|
-
c: c,
|
|
222
|
-
v: d[r][c]
|
|
223
|
-
},
|
|
224
|
-
key: "".concat(r, "_").concat(c),
|
|
225
|
-
type: "update"
|
|
226
|
-
});
|
|
227
199
|
};
|
|
228
200
|
for (var c = col_st; c <= col_ed; c += 1) {
|
|
229
201
|
_loop_1(c);
|
|
230
202
|
}
|
|
231
203
|
}
|
|
232
|
-
if ((_9 = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _9 === void 0 ? void 0 : _9.updateCellYdoc) {
|
|
233
|
-
(_10 = ctx.hooks) === null || _10 === void 0 ? void 0 : _10.updateCellYdoc(changes);
|
|
234
|
-
}
|
|
235
204
|
}
|
|
236
205
|
}
|
|
237
206
|
export function updateFormat(ctx, $input, d, attr, foucsStatus, canvas) {
|
package/es/settings.d.ts
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Sheet, Selection, CellMatrix, Cell } from "./types";
|
|
3
|
-
type SheetChangePath = {
|
|
4
|
-
sheetId: string;
|
|
5
|
-
path: string[];
|
|
6
|
-
key?: string;
|
|
7
|
-
value: any;
|
|
8
|
-
type?: "update" | "delete";
|
|
9
|
-
};
|
|
10
3
|
export type Hooks = {
|
|
11
|
-
calcChainChange?: () => void;
|
|
12
|
-
sheetLengthChange?: () => void;
|
|
13
|
-
dataVerificationChange?: () => void;
|
|
14
|
-
liveQueryChange?: () => void;
|
|
15
|
-
imageListChange?: () => void;
|
|
16
|
-
iframeListChange?: () => void;
|
|
17
|
-
conditionRulesChange?: () => void;
|
|
18
|
-
conditionFormatChange?: () => void;
|
|
19
|
-
cellDataChange?: () => void;
|
|
20
|
-
hyperlinkChange?: () => void;
|
|
21
|
-
updateCellYdoc?: (changes: SheetChangePath[]) => void;
|
|
22
4
|
beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
|
|
23
5
|
afterUpdateCell?: (row: number, column: number, oldValue: any, newValue: any) => void;
|
|
24
6
|
afterSelectionChange?: (sheetId: string, selection: Selection) => void;
|
package/lib/api/cell.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { CommonOptions } from "./common";
|
|
|
4
4
|
export declare function getCellValue(ctx: Context, row: number, column: number, options?: CommonOptions & {
|
|
5
5
|
type?: keyof Cell;
|
|
6
6
|
}): any;
|
|
7
|
-
export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions
|
|
7
|
+
export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions): void;
|
|
8
8
|
export declare function clearCell(ctx: Context, row: number, column: number, options?: CommonOptions): void;
|
|
9
9
|
export declare function setCellFormat(ctx: Context, row: number, column: number, attr: keyof Cell, value: any, options?: CommonOptions): void;
|
|
10
10
|
export declare function autoFillCell(ctx: Context, copyRange: SingleRange, applyRange: SingleRange, direction: "up" | "down" | "left" | "right"): void;
|
package/lib/api/cell.js
CHANGED
|
@@ -61,8 +61,8 @@ function getCellValue(ctx, row, column, options) {
|
|
|
61
61
|
}
|
|
62
62
|
return ret;
|
|
63
63
|
}
|
|
64
|
-
function setCellValue(ctx, row, column, value, cellInput, options
|
|
65
|
-
var _a
|
|
64
|
+
function setCellValue(ctx, row, column, value, cellInput, options) {
|
|
65
|
+
var _a;
|
|
66
66
|
if (options === void 0) {
|
|
67
67
|
options = {};
|
|
68
68
|
}
|
|
@@ -138,9 +138,6 @@ function setCellValue(ctx, row, column, value, cellInput, options, callAfterUpda
|
|
|
138
138
|
(0, _modules.setCellValue)(ctx, row, column, data, value);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
if (callAfterUpdate && ctx.hooks.afterUpdateCell) {
|
|
142
|
-
(_c = (_b = ctx.hooks).afterUpdateCell) === null || _c === void 0 ? void 0 : _c.call(_b, row, column, null, value);
|
|
143
|
-
}
|
|
144
141
|
}
|
|
145
142
|
function clearCell(ctx, row, column, options) {
|
|
146
143
|
var _a, _b;
|
package/lib/api/range.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ export declare function getSelectionCoordinates(ctx: Context): string[];
|
|
|
18
18
|
export declare function getCellsByRange(ctx: Context, range: Selection, options?: CommonOptions): (Cell | null)[][];
|
|
19
19
|
export declare function getHtmlByRange(ctx: Context, range: Range, options?: CommonOptions): string | null;
|
|
20
20
|
export declare function setSelection(ctx: Context, range: Range, options: CommonOptions): void;
|
|
21
|
-
export declare function setCellValuesByRange(ctx: Context, data: any[][], range: SingleRange, cellInput: HTMLDivElement | null, options?: CommonOptions
|
|
21
|
+
export declare function setCellValuesByRange(ctx: Context, data: any[][], range: SingleRange, cellInput: HTMLDivElement | null, options?: CommonOptions): void;
|
|
22
22
|
export declare function setCellFormatByRange(ctx: Context, attr: keyof Cell, value: any, range: Range | SingleRange, options?: CommonOptions): void;
|
package/lib/api/range.js
CHANGED
|
@@ -92,7 +92,7 @@ function setSelection(ctx, range, options) {
|
|
|
92
92
|
ctx.luckysheet_select_save = sheet.luckysheet_select_save;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
function setCellValuesByRange(ctx, data, range, cellInput, options
|
|
95
|
+
function setCellValuesByRange(ctx, data, range, cellInput, options) {
|
|
96
96
|
if (options === void 0) {
|
|
97
97
|
options = {};
|
|
98
98
|
}
|
|
@@ -114,7 +114,7 @@ function setCellValuesByRange(ctx, data, range, cellInput, options, callAfterUpd
|
|
|
114
114
|
for (var j = 0; j < columnCount; j += 1) {
|
|
115
115
|
var row = range.row[0] + i;
|
|
116
116
|
var column = range.column[0] + j;
|
|
117
|
-
(0, _cell.setCellValue)(ctx, row, column, data[i][j], cellInput, options
|
|
117
|
+
(0, _cell.setCellValue)(ctx, row, column, data[i][j], cellInput, options);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
package/lib/events/keyboard.js
CHANGED
|
@@ -476,7 +476,6 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
|
|
|
476
476
|
} else if (kstr === "Escape") {
|
|
477
477
|
ctx.contextMenu = {};
|
|
478
478
|
} else if (kstr === "Delete" || kstr === "Backspace") {
|
|
479
|
-
console.log("Delete");
|
|
480
479
|
if (!allowEdit) return [2];
|
|
481
480
|
if (ctx.activeImg != null) {
|
|
482
481
|
(0, _2.removeActiveImage)(ctx);
|
package/lib/events/paste.js
CHANGED
|
@@ -202,43 +202,28 @@ function postPasteCut(ctx, source, target, RowlChange) {
|
|
|
202
202
|
(0, _sheet.storeSheetParamALL)(ctx);
|
|
203
203
|
}
|
|
204
204
|
var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
|
|
205
|
-
var _a
|
|
206
|
-
var changes = [];
|
|
205
|
+
var _a;
|
|
207
206
|
for (var r = 0; r < d.length; r += 1) {
|
|
208
207
|
var x = d[r];
|
|
209
208
|
for (var c = 0; c < d[0].length; c += 1) {
|
|
210
209
|
var value = (0, _lodash.isObject)(d[r][c]) ? (_a = d[r][c]) === null || _a === void 0 ? void 0 : _a.v : d[r][c];
|
|
211
210
|
if (value && String(value).startsWith("=")) {
|
|
212
211
|
var cell = {};
|
|
213
|
-
var
|
|
214
|
-
v =
|
|
215
|
-
f =
|
|
212
|
+
var _b = (0, _formula.execfunction)(ctx, String(value), r, c, undefined, undefined, true),
|
|
213
|
+
v = _b[1],
|
|
214
|
+
f = _b[2];
|
|
216
215
|
cell.v = v;
|
|
217
216
|
cell.f = f;
|
|
218
217
|
cell.m = v.toString();
|
|
219
218
|
x[c] = cell;
|
|
220
219
|
}
|
|
221
220
|
d[r] = x;
|
|
222
|
-
changes.push({
|
|
223
|
-
sheetId: ctx.currentSheetId,
|
|
224
|
-
path: ["celldata"],
|
|
225
|
-
value: {
|
|
226
|
-
r: r,
|
|
227
|
-
c: c,
|
|
228
|
-
v: d[r][c]
|
|
229
|
-
},
|
|
230
|
-
key: "".concat(r, "_").concat(c),
|
|
231
|
-
type: "update"
|
|
232
|
-
});
|
|
233
221
|
}
|
|
234
222
|
}
|
|
235
|
-
if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
|
|
236
|
-
(_c = ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc(changes);
|
|
237
|
-
}
|
|
238
223
|
};
|
|
239
224
|
function pasteHandler(ctx, data, borderInfo) {
|
|
240
225
|
var _a;
|
|
241
|
-
var _b, _c, _d, _e, _f, _g
|
|
226
|
+
var _b, _c, _d, _e, _f, _g;
|
|
242
227
|
if (ctx.luckysheet_selection_range) {
|
|
243
228
|
ctx.luckysheet_selection_range = [];
|
|
244
229
|
}
|
|
@@ -286,7 +271,6 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
286
271
|
}
|
|
287
272
|
var RowlChange = false;
|
|
288
273
|
var offsetMC = {};
|
|
289
|
-
var changes = [];
|
|
290
274
|
for (var h = minh; h <= maxh; h += 1) {
|
|
291
275
|
var x = d[h];
|
|
292
276
|
var currentRowLen = ctx.defaultrowlen;
|
|
@@ -334,26 +318,12 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
334
318
|
};
|
|
335
319
|
(_f = cfg.borderInfo) === null || _f === void 0 ? void 0 : _f.push(bd_obj);
|
|
336
320
|
}
|
|
337
|
-
changes.push({
|
|
338
|
-
sheetId: ctx.currentSheetId,
|
|
339
|
-
path: ["celldata"],
|
|
340
|
-
value: {
|
|
341
|
-
r: h,
|
|
342
|
-
c: c,
|
|
343
|
-
v: d[h][c]
|
|
344
|
-
},
|
|
345
|
-
key: "".concat(h, "_").concat(c),
|
|
346
|
-
type: "update"
|
|
347
|
-
});
|
|
348
321
|
}
|
|
349
322
|
d[h] = x;
|
|
350
323
|
if (currentRowLen !== ctx.defaultrowlen) {
|
|
351
324
|
cfg.rowlen[h] = currentRowLen;
|
|
352
325
|
}
|
|
353
326
|
}
|
|
354
|
-
if ((_g = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _g === void 0 ? void 0 : _g.updateCellYdoc) {
|
|
355
|
-
(_h = ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc(changes);
|
|
356
|
-
}
|
|
357
327
|
ctx.luckysheet_select_save = [{
|
|
358
328
|
row: [minh, maxh],
|
|
359
329
|
column: [minc, maxc]
|
|
@@ -378,7 +348,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
378
348
|
}
|
|
379
349
|
var d = (0, _context.getFlowdata)(ctx);
|
|
380
350
|
if (!d) return;
|
|
381
|
-
var last = (
|
|
351
|
+
var last = (_g = ctx.luckysheet_select_save) === null || _g === void 0 ? void 0 : _g[ctx.luckysheet_select_save.length - 1];
|
|
382
352
|
if (!last) return;
|
|
383
353
|
var curR = last.row == null ? 0 : last.row[0];
|
|
384
354
|
var curC = last.column == null ? 0 : last.column[0];
|
|
@@ -403,7 +373,6 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
403
373
|
if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
|
|
404
374
|
return t.startsWith("http") ? t : "https://".concat(t);
|
|
405
375
|
};
|
|
406
|
-
var changes = [];
|
|
407
376
|
for (var r = 0; r < rlen; r += 1) {
|
|
408
377
|
var x = d[r + curR];
|
|
409
378
|
for (var c = 0; c < clen; c += 1) {
|
|
@@ -476,23 +445,9 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
476
445
|
}
|
|
477
446
|
x[c + curC] = cell;
|
|
478
447
|
}
|
|
479
|
-
changes.push(changes.push({
|
|
480
|
-
sheetId: ctx.currentSheetId,
|
|
481
|
-
path: ["celldata"],
|
|
482
|
-
value: {
|
|
483
|
-
r: r,
|
|
484
|
-
c: c,
|
|
485
|
-
v: d[r][c]
|
|
486
|
-
},
|
|
487
|
-
key: "".concat(r, "_").concat(c),
|
|
488
|
-
type: "update"
|
|
489
|
-
}));
|
|
490
448
|
}
|
|
491
449
|
d[r + curR] = x;
|
|
492
450
|
}
|
|
493
|
-
if ((_k = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _k === void 0 ? void 0 : _k.updateCellYdoc) {
|
|
494
|
-
(_l = ctx.hooks) === null || _l === void 0 ? void 0 : _l.updateCellYdoc(changes);
|
|
495
|
-
}
|
|
496
451
|
last.row = [curR, curR + rlen - 1];
|
|
497
452
|
last.column = [curC, curC + clen - 1];
|
|
498
453
|
(0, _refresh.jfrefreshgrid)(ctx, null, undefined);
|
package/lib/modules/cell.js
CHANGED
|
@@ -144,7 +144,6 @@ function getCellValue(r, c, data, attr) {
|
|
|
144
144
|
}
|
|
145
145
|
function setCellValue(ctx, r, c, d, v) {
|
|
146
146
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
147
|
-
console.log("setCellValue", r, c, v);
|
|
148
147
|
if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
|
|
149
148
|
if (_lodash.default.isNil(d)) {
|
|
150
149
|
d = (0, _context.getFlowdata)(ctx);
|
package/lib/modules/hyperlink.js
CHANGED
|
@@ -55,7 +55,6 @@ function getCellHyperlink(ctx, r, c) {
|
|
|
55
55
|
return undefined;
|
|
56
56
|
}
|
|
57
57
|
function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress) {
|
|
58
|
-
var _a, _b;
|
|
59
58
|
var sheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
60
59
|
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
61
60
|
if (sheetIndex != null && flowdata != null && linkType && linkAddress) {
|
|
@@ -76,19 +75,6 @@ function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress) {
|
|
|
76
75
|
};
|
|
77
76
|
flowdata[r][c] = cell;
|
|
78
77
|
ctx.linkCard = undefined;
|
|
79
|
-
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
|
|
80
|
-
(_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc([{
|
|
81
|
-
sheetId: ctx.currentSheetId,
|
|
82
|
-
path: ["celldata"],
|
|
83
|
-
value: {
|
|
84
|
-
r: r,
|
|
85
|
-
c: c,
|
|
86
|
-
v: cell
|
|
87
|
-
},
|
|
88
|
-
key: "".concat(r, "_").concat(c),
|
|
89
|
-
type: "update"
|
|
90
|
-
}]);
|
|
91
|
-
}
|
|
92
78
|
}
|
|
93
79
|
}
|
|
94
80
|
function removeHyperlink(ctx, r, c) {
|
package/lib/modules/selection.js
CHANGED
|
@@ -1531,7 +1531,7 @@ function copy(ctx) {
|
|
|
1531
1531
|
}
|
|
1532
1532
|
}
|
|
1533
1533
|
function deleteSelectedCellText(ctx) {
|
|
1534
|
-
var _a, _b, _c
|
|
1534
|
+
var _a, _b, _c;
|
|
1535
1535
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
1536
1536
|
if (allowEdit === false || ctx.isFlvReadOnly) {
|
|
1537
1537
|
return "allowEdit";
|
|
@@ -1560,7 +1560,6 @@ function deleteSelectedCellText(ctx) {
|
|
|
1560
1560
|
var r2 = selection[s].row[1];
|
|
1561
1561
|
var c1 = selection[s].column[0];
|
|
1562
1562
|
var c2 = selection[s].column[1];
|
|
1563
|
-
var changes = [];
|
|
1564
1563
|
for (var r = r1; r <= r2; r += 1) {
|
|
1565
1564
|
for (var c = c1; c <= c2; c += 1) {
|
|
1566
1565
|
var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
@@ -1589,18 +1588,6 @@ function deleteSelectedCellText(ctx) {
|
|
|
1589
1588
|
if (hyperlinkMap && hyperlinkMap["".concat(r, "_").concat(c)]) {
|
|
1590
1589
|
delete hyperlinkMap["".concat(r, "_").concat(c)];
|
|
1591
1590
|
}
|
|
1592
|
-
if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.afterUpdateCell) {
|
|
1593
|
-
ctx.hooks.afterUpdateCell(r, c, null, d[r][c]);
|
|
1594
|
-
}
|
|
1595
|
-
changes.push({
|
|
1596
|
-
sheetId: ctx.currentSheetId,
|
|
1597
|
-
path: ["celldata"],
|
|
1598
|
-
value: {
|
|
1599
|
-
r: r,
|
|
1600
|
-
c: c,
|
|
1601
|
-
v: d[r][c]
|
|
1602
|
-
}
|
|
1603
|
-
});
|
|
1604
1591
|
}
|
|
1605
1592
|
}
|
|
1606
1593
|
}
|
package/lib/modules/sheet.js
CHANGED
|
@@ -16,16 +16,6 @@ var _sheet = require("../api/sheet");
|
|
|
16
16
|
var _locale = require("../locale");
|
|
17
17
|
var _utils = require("../utils");
|
|
18
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
-
var __assign = void 0 && (void 0).__assign || function () {
|
|
20
|
-
__assign = Object.assign || function (t) {
|
|
21
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
22
|
-
s = arguments[i];
|
|
23
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
24
|
-
}
|
|
25
|
-
return t;
|
|
26
|
-
};
|
|
27
|
-
return __assign.apply(this, arguments);
|
|
28
|
-
};
|
|
29
19
|
function storeSheetParam(ctx) {
|
|
30
20
|
var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
31
21
|
if (index == null) return;
|
|
@@ -42,7 +32,7 @@ function storeSheetParamALL(ctx) {
|
|
|
42
32
|
ctx.luckysheetfile[index].config = ctx.config;
|
|
43
33
|
}
|
|
44
34
|
function changeSheet(ctx, id, isPivotInitial, isNewSheet, isCopySheet) {
|
|
45
|
-
var _a, _b
|
|
35
|
+
var _a, _b;
|
|
46
36
|
if (id === ctx.currentSheetId) {
|
|
47
37
|
return;
|
|
48
38
|
}
|
|
@@ -58,11 +48,14 @@ function changeSheet(ctx, id, isPivotInitial, isNewSheet, isCopySheet) {
|
|
|
58
48
|
ctx.luckysheetcurrentisPivotTable = false;
|
|
59
49
|
}
|
|
60
50
|
if (ctx.hooks.afterActivateSheet) {
|
|
61
|
-
(
|
|
51
|
+
setTimeout(function () {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
(_b = (_a = ctx.hooks).afterActivateSheet) === null || _b === void 0 ? void 0 : _b.call(_a, id);
|
|
54
|
+
});
|
|
62
55
|
}
|
|
63
56
|
}
|
|
64
57
|
function addSheet(ctx, settings, newSheetID, isPivotTable, sheetName, sheetData) {
|
|
65
|
-
var _a, _b
|
|
58
|
+
var _a, _b;
|
|
66
59
|
if (newSheetID === void 0) {
|
|
67
60
|
newSheetID = undefined;
|
|
68
61
|
}
|
|
@@ -106,12 +99,18 @@ function addSheet(ctx, settings, newSheetID, isPivotTable, sheetName, sheetData)
|
|
|
106
99
|
return;
|
|
107
100
|
}
|
|
108
101
|
ctx.luckysheetfile.push(sheetconfig);
|
|
102
|
+
if (!newSheetID) {
|
|
103
|
+
changeSheet(ctx, id, isPivotTable, true);
|
|
104
|
+
}
|
|
109
105
|
if (ctx.hooks.afterAddSheet) {
|
|
110
|
-
(
|
|
106
|
+
setTimeout(function () {
|
|
107
|
+
var _a, _b;
|
|
108
|
+
(_b = (_a = ctx.hooks).afterAddSheet) === null || _b === void 0 ? void 0 : _b.call(_a, sheetconfig);
|
|
109
|
+
});
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
function deleteSheet(ctx, id) {
|
|
114
|
-
var _a, _b, _c
|
|
113
|
+
var _a, _b, _c;
|
|
115
114
|
if (ctx.allowEdit === false) {
|
|
116
115
|
return;
|
|
117
116
|
}
|
|
@@ -137,7 +136,10 @@ function deleteSheet(ctx, id) {
|
|
|
137
136
|
ctx.currentSheetId = (_c = orderSheets === null || orderSheets === void 0 ? void 0 : orderSheets[0]) === null || _c === void 0 ? void 0 : _c.id;
|
|
138
137
|
}
|
|
139
138
|
if (ctx.hooks.afterDeleteSheet) {
|
|
140
|
-
(
|
|
139
|
+
setTimeout(function () {
|
|
140
|
+
var _a, _b;
|
|
141
|
+
(_b = (_a = ctx.hooks).afterDeleteSheet) === null || _b === void 0 ? void 0 : _b.call(_a, id);
|
|
142
|
+
});
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
145
|
function updateSheet(ctx, newData) {
|
package/lib/modules/toolbar.js
CHANGED
|
@@ -48,14 +48,12 @@ var _conditionalFormat = require("./conditionalFormat");
|
|
|
48
48
|
var _text = require("./text");
|
|
49
49
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
50
50
|
function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col_ed, canvas) {
|
|
51
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6
|
|
52
|
-
var
|
|
53
|
-
console.log("updateFormatCell", row_st, row_ed, col_st, col_ed);
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
|
|
52
|
+
var _7;
|
|
54
53
|
if (_lodash.default.isNil(d) || _lodash.default.isNil(attr)) {
|
|
55
54
|
return;
|
|
56
55
|
}
|
|
57
56
|
if (attr === "ct") {
|
|
58
|
-
var changes = [];
|
|
59
57
|
for (var r = row_st; r <= row_ed; r += 1) {
|
|
60
58
|
if (!_lodash.default.isNil(ctx.config.rowhidden) && !_lodash.default.isNil(ctx.config.rowhidden[r])) {
|
|
61
59
|
continue;
|
|
@@ -107,20 +105,6 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
107
105
|
m: mask
|
|
108
106
|
};
|
|
109
107
|
}
|
|
110
|
-
changes.push({
|
|
111
|
-
sheetId: ctx.currentSheetId,
|
|
112
|
-
path: ["celldata"],
|
|
113
|
-
value: {
|
|
114
|
-
r: r,
|
|
115
|
-
c: c,
|
|
116
|
-
v: d[r][c]
|
|
117
|
-
},
|
|
118
|
-
key: "".concat(r, "_").concat(c),
|
|
119
|
-
type: "update"
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
if ((_x = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _x === void 0 ? void 0 : _x.updateCellYdoc) {
|
|
123
|
-
(_y = ctx.hooks) === null || _y === void 0 ? void 0 : _y.updateCellYdoc(changes);
|
|
124
108
|
}
|
|
125
109
|
}
|
|
126
110
|
} else {
|
|
@@ -167,7 +151,6 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
167
151
|
if (sheetIndex == null) {
|
|
168
152
|
return;
|
|
169
153
|
}
|
|
170
|
-
var changes = [];
|
|
171
154
|
for (var r = row_st; r <= row_ed; r += 1) {
|
|
172
155
|
if (!_lodash.default.isNil(ctx.config.rowhidden) && !_lodash.default.isNil(ctx.config.rowhidden[r])) {
|
|
173
156
|
continue;
|
|
@@ -177,11 +160,11 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
177
160
|
if (value && _lodash.default.isPlainObject(value)) {
|
|
178
161
|
(0, _inlineString.updateInlineStringFormatOutside)(value, attr, foucsStatus);
|
|
179
162
|
value[attr] = foucsStatus;
|
|
180
|
-
(
|
|
163
|
+
(_7 = ctx.luckysheetfile[sheetIndex]).config || (_7.config = {});
|
|
181
164
|
var cfg = ctx.luckysheetfile[sheetIndex].config;
|
|
182
|
-
var cellWidth = ((
|
|
165
|
+
var cellWidth = ((_x = cfg.columnlen) === null || _x === void 0 ? void 0 : _x[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
|
|
183
166
|
if (attr === "tb" && canvas && foucsStatus === "2") {
|
|
184
|
-
var currentColWidth_1 = ((
|
|
167
|
+
var currentColWidth_1 = ((_y = cfg.columnlen) === null || _y === void 0 ? void 0 : _y[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
|
|
185
168
|
var lineCount_1 = 1;
|
|
186
169
|
var fontString_1 = "10px Arial";
|
|
187
170
|
if (value.fs) {
|
|
@@ -194,9 +177,9 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
194
177
|
lineCount_1 = (0, _utils.getLineCount)(value.m, currentColWidth_1, fontString_1);
|
|
195
178
|
var hOffset = lineCount_1 < 4 ? 1.9 : 1.7;
|
|
196
179
|
lineCount_1 = lineCount_1 * hOffset + 1;
|
|
197
|
-
} else if ((
|
|
180
|
+
} else if ((_1 = (_0 = (_z = value === null || value === void 0 ? void 0 : value.ct) === null || _z === void 0 ? void 0 : _z.s) === null || _0 === void 0 ? void 0 : _0[0]) === null || _1 === void 0 ? void 0 : _1.v) {
|
|
198
181
|
lineCount_1 -= 1;
|
|
199
|
-
var line = (
|
|
182
|
+
var line = (_4 = (_3 = (_2 = value === null || value === void 0 ? void 0 : value.ct) === null || _2 === void 0 ? void 0 : _2.s) === null || _3 === void 0 ? void 0 : _3[0]) === null || _4 === void 0 ? void 0 : _4.v.split("\n");
|
|
200
183
|
line.forEach(function (item) {
|
|
201
184
|
var subLineCount = (0, _utils.getLineCount)(item, currentColWidth_1, fontString_1);
|
|
202
185
|
lineCount_1 += subLineCount;
|
|
@@ -216,7 +199,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
216
199
|
});
|
|
217
200
|
if (!textInfo) return "continue";
|
|
218
201
|
var rowHeight = _lodash.default.round(textInfo.textHeightAll);
|
|
219
|
-
var currentRowHeight = ((
|
|
202
|
+
var currentRowHeight = ((_5 = cfg.rowlen) === null || _5 === void 0 ? void 0 : _5[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
|
|
220
203
|
if (!_lodash.default.isUndefined(rowHeight) && rowHeight > currentRowHeight && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
|
|
221
204
|
if (_lodash.default.isUndefined(cfg.rowlen)) cfg.rowlen = {};
|
|
222
205
|
_lodash.default.set(cfg, "rowlen.".concat(r), rowHeight);
|
|
@@ -231,7 +214,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
231
214
|
});
|
|
232
215
|
if (!textInfo) return "continue";
|
|
233
216
|
var newHeight = _lodash.default.round(textInfo.textHeightAll);
|
|
234
|
-
var oldHeight = ((
|
|
217
|
+
var oldHeight = ((_6 = cfg.rowlen) === null || _6 === void 0 ? void 0 : _6[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
|
|
235
218
|
var shouldResize = foucsStatus === "2" ? newHeight > oldHeight : true;
|
|
236
219
|
if (shouldResize && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
|
|
237
220
|
var padding = 12;
|
|
@@ -246,25 +229,11 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
246
229
|
};
|
|
247
230
|
d[r][c][attr] = foucsStatus;
|
|
248
231
|
}
|
|
249
|
-
changes.push({
|
|
250
|
-
sheetId: ctx.currentSheetId,
|
|
251
|
-
path: ["celldata"],
|
|
252
|
-
value: {
|
|
253
|
-
r: r,
|
|
254
|
-
c: c,
|
|
255
|
-
v: d[r][c]
|
|
256
|
-
},
|
|
257
|
-
key: "".concat(r, "_").concat(c),
|
|
258
|
-
type: "update"
|
|
259
|
-
});
|
|
260
232
|
};
|
|
261
233
|
for (var c = col_st; c <= col_ed; c += 1) {
|
|
262
234
|
_loop_1(c);
|
|
263
235
|
}
|
|
264
236
|
}
|
|
265
|
-
if ((_9 = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _9 === void 0 ? void 0 : _9.updateCellYdoc) {
|
|
266
|
-
(_10 = ctx.hooks) === null || _10 === void 0 ? void 0 : _10.updateCellYdoc(changes);
|
|
267
|
-
}
|
|
268
237
|
}
|
|
269
238
|
}
|
|
270
239
|
function updateFormat(ctx, $input, d, attr, foucsStatus, canvas) {
|
package/lib/settings.d.ts
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Sheet, Selection, CellMatrix, Cell } from "./types";
|
|
3
|
-
type SheetChangePath = {
|
|
4
|
-
sheetId: string;
|
|
5
|
-
path: string[];
|
|
6
|
-
key?: string;
|
|
7
|
-
value: any;
|
|
8
|
-
type?: "update" | "delete";
|
|
9
|
-
};
|
|
10
3
|
export type Hooks = {
|
|
11
|
-
calcChainChange?: () => void;
|
|
12
|
-
sheetLengthChange?: () => void;
|
|
13
|
-
dataVerificationChange?: () => void;
|
|
14
|
-
liveQueryChange?: () => void;
|
|
15
|
-
imageListChange?: () => void;
|
|
16
|
-
iframeListChange?: () => void;
|
|
17
|
-
conditionRulesChange?: () => void;
|
|
18
|
-
conditionFormatChange?: () => void;
|
|
19
|
-
cellDataChange?: () => void;
|
|
20
|
-
hyperlinkChange?: () => void;
|
|
21
|
-
updateCellYdoc?: (changes: SheetChangePath[]) => void;
|
|
22
4
|
beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
|
|
23
5
|
afterUpdateCell?: (row: number, column: number, oldValue: any, newValue: any) => void;
|
|
24
6
|
afterSelectionChange?: (sheetId: string, selection: Selection) => void;
|