@fileverse-dev/fortune-react 1.3.3 → 1.3.5

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.
@@ -974,7 +974,8 @@ var ContextMenu = function ContextMenu() {
974
974
  key: name,
975
975
  onClick: function onClick() {
976
976
  setContext(function (draftCtx) {
977
- handleLink(draftCtx);
977
+ var _a;
978
+ handleLink(draftCtx, (_a = refs.cellInput.current) !== null && _a !== void 0 ? _a : undefined);
978
979
  draftCtx.contextMenu = {};
979
980
  });
980
981
  }
@@ -144,7 +144,7 @@ var DataVerification = function DataVerification() {
144
144
  var matchingCells = findMatchingCells(context, sourceCell.row, sourceCell.col);
145
145
  if (matchingCells.length > 1) {
146
146
  var allMatchingRange_1 = cellsToRangeString(context, matchingCells);
147
- showDialog("Found ".concat(matchingCells.length, " cells with matching validation. Apply changes to:"), "yesno", "Apply Changes", "All Matching Cells", "Just Selected Range", function () {
147
+ showDialog("There are ".concat(matchingCells.length, " cells with the same validation. Do you want to make changes to all of them?"), "yesno", "Apply Changes", "All other cells", "Just this instance", function () {
148
148
  applyValidation(allMatchingRange_1);
149
149
  hideDialog();
150
150
  }, function () {
@@ -9,7 +9,7 @@ var __assign = this && this.__assign || function () {
9
9
  return __assign.apply(this, arguments);
10
10
  };
11
11
  import React, { useContext, useState, useMemo, useCallback, useLayoutEffect, useRef, useEffect } from "react";
12
- import { locale, saveHyperlink, removeHyperlink, replaceHtml, goToLink, isLinkValid } from "@fileverse-dev/fortune-core";
12
+ import { locale, saveHyperlink, removeHyperlink, replaceHtml, goToLink, isLinkValid, jfrefreshgrid } from "@fileverse-dev/fortune-core";
13
13
  import { Button, TextField, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, LucideIcon } from "@fileverse/ui";
14
14
  import "./index.css";
15
15
  import _ from "lodash";
@@ -23,7 +23,8 @@ export var LinkEditCard = function LinkEditCard(_a) {
23
23
  originType = _a.originType,
24
24
  originAddress = _a.originAddress,
25
25
  isEditing = _a.isEditing,
26
- position = _a.position;
26
+ position = _a.position,
27
+ applyToSelection = _a.applyToSelection;
27
28
  var _b = useContext(WorkbookContext),
28
29
  context = _b.context,
29
30
  setContext = _b.setContext,
@@ -86,7 +87,14 @@ export var LinkEditCard = function LinkEditCard(_a) {
86
87
  if (e.key === "Enter") {
87
88
  _.set(refs.globalCache, "linkCard.mouseEnter", false);
88
89
  setContext(function (draftCtx) {
89
- return saveHyperlink(draftCtx, r, c, linkText, linkType, linkAddress);
90
+ saveHyperlink(draftCtx, r, c, linkText, linkType, linkAddress, {
91
+ applyToSelection: applyToSelection || undefined,
92
+ cellInput: refs.cellInput.current
93
+ });
94
+ if (!applyToSelection) {
95
+ draftCtx.luckysheetCellUpdate = [];
96
+ jfrefreshgrid(draftCtx, null, undefined);
97
+ }
90
98
  });
91
99
  }
92
100
  },
@@ -94,7 +102,7 @@ export var LinkEditCard = function LinkEditCard(_a) {
94
102
  return e.stopPropagation();
95
103
  }
96
104
  };
97
- }, [refs.globalCache, isButtonDisabled]);
105
+ }, [refs.globalCache, isButtonDisabled, applyToSelection, linkText, linkType, linkAddress, r, c, setContext, refs.cellInput]);
98
106
  var renderToolbarButton = useCallback(function (iconId, onClick) {
99
107
  var iconIdClass = iconId.replace(/[^a-zA-Z0-9-]/g, "-").replace(/-+/g, "-");
100
108
  return /*#__PURE__*/React.createElement("div", {
@@ -288,7 +296,14 @@ export var LinkEditCard = function LinkEditCard(_a) {
288
296
  if (isButtonDisabled) return;
289
297
  _.set(refs.globalCache, "linkCard.mouseEnter", false);
290
298
  setContext(function (draftCtx) {
291
- return saveHyperlink(draftCtx, r, c, linkText, linkType, linkAddress);
299
+ saveHyperlink(draftCtx, r, c, linkText, linkType, linkAddress, {
300
+ applyToSelection: applyToSelection || undefined,
301
+ cellInput: refs.cellInput.current
302
+ });
303
+ if (!applyToSelection) {
304
+ draftCtx.luckysheetCellUpdate = [];
305
+ jfrefreshgrid(draftCtx, null, undefined);
306
+ }
292
307
  });
293
308
  },
294
309
  "data-testid": "link-card-cta-insert"
@@ -262,7 +262,7 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
262
262
  var history = globalCache.current.undoList.pop();
263
263
  if (history) {
264
264
  setContext(function (ctx_) {
265
- var _a, _b, _c, _d, _e, _f, _g;
265
+ var _a, _b, _c, _d, _e, _f, _g, _h;
266
266
  var isBorderUndo = history.patches.some(function (onePatch) {
267
267
  var _a;
268
268
  return (_a = onePatch.value) === null || _a === void 0 ? void 0 : _a.borderInfo;
@@ -299,16 +299,19 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
299
299
  delete inversedOptions.addSheet.value.data;
300
300
  }
301
301
  emitOp(newContext, history.inversePatches, inversedOptions, true);
302
- var nw = __assign({}, newContext);
302
+ var sheetIdxAfterUndo = getSheetIndex(newContext, newContext.currentSheetId);
303
+ var nw = __assign(__assign({}, newContext), sheetIdxAfterUndo != null && ((_f = newContext.luckysheetfile[sheetIdxAfterUndo]) === null || _f === void 0 ? void 0 : _f.config) != null ? {
304
+ config: newContext.luckysheetfile[sheetIdxAfterUndo].config
305
+ } : {});
303
306
  if (isBorderUndo) {
304
- var nwborderlist = (_g = (_f = nw === null || nw === void 0 ? void 0 : nw.config) === null || _f === void 0 ? void 0 : _f.borderInfo) === null || _g === void 0 ? void 0 : _g.slice(0, -1);
307
+ var nwborderlist = (_h = (_g = nw === null || nw === void 0 ? void 0 : nw.config) === null || _g === void 0 ? void 0 : _g.borderInfo) === null || _h === void 0 ? void 0 : _h.slice(0, -1);
305
308
  nw = __assign(__assign({}, nw), {
306
309
  config: __assign(__assign({}, nw.config), {
307
310
  borderInfo: nwborderlist
308
311
  })
309
312
  });
310
313
  }
311
- return isBorderUndo ? nw : newContext;
314
+ return nw;
312
315
  });
313
316
  }
314
317
  }, [emitOp, globalCache]);
@@ -316,7 +319,7 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
316
319
  var history = globalCache.current.redoList.pop();
317
320
  if (history) {
318
321
  setContext(function (ctx_) {
319
- var _a, _b, _c;
322
+ var _a, _b, _c, _d;
320
323
  var newContext = applyPatches(ctx_, history.patches);
321
324
  var isBorderUndo = history.patches.some(function (onePatch) {
322
325
  var _a;
@@ -324,16 +327,19 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
324
327
  });
325
328
  globalCache.current.undoList.push(history);
326
329
  emitOp(newContext, history.patches, history.options);
327
- var nw = __assign({}, newContext);
330
+ var sheetIdxAfterRedo = getSheetIndex(newContext, newContext.currentSheetId);
331
+ var nw = __assign(__assign({}, newContext), sheetIdxAfterRedo != null && ((_a = newContext.luckysheetfile[sheetIdxAfterRedo]) === null || _a === void 0 ? void 0 : _a.config) != null ? {
332
+ config: newContext.luckysheetfile[sheetIdxAfterRedo].config
333
+ } : {});
328
334
  if (isBorderUndo) {
329
- var nwborderlist = ((_b = (_a = nw === null || nw === void 0 ? void 0 : nw.config) === null || _a === void 0 ? void 0 : _a.borderInfo) !== null && _b !== void 0 ? _b : []).concat((_c = history.patches[0].value) === null || _c === void 0 ? void 0 : _c.borderInfo[0]);
335
+ var nwborderlist = ((_c = (_b = nw === null || nw === void 0 ? void 0 : nw.config) === null || _b === void 0 ? void 0 : _b.borderInfo) !== null && _c !== void 0 ? _c : []).concat((_d = history.patches[0].value) === null || _d === void 0 ? void 0 : _d.borderInfo[0]);
330
336
  nw = __assign(__assign({}, nw), {
331
337
  config: __assign(__assign({}, nw.config), {
332
338
  borderInfo: nwborderlist
333
339
  })
334
340
  });
335
341
  }
336
- return isBorderUndo ? nw : newContext;
342
+ return nw;
337
343
  });
338
344
  }
339
345
  }, [emitOp, globalCache]);
@@ -983,7 +983,8 @@ var ContextMenu = function ContextMenu() {
983
983
  key: name,
984
984
  onClick: function onClick() {
985
985
  setContext(function (draftCtx) {
986
- (0, _fortuneCore.handleLink)(draftCtx);
986
+ var _a;
987
+ (0, _fortuneCore.handleLink)(draftCtx, (_a = refs.cellInput.current) !== null && _a !== void 0 ? _a : undefined);
987
988
  draftCtx.contextMenu = {};
988
989
  });
989
990
  }
@@ -153,7 +153,7 @@ var DataVerification = function DataVerification() {
153
153
  var matchingCells = (0, _helpers.findMatchingCells)(context, sourceCell.row, sourceCell.col);
154
154
  if (matchingCells.length > 1) {
155
155
  var allMatchingRange_1 = (0, _helpers.cellsToRangeString)(context, matchingCells);
156
- showDialog("Found ".concat(matchingCells.length, " cells with matching validation. Apply changes to:"), "yesno", "Apply Changes", "All Matching Cells", "Just Selected Range", function () {
156
+ showDialog("There are ".concat(matchingCells.length, " cells with the same validation. Do you want to make changes to all of them?"), "yesno", "Apply Changes", "All other cells", "Just this instance", function () {
157
157
  applyValidation(allMatchingRange_1);
158
158
  hideDialog();
159
159
  }, function () {
@@ -32,7 +32,8 @@ var LinkEditCard = exports.LinkEditCard = function LinkEditCard(_a) {
32
32
  originType = _a.originType,
33
33
  originAddress = _a.originAddress,
34
34
  isEditing = _a.isEditing,
35
- position = _a.position;
35
+ position = _a.position,
36
+ applyToSelection = _a.applyToSelection;
36
37
  var _b = (0, _react.useContext)(_context.default),
37
38
  context = _b.context,
38
39
  setContext = _b.setContext,
@@ -95,7 +96,14 @@ var LinkEditCard = exports.LinkEditCard = function LinkEditCard(_a) {
95
96
  if (e.key === "Enter") {
96
97
  _lodash.default.set(refs.globalCache, "linkCard.mouseEnter", false);
97
98
  setContext(function (draftCtx) {
98
- return (0, _fortuneCore.saveHyperlink)(draftCtx, r, c, linkText, linkType, linkAddress);
99
+ (0, _fortuneCore.saveHyperlink)(draftCtx, r, c, linkText, linkType, linkAddress, {
100
+ applyToSelection: applyToSelection || undefined,
101
+ cellInput: refs.cellInput.current
102
+ });
103
+ if (!applyToSelection) {
104
+ draftCtx.luckysheetCellUpdate = [];
105
+ (0, _fortuneCore.jfrefreshgrid)(draftCtx, null, undefined);
106
+ }
99
107
  });
100
108
  }
101
109
  },
@@ -103,7 +111,7 @@ var LinkEditCard = exports.LinkEditCard = function LinkEditCard(_a) {
103
111
  return e.stopPropagation();
104
112
  }
105
113
  };
106
- }, [refs.globalCache, isButtonDisabled]);
114
+ }, [refs.globalCache, isButtonDisabled, applyToSelection, linkText, linkType, linkAddress, r, c, setContext, refs.cellInput]);
107
115
  var renderToolbarButton = (0, _react.useCallback)(function (iconId, onClick) {
108
116
  var iconIdClass = iconId.replace(/[^a-zA-Z0-9-]/g, "-").replace(/-+/g, "-");
109
117
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -297,7 +305,14 @@ var LinkEditCard = exports.LinkEditCard = function LinkEditCard(_a) {
297
305
  if (isButtonDisabled) return;
298
306
  _lodash.default.set(refs.globalCache, "linkCard.mouseEnter", false);
299
307
  setContext(function (draftCtx) {
300
- return (0, _fortuneCore.saveHyperlink)(draftCtx, r, c, linkText, linkType, linkAddress);
308
+ (0, _fortuneCore.saveHyperlink)(draftCtx, r, c, linkText, linkType, linkAddress, {
309
+ applyToSelection: applyToSelection || undefined,
310
+ cellInput: refs.cellInput.current
311
+ });
312
+ if (!applyToSelection) {
313
+ draftCtx.luckysheetCellUpdate = [];
314
+ (0, _fortuneCore.jfrefreshgrid)(draftCtx, null, undefined);
315
+ }
301
316
  });
302
317
  },
303
318
  "data-testid": "link-card-cta-insert"
@@ -271,7 +271,7 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
271
271
  var history = globalCache.current.undoList.pop();
272
272
  if (history) {
273
273
  setContext(function (ctx_) {
274
- var _a, _b, _c, _d, _e, _f, _g;
274
+ var _a, _b, _c, _d, _e, _f, _g, _h;
275
275
  var isBorderUndo = history.patches.some(function (onePatch) {
276
276
  var _a;
277
277
  return (_a = onePatch.value) === null || _a === void 0 ? void 0 : _a.borderInfo;
@@ -308,16 +308,19 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
308
308
  delete inversedOptions.addSheet.value.data;
309
309
  }
310
310
  emitOp(newContext, history.inversePatches, inversedOptions, true);
311
- var nw = __assign({}, newContext);
311
+ var sheetIdxAfterUndo = (0, _fortuneCore.getSheetIndex)(newContext, newContext.currentSheetId);
312
+ var nw = __assign(__assign({}, newContext), sheetIdxAfterUndo != null && ((_f = newContext.luckysheetfile[sheetIdxAfterUndo]) === null || _f === void 0 ? void 0 : _f.config) != null ? {
313
+ config: newContext.luckysheetfile[sheetIdxAfterUndo].config
314
+ } : {});
312
315
  if (isBorderUndo) {
313
- var nwborderlist = (_g = (_f = nw === null || nw === void 0 ? void 0 : nw.config) === null || _f === void 0 ? void 0 : _f.borderInfo) === null || _g === void 0 ? void 0 : _g.slice(0, -1);
316
+ var nwborderlist = (_h = (_g = nw === null || nw === void 0 ? void 0 : nw.config) === null || _g === void 0 ? void 0 : _g.borderInfo) === null || _h === void 0 ? void 0 : _h.slice(0, -1);
314
317
  nw = __assign(__assign({}, nw), {
315
318
  config: __assign(__assign({}, nw.config), {
316
319
  borderInfo: nwborderlist
317
320
  })
318
321
  });
319
322
  }
320
- return isBorderUndo ? nw : newContext;
323
+ return nw;
321
324
  });
322
325
  }
323
326
  }, [emitOp, globalCache]);
@@ -325,7 +328,7 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
325
328
  var history = globalCache.current.redoList.pop();
326
329
  if (history) {
327
330
  setContext(function (ctx_) {
328
- var _a, _b, _c;
331
+ var _a, _b, _c, _d;
329
332
  var newContext = (0, _immer.applyPatches)(ctx_, history.patches);
330
333
  var isBorderUndo = history.patches.some(function (onePatch) {
331
334
  var _a;
@@ -333,16 +336,19 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
333
336
  });
334
337
  globalCache.current.undoList.push(history);
335
338
  emitOp(newContext, history.patches, history.options);
336
- var nw = __assign({}, newContext);
339
+ var sheetIdxAfterRedo = (0, _fortuneCore.getSheetIndex)(newContext, newContext.currentSheetId);
340
+ var nw = __assign(__assign({}, newContext), sheetIdxAfterRedo != null && ((_a = newContext.luckysheetfile[sheetIdxAfterRedo]) === null || _a === void 0 ? void 0 : _a.config) != null ? {
341
+ config: newContext.luckysheetfile[sheetIdxAfterRedo].config
342
+ } : {});
337
343
  if (isBorderUndo) {
338
- var nwborderlist = ((_b = (_a = nw === null || nw === void 0 ? void 0 : nw.config) === null || _a === void 0 ? void 0 : _a.borderInfo) !== null && _b !== void 0 ? _b : []).concat((_c = history.patches[0].value) === null || _c === void 0 ? void 0 : _c.borderInfo[0]);
344
+ var nwborderlist = ((_c = (_b = nw === null || nw === void 0 ? void 0 : nw.config) === null || _b === void 0 ? void 0 : _b.borderInfo) !== null && _c !== void 0 ? _c : []).concat((_d = history.patches[0].value) === null || _d === void 0 ? void 0 : _d.borderInfo[0]);
339
345
  nw = __assign(__assign({}, nw), {
340
346
  config: __assign(__assign({}, nw.config), {
341
347
  borderInfo: nwborderlist
342
348
  })
343
349
  });
344
350
  }
345
- return isBorderUndo ? nw : newContext;
351
+ return nw;
346
352
  });
347
353
  }
348
354
  }, [emitOp, globalCache]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "module": "es/index.js",
@@ -16,7 +16,7 @@
16
16
  "tsc": "tsc"
17
17
  },
18
18
  "dependencies": {
19
- "@fileverse-dev/fortune-core": "1.3.3",
19
+ "@fileverse-dev/fortune-core": "1.3.5",
20
20
  "@fileverse/ui": "5.0.0",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",