sheet-happens 0.0.35 → 0.0.36

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.
@@ -1419,7 +1419,7 @@ var useClipboardCopy = function useClipboardCopy(textAreaRef, selection, editMod
1419
1419
  }
1420
1420
  });
1421
1421
  };
1422
- var useClipboardPaste = function useClipboardPaste(textAreaRef, selection, onSelectionChange, onChange) {
1422
+ var useClipboardPaste = function useClipboardPaste(textAreaRef, selection, onSelectionChange, onChange, isReadOnly) {
1423
1423
  useEffect(function () {
1424
1424
  var onPaste = function onPaste(e) {
1425
1425
  var textArea = textAreaRef.current;
@@ -1432,10 +1432,10 @@ var useClipboardPaste = function useClipboardPaste(textAreaRef, selection, onSel
1432
1432
 
1433
1433
  if (types.includes('text/html')) {
1434
1434
  var pastedHtml = clipboardData.getData('text/html');
1435
- parsed = parsePastedHtml(selection, pastedHtml);
1435
+ parsed = parsePastedHtml(selection, pastedHtml, isReadOnly);
1436
1436
  } else if (types.includes('text/plain')) {
1437
1437
  var text = clipboardData.getData('text/plain');
1438
- parsed = parsePastedText(selection, text);
1438
+ parsed = parsePastedText(selection, text, isReadOnly);
1439
1439
  }
1440
1440
 
1441
1441
  if (!parsed) return;
@@ -1521,7 +1521,7 @@ var findTable = function findTable(element) {
1521
1521
  }
1522
1522
  };
1523
1523
 
1524
- var parsePastedHtml = function parsePastedHtml(selection, html) {
1524
+ var parsePastedHtml = function parsePastedHtml(selection, html, isReadOnly) {
1525
1525
  var div = document.createElement('div');
1526
1526
  div.innerHTML = html.trim();
1527
1527
 
@@ -1572,7 +1572,7 @@ var parsePastedHtml = function parsePastedHtml(selection, html) {
1572
1572
 
1573
1573
  str = str.replaceAll('\n', '');
1574
1574
  str = str.replaceAll(/\s\s+/g, ' ');
1575
- changes.push({
1575
+ if (!(isReadOnly !== null && isReadOnly !== void 0 && isReadOnly(x, y))) changes.push({
1576
1576
  x: x,
1577
1577
  y: y,
1578
1578
  value: str
@@ -1596,7 +1596,7 @@ var parsePastedHtml = function parsePastedHtml(selection, html) {
1596
1596
  };
1597
1597
  };
1598
1598
 
1599
- var parsePastedText = function parsePastedText(selection, text) {
1599
+ var parsePastedText = function parsePastedText(selection, text, isReadOnly) {
1600
1600
  var _normalizeSelection3 = normalizeSelection(selection),
1601
1601
  _normalizeSelection3$ = _normalizeSelection3[0],
1602
1602
  minX = _normalizeSelection3$[0],
@@ -1614,9 +1614,11 @@ var parsePastedText = function parsePastedText(selection, text) {
1614
1614
  right = Math.max(right, left + cols.length - 1);
1615
1615
 
1616
1616
  for (var x = 0; x < cols.length; x++) {
1617
- changes.push({
1618
- x: left + x,
1619
- y: top + y,
1617
+ var X = left + x;
1618
+ var Y = top + y;
1619
+ if (!(isReadOnly !== null && isReadOnly !== void 0 && isReadOnly(X, Y))) changes.push({
1620
+ x: X,
1621
+ y: Y,
1620
1622
  value: cols[x]
1621
1623
  });
1622
1624
  }
@@ -2812,7 +2814,7 @@ var Sheet = forwardRef(function (props, ref) {
2812
2814
  var hitmapRef = useRef(NO_CLICKABLES);
2813
2815
  var textAreaRef = useRef(null);
2814
2816
  useClipboardCopy(textAreaRef, selection, editMode, editData);
2815
- useClipboardPaste(textAreaRef, selection, changeSelection, props.onChange);
2817
+ useClipboardPaste(textAreaRef, selection, changeSelection, props.onChange, cellReadOnly);
2816
2818
  var onScroll = useScroll(dataOffset, maxScroll, cellLayout, setDataOffset, setMaxScroll);
2817
2819
 
2818
2820
  var _useMouse = useMouse(hitmapRef, selection, knobArea, editMode, editData, sourceData, cellReadOnly, canSizeColumn, canSizeRow, canOrderColumn, canOrderRow, cellLayout, visibleCells, sheetStyle, startEditingCell, commitEditingCell, setKnobArea, setDragOffset, setDropTarget, changeSelection, props.cacheLayout ? columnLayout.clearAfter : undefined, props.cacheLayout ? rowLayout.clearAfter : undefined, props.onChange, props.onColumnOrderChange, props.onRowOrderChange, props.onCellWidthChange, props.onCellHeightChange, props.onRightClick, props.dontCommitEditOnSelectionChange),