sheet-happens 0.0.9 → 0.0.10

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.
@@ -1111,10 +1111,26 @@ function Sheet(props) {
1111
1111
  var td = _step18.value;
1112
1112
 
1113
1113
  if (td.nodeName === 'TD') {
1114
+ var str = '';
1115
+
1116
+ if (td.children.length !== 0 && td.children[0].nodeName === 'P') {
1117
+ var p = td.children[0];
1118
+
1119
+ if (p.children.length !== 0 && p.children[0].nodeName === 'FONT') {
1120
+ str = p.children[0].innerHTML;
1121
+ } else {
1122
+ str = p.innerHTML;
1123
+ }
1124
+ } else {
1125
+ str = td.innerHTML;
1126
+ }
1127
+
1128
+ str = str.replaceAll('\n', '');
1129
+ str = str.replaceAll(/\s\s+/g, ' ');
1114
1130
  changes.push({
1115
1131
  y: y,
1116
1132
  x: x,
1117
- value: td.innerHTML
1133
+ value: str
1118
1134
  });
1119
1135
  x++;
1120
1136
  }
@@ -1396,7 +1412,7 @@ function Sheet(props) {
1396
1412
  var scrollToP2 = true;
1397
1413
 
1398
1414
  if (x < rowHeaderWidth) {
1399
- sel2.x = 100;
1415
+ sel2.x = dataOffset.x + 100;
1400
1416
  scrollToP2 = false;
1401
1417
  setRowSelectionInProgress(true);
1402
1418
  } else {
@@ -1404,7 +1420,7 @@ function Sheet(props) {
1404
1420
  }
1405
1421
 
1406
1422
  if (y < columnHeaderHeight) {
1407
- sel2.y = 100;
1423
+ sel2.y = dataOffset.y + 100;
1408
1424
  scrollToP2 = false;
1409
1425
  setColumnSelectionInProgress(true);
1410
1426
  } else {
@@ -1662,7 +1678,14 @@ function Sheet(props) {
1662
1678
  y2 = selection.y1;
1663
1679
  }
1664
1680
 
1665
- if (Math.abs(cell.x - (x1 + x2) * 0.5) < Math.abs(cell.y - (y1 + y2) * 0.5)) {
1681
+ var xCellDiff = 0;
1682
+ if (cell.x < x1) xCellDiff = cell.x - x1;
1683
+ if (cell.x > x2) xCellDiff = x2 - cell.x;
1684
+ var yCellDiff = 0;
1685
+ if (cell.y < y1) yCellDiff = cell.y - y1;
1686
+ if (cell.y > y2) yCellDiff = y2 - cell.y;
1687
+
1688
+ if (xCellDiff > yCellDiff) {
1666
1689
  if (cell.y < y1) {
1667
1690
  y1 = cell.y;
1668
1691
  } else {
@@ -1686,7 +1709,9 @@ function Sheet(props) {
1686
1709
  };
1687
1710
 
1688
1711
  var onDoubleClick = function onDoubleClick(e) {
1689
- if (!e.target || !(e.target instanceof Element)) {
1712
+ e.preventDefault();
1713
+
1714
+ if (!e.target || !(e.target instanceof Element) || shiftKeyDown) {
1690
1715
  return;
1691
1716
  }
1692
1717
 
@@ -1890,6 +1915,18 @@ function Sheet(props) {
1890
1915
  y1 = selection.y1,
1891
1916
  y2 = selection.y2;
1892
1917
 
1918
+ if (x1 > x2) {
1919
+ var _ref = [x2, x1];
1920
+ x1 = _ref[0];
1921
+ x2 = _ref[1];
1922
+ }
1923
+
1924
+ if (y1 > y2) {
1925
+ var _ref2 = [y2, y1];
1926
+ y1 = _ref2[0];
1927
+ y2 = _ref2[1];
1928
+ }
1929
+
1893
1930
  if (!(y > columnHeaderHeight && x > rowHeaderWidth)) {
1894
1931
  return;
1895
1932
  }