@fileverse-dev/fortune-react 1.3.4 → 1.3.5-hyper-1

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
  }
@@ -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"
@@ -83,7 +83,7 @@ var SheetOverlay = function SheetOverlay() {
83
83
  }
84
84
  if (skip || ((_a = globalCache.linkCard) === null || _a === void 0 ? void 0 : _a.mouseEnter)) return;
85
85
  setContext(function (draftCtx) {
86
- showLinkCard(draftCtx, r, c, isEditing);
86
+ showLinkCard(draftCtx, r, c, undefined, isEditing);
87
87
  });
88
88
  }, 800);
89
89
  }, [setContext]);
@@ -96,7 +96,7 @@ var SheetOverlay = function SheetOverlay() {
96
96
  debouncedShowLinkCard(globalCache, rc.r, rc.c, false);
97
97
  } else {
98
98
  if ((_a = globalCache.linkCard) === null || _a === void 0 ? void 0 : _a.mouseEnter) return;
99
- showLinkCard(ctx, rc.r, rc.c, false);
99
+ showLinkCard(ctx, rc.r, rc.c, undefined, false);
100
100
  debouncedShowLinkCard(globalCache, rc.r, rc.c, false, true);
101
101
  }
102
102
  }, [debouncedShowLinkCard]);
@@ -643,6 +643,12 @@ var Toolbar = function Toolbar(_a) {
643
643
  window.dataVerificationClick = dataVerificationClick;
644
644
  window.conditionalFormatClick = conditionalFormatClick;
645
645
  }, []);
646
+ useEffect(function () {
647
+ if (cell != null) {
648
+ refs.globalCache.recentTextColor = normalizedCellAttr(cell, "fc");
649
+ refs.globalCache.recentBackgroundColor = normalizedCellAttr(cell, "bg");
650
+ }
651
+ }, [cell, refs.globalCache]);
646
652
  var getToolbarItem = useCallback(function (name, i) {
647
653
  var _a, _b, _c, _d, _e, _f, _g;
648
654
  var tooltip = toolbar[name];
@@ -652,6 +658,8 @@ var Toolbar = function Toolbar(_a) {
652
658
  });
653
659
  }
654
660
  if (["font-color", "background"].includes(name)) {
661
+ var displayTextColor_1 = cell != null ? normalizedCellAttr(cell, "fc") : "#000000";
662
+ var displayBackgroundColor_1 = cell != null ? normalizedCellAttr(cell, "bg") : undefined;
655
663
  var pick_1 = function pick_1(color) {
656
664
  setContext(function (draftCtx) {
657
665
  return (name === "font-color" ? handleTextColor : handleTextBackground)(draftCtx, refs.cellInput.current, color);
@@ -671,7 +679,7 @@ var Toolbar = function Toolbar(_a) {
671
679
  style: {
672
680
  width: 24,
673
681
  height: 4,
674
- backgroundColor: name === "font-color" ? refs.globalCache.recentTextColor : refs.globalCache.recentBackgroundColor,
682
+ backgroundColor: name === "font-color" ? displayTextColor_1 : displayBackgroundColor_1,
675
683
  position: "absolute",
676
684
  bottom: 2,
677
685
  left: 3,
@@ -681,9 +689,9 @@ var Toolbar = function Toolbar(_a) {
681
689
  iconId: name,
682
690
  tooltip: tooltip,
683
691
  showArrow: false,
684
- fillColor: name === "font-color" ? refs.globalCache.recentTextColor : undefined,
692
+ fillColor: name === "font-color" ? displayTextColor_1 : undefined,
685
693
  onClick: function onClick() {
686
- var color = name === "font-color" ? refs.globalCache.recentTextColor : refs.globalCache.recentBackgroundColor;
694
+ var color = name === "font-color" ? displayTextColor_1 : displayBackgroundColor_1;
687
695
  if (color) pick_1(color);
688
696
  }
689
697
  }, function (setOpen) {
@@ -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
  }
@@ -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"
@@ -92,7 +92,7 @@ var SheetOverlay = function SheetOverlay() {
92
92
  }
93
93
  if (skip || ((_a = globalCache.linkCard) === null || _a === void 0 ? void 0 : _a.mouseEnter)) return;
94
94
  setContext(function (draftCtx) {
95
- (0, _fortuneCore.showLinkCard)(draftCtx, r, c, isEditing);
95
+ (0, _fortuneCore.showLinkCard)(draftCtx, r, c, undefined, isEditing);
96
96
  });
97
97
  }, 800);
98
98
  }, [setContext]);
@@ -105,7 +105,7 @@ var SheetOverlay = function SheetOverlay() {
105
105
  debouncedShowLinkCard(globalCache, rc.r, rc.c, false);
106
106
  } else {
107
107
  if ((_a = globalCache.linkCard) === null || _a === void 0 ? void 0 : _a.mouseEnter) return;
108
- (0, _fortuneCore.showLinkCard)(ctx, rc.r, rc.c, false);
108
+ (0, _fortuneCore.showLinkCard)(ctx, rc.r, rc.c, undefined, false);
109
109
  debouncedShowLinkCard(globalCache, rc.r, rc.c, false, true);
110
110
  }
111
111
  }, [debouncedShowLinkCard]);
@@ -652,6 +652,12 @@ var Toolbar = function Toolbar(_a) {
652
652
  window.dataVerificationClick = dataVerificationClick;
653
653
  window.conditionalFormatClick = conditionalFormatClick;
654
654
  }, []);
655
+ (0, _react.useEffect)(function () {
656
+ if (cell != null) {
657
+ refs.globalCache.recentTextColor = (0, _fortuneCore.normalizedCellAttr)(cell, "fc");
658
+ refs.globalCache.recentBackgroundColor = (0, _fortuneCore.normalizedCellAttr)(cell, "bg");
659
+ }
660
+ }, [cell, refs.globalCache]);
655
661
  var getToolbarItem = (0, _react.useCallback)(function (name, i) {
656
662
  var _a, _b, _c, _d, _e, _f, _g;
657
663
  var tooltip = toolbar[name];
@@ -661,6 +667,8 @@ var Toolbar = function Toolbar(_a) {
661
667
  });
662
668
  }
663
669
  if (["font-color", "background"].includes(name)) {
670
+ var displayTextColor_1 = cell != null ? (0, _fortuneCore.normalizedCellAttr)(cell, "fc") : "#000000";
671
+ var displayBackgroundColor_1 = cell != null ? (0, _fortuneCore.normalizedCellAttr)(cell, "bg") : undefined;
664
672
  var pick_1 = function pick_1(color) {
665
673
  setContext(function (draftCtx) {
666
674
  return (name === "font-color" ? _fortuneCore.handleTextColor : _fortuneCore.handleTextBackground)(draftCtx, refs.cellInput.current, color);
@@ -680,7 +688,7 @@ var Toolbar = function Toolbar(_a) {
680
688
  style: {
681
689
  width: 24,
682
690
  height: 4,
683
- backgroundColor: name === "font-color" ? refs.globalCache.recentTextColor : refs.globalCache.recentBackgroundColor,
691
+ backgroundColor: name === "font-color" ? displayTextColor_1 : displayBackgroundColor_1,
684
692
  position: "absolute",
685
693
  bottom: 2,
686
694
  left: 3,
@@ -690,9 +698,9 @@ var Toolbar = function Toolbar(_a) {
690
698
  iconId: name,
691
699
  tooltip: tooltip,
692
700
  showArrow: false,
693
- fillColor: name === "font-color" ? refs.globalCache.recentTextColor : undefined,
701
+ fillColor: name === "font-color" ? displayTextColor_1 : undefined,
694
702
  onClick: function onClick() {
695
- var color = name === "font-color" ? refs.globalCache.recentTextColor : refs.globalCache.recentBackgroundColor;
703
+ var color = name === "font-color" ? displayTextColor_1 : displayBackgroundColor_1;
696
704
  if (color) pick_1(color);
697
705
  }
698
706
  }, function (setOpen) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.3.4",
3
+ "version": "1.3.5-hyper-1",
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.4",
19
+ "@fileverse-dev/fortune-core": "1.3.5-hyper-1",
20
20
  "@fileverse/ui": "5.0.0",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",