@fileverse-dev/fortune-core 1.3.10-yjs-5 → 1.3.10-yjs-6

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/sheet.js CHANGED
@@ -146,7 +146,7 @@ function generateCopySheetName(ctx, sheetId) {
146
146
  return sheetCopyName;
147
147
  }
148
148
  export function copySheet(ctx, sheetId) {
149
- var _a, _b, _c;
149
+ var _a, _b, _c, _d, _e;
150
150
  var index = getSheetIndex(ctx, sheetId);
151
151
  var order = ctx.luckysheetfile[index].order + 1;
152
152
  var sheetName = generateCopySheetName(ctx, sheetId);
@@ -183,6 +183,33 @@ export function copySheet(ctx, sheetId) {
183
183
  var sheetOrderList = {};
184
184
  sheetOrderList[newSheetId] = order;
185
185
  api.setSheetOrder(ctx, sheetOrderList);
186
+ if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateAllCell) {
187
+ ctx.hooks.updateAllCell(newSheetId);
188
+ } else if ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc) {
189
+ var changes_1 = [];
190
+ var celldata = newSheet.celldata || dataToCelldata(newSheet.data);
191
+ if (Array.isArray(celldata)) {
192
+ celldata.forEach(function (d) {
193
+ var _a;
194
+ if (d == null) return;
195
+ var r = d.r;
196
+ var c = d.c;
197
+ if (!_.isNumber(r) || !_.isNumber(c)) return;
198
+ changes_1.push({
199
+ sheetId: newSheetId,
200
+ path: ["celldata"],
201
+ key: "".concat(r, "_").concat(c),
202
+ value: {
203
+ r: r,
204
+ c: c,
205
+ v: (_a = d.v) !== null && _a !== void 0 ? _a : null
206
+ },
207
+ type: d.v == null ? "delete" : "update"
208
+ });
209
+ });
210
+ }
211
+ if (changes_1.length > 0) ctx.hooks.updateCellYdoc(changes_1);
212
+ }
186
213
  }
187
214
  export function calculateSheetFromula(ctx, id) {
188
215
  var _a, _b, _c;
@@ -850,10 +850,12 @@ export function handleFormatPainter(ctx) {
850
850
  ctx.luckysheetPaintSingle = true;
851
851
  }
852
852
  export function handleClearFormat(ctx) {
853
- var _a;
853
+ var _a, _b, _c, _d, _e, _f, _g;
854
854
  if (ctx.allowEdit === false) return;
855
855
  var flowdata = getFlowdata(ctx);
856
856
  if (!flowdata) return;
857
+ var ydocChanges = [];
858
+ var borderInfoChanged = false;
857
859
  (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a.every(function (selection) {
858
860
  var _a = selection.row,
859
861
  rowSt = _a[0],
@@ -869,6 +871,17 @@ export function handleClearFormat(ctx) {
869
871
  var cell = flowdata[r][c];
870
872
  if (!cell) continue;
871
873
  flowdata[r][c] = _.pick(cell, "v", "m", "mc", "f", "ct");
874
+ ydocChanges.push({
875
+ sheetId: ctx.currentSheetId,
876
+ path: ["celldata"],
877
+ key: "".concat(r, "_").concat(c),
878
+ value: {
879
+ r: r,
880
+ c: c,
881
+ v: flowdata[r][c]
882
+ },
883
+ type: "update"
884
+ });
872
885
  }
873
886
  }
874
887
  var index = getSheetIndex(ctx, ctx.currentSheetId);
@@ -904,9 +917,25 @@ export function handleClearFormat(ctx) {
904
917
  }
905
918
  }
906
919
  ctx.luckysheetfile[index].config.borderInfo = source_borderInfo;
920
+ borderInfoChanged = true;
907
921
  }
908
922
  return true;
909
923
  });
924
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
925
+ if (borderInfoChanged) {
926
+ var index = getSheetIndex(ctx, ctx.currentSheetId);
927
+ var borderInfo = index == null ? (_d = (_c = ctx.config) === null || _c === void 0 ? void 0 : _c.borderInfo) !== null && _d !== void 0 ? _d : [] : (_g = (_f = (_e = ctx.luckysheetfile[index]) === null || _e === void 0 ? void 0 : _e.config) === null || _f === void 0 ? void 0 : _f.borderInfo) !== null && _g !== void 0 ? _g : [];
928
+ ydocChanges.push({
929
+ sheetId: ctx.currentSheetId,
930
+ path: ["config", "borderInfo"],
931
+ value: borderInfo,
932
+ type: "update"
933
+ });
934
+ }
935
+ if (ydocChanges.length > 0) {
936
+ ctx.hooks.updateCellYdoc(ydocChanges);
937
+ }
938
+ }
910
939
  }
911
940
  export function handleTextColor(ctx, cellInput, color) {
912
941
  setAttr(ctx, cellInput, "fc", color);
package/es/settings.d.ts CHANGED
@@ -79,6 +79,8 @@ export type Hooks = {
79
79
  afterIframesChange?: () => void;
80
80
  afterFrozenChange?: () => void;
81
81
  afterOrderChanges?: () => void;
82
+ afterColorChanges?: () => void;
83
+ afterHideChanges?: () => void;
82
84
  afterConfigChanges?: () => void;
83
85
  afterColRowChanges?: () => void;
84
86
  afterShowGridLinesChange?: () => void;
package/lib/api/sheet.js CHANGED
@@ -164,7 +164,7 @@ function generateCopySheetName(ctx, sheetId) {
164
164
  return sheetCopyName;
165
165
  }
166
166
  function copySheet(ctx, sheetId) {
167
- var _a, _b, _c;
167
+ var _a, _b, _c, _d, _e;
168
168
  var index = (0, _utils.getSheetIndex)(ctx, sheetId);
169
169
  var order = ctx.luckysheetfile[index].order + 1;
170
170
  var sheetName = generateCopySheetName(ctx, sheetId);
@@ -201,6 +201,33 @@ function copySheet(ctx, sheetId) {
201
201
  var sheetOrderList = {};
202
202
  sheetOrderList[newSheetId] = order;
203
203
  _2.api.setSheetOrder(ctx, sheetOrderList);
204
+ if ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _d === void 0 ? void 0 : _d.updateAllCell) {
205
+ ctx.hooks.updateAllCell(newSheetId);
206
+ } else if ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _e === void 0 ? void 0 : _e.updateCellYdoc) {
207
+ var changes_1 = [];
208
+ var celldata = newSheet.celldata || (0, _common.dataToCelldata)(newSheet.data);
209
+ if (Array.isArray(celldata)) {
210
+ celldata.forEach(function (d) {
211
+ var _a;
212
+ if (d == null) return;
213
+ var r = d.r;
214
+ var c = d.c;
215
+ if (!_lodash.default.isNumber(r) || !_lodash.default.isNumber(c)) return;
216
+ changes_1.push({
217
+ sheetId: newSheetId,
218
+ path: ["celldata"],
219
+ key: "".concat(r, "_").concat(c),
220
+ value: {
221
+ r: r,
222
+ c: c,
223
+ v: (_a = d.v) !== null && _a !== void 0 ? _a : null
224
+ },
225
+ type: d.v == null ? "delete" : "update"
226
+ });
227
+ });
228
+ }
229
+ if (changes_1.length > 0) ctx.hooks.updateCellYdoc(changes_1);
230
+ }
204
231
  }
205
232
  function calculateSheetFromula(ctx, id) {
206
233
  var _a, _b, _c;
@@ -883,10 +883,12 @@ function handleFormatPainter(ctx) {
883
883
  ctx.luckysheetPaintSingle = true;
884
884
  }
885
885
  function handleClearFormat(ctx) {
886
- var _a;
886
+ var _a, _b, _c, _d, _e, _f, _g;
887
887
  if (ctx.allowEdit === false) return;
888
888
  var flowdata = (0, _context.getFlowdata)(ctx);
889
889
  if (!flowdata) return;
890
+ var ydocChanges = [];
891
+ var borderInfoChanged = false;
890
892
  (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a.every(function (selection) {
891
893
  var _a = selection.row,
892
894
  rowSt = _a[0],
@@ -902,6 +904,17 @@ function handleClearFormat(ctx) {
902
904
  var cell = flowdata[r][c];
903
905
  if (!cell) continue;
904
906
  flowdata[r][c] = _lodash.default.pick(cell, "v", "m", "mc", "f", "ct");
907
+ ydocChanges.push({
908
+ sheetId: ctx.currentSheetId,
909
+ path: ["celldata"],
910
+ key: "".concat(r, "_").concat(c),
911
+ value: {
912
+ r: r,
913
+ c: c,
914
+ v: flowdata[r][c]
915
+ },
916
+ type: "update"
917
+ });
905
918
  }
906
919
  }
907
920
  var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
@@ -937,9 +950,25 @@ function handleClearFormat(ctx) {
937
950
  }
938
951
  }
939
952
  ctx.luckysheetfile[index].config.borderInfo = source_borderInfo;
953
+ borderInfoChanged = true;
940
954
  }
941
955
  return true;
942
956
  });
957
+ if ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.hooks) === null || _b === void 0 ? void 0 : _b.updateCellYdoc) {
958
+ if (borderInfoChanged) {
959
+ var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
960
+ var borderInfo = index == null ? (_d = (_c = ctx.config) === null || _c === void 0 ? void 0 : _c.borderInfo) !== null && _d !== void 0 ? _d : [] : (_g = (_f = (_e = ctx.luckysheetfile[index]) === null || _e === void 0 ? void 0 : _e.config) === null || _f === void 0 ? void 0 : _f.borderInfo) !== null && _g !== void 0 ? _g : [];
961
+ ydocChanges.push({
962
+ sheetId: ctx.currentSheetId,
963
+ path: ["config", "borderInfo"],
964
+ value: borderInfo,
965
+ type: "update"
966
+ });
967
+ }
968
+ if (ydocChanges.length > 0) {
969
+ ctx.hooks.updateCellYdoc(ydocChanges);
970
+ }
971
+ }
943
972
  }
944
973
  function handleTextColor(ctx, cellInput, color) {
945
974
  setAttr(ctx, cellInput, "fc", color);
package/lib/settings.d.ts CHANGED
@@ -79,6 +79,8 @@ export type Hooks = {
79
79
  afterIframesChange?: () => void;
80
80
  afterFrozenChange?: () => void;
81
81
  afterOrderChanges?: () => void;
82
+ afterColorChanges?: () => void;
83
+ afterHideChanges?: () => void;
82
84
  afterConfigChanges?: () => void;
83
85
  afterColRowChanges?: () => void;
84
86
  afterShowGridLinesChange?: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.3.10-yjs-5",
3
+ "version": "1.3.10-yjs-6",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",