@fileverse-dev/fortune-core 1.3.10 → 1.3.11-input-ref-1
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/range.js +20 -0
- package/es/api/sheet.js +30 -2
- package/es/events/keyboard.js +50 -15
- package/es/events/mouse.js +62 -40
- package/es/events/paste.js +77 -28
- package/es/modules/cell.js +60 -2
- package/es/modules/comment.js +129 -24
- package/es/modules/dataVerification.js +34 -1
- package/es/modules/dropCell.js +65 -1
- package/es/modules/formula.d.ts +11 -0
- package/es/modules/formula.js +390 -47
- package/es/modules/hyperlink.js +52 -5
- package/es/modules/merge.js +93 -1
- package/es/modules/moveCells.js +35 -9
- package/es/modules/rowcol.js +75 -2
- package/es/modules/searchReplace.js +58 -2
- package/es/modules/selection.js +152 -42
- package/es/modules/sort.js +74 -9
- package/es/modules/splitColumn.js +21 -0
- package/es/modules/toolbar.js +46 -3
- package/es/settings.d.ts +5 -0
- package/lib/api/range.js +20 -0
- package/lib/api/sheet.js +29 -1
- package/lib/events/keyboard.js +49 -14
- package/lib/events/mouse.js +61 -39
- package/lib/events/paste.js +77 -28
- package/lib/modules/cell.js +60 -2
- package/lib/modules/comment.js +129 -24
- package/lib/modules/dataVerification.js +34 -1
- package/lib/modules/dropCell.js +65 -1
- package/lib/modules/formula.d.ts +11 -0
- package/lib/modules/formula.js +399 -47
- package/lib/modules/hyperlink.js +52 -5
- package/lib/modules/merge.js +93 -1
- package/lib/modules/moveCells.js +35 -9
- package/lib/modules/rowcol.js +75 -2
- package/lib/modules/searchReplace.js +58 -2
- package/lib/modules/selection.js +152 -42
- package/lib/modules/sort.js +74 -9
- package/lib/modules/splitColumn.js +21 -0
- package/lib/modules/toolbar.js +46 -3
- package/lib/settings.d.ts +5 -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, _t;
|
|
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;
|
|
@@ -1069,6 +1100,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1069
1100
|
value.m = "Loading...";
|
|
1070
1101
|
}
|
|
1071
1102
|
}
|
|
1103
|
+
var afterHookCalled = false;
|
|
1072
1104
|
if (!_.isNil(value) && !_.isNil(value.f)) {
|
|
1073
1105
|
var adjustedFormula = value.f;
|
|
1074
1106
|
var isError = false;
|
|
@@ -1121,6 +1153,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1121
1153
|
v: arr.length === 1 ? funcV[1] : value.v,
|
|
1122
1154
|
m: funcV[1] instanceof Promise ? "[object Promise]" : funcV[1]
|
|
1123
1155
|
}));
|
|
1156
|
+
afterHookCalled = true;
|
|
1124
1157
|
}
|
|
1125
1158
|
}
|
|
1126
1159
|
if (!_.isNil(value.spl)) {}
|
|
@@ -1141,6 +1174,19 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1141
1174
|
};
|
|
1142
1175
|
}
|
|
1143
1176
|
}
|
|
1177
|
+
if (!(((_k = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _k === void 0 ? void 0 : _k.afterUpdateCell) && afterHookCalled)) {
|
|
1178
|
+
changes.push({
|
|
1179
|
+
sheetId: ctx.currentSheetId,
|
|
1180
|
+
path: ["celldata"],
|
|
1181
|
+
value: {
|
|
1182
|
+
r: h,
|
|
1183
|
+
c: c,
|
|
1184
|
+
v: d[h][c]
|
|
1185
|
+
},
|
|
1186
|
+
key: "".concat(h, "_").concat(c),
|
|
1187
|
+
type: "update"
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1144
1190
|
}
|
|
1145
1191
|
d[h] = x;
|
|
1146
1192
|
}
|
|
@@ -1152,7 +1198,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1152
1198
|
var a_file = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)];
|
|
1153
1199
|
var ruleArr_cf = _.cloneDeep(c_file.luckysheet_conditionformat_save);
|
|
1154
1200
|
if (!_.isNil(ruleArr_cf) && ruleArr_cf.length > 0) {
|
|
1155
|
-
cdformat = (
|
|
1201
|
+
cdformat = (_l = _.cloneDeep(a_file.luckysheet_conditionformat_save)) !== null && _l !== void 0 ? _l : [];
|
|
1156
1202
|
for (var i = 0; i < ruleArr_cf.length; i += 1) {
|
|
1157
1203
|
var cf_range = ruleArr_cf[i].cellrange;
|
|
1158
1204
|
var emptyRange = [];
|
|
@@ -1188,8 +1234,8 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1188
1234
|
file.config = cfg;
|
|
1189
1235
|
file.luckysheet_conditionformat_save = cdformat;
|
|
1190
1236
|
file.dataVerification = __assign(__assign({}, file.dataVerification), dataVerification);
|
|
1191
|
-
if (((
|
|
1192
|
-
var srcIndex = getSheetIndex(ctx, (
|
|
1237
|
+
if (((_m = ctx.luckysheet_select_save) === null || _m === void 0 ? void 0 : _m.length) === 1 && ((_o = ctx.luckysheet_copy_save) === null || _o === void 0 ? void 0 : _o.copyRange.length) === 1) {
|
|
1238
|
+
var srcIndex = getSheetIndex(ctx, (_p = ctx.luckysheet_copy_save) === null || _p === void 0 ? void 0 : _p.dataSheetId);
|
|
1193
1239
|
var targetSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
1194
1240
|
var srcHyperlinks = ctx.luckysheetfile[srcIndex].hyperlink;
|
|
1195
1241
|
var srcData = ctx.luckysheetfile[srcIndex].data;
|
|
@@ -1200,7 +1246,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1200
1246
|
var isSingleCell = copyh === 1 && copyc === 1;
|
|
1201
1247
|
var cachedSrcLinkKey = isSingleCell ? "".concat(c_r1, "_").concat(c_c1) : null;
|
|
1202
1248
|
var cachedSrcLink = isSingleCell && srcHyperlinks ? srcHyperlinks[cachedSrcLinkKey] : null;
|
|
1203
|
-
var cachedSrcCell = isSingleCell && srcData ? (
|
|
1249
|
+
var cachedSrcCell = isSingleCell && srcData ? (_q = srcData[c_r1]) === null || _q === void 0 ? void 0 : _q[c_c1] : null;
|
|
1204
1250
|
for (var th = 1; th <= timesH; th += 1) {
|
|
1205
1251
|
for (var tc = 1; tc <= timesC; tc += 1) {
|
|
1206
1252
|
var linkMth = minh + (th - 1) * copyh;
|
|
@@ -1220,7 +1266,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1220
1266
|
if (!srcLink) continue;
|
|
1221
1267
|
var targetKey = "".concat(h, "_").concat(c);
|
|
1222
1268
|
targetHyperlinks[targetKey] = srcLink;
|
|
1223
|
-
var cell = (
|
|
1269
|
+
var cell = (_r = d[h]) === null || _r === void 0 ? void 0 : _r[c];
|
|
1224
1270
|
if (cell) {
|
|
1225
1271
|
var srcCell = void 0;
|
|
1226
1272
|
if (isSingleCell && cachedSrcCell) {
|
|
@@ -1228,7 +1274,7 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1228
1274
|
} else {
|
|
1229
1275
|
var srcRow = c_r1 + (h - linkMth);
|
|
1230
1276
|
var srcCol = c_c1 + (c - linkMtc);
|
|
1231
|
-
srcCell = (
|
|
1277
|
+
srcCell = (_s = srcData === null || srcData === void 0 ? void 0 : srcData[srcRow]) === null || _s === void 0 ? void 0 : _s[srcCol];
|
|
1232
1278
|
}
|
|
1233
1279
|
cell.hl = {
|
|
1234
1280
|
r: h,
|
|
@@ -1248,6 +1294,9 @@ function pasteHandlerOfCopyPaste(ctx, copyRange) {
|
|
|
1248
1294
|
}
|
|
1249
1295
|
}
|
|
1250
1296
|
}
|
|
1297
|
+
if (changes.length > 0 && ((_t = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _t === void 0 ? void 0 : _t.updateCellYdoc)) {
|
|
1298
|
+
ctx.hooks.updateCellYdoc(changes);
|
|
1299
|
+
}
|
|
1251
1300
|
if (copyRowlChange || addr > 0 || addc > 0) {
|
|
1252
1301
|
jfrefreshgrid(ctx, d, ctx.luckysheet_select_save);
|
|
1253
1302
|
} else {
|
package/es/modules/cell.js
CHANGED
|
@@ -541,6 +541,8 @@ export function cancelNormalSelected(ctx) {
|
|
|
541
541
|
ctx.formulaCache.rangestart = false;
|
|
542
542
|
ctx.formulaCache.rangedrag_column_start = false;
|
|
543
543
|
ctx.formulaCache.rangedrag_row_start = false;
|
|
544
|
+
ctx.formulaCache.rangeSelectionActive = null;
|
|
545
|
+
ctx.formulaCache.formulaEditorOwner = null;
|
|
544
546
|
}
|
|
545
547
|
export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
546
548
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
@@ -809,7 +811,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
|
|
|
809
811
|
var newValue_1 = _.cloneDeep(d[r][c]);
|
|
810
812
|
setTimeout(function () {
|
|
811
813
|
var _a, _b;
|
|
812
|
-
return (_b = (_a = ctx.hooks).afterUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c,
|
|
814
|
+
return (_b = (_a = ctx.hooks).afterUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, oldValue_1, newValue_1);
|
|
813
815
|
});
|
|
814
816
|
}
|
|
815
817
|
ctx.formulaCache.execFunctionGlobalData = null;
|
|
@@ -1262,13 +1264,16 @@ function keepOnlyValueParts(cell) {
|
|
|
1262
1264
|
} : null;
|
|
1263
1265
|
}
|
|
1264
1266
|
export function clearSelectedCellFormat(ctx) {
|
|
1267
|
+
var _a;
|
|
1265
1268
|
var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
1266
1269
|
if (activeSheetIndex == null) return;
|
|
1270
|
+
var changeMap = new Map();
|
|
1267
1271
|
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1268
1272
|
var selectedRanges = ctx.luckysheet_select_save;
|
|
1269
1273
|
if (!activeSheetFile || !selectedRanges) return;
|
|
1270
1274
|
var sheetData = activeSheetFile.data;
|
|
1271
1275
|
selectedRanges.forEach(function (_a) {
|
|
1276
|
+
var _b;
|
|
1272
1277
|
var rowRange = _a.row,
|
|
1273
1278
|
columnRange = _a.column;
|
|
1274
1279
|
var startRow = rowRange[0],
|
|
@@ -1281,20 +1286,38 @@ export function clearSelectedCellFormat(ctx) {
|
|
|
1281
1286
|
for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
|
|
1282
1287
|
if (rowCells[columnIndex] === undefined) continue;
|
|
1283
1288
|
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1289
|
+
var v = (_b = rowCells[columnIndex]) !== null && _b !== void 0 ? _b : null;
|
|
1290
|
+
var key = "".concat(rowIndex, "_").concat(columnIndex);
|
|
1291
|
+
changeMap.set(key, {
|
|
1292
|
+
sheetId: ctx.currentSheetId,
|
|
1293
|
+
path: ["celldata"],
|
|
1294
|
+
key: key,
|
|
1295
|
+
value: {
|
|
1296
|
+
r: rowIndex,
|
|
1297
|
+
c: columnIndex,
|
|
1298
|
+
v: v
|
|
1299
|
+
},
|
|
1300
|
+
type: v == null ? "delete" : "update"
|
|
1301
|
+
});
|
|
1284
1302
|
}
|
|
1285
1303
|
}
|
|
1286
1304
|
});
|
|
1305
|
+
if (((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) && changeMap.size > 0) {
|
|
1306
|
+
ctx.hooks.updateCellYdoc(Array.from(changeMap.values()));
|
|
1307
|
+
}
|
|
1287
1308
|
}
|
|
1288
1309
|
export function clearRowsCellsFormat(ctx) {
|
|
1289
|
-
var _a, _b;
|
|
1310
|
+
var _a, _b, _c;
|
|
1290
1311
|
var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
1291
1312
|
if (activeSheetIndex == null) return;
|
|
1313
|
+
var changeMap = new Map();
|
|
1292
1314
|
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1293
1315
|
var selectedRanges = ctx.luckysheet_select_save;
|
|
1294
1316
|
if (!activeSheetFile || !selectedRanges) return;
|
|
1295
1317
|
var sheetData = activeSheetFile.data;
|
|
1296
1318
|
var columnCount = (_b = (_a = sheetData === null || sheetData === void 0 ? void 0 : sheetData[0]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
1297
1319
|
selectedRanges.forEach(function (_a) {
|
|
1320
|
+
var _b;
|
|
1298
1321
|
var rowRange = _a.row;
|
|
1299
1322
|
var startRow = rowRange[0],
|
|
1300
1323
|
endRow = rowRange[1];
|
|
@@ -1304,19 +1327,38 @@ export function clearRowsCellsFormat(ctx) {
|
|
|
1304
1327
|
for (var columnIndex = 0; columnIndex < columnCount; columnIndex++) {
|
|
1305
1328
|
if (rowCells[columnIndex] === undefined) continue;
|
|
1306
1329
|
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1330
|
+
var v = (_b = rowCells[columnIndex]) !== null && _b !== void 0 ? _b : null;
|
|
1331
|
+
var key = "".concat(rowIndex, "_").concat(columnIndex);
|
|
1332
|
+
changeMap.set(key, {
|
|
1333
|
+
sheetId: ctx.currentSheetId,
|
|
1334
|
+
path: ["celldata"],
|
|
1335
|
+
key: key,
|
|
1336
|
+
value: {
|
|
1337
|
+
r: rowIndex,
|
|
1338
|
+
c: columnIndex,
|
|
1339
|
+
v: v
|
|
1340
|
+
},
|
|
1341
|
+
type: v == null ? "delete" : "update"
|
|
1342
|
+
});
|
|
1307
1343
|
}
|
|
1308
1344
|
}
|
|
1309
1345
|
});
|
|
1346
|
+
if (((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) && changeMap.size > 0) {
|
|
1347
|
+
ctx.hooks.updateCellYdoc(Array.from(changeMap.values()));
|
|
1348
|
+
}
|
|
1310
1349
|
}
|
|
1311
1350
|
export function clearColumnsCellsFormat(ctx) {
|
|
1351
|
+
var _a;
|
|
1312
1352
|
var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
|
|
1313
1353
|
if (activeSheetIndex == null) return;
|
|
1354
|
+
var changeMap = new Map();
|
|
1314
1355
|
var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
|
|
1315
1356
|
var selectedRanges = ctx.luckysheet_select_save;
|
|
1316
1357
|
if (!activeSheetFile || !selectedRanges) return;
|
|
1317
1358
|
var sheetData = activeSheetFile.data;
|
|
1318
1359
|
var rowCount = sheetData.length;
|
|
1319
1360
|
selectedRanges.forEach(function (_a) {
|
|
1361
|
+
var _b;
|
|
1320
1362
|
var columnRange = _a.column;
|
|
1321
1363
|
var startColumn = columnRange[0],
|
|
1322
1364
|
endColumn = columnRange[1];
|
|
@@ -1326,7 +1368,23 @@ export function clearColumnsCellsFormat(ctx) {
|
|
|
1326
1368
|
for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
|
|
1327
1369
|
if (rowCells[columnIndex] === undefined) continue;
|
|
1328
1370
|
rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
|
|
1371
|
+
var v = (_b = rowCells[columnIndex]) !== null && _b !== void 0 ? _b : null;
|
|
1372
|
+
var key = "".concat(rowIndex, "_").concat(columnIndex);
|
|
1373
|
+
changeMap.set(key, {
|
|
1374
|
+
sheetId: ctx.currentSheetId,
|
|
1375
|
+
path: ["celldata"],
|
|
1376
|
+
key: key,
|
|
1377
|
+
value: {
|
|
1378
|
+
r: rowIndex,
|
|
1379
|
+
c: columnIndex,
|
|
1380
|
+
v: v
|
|
1381
|
+
},
|
|
1382
|
+
type: v == null ? "delete" : "update"
|
|
1383
|
+
});
|
|
1329
1384
|
}
|
|
1330
1385
|
}
|
|
1331
1386
|
});
|
|
1387
|
+
if (((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) && changeMap.size > 0) {
|
|
1388
|
+
ctx.hooks.updateCellYdoc(Array.from(changeMap.values()));
|
|
1389
|
+
}
|
|
1332
1390
|
}
|
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
|
}
|