@fileverse-dev/fortune-core 1.3.10-yjs-1 → 1.3.10-yjs-3
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 +67 -22
- package/es/modules/cell.js +1 -1
- package/es/modules/comment.js +129 -24
- package/es/modules/rowcol.js +78 -2
- package/es/modules/selection.js +41 -4
- package/es/modules/sort.js +30 -9
- package/es/settings.d.ts +1 -0
- package/lib/events/paste.js +67 -22
- package/lib/modules/cell.js +1 -1
- package/lib/modules/comment.js +129 -24
- package/lib/modules/rowcol.js +78 -2
- package/lib/modules/selection.js +41 -4
- package/lib/modules/sort.js +30 -9
- package/lib/settings.d.ts +1 -0
- package/package.json +1 -1
package/es/events/paste.js
CHANGED
|
@@ -203,19 +203,19 @@ var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
|
|
|
203
203
|
cell.f = f;
|
|
204
204
|
cell.m = v.toString();
|
|
205
205
|
x[c] = cell;
|
|
206
|
+
changes.push({
|
|
207
|
+
sheetId: ctx.currentSheetId,
|
|
208
|
+
path: ["celldata"],
|
|
209
|
+
value: {
|
|
210
|
+
r: r,
|
|
211
|
+
c: c,
|
|
212
|
+
v: d[r][c]
|
|
213
|
+
},
|
|
214
|
+
key: "".concat(r, "_").concat(c),
|
|
215
|
+
type: "update"
|
|
216
|
+
});
|
|
206
217
|
}
|
|
207
218
|
d[r] = x;
|
|
208
|
-
changes.push({
|
|
209
|
-
sheetId: ctx.currentSheetId,
|
|
210
|
-
path: ["celldata"],
|
|
211
|
-
value: {
|
|
212
|
-
r: r,
|
|
213
|
-
c: c,
|
|
214
|
-
v: d[r][c]
|
|
215
|
-
},
|
|
216
|
-
key: "".concat(r, "_").concat(c),
|
|
217
|
-
type: "update"
|
|
218
|
-
});
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
|
|
@@ -349,7 +349,9 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
349
349
|
ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].config = cfg;
|
|
350
350
|
}
|
|
351
351
|
jfrefreshgrid(ctx, null, undefined);
|
|
352
|
-
|
|
352
|
+
if (data.includes("=")) {
|
|
353
|
+
handleFormulaOnPaste(ctx, d);
|
|
354
|
+
}
|
|
353
355
|
} else {
|
|
354
356
|
data = data.replace(/\r/g, "");
|
|
355
357
|
var dataChe = [];
|
|
@@ -479,17 +481,17 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
479
481
|
}
|
|
480
482
|
x[c + curC] = cell;
|
|
481
483
|
}
|
|
482
|
-
changes.push(
|
|
484
|
+
changes.push({
|
|
483
485
|
sheetId: ctx.currentSheetId,
|
|
484
486
|
path: ["celldata"],
|
|
485
487
|
value: {
|
|
486
|
-
r: r,
|
|
487
|
-
c: c,
|
|
488
|
-
v: d[r][c]
|
|
488
|
+
r: r + curR,
|
|
489
|
+
c: c + curC,
|
|
490
|
+
v: d[r + curR][c + curC]
|
|
489
491
|
},
|
|
490
|
-
key: "".concat(r, "_").concat(c),
|
|
492
|
+
key: "".concat(r + curR, "_").concat(c + curC),
|
|
491
493
|
type: "update"
|
|
492
|
-
})
|
|
494
|
+
});
|
|
493
495
|
}
|
|
494
496
|
d[r + curR] = x;
|
|
495
497
|
}
|
|
@@ -499,7 +501,9 @@ function pasteHandler(ctx, data, borderInfo) {
|
|
|
499
501
|
last.row = [curR, curR + rlen - 1];
|
|
500
502
|
last.column = [curC, curC + clen - 1];
|
|
501
503
|
jfrefreshgrid(ctx, null, undefined);
|
|
502
|
-
|
|
504
|
+
if (data.includes("=")) {
|
|
505
|
+
handleFormulaOnPaste(ctx, d);
|
|
506
|
+
}
|
|
503
507
|
}
|
|
504
508
|
}
|
|
505
509
|
function setCellHyperlink(ctx, id, r, c, link) {
|
|
@@ -510,7 +514,7 @@ function setCellHyperlink(ctx, id, r, c, link) {
|
|
|
510
514
|
ctx.luckysheetfile[index].hyperlink["".concat(r, "_").concat(c)] = link;
|
|
511
515
|
}
|
|
512
516
|
function pasteHandlerOfCutPaste(ctx, copyRange) {
|
|
513
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
517
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
514
518
|
var allowEdit = isAllowEdit(ctx);
|
|
515
519
|
if (!allowEdit || ctx.isFlvReadOnly) return;
|
|
516
520
|
if (!copyRange) return;
|
|
@@ -553,6 +557,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
|
|
|
553
557
|
if (addr > 0 || addc > 0) {
|
|
554
558
|
expandRowsAndColumns(d, addr, addc);
|
|
555
559
|
}
|
|
560
|
+
var changes = [];
|
|
556
561
|
var borderInfoCompute = getBorderInfoCompute(ctx, copySheetId);
|
|
557
562
|
var c_dataVerification = _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, copySheetId)].dataVerification) || {};
|
|
558
563
|
var dataVerification = _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].dataVerification) || {};
|
|
@@ -584,6 +589,17 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
|
|
|
584
589
|
delete cell.mc;
|
|
585
590
|
}
|
|
586
591
|
d[i][j] = null;
|
|
592
|
+
changes.push({
|
|
593
|
+
sheetId: ctx.currentSheetId,
|
|
594
|
+
path: ["celldata"],
|
|
595
|
+
value: {
|
|
596
|
+
r: i,
|
|
597
|
+
c: j,
|
|
598
|
+
v: null
|
|
599
|
+
},
|
|
600
|
+
key: "".concat(i, "_").concat(j),
|
|
601
|
+
type: "update"
|
|
602
|
+
});
|
|
587
603
|
delete dataVerification["".concat(i, "_").concat(j)];
|
|
588
604
|
(_f = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].hyperlink) === null || _f === void 0 ? true : delete _f["".concat(i, "_").concat(j)];
|
|
589
605
|
}
|
|
@@ -683,6 +699,17 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
|
|
|
683
699
|
value = copyData[h - minh][c - minc];
|
|
684
700
|
}
|
|
685
701
|
x[c] = _.cloneDeep(value);
|
|
702
|
+
changes.push({
|
|
703
|
+
sheetId: ctx.currentSheetId,
|
|
704
|
+
path: ["celldata"],
|
|
705
|
+
value: {
|
|
706
|
+
r: h,
|
|
707
|
+
c: c,
|
|
708
|
+
v: d[h][c]
|
|
709
|
+
},
|
|
710
|
+
key: "".concat(h, "_").concat(c),
|
|
711
|
+
type: "update"
|
|
712
|
+
});
|
|
686
713
|
if (value != null && copyHasMC && ((_k = x[c]) === null || _k === void 0 ? void 0 : _k.mc)) {
|
|
687
714
|
if (x[c].mc.rs != null) {
|
|
688
715
|
x[c].mc.r = h;
|
|
@@ -703,6 +730,9 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
|
|
|
703
730
|
}
|
|
704
731
|
last.row = [minh, maxh];
|
|
705
732
|
last.column = [minc, maxc];
|
|
733
|
+
if (changes.length > 0 && ((_l = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _l === void 0 ? void 0 : _l.updateCellYdoc)) {
|
|
734
|
+
ctx.hooks.updateCellYdoc(changes);
|
|
735
|
+
}
|
|
706
736
|
if (copyRowlChange) {}
|
|
707
737
|
var source;
|
|
708
738
|
var target;
|
|
@@ -785,7 +815,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
|
|
|
785
815
|
}
|
|
786
816
|
source_curCdformat[i].cellrange = emptyRange;
|
|
787
817
|
if (emptyRange2.length > 0) {
|
|
788
|
-
var ruleObj = (
|
|
818
|
+
var ruleObj = (_m = source_curCdformat[i]) !== null && _m !== void 0 ? _m : {};
|
|
789
819
|
ruleObj.cellrange = emptyRange2;
|
|
790
820
|
ruleArr.push(ruleObj);
|
|
791
821
|
}
|
|
@@ -889,7 +919,7 @@ function pasteHandlerOfCutPaste(ctx, copyRange) {
|
|
|
889
919
|
}
|
|
890
920
|
}
|
|
891
921
|
function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
892
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
922
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
893
923
|
var allowEdit = isAllowEdit(ctx);
|
|
894
924
|
if (!allowEdit || ctx.isFlvReadOnly) return;
|
|
895
925
|
if (!copyRange) return;
|
|
@@ -980,6 +1010,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
980
1010
|
if (addr > 0 || addc > 0) {
|
|
981
1011
|
expandRowsAndColumns(d, addr, addc);
|
|
982
1012
|
}
|
|
1013
|
+
var changes = [];
|
|
983
1014
|
var borderInfoCompute = getBorderInfoCompute(ctx, copySheetIndex);
|
|
984
1015
|
var c_dataVerification = _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, copySheetIndex)].dataVerification) || {};
|
|
985
1016
|
var dataVerification = null;
|
|
@@ -1141,6 +1172,17 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1141
1172
|
};
|
|
1142
1173
|
}
|
|
1143
1174
|
}
|
|
1175
|
+
changes.push({
|
|
1176
|
+
sheetId: ctx.currentSheetId,
|
|
1177
|
+
path: ["celldata"],
|
|
1178
|
+
value: {
|
|
1179
|
+
r: h,
|
|
1180
|
+
c: c,
|
|
1181
|
+
v: d[h][c]
|
|
1182
|
+
},
|
|
1183
|
+
key: "".concat(h, "_").concat(c),
|
|
1184
|
+
type: "update"
|
|
1185
|
+
});
|
|
1144
1186
|
}
|
|
1145
1187
|
d[h] = x;
|
|
1146
1188
|
}
|
|
@@ -1248,6 +1290,9 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1248
1290
|
}
|
|
1249
1291
|
}
|
|
1250
1292
|
}
|
|
1293
|
+
if (changes.length > 0 && ((_s = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _s === void 0 ? void 0 : _s.updateCellYdoc)) {
|
|
1294
|
+
ctx.hooks.updateCellYdoc(changes);
|
|
1295
|
+
}
|
|
1251
1296
|
if (copyRowlChange || addr > 0 || addc > 0) {
|
|
1252
1297
|
jfrefreshgrid(ctx, d, ctx.luckysheet_select_save);
|
|
1253
1298
|
} else {
|
package/es/modules/cell.js
CHANGED
|
@@ -809,7 +809,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
809
809
|
var newValue_1 = _.cloneDeep(d[r][c]);
|
|
810
810
|
setTimeout(function () {
|
|
811
811
|
var _a, _b;
|
|
812
|
-
return (_b = (_a = ctx.hooks).afterUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c,
|
|
812
|
+
return (_b = (_a = ctx.hooks).afterUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, oldValue_1, newValue_1);
|
|
813
813
|
});
|
|
814
814
|
}
|
|
815
815
|
ctx.formulaCache.execFunctionGlobalData = null;
|
package/es/modules/comment.js
CHANGED
|
@@ -163,7 +163,7 @@ export function setEditingComment(ctx, flowdata, r, c) {
|
|
|
163
163
|
ctx.editingCommentBox = getCommentBoxByRC(ctx, flowdata, r, c);
|
|
164
164
|
}
|
|
165
165
|
export function removeEditingComment(ctx, globalCache) {
|
|
166
|
-
var _a, _b;
|
|
166
|
+
var _a, _b, _c;
|
|
167
167
|
var editingCommentBoxEle = globalCache.editingCommentBoxEle;
|
|
168
168
|
ctx.editingCommentBox = undefined;
|
|
169
169
|
var r = editingCommentBoxEle === null || editingCommentBoxEle === void 0 ? void 0 : editingCommentBoxEle.dataset.r;
|
|
@@ -187,6 +187,19 @@ export function removeEditingComment(ctx, globalCache) {
|
|
|
187
187
|
return v.rc !== "".concat(r, "_").concat(c);
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
|
+
if ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) {
|
|
191
|
+
ctx.hooks.updateCellYdoc([{
|
|
192
|
+
sheetId: ctx.currentSheetId,
|
|
193
|
+
path: ["celldata"],
|
|
194
|
+
value: {
|
|
195
|
+
r: r,
|
|
196
|
+
c: c,
|
|
197
|
+
v: cell
|
|
198
|
+
},
|
|
199
|
+
key: "".concat(r, "_").concat(c),
|
|
200
|
+
type: "update"
|
|
201
|
+
}]);
|
|
202
|
+
}
|
|
190
203
|
if (ctx.hooks.afterUpdateComment) {
|
|
191
204
|
setTimeout(function () {
|
|
192
205
|
var _a, _b;
|
|
@@ -195,7 +208,7 @@ export function removeEditingComment(ctx, globalCache) {
|
|
|
195
208
|
}
|
|
196
209
|
}
|
|
197
210
|
export function newComment(ctx, globalCache, r, c) {
|
|
198
|
-
var _a, _b;
|
|
211
|
+
var _a, _b, _c, _d;
|
|
199
212
|
if (((_b = (_a = ctx.hooks).beforeInsertComment) === null || _b === void 0 ? void 0 : _b.call(_a, r, c)) === false) {
|
|
200
213
|
return;
|
|
201
214
|
}
|
|
@@ -220,6 +233,19 @@ export function newComment(ctx, globalCache, r, c) {
|
|
|
220
233
|
ctx.editingCommentBox = __assign(__assign({}, getCommentBoxByRC(ctx, flowdata, r, c)), {
|
|
221
234
|
autoFocus: true
|
|
222
235
|
});
|
|
236
|
+
if ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) {
|
|
237
|
+
ctx.hooks.updateCellYdoc([{
|
|
238
|
+
sheetId: ctx.currentSheetId,
|
|
239
|
+
path: ["celldata"],
|
|
240
|
+
value: {
|
|
241
|
+
r: r,
|
|
242
|
+
c: c,
|
|
243
|
+
v: (_d = flowdata[r][c]) !== null && _d !== void 0 ? _d : null
|
|
244
|
+
},
|
|
245
|
+
key: "".concat(r, "_").concat(c),
|
|
246
|
+
type: "update"
|
|
247
|
+
}]);
|
|
248
|
+
}
|
|
223
249
|
if (ctx.hooks.afterInsertComment) {
|
|
224
250
|
setTimeout(function () {
|
|
225
251
|
var _a, _b;
|
|
@@ -246,7 +272,7 @@ export function editComment(ctx, globalCache, r, c) {
|
|
|
246
272
|
}
|
|
247
273
|
}
|
|
248
274
|
export function deleteComment(ctx, globalCache, r, c) {
|
|
249
|
-
var _a, _b;
|
|
275
|
+
var _a, _b, _c;
|
|
250
276
|
var allowEdit = isAllowEdit(ctx);
|
|
251
277
|
if (!allowEdit) return;
|
|
252
278
|
if (((_b = (_a = ctx.hooks).beforeDeleteComment) === null || _b === void 0 ? void 0 : _b.call(_a, r, c)) === false) {
|
|
@@ -257,6 +283,19 @@ export function deleteComment(ctx, globalCache, r, c) {
|
|
|
257
283
|
var cell = flowdata[r][c];
|
|
258
284
|
if (!cell) return;
|
|
259
285
|
cell.ps = undefined;
|
|
286
|
+
if ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) {
|
|
287
|
+
ctx.hooks.updateCellYdoc([{
|
|
288
|
+
sheetId: ctx.currentSheetId,
|
|
289
|
+
path: ["celldata"],
|
|
290
|
+
value: {
|
|
291
|
+
r: r,
|
|
292
|
+
c: c,
|
|
293
|
+
v: cell
|
|
294
|
+
},
|
|
295
|
+
key: "".concat(r, "_").concat(c),
|
|
296
|
+
type: "update"
|
|
297
|
+
}]);
|
|
298
|
+
}
|
|
260
299
|
if (ctx.hooks.afterDeleteComment) {
|
|
261
300
|
setTimeout(function () {
|
|
262
301
|
var _a, _b;
|
|
@@ -276,7 +315,7 @@ export function showComments(ctx, commentShowCells) {
|
|
|
276
315
|
}
|
|
277
316
|
}
|
|
278
317
|
export function showHideComment(ctx, globalCache, r, c) {
|
|
279
|
-
var _a;
|
|
318
|
+
var _a, _b, _c;
|
|
280
319
|
var flowdata = getFlowdata(ctx);
|
|
281
320
|
var comment = (_a = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r][c]) === null || _a === void 0 ? void 0 : _a.ps;
|
|
282
321
|
if (!comment) return;
|
|
@@ -290,9 +329,23 @@ export function showHideComment(ctx, globalCache, r, c) {
|
|
|
290
329
|
} else {
|
|
291
330
|
comment.isShow = true;
|
|
292
331
|
}
|
|
332
|
+
var cell = (_b = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r]) === null || _b === void 0 ? void 0 : _b[c];
|
|
333
|
+
if (cell && ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc)) {
|
|
334
|
+
ctx.hooks.updateCellYdoc([{
|
|
335
|
+
sheetId: ctx.currentSheetId,
|
|
336
|
+
path: ["celldata"],
|
|
337
|
+
value: {
|
|
338
|
+
r: r,
|
|
339
|
+
c: c,
|
|
340
|
+
v: cell
|
|
341
|
+
},
|
|
342
|
+
key: "".concat(r, "_").concat(c),
|
|
343
|
+
type: "update"
|
|
344
|
+
}]);
|
|
345
|
+
}
|
|
293
346
|
}
|
|
294
347
|
export function showHideAllComments(ctx) {
|
|
295
|
-
var _a, _b;
|
|
348
|
+
var _a, _b, _c, _d, _e;
|
|
296
349
|
var flowdata = getFlowdata(ctx);
|
|
297
350
|
if (!flowdata) return;
|
|
298
351
|
var isAllShow = true;
|
|
@@ -313,29 +366,55 @@ export function showHideAllComments(ctx) {
|
|
|
313
366
|
}
|
|
314
367
|
var rcs = [];
|
|
315
368
|
if (allComments.length > 0) {
|
|
369
|
+
var cellChanges = [];
|
|
316
370
|
if (isAllShow) {
|
|
317
371
|
for (var i = 0; i < allComments.length; i += 1) {
|
|
318
|
-
var
|
|
319
|
-
r =
|
|
320
|
-
c =
|
|
372
|
+
var _f = allComments[i],
|
|
373
|
+
r = _f.r,
|
|
374
|
+
c = _f.c;
|
|
321
375
|
var comment = (_a = flowdata[r][c]) === null || _a === void 0 ? void 0 : _a.ps;
|
|
322
376
|
if (comment === null || comment === void 0 ? void 0 : comment.isShow) {
|
|
323
377
|
comment.isShow = false;
|
|
324
378
|
rcs.push("".concat(r, "_").concat(c));
|
|
379
|
+
cellChanges.push({
|
|
380
|
+
sheetId: ctx.currentSheetId,
|
|
381
|
+
path: ["celldata"],
|
|
382
|
+
value: {
|
|
383
|
+
r: r,
|
|
384
|
+
c: c,
|
|
385
|
+
v: (_b = flowdata[r][c]) !== null && _b !== void 0 ? _b : null
|
|
386
|
+
},
|
|
387
|
+
key: "".concat(r, "_").concat(c),
|
|
388
|
+
type: "update"
|
|
389
|
+
});
|
|
325
390
|
}
|
|
326
391
|
}
|
|
327
392
|
ctx.commentBoxes = [];
|
|
328
393
|
} else {
|
|
329
394
|
for (var i = 0; i < allComments.length; i += 1) {
|
|
330
|
-
var
|
|
331
|
-
r =
|
|
332
|
-
c =
|
|
333
|
-
var comment = (
|
|
395
|
+
var _g = allComments[i],
|
|
396
|
+
r = _g.r,
|
|
397
|
+
c = _g.c;
|
|
398
|
+
var comment = (_c = flowdata[r][c]) === null || _c === void 0 ? void 0 : _c.ps;
|
|
334
399
|
if (comment && !comment.isShow) {
|
|
335
400
|
comment.isShow = true;
|
|
401
|
+
cellChanges.push({
|
|
402
|
+
sheetId: ctx.currentSheetId,
|
|
403
|
+
path: ["celldata"],
|
|
404
|
+
value: {
|
|
405
|
+
r: r,
|
|
406
|
+
c: c,
|
|
407
|
+
v: (_d = flowdata[r][c]) !== null && _d !== void 0 ? _d : null
|
|
408
|
+
},
|
|
409
|
+
key: "".concat(r, "_").concat(c),
|
|
410
|
+
type: "update"
|
|
411
|
+
});
|
|
336
412
|
}
|
|
337
413
|
}
|
|
338
414
|
}
|
|
415
|
+
if (cellChanges.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
|
|
416
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
417
|
+
}
|
|
339
418
|
}
|
|
340
419
|
}
|
|
341
420
|
export function removeOverShowComment(ctx) {
|
|
@@ -497,13 +576,13 @@ export function onCommentBoxResize(ctx, globalCache, e) {
|
|
|
497
576
|
return false;
|
|
498
577
|
}
|
|
499
578
|
export function onCommentBoxResizeEnd(ctx, globalCache) {
|
|
500
|
-
var _a;
|
|
579
|
+
var _a, _b;
|
|
501
580
|
if ((_a = globalCache.commentBox) === null || _a === void 0 ? void 0 : _a.resizingId) {
|
|
502
|
-
var
|
|
503
|
-
resizingId =
|
|
504
|
-
|
|
505
|
-
r =
|
|
506
|
-
c =
|
|
581
|
+
var _c = globalCache.commentBox,
|
|
582
|
+
resizingId = _c.resizingId,
|
|
583
|
+
_d = _c.commentRC,
|
|
584
|
+
r = _d.r,
|
|
585
|
+
c = _d.c;
|
|
507
586
|
globalCache.commentBox.resizingId = undefined;
|
|
508
587
|
var position = getCommentBoxPosition(resizingId);
|
|
509
588
|
if (position) {
|
|
@@ -519,6 +598,19 @@ export function onCommentBoxResizeEnd(ctx, globalCache) {
|
|
|
519
598
|
cell.ps.width = width / ctx.zoomRatio;
|
|
520
599
|
cell.ps.height = height / ctx.zoomRatio;
|
|
521
600
|
setEditingComment(ctx, flowdata, r, c);
|
|
601
|
+
if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
|
|
602
|
+
ctx.hooks.updateCellYdoc([{
|
|
603
|
+
sheetId: ctx.currentSheetId,
|
|
604
|
+
path: ["celldata"],
|
|
605
|
+
value: {
|
|
606
|
+
r: r,
|
|
607
|
+
c: c,
|
|
608
|
+
v: cell
|
|
609
|
+
},
|
|
610
|
+
key: "".concat(r, "_").concat(c),
|
|
611
|
+
type: "update"
|
|
612
|
+
}]);
|
|
613
|
+
}
|
|
522
614
|
}
|
|
523
615
|
}
|
|
524
616
|
}
|
|
@@ -570,13 +662,13 @@ export function onCommentBoxMove(ctx, globalCache, e) {
|
|
|
570
662
|
return false;
|
|
571
663
|
}
|
|
572
664
|
export function onCommentBoxMoveEnd(ctx, globalCache) {
|
|
573
|
-
var _a;
|
|
665
|
+
var _a, _b;
|
|
574
666
|
if ((_a = globalCache.commentBox) === null || _a === void 0 ? void 0 : _a.movingId) {
|
|
575
|
-
var
|
|
576
|
-
movingId =
|
|
577
|
-
|
|
578
|
-
r =
|
|
579
|
-
c =
|
|
667
|
+
var _c = globalCache.commentBox,
|
|
668
|
+
movingId = _c.movingId,
|
|
669
|
+
_d = _c.commentRC,
|
|
670
|
+
r = _d.r,
|
|
671
|
+
c = _d.c;
|
|
580
672
|
globalCache.commentBox.movingId = undefined;
|
|
581
673
|
var position = getCommentBoxPosition(movingId);
|
|
582
674
|
if (position) {
|
|
@@ -588,6 +680,19 @@ export function onCommentBoxMoveEnd(ctx, globalCache) {
|
|
|
588
680
|
cell.ps.left = left / ctx.zoomRatio;
|
|
589
681
|
cell.ps.top = top_5 / ctx.zoomRatio;
|
|
590
682
|
setEditingComment(ctx, flowdata, r, c);
|
|
683
|
+
if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
|
|
684
|
+
ctx.hooks.updateCellYdoc([{
|
|
685
|
+
sheetId: ctx.currentSheetId,
|
|
686
|
+
path: ["celldata"],
|
|
687
|
+
value: {
|
|
688
|
+
r: r,
|
|
689
|
+
c: c,
|
|
690
|
+
v: cell
|
|
691
|
+
},
|
|
692
|
+
key: "".concat(r, "_").concat(c),
|
|
693
|
+
type: "update"
|
|
694
|
+
}]);
|
|
695
|
+
}
|
|
591
696
|
}
|
|
592
697
|
}
|
|
593
698
|
}
|
package/es/modules/rowcol.js
CHANGED
|
@@ -54,8 +54,66 @@ var refreshLocalMergeData = function refreshLocalMergeData(merge_new, file) {
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
|
+
var getMergeBounds = function getMergeBounds(mergeMap) {
|
|
58
|
+
if (!mergeMap) return null;
|
|
59
|
+
var minR = Infinity;
|
|
60
|
+
var minC = Infinity;
|
|
61
|
+
var maxR = -Infinity;
|
|
62
|
+
var maxC = -Infinity;
|
|
63
|
+
Object.values(mergeMap).forEach(function (mc) {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
if (!mc) return;
|
|
66
|
+
var r = Number(mc.r);
|
|
67
|
+
var c = Number(mc.c);
|
|
68
|
+
var rs = Number((_a = mc.rs) !== null && _a !== void 0 ? _a : 1);
|
|
69
|
+
var cs = Number((_b = mc.cs) !== null && _b !== void 0 ? _b : 1);
|
|
70
|
+
if (!Number.isFinite(r) || !Number.isFinite(c)) return;
|
|
71
|
+
minR = Math.min(minR, r);
|
|
72
|
+
minC = Math.min(minC, c);
|
|
73
|
+
maxR = Math.max(maxR, r + Math.max(1, rs) - 1);
|
|
74
|
+
maxC = Math.max(maxC, c + Math.max(1, cs) - 1);
|
|
75
|
+
});
|
|
76
|
+
if (minR === Infinity) return null;
|
|
77
|
+
return {
|
|
78
|
+
minR: minR,
|
|
79
|
+
minC: minC,
|
|
80
|
+
maxR: maxR,
|
|
81
|
+
maxC: maxC
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
var emitCellRangeToYdoc = function emitCellRangeToYdoc(ctx, sheetId, d, r1, r2, c1, c2) {
|
|
85
|
+
var _a, _b, _c, _d;
|
|
86
|
+
if (!((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) return;
|
|
87
|
+
if (!d || !Array.isArray(d) || d.length === 0) return;
|
|
88
|
+
var rowEnd = Math.min(r2, d.length - 1);
|
|
89
|
+
var colEnd = Math.min(c2, ((_c = (_b = d[0]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) - 1);
|
|
90
|
+
var rowStart = Math.max(0, r1);
|
|
91
|
+
var colStart = Math.max(0, c1);
|
|
92
|
+
if (rowStart > rowEnd || colStart > colEnd) return;
|
|
93
|
+
var changes = [];
|
|
94
|
+
for (var r = rowStart; r <= rowEnd; r += 1) {
|
|
95
|
+
var row = d[r] || [];
|
|
96
|
+
for (var c = colStart; c <= colEnd; c += 1) {
|
|
97
|
+
changes.push({
|
|
98
|
+
sheetId: sheetId,
|
|
99
|
+
path: ["celldata"],
|
|
100
|
+
value: {
|
|
101
|
+
r: r,
|
|
102
|
+
c: c,
|
|
103
|
+
v: (_d = row === null || row === void 0 ? void 0 : row[c]) !== null && _d !== void 0 ? _d : null
|
|
104
|
+
},
|
|
105
|
+
key: "".concat(r, "_").concat(c),
|
|
106
|
+
type: "update"
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
changes.forEach(function (change) {
|
|
111
|
+
console.log("emitCellRangeToYdoc", change, __assign({}, change.value.v));
|
|
112
|
+
});
|
|
113
|
+
if (changes.length > 0) ctx.hooks.updateCellYdoc(changes);
|
|
114
|
+
};
|
|
57
115
|
export function insertRowCol(ctx, op, changeSelection) {
|
|
58
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
116
|
+
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;
|
|
59
117
|
if (changeSelection === void 0) {
|
|
60
118
|
changeSelection = true;
|
|
61
119
|
}
|
|
@@ -1020,9 +1078,19 @@ export function insertRowCol(ctx, op, changeSelection) {
|
|
|
1020
1078
|
}
|
|
1021
1079
|
}
|
|
1022
1080
|
refreshLocalMergeData(merge_new, file);
|
|
1081
|
+
var mergeBounds = getMergeBounds(cfg.merge);
|
|
1082
|
+
if (type === "row") {
|
|
1083
|
+
var baseStart = direction === "lefttop" ? index : index + 1;
|
|
1084
|
+
var startR = mergeBounds ? Math.min(baseStart, mergeBounds.minR) : baseStart;
|
|
1085
|
+
emitCellRangeToYdoc(ctx, id, d, startR, d.length - 1, 0, ((_y = (_x = d[0]) === null || _x === void 0 ? void 0 : _x.length) !== null && _y !== void 0 ? _y : 1) - 1);
|
|
1086
|
+
} else {
|
|
1087
|
+
var baseStart = direction === "lefttop" ? index : index + 1;
|
|
1088
|
+
var startC = mergeBounds ? Math.min(baseStart, mergeBounds.minC) : baseStart;
|
|
1089
|
+
emitCellRangeToYdoc(ctx, id, d, 0, d.length - 1, startC, ((_0 = (_z = d[0]) === null || _z === void 0 ? void 0 : _z.length) !== null && _0 !== void 0 ? _0 : 1) - 1);
|
|
1090
|
+
}
|
|
1023
1091
|
}
|
|
1024
1092
|
export function deleteRowCol(ctx, op) {
|
|
1025
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
1093
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
1026
1094
|
var type = op.type;
|
|
1027
1095
|
var start = op.start,
|
|
1028
1096
|
end = op.end,
|
|
@@ -1742,6 +1810,14 @@ export function deleteRowCol(ctx, op) {
|
|
|
1742
1810
|
file.dataVerification = newDataVerification;
|
|
1743
1811
|
file.hyperlink = newHyperlink;
|
|
1744
1812
|
refreshLocalMergeData(merge_new, file);
|
|
1813
|
+
var mergeBounds = getMergeBounds(cfg.merge);
|
|
1814
|
+
if (type === "row") {
|
|
1815
|
+
var startR = mergeBounds ? Math.min(start, mergeBounds.minR) : start;
|
|
1816
|
+
emitCellRangeToYdoc(ctx, id, d, startR, d.length - 1, 0, ((_s = (_r = d[0]) === null || _r === void 0 ? void 0 : _r.length) !== null && _s !== void 0 ? _s : 1) - 1);
|
|
1817
|
+
} else {
|
|
1818
|
+
var startC = mergeBounds ? Math.min(start, mergeBounds.minC) : start;
|
|
1819
|
+
emitCellRangeToYdoc(ctx, id, d, 0, d.length - 1, startC, ((_u = (_t = d[0]) === null || _t === void 0 ? void 0 : _t.length) !== null && _u !== void 0 ? _u : 1) - 1);
|
|
1820
|
+
}
|
|
1745
1821
|
if (file.id === ctx.currentSheetId) {
|
|
1746
1822
|
ctx.config = cfg;
|
|
1747
1823
|
} else {}
|
package/es/modules/selection.js
CHANGED
|
@@ -180,7 +180,7 @@ export function selectTitlesRange(map) {
|
|
|
180
180
|
return rangeArr;
|
|
181
181
|
}
|
|
182
182
|
export function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
183
|
-
var _a;
|
|
183
|
+
var _a, _b, _c;
|
|
184
184
|
var cfg = ctx.config;
|
|
185
185
|
if (cfg.merge == null) {
|
|
186
186
|
cfg.merge = {};
|
|
@@ -219,6 +219,7 @@ export function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
|
219
219
|
var timesC = Math.ceil((maxc - minc + 1) / copyc);
|
|
220
220
|
var flowdata = getFlowdata(ctx);
|
|
221
221
|
if (flowdata == null) return;
|
|
222
|
+
var cellChanges = [];
|
|
222
223
|
var cellMaxLength = flowdata[0].length;
|
|
223
224
|
var rowMaxLength = flowdata.length;
|
|
224
225
|
var borderInfoCompute = getBorderInfoCompute(ctx, copySheetIndex);
|
|
@@ -356,6 +357,17 @@ export function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
|
356
357
|
}
|
|
357
358
|
}
|
|
358
359
|
}
|
|
360
|
+
cellChanges.push({
|
|
361
|
+
sheetId: ctx.currentSheetId,
|
|
362
|
+
path: ["celldata"],
|
|
363
|
+
value: {
|
|
364
|
+
r: h,
|
|
365
|
+
c: c,
|
|
366
|
+
v: (_a = x[c]) !== null && _a !== void 0 ? _a : null
|
|
367
|
+
},
|
|
368
|
+
key: "".concat(h, "_").concat(c),
|
|
369
|
+
type: "update"
|
|
370
|
+
});
|
|
359
371
|
};
|
|
360
372
|
for (var c = mtc; c < maxcellCahe; c += 1) {
|
|
361
373
|
_loop_2(c);
|
|
@@ -368,6 +380,9 @@ export function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
|
368
380
|
}
|
|
369
381
|
}
|
|
370
382
|
}
|
|
383
|
+
if (cellChanges.length > 0 && ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc)) {
|
|
384
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
385
|
+
}
|
|
371
386
|
var currFile = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)];
|
|
372
387
|
currFile.config = cfg;
|
|
373
388
|
if (dataVerification != null) {
|
|
@@ -379,7 +394,7 @@ export function pasteHandlerOfPaintModel(ctx, copyRange) {
|
|
|
379
394
|
if (!_.isNil(ruleArr) && ruleArr.length > 0) {
|
|
380
395
|
var currentIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
381
396
|
var existingCf = ctx.luckysheetfile[currentIndex].luckysheet_conditionformat_save;
|
|
382
|
-
var cdformat = (
|
|
397
|
+
var cdformat = (_c = _.cloneDeep(existingCf)) !== null && _c !== void 0 ? _c : [];
|
|
383
398
|
for (var i = 0; i < ruleArr.length; i += 1) {
|
|
384
399
|
var cdformat_cellrange = ruleArr[i].cellrange;
|
|
385
400
|
var emptyRange = [];
|
|
@@ -1501,7 +1516,7 @@ export function copy(ctx) {
|
|
|
1501
1516
|
}
|
|
1502
1517
|
}
|
|
1503
1518
|
export function deleteSelectedCellText(ctx) {
|
|
1504
|
-
var _a, _b, _c, _d;
|
|
1519
|
+
var _a, _b, _c, _d, _e;
|
|
1505
1520
|
var allowEdit = isAllowEdit(ctx);
|
|
1506
1521
|
if (allowEdit === false || ctx.isFlvReadOnly) {
|
|
1507
1522
|
return "allowEdit";
|
|
@@ -1511,6 +1526,7 @@ export function deleteSelectedCellText(ctx) {
|
|
|
1511
1526
|
var d = getFlowdata(ctx);
|
|
1512
1527
|
if (!d) return "dataNullError";
|
|
1513
1528
|
var has_PartMC = false;
|
|
1529
|
+
var cellChanges = [];
|
|
1514
1530
|
for (var s = 0; s < selection.length; s += 1) {
|
|
1515
1531
|
var r1 = selection[s].row[0];
|
|
1516
1532
|
var r2 = selection[s].row[1];
|
|
@@ -1571,15 +1587,21 @@ export function deleteSelectedCellText(ctx) {
|
|
|
1571
1587
|
r: r,
|
|
1572
1588
|
c: c,
|
|
1573
1589
|
v: d[r][c]
|
|
1574
|
-
}
|
|
1590
|
+
},
|
|
1591
|
+
key: "".concat(r, "_").concat(c),
|
|
1592
|
+
type: "update"
|
|
1575
1593
|
});
|
|
1576
1594
|
}
|
|
1577
1595
|
}
|
|
1596
|
+
if (changes.length > 0 && ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc)) {
|
|
1597
|
+
ctx.hooks.updateCellYdoc(changes);
|
|
1598
|
+
}
|
|
1578
1599
|
}
|
|
1579
1600
|
}
|
|
1580
1601
|
return "success";
|
|
1581
1602
|
}
|
|
1582
1603
|
export function deleteSelectedCellFormat(ctx) {
|
|
1604
|
+
var _a;
|
|
1583
1605
|
var allowEdit = isAllowEdit(ctx);
|
|
1584
1606
|
if (allowEdit === false) {
|
|
1585
1607
|
return "allowEdit";
|
|
@@ -1602,6 +1624,7 @@ export function deleteSelectedCellFormat(ctx) {
|
|
|
1602
1624
|
if (has_PartMC) {
|
|
1603
1625
|
return "partMC";
|
|
1604
1626
|
}
|
|
1627
|
+
var cellChanges = [];
|
|
1605
1628
|
for (var s = 0; s < selection.length; s += 1) {
|
|
1606
1629
|
var r1 = selection[s].row[0];
|
|
1607
1630
|
var r2 = selection[s].row[1];
|
|
@@ -1620,10 +1643,24 @@ export function deleteSelectedCellFormat(ctx) {
|
|
|
1620
1643
|
delete cell.bg;
|
|
1621
1644
|
delete cell.tb;
|
|
1622
1645
|
}
|
|
1646
|
+
cellChanges.push({
|
|
1647
|
+
sheetId: ctx.currentSheetId,
|
|
1648
|
+
path: ["celldata"],
|
|
1649
|
+
value: {
|
|
1650
|
+
r: r,
|
|
1651
|
+
c: c,
|
|
1652
|
+
v: d[r][c]
|
|
1653
|
+
},
|
|
1654
|
+
key: "".concat(r, "_").concat(c),
|
|
1655
|
+
type: "update"
|
|
1656
|
+
});
|
|
1623
1657
|
}
|
|
1624
1658
|
}
|
|
1625
1659
|
}
|
|
1626
1660
|
}
|
|
1661
|
+
if (cellChanges.length > 0 && ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc)) {
|
|
1662
|
+
ctx.hooks.updateCellYdoc(cellChanges);
|
|
1663
|
+
}
|
|
1627
1664
|
}
|
|
1628
1665
|
return "success";
|
|
1629
1666
|
}
|