@leankylin-sheet/react 1.2.14 → 1.2.15

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.
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defaultContext, defaultSettings, getSheetIndex, colLocationByIndex, fixPositionOnFrozenCells, colLocation, getFlowdata, isAllowEdit, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleContextMenu, selectTitlesMap, selectTitlesRange, fixColumnStyleOverflowInFreeze, rowLocationByIndex, rowLocation, handleRowHeaderMouseDown, handleRowSizeHandleMouseDown, handleRowFreezeHandleMouseDown, fixRowStyleOverflowInFreeze, locale, getStyleByCell, getCellValue, createRangeHightlight, isInlineStringCell, getInlineStringHTML, valueShowEs, escapeHTMLTag, escapeScriptTag, moveToEnd, isShowHidenCR, cancelNormalSelected, moveHighlightCell, updateCell, israngeseleciton, handleFormulaInput, onSearchDialogMoveStart, replaceAll, replace, searchAll, searchNext, normalizeSelection, scrollToHighlightCell, isLinkValid, getRangetxt, goToLink, replaceHtml, removeHyperlink, onRangeSelectionModalMoveStart, saveHyperlink, createFilterOptions, onImageMoveStart, onImageResizeStart, showComments, setEditingComment, onCommentBoxMoveStart, onCommentBoxResizeStart, confirmMessage, getRangeByTxt, getDropdownList, setCellValue, setConditionRules, mergeBorder, setDropcownValue, handleCellAreaMouseDown, handleCellAreaDoubleClick, selectAll, showLinkCard, getCellRowColumn, getCellHyperlink, handleOverlayMouseMove, handleOverlayMouseUp, handleKeydownForZoom, handleOverlayTouchStart, handleOverlayTouchMove, handleOverlayTouchEnd, drawArrow, onCellsMoveStart, createDropCellRange, updateContextWithSheetData, updateContextWithCanvas, initFreeze, Canvas, handleGlobalWheel, setCaretPosition, getDataArr, updateMoreCell, getRegStr, getOptionValue, getSelectRange, applyLocation, updateItem, update, normalizedCellAttr, updateFormat, handleTextSize, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, showImgChooser, insertImage, editComment, deleteComment, showHideComment, showHideAllComments, newComment, handleSum, autoSelectionFormula, handleMerge, handleBorder, handleFreeze, handleSort, createFilter, clearFilter, toolbarItemSelectedFunc, toolbarItemClickHandler, handleTextColor, handleTextBackground, getInlineStringNoStyle, rangeHightlightselected, editSheetName, cancelActiveImgItem, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, addSheet, indexToColumnChar, sortSelection, handleCopy, getClipboardContent, handlePasteByLeanklin, insertRowCol, deleteRowCol, hideSelected, showSelected, api, removeActiveImage, deleteSelectedCellText, jfrefreshgrid, handleLink, deleteSheet, opToPatch, orderbydatafiler, getFilterColumnValues, getFilterColumnColors, saveFilter, calcSelectionInfo, patchToOp, filterPatch, inverseRowColOptions, ensureSheetIndex, initSheetIndex, handleGlobalKeyDown, groupValuesRefresh } from '@leankylin-sheet/core';
1
+ import { defaultContext, defaultSettings, getSheetIndex, colLocationByIndex, fixPositionOnFrozenCells, colLocation, getFlowdata, isAllowEdit, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleContextMenu, selectTitlesMap, selectTitlesRange, fixColumnStyleOverflowInFreeze, rowLocationByIndex, rowLocation, handleRowHeaderMouseDown, handleRowSizeHandleMouseDown, handleRowFreezeHandleMouseDown, fixRowStyleOverflowInFreeze, locale, getStyleByCell, getCellValue, createRangeHightlight, isInlineStringCell, getInlineStringHTML, valueShowEs, escapeHTMLTag, escapeScriptTag, moveToEnd, isShowHidenCR, cancelNormalSelected, moveHighlightCell, updateCell, israngeseleciton, handleFormulaInput, onSearchDialogMoveStart, replaceAll, replace, searchAll, searchNext, normalizeSelection, scrollToHighlightCell, isLinkValid, getRangetxt, goToLink, replaceHtml, removeHyperlink, onRangeSelectionModalMoveStart, saveHyperlink, createFilterOptions, onImageMoveStart, onImageResizeStart, showComments, setEditingComment, onCommentBoxMoveStart, onCommentBoxResizeStart, confirmMessage, getRangeByTxt, getDropdownList, setCellValue, setConditionRules, mergeBorder, setDropcownValue, handleCellAreaMouseDown, handleCellAreaDoubleClick, selectAll, showLinkCard, getCellRowColumn, getCellHyperlink, handleOverlayMouseMove, handleOverlayMouseUp, handleKeydownForZoom, handleOverlayTouchStart, handleOverlayTouchMove, handleOverlayTouchEnd, drawArrow, onCellsMoveStart, createDropCellRange, updateContextWithSheetData, updateContextWithCanvas, initFreeze, Canvas, handleGlobalWheel, setCaretPosition, getDataArr, updateMoreCell, getRegStr, getOptionValue, getSelectRange, applyLocation, updateItem, update, normalizedCellAttr, updateFormat, handleTextSize, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, showImgChooser, insertImage, editComment, deleteComment, showHideComment, showHideAllComments, newComment, handleSum, autoSelectionFormula, handleMerge, handleBorder, handleFreeze, handleSort, createFilter, clearFilter, toolbarItemSelectedFunc, toolbarItemClickHandler, handleTextColor, handleTextBackground, getInlineStringNoStyle, rangeHightlightselected, editSheetName, cancelActiveImgItem, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, addSheet, indexToColumnChar, sortSelection, handleCopy, insertRowCol, deleteRowCol, hideSelected, showSelected, api, removeActiveImage, deleteSelectedCellText, jfrefreshgrid, handleLink, deleteSheet, opToPatch, orderbydatafiler, getFilterColumnValues, getFilterColumnColors, saveFilter, calcSelectionInfo, patchToOp, filterPatch, inverseRowColOptions, ensureSheetIndex, initSheetIndex, handleGlobalKeyDown, handlePasteByLeanklin, groupValuesRefresh } from '@leankylin-sheet/core';
2
2
  import React, { useContext, useRef, useState, useMemo, useCallback, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
3
3
  import produce, { applyPatches, enablePatches, produceWithPatches } from 'immer';
4
4
  import _ from 'lodash';
@@ -6958,6 +6958,10 @@ var Menu = function Menu(_ref) {
6958
6958
  onClick: function onClick(e) {
6959
6959
  return _onClick === null || _onClick === void 0 ? void 0 : _onClick(e, containerRef.current);
6960
6960
  },
6961
+ onMouseDown: function onMouseDown(e) {
6962
+ e.stopPropagation();
6963
+ e.preventDefault();
6964
+ },
6961
6965
  onMouseLeave: function onMouseLeave(e) {
6962
6966
  return _onMouseLeave === null || _onMouseLeave === void 0 ? void 0 : _onMouseLeave(e, containerRef.current);
6963
6967
  },
@@ -7127,13 +7131,14 @@ var ContextMenu = function ContextMenu() {
7127
7131
  if (name === "paste") {
7128
7132
  return /*#__PURE__*/React.createElement(Menu, {
7129
7133
  key: name,
7130
- onClick: function onClick() {
7131
- getClipboardContent().then(function (clipboard) {
7132
- setContext(function (draftCtx) {
7133
- handlePasteByLeanklin(draftCtx, clipboard);
7134
- draftCtx.contextMenu = {};
7135
- });
7134
+ onClick: function onClick(e) {
7135
+ e.stopPropagation();
7136
+ e.preventDefault();
7137
+ var pasteEvent = new Event('paste', {
7138
+ bubbles: true,
7139
+ cancelable: true
7136
7140
  });
7141
+ document.dispatchEvent(pasteEvent);
7137
7142
  }
7138
7143
  }, rightclick.paste);
7139
7144
  }
@@ -10309,6 +10314,7 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
10309
10314
  var scrollbarY = useRef(null);
10310
10315
  var cellArea = useRef(null);
10311
10316
  var workbookContainer = useRef(null);
10317
+ var isFocusRef = useRef(false);
10312
10318
  var refs = useMemo(function () {
10313
10319
  return {
10314
10320
  globalCache: globalCache.current,
@@ -10708,23 +10714,13 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
10708
10714
  });
10709
10715
  }, [handleRedo, handleUndo, setContextWithProduce, mergedSettings.disabledKeyboardCodes]);
10710
10716
  var onPaste = useCallback(function (e) {
10711
- var _document$activeEleme;
10712
- if (cellInput.current === document.activeElement || ((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.className) === "leankylin-sheet-overlay") {
10713
- var clipboardData = e.clipboardData;
10714
- if (!clipboardData) {
10715
- clipboardData = window.clipboardData;
10716
- }
10717
- var txtdata = clipboardData.getData("text/html") || clipboardData.getData("text/plain");
10718
- var ele = document.createElement("div");
10719
- ele.innerHTML = txtdata;
10720
- getClipboardContent().then(function (clipboard) {
10721
- setContextWithProduce(function (draftCtx) {
10722
- try {
10723
- handlePasteByLeanklin(draftCtx, clipboard);
10724
- } catch (err) {
10725
- console.error(err);
10726
- }
10727
- });
10717
+ if (isFocusRef.current) {
10718
+ setContextWithProduce(function (draftCtx) {
10719
+ try {
10720
+ handlePasteByLeanklin(draftCtx, e);
10721
+ } catch (err) {
10722
+ console.error(err);
10723
+ }
10728
10724
  });
10729
10725
  }
10730
10726
  }, [context, setContextWithProduce]);
@@ -10753,6 +10749,12 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
10753
10749
  }, /*#__PURE__*/React.createElement(ModalProvider, null, /*#__PURE__*/React.createElement("div", {
10754
10750
  className: "leankylin-container",
10755
10751
  ref: workbookContainer,
10752
+ onFocus: function onFocus() {
10753
+ isFocusRef.current = true;
10754
+ },
10755
+ onBlur: function onBlur() {
10756
+ isFocusRef.current = false;
10757
+ },
10756
10758
  onKeyDown: onKeyDown
10757
10759
  }, /*#__PURE__*/React.createElement(SVGDefines, null), /*#__PURE__*/React.createElement("div", {
10758
10760
  className: "leankylin-workarea"
package/dist/index.js CHANGED
@@ -6968,6 +6968,10 @@ var Menu = function Menu(_ref) {
6968
6968
  onClick: function onClick(e) {
6969
6969
  return _onClick === null || _onClick === void 0 ? void 0 : _onClick(e, containerRef.current);
6970
6970
  },
6971
+ onMouseDown: function onMouseDown(e) {
6972
+ e.stopPropagation();
6973
+ e.preventDefault();
6974
+ },
6971
6975
  onMouseLeave: function onMouseLeave(e) {
6972
6976
  return _onMouseLeave === null || _onMouseLeave === void 0 ? void 0 : _onMouseLeave(e, containerRef.current);
6973
6977
  },
@@ -7137,13 +7141,14 @@ var ContextMenu = function ContextMenu() {
7137
7141
  if (name === "paste") {
7138
7142
  return /*#__PURE__*/React__default['default'].createElement(Menu, {
7139
7143
  key: name,
7140
- onClick: function onClick() {
7141
- core.getClipboardContent().then(function (clipboard) {
7142
- setContext(function (draftCtx) {
7143
- core.handlePasteByLeanklin(draftCtx, clipboard);
7144
- draftCtx.contextMenu = {};
7145
- });
7144
+ onClick: function onClick(e) {
7145
+ e.stopPropagation();
7146
+ e.preventDefault();
7147
+ var pasteEvent = new Event('paste', {
7148
+ bubbles: true,
7149
+ cancelable: true
7146
7150
  });
7151
+ document.dispatchEvent(pasteEvent);
7147
7152
  }
7148
7153
  }, rightclick.paste);
7149
7154
  }
@@ -10319,6 +10324,7 @@ var Workbook = /*#__PURE__*/React__default['default'].forwardRef(function (_ref,
10319
10324
  var scrollbarY = React.useRef(null);
10320
10325
  var cellArea = React.useRef(null);
10321
10326
  var workbookContainer = React.useRef(null);
10327
+ var isFocusRef = React.useRef(false);
10322
10328
  var refs = React.useMemo(function () {
10323
10329
  return {
10324
10330
  globalCache: globalCache.current,
@@ -10718,23 +10724,13 @@ var Workbook = /*#__PURE__*/React__default['default'].forwardRef(function (_ref,
10718
10724
  });
10719
10725
  }, [handleRedo, handleUndo, setContextWithProduce, mergedSettings.disabledKeyboardCodes]);
10720
10726
  var onPaste = React.useCallback(function (e) {
10721
- var _document$activeEleme;
10722
- if (cellInput.current === document.activeElement || ((_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.className) === "leankylin-sheet-overlay") {
10723
- var clipboardData = e.clipboardData;
10724
- if (!clipboardData) {
10725
- clipboardData = window.clipboardData;
10726
- }
10727
- var txtdata = clipboardData.getData("text/html") || clipboardData.getData("text/plain");
10728
- var ele = document.createElement("div");
10729
- ele.innerHTML = txtdata;
10730
- core.getClipboardContent().then(function (clipboard) {
10731
- setContextWithProduce(function (draftCtx) {
10732
- try {
10733
- core.handlePasteByLeanklin(draftCtx, clipboard);
10734
- } catch (err) {
10735
- console.error(err);
10736
- }
10737
- });
10727
+ if (isFocusRef.current) {
10728
+ setContextWithProduce(function (draftCtx) {
10729
+ try {
10730
+ core.handlePasteByLeanklin(draftCtx, e);
10731
+ } catch (err) {
10732
+ console.error(err);
10733
+ }
10738
10734
  });
10739
10735
  }
10740
10736
  }, [context, setContextWithProduce]);
@@ -10763,6 +10759,12 @@ var Workbook = /*#__PURE__*/React__default['default'].forwardRef(function (_ref,
10763
10759
  }, /*#__PURE__*/React__default['default'].createElement(ModalProvider, null, /*#__PURE__*/React__default['default'].createElement("div", {
10764
10760
  className: "leankylin-container",
10765
10761
  ref: workbookContainer,
10762
+ onFocus: function onFocus() {
10763
+ isFocusRef.current = true;
10764
+ },
10765
+ onBlur: function onBlur() {
10766
+ isFocusRef.current = false;
10767
+ },
10766
10768
  onKeyDown: onKeyDown
10767
10769
  }, /*#__PURE__*/React__default['default'].createElement(SVGDefines, null), /*#__PURE__*/React__default['default'].createElement("div", {
10768
10770
  className: "leankylin-workarea"