@fileverse-dev/fortune-core 1.2.90-ydoc-10 → 1.2.90-ydoc-12
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/events/paste.js +51 -6
- package/es/modules/selection.js +14 -1
- package/es/modules/toolbar.js +36 -9
- package/es/settings.d.ts +9 -0
- package/lib/events/paste.js +51 -6
- package/lib/modules/selection.js +14 -1
- package/lib/modules/toolbar.js +36 -9
- package/lib/settings.d.ts +9 -0
- package/package.json +1 -1
package/es/events/paste.js
CHANGED
|
@@ -189,28 +189,43 @@ function postPasteCut(ctx, source, target, RowlChange) {
|
|
|
189
189
|
storeSheetParamALL(ctx);
|
|
190
190
|
}
|
|
191
191
|
var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
|
|
192
|
-
var _a;
|
|
192
|
+
var _a, _b, _c;
|
|
193
|
+
var changes = [];
|
|
193
194
|
for (var r = 0; r < d.length; r += 1) {
|
|
194
195
|
var x = d[r];
|
|
195
196
|
for (var c = 0; c < d[0].length; c += 1) {
|
|
196
197
|
var value = isObject(d[r][c]) ? (_a = d[r][c]) === null || _a === void 0 ? void 0 : _a.v : d[r][c];
|
|
197
198
|
if (value && String(value).startsWith("=")) {
|
|
198
199
|
var cell = {};
|
|
199
|
-
var
|
|
200
|
-
v =
|
|
201
|
-
f =
|
|
200
|
+
var _d = execfunction(ctx, String(value), r, c, undefined, undefined, true),
|
|
201
|
+
v = _d[1],
|
|
202
|
+
f = _d[2];
|
|
202
203
|
cell.v = v;
|
|
203
204
|
cell.f = f;
|
|
204
205
|
cell.m = v.toString();
|
|
205
206
|
x[c] = cell;
|
|
206
207
|
}
|
|
207
208
|
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: r + '_' + c,
|
|
218
|
+
type: 'update'
|
|
219
|
+
});
|
|
208
220
|
}
|
|
209
221
|
}
|
|
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
|
+
}
|
|
210
225
|
};
|
|
211
226
|
function pasteHandler(ctx, data, borderInfo) {
|
|
212
227
|
var _a;
|
|
213
|
-
var _b, _c, _d, _e, _f, _g;
|
|
228
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
214
229
|
if (ctx.luckysheet_selection_range) {
|
|
215
230
|
ctx.luckysheet_selection_range = [];
|
|
216
231
|
}
|
|
@@ -258,6 +273,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
258
273
|
}
|
|
259
274
|
var RowlChange = false;
|
|
260
275
|
var offsetMC = {};
|
|
276
|
+
var changes = [];
|
|
261
277
|
for (var h = minh; h <= maxh; h += 1) {
|
|
262
278
|
var x = d[h];
|
|
263
279
|
var currentRowLen = ctx.defaultrowlen;
|
|
@@ -305,12 +321,26 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
305
321
|
};
|
|
306
322
|
(_f = cfg.borderInfo) === null || _f === void 0 ? void 0 : _f.push(bd_obj);
|
|
307
323
|
}
|
|
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: h + '_' + c,
|
|
333
|
+
type: 'update'
|
|
334
|
+
});
|
|
308
335
|
}
|
|
309
336
|
d[h] = x;
|
|
310
337
|
if (currentRowLen !== ctx.defaultrowlen) {
|
|
311
338
|
cfg.rowlen[h] = currentRowLen;
|
|
312
339
|
}
|
|
313
340
|
}
|
|
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
|
+
}
|
|
314
344
|
ctx.luckysheet_select_save = [{
|
|
315
345
|
row: [minh, maxh],
|
|
316
346
|
column: [minc, maxc]
|
|
@@ -335,7 +365,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
335
365
|
}
|
|
336
366
|
var d = getFlowdata(ctx);
|
|
337
367
|
if (!d) return;
|
|
338
|
-
var last = (
|
|
368
|
+
var last = (_j = ctx.luckysheet_select_save) === null || _j === void 0 ? void 0 : _j[ctx.luckysheet_select_save.length - 1];
|
|
339
369
|
if (!last) return;
|
|
340
370
|
var curR = last.row == null ? 0 : last.row[0];
|
|
341
371
|
var curC = last.column == null ? 0 : last.column[0];
|
|
@@ -360,6 +390,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
360
390
|
if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
|
|
361
391
|
return t.startsWith("http") ? t : "https://".concat(t);
|
|
362
392
|
};
|
|
393
|
+
var changes = [];
|
|
363
394
|
for (var r = 0; r < rlen; r += 1) {
|
|
364
395
|
var x = d[r + curR];
|
|
365
396
|
for (var c = 0; c < clen; c += 1) {
|
|
@@ -432,9 +463,23 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
432
463
|
}
|
|
433
464
|
x[c + curC] = cell;
|
|
434
465
|
}
|
|
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: r + '_' + c,
|
|
475
|
+
type: 'update'
|
|
476
|
+
}));
|
|
435
477
|
}
|
|
436
478
|
d[r + curR] = x;
|
|
437
479
|
}
|
|
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
|
+
}
|
|
438
483
|
last.row = [curR, curR + rlen - 1];
|
|
439
484
|
last.column = [curC, curC + clen - 1];
|
|
440
485
|
jfrefreshgrid(ctx, null, undefined);
|
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, _d;
|
|
1500
1500
|
var allowEdit = isAllowEdit(ctx);
|
|
1501
1501
|
if (allowEdit === false || ctx.isFlvReadOnly) {
|
|
1502
1502
|
return "allowEdit";
|
|
@@ -1525,6 +1525,7 @@ 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 = [];
|
|
1528
1529
|
for (var r = r1; r <= r2; r += 1) {
|
|
1529
1530
|
for (var c = c1; c <= c2; c += 1) {
|
|
1530
1531
|
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
@@ -1553,6 +1554,18 @@ export function deleteSelectedCellText(ctx) {
|
|
|
1553
1554
|
if (hyperlinkMap && hyperlinkMap["".concat(r, "_").concat(c)]) {
|
|
1554
1555
|
delete hyperlinkMap["".concat(r, "_").concat(c)];
|
|
1555
1556
|
}
|
|
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
|
+
});
|
|
1556
1569
|
}
|
|
1557
1570
|
}
|
|
1558
1571
|
}
|
package/es/modules/toolbar.js
CHANGED
|
@@ -15,12 +15,14 @@ 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
|
|
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, _7, _8, _9, _10;
|
|
19
|
+
var _11;
|
|
20
|
+
console.log("updateFormatCell", row_st, row_ed, col_st, col_ed);
|
|
20
21
|
if (_.isNil(d) || _.isNil(attr)) {
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
if (attr === "ct") {
|
|
25
|
+
var changes = [];
|
|
24
26
|
for (var r = row_st; r <= row_ed; r += 1) {
|
|
25
27
|
if (!_.isNil(ctx.config.rowhidden) && !_.isNil(ctx.config.rowhidden[r])) {
|
|
26
28
|
continue;
|
|
@@ -72,6 +74,18 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
72
74
|
m: mask
|
|
73
75
|
};
|
|
74
76
|
}
|
|
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
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if ((_x = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _x === void 0 ? void 0 : _x.updateCellYdoc) {
|
|
88
|
+
(_y = ctx.hooks) === null || _y === void 0 ? void 0 : _y.updateCellYdoc(changes);
|
|
75
89
|
}
|
|
76
90
|
}
|
|
77
91
|
} else {
|
|
@@ -118,6 +132,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
118
132
|
if (sheetIndex == null) {
|
|
119
133
|
return;
|
|
120
134
|
}
|
|
135
|
+
var changes = [];
|
|
121
136
|
for (var r = row_st; r <= row_ed; r += 1) {
|
|
122
137
|
if (!_.isNil(ctx.config.rowhidden) && !_.isNil(ctx.config.rowhidden[r])) {
|
|
123
138
|
continue;
|
|
@@ -127,11 +142,11 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
127
142
|
if (value && _.isPlainObject(value)) {
|
|
128
143
|
updateInlineStringFormatOutside(value, attr, foucsStatus);
|
|
129
144
|
value[attr] = foucsStatus;
|
|
130
|
-
(
|
|
145
|
+
(_11 = ctx.luckysheetfile[sheetIndex]).config || (_11.config = {});
|
|
131
146
|
var cfg = ctx.luckysheetfile[sheetIndex].config;
|
|
132
|
-
var cellWidth = ((
|
|
147
|
+
var cellWidth = ((_z = cfg.columnlen) === null || _z === void 0 ? void 0 : _z[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
|
|
133
148
|
if (attr === "tb" && canvas && foucsStatus === "2") {
|
|
134
|
-
var currentColWidth_1 = ((
|
|
149
|
+
var currentColWidth_1 = ((_0 = cfg.columnlen) === null || _0 === void 0 ? void 0 : _0[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
|
|
135
150
|
var lineCount_1 = 1;
|
|
136
151
|
var fontString_1 = "10px Arial";
|
|
137
152
|
if (value.fs) {
|
|
@@ -144,9 +159,9 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
144
159
|
lineCount_1 = getLineCount(value.m, currentColWidth_1, fontString_1);
|
|
145
160
|
var hOffset = lineCount_1 < 4 ? 1.9 : 1.7;
|
|
146
161
|
lineCount_1 = lineCount_1 * hOffset + 1;
|
|
147
|
-
} else if ((
|
|
162
|
+
} else if ((_3 = (_2 = (_1 = value === null || value === void 0 ? void 0 : value.ct) === null || _1 === void 0 ? void 0 : _1.s) === null || _2 === void 0 ? void 0 : _2[0]) === null || _3 === void 0 ? void 0 : _3.v) {
|
|
148
163
|
lineCount_1 -= 1;
|
|
149
|
-
var line = (
|
|
164
|
+
var line = (_6 = (_5 = (_4 = value === null || value === void 0 ? void 0 : value.ct) === null || _4 === void 0 ? void 0 : _4.s) === null || _5 === void 0 ? void 0 : _5[0]) === null || _6 === void 0 ? void 0 : _6.v.split("\n");
|
|
150
165
|
line.forEach(function (item) {
|
|
151
166
|
var subLineCount = getLineCount(item, currentColWidth_1, fontString_1);
|
|
152
167
|
lineCount_1 += subLineCount;
|
|
@@ -166,7 +181,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
166
181
|
});
|
|
167
182
|
if (!textInfo) return "continue";
|
|
168
183
|
var rowHeight = _.round(textInfo.textHeightAll);
|
|
169
|
-
var currentRowHeight = ((
|
|
184
|
+
var currentRowHeight = ((_7 = cfg.rowlen) === null || _7 === void 0 ? void 0 : _7[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
|
|
170
185
|
if (!_.isUndefined(rowHeight) && rowHeight > currentRowHeight && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
|
|
171
186
|
if (_.isUndefined(cfg.rowlen)) cfg.rowlen = {};
|
|
172
187
|
_.set(cfg, "rowlen.".concat(r), rowHeight);
|
|
@@ -181,7 +196,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
181
196
|
});
|
|
182
197
|
if (!textInfo) return "continue";
|
|
183
198
|
var newHeight = _.round(textInfo.textHeightAll);
|
|
184
|
-
var oldHeight = ((
|
|
199
|
+
var oldHeight = ((_8 = cfg.rowlen) === null || _8 === void 0 ? void 0 : _8[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
|
|
185
200
|
var shouldResize = foucsStatus === "2" ? newHeight > oldHeight : true;
|
|
186
201
|
if (shouldResize && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
|
|
187
202
|
var padding = 12;
|
|
@@ -196,11 +211,23 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
|
|
|
196
211
|
};
|
|
197
212
|
d[r][c][attr] = foucsStatus;
|
|
198
213
|
}
|
|
214
|
+
changes.push({
|
|
215
|
+
sheetId: ctx.currentSheetId,
|
|
216
|
+
path: ['celldata'],
|
|
217
|
+
value: {
|
|
218
|
+
r: r,
|
|
219
|
+
c: c,
|
|
220
|
+
v: d[r][c]
|
|
221
|
+
}
|
|
222
|
+
});
|
|
199
223
|
};
|
|
200
224
|
for (var c = col_st; c <= col_ed; c += 1) {
|
|
201
225
|
_loop_1(c);
|
|
202
226
|
}
|
|
203
227
|
}
|
|
228
|
+
if ((_9 = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _9 === void 0 ? void 0 : _9.updateCellYdoc) {
|
|
229
|
+
(_10 = ctx.hooks) === null || _10 === void 0 ? void 0 : _10.updateCellYdoc(changes);
|
|
230
|
+
}
|
|
204
231
|
}
|
|
205
232
|
}
|
|
206
233
|
export function updateFormat(ctx, $input, d, attr, foucsStatus, canvas) {
|
package/es/settings.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
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
|
+
};
|
|
3
10
|
export type Hooks = {
|
|
4
11
|
calcChainChange?: () => void;
|
|
5
12
|
sheetLengthChange?: () => void;
|
|
@@ -10,6 +17,8 @@ export type Hooks = {
|
|
|
10
17
|
conditionRulesChange?: () => void;
|
|
11
18
|
conditionFormatChange?: () => void;
|
|
12
19
|
cellDataChange?: () => void;
|
|
20
|
+
hyperlinkChange?: () => void;
|
|
21
|
+
updateCellYdoc?: (changes: SheetChangePath[]) => void;
|
|
13
22
|
beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
|
|
14
23
|
afterUpdateCell?: (row: number, column: number, oldValue: any, newValue: any) => void;
|
|
15
24
|
afterSelectionChange?: (sheetId: string, selection: Selection) => void;
|
package/lib/events/paste.js
CHANGED
|
@@ -202,28 +202,43 @@ 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;
|
|
205
|
+
var _a, _b, _c;
|
|
206
|
+
var changes = [];
|
|
206
207
|
for (var r = 0; r < d.length; r += 1) {
|
|
207
208
|
var x = d[r];
|
|
208
209
|
for (var c = 0; c < d[0].length; c += 1) {
|
|
209
210
|
var value = (0, _lodash.isObject)(d[r][c]) ? (_a = d[r][c]) === null || _a === void 0 ? void 0 : _a.v : d[r][c];
|
|
210
211
|
if (value && String(value).startsWith("=")) {
|
|
211
212
|
var cell = {};
|
|
212
|
-
var
|
|
213
|
-
v =
|
|
214
|
-
f =
|
|
213
|
+
var _d = (0, _formula.execfunction)(ctx, String(value), r, c, undefined, undefined, true),
|
|
214
|
+
v = _d[1],
|
|
215
|
+
f = _d[2];
|
|
215
216
|
cell.v = v;
|
|
216
217
|
cell.f = f;
|
|
217
218
|
cell.m = v.toString();
|
|
218
219
|
x[c] = cell;
|
|
219
220
|
}
|
|
220
221
|
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: r + '_' + c,
|
|
231
|
+
type: 'update'
|
|
232
|
+
});
|
|
221
233
|
}
|
|
222
234
|
}
|
|
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
|
+
}
|
|
223
238
|
};
|
|
224
239
|
function pasteHandler(ctx, data, borderInfo) {
|
|
225
240
|
var _a;
|
|
226
|
-
var _b, _c, _d, _e, _f, _g;
|
|
241
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
227
242
|
if (ctx.luckysheet_selection_range) {
|
|
228
243
|
ctx.luckysheet_selection_range = [];
|
|
229
244
|
}
|
|
@@ -271,6 +286,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
271
286
|
}
|
|
272
287
|
var RowlChange = false;
|
|
273
288
|
var offsetMC = {};
|
|
289
|
+
var changes = [];
|
|
274
290
|
for (var h = minh; h <= maxh; h += 1) {
|
|
275
291
|
var x = d[h];
|
|
276
292
|
var currentRowLen = ctx.defaultrowlen;
|
|
@@ -318,12 +334,26 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
318
334
|
};
|
|
319
335
|
(_f = cfg.borderInfo) === null || _f === void 0 ? void 0 : _f.push(bd_obj);
|
|
320
336
|
}
|
|
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: h + '_' + c,
|
|
346
|
+
type: 'update'
|
|
347
|
+
});
|
|
321
348
|
}
|
|
322
349
|
d[h] = x;
|
|
323
350
|
if (currentRowLen !== ctx.defaultrowlen) {
|
|
324
351
|
cfg.rowlen[h] = currentRowLen;
|
|
325
352
|
}
|
|
326
353
|
}
|
|
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
|
+
}
|
|
327
357
|
ctx.luckysheet_select_save = [{
|
|
328
358
|
row: [minh, maxh],
|
|
329
359
|
column: [minc, maxc]
|
|
@@ -348,7 +378,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
348
378
|
}
|
|
349
379
|
var d = (0, _context.getFlowdata)(ctx);
|
|
350
380
|
if (!d) return;
|
|
351
|
-
var last = (
|
|
381
|
+
var last = (_j = ctx.luckysheet_select_save) === null || _j === void 0 ? void 0 : _j[ctx.luckysheet_select_save.length - 1];
|
|
352
382
|
if (!last) return;
|
|
353
383
|
var curR = last.row == null ? 0 : last.row[0];
|
|
354
384
|
var curC = last.column == null ? 0 : last.column[0];
|
|
@@ -373,6 +403,7 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
373
403
|
if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
|
|
374
404
|
return t.startsWith("http") ? t : "https://".concat(t);
|
|
375
405
|
};
|
|
406
|
+
var changes = [];
|
|
376
407
|
for (var r = 0; r < rlen; r += 1) {
|
|
377
408
|
var x = d[r + curR];
|
|
378
409
|
for (var c = 0; c < clen; c += 1) {
|
|
@@ -445,9 +476,23 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
445
476
|
}
|
|
446
477
|
x[c + curC] = cell;
|
|
447
478
|
}
|
|
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: r + '_' + c,
|
|
488
|
+
type: 'update'
|
|
489
|
+
}));
|
|
448
490
|
}
|
|
449
491
|
d[r + curR] = x;
|
|
450
492
|
}
|
|
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
|
+
}
|
|
451
496
|
last.row = [curR, curR + rlen - 1];
|
|
452
497
|
last.column = [curC, curC + clen - 1];
|
|
453
498
|
(0, _refresh.jfrefreshgrid)(ctx, null, undefined);
|
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, _d;
|
|
1535
1535
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
1536
1536
|
if (allowEdit === false || ctx.isFlvReadOnly) {
|
|
1537
1537
|
return "allowEdit";
|
|
@@ -1560,6 +1560,7 @@ 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 = [];
|
|
1563
1564
|
for (var r = r1; r <= r2; r += 1) {
|
|
1564
1565
|
for (var c = c1; c <= c2; c += 1) {
|
|
1565
1566
|
var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
@@ -1588,6 +1589,18 @@ function deleteSelectedCellText(ctx) {
|
|
|
1588
1589
|
if (hyperlinkMap && hyperlinkMap["".concat(r, "_").concat(c)]) {
|
|
1589
1590
|
delete hyperlinkMap["".concat(r, "_").concat(c)];
|
|
1590
1591
|
}
|
|
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
|
+
});
|
|
1591
1604
|
}
|
|
1592
1605
|
}
|
|
1593
1606
|
}
|
package/lib/modules/toolbar.js
CHANGED
|
@@ -48,12 +48,14 @@ 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
|
|
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, _7, _8, _9, _10;
|
|
52
|
+
var _11;
|
|
53
|
+
console.log("updateFormatCell", row_st, row_ed, col_st, col_ed);
|
|
53
54
|
if (_lodash.default.isNil(d) || _lodash.default.isNil(attr)) {
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
57
|
if (attr === "ct") {
|
|
58
|
+
var changes = [];
|
|
57
59
|
for (var r = row_st; r <= row_ed; r += 1) {
|
|
58
60
|
if (!_lodash.default.isNil(ctx.config.rowhidden) && !_lodash.default.isNil(ctx.config.rowhidden[r])) {
|
|
59
61
|
continue;
|
|
@@ -105,6 +107,18 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
105
107
|
m: mask
|
|
106
108
|
};
|
|
107
109
|
}
|
|
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
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if ((_x = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _x === void 0 ? void 0 : _x.updateCellYdoc) {
|
|
121
|
+
(_y = ctx.hooks) === null || _y === void 0 ? void 0 : _y.updateCellYdoc(changes);
|
|
108
122
|
}
|
|
109
123
|
}
|
|
110
124
|
} else {
|
|
@@ -151,6 +165,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
151
165
|
if (sheetIndex == null) {
|
|
152
166
|
return;
|
|
153
167
|
}
|
|
168
|
+
var changes = [];
|
|
154
169
|
for (var r = row_st; r <= row_ed; r += 1) {
|
|
155
170
|
if (!_lodash.default.isNil(ctx.config.rowhidden) && !_lodash.default.isNil(ctx.config.rowhidden[r])) {
|
|
156
171
|
continue;
|
|
@@ -160,11 +175,11 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
160
175
|
if (value && _lodash.default.isPlainObject(value)) {
|
|
161
176
|
(0, _inlineString.updateInlineStringFormatOutside)(value, attr, foucsStatus);
|
|
162
177
|
value[attr] = foucsStatus;
|
|
163
|
-
(
|
|
178
|
+
(_11 = ctx.luckysheetfile[sheetIndex]).config || (_11.config = {});
|
|
164
179
|
var cfg = ctx.luckysheetfile[sheetIndex].config;
|
|
165
|
-
var cellWidth = ((
|
|
180
|
+
var cellWidth = ((_z = cfg.columnlen) === null || _z === void 0 ? void 0 : _z[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
|
|
166
181
|
if (attr === "tb" && canvas && foucsStatus === "2") {
|
|
167
|
-
var currentColWidth_1 = ((
|
|
182
|
+
var currentColWidth_1 = ((_0 = cfg.columnlen) === null || _0 === void 0 ? void 0 : _0[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
|
|
168
183
|
var lineCount_1 = 1;
|
|
169
184
|
var fontString_1 = "10px Arial";
|
|
170
185
|
if (value.fs) {
|
|
@@ -177,9 +192,9 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
177
192
|
lineCount_1 = (0, _utils.getLineCount)(value.m, currentColWidth_1, fontString_1);
|
|
178
193
|
var hOffset = lineCount_1 < 4 ? 1.9 : 1.7;
|
|
179
194
|
lineCount_1 = lineCount_1 * hOffset + 1;
|
|
180
|
-
} else if ((
|
|
195
|
+
} else if ((_3 = (_2 = (_1 = value === null || value === void 0 ? void 0 : value.ct) === null || _1 === void 0 ? void 0 : _1.s) === null || _2 === void 0 ? void 0 : _2[0]) === null || _3 === void 0 ? void 0 : _3.v) {
|
|
181
196
|
lineCount_1 -= 1;
|
|
182
|
-
var line = (
|
|
197
|
+
var line = (_6 = (_5 = (_4 = value === null || value === void 0 ? void 0 : value.ct) === null || _4 === void 0 ? void 0 : _4.s) === null || _5 === void 0 ? void 0 : _5[0]) === null || _6 === void 0 ? void 0 : _6.v.split("\n");
|
|
183
198
|
line.forEach(function (item) {
|
|
184
199
|
var subLineCount = (0, _utils.getLineCount)(item, currentColWidth_1, fontString_1);
|
|
185
200
|
lineCount_1 += subLineCount;
|
|
@@ -199,7 +214,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
199
214
|
});
|
|
200
215
|
if (!textInfo) return "continue";
|
|
201
216
|
var rowHeight = _lodash.default.round(textInfo.textHeightAll);
|
|
202
|
-
var currentRowHeight = ((
|
|
217
|
+
var currentRowHeight = ((_7 = cfg.rowlen) === null || _7 === void 0 ? void 0 : _7[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
|
|
203
218
|
if (!_lodash.default.isUndefined(rowHeight) && rowHeight > currentRowHeight && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
|
|
204
219
|
if (_lodash.default.isUndefined(cfg.rowlen)) cfg.rowlen = {};
|
|
205
220
|
_lodash.default.set(cfg, "rowlen.".concat(r), rowHeight);
|
|
@@ -214,7 +229,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
214
229
|
});
|
|
215
230
|
if (!textInfo) return "continue";
|
|
216
231
|
var newHeight = _lodash.default.round(textInfo.textHeightAll);
|
|
217
|
-
var oldHeight = ((
|
|
232
|
+
var oldHeight = ((_8 = cfg.rowlen) === null || _8 === void 0 ? void 0 : _8[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
|
|
218
233
|
var shouldResize = foucsStatus === "2" ? newHeight > oldHeight : true;
|
|
219
234
|
if (shouldResize && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
|
|
220
235
|
var padding = 12;
|
|
@@ -229,11 +244,23 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
|
|
|
229
244
|
};
|
|
230
245
|
d[r][c][attr] = foucsStatus;
|
|
231
246
|
}
|
|
247
|
+
changes.push({
|
|
248
|
+
sheetId: ctx.currentSheetId,
|
|
249
|
+
path: ['celldata'],
|
|
250
|
+
value: {
|
|
251
|
+
r: r,
|
|
252
|
+
c: c,
|
|
253
|
+
v: d[r][c]
|
|
254
|
+
}
|
|
255
|
+
});
|
|
232
256
|
};
|
|
233
257
|
for (var c = col_st; c <= col_ed; c += 1) {
|
|
234
258
|
_loop_1(c);
|
|
235
259
|
}
|
|
236
260
|
}
|
|
261
|
+
if ((_9 = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _9 === void 0 ? void 0 : _9.updateCellYdoc) {
|
|
262
|
+
(_10 = ctx.hooks) === null || _10 === void 0 ? void 0 : _10.updateCellYdoc(changes);
|
|
263
|
+
}
|
|
237
264
|
}
|
|
238
265
|
}
|
|
239
266
|
function updateFormat(ctx, $input, d, attr, foucsStatus, canvas) {
|
package/lib/settings.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
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
|
+
};
|
|
3
10
|
export type Hooks = {
|
|
4
11
|
calcChainChange?: () => void;
|
|
5
12
|
sheetLengthChange?: () => void;
|
|
@@ -10,6 +17,8 @@ export type Hooks = {
|
|
|
10
17
|
conditionRulesChange?: () => void;
|
|
11
18
|
conditionFormatChange?: () => void;
|
|
12
19
|
cellDataChange?: () => void;
|
|
20
|
+
hyperlinkChange?: () => void;
|
|
21
|
+
updateCellYdoc?: (changes: SheetChangePath[]) => void;
|
|
13
22
|
beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
|
|
14
23
|
afterUpdateCell?: (row: number, column: number, oldValue: any, newValue: any) => void;
|
|
15
24
|
afterSelectionChange?: (sheetId: string, selection: Selection) => void;
|