@fileverse-dev/fortune-react 1.3.3 → 1.3.4-viewMode-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.
@@ -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 () {
@@ -10,7 +10,7 @@ var __assign = this && this.__assign || function () {
10
10
  };
11
11
  import React, { useContext, useCallback, useRef, useEffect, useLayoutEffect, useMemo } from "react";
12
12
  import "./index.css";
13
- import { locale, drawArrow, handleCellAreaDoubleClick, handleCellAreaMouseDown, handleContextMenu, handleOverlayMouseMove, handleOverlayMouseUp, selectAll, handleOverlayTouchEnd, handleOverlayTouchStart, createDropCellRange, getCellRowColumn, getCellHyperlink, showLinkCard, onCellsMoveStart, insertRowCol, getSheetIndex, fixRowStyleOverflowInFreeze, fixColumnStyleOverflowInFreeze, handleKeydownForZoom } from "@fileverse-dev/fortune-core";
13
+ import { locale, drawArrow, handleCellAreaDoubleClick, handleCellAreaMouseDown, handleContextMenu, handleOverlayMouseMove, handleOverlayMouseUp, selectAll, handleOverlayTouchEnd, handleOverlayTouchStart, createDropCellRange, getCellRowColumn, getCellHyperlink, showLinkCard, goToLink, isAllowEdit, onCellsMoveStart, insertRowCol, getSheetIndex, fixRowStyleOverflowInFreeze, fixColumnStyleOverflowInFreeze, handleKeydownForZoom } from "@fileverse-dev/fortune-core";
14
14
  import _ from "lodash";
15
15
  import WorkbookContext from "../../context";
16
16
  import ColumnHeader from "./ColumnHeader";
@@ -50,14 +50,23 @@ var SheetOverlay = function SheetOverlay() {
50
50
  var _a;
51
51
  handleCellAreaMouseDown(draftCtx, refs.globalCache, nativeEvent, refs.cellInput.current, refs.cellArea.current, refs.fxInput.current, refs.canvas.current.getContext("2d"));
52
52
  if (!_.isEmpty((_a = draftCtx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) && refs.cellInput.current) {
53
- setTimeout(function () {
54
- var _a;
55
- (_a = refs.cellInput.current) === null || _a === void 0 ? void 0 : _a.focus();
56
- });
53
+ if (!isAllowEdit(draftCtx)) {
54
+ setTimeout(function () {
55
+ var _a;
56
+ (_a = refs.workbookContainer.current) === null || _a === void 0 ? void 0 : _a.focus({
57
+ preventScroll: true
58
+ });
59
+ });
60
+ } else {
61
+ setTimeout(function () {
62
+ var _a;
63
+ (_a = refs.cellInput.current) === null || _a === void 0 ? void 0 : _a.focus();
64
+ });
65
+ }
57
66
  }
58
67
  });
59
68
  }
60
- }, [setContext, refs.globalCache, refs.cellInput, refs.cellArea, refs.fxInput, refs.canvas]);
69
+ }, [setContext, refs.globalCache, refs.cellInput, refs.cellArea, refs.fxInput, refs.canvas, refs.workbookContainer]);
61
70
  var cellAreaContextMenu = useCallback(function (e) {
62
71
  var nativeEvent = e.nativeEvent;
63
72
  setContext(function (draftCtx) {
@@ -67,9 +76,19 @@ var SheetOverlay = function SheetOverlay() {
67
76
  var cellAreaDoubleClick = useCallback(function (e) {
68
77
  var nativeEvent = e.nativeEvent;
69
78
  setContext(function (draftCtx) {
79
+ if (!isAllowEdit(draftCtx)) {
80
+ var rc = getCellRowColumn(draftCtx, nativeEvent, containerRef.current, refs.scrollbarX.current, refs.scrollbarY.current);
81
+ if (rc != null) {
82
+ var link = getCellHyperlink(draftCtx, rc.r, rc.c);
83
+ if (link != null) {
84
+ goToLink(draftCtx, rc.r, rc.c, link.linkType, link.linkAddress, refs.scrollbarX.current, refs.scrollbarY.current);
85
+ return;
86
+ }
87
+ }
88
+ }
70
89
  handleCellAreaDoubleClick(draftCtx, refs.globalCache, settings, nativeEvent, refs.cellArea.current);
71
90
  });
72
- }, [refs.cellArea, refs.globalCache, setContext, settings]);
91
+ }, [refs.cellArea, refs.globalCache, refs.scrollbarX, refs.scrollbarY, setContext, settings]);
73
92
  var onLeftTopClick = useCallback(function () {
74
93
  setContext(function (draftCtx) {
75
94
  selectAll(draftCtx);
@@ -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]);
@@ -720,7 +726,8 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
720
726
  }, /*#__PURE__*/React.createElement(ModalProvider, null, /*#__PURE__*/React.createElement("div", {
721
727
  className: "fortune-container",
722
728
  ref: workbookContainer,
723
- onKeyDown: onKeyDown
729
+ onKeyDown: onKeyDown,
730
+ tabIndex: -1
724
731
  }, /*#__PURE__*/React.createElement(SVGDefines, {
725
732
  currency: mergedSettings.currency
726
733
  }), /*#__PURE__*/React.createElement("div", {
@@ -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 () {
@@ -59,14 +59,23 @@ var SheetOverlay = function SheetOverlay() {
59
59
  var _a;
60
60
  (0, _fortuneCore.handleCellAreaMouseDown)(draftCtx, refs.globalCache, nativeEvent, refs.cellInput.current, refs.cellArea.current, refs.fxInput.current, refs.canvas.current.getContext("2d"));
61
61
  if (!_lodash.default.isEmpty((_a = draftCtx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) && refs.cellInput.current) {
62
- setTimeout(function () {
63
- var _a;
64
- (_a = refs.cellInput.current) === null || _a === void 0 ? void 0 : _a.focus();
65
- });
62
+ if (!(0, _fortuneCore.isAllowEdit)(draftCtx)) {
63
+ setTimeout(function () {
64
+ var _a;
65
+ (_a = refs.workbookContainer.current) === null || _a === void 0 ? void 0 : _a.focus({
66
+ preventScroll: true
67
+ });
68
+ });
69
+ } else {
70
+ setTimeout(function () {
71
+ var _a;
72
+ (_a = refs.cellInput.current) === null || _a === void 0 ? void 0 : _a.focus();
73
+ });
74
+ }
66
75
  }
67
76
  });
68
77
  }
69
- }, [setContext, refs.globalCache, refs.cellInput, refs.cellArea, refs.fxInput, refs.canvas]);
78
+ }, [setContext, refs.globalCache, refs.cellInput, refs.cellArea, refs.fxInput, refs.canvas, refs.workbookContainer]);
70
79
  var cellAreaContextMenu = (0, _react.useCallback)(function (e) {
71
80
  var nativeEvent = e.nativeEvent;
72
81
  setContext(function (draftCtx) {
@@ -76,9 +85,19 @@ var SheetOverlay = function SheetOverlay() {
76
85
  var cellAreaDoubleClick = (0, _react.useCallback)(function (e) {
77
86
  var nativeEvent = e.nativeEvent;
78
87
  setContext(function (draftCtx) {
88
+ if (!(0, _fortuneCore.isAllowEdit)(draftCtx)) {
89
+ var rc = (0, _fortuneCore.getCellRowColumn)(draftCtx, nativeEvent, containerRef.current, refs.scrollbarX.current, refs.scrollbarY.current);
90
+ if (rc != null) {
91
+ var link = (0, _fortuneCore.getCellHyperlink)(draftCtx, rc.r, rc.c);
92
+ if (link != null) {
93
+ (0, _fortuneCore.goToLink)(draftCtx, rc.r, rc.c, link.linkType, link.linkAddress, refs.scrollbarX.current, refs.scrollbarY.current);
94
+ return;
95
+ }
96
+ }
97
+ }
79
98
  (0, _fortuneCore.handleCellAreaDoubleClick)(draftCtx, refs.globalCache, settings, nativeEvent, refs.cellArea.current);
80
99
  });
81
- }, [refs.cellArea, refs.globalCache, setContext, settings]);
100
+ }, [refs.cellArea, refs.globalCache, refs.scrollbarX, refs.scrollbarY, setContext, settings]);
82
101
  var onLeftTopClick = (0, _react.useCallback)(function () {
83
102
  setContext(function (draftCtx) {
84
103
  (0, _fortuneCore.selectAll)(draftCtx);
@@ -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]);
@@ -729,7 +735,8 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
729
735
  }, /*#__PURE__*/_react.default.createElement(_modal.ModalProvider, null, /*#__PURE__*/_react.default.createElement("div", {
730
736
  className: "fortune-container",
731
737
  ref: workbookContainer,
732
- onKeyDown: onKeyDown
738
+ onKeyDown: onKeyDown,
739
+ tabIndex: -1
733
740
  }, /*#__PURE__*/_react.default.createElement(_SVGDefines.default, {
734
741
  currency: mergedSettings.currency
735
742
  }), /*#__PURE__*/_react.default.createElement("div", {
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.4-viewMode-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.3",
19
+ "@fileverse-dev/fortune-core": "1.3.4-viewMode-1",
20
20
  "@fileverse/ui": "5.0.0",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",