@atlaskit/editor-tables 2.3.11 → 2.3.13

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/cell-bookmark.js +2 -3
  3. package/dist/cjs/cell-selection.js +1 -2
  4. package/dist/cjs/pm-plugins/input.js +2 -3
  5. package/dist/cjs/pm-plugins/plugin-key.js +2 -4
  6. package/dist/cjs/table-map.js +4 -8
  7. package/dist/cjs/utils/add-column-at.js +2 -3
  8. package/dist/cjs/utils/add-row-at.js +3 -5
  9. package/dist/cjs/utils/clone-tr.js +2 -3
  10. package/dist/cjs/utils/create-table.js +2 -3
  11. package/dist/cjs/utils/empty-cells.js +2 -3
  12. package/dist/cjs/utils/find.js +5 -9
  13. package/dist/cjs/utils/for-each-cell.js +3 -5
  14. package/dist/cjs/utils/get-cells-in-column.js +2 -3
  15. package/dist/cjs/utils/get-cells-in-row.js +2 -3
  16. package/dist/cjs/utils/get-cells-in-table.js +2 -3
  17. package/dist/cjs/utils/get-selection-range-in-column.js +2 -3
  18. package/dist/cjs/utils/get-selection-range-in-row.js +2 -3
  19. package/dist/cjs/utils/get-selection-rect.js +2 -3
  20. package/dist/cjs/utils/is-selected.js +5 -9
  21. package/dist/cjs/utils/move-column.js +12 -4
  22. package/dist/cjs/utils/move-row.js +12 -4
  23. package/dist/cjs/utils/remove-column.js +4 -7
  24. package/dist/cjs/utils/remove-row.js +4 -7
  25. package/dist/cjs/utils/remove-table.js +2 -3
  26. package/dist/cjs/utils/reorder-utils.js +7 -13
  27. package/dist/cjs/utils/replace-table.js +2 -3
  28. package/dist/cjs/utils/select-nodes.js +54 -10
  29. package/dist/cjs/utils/set-cell-attrs.js +2 -3
  30. package/dist/cjs/utils/split-cell.js +2 -3
  31. package/dist/cjs/utils/test-utils.js +5 -9
  32. package/dist/cjs/utils/uuid.js +4 -5
  33. package/dist/es2019/utils/move-column.js +10 -1
  34. package/dist/es2019/utils/move-row.js +10 -1
  35. package/dist/es2019/utils/select-nodes.js +49 -1
  36. package/dist/esm/pm-plugins/input.js +1 -1
  37. package/dist/esm/utils/move-column.js +10 -1
  38. package/dist/esm/utils/move-row.js +10 -1
  39. package/dist/esm/utils/select-nodes.js +49 -1
  40. package/dist/types/utils/move-column.d.ts +1 -1
  41. package/dist/types/utils/move-row.d.ts +1 -1
  42. package/dist/types/utils/select-nodes.d.ts +2 -2
  43. package/dist/types-ts4.5/utils/move-column.d.ts +1 -1
  44. package/dist/types-ts4.5/utils/move-row.d.ts +1 -1
  45. package/dist/types-ts4.5/utils/select-nodes.d.ts +2 -2
  46. package/package.json +9 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-tables
2
2
 
3
+ ## 2.3.13
4
+
5
+ ### Patch Changes
6
+
7
+ - [#42109](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42109) [`d25ae495fed`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d25ae495fed) - [ux] Adds a fix to keep selection on a dropped row or column.
8
+
9
+ ## 2.3.12
10
+
11
+ ### Patch Changes
12
+
13
+ - [#41991](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41991) [`28a7171e7e3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/28a7171e7e3) - [ux] add shift click select backward feature to expand selection
14
+
3
15
  ## 2.3.11
4
16
 
5
17
  ### Patch Changes
@@ -9,7 +9,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _state = require("@atlaskit/editor-prosemirror/state");
11
11
  var _tables = require("./utils/tables");
12
- var CellBookmark = /*#__PURE__*/function () {
12
+ var CellBookmark = exports.CellBookmark = /*#__PURE__*/function () {
13
13
  function CellBookmark(anchor, head) {
14
14
  (0, _classCallCheck2.default)(this, CellBookmark);
15
15
  this.anchor = anchor;
@@ -37,5 +37,4 @@ var CellBookmark = /*#__PURE__*/function () {
37
37
  }
38
38
  }]);
39
39
  return CellBookmark;
40
- }();
41
- exports.CellBookmark = CellBookmark;
40
+ }();
@@ -32,7 +32,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
32
32
  // With the plugin enabled, these will be created when the user
33
33
  // selects across cells, and will be drawn by giving selected cells a
34
34
  // `selectedCell` CSS class.
35
- var CellSelection = /*#__PURE__*/function (_Selection) {
35
+ var CellSelection = exports.CellSelection = /*#__PURE__*/function (_Selection) {
36
36
  (0, _inherits2.default)(CellSelection, _Selection);
37
37
  var _super = _createSuper(CellSelection);
38
38
  // :: (ResolvedPos, ?ResolvedPos)
@@ -337,5 +337,4 @@ var CellSelection = /*#__PURE__*/function (_Selection) {
337
337
  }]);
338
338
  return CellSelection;
339
339
  }(_state.Selection);
340
- exports.CellSelection = CellSelection;
341
340
  _state.Selection.jsonID('cell', CellSelection);
@@ -17,7 +17,7 @@ var _pluginKey = require("./plugin-key");
17
17
  // This file defines a number of helpers for wiring up user input to
18
18
  // table-related functionality.
19
19
 
20
- var handleKeyDown = (0, _keymap.keydownHandler)({
20
+ var handleKeyDown = exports.handleKeyDown = (0, _keymap.keydownHandler)({
21
21
  ArrowLeft: arrow('horiz', -1),
22
22
  ArrowRight: arrow('horiz', 1),
23
23
  ArrowUp: arrow('vert', -1),
@@ -31,7 +31,6 @@ var handleKeyDown = (0, _keymap.keydownHandler)({
31
31
  Delete: deleteCellSelection,
32
32
  'Mod-Delete': deleteCellSelection
33
33
  });
34
- exports.handleKeyDown = handleKeyDown;
35
34
  function maybeSetSelection(state, dispatch, selection) {
36
35
  if (selection.eq(state.selection)) {
37
36
  return false;
@@ -88,7 +87,7 @@ function shiftArrow(axis, dir) {
88
87
  var maybeTableCell = _$head.blockRange($anchor);
89
88
 
90
89
  // Make sure the selection is coming from the same cell
91
- var sameCell = ['tableCell', 'tableHeader'].includes((maybeTableCell === null || maybeTableCell === void 0 ? void 0 : (_maybeTableCell$paren = maybeTableCell.parent) === null || _maybeTableCell$paren === void 0 ? void 0 : _maybeTableCell$paren.type.name) || '');
90
+ var sameCell = ['tableCell', 'tableHeader'].includes((maybeTableCell === null || maybeTableCell === void 0 || (_maybeTableCell$paren = maybeTableCell.parent) === null || _maybeTableCell$paren === void 0 ? void 0 : _maybeTableCell$paren.type.name) || '');
92
91
  if (!sameCell) {
93
92
  return false;
94
93
  }
@@ -5,7 +5,5 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.tableEditingKey = exports.fixTablesKey = void 0;
7
7
  var _state = require("@atlaskit/editor-prosemirror/state");
8
- var tableEditingKey = new _state.PluginKey('selectingCells');
9
- exports.tableEditingKey = tableEditingKey;
10
- var fixTablesKey = new _state.PluginKey('fix-tables');
11
- exports.fixTablesKey = fixTablesKey;
8
+ var tableEditingKey = exports.tableEditingKey = new _state.PluginKey('selectingCells');
9
+ var fixTablesKey = exports.fixTablesKey = new _state.PluginKey('fix-tables');
@@ -48,34 +48,31 @@ if (typeof WeakMap !== 'undefined') {
48
48
  return _cache[cachePos++] = value;
49
49
  };
50
50
  }
51
- var Rect = /*#__PURE__*/(0, _createClass2.default)(function Rect(left, top, right, bottom) {
51
+ var Rect = exports.Rect = /*#__PURE__*/(0, _createClass2.default)(function Rect(left, top, right, bottom) {
52
52
  (0, _classCallCheck2.default)(this, Rect);
53
53
  this.left = left;
54
54
  this.top = top;
55
55
  this.right = right;
56
56
  this.bottom = bottom;
57
57
  });
58
- exports.Rect = Rect;
59
- var TableProblemTypes = /*#__PURE__*/function (TableProblemTypes) {
58
+ var TableProblemTypes = exports.TableProblemTypes = /*#__PURE__*/function (TableProblemTypes) {
60
59
  TableProblemTypes["COLLISION"] = "collision";
61
60
  TableProblemTypes["OVERLONG_ROWSPAN"] = "overlong_rowspan";
62
61
  TableProblemTypes["MISSING"] = "missing";
63
62
  TableProblemTypes["COLWIDTH_MISMATCH"] = "colwidth mismatch";
64
63
  return TableProblemTypes;
65
64
  }({});
66
- exports.TableProblemTypes = TableProblemTypes;
67
65
  // Ideally tableNewColumnMinWidth should be imported
68
66
  // from '@atlaskit/editor-common/styles';
69
67
  // We don't want to introduce a new dependency.
70
68
  // Thus we define the constant here.
71
- var tableNewColumnMinWidth = 140;
69
+ var tableNewColumnMinWidth = exports.tableNewColumnMinWidth = 140;
72
70
 
73
71
  // ::- A table map describes the structore of a given table. To avoid
74
72
  // recomputing them all the time, they are cached per table node. To
75
73
  // be able to do that, positions saved in the map are relative to the
76
74
  // start of the table, rather than the start of the document.
77
- exports.tableNewColumnMinWidth = tableNewColumnMinWidth;
78
- var TableMap = /*#__PURE__*/function () {
75
+ var TableMap = exports.TableMap = /*#__PURE__*/function () {
79
76
  // The width of the table
80
77
 
81
78
  // The table's height
@@ -256,7 +253,6 @@ var TableMap = /*#__PURE__*/function () {
256
253
  }]);
257
254
  return TableMap;
258
255
  }(); // Compute a table map.
259
- exports.TableMap = TableMap;
260
256
  function computeMap(table) {
261
257
  if (table.type.spec.tableRole !== 'table') {
262
258
  throw new RangeError('Not a table node: ' + table.type.name);
@@ -9,7 +9,7 @@ var _addColumn = require("./add-column");
9
9
  var _cloneTr = require("./clone-tr");
10
10
  var _find = require("./find");
11
11
  // Returns a new transaction that adds a new column at index `columnIndex`.
12
- var addColumnAt = function addColumnAt(columnIndex) {
12
+ var addColumnAt = exports.addColumnAt = function addColumnAt(columnIndex) {
13
13
  return function (tr) {
14
14
  var table = (0, _find.findTable)(tr.selection);
15
15
  if (table) {
@@ -24,5 +24,4 @@ var addColumnAt = function addColumnAt(columnIndex) {
24
24
  }
25
25
  return tr;
26
26
  };
27
- };
28
- exports.addColumnAt = addColumnAt;
27
+ };
@@ -30,7 +30,7 @@ var filterCellsInRow = function filterCellsInRow(rowIndex, predicate) {
30
30
  };
31
31
 
32
32
  // Returns a new transaction that adds a new row after `cloneRowIndex`, cloning the row attributes at `cloneRowIndex`.
33
- var cloneRowAt = function cloneRowAt(rowIndex) {
33
+ var cloneRowAt = exports.cloneRowAt = function cloneRowAt(rowIndex) {
34
34
  return function (tr) {
35
35
  var table = (0, _find.findTable)(tr.selection);
36
36
  if (table) {
@@ -88,8 +88,7 @@ var cloneRowAt = function cloneRowAt(rowIndex) {
88
88
  };
89
89
 
90
90
  // Returns a new transaction that adds a new row at index `rowIndex`. Optionally clone the previous row.
91
- exports.cloneRowAt = cloneRowAt;
92
- var addRowAt = function addRowAt(rowIndex, clonePreviousRow) {
91
+ var addRowAt = exports.addRowAt = function addRowAt(rowIndex, clonePreviousRow) {
93
92
  return function (tr) {
94
93
  var table = (0, _find.findTable)(tr.selection);
95
94
  if (table) {
@@ -108,5 +107,4 @@ var addRowAt = function addRowAt(rowIndex, clonePreviousRow) {
108
107
  }
109
108
  return tr;
110
109
  };
111
- };
112
- exports.addRowAt = addRowAt;
110
+ };
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.cloneTr = void 0;
7
7
  // Creates a new transaction object from a given transaction
8
- var cloneTr = function cloneTr(tr) {
8
+ var cloneTr = exports.cloneTr = function cloneTr(tr) {
9
9
  return Object.assign(Object.create(tr), tr).setTime(Date.now());
10
- };
11
- exports.cloneTr = cloneTr;
10
+ };
@@ -17,7 +17,7 @@ var createCell = function createCell(cellType, cellContent) {
17
17
  // Returns a table node of a given size.
18
18
  // `withHeaderRow` defines whether the first row of the table will be a header row.
19
19
  // `cellContent` defines the content of each cell.
20
- var createTable = function createTable(_ref) {
20
+ var createTable = exports.createTable = function createTable(_ref) {
21
21
  var schema = _ref.schema,
22
22
  _ref$rowsCount = _ref.rowsCount,
23
23
  rowsCount = _ref$rowsCount === void 0 ? 3 : _ref$rowsCount,
@@ -58,5 +58,4 @@ var createTable = function createTable(_ref) {
58
58
  return table.createChecked({
59
59
  localId: _uuid.uuid.generate()
60
60
  }, rows);
61
- };
62
- exports.createTable = createTable;
61
+ };
@@ -7,7 +7,7 @@ exports.emptyCell = void 0;
7
7
  var _cloneTr = require("./clone-tr");
8
8
  var _tableNodeTypes = require("./table-node-types");
9
9
  // Returns a new transaction that clears the content of a given `cell`.
10
- var emptyCell = function emptyCell(cell, schema) {
10
+ var emptyCell = exports.emptyCell = function emptyCell(cell, schema) {
11
11
  return function (tr) {
12
12
  if (cell) {
13
13
  var node = (0, _tableNodeTypes.tableNodeTypes)(schema).cell.createAndFill();
@@ -18,5 +18,4 @@ var emptyCell = function emptyCell(cell, schema) {
18
18
  }
19
19
  return tr;
20
20
  };
21
- };
22
- exports.emptyCell = emptyCell;
21
+ };
@@ -7,15 +7,14 @@ exports.findTableClosestToPos = exports.findTable = exports.findCellRectClosestT
7
7
  var _utils = require("@atlaskit/editor-prosemirror/utils");
8
8
  var _tableMap = require("../table-map");
9
9
  // Iterates over parent nodes, returning the closest table node.
10
- var findTable = function findTable(selection) {
10
+ var findTable = exports.findTable = function findTable(selection) {
11
11
  return (0, _utils.findParentNode)(function (node) {
12
12
  return node.type.spec.tableRole && node.type.spec.tableRole === 'table';
13
13
  })(selection);
14
14
  };
15
15
 
16
16
  // Iterates over parent nodes, returning a table node closest to a given `$pos`.
17
- exports.findTable = findTable;
18
- var findTableClosestToPos = function findTableClosestToPos($pos) {
17
+ var findTableClosestToPos = exports.findTableClosestToPos = function findTableClosestToPos($pos) {
19
18
  var predicate = function predicate(node) {
20
19
  return node.type.spec.tableRole && node.type.spec.tableRole === 'table';
21
20
  };
@@ -23,8 +22,7 @@ var findTableClosestToPos = function findTableClosestToPos($pos) {
23
22
  };
24
23
 
25
24
  // Iterates over parent nodes, returning a table cell or a table header node closest to a given `$pos`.
26
- exports.findTableClosestToPos = findTableClosestToPos;
27
- var findCellClosestToPos = function findCellClosestToPos($pos) {
25
+ var findCellClosestToPos = exports.findCellClosestToPos = function findCellClosestToPos($pos) {
28
26
  var predicate = function predicate(node) {
29
27
  return node.type.spec.tableRole && /cell/i.test(node.type.spec.tableRole);
30
28
  };
@@ -32,8 +30,7 @@ var findCellClosestToPos = function findCellClosestToPos($pos) {
32
30
  };
33
31
 
34
32
  // Returns the rectangle spanning a cell closest to a given `$pos`.
35
- exports.findCellClosestToPos = findCellClosestToPos;
36
- var findCellRectClosestToPos = function findCellRectClosestToPos($pos) {
33
+ var findCellRectClosestToPos = exports.findCellRectClosestToPos = function findCellRectClosestToPos($pos) {
37
34
  var cell = findCellClosestToPos($pos);
38
35
  if (cell) {
39
36
  var table = findTableClosestToPos($pos);
@@ -43,5 +40,4 @@ var findCellRectClosestToPos = function findCellRectClosestToPos($pos) {
43
40
  return map.rectBetween(cellPos, cellPos);
44
41
  }
45
42
  }
46
- };
47
- exports.findCellRectClosestToPos = findCellRectClosestToPos;
43
+ };
@@ -10,7 +10,7 @@ var _getCellsInColumn = require("./get-cells-in-column");
10
10
  var _getCellsInRow = require("./get-cells-in-row");
11
11
  // Returns a new transaction that maps a given `cellTransform` function to each cell in a column at a given `columnIndex`.
12
12
  // It will set the selection into the last cell of the column if `setCursorToLastCell` param is set to `true`.
13
- var forEachCellInColumn = function forEachCellInColumn(columnIndex, cellTransform, setCursorToLastCell) {
13
+ var forEachCellInColumn = exports.forEachCellInColumn = function forEachCellInColumn(columnIndex, cellTransform, setCursorToLastCell) {
14
14
  return function (tr) {
15
15
  var cells = (0, _getCellsInColumn.getCellsInColumn)(columnIndex)(tr.selection);
16
16
  if (cells) {
@@ -29,8 +29,7 @@ var forEachCellInColumn = function forEachCellInColumn(columnIndex, cellTransfor
29
29
 
30
30
  // Returns a new transaction that maps a given `cellTransform` function to each cell in a row at a given `rowIndex`.
31
31
  // It will set the selection into the last cell of the row if `setCursorToLastCell` param is set to `true`.
32
- exports.forEachCellInColumn = forEachCellInColumn;
33
- var forEachCellInRow = function forEachCellInRow(rowIndex, cellTransform, setCursorToLastCell) {
32
+ var forEachCellInRow = exports.forEachCellInRow = function forEachCellInRow(rowIndex, cellTransform, setCursorToLastCell) {
34
33
  return function (tr) {
35
34
  var cells = (0, _getCellsInRow.getCellsInRow)(rowIndex)(tr.selection);
36
35
  if (cells) {
@@ -44,5 +43,4 @@ var forEachCellInRow = function forEachCellInRow(rowIndex, cellTransform, setCur
44
43
  }
45
44
  return tr;
46
45
  };
47
- };
48
- exports.forEachCellInRow = forEachCellInRow;
46
+ };
@@ -7,7 +7,7 @@ exports.getCellsInColumn = void 0;
7
7
  var _tableMap = require("../table-map");
8
8
  var _find = require("./find");
9
9
  // Returns an array of cells in a column(s), where `columnIndex` could be a column index or an array of column indexes.
10
- var getCellsInColumn = function getCellsInColumn(columnIndexes) {
10
+ var getCellsInColumn = exports.getCellsInColumn = function getCellsInColumn(columnIndexes) {
11
11
  return function (selection) {
12
12
  var table = (0, _find.findTable)(selection);
13
13
  if (!table) {
@@ -36,5 +36,4 @@ var getCellsInColumn = function getCellsInColumn(columnIndexes) {
36
36
  }));
37
37
  }, []);
38
38
  };
39
- };
40
- exports.getCellsInColumn = getCellsInColumn;
39
+ };
@@ -7,7 +7,7 @@ exports.getCellsInRow = void 0;
7
7
  var _tableMap = require("../table-map");
8
8
  var _find = require("./find");
9
9
  // Returns an array of cells in a row(s), where `rowIndex` could be a row index or an array of row indexes.
10
- var getCellsInRow = function getCellsInRow(rowIndex) {
10
+ var getCellsInRow = exports.getCellsInRow = function getCellsInRow(rowIndex) {
11
11
  return function (selection) {
12
12
  var table = (0, _find.findTable)(selection);
13
13
  if (!table) {
@@ -36,5 +36,4 @@ var getCellsInRow = function getCellsInRow(rowIndex) {
36
36
  }));
37
37
  }, []);
38
38
  };
39
- };
40
- exports.getCellsInRow = getCellsInRow;
39
+ };
@@ -7,7 +7,7 @@ exports.getCellsInTable = void 0;
7
7
  var _tableMap = require("../table-map");
8
8
  var _find = require("./find");
9
9
  // Returns an array of all cells in a table.
10
- var getCellsInTable = function getCellsInTable(selection) {
10
+ var getCellsInTable = exports.getCellsInTable = function getCellsInTable(selection) {
11
11
  var table = (0, _find.findTable)(selection);
12
12
  if (!table) {
13
13
  return;
@@ -33,5 +33,4 @@ var getCellsInTable = function getCellsInTable(selection) {
33
33
  }).filter(function (cell) {
34
34
  return typeof cell !== 'undefined';
35
35
  });
36
- };
37
- exports.getCellsInTable = getCellsInTable;
36
+ };
@@ -7,7 +7,7 @@ exports.getSelectionRangeInColumn = void 0;
7
7
  var _getCellsInColumn = require("./get-cells-in-column");
8
8
  var _getCellsInRow = require("./get-cells-in-row");
9
9
  // Returns a range of rectangular selection spanning all merged cells around a column at index `columnIndex`.
10
- var getSelectionRangeInColumn = function getSelectionRangeInColumn(columnIndex) {
10
+ var getSelectionRangeInColumn = exports.getSelectionRangeInColumn = function getSelectionRangeInColumn(columnIndex) {
11
11
  return function (tr) {
12
12
  var startIndex = columnIndex;
13
13
  var endIndex = columnIndex;
@@ -87,5 +87,4 @@ var getSelectionRangeInColumn = function getSelectionRangeInColumn(columnIndex)
87
87
  indexes: indexes
88
88
  };
89
89
  };
90
- };
91
- exports.getSelectionRangeInColumn = getSelectionRangeInColumn;
90
+ };
@@ -7,7 +7,7 @@ exports.getSelectionRangeInRow = void 0;
7
7
  var _getCellsInColumn = require("./get-cells-in-column");
8
8
  var _getCellsInRow = require("./get-cells-in-row");
9
9
  // Returns a range of rectangular selection spanning all merged cells around a row at index `rowIndex`.
10
- var getSelectionRangeInRow = function getSelectionRangeInRow(rowIndex) {
10
+ var getSelectionRangeInRow = exports.getSelectionRangeInRow = function getSelectionRangeInRow(rowIndex) {
11
11
  return function (tr) {
12
12
  var startIndex = rowIndex;
13
13
  var endIndex = rowIndex;
@@ -87,5 +87,4 @@ var getSelectionRangeInRow = function getSelectionRangeInRow(rowIndex) {
87
87
  indexes: indexes
88
88
  };
89
89
  };
90
- };
91
- exports.getSelectionRangeInRow = getSelectionRangeInRow;
90
+ };
@@ -7,12 +7,11 @@ exports.getSelectionRect = void 0;
7
7
  var _tableMap = require("../table-map");
8
8
  var _isSelectionType = require("./is-selection-type");
9
9
  // Get the selection rectangle. Returns `undefined` if selection is not a CellSelection.
10
- var getSelectionRect = function getSelectionRect(selection) {
10
+ var getSelectionRect = exports.getSelectionRect = function getSelectionRect(selection) {
11
11
  if (!(0, _isSelectionType.isSelectionType)(selection, 'cell')) {
12
12
  return;
13
13
  }
14
14
  var start = selection.$anchorCell.start(-1);
15
15
  var map = _tableMap.TableMap.get(selection.$anchorCell.node(-1));
16
16
  return map.rectBetween(selection.$anchorCell.pos - start, selection.$headCell.pos - start);
17
- };
18
- exports.getSelectionRect = getSelectionRect;
17
+ };
@@ -7,7 +7,7 @@ exports.isTableSelected = exports.isRowSelected = exports.isRectSelected = expor
7
7
  var _tableMap = require("../table-map");
8
8
  var _isSelectionType = require("./is-selection-type");
9
9
  // Checks if a given CellSelection rect is selected
10
- var isRectSelected = function isRectSelected(rect) {
10
+ var isRectSelected = exports.isRectSelected = function isRectSelected(rect) {
11
11
  return function (selection) {
12
12
  if (!(0, _isSelectionType.isSelectionType)(selection, 'cell')) {
13
13
  return false;
@@ -26,8 +26,7 @@ var isRectSelected = function isRectSelected(rect) {
26
26
  };
27
27
 
28
28
  // Checks if entire column at index `columnIndex` is selected.
29
- exports.isRectSelected = isRectSelected;
30
- var isColumnSelected = function isColumnSelected(columnIndex) {
29
+ var isColumnSelected = exports.isColumnSelected = function isColumnSelected(columnIndex) {
31
30
  return function (selection) {
32
31
  if ((0, _isSelectionType.isSelectionType)(selection, 'cell')) {
33
32
  var map = _tableMap.TableMap.get(selection.$anchorCell.node(-1));
@@ -43,8 +42,7 @@ var isColumnSelected = function isColumnSelected(columnIndex) {
43
42
  };
44
43
 
45
44
  // Checks if entire row at index `rowIndex` is selected.
46
- exports.isColumnSelected = isColumnSelected;
47
- var isRowSelected = function isRowSelected(rowIndex) {
45
+ var isRowSelected = exports.isRowSelected = function isRowSelected(rowIndex) {
48
46
  return function (selection) {
49
47
  if ((0, _isSelectionType.isSelectionType)(selection, 'cell')) {
50
48
  var map = _tableMap.TableMap.get(selection.$anchorCell.node(-1));
@@ -60,8 +58,7 @@ var isRowSelected = function isRowSelected(rowIndex) {
60
58
  };
61
59
 
62
60
  // Checks if entire table is selected
63
- exports.isRowSelected = isRowSelected;
64
- var isTableSelected = function isTableSelected(selection) {
61
+ var isTableSelected = exports.isTableSelected = function isTableSelected(selection) {
65
62
  if ((0, _isSelectionType.isSelectionType)(selection, 'cell')) {
66
63
  var map = _tableMap.TableMap.get(selection.$anchorCell.node(-1));
67
64
  return isRectSelected({
@@ -72,5 +69,4 @@ var isTableSelected = function isTableSelected(selection) {
72
69
  })(selection);
73
70
  }
74
71
  return false;
75
- };
76
- exports.isTableSelected = isTableSelected;
72
+ };
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.moveColumn = void 0;
7
+ var _state = require("@atlaskit/editor-prosemirror/state");
8
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
7
9
  var _cloneTr = require("./clone-tr");
8
10
  var _find = require("./find");
9
11
  var _getSelectionRangeInColumn = require("./get-selection-range-in-column");
@@ -136,7 +138,7 @@ var _reorderUtils = require("./reorder-utils");
136
138
  // moveColumn(x, y, options)(state.tr)
137
139
  // );
138
140
  // ```
139
- var moveColumn = function moveColumn(originColumnIndex, targetColumnIndex) {
141
+ var moveColumn = exports.moveColumn = function moveColumn(originColumnIndex, targetColumnIndex) {
140
142
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
141
143
  tryToFit: false,
142
144
  direction: 0
@@ -147,6 +149,7 @@ var moveColumn = function moveColumn(originColumnIndex, targetColumnIndex) {
147
149
  if (!table) {
148
150
  return tr;
149
151
  }
152
+ var anchor = tr.selection.anchor;
150
153
  var originalColumnRanges = (0, _getSelectionRangeInColumn.getSelectionRangeInColumn)(originColumnIndex)(tr);
151
154
  var targetColumnRanges = (0, _getSelectionRangeInColumn.getSelectionRangeInColumn)(targetColumnIndex)(tr);
152
155
  var indexesOriginColumn = (_originalColumnRanges = originalColumnRanges === null || originalColumnRanges === void 0 ? void 0 : originalColumnRanges.indexes) !== null && _originalColumnRanges !== void 0 ? _originalColumnRanges : [];
@@ -158,7 +161,12 @@ var moveColumn = function moveColumn(originColumnIndex, targetColumnIndex) {
158
161
  (0, _reorderUtils.isValidReorder)(originColumnIndex, targetColumnIndex, indexesTargetColumn, 'column');
159
162
  }
160
163
  var newTable = (0, _reorderUtils.moveTableColumn)(table, indexesOriginColumn, indexesTargetColumn, options.direction);
161
- return (0, _cloneTr.cloneTr)(tr).replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);
164
+ var newTr = (0, _cloneTr.cloneTr)(tr).replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);
165
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.drag-and-drop')) {
166
+ // Set selection inside a newly created table
167
+ return newTr.setSelection(_state.TextSelection.create(newTr.doc, anchor));
168
+ } else {
169
+ return newTr;
170
+ }
162
171
  };
163
- };
164
- exports.moveColumn = moveColumn;
172
+ };
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.moveRow = void 0;
7
+ var _state = require("@atlaskit/editor-prosemirror/state");
8
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
7
9
  var _cloneTr = require("./clone-tr");
8
10
  var _find = require("./find");
9
11
  var _getSelectionRangeInRow = require("./get-selection-range-in-row");
@@ -151,7 +153,7 @@ var _reorderUtils = require("./reorder-utils");
151
153
  // moveRow(x, y, options)(state.tr)
152
154
  // );
153
155
  // ```
154
- var moveRow = function moveRow(originRowIndex, targetRowIndex) {
156
+ var moveRow = exports.moveRow = function moveRow(originRowIndex, targetRowIndex) {
155
157
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
156
158
  tryToFit: false,
157
159
  direction: 0
@@ -161,6 +163,7 @@ var moveRow = function moveRow(originRowIndex, targetRowIndex) {
161
163
  if (!table) {
162
164
  return tr;
163
165
  }
166
+ var anchor = tr.selection.anchor;
164
167
  var originalRowRanges = (0, _getSelectionRangeInRow.getSelectionRangeInRow)(originRowIndex)(tr);
165
168
  var targetRowRanges = (0, _getSelectionRangeInRow.getSelectionRangeInRow)(targetRowIndex)(tr);
166
169
  var indexesOriginRow = (originalRowRanges === null || originalRowRanges === void 0 ? void 0 : originalRowRanges.indexes) || [];
@@ -172,7 +175,12 @@ var moveRow = function moveRow(originRowIndex, targetRowIndex) {
172
175
  (0, _reorderUtils.isValidReorder)(originRowIndex, targetRowIndex, indexesTargetRow, 'row');
173
176
  }
174
177
  var newTable = (0, _reorderUtils.moveTableRow)(table, indexesOriginRow, indexesTargetRow, options.direction);
175
- return (0, _cloneTr.cloneTr)(tr).replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);
178
+ var newTr = (0, _cloneTr.cloneTr)(tr).replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);
179
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.drag-and-drop')) {
180
+ // Set selection inside a newly created table
181
+ return newTr.setSelection(_state.TextSelection.create(newTr.doc, anchor));
182
+ } else {
183
+ return newTr;
184
+ }
176
185
  };
177
- };
178
- exports.moveRow = moveRow;
186
+ };
@@ -42,7 +42,7 @@ function removeColumn(tr, _ref, columnIndex) {
42
42
  }
43
43
 
44
44
  // Returns a new transaction that removes a column at index `columnIndex`. If there is only one column left, it will remove the entire table.
45
- var removeColumnAt = function removeColumnAt(columnIndex) {
45
+ var removeColumnAt = exports.removeColumnAt = function removeColumnAt(columnIndex) {
46
46
  return function (tr) {
47
47
  var table = (0, _find.findTable)(tr.selection);
48
48
  if (table) {
@@ -63,8 +63,7 @@ var removeColumnAt = function removeColumnAt(columnIndex) {
63
63
  };
64
64
 
65
65
  // Returns a new transaction that removes selected columns.
66
- exports.removeColumnAt = removeColumnAt;
67
- var removeSelectedColumns = function removeSelectedColumns(tr) {
66
+ var removeSelectedColumns = exports.removeSelectedColumns = function removeSelectedColumns(tr) {
68
67
  var selection = tr.selection;
69
68
  if ((0, _isSelected.isTableSelected)(selection)) {
70
69
  return (0, _removeTable.removeTable)(tr);
@@ -97,8 +96,7 @@ var removeSelectedColumns = function removeSelectedColumns(tr) {
97
96
  };
98
97
 
99
98
  // Returns a new transaction that removes a column closest to a given `$pos`.
100
- exports.removeSelectedColumns = removeSelectedColumns;
101
- var removeColumnClosestToPos = function removeColumnClosestToPos($pos) {
99
+ var removeColumnClosestToPos = exports.removeColumnClosestToPos = function removeColumnClosestToPos($pos) {
102
100
  return function (tr) {
103
101
  var rect = (0, _find.findCellRectClosestToPos)($pos);
104
102
  if (rect) {
@@ -106,5 +104,4 @@ var removeColumnClosestToPos = function removeColumnClosestToPos($pos) {
106
104
  }
107
105
  return tr;
108
106
  };
109
- };
110
- exports.removeColumnClosestToPos = removeColumnClosestToPos;
107
+ };
@@ -57,7 +57,7 @@ function removeRow(tr, _ref, rowIndex) {
57
57
  }
58
58
 
59
59
  // Returns a new transaction that removes a row at index `rowIndex`. If there is only one row left, it will remove the entire table.
60
- var removeRowAt = function removeRowAt(rowIndex) {
60
+ var removeRowAt = exports.removeRowAt = function removeRowAt(rowIndex) {
61
61
  return function (tr) {
62
62
  var table = (0, _find.findTable)(tr.selection);
63
63
  if (table) {
@@ -78,8 +78,7 @@ var removeRowAt = function removeRowAt(rowIndex) {
78
78
  };
79
79
 
80
80
  // Returns a new transaction that removes selected rows.
81
- exports.removeRowAt = removeRowAt;
82
- var removeSelectedRows = function removeSelectedRows(tr) {
81
+ var removeSelectedRows = exports.removeSelectedRows = function removeSelectedRows(tr) {
83
82
  var selection = tr.selection;
84
83
  if ((0, _isSelected.isTableSelected)(selection)) {
85
84
  return (0, _removeTable.removeTable)(tr);
@@ -112,8 +111,7 @@ var removeSelectedRows = function removeSelectedRows(tr) {
112
111
  };
113
112
 
114
113
  // Returns a new transaction that removes a row closest to a given `$pos`.
115
- exports.removeSelectedRows = removeSelectedRows;
116
- var removeRowClosestToPos = function removeRowClosestToPos($pos) {
114
+ var removeRowClosestToPos = exports.removeRowClosestToPos = function removeRowClosestToPos($pos) {
117
115
  return function (tr) {
118
116
  var rect = (0, _find.findCellRectClosestToPos)($pos);
119
117
  if (rect) {
@@ -121,5 +119,4 @@ var removeRowClosestToPos = function removeRowClosestToPos($pos) {
121
119
  }
122
120
  return tr;
123
121
  };
124
- };
125
- exports.removeRowClosestToPos = removeRowClosestToPos;
122
+ };
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.removeTable = void 0;
7
7
  var _cloneTr = require("./clone-tr");
8
8
  // Returns a new transaction that removes a table node if the cursor is inside of it.
9
- var removeTable = function removeTable(tr) {
9
+ var removeTable = exports.removeTable = function removeTable(tr) {
10
10
  var $from = tr.selection.$from;
11
11
  for (var depth = $from.depth; depth > 0; depth--) {
12
12
  var node = $from.node(depth);
@@ -15,5 +15,4 @@ var removeTable = function removeTable(tr) {
15
15
  }
16
16
  }
17
17
  return tr;
18
- };
19
- exports.removeTable = removeTable;
18
+ };