@fileverse-dev/fortune-core 1.2.94 → 1.2.95-ydoc

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/cell.d.ts CHANGED
@@ -4,7 +4,7 @@ import { CommonOptions } from "./common";
4
4
  export declare function getCellValue(ctx: Context, row: number, column: number, options?: CommonOptions & {
5
5
  type?: keyof Cell;
6
6
  }): any;
7
- export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions): void;
7
+ export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions, callAfterUpdate?: boolean): void;
8
8
  export declare function clearCell(ctx: Context, row: number, column: number, options?: CommonOptions): void;
9
9
  export declare function setCellFormat(ctx: Context, row: number, column: number, attr: keyof Cell, value: any, options?: CommonOptions): void;
10
10
  export declare function autoFillCell(ctx: Context, copyRange: SingleRange, applyRange: SingleRange, direction: "up" | "down" | "left" | "right"): void;
package/es/api/cell.js CHANGED
@@ -50,8 +50,8 @@ export function getCellValue(ctx, row, column, options) {
50
50
  }
51
51
  return ret;
52
52
  }
53
- export function setCellValue(ctx, row, column, value, cellInput, options) {
54
- var _a;
53
+ export function setCellValue(ctx, row, column, value, cellInput, options, callAfterUpdate) {
54
+ var _a, _b, _c;
55
55
  if (options === void 0) {
56
56
  options = {};
57
57
  }
@@ -127,6 +127,9 @@ export function setCellValue(ctx, row, column, value, cellInput, options) {
127
127
  setCellValueInternal(ctx, row, column, data, value);
128
128
  }
129
129
  }
130
+ if (callAfterUpdate && ctx.hooks.afterUpdateCell) {
131
+ (_c = (_b = ctx.hooks).afterUpdateCell) === null || _c === void 0 ? void 0 : _c.call(_b, row, column, null, value);
132
+ }
130
133
  }
131
134
  export function clearCell(ctx, row, column, options) {
132
135
  var _a, _b;
package/es/api/range.d.ts CHANGED
@@ -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/es/api/range.js CHANGED
@@ -77,7 +77,7 @@ export function setSelection(ctx, range, options) {
77
77
  ctx.luckysheet_select_save = sheet.luckysheet_select_save;
78
78
  }
79
79
  }
80
- export function setCellValuesByRange(ctx, data, range, cellInput, options) {
80
+ export function setCellValuesByRange(ctx, data, range, cellInput, options, callAfterUpdate) {
81
81
  if (options === void 0) {
82
82
  options = {};
83
83
  }
@@ -99,7 +99,7 @@ export function setCellValuesByRange(ctx, data, range, cellInput, options) {
99
99
  for (var j = 0; j < columnCount; j += 1) {
100
100
  var row = range.row[0] + i;
101
101
  var column = range.column[0] + j;
102
- setCellValue(ctx, row, column, data[i][j], cellInput, options);
102
+ setCellValue(ctx, row, column, data[i][j], cellInput, options, callAfterUpdate);
103
103
  }
104
104
  }
105
105
  }
@@ -189,28 +189,43 @@ function postPasteCut(ctx, source, target, RowlChange) {
189
189
  storeSheetParamALL(ctx);
190
190
  }
191
191
  var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
192
- var _a;
192
+ var _a, _b, _c;
193
+ var changes = [];
193
194
  for (var r = 0; r < d.length; r += 1) {
194
195
  var x = d[r];
195
196
  for (var c = 0; c < d[0].length; c += 1) {
196
197
  var value = isObject(d[r][c]) ? (_a = d[r][c]) === null || _a === void 0 ? void 0 : _a.v : d[r][c];
197
198
  if (value && String(value).startsWith("=")) {
198
199
  var cell = {};
199
- var _b = execfunction(ctx, String(value), r, c, undefined, undefined, true),
200
- v = _b[1],
201
- f = _b[2];
200
+ var _d = execfunction(ctx, String(value), r, c, undefined, undefined, true),
201
+ v = _d[1],
202
+ f = _d[2];
202
203
  cell.v = v;
203
204
  cell.f = f;
204
205
  cell.m = v.toString();
205
206
  x[c] = cell;
206
207
  }
207
208
  d[r] = x;
209
+ changes.push({
210
+ sheetId: ctx.currentSheetId,
211
+ path: ["celldata"],
212
+ value: {
213
+ r: r,
214
+ c: c,
215
+ v: d[r][c]
216
+ },
217
+ key: "".concat(r, "_").concat(c),
218
+ type: "update"
219
+ });
208
220
  }
209
221
  }
222
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
223
+ (_c = ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc(changes);
224
+ }
210
225
  };
211
226
  function pasteHandler(ctx, data, borderInfo) {
212
227
  var _a;
213
- var _b, _c, _d, _e, _f, _g;
228
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
214
229
  if (ctx.luckysheet_selection_range) {
215
230
  ctx.luckysheet_selection_range = [];
216
231
  }
@@ -258,6 +273,7 @@ function pasteHandler(ctx, data, borderInfo) {
258
273
  }
259
274
  var RowlChange = false;
260
275
  var offsetMC = {};
276
+ var changes = [];
261
277
  for (var h = minh; h <= maxh; h += 1) {
262
278
  var x = d[h];
263
279
  var currentRowLen = ctx.defaultrowlen;
@@ -305,12 +321,26 @@ function pasteHandler(ctx, data, borderInfo) {
305
321
  };
306
322
  (_f = cfg.borderInfo) === null || _f === void 0 ? void 0 : _f.push(bd_obj);
307
323
  }
324
+ changes.push({
325
+ sheetId: ctx.currentSheetId,
326
+ path: ["celldata"],
327
+ value: {
328
+ r: h,
329
+ c: c,
330
+ v: d[h][c]
331
+ },
332
+ key: "".concat(h, "_").concat(c),
333
+ type: "update"
334
+ });
308
335
  }
309
336
  d[h] = x;
310
337
  if (currentRowLen !== ctx.defaultrowlen) {
311
338
  cfg.rowlen[h] = currentRowLen;
312
339
  }
313
340
  }
341
+ if ((_g = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _g === void 0 ? void 0 : _g.updateCellYdoc) {
342
+ (_h = ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc(changes);
343
+ }
314
344
  ctx.luckysheet_select_save = [{
315
345
  row: [minh, maxh],
316
346
  column: [minc, maxc]
@@ -335,7 +365,7 @@ function pasteHandler(ctx, data, borderInfo) {
335
365
  }
336
366
  var d = getFlowdata(ctx);
337
367
  if (!d) return;
338
- var last = (_g = ctx.luckysheet_select_save) === null || _g === void 0 ? void 0 : _g[ctx.luckysheet_select_save.length - 1];
368
+ var last = (_j = ctx.luckysheet_select_save) === null || _j === void 0 ? void 0 : _j[ctx.luckysheet_select_save.length - 1];
339
369
  if (!last) return;
340
370
  var curR = last.row == null ? 0 : last.row[0];
341
371
  var curC = last.column == null ? 0 : last.column[0];
@@ -360,6 +390,7 @@ function pasteHandler(ctx, data, borderInfo) {
360
390
  if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
361
391
  return t.startsWith("http") ? t : "https://".concat(t);
362
392
  };
393
+ var changes = [];
363
394
  for (var r = 0; r < rlen; r += 1) {
364
395
  var x = d[r + curR];
365
396
  for (var c = 0; c < clen; c += 1) {
@@ -432,9 +463,23 @@ function pasteHandler(ctx, data, borderInfo) {
432
463
  }
433
464
  x[c + curC] = cell;
434
465
  }
466
+ changes.push(changes.push({
467
+ sheetId: ctx.currentSheetId,
468
+ path: ["celldata"],
469
+ value: {
470
+ r: r,
471
+ c: c,
472
+ v: d[r][c]
473
+ },
474
+ key: "".concat(r, "_").concat(c),
475
+ type: "update"
476
+ }));
435
477
  }
436
478
  d[r + curR] = x;
437
479
  }
480
+ if ((_k = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _k === void 0 ? void 0 : _k.updateCellYdoc) {
481
+ (_l = ctx.hooks) === null || _l === void 0 ? void 0 : _l.updateCellYdoc(changes);
482
+ }
438
483
  last.row = [curR, curR + rlen - 1];
439
484
  last.column = [curC, curC + clen - 1];
440
485
  jfrefreshgrid(ctx, null, undefined);
@@ -111,6 +111,7 @@ export function getCellValue(r, c, data, attr) {
111
111
  }
112
112
  export function setCellValue(ctx, r, c, d, v) {
113
113
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
114
+ console.log("setCellValue", r, c, v);
114
115
  if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
115
116
  if (_.isNil(d)) {
116
117
  d = getFlowdata(ctx);
@@ -411,6 +411,9 @@ function fillCopy(data, len) {
411
411
  var index = (i - 1) % data.length;
412
412
  var d = _.cloneDeep(data[index]);
413
413
  if (!_.isUndefined(d)) {
414
+ if (d) {
415
+ delete d.ps;
416
+ }
414
417
  applyData.push(d);
415
418
  }
416
419
  }
@@ -1307,6 +1310,9 @@ function getDataByType(data, len, direction, type, dataType) {
1307
1310
  applyData = fillCopy(data, len);
1308
1311
  }
1309
1312
  }
1313
+ applyData.forEach(function (c) {
1314
+ if (c != null) delete c.ps;
1315
+ });
1310
1316
  return applyData;
1311
1317
  }
1312
1318
  function getCopyData(d, r1, r2, c1, c2, direction) {
@@ -2173,6 +2179,7 @@ export function updateDropCell(ctx) {
2173
2179
  }
2174
2180
  }
2175
2181
  }
2182
+ file.dataVerification = dataVerification;
2176
2183
  jfrefreshgrid(ctx, d, ctx.luckysheet_select_save);
2177
2184
  }
2178
2185
  export function onDropCellSelectEnd(ctx, e, container) {
@@ -39,6 +39,7 @@ export function getCellHyperlink(ctx, r, c) {
39
39
  return undefined;
40
40
  }
41
41
  export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress) {
42
+ var _a, _b;
42
43
  var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
43
44
  var flowdata = getFlowdata(ctx);
44
45
  if (sheetIndex != null && flowdata != null && linkType && linkAddress) {
@@ -59,6 +60,19 @@ export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress) {
59
60
  };
60
61
  flowdata[r][c] = cell;
61
62
  ctx.linkCard = undefined;
63
+ if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
64
+ (_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc([{
65
+ sheetId: ctx.currentSheetId,
66
+ path: ["celldata"],
67
+ value: {
68
+ r: r,
69
+ c: c,
70
+ v: cell
71
+ },
72
+ key: "".concat(r, "_").concat(c),
73
+ type: "update"
74
+ }]);
75
+ }
62
76
  }
63
77
  }
64
78
  export function removeHyperlink(ctx, r, c) {
@@ -1496,7 +1496,7 @@ export function copy(ctx) {
1496
1496
  }
1497
1497
  }
1498
1498
  export function deleteSelectedCellText(ctx) {
1499
- var _a, _b, _c;
1499
+ var _a, _b, _c, _d;
1500
1500
  var allowEdit = isAllowEdit(ctx);
1501
1501
  if (allowEdit === false || ctx.isFlvReadOnly) {
1502
1502
  return "allowEdit";
@@ -1525,6 +1525,7 @@ export function deleteSelectedCellText(ctx) {
1525
1525
  var r2 = selection[s].row[1];
1526
1526
  var c1 = selection[s].column[0];
1527
1527
  var c2 = selection[s].column[1];
1528
+ var changes = [];
1528
1529
  for (var r = r1; r <= r2; r += 1) {
1529
1530
  for (var c = c1; c <= c2; c += 1) {
1530
1531
  var index = getSheetIndex(ctx, ctx.currentSheetId);
@@ -1553,6 +1554,18 @@ export function deleteSelectedCellText(ctx) {
1553
1554
  if (hyperlinkMap && hyperlinkMap["".concat(r, "_").concat(c)]) {
1554
1555
  delete hyperlinkMap["".concat(r, "_").concat(c)];
1555
1556
  }
1557
+ if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.afterUpdateCell) {
1558
+ ctx.hooks.afterUpdateCell(r, c, null, d[r][c]);
1559
+ }
1560
+ changes.push({
1561
+ sheetId: ctx.currentSheetId,
1562
+ path: ["celldata"],
1563
+ value: {
1564
+ r: r,
1565
+ c: c,
1566
+ v: d[r][c]
1567
+ }
1568
+ });
1556
1569
  }
1557
1570
  }
1558
1571
  }
@@ -1,3 +1,13 @@
1
+ var __assign = this && this.__assign || function () {
2
+ __assign = Object.assign || function (t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
6
+ }
7
+ return t;
8
+ };
9
+ return __assign.apply(this, arguments);
10
+ };
1
11
  import _ from "lodash";
2
12
  import { v4 as uuidv4 } from "uuid";
3
13
  import { initSheetData } from "../api/sheet";
@@ -19,7 +29,7 @@ export function storeSheetParamALL(ctx) {
19
29
  ctx.luckysheetfile[index].config = ctx.config;
20
30
  }
21
31
  export function changeSheet(ctx, id, isPivotInitial, isNewSheet, isCopySheet) {
22
- var _a, _b;
32
+ var _a, _b, _c, _d;
23
33
  if (id === ctx.currentSheetId) {
24
34
  return;
25
35
  }
@@ -35,14 +45,11 @@ export function changeSheet(ctx, id, isPivotInitial, isNewSheet, isCopySheet) {
35
45
  ctx.luckysheetcurrentisPivotTable = false;
36
46
  }
37
47
  if (ctx.hooks.afterActivateSheet) {
38
- setTimeout(function () {
39
- var _a, _b;
40
- (_b = (_a = ctx.hooks).afterActivateSheet) === null || _b === void 0 ? void 0 : _b.call(_a, id);
41
- });
48
+ (_d = (_c = ctx.hooks).afterActivateSheet) === null || _d === void 0 ? void 0 : _d.call(_c, id);
42
49
  }
43
50
  }
44
51
  export function addSheet(ctx, settings, newSheetID, isPivotTable, sheetName, sheetData) {
45
- var _a, _b;
52
+ var _a, _b, _c, _d;
46
53
  if (newSheetID === void 0) {
47
54
  newSheetID = undefined;
48
55
  }
@@ -86,18 +93,12 @@ export function addSheet(ctx, settings, newSheetID, isPivotTable, sheetName, she
86
93
  return;
87
94
  }
88
95
  ctx.luckysheetfile.push(sheetconfig);
89
- if (!newSheetID) {
90
- changeSheet(ctx, id, isPivotTable, true);
91
- }
92
96
  if (ctx.hooks.afterAddSheet) {
93
- setTimeout(function () {
94
- var _a, _b;
95
- (_b = (_a = ctx.hooks).afterAddSheet) === null || _b === void 0 ? void 0 : _b.call(_a, sheetconfig);
96
- });
97
+ (_d = (_c = ctx.hooks).afterAddSheet) === null || _d === void 0 ? void 0 : _d.call(_c, __assign({}, sheetconfig));
97
98
  }
98
99
  }
99
100
  export function deleteSheet(ctx, id) {
100
- var _a, _b, _c;
101
+ var _a, _b, _c, _d, _e;
101
102
  if (ctx.allowEdit === false) {
102
103
  return;
103
104
  }
@@ -123,10 +124,7 @@ export function deleteSheet(ctx, id) {
123
124
  ctx.currentSheetId = (_c = orderSheets === null || orderSheets === void 0 ? void 0 : orderSheets[0]) === null || _c === void 0 ? void 0 : _c.id;
124
125
  }
125
126
  if (ctx.hooks.afterDeleteSheet) {
126
- setTimeout(function () {
127
- var _a, _b;
128
- (_b = (_a = ctx.hooks).afterDeleteSheet) === null || _b === void 0 ? void 0 : _b.call(_a, id);
129
- });
127
+ (_e = (_d = ctx.hooks).afterDeleteSheet) === null || _e === void 0 ? void 0 : _e.call(_d, id);
130
128
  }
131
129
  }
132
130
  export function updateSheet(ctx, newData) {
@@ -15,12 +15,14 @@ import { showLinkCard } from "./hyperlink";
15
15
  import { cfSplitRange } from "./conditionalFormat";
16
16
  import { clearMeasureTextCache, getCellTextInfo } from "./text";
17
17
  export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col_ed, canvas) {
18
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
19
- var _7;
18
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
19
+ var _11;
20
+ console.log("updateFormatCell", row_st, row_ed, col_st, col_ed);
20
21
  if (_.isNil(d) || _.isNil(attr)) {
21
22
  return;
22
23
  }
23
24
  if (attr === "ct") {
25
+ var changes = [];
24
26
  for (var r = row_st; r <= row_ed; r += 1) {
25
27
  if (!_.isNil(ctx.config.rowhidden) && !_.isNil(ctx.config.rowhidden[r])) {
26
28
  continue;
@@ -72,6 +74,20 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
72
74
  m: mask
73
75
  };
74
76
  }
77
+ changes.push({
78
+ sheetId: ctx.currentSheetId,
79
+ path: ["celldata"],
80
+ value: {
81
+ r: r,
82
+ c: c,
83
+ v: d[r][c]
84
+ },
85
+ key: "".concat(r, "_").concat(c),
86
+ type: "update"
87
+ });
88
+ }
89
+ if ((_x = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _x === void 0 ? void 0 : _x.updateCellYdoc) {
90
+ (_y = ctx.hooks) === null || _y === void 0 ? void 0 : _y.updateCellYdoc(changes);
75
91
  }
76
92
  }
77
93
  } else {
@@ -118,6 +134,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
118
134
  if (sheetIndex == null) {
119
135
  return;
120
136
  }
137
+ var changes = [];
121
138
  for (var r = row_st; r <= row_ed; r += 1) {
122
139
  if (!_.isNil(ctx.config.rowhidden) && !_.isNil(ctx.config.rowhidden[r])) {
123
140
  continue;
@@ -127,11 +144,11 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
127
144
  if (value && _.isPlainObject(value)) {
128
145
  updateInlineStringFormatOutside(value, attr, foucsStatus);
129
146
  value[attr] = foucsStatus;
130
- (_7 = ctx.luckysheetfile[sheetIndex]).config || (_7.config = {});
147
+ (_11 = ctx.luckysheetfile[sheetIndex]).config || (_11.config = {});
131
148
  var cfg = ctx.luckysheetfile[sheetIndex].config;
132
- var cellWidth = ((_x = cfg.columnlen) === null || _x === void 0 ? void 0 : _x[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
149
+ var cellWidth = ((_z = cfg.columnlen) === null || _z === void 0 ? void 0 : _z[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
133
150
  if (attr === "tb" && canvas && foucsStatus === "2") {
134
- var currentColWidth_1 = ((_y = cfg.columnlen) === null || _y === void 0 ? void 0 : _y[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
151
+ var currentColWidth_1 = ((_0 = cfg.columnlen) === null || _0 === void 0 ? void 0 : _0[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
135
152
  var lineCount_1 = 1;
136
153
  var fontString_1 = "10px Arial";
137
154
  if (value.fs) {
@@ -144,9 +161,9 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
144
161
  lineCount_1 = getLineCount(value.m, currentColWidth_1, fontString_1);
145
162
  var hOffset = lineCount_1 < 4 ? 1.9 : 1.7;
146
163
  lineCount_1 = lineCount_1 * hOffset + 1;
147
- } 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) {
164
+ } else if ((_3 = (_2 = (_1 = value === null || value === void 0 ? void 0 : value.ct) === null || _1 === void 0 ? void 0 : _1.s) === null || _2 === void 0 ? void 0 : _2[0]) === null || _3 === void 0 ? void 0 : _3.v) {
148
165
  lineCount_1 -= 1;
149
- 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");
166
+ var line = (_6 = (_5 = (_4 = value === null || value === void 0 ? void 0 : value.ct) === null || _4 === void 0 ? void 0 : _4.s) === null || _5 === void 0 ? void 0 : _5[0]) === null || _6 === void 0 ? void 0 : _6.v.split("\n");
150
167
  line.forEach(function (item) {
151
168
  var subLineCount = getLineCount(item, currentColWidth_1, fontString_1);
152
169
  lineCount_1 += subLineCount;
@@ -166,7 +183,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
166
183
  });
167
184
  if (!textInfo) return "continue";
168
185
  var rowHeight = _.round(textInfo.textHeightAll);
169
- var currentRowHeight = ((_5 = cfg.rowlen) === null || _5 === void 0 ? void 0 : _5[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
186
+ var currentRowHeight = ((_7 = cfg.rowlen) === null || _7 === void 0 ? void 0 : _7[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
170
187
  if (!_.isUndefined(rowHeight) && rowHeight > currentRowHeight && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
171
188
  if (_.isUndefined(cfg.rowlen)) cfg.rowlen = {};
172
189
  _.set(cfg, "rowlen.".concat(r), rowHeight);
@@ -181,7 +198,7 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
181
198
  });
182
199
  if (!textInfo) return "continue";
183
200
  var newHeight = _.round(textInfo.textHeightAll);
184
- var oldHeight = ((_6 = cfg.rowlen) === null || _6 === void 0 ? void 0 : _6[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
201
+ var oldHeight = ((_8 = cfg.rowlen) === null || _8 === void 0 ? void 0 : _8[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
185
202
  var shouldResize = foucsStatus === "2" ? newHeight > oldHeight : true;
186
203
  if (shouldResize && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
187
204
  var padding = 12;
@@ -196,11 +213,25 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
196
213
  };
197
214
  d[r][c][attr] = foucsStatus;
198
215
  }
216
+ changes.push({
217
+ sheetId: ctx.currentSheetId,
218
+ path: ["celldata"],
219
+ value: {
220
+ r: r,
221
+ c: c,
222
+ v: d[r][c]
223
+ },
224
+ key: "".concat(r, "_").concat(c),
225
+ type: "update"
226
+ });
199
227
  };
200
228
  for (var c = col_st; c <= col_ed; c += 1) {
201
229
  _loop_1(c);
202
230
  }
203
231
  }
232
+ if ((_9 = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _9 === void 0 ? void 0 : _9.updateCellYdoc) {
233
+ (_10 = ctx.hooks) === null || _10 === void 0 ? void 0 : _10.updateCellYdoc(changes);
234
+ }
204
235
  }
205
236
  }
206
237
  export function updateFormat(ctx, $input, d, attr, foucsStatus, canvas) {
package/es/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,13 @@ 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;
59
84
  };
60
85
  type CommentUIDragFn = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
61
86
  export type Settings = {
package/lib/api/cell.d.ts CHANGED
@@ -4,7 +4,7 @@ import { CommonOptions } from "./common";
4
4
  export declare function getCellValue(ctx: Context, row: number, column: number, options?: CommonOptions & {
5
5
  type?: keyof Cell;
6
6
  }): any;
7
- export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions): void;
7
+ export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions, callAfterUpdate?: boolean): void;
8
8
  export declare function clearCell(ctx: Context, row: number, column: number, options?: CommonOptions): void;
9
9
  export declare function setCellFormat(ctx: Context, row: number, column: number, attr: keyof Cell, value: any, options?: CommonOptions): void;
10
10
  export declare function autoFillCell(ctx: Context, copyRange: SingleRange, applyRange: SingleRange, direction: "up" | "down" | "left" | "right"): void;
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
  }
@@ -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
  }
@@ -202,28 +202,43 @@ function postPasteCut(ctx, source, target, RowlChange) {
202
202
  (0, _sheet.storeSheetParamALL)(ctx);
203
203
  }
204
204
  var handleFormulaOnPaste = function handleFormulaOnPaste(ctx, d) {
205
- var _a;
205
+ var _a, _b, _c;
206
+ var changes = [];
206
207
  for (var r = 0; r < d.length; r += 1) {
207
208
  var x = d[r];
208
209
  for (var c = 0; c < d[0].length; c += 1) {
209
210
  var value = (0, _lodash.isObject)(d[r][c]) ? (_a = d[r][c]) === null || _a === void 0 ? void 0 : _a.v : d[r][c];
210
211
  if (value && String(value).startsWith("=")) {
211
212
  var cell = {};
212
- var _b = (0, _formula.execfunction)(ctx, String(value), r, c, undefined, undefined, true),
213
- v = _b[1],
214
- f = _b[2];
213
+ var _d = (0, _formula.execfunction)(ctx, String(value), r, c, undefined, undefined, true),
214
+ v = _d[1],
215
+ f = _d[2];
215
216
  cell.v = v;
216
217
  cell.f = f;
217
218
  cell.m = v.toString();
218
219
  x[c] = cell;
219
220
  }
220
221
  d[r] = x;
222
+ changes.push({
223
+ sheetId: ctx.currentSheetId,
224
+ path: ["celldata"],
225
+ value: {
226
+ r: r,
227
+ c: c,
228
+ v: d[r][c]
229
+ },
230
+ key: "".concat(r, "_").concat(c),
231
+ type: "update"
232
+ });
221
233
  }
222
234
  }
235
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
236
+ (_c = ctx.hooks) === null || _c === void 0 ? void 0 : _c.updateCellYdoc(changes);
237
+ }
223
238
  };
224
239
  function pasteHandler(ctx, data, borderInfo) {
225
240
  var _a;
226
- var _b, _c, _d, _e, _f, _g;
241
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
227
242
  if (ctx.luckysheet_selection_range) {
228
243
  ctx.luckysheet_selection_range = [];
229
244
  }
@@ -271,6 +286,7 @@ function pasteHandler(ctx, data, borderInfo) {
271
286
  }
272
287
  var RowlChange = false;
273
288
  var offsetMC = {};
289
+ var changes = [];
274
290
  for (var h = minh; h <= maxh; h += 1) {
275
291
  var x = d[h];
276
292
  var currentRowLen = ctx.defaultrowlen;
@@ -318,12 +334,26 @@ function pasteHandler(ctx, data, borderInfo) {
318
334
  };
319
335
  (_f = cfg.borderInfo) === null || _f === void 0 ? void 0 : _f.push(bd_obj);
320
336
  }
337
+ changes.push({
338
+ sheetId: ctx.currentSheetId,
339
+ path: ["celldata"],
340
+ value: {
341
+ r: h,
342
+ c: c,
343
+ v: d[h][c]
344
+ },
345
+ key: "".concat(h, "_").concat(c),
346
+ type: "update"
347
+ });
321
348
  }
322
349
  d[h] = x;
323
350
  if (currentRowLen !== ctx.defaultrowlen) {
324
351
  cfg.rowlen[h] = currentRowLen;
325
352
  }
326
353
  }
354
+ if ((_g = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _g === void 0 ? void 0 : _g.updateCellYdoc) {
355
+ (_h = ctx.hooks) === null || _h === void 0 ? void 0 : _h.updateCellYdoc(changes);
356
+ }
327
357
  ctx.luckysheet_select_save = [{
328
358
  row: [minh, maxh],
329
359
  column: [minc, maxc]
@@ -348,7 +378,7 @@ function pasteHandler(ctx, data, borderInfo) {
348
378
  }
349
379
  var d = (0, _context.getFlowdata)(ctx);
350
380
  if (!d) return;
351
- var last = (_g = ctx.luckysheet_select_save) === null || _g === void 0 ? void 0 : _g[ctx.luckysheet_select_save.length - 1];
381
+ var last = (_j = ctx.luckysheet_select_save) === null || _j === void 0 ? void 0 : _j[ctx.luckysheet_select_save.length - 1];
352
382
  if (!last) return;
353
383
  var curR = last.row == null ? 0 : last.row[0];
354
384
  var curC = last.column == null ? 0 : last.column[0];
@@ -373,6 +403,7 @@ function pasteHandler(ctx, data, borderInfo) {
373
403
  if (!/^(https?:\/\/|www\.)\S+$/i.test(t)) return null;
374
404
  return t.startsWith("http") ? t : "https://".concat(t);
375
405
  };
406
+ var changes = [];
376
407
  for (var r = 0; r < rlen; r += 1) {
377
408
  var x = d[r + curR];
378
409
  for (var c = 0; c < clen; c += 1) {
@@ -445,9 +476,23 @@ function pasteHandler(ctx, data, borderInfo) {
445
476
  }
446
477
  x[c + curC] = cell;
447
478
  }
479
+ changes.push(changes.push({
480
+ sheetId: ctx.currentSheetId,
481
+ path: ["celldata"],
482
+ value: {
483
+ r: r,
484
+ c: c,
485
+ v: d[r][c]
486
+ },
487
+ key: "".concat(r, "_").concat(c),
488
+ type: "update"
489
+ }));
448
490
  }
449
491
  d[r + curR] = x;
450
492
  }
493
+ if ((_k = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _k === void 0 ? void 0 : _k.updateCellYdoc) {
494
+ (_l = ctx.hooks) === null || _l === void 0 ? void 0 : _l.updateCellYdoc(changes);
495
+ }
451
496
  last.row = [curR, curR + rlen - 1];
452
497
  last.column = [curC, curC + clen - 1];
453
498
  (0, _refresh.jfrefreshgrid)(ctx, null, undefined);
@@ -144,6 +144,7 @@ function getCellValue(r, c, data, attr) {
144
144
  }
145
145
  function setCellValue(ctx, r, c, d, v) {
146
146
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
147
+ console.log("setCellValue", r, c, v);
147
148
  if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
148
149
  if (_lodash.default.isNil(d)) {
149
150
  d = (0, _context.getFlowdata)(ctx);
@@ -427,6 +427,9 @@ function fillCopy(data, len) {
427
427
  var index = (i - 1) % data.length;
428
428
  var d = _lodash.default.cloneDeep(data[index]);
429
429
  if (!_lodash.default.isUndefined(d)) {
430
+ if (d) {
431
+ delete d.ps;
432
+ }
430
433
  applyData.push(d);
431
434
  }
432
435
  }
@@ -1323,6 +1326,9 @@ function getDataByType(data, len, direction, type, dataType) {
1323
1326
  applyData = fillCopy(data, len);
1324
1327
  }
1325
1328
  }
1329
+ applyData.forEach(function (c) {
1330
+ if (c != null) delete c.ps;
1331
+ });
1326
1332
  return applyData;
1327
1333
  }
1328
1334
  function getCopyData(d, r1, r2, c1, c2, direction) {
@@ -2189,6 +2195,7 @@ function updateDropCell(ctx) {
2189
2195
  }
2190
2196
  }
2191
2197
  }
2198
+ file.dataVerification = dataVerification;
2192
2199
  (0, _refresh.jfrefreshgrid)(ctx, d, ctx.luckysheet_select_save);
2193
2200
  }
2194
2201
  function onDropCellSelectEnd(ctx, e, container) {
@@ -55,6 +55,7 @@ function getCellHyperlink(ctx, r, c) {
55
55
  return undefined;
56
56
  }
57
57
  function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress) {
58
+ var _a, _b;
58
59
  var sheetIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
59
60
  var flowdata = (0, _context.getFlowdata)(ctx);
60
61
  if (sheetIndex != null && flowdata != null && linkType && linkAddress) {
@@ -75,6 +76,19 @@ function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress) {
75
76
  };
76
77
  flowdata[r][c] = cell;
77
78
  ctx.linkCard = undefined;
79
+ if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _a === void 0 ? void 0 : _a.updateCellYdoc) {
80
+ (_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc([{
81
+ sheetId: ctx.currentSheetId,
82
+ path: ["celldata"],
83
+ value: {
84
+ r: r,
85
+ c: c,
86
+ v: cell
87
+ },
88
+ key: "".concat(r, "_").concat(c),
89
+ type: "update"
90
+ }]);
91
+ }
78
92
  }
79
93
  }
80
94
  function removeHyperlink(ctx, r, c) {
@@ -1531,7 +1531,7 @@ function copy(ctx) {
1531
1531
  }
1532
1532
  }
1533
1533
  function deleteSelectedCellText(ctx) {
1534
- var _a, _b, _c;
1534
+ var _a, _b, _c, _d;
1535
1535
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
1536
1536
  if (allowEdit === false || ctx.isFlvReadOnly) {
1537
1537
  return "allowEdit";
@@ -1560,6 +1560,7 @@ function deleteSelectedCellText(ctx) {
1560
1560
  var r2 = selection[s].row[1];
1561
1561
  var c1 = selection[s].column[0];
1562
1562
  var c2 = selection[s].column[1];
1563
+ var changes = [];
1563
1564
  for (var r = r1; r <= r2; r += 1) {
1564
1565
  for (var c = c1; c <= c2; c += 1) {
1565
1566
  var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
@@ -1588,6 +1589,18 @@ function deleteSelectedCellText(ctx) {
1588
1589
  if (hyperlinkMap && hyperlinkMap["".concat(r, "_").concat(c)]) {
1589
1590
  delete hyperlinkMap["".concat(r, "_").concat(c)];
1590
1591
  }
1592
+ if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.afterUpdateCell) {
1593
+ ctx.hooks.afterUpdateCell(r, c, null, d[r][c]);
1594
+ }
1595
+ changes.push({
1596
+ sheetId: ctx.currentSheetId,
1597
+ path: ["celldata"],
1598
+ value: {
1599
+ r: r,
1600
+ c: c,
1601
+ v: d[r][c]
1602
+ }
1603
+ });
1591
1604
  }
1592
1605
  }
1593
1606
  }
@@ -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) {
@@ -48,12 +48,14 @@ var _conditionalFormat = require("./conditionalFormat");
48
48
  var _text = require("./text");
49
49
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
50
50
  function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col_ed, canvas) {
51
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
52
- var _7;
51
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
52
+ var _11;
53
+ console.log("updateFormatCell", row_st, row_ed, col_st, col_ed);
53
54
  if (_lodash.default.isNil(d) || _lodash.default.isNil(attr)) {
54
55
  return;
55
56
  }
56
57
  if (attr === "ct") {
58
+ var changes = [];
57
59
  for (var r = row_st; r <= row_ed; r += 1) {
58
60
  if (!_lodash.default.isNil(ctx.config.rowhidden) && !_lodash.default.isNil(ctx.config.rowhidden[r])) {
59
61
  continue;
@@ -105,6 +107,20 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
105
107
  m: mask
106
108
  };
107
109
  }
110
+ changes.push({
111
+ sheetId: ctx.currentSheetId,
112
+ path: ["celldata"],
113
+ value: {
114
+ r: r,
115
+ c: c,
116
+ v: d[r][c]
117
+ },
118
+ key: "".concat(r, "_").concat(c),
119
+ type: "update"
120
+ });
121
+ }
122
+ if ((_x = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _x === void 0 ? void 0 : _x.updateCellYdoc) {
123
+ (_y = ctx.hooks) === null || _y === void 0 ? void 0 : _y.updateCellYdoc(changes);
108
124
  }
109
125
  }
110
126
  } else {
@@ -151,6 +167,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
151
167
  if (sheetIndex == null) {
152
168
  return;
153
169
  }
170
+ var changes = [];
154
171
  for (var r = row_st; r <= row_ed; r += 1) {
155
172
  if (!_lodash.default.isNil(ctx.config.rowhidden) && !_lodash.default.isNil(ctx.config.rowhidden[r])) {
156
173
  continue;
@@ -160,11 +177,11 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
160
177
  if (value && _lodash.default.isPlainObject(value)) {
161
178
  (0, _inlineString.updateInlineStringFormatOutside)(value, attr, foucsStatus);
162
179
  value[attr] = foucsStatus;
163
- (_7 = ctx.luckysheetfile[sheetIndex]).config || (_7.config = {});
180
+ (_11 = ctx.luckysheetfile[sheetIndex]).config || (_11.config = {});
164
181
  var cfg = ctx.luckysheetfile[sheetIndex].config;
165
- var cellWidth = ((_x = cfg.columnlen) === null || _x === void 0 ? void 0 : _x[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
182
+ var cellWidth = ((_z = cfg.columnlen) === null || _z === void 0 ? void 0 : _z[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
166
183
  if (attr === "tb" && canvas && foucsStatus === "2") {
167
- var currentColWidth_1 = ((_y = cfg.columnlen) === null || _y === void 0 ? void 0 : _y[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
184
+ var currentColWidth_1 = ((_0 = cfg.columnlen) === null || _0 === void 0 ? void 0 : _0[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
168
185
  var lineCount_1 = 1;
169
186
  var fontString_1 = "10px Arial";
170
187
  if (value.fs) {
@@ -177,9 +194,9 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
177
194
  lineCount_1 = (0, _utils.getLineCount)(value.m, currentColWidth_1, fontString_1);
178
195
  var hOffset = lineCount_1 < 4 ? 1.9 : 1.7;
179
196
  lineCount_1 = lineCount_1 * hOffset + 1;
180
- } 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) {
197
+ } else if ((_3 = (_2 = (_1 = value === null || value === void 0 ? void 0 : value.ct) === null || _1 === void 0 ? void 0 : _1.s) === null || _2 === void 0 ? void 0 : _2[0]) === null || _3 === void 0 ? void 0 : _3.v) {
181
198
  lineCount_1 -= 1;
182
- 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");
199
+ var line = (_6 = (_5 = (_4 = value === null || value === void 0 ? void 0 : value.ct) === null || _4 === void 0 ? void 0 : _4.s) === null || _5 === void 0 ? void 0 : _5[0]) === null || _6 === void 0 ? void 0 : _6.v.split("\n");
183
200
  line.forEach(function (item) {
184
201
  var subLineCount = (0, _utils.getLineCount)(item, currentColWidth_1, fontString_1);
185
202
  lineCount_1 += subLineCount;
@@ -199,7 +216,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
199
216
  });
200
217
  if (!textInfo) return "continue";
201
218
  var rowHeight = _lodash.default.round(textInfo.textHeightAll);
202
- var currentRowHeight = ((_5 = cfg.rowlen) === null || _5 === void 0 ? void 0 : _5[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
219
+ var currentRowHeight = ((_7 = cfg.rowlen) === null || _7 === void 0 ? void 0 : _7[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
203
220
  if (!_lodash.default.isUndefined(rowHeight) && rowHeight > currentRowHeight && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
204
221
  if (_lodash.default.isUndefined(cfg.rowlen)) cfg.rowlen = {};
205
222
  _lodash.default.set(cfg, "rowlen.".concat(r), rowHeight);
@@ -214,7 +231,7 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
214
231
  });
215
232
  if (!textInfo) return "continue";
216
233
  var newHeight = _lodash.default.round(textInfo.textHeightAll);
217
- var oldHeight = ((_6 = cfg.rowlen) === null || _6 === void 0 ? void 0 : _6[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
234
+ var oldHeight = ((_8 = cfg.rowlen) === null || _8 === void 0 ? void 0 : _8[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
218
235
  var shouldResize = foucsStatus === "2" ? newHeight > oldHeight : true;
219
236
  if (shouldResize && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
220
237
  var padding = 12;
@@ -229,11 +246,25 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
229
246
  };
230
247
  d[r][c][attr] = foucsStatus;
231
248
  }
249
+ changes.push({
250
+ sheetId: ctx.currentSheetId,
251
+ path: ["celldata"],
252
+ value: {
253
+ r: r,
254
+ c: c,
255
+ v: d[r][c]
256
+ },
257
+ key: "".concat(r, "_").concat(c),
258
+ type: "update"
259
+ });
232
260
  };
233
261
  for (var c = col_st; c <= col_ed; c += 1) {
234
262
  _loop_1(c);
235
263
  }
236
264
  }
265
+ if ((_9 = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _9 === void 0 ? void 0 : _9.updateCellYdoc) {
266
+ (_10 = ctx.hooks) === null || _10 === void 0 ? void 0 : _10.updateCellYdoc(changes);
267
+ }
237
268
  }
238
269
  }
239
270
  function updateFormat(ctx, $input, d, attr, foucsStatus, canvas) {
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,13 @@ 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;
59
84
  };
60
85
  type CommentUIDragFn = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
61
86
  export type Settings = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.2.94",
3
+ "version": "1.2.95-ydoc",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",