handsontable 0.0.0-next-cecf979-20231026 → 0.0.0-next-e54c3d6-20231026

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

Files changed (47) hide show
  1. package/3rdparty/walkontable/src/cell/coords.d.ts +2 -0
  2. package/3rdparty/walkontable/src/cell/coords.js +29 -0
  3. package/3rdparty/walkontable/src/cell/coords.mjs +29 -0
  4. package/base.js +2 -2
  5. package/base.mjs +2 -2
  6. package/core/focusCatcher/index.js +26 -20
  7. package/core/focusCatcher/index.mjs +26 -20
  8. package/core.js +65 -53
  9. package/core.mjs +65 -53
  10. package/dist/handsontable.css +2 -2
  11. package/dist/handsontable.full.css +2 -2
  12. package/dist/handsontable.full.js +3602 -2219
  13. package/dist/handsontable.full.min.css +2 -2
  14. package/dist/handsontable.full.min.js +88 -81
  15. package/dist/handsontable.js +3603 -2220
  16. package/dist/handsontable.min.css +2 -2
  17. package/dist/handsontable.min.js +30 -23
  18. package/helpers/mixed.js +1 -1
  19. package/helpers/mixed.mjs +1 -1
  20. package/package.json +1 -1
  21. package/pluginHooks.d.ts +30 -6
  22. package/pluginHooks.js +148 -62
  23. package/pluginHooks.mjs +148 -62
  24. package/plugins/copyPaste/clipboardData/clipboardData.js +517 -0
  25. package/plugins/copyPaste/clipboardData/clipboardData.mjs +512 -0
  26. package/plugins/copyPaste/clipboardData/copyClipboardData.js +69 -0
  27. package/plugins/copyPaste/clipboardData/copyClipboardData.mjs +65 -0
  28. package/plugins/copyPaste/clipboardData/index.js +9 -0
  29. package/plugins/copyPaste/clipboardData/index.mjs +4 -0
  30. package/plugins/copyPaste/clipboardData/pasteClipboardData.js +81 -0
  31. package/plugins/copyPaste/clipboardData/pasteClipboardData.mjs +77 -0
  32. package/plugins/copyPaste/copyPaste.js +38 -92
  33. package/plugins/copyPaste/copyPaste.mjs +40 -94
  34. package/plugins/nestedHeaders/nestedHeaders.js +21 -22
  35. package/plugins/nestedHeaders/nestedHeaders.mjs +21 -22
  36. package/selection/selection.js +12 -0
  37. package/selection/selection.mjs +12 -0
  38. package/selection/transformation.js +42 -44
  39. package/selection/transformation.mjs +42 -44
  40. package/shortcutContexts/grid.js +4 -0
  41. package/shortcutContexts/grid.mjs +4 -0
  42. package/utils/parseTable.js +527 -83
  43. package/utils/parseTable.mjs +523 -82
  44. package/plugins/copyPaste/clipboardData.js +0 -18
  45. package/plugins/copyPaste/clipboardData.mjs +0 -14
  46. package/plugins/copyPaste/pasteEvent.js +0 -14
  47. package/plugins/copyPaste/pasteEvent.mjs +0 -9
package/pluginHooks.mjs CHANGED
@@ -1200,6 +1200,38 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
1200
1200
  * If set to `false`, the rendering gets triggered by scrolling or moving the selection.
1201
1201
  */
1202
1202
  'afterRender',
1203
+ /**
1204
+ * When the focus position is moved to the next or previous row caused by the {@link Options#autoWrapRow} option
1205
+ * the hook is triggered.
1206
+ *
1207
+ * @since 14.0.0
1208
+ * @event Hooks#beforeRowWrap
1209
+ * @param {boolean} isWrapEnabled Tells whether the row wrapping is going to happen.
1210
+ * There may be situations where the option does not work even though it is enabled.
1211
+ * This is due to the priority of other options that may block the feature.
1212
+ * For example, when the {@link Options#minSpareCols} is defined, the {@link Options#autoWrapRow} option is not checked.
1213
+ * Thus, row wrapping is off.
1214
+ * @param {CellCoords} newCoords The new focus position.
1215
+ * @param {boolean} isFlipped `true` if the row index was flipped, `false` otherwise.
1216
+ * Flipped index means that the user reached the last row and the focus is moved to the first row or vice versa.
1217
+ */
1218
+ 'beforeRowWrap',
1219
+ /**
1220
+ * When the focus position is moved to the next or previous column caused by the {@link Options#autoWrapCol} option
1221
+ * the hook is triggered.
1222
+ *
1223
+ * @since 14.0.0
1224
+ * @event Hooks#beforeColumnWrap
1225
+ * @param {boolean} isWrapEnabled Tells whether the column wrapping is going to happen.
1226
+ * There may be situations where the option does not work even though it is enabled.
1227
+ * This is due to the priority of other options that may block the feature.
1228
+ * For example, when the {@link Options#minSpareRows} is defined, the {@link Options#autoWrapCol} option is not checked.
1229
+ * Thus, column wrapping is off.
1230
+ * @param {CellCoords} newCoords The new focus position.
1231
+ * @param {boolean} isFlipped `true` if the column index was flipped, `false` otherwise.
1232
+ * Flipped index means that the user reached the last column and the focus is moved to the first column or vice versa.
1233
+ */
1234
+ 'beforeColumnWrap',
1203
1235
  /**
1204
1236
  * Fired before cell meta is changed.
1205
1237
  *
@@ -1471,26 +1503,35 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
1471
1503
  * Fired by {@link CopyPaste} plugin before copying the values to the clipboard and before clearing values of
1472
1504
  * the selected cells. This hook is fired when {@link Options#copyPaste} option is enabled.
1473
1505
  *
1506
+ * Note: Please keep in mind since @14.0.0 the method arguments has been changed.
1507
+ *
1474
1508
  * @event Hooks#beforeCut
1475
- * @param {Array[]} data An array of arrays which contains data to cut.
1476
- * @param {object[]} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
1477
- * which will be cut out.
1509
+ * @param {object} clipboardData Information about cut action which is going to happen.
1510
+ * @param {Function} clipboardData.removeRow Remove row from the copied dataset.
1511
+ * @param {Function} clipboardData.removeColumn Remove column from the copied dataset.
1512
+ * @param {Function} clipboardData.insertAtRow Insert values at row index.
1513
+ * @param {Function} clipboardData.insertAtColumn Insert values at column index.
1514
+ * @param {Function} clipboardData.setCellAt Change headers or cells in the copied dataset.
1515
+ * @param {Function} clipboardData.getCellAt Get headers or cells from the copied dataset.
1516
+ * @param {Function} clipboardData.getData Gets copied data stored as array of arrays.
1517
+ * @param {Function} clipboardData.getMetaInfo Gets meta information for the copied data.
1518
+ * @param {Function} clipboardData.getRanges Returns ranges related to copied part of Handsontable.
1478
1519
  * @returns {*} If returns `false` then operation of the cutting out is canceled.
1479
1520
  * @example
1480
1521
  * ::: only-for javascript
1481
1522
  * ```js
1482
- * // To disregard a single row, remove it from the array using data.splice(i, 1).
1523
+ * // To disregard a single row or column, remove it from copied dataset using `removeRows`/`removeColumns` method on the object from the first callback argument.
1483
1524
  * new Handsontable(element, {
1484
- * beforeCut: function(data, coords) {
1485
- * // data -> [[1, 2, 3], [4, 5, 6]]
1486
- * data.splice(0, 1);
1487
- * // data -> [[4, 5, 6]]
1488
- * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
1525
+ * beforeCut: function(clipboardData) {
1526
+ * // clipboardData.getData() -> [[1, 2, 3], [4, 5, 6]]
1527
+ * clipboardData.removeRows([0]);
1528
+ * clipboardData.removeColumns([0]);
1529
+ * // clipboardData.getData() -> [[5, 6]]
1489
1530
  * }
1490
1531
  * });
1491
1532
  * // To cancel a cutting action, just return `false`.
1492
1533
  * new Handsontable(element, {
1493
- * beforeCut: function(data, coords) {
1534
+ * beforeCut: function(clipboardData) {
1494
1535
  * return false;
1495
1536
  * }
1496
1537
  * });
@@ -1499,18 +1540,18 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
1499
1540
  *
1500
1541
  * ::: only-for react
1501
1542
  * ```jsx
1502
- * // To disregard a single row, remove it from the array using data.splice(i, 1).
1543
+ * // To disregard a single row or column, remove it from copied dataset using `removeRows`/`removeColumns` method on the object from the first callback argument.
1503
1544
  * <HotTable
1504
- * beforeCut={(data, coords) => {
1505
- * // data -> [[1, 2, 3], [4, 5, 6]]
1506
- * data.splice(0, 1);
1507
- * // data -> [[4, 5, 6]]
1508
- * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
1545
+ * beforeCut={(clipboardData) => {
1546
+ * // clipboardData.getData() -> [[1, 2, 3], [4, 5, 6]]
1547
+ * clipboardData.removeRows([0]);
1548
+ * clipboardData.removeColumns([0]);
1549
+ * // clipboardData.getData() -> [[5, 6]]
1509
1550
  * }}
1510
1551
  * />
1511
1552
  * // To cancel a cutting action, just return `false`.
1512
1553
  * <HotTable
1513
- * beforeCut={(data, coords) => {
1554
+ * beforeCut={(clipboardData) => {
1514
1555
  * return false;
1515
1556
  * }}
1516
1557
  * />
@@ -1522,33 +1563,50 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
1522
1563
  * Fired by {@link CopyPaste} plugin after data was cut out from the table. This hook is fired when
1523
1564
  * {@link Options#copyPaste} option is enabled.
1524
1565
  *
1566
+ * Note: Please keep in mind since @14.0.0 the method arguments has been changed.
1567
+ *
1525
1568
  * @event Hooks#afterCut
1526
- * @param {Array[]} data An array of arrays with the cut data.
1527
- * @param {object[]} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
1528
- * which was cut out.
1569
+ * @param {object} clipboardData Information about already performed cut action.
1570
+ * @param {Function} clipboardData.removeRow Remove row from the copied dataset.
1571
+ * @param {Function} clipboardData.removeColumn Remove column from the copied dataset.
1572
+ * @param {Function} clipboardData.insertAtRow Insert values at row index.
1573
+ * @param {Function} clipboardData.insertAtColumn Insert values at column index.
1574
+ * @param {Function} clipboardData.setCellAt Change headers or cells in the copied dataset.
1575
+ * @param {Function} clipboardData.getCellAt Get headers or cells from the copied dataset.
1576
+ * @param {Function} clipboardData.getData Gets copied data stored as array of arrays.
1577
+ * @param {Function} clipboardData.getMetaInfo Gets meta information for the copied data.
1578
+ * @param {Function} clipboardData.getRanges Returns ranges related to copied part of Handsontable.
1529
1579
  */
1530
1580
  'afterCut',
1531
1581
  /**
1532
1582
  * Fired before values are copied to the clipboard.
1533
1583
  *
1584
+ * Note: Please keep in mind since @14.0.0 the method arguments has been changed.
1585
+ *
1534
1586
  * @event Hooks#beforeCopy
1535
- * @param {Array[]} data An array of arrays which contains data to copied.
1536
- * @param {object[]} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
1537
- * which will copied.
1538
- * @param {{ columnHeadersCount: number }} copiedHeadersCount (Since 12.3.0) The number of copied column headers.
1587
+ * @param {object} clipboardData Information about copy action which is going to happen.
1588
+ * @param {Function} clipboardData.removeRow Remove row from the copied dataset.
1589
+ * @param {Function} clipboardData.removeColumn Remove column from the copied dataset.
1590
+ * @param {Function} clipboardData.insertAtRow Insert values at row index.
1591
+ * @param {Function} clipboardData.insertAtColumn Insert values at column index.
1592
+ * @param {Function} clipboardData.setCellAt Change headers or cells in the copied dataset.
1593
+ * @param {Function} clipboardData.getCellAt Get headers or cells from the copied dataset.
1594
+ * @param {Function} clipboardData.getData Gets copied data stored as array of arrays.
1595
+ * @param {Function} clipboardData.getMetaInfo Gets meta information for the copied data.
1596
+ * @param {Function} clipboardData.getRanges Returns ranges related to copied part of Handsontable.
1539
1597
  * @returns {*} If returns `false` then copying is canceled.
1540
1598
  *
1541
1599
  * @example
1542
1600
  * ::: only-for javascript
1543
1601
  * ```js
1544
- * // To disregard a single row, remove it from array using data.splice(i, 1).
1602
+ * // To disregard a single row or column, remove it from copied dataset using `removeRows`/`removeColumns` method on the object from the first callback argument.
1545
1603
  * ...
1546
1604
  * new Handsontable(document.getElementById('example'), {
1547
- * beforeCopy: (data, coords) => {
1548
- * // data -> [[1, 2, 3], [4, 5, 6]]
1549
- * data.splice(0, 1);
1550
- * // data -> [[4, 5, 6]]
1551
- * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
1605
+ * beforeCopy: (clipboardData) => {
1606
+ * // clipboardData.getData() -> [[1, 2, 3], [4, 5, 6]]
1607
+ * clipboardData.removeRows([0]);
1608
+ * clipboardData.removeColumns([0]);
1609
+ * // clipboardData.getData() -> [[5, 6]]
1552
1610
  * }
1553
1611
  * });
1554
1612
  * ...
@@ -1556,7 +1614,7 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
1556
1614
  * // To cancel copying, return false from the callback.
1557
1615
  * ...
1558
1616
  * new Handsontable(document.getElementById('example'), {
1559
- * beforeCopy: (data, coords) => {
1617
+ * beforeCopy: (clipboardData) => {
1560
1618
  * return false;
1561
1619
  * }
1562
1620
  * });
@@ -1566,14 +1624,14 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
1566
1624
  *
1567
1625
  * ::: only-for react
1568
1626
  * ```jsx
1569
- * // To disregard a single row, remove it from array using data.splice(i, 1).
1627
+ * // To disregard a single row or column, remove it from copied dataset using `removeRows`/`removeColumns` method on the object from the first callback argument.
1570
1628
  * ...
1571
1629
  * <HotTable
1572
- * beforeCopy={(data, coords) => {
1573
- * // data -> [[1, 2, 3], [4, 5, 6]]
1574
- * data.splice(0, 1);
1575
- * // data -> [[4, 5, 6]]
1576
- * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
1630
+ * beforeCopy={(clipboardData) => {
1631
+ * // clipboardData.getData() -> [[1, 2, 3], [4, 5, 6]]
1632
+ * clipboardData.removeRows([0]);
1633
+ * clipboardData.removeColumns([0]);
1634
+ * // clipboardData.getData() -> [[5, 6]]
1577
1635
  * }}
1578
1636
  * />
1579
1637
  * ...
@@ -1581,7 +1639,7 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
1581
1639
  * // To cancel copying, return false from the callback.
1582
1640
  * ...
1583
1641
  * <HotTable
1584
- * beforeCopy={(data, coords) => {
1642
+ * beforeCopy={(clipboardData) => {
1585
1643
  * return false;
1586
1644
  * }}
1587
1645
  * />
@@ -1594,37 +1652,55 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
1594
1652
  * Fired by {@link CopyPaste} plugin after data are pasted into table. This hook is fired when {@link Options#copyPaste}
1595
1653
  * option is enabled.
1596
1654
  *
1655
+ * Note: Please keep in mind since @14.0.0 the method arguments has been changed.
1656
+ *
1597
1657
  * @event Hooks#afterCopy
1598
- * @param {Array[]} data An array of arrays which contains the copied data.
1599
- * @param {object[]} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
1600
- * which was copied.
1601
- * @param {{ columnHeadersCount: number }} copiedHeadersCount (Since 12.3.0) The number of copied column headers.
1658
+ * @param {object} clipboardData Information about already performed copy action.
1659
+ * @param {Function} clipboardData.removeRow Remove row from the copied dataset.
1660
+ * @param {Function} clipboardData.removeColumn Remove column from the copied dataset.
1661
+ * @param {Function} clipboardData.insertAtRow Insert values at row index.
1662
+ * @param {Function} clipboardData.insertAtColumn Insert values at column index.
1663
+ * @param {Function} clipboardData.setCellAt Change headers or cells in the copied dataset.
1664
+ * @param {Function} clipboardData.getCellAt Get headers or cells from the copied dataset.
1665
+ * @param {Function} clipboardData.getData Gets copied data stored as array of arrays.
1666
+ * @param {Function} clipboardData.getMetaInfo Gets meta information for the copied data.
1667
+ * @param {Function} clipboardData.getRanges Returns ranges related to copied part of Handsontable.
1602
1668
  */
1603
1669
  'afterCopy',
1604
1670
  /**
1605
1671
  * Fired by {@link CopyPaste} plugin before values are pasted into table. This hook is fired when
1606
1672
  * {@link Options#copyPaste} option is enabled.
1607
1673
  *
1674
+ * Note: Please keep in mind since @14.0.0 the method arguments has been changed.
1675
+ *
1608
1676
  * @event Hooks#beforePaste
1609
- * @param {Array[]} data An array of arrays which contains data to paste.
1610
- * @param {object[]} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
1611
- * that correspond to the previously selected area.
1677
+ * @param {object} clipboardData Information about paste action which is going to happen.
1678
+ * @param {Function} clipboardData.removeRow Remove row from the pasted dataset.
1679
+ * @param {Function} clipboardData.removeColumn Remove column from the pasted dataset.
1680
+ * @param {Function} clipboardData.insertAtRow Insert values at row index.
1681
+ * @param {Function} clipboardData.insertAtColumn Insert values at column index.
1682
+ * @param {Function} clipboardData.setCellAt Change headers or cells in the pasted dataset.
1683
+ * @param {Function} clipboardData.getCellAt Get headers or cells from the pasted dataset.
1684
+ * @param {Function} clipboardData.getData Gets copied data stored as array of arrays.
1685
+ * @param {Function} clipboardData.getMetaInfo Gets meta information for the copied data.
1686
+ * @param {Function} clipboardData.getSource Gets information about source of the copied data
1687
+ * (Handsontable, table or string).
1612
1688
  * @returns {*} If returns `false` then pasting is canceled.
1613
1689
  * @example
1614
1690
  * ```js
1615
1691
  * ::: only-for javascript
1616
- * // To disregard a single row, remove it from array using data.splice(i, 1).
1692
+ * // To disregard a single row or column, remove it from copied dataset using `removeRows`/`removeColumns` method on the object from the first callback argument.
1617
1693
  * new Handsontable(example, {
1618
- * beforePaste: (data, coords) => {
1619
- * // data -> [[1, 2, 3], [4, 5, 6]]
1620
- * data.splice(0, 1);
1621
- * // data -> [[4, 5, 6]]
1622
- * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
1694
+ * beforePaste: (clipboardData) => {
1695
+ * // clipboardData.getData() -> [[1, 2, 3], [4, 5, 6]]
1696
+ * clipboardData.removeRows([0]);
1697
+ * clipboardData.removeColumns([0]);
1698
+ * // clipboardData.getData() -> [[5, 6]]
1623
1699
  * }
1624
1700
  * });
1625
1701
  * // To cancel pasting, return false from the callback.
1626
1702
  * new Handsontable(example, {
1627
- * beforePaste: (data, coords) => {
1703
+ * beforePaste: (clipboardData) => {
1628
1704
  * return false;
1629
1705
  * }
1630
1706
  * });
@@ -1633,18 +1709,18 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
1633
1709
  *
1634
1710
  * ::: only-for react
1635
1711
  * ```jsx
1636
- * // To disregard a single row, remove it from array using data.splice(i, 1).
1712
+ * // To disregard a single row or column, remove it from copied dataset using `removeRows`/`removeColumns` method on the object from the first callback argument.
1637
1713
  * <HotTable
1638
- * beforePaste={(data, coords) => {
1639
- * // data -> [[1, 2, 3], [4, 5, 6]]
1640
- * data.splice(0, 1);
1641
- * // data -> [[4, 5, 6]]
1642
- * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
1714
+ * beforePaste={(clipboardData) => {
1715
+ * // clipboardData.getData() -> [[1, 2, 3], [4, 5, 6]]
1716
+ * clipboardData.removeRows([0]);
1717
+ * clipboardData.removeColumns([0]);
1718
+ * // clipboardData.getData() -> [[5, 6]]
1643
1719
  * }}
1644
1720
  * />
1645
1721
  * // To cancel pasting, return false from the callback.
1646
1722
  * <HotTable
1647
- * beforePaste={(data, coords) => {
1723
+ * beforePaste={(clipboardData) => {
1648
1724
  * return false;
1649
1725
  * }}
1650
1726
  * />
@@ -1656,10 +1732,20 @@ const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-s
1656
1732
  * Fired by {@link CopyPaste} plugin after values are pasted into table. This hook is fired when
1657
1733
  * {@link Options#copyPaste} option is enabled.
1658
1734
  *
1735
+ * Note: Please keep in mind since @14.0.0 the method arguments has been changed.
1736
+ *
1659
1737
  * @event Hooks#afterPaste
1660
- * @param {Array[]} data An array of arrays with the pasted data.
1661
- * @param {object[]} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
1662
- * that correspond to the previously selected area.
1738
+ * @param {object} clipboardData Information about already performed paste action.
1739
+ * @param {Function} clipboardData.removeRow Remove row from the pasted dataset.
1740
+ * @param {Function} clipboardData.removeColumn Remove column from the pasted dataset.
1741
+ * @param {Function} clipboardData.insertAtRow Insert values at row index.
1742
+ * @param {Function} clipboardData.insertAtColumn Insert values at column index.
1743
+ * @param {Function} clipboardData.setCellAt Change headers or cells in the pasted dataset.
1744
+ * @param {Function} clipboardData.getCellAt Get headers or cells from the pasted dataset.
1745
+ * @param {Function} clipboardData.getData Gets copied data stored as array of arrays.
1746
+ * @param {Function} clipboardData.getMetaInfo Gets meta information for the copied data.
1747
+ * @param {Function} clipboardData.getSource Gets information about source of the copied data
1748
+ * (Handsontable, table or string).
1663
1749
  */
1664
1750
  'afterPaste',
1665
1751
  /**