@fileverse-dev/fortune-react 1.2.90-ydoc-14 → 1.2.91

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.
@@ -280,7 +280,7 @@ export var LinkEditCard = function LinkEditCard(_a) {
280
280
  if (isButtonDisabled) return;
281
281
  _.set(refs.globalCache, "linkCard.mouseEnter", false);
282
282
  setContext(function (draftCtx) {
283
- saveHyperlink(draftCtx, r, c, linkText, linkType, linkAddress);
283
+ return saveHyperlink(draftCtx, r, c, linkText, linkType, linkAddress);
284
284
  });
285
285
  }
286
286
  }, "Insert link"));
@@ -268,13 +268,9 @@ var InputBox = function InputBox() {
268
268
  };
269
269
  var onKeyDown = useCallback(function (e) {
270
270
  var _a, _b;
271
- if (isComposingRef.current || !inputRef.current) {
272
- ensureNotEmpty();
273
- return;
274
- }
275
271
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
276
272
  preText.current = inputRef.current.innerText;
277
- if (e.metaKey) {
273
+ if (e.metaKey && context.luckysheetCellUpdate.length > 0) {
278
274
  if (e.code === "KeyB") {
279
275
  handleBold(context, inputRef.current);
280
276
  stopPropagation(e);
@@ -295,7 +291,7 @@ var InputBox = function InputBox() {
295
291
  }
296
292
  var allowListNavigation = true;
297
293
  if (e.key === "Delete" || e.key === "Backspace") {
298
- requestAnimationFrame(ensureNotEmpty);
294
+ if (isComposingRef.current) requestAnimationFrame(ensureNotEmpty);
299
295
  if (getCursorPosition(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length)) {
300
296
  setTimeout(function () {
301
297
  moveCursorToEnd(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
@@ -589,7 +585,11 @@ var InputBox = function InputBox() {
589
585
  onCompositionUpdate: function onCompositionUpdate() {
590
586
  isComposingRef.current = true;
591
587
  },
592
- onCompositionEnd: function onCompositionEnd() {
588
+ onCompositionEnd: function onCompositionEnd(e) {
589
+ if (e.data === "" && e.currentTarget.value === "") {
590
+ isComposingRef.current = true;
591
+ return;
592
+ }
593
593
  ensureNotEmpty();
594
594
  isComposingRef.current = false;
595
595
  },
@@ -51,7 +51,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
51
51
  getCellsByRange: (range: Selection, options?: api.CommonOptions) => (Cell | null)[][];
52
52
  getHtmlByRange: (range: Range, options?: api.CommonOptions) => string | null;
53
53
  setSelection: (range: Range, options?: api.CommonOptions) => void;
54
- setCellValuesByRange: (data: any[][], range: SingleRange, options?: api.CommonOptions, cellAfter?: boolean) => void;
54
+ setCellValuesByRange: (data: any[][], range: SingleRange, options?: api.CommonOptions) => void;
55
55
  setCellFormatByRange: (attr: keyof Cell, value: any, range: Range | SingleRange, options?: api.CommonOptions) => void;
56
56
  mergeCells: (ranges: Range, type: string, options?: api.CommonOptions) => void;
57
57
  cancelMerge: (ranges: Range, options?: api.CommonOptions) => void;
@@ -276,12 +276,12 @@ export function generateAPIs(context, setContext, handleUndo, handleRedo, settin
276
276
  return api.setSelection(draftCtx, range, options);
277
277
  });
278
278
  },
279
- setCellValuesByRange: function setCellValuesByRange(data, range, options, cellAfter) {
279
+ setCellValuesByRange: function setCellValuesByRange(data, range, options) {
280
280
  if (options === void 0) {
281
281
  options = {};
282
282
  }
283
283
  return setContext(function (draftCtx) {
284
- return api.setCellValuesByRange(draftCtx, data, range, cellInput, options, cellAfter);
284
+ return api.setCellValuesByRange(draftCtx, data, range, cellInput, options);
285
285
  });
286
286
  },
287
287
  setCellFormatByRange: function setCellFormatByRange(attr, value, range, options) {
@@ -58,7 +58,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
58
58
  getCellsByRange: (range: import("@fileverse-dev/fortune-core").Selection, options?: api.CommonOptions) => (import("@fileverse-dev/fortune-core").Cell | null)[][];
59
59
  getHtmlByRange: (range: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => string | null;
60
60
  setSelection: (range: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
61
- setCellValuesByRange: (data: any[][], range: import("@fileverse-dev/fortune-core").SingleRange, options?: api.CommonOptions, cellAfter?: boolean | undefined) => void;
61
+ setCellValuesByRange: (data: any[][], range: import("@fileverse-dev/fortune-core").SingleRange, options?: api.CommonOptions) => void;
62
62
  setCellFormatByRange: (attr: "error" | "rt" | "f" | "m" | "v" | "mc" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, range: import("@fileverse-dev/fortune-core").Range | import("@fileverse-dev/fortune-core").SingleRange, options?: api.CommonOptions) => void;
63
63
  mergeCells: (ranges: import("@fileverse-dev/fortune-core").Range, type: string, options?: api.CommonOptions) => void;
64
64
  cancelMerge: (ranges: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
@@ -390,66 +390,6 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
390
390
  refs: refs
391
391
  };
392
392
  }, [context, handleRedo, handleUndo, mergedSettings, refs, setContextWithProduce]);
393
- useEffect(function () {
394
- var _a;
395
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.sheetLengthChange) {
396
- context.hooks.sheetLengthChange();
397
- }
398
- }, [context.luckysheetfile.length]);
399
- var currentSheet = useMemo(function () {
400
- var _a;
401
- return (_a = context === null || context === void 0 ? void 0 : context.luckysheetfile) === null || _a === void 0 ? void 0 : _a.find(function (sheet) {
402
- return sheet.id === (context === null || context === void 0 ? void 0 : context.currentSheetId);
403
- });
404
- }, [context === null || context === void 0 ? void 0 : context.luckysheetfile, context === null || context === void 0 ? void 0 : context.currentSheetId]);
405
- useEffect(function () {
406
- var _a;
407
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.calcChainChange) {
408
- context.hooks.calcChainChange();
409
- }
410
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.calcChain]);
411
- useEffect(function () {
412
- var _a;
413
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.dataVerificationChange) {
414
- context.hooks.dataVerificationChange();
415
- }
416
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.dataVerification]);
417
- useEffect(function () {
418
- var _a;
419
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.liveQueryChange) {
420
- context.hooks.liveQueryChange();
421
- }
422
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.liveQueryList]);
423
- useEffect(function () {
424
- var _a;
425
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.imageListChange) {
426
- context.hooks.imageListChange();
427
- }
428
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.images]);
429
- useEffect(function () {
430
- var _a;
431
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.iframeListChange) {
432
- context.hooks.iframeListChange();
433
- }
434
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.iframes]);
435
- useEffect(function () {
436
- var _a;
437
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.conditionRulesChange) {
438
- context.hooks.conditionRulesChange();
439
- }
440
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.conditionRules]);
441
- useEffect(function () {
442
- var _a;
443
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.conditionFormatChange) {
444
- context.hooks.conditionFormatChange();
445
- }
446
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.luckysheet_conditionformat_save]);
447
- useEffect(function () {
448
- var _a;
449
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.hyperlinkChange) {
450
- context.hooks.hyperlinkChange();
451
- }
452
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.hyperlink]);
453
393
  useEffect(function () {
454
394
  if (!_.isEmpty(context.luckysheetfile)) {
455
395
  onChange === null || onChange === void 0 ? void 0 : onChange(context.luckysheetfile);
@@ -289,7 +289,7 @@ var LinkEditCard = exports.LinkEditCard = function LinkEditCard(_a) {
289
289
  if (isButtonDisabled) return;
290
290
  _lodash.default.set(refs.globalCache, "linkCard.mouseEnter", false);
291
291
  setContext(function (draftCtx) {
292
- (0, _fortuneCore.saveHyperlink)(draftCtx, r, c, linkText, linkType, linkAddress);
292
+ return (0, _fortuneCore.saveHyperlink)(draftCtx, r, c, linkText, linkType, linkAddress);
293
293
  });
294
294
  }
295
295
  }, "Insert link"));
@@ -277,13 +277,9 @@ var InputBox = function InputBox() {
277
277
  };
278
278
  var onKeyDown = (0, _react.useCallback)(function (e) {
279
279
  var _a, _b;
280
- if (isComposingRef.current || !inputRef.current) {
281
- ensureNotEmpty();
282
- return;
283
- }
284
280
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
285
281
  preText.current = inputRef.current.innerText;
286
- if (e.metaKey) {
282
+ if (e.metaKey && context.luckysheetCellUpdate.length > 0) {
287
283
  if (e.code === "KeyB") {
288
284
  (0, _fortuneCore.handleBold)(context, inputRef.current);
289
285
  stopPropagation(e);
@@ -304,7 +300,7 @@ var InputBox = function InputBox() {
304
300
  }
305
301
  var allowListNavigation = true;
306
302
  if (e.key === "Delete" || e.key === "Backspace") {
307
- requestAnimationFrame(ensureNotEmpty);
303
+ if (isComposingRef.current) requestAnimationFrame(ensureNotEmpty);
308
304
  if ((0, _helper.getCursorPosition)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length)) {
309
305
  setTimeout(function () {
310
306
  (0, _helper.moveCursorToEnd)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
@@ -598,7 +594,11 @@ var InputBox = function InputBox() {
598
594
  onCompositionUpdate: function onCompositionUpdate() {
599
595
  isComposingRef.current = true;
600
596
  },
601
- onCompositionEnd: function onCompositionEnd() {
597
+ onCompositionEnd: function onCompositionEnd(e) {
598
+ if (e.data === "" && e.currentTarget.value === "") {
599
+ isComposingRef.current = true;
600
+ return;
601
+ }
602
602
  ensureNotEmpty();
603
603
  isComposingRef.current = false;
604
604
  },
@@ -51,7 +51,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
51
51
  getCellsByRange: (range: Selection, options?: api.CommonOptions) => (Cell | null)[][];
52
52
  getHtmlByRange: (range: Range, options?: api.CommonOptions) => string | null;
53
53
  setSelection: (range: Range, options?: api.CommonOptions) => void;
54
- setCellValuesByRange: (data: any[][], range: SingleRange, options?: api.CommonOptions, cellAfter?: boolean) => void;
54
+ setCellValuesByRange: (data: any[][], range: SingleRange, options?: api.CommonOptions) => void;
55
55
  setCellFormatByRange: (attr: keyof Cell, value: any, range: Range | SingleRange, options?: api.CommonOptions) => void;
56
56
  mergeCells: (ranges: Range, type: string, options?: api.CommonOptions) => void;
57
57
  cancelMerge: (ranges: Range, options?: api.CommonOptions) => void;
@@ -283,12 +283,12 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
283
283
  return _fortuneCore.api.setSelection(draftCtx, range, options);
284
284
  });
285
285
  },
286
- setCellValuesByRange: function setCellValuesByRange(data, range, options, cellAfter) {
286
+ setCellValuesByRange: function setCellValuesByRange(data, range, options) {
287
287
  if (options === void 0) {
288
288
  options = {};
289
289
  }
290
290
  return setContext(function (draftCtx) {
291
- return _fortuneCore.api.setCellValuesByRange(draftCtx, data, range, cellInput, options, cellAfter);
291
+ return _fortuneCore.api.setCellValuesByRange(draftCtx, data, range, cellInput, options);
292
292
  });
293
293
  },
294
294
  setCellFormatByRange: function setCellFormatByRange(attr, value, range, options) {
@@ -58,7 +58,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
58
58
  getCellsByRange: (range: import("@fileverse-dev/fortune-core").Selection, options?: api.CommonOptions) => (import("@fileverse-dev/fortune-core").Cell | null)[][];
59
59
  getHtmlByRange: (range: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => string | null;
60
60
  setSelection: (range: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
61
- setCellValuesByRange: (data: any[][], range: import("@fileverse-dev/fortune-core").SingleRange, options?: api.CommonOptions, cellAfter?: boolean | undefined) => void;
61
+ setCellValuesByRange: (data: any[][], range: import("@fileverse-dev/fortune-core").SingleRange, options?: api.CommonOptions) => void;
62
62
  setCellFormatByRange: (attr: "error" | "rt" | "f" | "m" | "v" | "mc" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle, value: any, range: import("@fileverse-dev/fortune-core").Range | import("@fileverse-dev/fortune-core").SingleRange, options?: api.CommonOptions) => void;
63
63
  mergeCells: (ranges: import("@fileverse-dev/fortune-core").Range, type: string, options?: api.CommonOptions) => void;
64
64
  cancelMerge: (ranges: import("@fileverse-dev/fortune-core").Range, options?: api.CommonOptions) => void;
@@ -399,66 +399,6 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
399
399
  refs: refs
400
400
  };
401
401
  }, [context, handleRedo, handleUndo, mergedSettings, refs, setContextWithProduce]);
402
- (0, _react.useEffect)(function () {
403
- var _a;
404
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.sheetLengthChange) {
405
- context.hooks.sheetLengthChange();
406
- }
407
- }, [context.luckysheetfile.length]);
408
- var currentSheet = (0, _react.useMemo)(function () {
409
- var _a;
410
- return (_a = context === null || context === void 0 ? void 0 : context.luckysheetfile) === null || _a === void 0 ? void 0 : _a.find(function (sheet) {
411
- return sheet.id === (context === null || context === void 0 ? void 0 : context.currentSheetId);
412
- });
413
- }, [context === null || context === void 0 ? void 0 : context.luckysheetfile, context === null || context === void 0 ? void 0 : context.currentSheetId]);
414
- (0, _react.useEffect)(function () {
415
- var _a;
416
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.calcChainChange) {
417
- context.hooks.calcChainChange();
418
- }
419
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.calcChain]);
420
- (0, _react.useEffect)(function () {
421
- var _a;
422
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.dataVerificationChange) {
423
- context.hooks.dataVerificationChange();
424
- }
425
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.dataVerification]);
426
- (0, _react.useEffect)(function () {
427
- var _a;
428
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.liveQueryChange) {
429
- context.hooks.liveQueryChange();
430
- }
431
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.liveQueryList]);
432
- (0, _react.useEffect)(function () {
433
- var _a;
434
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.imageListChange) {
435
- context.hooks.imageListChange();
436
- }
437
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.images]);
438
- (0, _react.useEffect)(function () {
439
- var _a;
440
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.iframeListChange) {
441
- context.hooks.iframeListChange();
442
- }
443
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.iframes]);
444
- (0, _react.useEffect)(function () {
445
- var _a;
446
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.conditionRulesChange) {
447
- context.hooks.conditionRulesChange();
448
- }
449
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.conditionRules]);
450
- (0, _react.useEffect)(function () {
451
- var _a;
452
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.conditionFormatChange) {
453
- context.hooks.conditionFormatChange();
454
- }
455
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.luckysheet_conditionformat_save]);
456
- (0, _react.useEffect)(function () {
457
- var _a;
458
- if ((_a = context === null || context === void 0 ? void 0 : context.hooks) === null || _a === void 0 ? void 0 : _a.hyperlinkChange) {
459
- context.hooks.hyperlinkChange();
460
- }
461
- }, [currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.hyperlink]);
462
402
  (0, _react.useEffect)(function () {
463
403
  if (!_lodash.default.isEmpty(context.luckysheetfile)) {
464
404
  onChange === null || onChange === void 0 ? void 0 : onChange(context.luckysheetfile);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.2.90-ydoc-14",
3
+ "version": "1.2.91",
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.2.90-ydoc-14",
19
+ "@fileverse-dev/fortune-core": "1.2.91",
20
20
  "@fileverse/ui": "^4.1.7-patch-40",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",