@atlaskit/editor-tables 2.3.11 → 2.3.12

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 (38) hide show
  1. package/CHANGELOG.md +6 -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 +2 -3
  22. package/dist/cjs/utils/move-row.js +2 -3
  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/select-nodes.js +49 -1
  34. package/dist/esm/pm-plugins/input.js +1 -1
  35. package/dist/esm/utils/select-nodes.js +49 -1
  36. package/dist/types/utils/select-nodes.d.ts +2 -2
  37. package/dist/types-ts4.5/utils/select-nodes.d.ts +2 -2
  38. package/package.json +7 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-tables
2
2
 
3
+ ## 2.3.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+
3
9
  ## 2.3.11
4
10
 
5
11
  ### 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
+ };
@@ -136,7 +136,7 @@ var _reorderUtils = require("./reorder-utils");
136
136
  // moveColumn(x, y, options)(state.tr)
137
137
  // );
138
138
  // ```
139
- var moveColumn = function moveColumn(originColumnIndex, targetColumnIndex) {
139
+ var moveColumn = exports.moveColumn = function moveColumn(originColumnIndex, targetColumnIndex) {
140
140
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
141
141
  tryToFit: false,
142
142
  direction: 0
@@ -160,5 +160,4 @@ var moveColumn = function moveColumn(originColumnIndex, targetColumnIndex) {
160
160
  var newTable = (0, _reorderUtils.moveTableColumn)(table, indexesOriginColumn, indexesTargetColumn, options.direction);
161
161
  return (0, _cloneTr.cloneTr)(tr).replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);
162
162
  };
163
- };
164
- exports.moveColumn = moveColumn;
163
+ };
@@ -151,7 +151,7 @@ var _reorderUtils = require("./reorder-utils");
151
151
  // moveRow(x, y, options)(state.tr)
152
152
  // );
153
153
  // ```
154
- var moveRow = function moveRow(originRowIndex, targetRowIndex) {
154
+ var moveRow = exports.moveRow = function moveRow(originRowIndex, targetRowIndex) {
155
155
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
156
156
  tryToFit: false,
157
157
  direction: 0
@@ -174,5 +174,4 @@ var moveRow = function moveRow(originRowIndex, targetRowIndex) {
174
174
  var newTable = (0, _reorderUtils.moveTableRow)(table, indexesOriginRow, indexesTargetRow, options.direction);
175
175
  return (0, _cloneTr.cloneTr)(tr).replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);
176
176
  };
177
- };
178
- exports.moveRow = moveRow;
177
+ };
@@ -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
+ };
@@ -33,7 +33,7 @@ var _tableMap = require("../table-map");
33
33
  // ['a3', 'b3', 'c3', 'd3'],
34
34
  // ]
35
35
  // ```
36
- var transpose = function transpose(array) {
36
+ var transpose = exports.transpose = function transpose(array) {
37
37
  return array[0].map(function (_, i) {
38
38
  return array.map(function (column) {
39
39
  return column[i];
@@ -67,8 +67,7 @@ var transpose = function transpose(array) {
67
67
  // |______|______|______|______|
68
68
  // ```
69
69
  //
70
- exports.transpose = transpose;
71
- var convertArrayOfRowsToTableNode = function convertArrayOfRowsToTableNode(tableNode, arrayOfNodes) {
70
+ var convertArrayOfRowsToTableNode = exports.convertArrayOfRowsToTableNode = function convertArrayOfRowsToTableNode(tableNode, arrayOfNodes) {
72
71
  var rowsPM = [];
73
72
  var map = _tableMap.TableMap.get(tableNode);
74
73
  for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
@@ -92,7 +91,6 @@ var convertArrayOfRowsToTableNode = function convertArrayOfRowsToTableNode(table
92
91
  var newTable = tableNode.type.createChecked(tableNode.attrs, rowsPM, tableNode.marks);
93
92
  return newTable;
94
93
  };
95
- exports.convertArrayOfRowsToTableNode = convertArrayOfRowsToTableNode;
96
94
  var moveRowInArrayOfRows = function moveRowInArrayOfRows(arrayOfNodes, indexesOrigin, indexesTarget, directionOverride) {
97
95
  var direction = indexesOrigin[0] > indexesTarget[0] ? -1 : 1;
98
96
  var rowsExtracted = arrayOfNodes.splice(indexesOrigin[0], indexesOrigin.length);
@@ -137,7 +135,7 @@ var moveRowInArrayOfRows = function moveRowInArrayOfRows(arrayOfNodes, indexesOr
137
135
  // [A3. B3, C2, null],
138
136
  // ]
139
137
  // ```
140
- var convertTableNodeToArrayOfRows = function convertTableNodeToArrayOfRows(tableNode) {
138
+ var convertTableNodeToArrayOfRows = exports.convertTableNodeToArrayOfRows = function convertTableNodeToArrayOfRows(tableNode) {
141
139
  var map = _tableMap.TableMap.get(tableNode);
142
140
  var rows = [];
143
141
  for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
@@ -158,21 +156,18 @@ var convertTableNodeToArrayOfRows = function convertTableNodeToArrayOfRows(table
158
156
  }
159
157
  return rows;
160
158
  };
161
- exports.convertTableNodeToArrayOfRows = convertTableNodeToArrayOfRows;
162
- var moveTableRow = function moveTableRow(table, indexesOrigin, indexesTarget, direction) {
159
+ var moveTableRow = exports.moveTableRow = function moveTableRow(table, indexesOrigin, indexesTarget, direction) {
163
160
  var rows = convertTableNodeToArrayOfRows(table.node);
164
161
  rows = moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, direction);
165
162
  return convertArrayOfRowsToTableNode(table.node, rows);
166
163
  };
167
- exports.moveTableRow = moveTableRow;
168
- var moveTableColumn = function moveTableColumn(table, indexesOrigin, indexesTarget, direction) {
164
+ var moveTableColumn = exports.moveTableColumn = function moveTableColumn(table, indexesOrigin, indexesTarget, direction) {
169
165
  var rows = transpose(convertTableNodeToArrayOfRows(table.node));
170
166
  rows = moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, direction);
171
167
  rows = transpose(rows);
172
168
  return convertArrayOfRowsToTableNode(table.node, rows);
173
169
  };
174
- exports.moveTableColumn = moveTableColumn;
175
- var isValidReorder = function isValidReorder(originIndex, targetIndex, targets, type) {
170
+ var isValidReorder = exports.isValidReorder = function isValidReorder(originIndex, targetIndex, targets, type) {
176
171
  var direction = originIndex > targetIndex ? -1 : 1;
177
172
  var errorMessage = "Target position is invalid, you can't move the ".concat(type, " ").concat(originIndex, " to ").concat(targetIndex, ", the target can't be split. You could use tryToFit option.");
178
173
  if (direction === 1) {
@@ -185,5 +180,4 @@ var isValidReorder = function isValidReorder(originIndex, targetIndex, targets,
185
180
  }
186
181
  }
187
182
  return true;
188
- };
189
- exports.isValidReorder = isValidReorder;
183
+ };
@@ -8,7 +8,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
8
8
  var _state = require("@atlaskit/editor-prosemirror/state");
9
9
  var _find = require("./find");
10
10
  var _isSelected = require("./is-selected");
11
- var replaceSelectedTable = function replaceSelectedTable(state, content) {
11
+ var replaceSelectedTable = exports.replaceSelectedTable = function replaceSelectedTable(state, content) {
12
12
  if ((0, _isSelected.isTableSelected)(state.selection)) {
13
13
  var table = (0, _find.findTable)(state.selection);
14
14
  if (table) {
@@ -19,5 +19,4 @@ var replaceSelectedTable = function replaceSelectedTable(state, content) {
19
19
  }
20
20
  }
21
21
  return state.tr;
22
- };
23
- exports.replaceSelectedTable = replaceSelectedTable;
22
+ };
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.selectTableClosestToPos = exports.selectTable = exports.selectRow = exports.selectColumn = void 0;
7
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
7
8
  var _cellSelection = require("../cell-selection");
8
9
  var _tableMap = require("../table-map");
9
10
  var _cloneTr = require("./clone-tr");
@@ -13,6 +14,8 @@ var select = function select(type) {
13
14
  return function (tr) {
14
15
  var table = (0, _find.findTable)(tr.selection);
15
16
  var isRowSelection = type === 'row';
17
+ var prevSelection = tr.selection;
18
+ var isPrevRowSelection = !!prevSelection.$anchorCell && !!prevSelection.$headCell;
16
19
  if (table) {
17
20
  var map = _tableMap.TableMap.get(table.node);
18
21
 
@@ -22,6 +25,7 @@ var select = function select(type) {
22
25
  var top = isRowSelection ? index : 0;
23
26
  var right = isRowSelection ? map.width : index + 1;
24
27
  var bottom = isRowSelection ? index + 1 : map.height;
28
+ var cellsInFirstRow = [];
25
29
  if (expand) {
26
30
  var cell = (0, _find.findCellClosestToPos)(tr.selection.$from);
27
31
  if (!cell) {
@@ -31,12 +35,56 @@ var select = function select(type) {
31
35
  if (isRowSelection) {
32
36
  top = Math.min(top, selRect.top);
33
37
  bottom = Math.max(bottom, selRect.bottom);
38
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-shift-click-selection-backward')) {
39
+ cellsInFirstRow = map.cellsInRect({
40
+ left: left,
41
+ top: top,
42
+ right: right,
43
+ bottom: top + 1
44
+ });
45
+ var targetRowCells = map.cellsInRect({
46
+ left: left,
47
+ top: index,
48
+ right: right,
49
+ bottom: index + 1
50
+ });
51
+ var isBackwardSelection = targetRowCells[0] < prevSelection.$head.pos;
52
+ if (isBackwardSelection && isPrevRowSelection) {
53
+ var _head = table.start + cellsInFirstRow[0];
54
+ var _anchor = prevSelection.$anchorCell.pos;
55
+ var _$head = tr.doc.resolve(_head);
56
+ var _$anchor = tr.doc.resolve(_anchor);
57
+ return (0, _cloneTr.cloneTr)(tr.setSelection(new _cellSelection.CellSelection(_$anchor, _$head)));
58
+ }
59
+ }
34
60
  } else {
35
61
  left = Math.min(left, selRect.left);
36
62
  right = Math.max(right, selRect.right);
63
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-shift-click-selection-backward')) {
64
+ cellsInFirstRow = map.cellsInRect({
65
+ left: left,
66
+ top: top,
67
+ right: left + 1,
68
+ bottom: bottom
69
+ });
70
+ var _targetRowCells = map.cellsInRect({
71
+ left: index,
72
+ top: top,
73
+ right: index + 1,
74
+ bottom: bottom
75
+ });
76
+ var _isBackwardSelection = _targetRowCells[0] < prevSelection.$head.pos;
77
+ if (_isBackwardSelection && isPrevRowSelection) {
78
+ var _head2 = table.start + cellsInFirstRow[0];
79
+ var _anchor2 = prevSelection.$anchorCell.pos;
80
+ var _$head2 = tr.doc.resolve(_head2);
81
+ var _$anchor2 = tr.doc.resolve(_anchor2);
82
+ return (0, _cloneTr.cloneTr)(tr.setSelection(new _cellSelection.CellSelection(_$anchor2, _$head2)));
83
+ }
84
+ }
37
85
  }
38
86
  }
39
- var cellsInFirstRow = map.cellsInRect({
87
+ cellsInFirstRow = map.cellsInRect({
40
88
  left: left,
41
89
  top: top,
42
90
  right: isRowSelection ? right : left + 1,
@@ -62,16 +110,14 @@ var select = function select(type) {
62
110
 
63
111
  // Returns a new transaction that selects a column at index `columnIndex`.
64
112
  // Use the optional `expand` param to extend from current selection.
65
- var selectColumn = select('column');
113
+ var selectColumn = exports.selectColumn = select('column');
66
114
 
67
115
  // Returns a new transaction that selects a row at index `rowIndex`.
68
116
  // Use the optional `expand` param to extend from current selection.
69
- exports.selectColumn = selectColumn;
70
- var selectRow = select('row');
117
+ var selectRow = exports.selectRow = select('row');
71
118
 
72
119
  // Returns a new transaction that selects a table.
73
- exports.selectRow = selectRow;
74
- var selectTable = function selectTable(tr) {
120
+ var selectTable = exports.selectTable = function selectTable(tr) {
75
121
  var table = (0, _find.findTable)(tr.selection);
76
122
  if (table) {
77
123
  var _TableMap$get = _tableMap.TableMap.get(table.node),
@@ -86,8 +132,7 @@ var selectTable = function selectTable(tr) {
86
132
  }
87
133
  return tr;
88
134
  };
89
- exports.selectTable = selectTable;
90
- var selectTableClosestToPos = function selectTableClosestToPos(tr, $pos) {
135
+ var selectTableClosestToPos = exports.selectTableClosestToPos = function selectTableClosestToPos(tr, $pos) {
91
136
  var table = (0, _find.findTableClosestToPos)($pos);
92
137
  if (table) {
93
138
  var _TableMap$get2 = _tableMap.TableMap.get(table.node),
@@ -101,5 +146,4 @@ var selectTableClosestToPos = function selectTableClosestToPos(tr, $pos) {
101
146
  }
102
147
  }
103
148
  return tr;
104
- };
105
- exports.selectTableClosestToPos = selectTableClosestToPos;
149
+ };
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.setCellAttrs = void 0;
7
7
  var _cloneTr = require("./clone-tr");
8
8
  // Returns a new transaction that sets given `attrs` to a given `cell`.
9
- var setCellAttrs = function setCellAttrs(cell, attrs) {
9
+ var setCellAttrs = exports.setCellAttrs = function setCellAttrs(cell, attrs) {
10
10
  return function (tr) {
11
11
  if (cell) {
12
12
  tr.setNodeMarkup(cell.pos, undefined, Object.assign({}, cell.node.attrs, attrs));
@@ -14,5 +14,4 @@ var setCellAttrs = function setCellAttrs(cell, attrs) {
14
14
  }
15
15
  return tr;
16
16
  };
17
- };
18
- exports.setCellAttrs = setCellAttrs;
17
+ };
@@ -8,11 +8,10 @@ var _splitCellWithType = require("./split-cell-with-type");
8
8
  var _tableNodeTypes = require("./table-node-types");
9
9
  // Split a selected cell, whose rowpan or colspan is greater than one,
10
10
  // into smaller cells. Use the first cell type for the new cells.
11
- var splitCell = function splitCell(state, dispatch) {
11
+ var splitCell = exports.splitCell = function splitCell(state, dispatch) {
12
12
  var nodeTypes = (0, _tableNodeTypes.tableNodeTypes)(state.schema);
13
13
  return (0, _splitCellWithType.splitCellWithType)(function (_ref) {
14
14
  var node = _ref.node;
15
15
  return nodeTypes[node.type.spec.tableRole];
16
16
  })(state, dispatch);
17
- };
18
- exports.splitCell = splitCell;
17
+ };
@@ -10,7 +10,7 @@ var _selectionRect = require("./selection-rect");
10
10
  var _tables = require("./tables");
11
11
  // :: (EditorState, dispatch: ?(tr: Transaction)) → bool
12
12
  // Add a table row before the selection.
13
- var addRowBefore = function addRowBefore(state, dispatch) {
13
+ var addRowBefore = exports.addRowBefore = function addRowBefore(state, dispatch) {
14
14
  if (!(0, _tables.isInTable)(state)) {
15
15
  return false;
16
16
  }
@@ -23,8 +23,7 @@ var addRowBefore = function addRowBefore(state, dispatch) {
23
23
 
24
24
  // :: (EditorState, dispatch: ?(tr: Transaction)) → bool
25
25
  // Add a table row after the selection.
26
- exports.addRowBefore = addRowBefore;
27
- var addRowAfter = function addRowAfter(state, dispatch) {
26
+ var addRowAfter = exports.addRowAfter = function addRowAfter(state, dispatch) {
28
27
  if (!(0, _tables.isInTable)(state)) {
29
28
  return false;
30
29
  }
@@ -37,8 +36,7 @@ var addRowAfter = function addRowAfter(state, dispatch) {
37
36
 
38
37
  // :: (EditorState, dispatch: ?(tr: Transaction)) → bool
39
38
  // Command to add a column before the column with the selection.
40
- exports.addRowAfter = addRowAfter;
41
- var addColumnBefore = function addColumnBefore(state, dispatch) {
39
+ var addColumnBefore = exports.addColumnBefore = function addColumnBefore(state, dispatch) {
42
40
  if (!(0, _tables.isInTable)(state)) {
43
41
  return false;
44
42
  }
@@ -51,8 +49,7 @@ var addColumnBefore = function addColumnBefore(state, dispatch) {
51
49
 
52
50
  // :: (EditorState, dispatch: ?(tr: Transaction)) → bool
53
51
  // Command to add a column after the column with the selection.
54
- exports.addColumnBefore = addColumnBefore;
55
- var addColumnAfter = function addColumnAfter(state, dispatch) {
52
+ var addColumnAfter = exports.addColumnAfter = function addColumnAfter(state, dispatch) {
56
53
  if (!(0, _tables.isInTable)(state)) {
57
54
  return false;
58
55
  }
@@ -61,5 +58,4 @@ var addColumnAfter = function addColumnAfter(state, dispatch) {
61
58
  dispatch((0, _addColumn.addColumn)(state.tr, rect, rect.right));
62
59
  }
63
60
  return true;
64
- };
65
- exports.addColumnAfter = addColumnAfter;
61
+ };
@@ -10,21 +10,20 @@ exports.uuid = exports.generateUuid = void 0;
10
10
  */
11
11
 
12
12
  /* eslint-disable no-bitwise */
13
- var generateUuid = function generateUuid() {
13
+ var generateUuid = exports.generateUuid = function generateUuid() {
14
14
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
15
15
  var r = Math.random() * 16 | 0;
16
16
  return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
17
17
  });
18
18
  };
19
19
  /* eslint-enable no-bitwise */
20
- exports.generateUuid = generateUuid;
20
+
21
21
  var staticValue = false;
22
- var uuid = {
22
+ var uuid = exports.uuid = {
23
23
  setStatic: function setStatic(value) {
24
24
  staticValue = value;
25
25
  },
26
26
  generate: function generate() {
27
27
  return staticValue || generateUuid();
28
28
  }
29
- };
30
- exports.uuid = uuid;
29
+ };
@@ -1,3 +1,4 @@
1
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
1
2
  import { CellSelection } from '../cell-selection';
2
3
  import { TableMap } from '../table-map';
3
4
  import { cloneTr } from './clone-tr';
@@ -5,6 +6,8 @@ import { findCellClosestToPos, findTable, findTableClosestToPos } from './find';
5
6
  const select = type => (index, expand) => tr => {
6
7
  const table = findTable(tr.selection);
7
8
  const isRowSelection = type === 'row';
9
+ const prevSelection = tr.selection;
10
+ const isPrevRowSelection = !!prevSelection.$anchorCell && !!prevSelection.$headCell;
8
11
  if (table) {
9
12
  const map = TableMap.get(table.node);
10
13
 
@@ -14,6 +17,7 @@ const select = type => (index, expand) => tr => {
14
17
  let top = isRowSelection ? index : 0;
15
18
  let right = isRowSelection ? map.width : index + 1;
16
19
  let bottom = isRowSelection ? index + 1 : map.height;
20
+ let cellsInFirstRow = [];
17
21
  if (expand) {
18
22
  const cell = findCellClosestToPos(tr.selection.$from);
19
23
  if (!cell) {
@@ -23,12 +27,56 @@ const select = type => (index, expand) => tr => {
23
27
  if (isRowSelection) {
24
28
  top = Math.min(top, selRect.top);
25
29
  bottom = Math.max(bottom, selRect.bottom);
30
+ if (getBooleanFF('platform.editor.table-shift-click-selection-backward')) {
31
+ cellsInFirstRow = map.cellsInRect({
32
+ left,
33
+ top,
34
+ right,
35
+ bottom: top + 1
36
+ });
37
+ const targetRowCells = map.cellsInRect({
38
+ left,
39
+ top: index,
40
+ right,
41
+ bottom: index + 1
42
+ });
43
+ const isBackwardSelection = targetRowCells[0] < prevSelection.$head.pos;
44
+ if (isBackwardSelection && isPrevRowSelection) {
45
+ const head = table.start + cellsInFirstRow[0];
46
+ const anchor = prevSelection.$anchorCell.pos;
47
+ const $head = tr.doc.resolve(head);
48
+ const $anchor = tr.doc.resolve(anchor);
49
+ return cloneTr(tr.setSelection(new CellSelection($anchor, $head)));
50
+ }
51
+ }
26
52
  } else {
27
53
  left = Math.min(left, selRect.left);
28
54
  right = Math.max(right, selRect.right);
55
+ if (getBooleanFF('platform.editor.table-shift-click-selection-backward')) {
56
+ cellsInFirstRow = map.cellsInRect({
57
+ left,
58
+ top,
59
+ right: left + 1,
60
+ bottom
61
+ });
62
+ const targetRowCells = map.cellsInRect({
63
+ left: index,
64
+ top,
65
+ right: index + 1,
66
+ bottom
67
+ });
68
+ const isBackwardSelection = targetRowCells[0] < prevSelection.$head.pos;
69
+ if (isBackwardSelection && isPrevRowSelection) {
70
+ const head = table.start + cellsInFirstRow[0];
71
+ const anchor = prevSelection.$anchorCell.pos;
72
+ const $head = tr.doc.resolve(head);
73
+ const $anchor = tr.doc.resolve(anchor);
74
+ return cloneTr(tr.setSelection(new CellSelection($anchor, $head)));
75
+ }
76
+ }
29
77
  }
30
78
  }
31
- const cellsInFirstRow = map.cellsInRect({
79
+ cellsInFirstRow = map.cellsInRect({
32
80
  left,
33
81
  top,
34
82
  right: isRowSelection ? right : left + 1,
@@ -79,7 +79,7 @@ function shiftArrow(axis, dir) {
79
79
  var maybeTableCell = _$head.blockRange($anchor);
80
80
 
81
81
  // Make sure the selection is coming from the same cell
82
- 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) || '');
82
+ 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) || '');
83
83
  if (!sameCell) {
84
84
  return false;
85
85
  }
@@ -1,3 +1,4 @@
1
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
1
2
  import { CellSelection } from '../cell-selection';
2
3
  import { TableMap } from '../table-map';
3
4
  import { cloneTr } from './clone-tr';
@@ -7,6 +8,8 @@ var select = function select(type) {
7
8
  return function (tr) {
8
9
  var table = findTable(tr.selection);
9
10
  var isRowSelection = type === 'row';
11
+ var prevSelection = tr.selection;
12
+ var isPrevRowSelection = !!prevSelection.$anchorCell && !!prevSelection.$headCell;
10
13
  if (table) {
11
14
  var map = TableMap.get(table.node);
12
15
 
@@ -16,6 +19,7 @@ var select = function select(type) {
16
19
  var top = isRowSelection ? index : 0;
17
20
  var right = isRowSelection ? map.width : index + 1;
18
21
  var bottom = isRowSelection ? index + 1 : map.height;
22
+ var cellsInFirstRow = [];
19
23
  if (expand) {
20
24
  var cell = findCellClosestToPos(tr.selection.$from);
21
25
  if (!cell) {
@@ -25,12 +29,56 @@ var select = function select(type) {
25
29
  if (isRowSelection) {
26
30
  top = Math.min(top, selRect.top);
27
31
  bottom = Math.max(bottom, selRect.bottom);
32
+ if (getBooleanFF('platform.editor.table-shift-click-selection-backward')) {
33
+ cellsInFirstRow = map.cellsInRect({
34
+ left: left,
35
+ top: top,
36
+ right: right,
37
+ bottom: top + 1
38
+ });
39
+ var targetRowCells = map.cellsInRect({
40
+ left: left,
41
+ top: index,
42
+ right: right,
43
+ bottom: index + 1
44
+ });
45
+ var isBackwardSelection = targetRowCells[0] < prevSelection.$head.pos;
46
+ if (isBackwardSelection && isPrevRowSelection) {
47
+ var _head = table.start + cellsInFirstRow[0];
48
+ var _anchor = prevSelection.$anchorCell.pos;
49
+ var _$head = tr.doc.resolve(_head);
50
+ var _$anchor = tr.doc.resolve(_anchor);
51
+ return cloneTr(tr.setSelection(new CellSelection(_$anchor, _$head)));
52
+ }
53
+ }
28
54
  } else {
29
55
  left = Math.min(left, selRect.left);
30
56
  right = Math.max(right, selRect.right);
57
+ if (getBooleanFF('platform.editor.table-shift-click-selection-backward')) {
58
+ cellsInFirstRow = map.cellsInRect({
59
+ left: left,
60
+ top: top,
61
+ right: left + 1,
62
+ bottom: bottom
63
+ });
64
+ var _targetRowCells = map.cellsInRect({
65
+ left: index,
66
+ top: top,
67
+ right: index + 1,
68
+ bottom: bottom
69
+ });
70
+ var _isBackwardSelection = _targetRowCells[0] < prevSelection.$head.pos;
71
+ if (_isBackwardSelection && isPrevRowSelection) {
72
+ var _head2 = table.start + cellsInFirstRow[0];
73
+ var _anchor2 = prevSelection.$anchorCell.pos;
74
+ var _$head2 = tr.doc.resolve(_head2);
75
+ var _$anchor2 = tr.doc.resolve(_anchor2);
76
+ return cloneTr(tr.setSelection(new CellSelection(_$anchor2, _$head2)));
77
+ }
78
+ }
31
79
  }
32
80
  }
33
- var cellsInFirstRow = map.cellsInRect({
81
+ cellsInFirstRow = map.cellsInRect({
34
82
  left: left,
35
83
  top: top,
36
84
  right: isRowSelection ? right : left + 1,
@@ -1,5 +1,5 @@
1
- import { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
1
+ import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  export declare const selectColumn: (index: number, expand?: boolean) => (tr: Transaction) => Transaction;
4
4
  export declare const selectRow: (index: number, expand?: boolean) => (tr: Transaction) => Transaction;
5
5
  export declare const selectTable: (tr: Transaction) => Transaction;
@@ -1,5 +1,5 @@
1
- import { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
1
+ import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  export declare const selectColumn: (index: number, expand?: boolean) => (tr: Transaction) => Transaction;
4
4
  export declare const selectRow: (index: number, expand?: boolean) => (tr: Transaction) => Transaction;
5
5
  export declare const selectTable: (tr: Transaction) => Transaction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-tables",
3
- "version": "2.3.11",
3
+ "version": "2.3.12",
4
4
  "description": "A package that contains common classes and utility functions for editor tables",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -34,7 +34,8 @@
34
34
  "@babel/runtime": "^7.0.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1"
37
+ "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
38
+ "@atlassian/feature-flags-test-utils": "^0.1.2"
38
39
  },
39
40
  "techstack": {
40
41
  "@atlassian/frontend": {
@@ -57,6 +58,9 @@
57
58
  "platform-feature-flags": {
58
59
  "platform.editor.custom-table-width": {
59
60
  "type": "boolean"
61
+ },
62
+ "platform.editor.table-shift-click-selection-backward": {
63
+ "type": "boolean"
60
64
  }
61
65
  }
62
- }
66
+ }