@fileverse-dev/fortune-core 1.3.9 → 1.3.10-copyPaste-2

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/lib/api/cell.js CHANGED
@@ -61,8 +61,8 @@ function getCellValue(ctx, row, column, options) {
61
61
  }
62
62
  return ret;
63
63
  }
64
- function setCellValue(ctx, row, column, value, cellInput, options) {
65
- var _a;
64
+ function setCellValue(ctx, row, column, value, cellInput, options, callAfterUpdate) {
65
+ var _a, _b, _c;
66
66
  if (options === void 0) {
67
67
  options = {};
68
68
  }
@@ -123,7 +123,7 @@ function setCellValue(ctx, row, column, value, cellInput, options) {
123
123
  (0, _modules.setCellValue)(ctx, row, column, data, curv);
124
124
  }
125
125
  _lodash.default.forEach(value, function (v, attr) {
126
- if (attr in formatList) {
126
+ if (attr in formatList && callAfterUpdate) {
127
127
  (0, _modules.updateFormatCell)(ctx, data, attr, v, row, row, column, column);
128
128
  } else {
129
129
  cell_1[attr] = v;
@@ -138,6 +138,9 @@ function setCellValue(ctx, row, column, value, cellInput, options) {
138
138
  (0, _modules.setCellValue)(ctx, row, column, data, value);
139
139
  }
140
140
  }
141
+ if (callAfterUpdate && ctx.hooks.afterUpdateCell) {
142
+ (_c = (_b = ctx.hooks).afterUpdateCell) === null || _c === void 0 ? void 0 : _c.call(_b, row, column, null, value);
143
+ }
141
144
  }
142
145
  function clearCell(ctx, row, column, options) {
143
146
  var _a, _b;
@@ -18,5 +18,5 @@ export declare function getSelectionCoordinates(ctx: Context): string[];
18
18
  export declare function getCellsByRange(ctx: Context, range: Selection, options?: CommonOptions): (Cell | null)[][];
19
19
  export declare function getHtmlByRange(ctx: Context, range: Range, options?: CommonOptions): string | null;
20
20
  export declare function setSelection(ctx: Context, range: Range, options: CommonOptions): void;
21
- export declare function setCellValuesByRange(ctx: Context, data: any[][], range: SingleRange, cellInput: HTMLDivElement | null, options?: CommonOptions): void;
21
+ export declare function setCellValuesByRange(ctx: Context, data: any[][], range: SingleRange, cellInput: HTMLDivElement | null, options?: CommonOptions, callAfterUpdate?: boolean): void;
22
22
  export declare function setCellFormatByRange(ctx: Context, attr: keyof Cell, value: any, range: Range | SingleRange, options?: CommonOptions): void;
package/lib/api/range.js CHANGED
@@ -92,7 +92,7 @@ function setSelection(ctx, range, options) {
92
92
  ctx.luckysheet_select_save = sheet.luckysheet_select_save;
93
93
  }
94
94
  }
95
- function setCellValuesByRange(ctx, data, range, cellInput, options) {
95
+ function setCellValuesByRange(ctx, data, range, cellInput, options, callAfterUpdate) {
96
96
  if (options === void 0) {
97
97
  options = {};
98
98
  }
@@ -114,7 +114,7 @@ function setCellValuesByRange(ctx, data, range, cellInput, options) {
114
114
  for (var j = 0; j < columnCount; j += 1) {
115
115
  var row = range.row[0] + i;
116
116
  var column = range.column[0] + j;
117
- (0, _cell.setCellValue)(ctx, row, column, data[i][j], cellInput, options);
117
+ (0, _cell.setCellValue)(ctx, row, column, data[i][j], cellInput, options, callAfterUpdate);
118
118
  }
119
119
  }
120
120
  }
@@ -94,6 +94,7 @@ function adjustFormulaForPaste(formula, srcCol, srcRow, destCol, destRow) {
94
94
  var stringOrCellRef = /"(?:\\.|[^"])*"|(\$?[A-Z]+\$?\d+)(?!\s*!)\b/g;
95
95
  var result = formula.replace(stringOrCellRef, function (m, cellRef) {
96
96
  if (!cellRef) return m;
97
+ if (cellRef.startsWith("$")) return m;
97
98
  return cellRef.replace(cellRefRegex, function (__, absCol, colLetters, absRow, rowNum) {
98
99
  var colIndex = columnLabelIndex(colLetters);
99
100
  var rowIndex = parseInt(rowNum, 10);
@@ -200,27 +201,42 @@ function postPasteCut(ctx, source, target, RowlChange) {
200
201
  (0, _sheet.storeSheetParamALL)(ctx);
201
202
  }
202
203
  var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
203
- var _a;
204
+ var _a, _b, _c;
205
+ var changes = [];
204
206
  for (var r = 0; r < d.length; r += 1) {
205
207
  var x = d[r];
206
208
  for (var c = 0; c < d[0].length; c += 1) {
207
209
  var value = (0, _lodash.isObject)(d[r][c]) ? (_a = d[r][c]) === null || _a === void 0 ? void 0 : _a.v : d[r][c];
208
210
  if (value && String(value).startsWith("=")) {
209
211
  var cell = {};
210
- var _b = (0, _formula.execfunction)(ctx, String(value), r, c, undefined, undefined, true),
211
- v = _b[1],
212
- f = _b[2];
212
+ var _d = (0, _formula.execfunction)(ctx, String(value), r, c, undefined, undefined, true),
213
+ v = _d[1],
214
+ f = _d[2];
213
215
  cell.v = v;
214
216
  cell.f = f;
215
217
  cell.m = v.toString();
216
218
  x[c] = cell;
217
219
  }
218
220
  d[r] = x;
221
+ changes.push({
222
+ sheetId: ctx.currentSheetId,
223
+ path: ["celldata"],
224
+ value: {
225
+ r: r,
226
+ c: c,
227
+ v: d[r][c]
228
+ },
229
+ key: "".concat(r, "_").concat(c),
230
+ type: "update"
231
+ });
219
232
  }
220
233
  }
234
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
235
+ (_c = ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc(changes);
236
+ }
221
237
  };
222
238
  function pasteHandler(ctx, data, borderInfo) {
223
- var _a, _b, _c, _d, _e, _f;
239
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
224
240
  if (ctx.luckysheet_selection_range) {
225
241
  ctx.luckysheet_selection_range = [];
226
242
  }
@@ -268,6 +284,7 @@ function pasteHandler(ctx, data, borderInfo) {
268
284
  }
269
285
  var RowlChange = false;
270
286
  var offsetMC = {};
287
+ var changes = [];
271
288
  for (var h = minh; h <= maxh; h += 1) {
272
289
  var x = d[h];
273
290
  var currentRowLen = ctx.defaultrowlen;
@@ -315,12 +332,26 @@ function pasteHandler(ctx, data, borderInfo) {
315
332
  };
316
333
  (_e = cfg.borderInfo) === null || _e === void 0 ? void 0 : _e.push(bd_obj);
317
334
  }
335
+ changes.push({
336
+ sheetId: ctx.currentSheetId,
337
+ path: ["celldata"],
338
+ value: {
339
+ r: h,
340
+ c: c,
341
+ v: d[h][c]
342
+ },
343
+ key: "".concat(h, "_").concat(c),
344
+ type: "update"
345
+ });
318
346
  }
319
347
  d[h] = x;
320
348
  if (currentRowLen !== ctx.defaultrowlen) {
321
349
  cfg.rowlen[h] = currentRowLen;
322
350
  }
323
351
  }
352
+ if ((_f = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _f === void 0 ? void 0 : _f.updateCellYdoc) {
353
+ (_g = ctx.hooks) === null || _g === void 0 ? void 0 : _g.updateCellYdoc(changes);
354
+ }
324
355
  ctx.luckysheet_select_save = [{
325
356
  row: [minh, maxh],
326
357
  column: [minc, maxc]
@@ -345,7 +376,7 @@ function pasteHandler(ctx, data, borderInfo) {
345
376
  }
346
377
  var d = (0, _context.getFlowdata)(ctx);
347
378
  if (!d) return;
348
- var last = (_f = ctx.luckysheet_select_save) === null || _f === void 0 ? void 0 : _f[ctx.luckysheet_select_save.length - 1];
379
+ var last = (_h = ctx.luckysheet_select_save) === null || _h === void 0 ? void 0 : _h[ctx.luckysheet_select_save.length - 1];
349
380
  if (!last) return;
350
381
  var curR = last.row == null ? 0 : last.row[0];
351
382
  var curC = last.column == null ? 0 : last.column[0];
@@ -370,6 +401,7 @@ function pasteHandler(ctx, data, borderInfo) {
370
401
  if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
371
402
  return t.startsWith("http") ? t : "https://".concat(t);
372
403
  };
404
+ var changes = [];
373
405
  for (var r = 0; r < rlen; r += 1) {
374
406
  var x = d[r + curR];
375
407
  for (var c = 0; c < clen; c += 1) {
@@ -460,9 +492,23 @@ function pasteHandler(ctx, data, borderInfo) {
460
492
  }
461
493
  x[c + curC] = cell;
462
494
  }
495
+ changes.push(changes.push({
496
+ sheetId: ctx.currentSheetId,
497
+ path: ["celldata"],
498
+ value: {
499
+ r: r,
500
+ c: c,
501
+ v: d[r][c]
502
+ },
503
+ key: "".concat(r, "_").concat(c),
504
+ type: "update"
505
+ }));
463
506
  }
464
507
  d[r + curR] = x;
465
508
  }
509
+ if ((_j = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _j === void 0 ? void 0 : _j.updateCellYdoc) {
510
+ (_k = ctx.hooks) === null || _k === void 0 ? void 0 : _k.updateCellYdoc(changes);
511
+ }
466
512
  last.row = [curR, curR + rlen - 1];
467
513
  last.column = [curC, curC + clen - 1];
468
514
  (0, _refresh.jfrefreshgrid)(ctx, null, undefined);
@@ -1074,7 +1074,7 @@ function getFontStyleByCell(cell, checksAF, checksCF, isCheck) {
1074
1074
  if (key === "it" && valueNum !== 0) {
1075
1075
  style.fontStyle = "italic";
1076
1076
  }
1077
- if (key === "fs" && valueNum !== 10) {
1077
+ if (key === "fs" && !_lodash.default.isNil(value)) {
1078
1078
  style.fontSize = "".concat(valueNum, "pt");
1079
1079
  }
1080
1080
  if (key === "fc" && value !== "#000000" || ((_a = checksAF === null || checksAF === void 0 ? void 0 : checksAF.length) !== null && _a !== void 0 ? _a : 0) > 0 || (checksCF === null || checksCF === void 0 ? void 0 : checksCF.textColor)) {
@@ -2019,7 +2019,6 @@ function updateDropCell(ctx) {
2019
2019
  var v = formula.execfunction(ctx, f, i, j);
2020
2020
  formula.execFunctionGroup(ctx, j, i, v[1], undefined, d);
2021
2021
  cell.v = v[1], cell.f = v[2];
2022
- console.log(j, i);
2023
2022
  var afterUpdateCell = ctx.hooks.afterUpdateCell;
2024
2023
  if (afterUpdateCell) {
2025
2024
  afterUpdateCell(i, j, null, __assign(__assign({}, cell), {
@@ -728,12 +728,6 @@ function replaceDotsInFunctionName(str) {
728
728
  return "=".concat(fixedFnName).concat(str.substring(openParenIndex));
729
729
  }
730
730
  function execfunction(ctx, txt, r, c, id, calcChainSet, isrefresh, notInsertFunc) {
731
- console.log("execfunction:", {
732
- txt: txt,
733
- r: r,
734
- c: c,
735
- id: id
736
- });
737
731
  var originalTxt = txt;
738
732
  if ((txt === null || txt === void 0 ? void 0 : txt.toUpperCase().includes("NETWORKDAYS.INTL")) || (txt === null || txt === void 0 ? void 0 : txt.toUpperCase().includes("WORKDAY.INTL"))) {
739
733
  txt = replaceDotsInFunctionName(txt);
@@ -851,7 +845,6 @@ function execFunctionGroup(ctx, origin_r, origin_c, value, id, data, isForce) {
851
845
  if (isForce === void 0) {
852
846
  isForce = false;
853
847
  }
854
- console.log("execFunctionGroup", origin_r, origin_c, value, id, data);
855
848
  if (_lodash.default.isNil(data)) {
856
849
  data = (0, _context.getFlowdata)(ctx);
857
850
  }
@@ -57,7 +57,7 @@ function getCellHyperlink(ctx, r, c) {
57
57
  return undefined;
58
58
  }
59
59
  function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, options) {
60
- var _a;
60
+ var _a, _b, _c;
61
61
  var applyToSelection = (options === null || options === void 0 ? void 0 : options.applyToSelection) && (options === null || options === void 0 ? void 0 : options.cellInput);
62
62
  var sheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
63
63
  var flowdata = (0, _context.getFlowdata)(ctx);
@@ -107,6 +107,19 @@ function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress, options) {
107
107
  };
108
108
  flowdata[r][c] = cell;
109
109
  ctx.linkCard = undefined;
110
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
111
+ (_c = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc([{
112
+ sheetId: ctx.currentSheetId,
113
+ path: ["celldata"],
114
+ value: {
115
+ r: r,
116
+ c: c,
117
+ v: cell
118
+ },
119
+ key: "".concat(r, "_").concat(c),
120
+ type: "update"
121
+ }]);
122
+ }
110
123
  }
111
124
  }
112
125
  function removeHyperlink(ctx, r, c) {
@@ -1206,7 +1206,7 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
1206
1206
  cpdata += "<tr height=".concat(rowLen, "px >");
1207
1207
  var _loop_3 = function _loop_3(j) {
1208
1208
  var c = colIndexArr[j];
1209
- var column = '<td ${span} style="${style}">';
1209
+ var column = '<td ${span} style="${style}" data-fortune-cell="${cellData}">';
1210
1210
  var cell = (_f = d[r]) === null || _f === void 0 ? void 0 : _f[c];
1211
1211
  if (cell != null) {
1212
1212
  var style = "";
@@ -1417,9 +1417,14 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
1417
1417
  }
1418
1418
  }
1419
1419
  }
1420
+ var cellData = encodeURIComponent(JSON.stringify(__assign(__assign({}, cell), {
1421
+ _srcRow: r,
1422
+ _srcCol: c
1423
+ })));
1420
1424
  column = (0, _utils.replaceHtml)(column, {
1421
1425
  style: style,
1422
- span: span
1426
+ span: span,
1427
+ cellData: cellData
1423
1428
  });
1424
1429
  if (_lodash.default.isNil(c_value)) {
1425
1430
  c_value = (0, _cell.getCellValue)(r, c, d);
@@ -1469,7 +1474,8 @@ function rangeValueToHtml(ctx, sheetId, ranges) {
1469
1474
  }
1470
1475
  column = (0, _utils.replaceHtml)(column, {
1471
1476
  style: style,
1472
- span: ""
1477
+ span: "",
1478
+ cellData: ""
1473
1479
  });
1474
1480
  column += "";
1475
1481
  }
@@ -1536,9 +1542,9 @@ function copy(ctx) {
1536
1542
  }
1537
1543
  }
1538
1544
  function deleteSelectedCellText(ctx) {
1539
- var _a, _b, _c;
1545
+ var _a, _b, _c, _d;
1540
1546
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
1541
- if (allowEdit === false || ctx.isFlvReadOnly) {
1547
+ if (allowEdit === false) {
1542
1548
  return "allowEdit";
1543
1549
  }
1544
1550
  var selection = ctx.luckysheet_select_save;
@@ -1565,6 +1571,7 @@ function deleteSelectedCellText(ctx) {
1565
1571
  var r2 = selection[s].row[1];
1566
1572
  var c1 = selection[s].column[0];
1567
1573
  var c2 = selection[s].column[1];
1574
+ var changes = [];
1568
1575
  for (var r = r1; r <= r2; r += 1) {
1569
1576
  for (var c = c1; c <= c2; c += 1) {
1570
1577
  var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
@@ -1595,6 +1602,18 @@ function deleteSelectedCellText(ctx) {
1595
1602
  if (hyperlinkMap && hyperlinkMap["".concat(r, "_").concat(c)]) {
1596
1603
  delete hyperlinkMap["".concat(r, "_").concat(c)];
1597
1604
  }
1605
+ if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.afterUpdateCell) {
1606
+ ctx.hooks.afterUpdateCell(r, c, null, d[r][c]);
1607
+ }
1608
+ changes.push({
1609
+ sheetId: ctx.currentSheetId,
1610
+ path: ["celldata"],
1611
+ value: {
1612
+ r: r,
1613
+ c: c,
1614
+ v: d[r][c]
1615
+ }
1616
+ });
1598
1617
  }
1599
1618
  }
1600
1619
  }
@@ -16,6 +16,16 @@ var _sheet = require("../api/sheet");
16
16
  var _locale = require("../locale");
17
17
  var _utils = require("../utils");
18
18
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
+ var __assign = void 0 && (void 0).__assign || function () {
20
+ __assign = Object.assign || function (t) {
21
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
22
+ s = arguments[i];
23
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
24
+ }
25
+ return t;
26
+ };
27
+ return __assign.apply(this, arguments);
28
+ };
19
29
  function storeSheetParam(ctx) {
20
30
  var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
21
31
  if (index == null) return;
@@ -32,7 +42,7 @@ function storeSheetParamALL(ctx) {
32
42
  ctx.luckysheetfile[index].config = ctx.config;
33
43
  }
34
44
  function changeSheet(ctx, id, isPivotInitial, isNewSheet, isCopySheet) {
35
- var _a, _b;
45
+ var _a, _b, _c, _d;
36
46
  if (id === ctx.currentSheetId) {
37
47
  return;
38
48
  }
@@ -48,14 +58,11 @@ function changeSheet(ctx, id, isPivotInitial, isNewSheet, isCopySheet) {
48
58
  ctx.luckysheetcurrentisPivotTable = false;
49
59
  }
50
60
  if (ctx.hooks.afterActivateSheet) {
51
- setTimeout(function () {
52
- var _a, _b;
53
- (_b = (_a = ctx.hooks).afterActivateSheet) === null || _b === void 0 ? void 0 : _b.call(_a, id);
54
- });
61
+ (_d = (_c = ctx.hooks).afterActivateSheet) === null || _d === void 0 ? void 0 : _d.call(_c, id);
55
62
  }
56
63
  }
57
64
  function addSheet(ctx, settings, newSheetID, isPivotTable, sheetName, sheetData) {
58
- var _a, _b;
65
+ var _a, _b, _c, _d;
59
66
  if (newSheetID === void 0) {
60
67
  newSheetID = undefined;
61
68
  }
@@ -99,18 +106,12 @@ function addSheet(ctx, settings, newSheetID, isPivotTable, sheetName, sheetData)
99
106
  return;
100
107
  }
101
108
  ctx.luckysheetfile.push(sheetconfig);
102
- if (!newSheetID) {
103
- changeSheet(ctx, id, isPivotTable, true);
104
- }
105
109
  if (ctx.hooks.afterAddSheet) {
106
- setTimeout(function () {
107
- var _a, _b;
108
- (_b = (_a = ctx.hooks).afterAddSheet) === null || _b === void 0 ? void 0 : _b.call(_a, sheetconfig);
109
- });
110
+ (_d = (_c = ctx.hooks).afterAddSheet) === null || _d === void 0 ? void 0 : _d.call(_c, __assign({}, sheetconfig));
110
111
  }
111
112
  }
112
113
  function deleteSheet(ctx, id) {
113
- var _a, _b, _c;
114
+ var _a, _b, _c, _d, _e;
114
115
  if (ctx.allowEdit === false) {
115
116
  return;
116
117
  }
@@ -136,10 +137,7 @@ function deleteSheet(ctx, id) {
136
137
  ctx.currentSheetId = (_c = orderSheets === null || orderSheets === void 0 ? void 0 : orderSheets[0]) === null || _c === void 0 ? void 0 : _c.id;
137
138
  }
138
139
  if (ctx.hooks.afterDeleteSheet) {
139
- setTimeout(function () {
140
- var _a, _b;
141
- (_b = (_a = ctx.hooks).afterDeleteSheet) === null || _b === void 0 ? void 0 : _b.call(_a, id);
142
- });
140
+ (_e = (_d = ctx.hooks).afterDeleteSheet) === null || _e === void 0 ? void 0 : _e.call(_d, id);
143
141
  }
144
142
  }
145
143
  function updateSheet(ctx, newData) {
@@ -49,12 +49,13 @@ var _conditionalFormat = require("./conditionalFormat");
49
49
  var _text = require("./text");
50
50
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
51
51
  function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col_ed, canvas) {
52
- 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;
53
- var _7;
52
+ 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;
53
+ var _11;
54
54
  if (_lodash.default.isNil(d) || _lodash.default.isNil(attr)) {
55
55
  return;
56
56
  }
57
57
  if (attr === "ct") {
58
+ var changes = [];
58
59
  for (var r = row_st; r <= row_ed; r += 1) {
59
60
  if (!_lodash.default.isNil(ctx.config.rowhidden) && !_lodash.default.isNil(ctx.config.rowhidden[r])) {
60
61
  continue;
@@ -130,6 +131,20 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
130
131
  m: mask
131
132
  };
132
133
  }
134
+ changes.push({
135
+ sheetId: ctx.currentSheetId,
136
+ path: ["celldata"],
137
+ value: {
138
+ r: r,
139
+ c: c,
140
+ v: d[r][c]
141
+ },
142
+ key: "".concat(r, "_").concat(c),
143
+ type: "update"
144
+ });
145
+ }
146
+ if ((_x = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _x === void 0 ? void 0 : _x.updateCellYdoc) {
147
+ (_y = ctx.hooks) === null || _y === void 0 ? void 0 : _y.updateCellYdoc(changes);
133
148
  }
134
149
  }
135
150
  } else {
@@ -176,6 +191,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
176
191
  if (sheetIndex == null) {
177
192
  return;
178
193
  }
194
+ var changes = [];
179
195
  for (var r = row_st; r <= row_ed; r += 1) {
180
196
  if (!_lodash.default.isNil(ctx.config.rowhidden) && !_lodash.default.isNil(ctx.config.rowhidden[r])) {
181
197
  continue;
@@ -185,11 +201,11 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
185
201
  if (value && _lodash.default.isPlainObject(value)) {
186
202
  (0, _inlineString.updateInlineStringFormatOutside)(value, attr, foucsStatus);
187
203
  value[attr] = foucsStatus;
188
- (_7 = ctx.luckysheetfile[sheetIndex]).config || (_7.config = {});
204
+ (_11 = ctx.luckysheetfile[sheetIndex]).config || (_11.config = {});
189
205
  var cfg = ctx.luckysheetfile[sheetIndex].config;
190
- var cellWidth = ((_x = cfg.columnlen) === null || _x === void 0 ? void 0 : _x[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
206
+ var cellWidth = ((_z = cfg.columnlen) === null || _z === void 0 ? void 0 : _z[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
191
207
  if (attr === "tb" && canvas && foucsStatus === "2") {
192
- var currentColWidth_1 = ((_y = cfg.columnlen) === null || _y === void 0 ? void 0 : _y[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
208
+ var currentColWidth_1 = ((_0 = cfg.columnlen) === null || _0 === void 0 ? void 0 : _0[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
193
209
  var lineCount_1 = 1;
194
210
  var fontString_1 = "10px Arial";
195
211
  if (value.fs) {
@@ -202,9 +218,9 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
202
218
  lineCount_1 = (0, _utils.getLineCount)(value.m, currentColWidth_1, fontString_1);
203
219
  var hOffset = lineCount_1 < 4 ? 1.9 : 1.7;
204
220
  lineCount_1 = lineCount_1 * hOffset + 1;
205
- } else if ((_1 = (_0 = (_z = value === null || value === void 0 ? void 0 : value.ct) === null || _z === void 0 ? void 0 : _z.s) === null || _0 === void 0 ? void 0 : _0[0]) === null || _1 === void 0 ? void 0 : _1.v) {
221
+ } 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) {
206
222
  lineCount_1 -= 1;
207
- var line = (_4 = (_3 = (_2 = value === null || value === void 0 ? void 0 : value.ct) === null || _2 === void 0 ? void 0 : _2.s) === null || _3 === void 0 ? void 0 : _3[0]) === null || _4 === void 0 ? void 0 : _4.v.split("\n");
223
+ 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");
208
224
  line.forEach(function (item) {
209
225
  var subLineCount = (0, _utils.getLineCount)(item, currentColWidth_1, fontString_1);
210
226
  lineCount_1 += subLineCount;
@@ -224,7 +240,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
224
240
  });
225
241
  if (!textInfo) return "continue";
226
242
  var rowHeight = _lodash.default.round(textInfo.textHeightAll);
227
- var currentRowHeight = ((_5 = cfg.rowlen) === null || _5 === void 0 ? void 0 : _5[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
243
+ var currentRowHeight = ((_7 = cfg.rowlen) === null || _7 === void 0 ? void 0 : _7[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
228
244
  if (!_lodash.default.isUndefined(rowHeight) && rowHeight > currentRowHeight && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
229
245
  if (_lodash.default.isUndefined(cfg.rowlen)) cfg.rowlen = {};
230
246
  _lodash.default.set(cfg, "rowlen.".concat(r), rowHeight);
@@ -239,7 +255,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
239
255
  });
240
256
  if (!textInfo) return "continue";
241
257
  var newHeight = _lodash.default.round(textInfo.textHeightAll);
242
- var oldHeight = ((_6 = cfg.rowlen) === null || _6 === void 0 ? void 0 : _6[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
258
+ var oldHeight = ((_8 = cfg.rowlen) === null || _8 === void 0 ? void 0 : _8[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
243
259
  var shouldResize = foucsStatus === "2" ? newHeight > oldHeight : true;
244
260
  if (shouldResize && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
245
261
  var padding = 12;
@@ -254,11 +270,25 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
254
270
  };
255
271
  d[r][c][attr] = foucsStatus;
256
272
  }
273
+ changes.push({
274
+ sheetId: ctx.currentSheetId,
275
+ path: ["celldata"],
276
+ value: {
277
+ r: r,
278
+ c: c,
279
+ v: d[r][c]
280
+ },
281
+ key: "".concat(r, "_").concat(c),
282
+ type: "update"
283
+ });
257
284
  };
258
285
  for (var c = col_st; c <= col_ed; c += 1) {
259
286
  _loop_1(c);
260
287
  }
261
288
  }
289
+ if ((_9 = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _9 === void 0 ? void 0 : _9.updateCellYdoc) {
290
+ (_10 = ctx.hooks) === null || _10 === void 0 ? void 0 : _10.updateCellYdoc(changes);
291
+ }
262
292
  }
263
293
  }
264
294
  function updateFormat(ctx, $input, d, attr, foucsStatus, canvas) {
@@ -10,6 +10,7 @@ var _locale = require("./locale");
10
10
  var _modules = require("./modules");
11
11
  var _utils = require("./utils");
12
12
  var _api = require("./api");
13
+ var _paste = require("./events/paste");
13
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
15
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
15
16
  var __assign = void 0 && (void 0).__assign || function () {
@@ -22,6 +23,14 @@ var __assign = void 0 && (void 0).__assign || function () {
22
23
  };
23
24
  return __assign.apply(this, arguments);
24
25
  };
26
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
27
+ var t = {};
28
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
30
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
31
+ }
32
+ return t;
33
+ };
25
34
  var DEFAULT_FONT_SIZE = exports.DEFAULT_FONT_SIZE = 12;
26
35
  var parseStylesheetPairs = function parseStylesheetPairs(styleInner) {
27
36
  var patternReg = /{([^}]*)}/g;
@@ -135,6 +144,28 @@ function brToNewline(str) {
135
144
  }
136
145
  var buildCellFromTd = function buildCellFromTd(td, classStyles, ctx) {
137
146
  var _a, _b, _c, _d;
147
+ var fortuneCellAttr = td.getAttribute("data-fortune-cell");
148
+ if (fortuneCellAttr) {
149
+ try {
150
+ var _e = JSON.parse(decodeURIComponent(fortuneCellAttr)),
151
+ _srcRow = _e._srcRow,
152
+ _srcCol = _e._srcCol,
153
+ parsed = __rest(_e, ["_srcRow", "_srcCol"]);
154
+ var cell_1 = parsed;
155
+ delete cell_1.mc;
156
+ delete cell_1.hl;
157
+ var rowspan_1 = parseInt(td.getAttribute("rowspan") || "1", 10);
158
+ var colspan_1 = parseInt(td.getAttribute("colspan") || "1", 10);
159
+ return {
160
+ cell: cell_1,
161
+ rowspan: Number.isNaN(rowspan_1) ? 1 : rowspan_1,
162
+ colspan: Number.isNaN(colspan_1) ? 1 : colspan_1,
163
+ hyperlink: detectHyperlink(td),
164
+ srcRow: _srcRow,
165
+ srcCol: _srcCol
166
+ };
167
+ } catch (_f) {}
168
+ }
138
169
  var cell = {};
139
170
  var rawText = (td.innerText || td.innerHTML || "").trim();
140
171
  var isLineBreak = rawText.includes("<br />");
@@ -285,10 +316,17 @@ function handlePastedTable(ctx, html, pasteHandler) {
285
316
  cell = _a.cell,
286
317
  rowspan = _a.rowspan,
287
318
  colspan = _a.colspan,
288
- hyperlink = _a.hyperlink;
319
+ hyperlink = _a.hyperlink,
320
+ srcRow = _a.srcRow,
321
+ srcCol = _a.srcCol;
289
322
  var anchorCol = ctx.luckysheet_select_save[0].column[0];
290
323
  var absoluteRow = anchorRow + localRowIndex;
291
324
  var absoluteCol = anchorCol + localColIndex;
325
+ if (cell.f && srcRow != null && srcCol != null) {
326
+ try {
327
+ cell.f = (0, _paste.adjustFormulaForPaste)(cell.f, srcCol, srcRow, absoluteCol, absoluteRow);
328
+ } catch (_b) {}
329
+ }
292
330
  pastedMatrix[localRowIndex][localColIndex] = cell;
293
331
  if (hyperlink) {
294
332
  (0, _modules.saveHyperlink)(ctx, absoluteRow, absoluteCol, hyperlink.href, "webpage", hyperlink.display);
package/lib/settings.d.ts CHANGED
@@ -1,6 +1,24 @@
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 = {
11
+ calcChainChange?: () => void;
12
+ sheetLengthChange?: () => void;
13
+ dataVerificationChange?: () => void;
14
+ liveQueryChange?: () => void;
15
+ imageListChange?: () => void;
16
+ iframeListChange?: () => void;
17
+ conditionRulesChange?: () => void;
18
+ conditionFormatChange?: () => void;
19
+ cellDataChange?: () => void;
20
+ hyperlinkChange?: () => void;
21
+ updateCellYdoc?: (changes: SheetChangePath[]) => void;
4
22
  beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
5
23
  afterUpdateCell?: (row: number, column: number, oldValue: any, newValue: any) => void;
6
24
  afterSelectionChange?: (sheetId: string, selection: Selection) => void;
@@ -56,6 +74,15 @@ export type Hooks = {
56
74
  afterDeleteSheet?: (id: string) => void;
57
75
  beforeUpdateSheetName?: (id: string, oldName: string, newName: string) => boolean;
58
76
  afterUpdateSheetName?: (id: string, oldName: string, newName: string) => void;
77
+ afterImagesChange?: () => void;
78
+ afterIframesChange?: () => void;
79
+ afterFrozenChange?: () => void;
80
+ afterOrderChanges?: () => void;
81
+ afterConfigChanges?: () => void;
82
+ afterColRowChanges?: () => void;
83
+ afterShowGridLinesChange?: () => void;
84
+ afterNameChanges?: () => void;
85
+ afterStatusChanges?: () => void;
59
86
  };
60
87
  type CommentUIDragFn = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
61
88
  export type Settings = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.3.9",
3
+ "version": "1.3.10-copyPaste-2",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",