@fileverse-dev/fortune-react 1.2.59 → 1.2.62-patch-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.
@@ -8,7 +8,7 @@ var __assign = this && this.__assign || function () {
8
8
  };
9
9
  return __assign.apply(this, arguments);
10
10
  };
11
- import { cancelNormalSelected, getCellValue, getInlineStringHTML, getStyleByCell, isInlineStringCell, moveToEnd, getFlowdata, handleFormulaInput, moveHighlightCell, escapeScriptTag, valueShowEs, createRangeHightlight, isShowHidenCR, israngeseleciton, escapeHTMLTag, isAllowEdit, getrangeseleciton, indexToColumnChar } from "@fileverse-dev/fortune-core";
11
+ import { cancelNormalSelected, getCellValue, getInlineStringHTML, getStyleByCell, isInlineStringCell, moveToEnd, getFlowdata, handleFormulaInput, moveHighlightCell, escapeScriptTag, valueShowEs, createRangeHightlight, isShowHidenCR, israngeseleciton, escapeHTMLTag, isAllowEdit, getrangeseleciton, indexToColumnChar, handleBold, handleItalic, handleUnderline, handleStrikeThrough } from "@fileverse-dev/fortune-core";
12
12
  import React, { useContext, useEffect, useMemo, useRef, useCallback, useLayoutEffect, useState } from "react";
13
13
  import _ from "lodash";
14
14
  import { Tooltip } from "@fileverse/ui";
@@ -249,6 +249,19 @@ var InputBox = function InputBox() {
249
249
  var _a, _b;
250
250
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
251
251
  preText.current = inputRef.current.innerText;
252
+ if (e.metaKey) {
253
+ e.preventDefault();
254
+ e.stopPropagation();
255
+ if (e.code === "KeyB") {
256
+ handleBold(context, inputRef.current);
257
+ } else if (e.code === "KeyI") {
258
+ handleItalic(context, inputRef.current);
259
+ } else if (e.code === "KeyU") {
260
+ handleUnderline(context, inputRef.current);
261
+ } else if (e.code === "KeyS") {
262
+ handleStrikeThrough(context, inputRef.current);
263
+ }
264
+ }
252
265
  var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
253
266
  setCommaCount(currentCommaCount);
254
267
  var allowListNavigation = true;
@@ -612,7 +612,9 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
612
612
  }, [handleRedo, handleUndo, setContextWithProduce]);
613
613
  var onPaste = useCallback(function (e) {
614
614
  var _a;
615
+ var startPaste = true;
615
616
  if (cellInput.current === document.activeElement || ((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.className) === "fortune-sheet-overlay") {
617
+ if (!startPaste) return;
616
618
  var clipboardData = e.clipboardData;
617
619
  if (!clipboardData) {
618
620
  clipboardData = window.clipboardData;
@@ -641,7 +643,10 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
641
643
  }
642
644
  setContextWithProduce(function (draftCtx) {
643
645
  try {
644
- handlePaste(draftCtx, e);
646
+ if (startPaste) {
647
+ startPaste = false;
648
+ handlePaste(draftCtx, e);
649
+ }
645
650
  } catch (err) {
646
651
  console.error(err);
647
652
  }
@@ -258,6 +258,19 @@ var InputBox = function InputBox() {
258
258
  var _a, _b;
259
259
  lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
260
260
  preText.current = inputRef.current.innerText;
261
+ if (e.metaKey) {
262
+ e.preventDefault();
263
+ e.stopPropagation();
264
+ if (e.code === "KeyB") {
265
+ (0, _fortuneCore.handleBold)(context, inputRef.current);
266
+ } else if (e.code === "KeyI") {
267
+ (0, _fortuneCore.handleItalic)(context, inputRef.current);
268
+ } else if (e.code === "KeyU") {
269
+ (0, _fortuneCore.handleUnderline)(context, inputRef.current);
270
+ } else if (e.code === "KeyS") {
271
+ (0, _fortuneCore.handleStrikeThrough)(context, inputRef.current);
272
+ }
273
+ }
261
274
  var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
262
275
  setCommaCount(currentCommaCount);
263
276
  var allowListNavigation = true;
@@ -621,7 +621,9 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
621
621
  }, [handleRedo, handleUndo, setContextWithProduce]);
622
622
  var onPaste = (0, _react.useCallback)(function (e) {
623
623
  var _a;
624
+ var startPaste = true;
624
625
  if (cellInput.current === document.activeElement || ((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.className) === "fortune-sheet-overlay") {
626
+ if (!startPaste) return;
625
627
  var clipboardData = e.clipboardData;
626
628
  if (!clipboardData) {
627
629
  clipboardData = window.clipboardData;
@@ -650,7 +652,10 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
650
652
  }
651
653
  setContextWithProduce(function (draftCtx) {
652
654
  try {
653
- (0, _fortuneCore.handlePaste)(draftCtx, e);
655
+ if (startPaste) {
656
+ startPaste = false;
657
+ (0, _fortuneCore.handlePaste)(draftCtx, e);
658
+ }
654
659
  } catch (err) {
655
660
  console.error(err);
656
661
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.2.59",
3
+ "version": "1.2.62-patch-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.2.59",
19
+ "@fileverse-dev/fortune-core": "1.2.62-patch-1",
20
20
  "@fileverse/ui": "^4.1.7-patch-40",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",