@fileverse-dev/fortune-core 1.3.10 → 1.3.11-input-ref

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.
Files changed (43) hide show
  1. package/es/api/range.js +20 -0
  2. package/es/api/sheet.js +30 -2
  3. package/es/events/keyboard.js +50 -15
  4. package/es/events/mouse.js +36 -20
  5. package/es/events/paste.js +77 -28
  6. package/es/modules/cell.js +59 -2
  7. package/es/modules/comment.js +129 -24
  8. package/es/modules/dataVerification.js +34 -1
  9. package/es/modules/dropCell.js +65 -1
  10. package/es/modules/formula.d.ts +7 -0
  11. package/es/modules/formula.js +356 -45
  12. package/es/modules/hyperlink.js +52 -5
  13. package/es/modules/merge.js +93 -1
  14. package/es/modules/moveCells.js +35 -9
  15. package/es/modules/rowcol.js +75 -2
  16. package/es/modules/searchReplace.js +58 -2
  17. package/es/modules/selection.js +152 -42
  18. package/es/modules/sort.js +74 -9
  19. package/es/modules/splitColumn.js +21 -0
  20. package/es/modules/toolbar.js +46 -3
  21. package/es/settings.d.ts +5 -0
  22. package/lib/api/range.js +20 -0
  23. package/lib/api/sheet.js +29 -1
  24. package/lib/events/keyboard.js +49 -14
  25. package/lib/events/mouse.js +35 -19
  26. package/lib/events/paste.js +77 -28
  27. package/lib/modules/cell.js +59 -2
  28. package/lib/modules/comment.js +129 -24
  29. package/lib/modules/dataVerification.js +34 -1
  30. package/lib/modules/dropCell.js +65 -1
  31. package/lib/modules/formula.d.ts +7 -0
  32. package/lib/modules/formula.js +362 -45
  33. package/lib/modules/hyperlink.js +52 -5
  34. package/lib/modules/merge.js +93 -1
  35. package/lib/modules/moveCells.js +35 -9
  36. package/lib/modules/rowcol.js +75 -2
  37. package/lib/modules/searchReplace.js +58 -2
  38. package/lib/modules/selection.js +152 -42
  39. package/lib/modules/sort.js +74 -9
  40. package/lib/modules/splitColumn.js +21 -0
  41. package/lib/modules/toolbar.js +46 -3
  42. package/lib/settings.d.ts +5 -0
  43. package/package.json +1 -1
@@ -541,6 +541,7 @@ 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;
544
545
  }
545
546
  export function updateCell(ctx, r, c, $input, value, canvas) {
546
547
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
@@ -809,7 +810,7 @@ export function updateCell(ctx, r, c, $input, value, canvas) {
809
810
  var newValue_1 = _.cloneDeep(d[r][c]);
810
811
  setTimeout(function () {
811
812
  var _a, _b;
812
- return (_b = (_a = ctx.hooks).afterUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, null, newValue_1);
813
+ return (_b = (_a = ctx.hooks).afterUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, oldValue_1, newValue_1);
813
814
  });
814
815
  }
815
816
  ctx.formulaCache.execFunctionGlobalData = null;
@@ -1262,13 +1263,16 @@ function keepOnlyValueParts(cell) {
1262
1263
  } : null;
1263
1264
  }
1264
1265
  export function clearSelectedCellFormat(ctx) {
1266
+ var _a;
1265
1267
  var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
1266
1268
  if (activeSheetIndex == null) return;
1269
+ var changeMap = new Map();
1267
1270
  var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
1268
1271
  var selectedRanges = ctx.luckysheet_select_save;
1269
1272
  if (!activeSheetFile || !selectedRanges) return;
1270
1273
  var sheetData = activeSheetFile.data;
1271
1274
  selectedRanges.forEach(function (_a) {
1275
+ var _b;
1272
1276
  var rowRange = _a.row,
1273
1277
  columnRange = _a.column;
1274
1278
  var startRow = rowRange[0],
@@ -1281,20 +1285,38 @@ export function clearSelectedCellFormat(ctx) {
1281
1285
  for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
1282
1286
  if (rowCells[columnIndex] === undefined) continue;
1283
1287
  rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
1288
+ var v = (_b = rowCells[columnIndex]) !== null && _b !== void 0 ? _b : null;
1289
+ var key = "".concat(rowIndex, "_").concat(columnIndex);
1290
+ changeMap.set(key, {
1291
+ sheetId: ctx.currentSheetId,
1292
+ path: ["celldata"],
1293
+ key: key,
1294
+ value: {
1295
+ r: rowIndex,
1296
+ c: columnIndex,
1297
+ v: v
1298
+ },
1299
+ type: v == null ? "delete" : "update"
1300
+ });
1284
1301
  }
1285
1302
  }
1286
1303
  });
1304
+ if (((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) && changeMap.size > 0) {
1305
+ ctx.hooks.updateCellYdoc(Array.from(changeMap.values()));
1306
+ }
1287
1307
  }
1288
1308
  export function clearRowsCellsFormat(ctx) {
1289
- var _a, _b;
1309
+ var _a, _b, _c;
1290
1310
  var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
1291
1311
  if (activeSheetIndex == null) return;
1312
+ var changeMap = new Map();
1292
1313
  var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
1293
1314
  var selectedRanges = ctx.luckysheet_select_save;
1294
1315
  if (!activeSheetFile || !selectedRanges) return;
1295
1316
  var sheetData = activeSheetFile.data;
1296
1317
  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
1318
  selectedRanges.forEach(function (_a) {
1319
+ var _b;
1298
1320
  var rowRange = _a.row;
1299
1321
  var startRow = rowRange[0],
1300
1322
  endRow = rowRange[1];
@@ -1304,19 +1326,38 @@ export function clearRowsCellsFormat(ctx) {
1304
1326
  for (var columnIndex = 0; columnIndex < columnCount; columnIndex++) {
1305
1327
  if (rowCells[columnIndex] === undefined) continue;
1306
1328
  rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
1329
+ var v = (_b = rowCells[columnIndex]) !== null && _b !== void 0 ? _b : null;
1330
+ var key = "".concat(rowIndex, "_").concat(columnIndex);
1331
+ changeMap.set(key, {
1332
+ sheetId: ctx.currentSheetId,
1333
+ path: ["celldata"],
1334
+ key: key,
1335
+ value: {
1336
+ r: rowIndex,
1337
+ c: columnIndex,
1338
+ v: v
1339
+ },
1340
+ type: v == null ? "delete" : "update"
1341
+ });
1307
1342
  }
1308
1343
  }
1309
1344
  });
1345
+ if (((_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc) && changeMap.size > 0) {
1346
+ ctx.hooks.updateCellYdoc(Array.from(changeMap.values()));
1347
+ }
1310
1348
  }
1311
1349
  export function clearColumnsCellsFormat(ctx) {
1350
+ var _a;
1312
1351
  var activeSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
1313
1352
  if (activeSheetIndex == null) return;
1353
+ var changeMap = new Map();
1314
1354
  var activeSheetFile = ctx.luckysheetfile[activeSheetIndex];
1315
1355
  var selectedRanges = ctx.luckysheet_select_save;
1316
1356
  if (!activeSheetFile || !selectedRanges) return;
1317
1357
  var sheetData = activeSheetFile.data;
1318
1358
  var rowCount = sheetData.length;
1319
1359
  selectedRanges.forEach(function (_a) {
1360
+ var _b;
1320
1361
  var columnRange = _a.column;
1321
1362
  var startColumn = columnRange[0],
1322
1363
  endColumn = columnRange[1];
@@ -1326,7 +1367,23 @@ export function clearColumnsCellsFormat(ctx) {
1326
1367
  for (var columnIndex = startColumn; columnIndex <= endColumn; columnIndex++) {
1327
1368
  if (rowCells[columnIndex] === undefined) continue;
1328
1369
  rowCells[columnIndex] = keepOnlyValueParts(rowCells[columnIndex]);
1370
+ var v = (_b = rowCells[columnIndex]) !== null && _b !== void 0 ? _b : null;
1371
+ var key = "".concat(rowIndex, "_").concat(columnIndex);
1372
+ changeMap.set(key, {
1373
+ sheetId: ctx.currentSheetId,
1374
+ path: ["celldata"],
1375
+ key: key,
1376
+ value: {
1377
+ r: rowIndex,
1378
+ c: columnIndex,
1379
+ v: v
1380
+ },
1381
+ type: v == null ? "delete" : "update"
1382
+ });
1329
1383
  }
1330
1384
  }
1331
1385
  });
1386
+ if (((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) && changeMap.size > 0) {
1387
+ ctx.hooks.updateCellYdoc(Array.from(changeMap.values()));
1388
+ }
1332
1389
  }
@@ -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 _c = allComments[i],
319
- r = _c.r,
320
- c = _c.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 _d = allComments[i],
331
- r = _d.r,
332
- c = _d.c;
333
- var comment = (_b = flowdata[r][c]) === null || _b === void 0 ? void 0 : _b.ps;
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 _b = globalCache.commentBox,
503
- resizingId = _b.resizingId,
504
- _c = _b.commentRC,
505
- r = _c.r,
506
- c = _c.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 _b = globalCache.commentBox,
576
- movingId = _b.movingId,
577
- _c = _b.commentRC,
578
- r = _c.r,
579
- c = _c.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
  }
@@ -229,7 +229,7 @@ export function validateCellData(ctx, item, cellValue) {
229
229
  return true;
230
230
  }
231
231
  export function checkboxChange(ctx, r, c) {
232
- var _a;
232
+ var _a, _b, _c, _d;
233
233
  var index = getSheetIndex(ctx, ctx.currentSheetId);
234
234
  var currentDataVerification = (_a = ctx.luckysheetfile[index].dataVerification) !== null && _a !== void 0 ? _a : {};
235
235
  var item = currentDataVerification["".concat(r, "_").concat(c)];
@@ -240,6 +240,25 @@ export function checkboxChange(ctx, r, c) {
240
240
  }
241
241
  var d = getFlowdata(ctx);
242
242
  setCellValue(ctx, r, c, d, value);
243
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
244
+ ctx.hooks.updateCellYdoc([{
245
+ sheetId: ctx.currentSheetId,
246
+ path: ["celldata"],
247
+ value: {
248
+ r: r,
249
+ c: c,
250
+ v: (_d = (_c = d === null || d === void 0 ? void 0 : d[r]) === null || _c === void 0 ? void 0 : _c[c]) !== null && _d !== void 0 ? _d : null
251
+ },
252
+ key: "".concat(r, "_").concat(c),
253
+ type: "update"
254
+ }, {
255
+ sheetId: ctx.currentSheetId,
256
+ path: ["dataVerification"],
257
+ key: "".concat(r, "_").concat(c),
258
+ value: JSON.parse(JSON.stringify(item)),
259
+ type: "update"
260
+ }]);
261
+ }
243
262
  }
244
263
  export function getFailureText(ctx, item) {
245
264
  var _a, _b, _c, _d, _e;
@@ -587,6 +606,7 @@ export function cellFocus(ctx, r, c, clickMode) {
587
606
  }
588
607
  export function setDropdownValue(ctx, value, arr) {
589
608
  var _a;
609
+ var _b, _c, _d;
590
610
  if (!ctx.luckysheet_select_save) return;
591
611
  var d = getFlowdata(ctx);
592
612
  if (!d) return;
@@ -632,6 +652,19 @@ export function setDropdownValue(ctx, value, arr) {
632
652
  v: value,
633
653
  pillColor: selectedColor
634
654
  });
655
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
656
+ ctx.hooks.updateCellYdoc([{
657
+ sheetId: ctx.currentSheetId,
658
+ path: ["celldata"],
659
+ value: {
660
+ r: rowIndex,
661
+ c: colIndex,
662
+ v: (_d = (_c = d === null || d === void 0 ? void 0 : d[rowIndex]) === null || _c === void 0 ? void 0 : _c[colIndex]) !== null && _d !== void 0 ? _d : null
663
+ },
664
+ key: "".concat(rowIndex, "_").concat(colIndex),
665
+ type: "update"
666
+ }]);
667
+ }
635
668
  var currentRowHeight = getRowHeight(ctx, [rowIndex])[rowIndex];
636
669
  var newHeight = 22 * (value.split(",").length || (valueData === null || valueData === void 0 ? void 0 : valueData.length)) || 22;
637
670
  if (currentRowHeight < newHeight) {
@@ -1779,7 +1779,7 @@ function getApplyData(copyD, csLen, asLen) {
1779
1779
  }
1780
1780
  export function updateDropCell(ctx) {
1781
1781
  var _a, _b, _c, _d;
1782
- var _e, _f, _g;
1782
+ var _e, _f, _g, _h;
1783
1783
  var d = getFlowdata(ctx);
1784
1784
  var allowEdit = isAllowEdit(ctx);
1785
1785
  var isReadOnly = isAllowEditReadOnly(ctx);
@@ -1815,6 +1815,7 @@ export function updateDropCell(ctx) {
1815
1815
  var apply_end_r = applyRange.row[1];
1816
1816
  var apply_str_c = applyRange.column[0];
1817
1817
  var apply_end_c = applyRange.column[1];
1818
+ var cellChanges = [];
1818
1819
  if (direction === "down" || direction === "up") {
1819
1820
  var asLen = apply_end_r - apply_str_r + 1;
1820
1821
  for (var i = apply_str_c; i <= apply_end_c; i += 1) {
@@ -1825,6 +1826,7 @@ export function updateDropCell(ctx) {
1825
1826
  for (var j = apply_str_r; j <= apply_end_r; j += 1) {
1826
1827
  if (hiddenRows.has("".concat(j))) continue;
1827
1828
  var cell = applyData[j - apply_str_r];
1829
+ var afterHookCalled = false;
1828
1830
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
1829
1831
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "down", j - apply_str_r + 1));
1830
1832
  var v = formula.execfunction(ctx, f, j, i);
@@ -1836,6 +1838,7 @@ export function updateDropCell(ctx) {
1836
1838
  v: v[1] instanceof Promise ? v[1] : cell.v,
1837
1839
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
1838
1840
  }));
1841
+ afterHookCalled = true;
1839
1842
  }
1840
1843
  if (cell.spl != null) {
1841
1844
  cell.spl = v[3].data;
@@ -1873,6 +1876,19 @@ export function updateDropCell(ctx) {
1873
1876
  }
1874
1877
  }
1875
1878
  d[j][i] = cell || null;
1879
+ if (!afterHookCalled) {
1880
+ cellChanges.push({
1881
+ sheetId: ctx.currentSheetId,
1882
+ path: ["celldata"],
1883
+ value: {
1884
+ r: j,
1885
+ c: i,
1886
+ v: d[j][i]
1887
+ },
1888
+ key: "".concat(j, "_").concat(i),
1889
+ type: "update"
1890
+ });
1891
+ }
1876
1892
  var bd_r = copy_str_r + (j - apply_str_r) % csLen;
1877
1893
  var bd_c = i;
1878
1894
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -1911,6 +1927,7 @@ export function updateDropCell(ctx) {
1911
1927
  for (var j = apply_end_r; j >= apply_str_r; j -= 1) {
1912
1928
  if (hiddenRows.has("".concat(j))) continue;
1913
1929
  var cell = applyData[apply_end_r - j];
1930
+ var afterHookCalled = false;
1914
1931
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
1915
1932
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "up", apply_end_r - j + 1));
1916
1933
  var v = formula.execfunction(ctx, f, j, i);
@@ -1922,6 +1939,7 @@ export function updateDropCell(ctx) {
1922
1939
  v: v[1] instanceof Promise ? v[1] : cell.v,
1923
1940
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
1924
1941
  }));
1942
+ afterHookCalled = true;
1925
1943
  }
1926
1944
  if (cell.spl != null) {
1927
1945
  cell.spl = v[3].data;
@@ -1953,6 +1971,19 @@ export function updateDropCell(ctx) {
1953
1971
  }
1954
1972
  }
1955
1973
  d[j][i] = cell || null;
1974
+ if (!afterHookCalled) {
1975
+ cellChanges.push({
1976
+ sheetId: ctx.currentSheetId,
1977
+ path: ["celldata"],
1978
+ value: {
1979
+ r: j,
1980
+ c: i,
1981
+ v: d[j][i]
1982
+ },
1983
+ key: "".concat(j, "_").concat(i),
1984
+ type: "update"
1985
+ });
1986
+ }
1956
1987
  var bd_r = copy_end_r - (apply_end_r - j) % csLen;
1957
1988
  var bd_c = i;
1958
1989
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -1998,6 +2029,7 @@ export function updateDropCell(ctx) {
1998
2029
  for (var j = apply_str_c; j <= apply_end_c; j += 1) {
1999
2030
  if (hiddenCols.has("".concat(j))) continue;
2000
2031
  var cell = applyData[j - apply_str_c];
2032
+ var afterHookCalled = false;
2001
2033
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
2002
2034
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "right", j - apply_str_c + 1));
2003
2035
  var v = formula.execfunction(ctx, f, i, j);
@@ -2009,6 +2041,7 @@ export function updateDropCell(ctx) {
2009
2041
  v: v[1] instanceof Promise ? v[1] : cell.v,
2010
2042
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
2011
2043
  }));
2044
+ afterHookCalled = true;
2012
2045
  }
2013
2046
  if (cell.spl != null) {
2014
2047
  cell.spl = v[3].data;
@@ -2040,6 +2073,19 @@ export function updateDropCell(ctx) {
2040
2073
  }
2041
2074
  }
2042
2075
  d[i][j] = cell || null;
2076
+ if (!afterHookCalled) {
2077
+ cellChanges.push({
2078
+ sheetId: ctx.currentSheetId,
2079
+ path: ["celldata"],
2080
+ value: {
2081
+ r: i,
2082
+ c: j,
2083
+ v: d[i][j]
2084
+ },
2085
+ key: "".concat(i, "_").concat(j),
2086
+ type: "update"
2087
+ });
2088
+ }
2043
2089
  var bd_r = i;
2044
2090
  var bd_c = copy_str_c + (j - apply_str_c) % csLen;
2045
2091
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2078,6 +2124,7 @@ export function updateDropCell(ctx) {
2078
2124
  for (var j = apply_end_c; j >= apply_str_c; j -= 1) {
2079
2125
  if (hiddenCols.has("".concat(j))) continue;
2080
2126
  var cell = applyData[apply_end_c - j];
2127
+ var afterHookCalled = false;
2081
2128
  if ((cell === null || cell === void 0 ? void 0 : cell.f) != null) {
2082
2129
  var f = "=".concat(formula.functionCopy(ctx, cell.f, "left", apply_end_c - j + 1));
2083
2130
  var v = formula.execfunction(ctx, f, i, j);
@@ -2089,6 +2136,7 @@ export function updateDropCell(ctx) {
2089
2136
  v: v[1] instanceof Promise ? v[1] : cell.v,
2090
2137
  m: v[1] instanceof Promise ? "[object Promise]" : v[1]
2091
2138
  }));
2139
+ afterHookCalled = true;
2092
2140
  }
2093
2141
  if (cell.spl != null) {
2094
2142
  cell.spl = v[3].data;
@@ -2120,6 +2168,19 @@ export function updateDropCell(ctx) {
2120
2168
  }
2121
2169
  }
2122
2170
  d[i][j] = cell || null;
2171
+ if (!afterHookCalled) {
2172
+ cellChanges.push({
2173
+ sheetId: ctx.currentSheetId,
2174
+ path: ["celldata"],
2175
+ value: {
2176
+ r: i,
2177
+ c: j,
2178
+ v: d[i][j]
2179
+ },
2180
+ key: "".concat(i, "_").concat(j),
2181
+ type: "update"
2182
+ });
2183
+ }
2123
2184
  var bd_r = i;
2124
2185
  var bd_c = copy_end_c - (apply_end_c - j) % csLen;
2125
2186
  if (borderInfoCompute["".concat(bd_r, "_").concat(bd_c)]) {
@@ -2156,6 +2217,9 @@ export function updateDropCell(ctx) {
2156
2217
  }
2157
2218
  }
2158
2219
  }
2220
+ if (cellChanges.length > 0 && ((_h = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc)) {
2221
+ ctx.hooks.updateCellYdoc(cellChanges);
2222
+ }
2159
2223
  var cdformat = file.luckysheet_conditionformat_save;
2160
2224
  if (cdformat != null && cdformat.length > 0) {
2161
2225
  for (var i = 0; i < cdformat.length; i += 1) {
@@ -20,6 +20,7 @@ export declare class FormulaCache {
20
20
  rangetosheet?: string;
21
21
  rangedrag_column_start?: boolean;
22
22
  rangedrag_row_start?: boolean;
23
+ rangeSelectionActive?: boolean | null;
23
24
  functionRangeIndex?: number[];
24
25
  functionlistMap: any;
25
26
  execFunctionExist?: any[];
@@ -44,8 +45,14 @@ export declare function setCaretPosition(ctx: Context, textDom: HTMLElement, chi
44
45
  export declare function getrangeseleciton(): ParentNode | ChildNode | null | undefined;
45
46
  export declare function rangeHightlightselected(ctx: Context, $editor: HTMLDivElement): void;
46
47
  export declare function functionHTMLGenerate(txt: string): string;
48
+ export declare function getLastFormulaRangeIndex($editor: HTMLDivElement): number | null;
49
+ export declare function getFormulaRangeIndexAtCaret($editor: HTMLDivElement): number | null;
50
+ export declare function markRangeSelectionDirty(ctx: Context): void;
51
+ export declare function getFormulaRangeIndexForKeyboardSync($editor: HTMLDivElement): number | null;
47
52
  export declare function handleFormulaInput(ctx: Context, $copyTo: HTMLDivElement | null | undefined, $editor: HTMLDivElement, kcode: number, preText?: string, refreshRangeSelect?: boolean): void;
48
53
  export declare function israngeseleciton(ctx: Context, istooltip?: boolean): boolean;
54
+ export declare function isFormulaReferenceInputMode(ctx: Context): boolean;
55
+ export declare function maybeRecoverDirtyRangeSelection(ctx: Context): boolean;
49
56
  export declare function functionStrChange(txt: string, type: string, rc: "row" | "col", orient: string | null, stindex: number, step: number): string;
50
57
  export declare function rangeSetValue(ctx: Context, cellInput: HTMLDivElement, selected: any, fxInput?: HTMLDivElement | null): void;
51
58
  export declare function onFormulaRangeDragEnd(ctx: Context): void;