@fileverse-dev/fortune-react 1.2.90-bold → 1.2.90-bold-2

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.
@@ -71,6 +71,7 @@ var InputBox = function InputBox() {
71
71
  var el = inputRef.current;
72
72
  if (!el) return;
73
73
  var text = el.textContent;
74
+ console.log(text, "yoooo");
74
75
  if (!text || text === ZWSP) {
75
76
  el.innerHTML = ZWSP;
76
77
  moveCursorToEnd(el);
@@ -268,13 +269,11 @@ var InputBox = function InputBox() {
268
269
  };
269
270
  var onKeyDown = useCallback(function (e) {
270
271
  var _a, _b;
271
- if (isComposingRef.current || !inputRef.current) {
272
- ensureNotEmpty();
273
- return;
274
- }
272
+ console.log(e.code, "onKeyDown in InputBox");
275
273
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
276
274
  preText.current = inputRef.current.innerText;
277
- if (e.metaKey) {
275
+ if (e.metaKey && context.luckysheetCellUpdate.length > 0) {
276
+ console.log(e.code, "e.code");
278
277
  if (e.code === "KeyB") {
279
278
  handleBold(context, inputRef.current);
280
279
  stopPropagation(e);
@@ -282,9 +281,11 @@ var InputBox = function InputBox() {
282
281
  handleItalic(context, inputRef.current);
283
282
  stopPropagation(e);
284
283
  } else if (e.code === "KeyU") {
284
+ console.log("underline");
285
285
  handleUnderline(context, inputRef.current);
286
286
  stopPropagation(e);
287
287
  } else if (e.code === "KeyS") {
288
+ console.log("strikethrough");
288
289
  handleStrikeThrough(context, inputRef.current);
289
290
  stopPropagation(e);
290
291
  }
@@ -295,7 +296,7 @@ var InputBox = function InputBox() {
295
296
  }
296
297
  var allowListNavigation = true;
297
298
  if (e.key === "Delete" || e.key === "Backspace") {
298
- requestAnimationFrame(ensureNotEmpty);
299
+ if (isComposingRef.current) requestAnimationFrame(ensureNotEmpty);
299
300
  if (getCursorPosition(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length)) {
300
301
  setTimeout(function () {
301
302
  moveCursorToEnd(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
@@ -589,7 +590,11 @@ var InputBox = function InputBox() {
589
590
  onCompositionUpdate: function onCompositionUpdate() {
590
591
  isComposingRef.current = true;
591
592
  },
592
- onCompositionEnd: function onCompositionEnd() {
593
+ onCompositionEnd: function onCompositionEnd(e) {
594
+ if (e.data === "" && e.currentTarget.value === "") {
595
+ isComposingRef.current = true;
596
+ return;
597
+ }
593
598
  ensureNotEmpty();
594
599
  isComposingRef.current = false;
595
600
  },
@@ -503,7 +503,6 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
503
503
  var resetDeleteRowTimer;
504
504
  var onKeyDown = useCallback(function (e) {
505
505
  var _a, _b;
506
- console.log("onKeyDown", e);
507
506
  var _c = ref.current,
508
507
  getSelection = _c.getSelection,
509
508
  getSheet = _c.getSheet,
@@ -645,7 +644,6 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
645
644
  return;
646
645
  }
647
646
  setContextWithProduce(function (draftCtx) {
648
- console.log("handleGlobalKeyDown");
649
647
  handleGlobalKeyDown(draftCtx, cellInput.current, fxInput.current, nativeEvent, globalCache.current, handleUndo, handleRedo, canvas.current.getContext("2d"));
650
648
  });
651
649
  }, [handleRedo, handleUndo, setContextWithProduce]);
@@ -80,6 +80,7 @@ var InputBox = function InputBox() {
80
80
  var el = inputRef.current;
81
81
  if (!el) return;
82
82
  var text = el.textContent;
83
+ console.log(text, "yoooo");
83
84
  if (!text || text === ZWSP) {
84
85
  el.innerHTML = ZWSP;
85
86
  (0, _helper.moveCursorToEnd)(el);
@@ -277,13 +278,11 @@ var InputBox = function InputBox() {
277
278
  };
278
279
  var onKeyDown = (0, _react.useCallback)(function (e) {
279
280
  var _a, _b;
280
- if (isComposingRef.current || !inputRef.current) {
281
- ensureNotEmpty();
282
- return;
283
- }
281
+ console.log(e.code, "onKeyDown in InputBox");
284
282
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
285
283
  preText.current = inputRef.current.innerText;
286
- if (e.metaKey) {
284
+ if (e.metaKey && context.luckysheetCellUpdate.length > 0) {
285
+ console.log(e.code, "e.code");
287
286
  if (e.code === "KeyB") {
288
287
  (0, _fortuneCore.handleBold)(context, inputRef.current);
289
288
  stopPropagation(e);
@@ -291,9 +290,11 @@ var InputBox = function InputBox() {
291
290
  (0, _fortuneCore.handleItalic)(context, inputRef.current);
292
291
  stopPropagation(e);
293
292
  } else if (e.code === "KeyU") {
293
+ console.log("underline");
294
294
  (0, _fortuneCore.handleUnderline)(context, inputRef.current);
295
295
  stopPropagation(e);
296
296
  } else if (e.code === "KeyS") {
297
+ console.log("strikethrough");
297
298
  (0, _fortuneCore.handleStrikeThrough)(context, inputRef.current);
298
299
  stopPropagation(e);
299
300
  }
@@ -304,7 +305,7 @@ var InputBox = function InputBox() {
304
305
  }
305
306
  var allowListNavigation = true;
306
307
  if (e.key === "Delete" || e.key === "Backspace") {
307
- requestAnimationFrame(ensureNotEmpty);
308
+ if (isComposingRef.current) requestAnimationFrame(ensureNotEmpty);
308
309
  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
310
  setTimeout(function () {
310
311
  (0, _helper.moveCursorToEnd)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
@@ -598,7 +599,11 @@ var InputBox = function InputBox() {
598
599
  onCompositionUpdate: function onCompositionUpdate() {
599
600
  isComposingRef.current = true;
600
601
  },
601
- onCompositionEnd: function onCompositionEnd() {
602
+ onCompositionEnd: function onCompositionEnd(e) {
603
+ if (e.data === "" && e.currentTarget.value === "") {
604
+ isComposingRef.current = true;
605
+ return;
606
+ }
602
607
  ensureNotEmpty();
603
608
  isComposingRef.current = false;
604
609
  },
@@ -512,7 +512,6 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
512
512
  var resetDeleteRowTimer;
513
513
  var onKeyDown = (0, _react.useCallback)(function (e) {
514
514
  var _a, _b;
515
- console.log("onKeyDown", e);
516
515
  var _c = ref.current,
517
516
  getSelection = _c.getSelection,
518
517
  getSheet = _c.getSheet,
@@ -654,7 +653,6 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
654
653
  return;
655
654
  }
656
655
  setContextWithProduce(function (draftCtx) {
657
- console.log("handleGlobalKeyDown");
658
656
  (0, _fortuneCore.handleGlobalKeyDown)(draftCtx, cellInput.current, fxInput.current, nativeEvent, globalCache.current, handleUndo, handleRedo, canvas.current.getContext("2d"));
659
657
  });
660
658
  }, [handleRedo, handleUndo, setContextWithProduce]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.2.90-bold",
3
+ "version": "1.2.90-bold-2",
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-bold",
19
+ "@fileverse-dev/fortune-core": "1.2.90-bold-2",
20
20
  "@fileverse/ui": "^4.1.7-patch-40",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",