@atlaskit/editor-plugin-table 7.5.11 → 7.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.5.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [#82347](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/82347) [`1290405f274b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1290405f274b) - [ux] Updates move util used by move shortcuts and drag menu to cater for new merged cells logic.
8
+ - Updated dependencies
9
+
3
10
  ## 7.5.11
4
11
 
5
12
  ### Patch Changes
@@ -203,9 +203,17 @@ var DragMenu = exports.DragMenu = /*#__PURE__*/_react.default.memo(function (_re
203
203
  var _getPluginState = (0, _pluginFactory.getPluginState)(state),
204
204
  isKeyboardModeActive = _getPluginState.isKeyboardModeActive;
205
205
  var selectionRect = (0, _utils2.isSelectionType)(selection, 'cell') ? (0, _utils2.getSelectionRect)(selection) : (0, _utils2.findCellRectClosestToPos)(selection.$from);
206
- var hasMergedCells = direction === 'row' ? _utils3.hasMergedCellsInRow : _utils3.hasMergedCellsInColumn;
207
- var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
208
- var hasMergedCellsInTable = (0, _utils3.getMergedCellsPositions)(state.tr).length > 0;
206
+ var shouldMoveDisabled;
207
+ var hasMergedCellsInTable;
208
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.drag-move-options-logic-update_fp7xw')) {
209
+ var _tableMap$hasMergedCe;
210
+ shouldMoveDisabled = false;
211
+ hasMergedCellsInTable = (_tableMap$hasMergedCe = tableMap === null || tableMap === void 0 ? void 0 : tableMap.hasMergedCells()) !== null && _tableMap$hasMergedCe !== void 0 ? _tableMap$hasMergedCe : false;
212
+ } else {
213
+ var hasMergedCells = direction === 'row' ? _utils3.hasMergedCellsInRow : _utils3.hasMergedCellsInColumn;
214
+ shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
215
+ hasMergedCellsInTable = (0, _utils3.getMergedCellsPositions)(state.tr).length > 0;
216
+ }
209
217
  var allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
210
218
  var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled);
211
219
  var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig, formatMessage, selectionRect),
@@ -18,6 +18,7 @@ var _layoutThreeEqual = _interopRequireDefault(require("@atlaskit/icon/glyph/edi
18
18
  var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
19
19
  var _chevronDoubleDown = _interopRequireDefault(require("@atlaskit/icon/glyph/hipchat/chevron-double-down"));
20
20
  var _chevronDoubleUp = _interopRequireDefault(require("@atlaskit/icon/glyph/hipchat/chevron-double-up"));
21
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
22
  var _commandsWithAnalytics = require("../commands-with-analytics");
22
23
  var _commandsWithAnalytics2 = require("../pm-plugins/drag-and-drop/commands-with-analytics");
23
24
  var _resizeState = require("../pm-plugins/table-resizing/utils/resize-state");
@@ -40,17 +41,23 @@ var canMove = exports.canMove = function canMove(sourceType, direction, totalIte
40
41
  return false;
41
42
  }
42
43
 
43
- // We can't move column when target has merges with other columns
44
- // We can't move row when target has merges with other rows
44
+ // We can't move column when target has merged cells with other columns
45
+ // We can't move row when target has merged cells with other rows
45
46
  var hasMergedCellsInTarget = isRow ? (0, _mergedCells.hasMergedCellsWithRowNextToRowIndex)(targetIndex, selection) : (0, _mergedCells.hasMergedCellsWithColumnNextToColumnIndex)(targetIndex, selection);
46
47
  if (hasMergedCellsInTarget) {
47
48
  return false;
48
49
  }
49
-
50
- // Currently we can't move in any direction if there are merged cells in the source
51
- var hasMergedCellsInSource = isRow ? (0, _mergedCells.hasMergedCellsInRow)(selectedIndexes)(selection) : (0, _mergedCells.hasMergedCellsInColumn)(selectedIndexes)(selection);
52
- if (hasMergedCellsInSource) {
53
- return false;
50
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.drag-move-options-logic-update_fp7xw')) {
51
+ // We can't move if selection in the source is not a rectangle
52
+ if ((0, _mergedCells.hasMergedCellsInSelection)(selectedIndexes, isRow ? 'row' : 'column')(selection)) {
53
+ return false;
54
+ }
55
+ } else {
56
+ // Currently we can't move in any direction if there are merged cells in the source
57
+ var hasMergedCellsInSource = isRow ? (0, _mergedCells.hasMergedCellsInRow)(selectedIndexes)(selection) : (0, _mergedCells.hasMergedCellsInColumn)(selectedIndexes)(selection);
58
+ if (hasMergedCellsInSource) {
59
+ return false;
60
+ }
54
61
  }
55
62
  return true;
56
63
  };
@@ -192,9 +192,17 @@ export const DragMenu = /*#__PURE__*/React.memo(({
192
192
  isKeyboardModeActive
193
193
  } = getPluginState(state);
194
194
  const selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
195
- const hasMergedCells = direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
196
- const shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
197
- const hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
195
+ let shouldMoveDisabled;
196
+ let hasMergedCellsInTable;
197
+ if (getBooleanFF('platform.editor.table.drag-move-options-logic-update_fp7xw')) {
198
+ var _tableMap$hasMergedCe;
199
+ shouldMoveDisabled = false;
200
+ hasMergedCellsInTable = (_tableMap$hasMergedCe = tableMap === null || tableMap === void 0 ? void 0 : tableMap.hasMergedCells()) !== null && _tableMap$hasMergedCe !== void 0 ? _tableMap$hasMergedCe : false;
201
+ } else {
202
+ const hasMergedCells = direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
203
+ shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
204
+ hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
205
+ }
198
206
  const allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
199
207
  const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled);
200
208
  const {
@@ -10,12 +10,13 @@ import EditorLayoutThreeEqualIcon from '@atlaskit/icon/glyph/editor/layout-three
10
10
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
11
11
  import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-down';
12
12
  import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
13
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
14
  import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, sortColumnWithAnalytics } from '../commands-with-analytics';
14
15
  import { moveSourceWithAnalytics } from '../pm-plugins/drag-and-drop/commands-with-analytics';
15
16
  import { getNewResizeStateFromSelectedColumns } from '../pm-plugins/table-resizing/utils/resize-state';
16
17
  import { getClosestSelectionRect } from '../toolbar';
17
18
  import { AddColLeftIcon, AddColRightIcon, AddRowAboveIcon, AddRowBelowIcon } from '../ui/icons';
18
- import { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsWithColumnNextToColumnIndex, hasMergedCellsWithRowNextToRowIndex } from './merged-cells';
19
+ import { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsInSelection, hasMergedCellsWithColumnNextToColumnIndex, hasMergedCellsWithRowNextToRowIndex } from './merged-cells';
19
20
  import { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
20
21
  export const getTargetIndex = (selectedIndexes, direction) => Math[direction < 0 ? 'min' : 'max'](...selectedIndexes) + direction;
21
22
  export const canMove = (sourceType, direction, totalItemsOfSourceTypeCount, selection, selectionRect) => {
@@ -30,17 +31,23 @@ export const canMove = (sourceType, direction, totalItemsOfSourceTypeCount, sele
30
31
  return false;
31
32
  }
32
33
 
33
- // We can't move column when target has merges with other columns
34
- // We can't move row when target has merges with other rows
34
+ // We can't move column when target has merged cells with other columns
35
+ // We can't move row when target has merged cells with other rows
35
36
  const hasMergedCellsInTarget = isRow ? hasMergedCellsWithRowNextToRowIndex(targetIndex, selection) : hasMergedCellsWithColumnNextToColumnIndex(targetIndex, selection);
36
37
  if (hasMergedCellsInTarget) {
37
38
  return false;
38
39
  }
39
-
40
- // Currently we can't move in any direction if there are merged cells in the source
41
- const hasMergedCellsInSource = isRow ? hasMergedCellsInRow(selectedIndexes)(selection) : hasMergedCellsInColumn(selectedIndexes)(selection);
42
- if (hasMergedCellsInSource) {
43
- return false;
40
+ if (getBooleanFF('platform.editor.table.drag-move-options-logic-update_fp7xw')) {
41
+ // We can't move if selection in the source is not a rectangle
42
+ if (hasMergedCellsInSelection(selectedIndexes, isRow ? 'row' : 'column')(selection)) {
43
+ return false;
44
+ }
45
+ } else {
46
+ // Currently we can't move in any direction if there are merged cells in the source
47
+ const hasMergedCellsInSource = isRow ? hasMergedCellsInRow(selectedIndexes)(selection) : hasMergedCellsInColumn(selectedIndexes)(selection);
48
+ if (hasMergedCellsInSource) {
49
+ return false;
50
+ }
44
51
  }
45
52
  return true;
46
53
  };
@@ -192,9 +192,17 @@ export var DragMenu = /*#__PURE__*/React.memo(function (_ref) {
192
192
  var _getPluginState = getPluginState(state),
193
193
  isKeyboardModeActive = _getPluginState.isKeyboardModeActive;
194
194
  var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
195
- var hasMergedCells = direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
196
- var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
197
- var hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
195
+ var shouldMoveDisabled;
196
+ var hasMergedCellsInTable;
197
+ if (getBooleanFF('platform.editor.table.drag-move-options-logic-update_fp7xw')) {
198
+ var _tableMap$hasMergedCe;
199
+ shouldMoveDisabled = false;
200
+ hasMergedCellsInTable = (_tableMap$hasMergedCe = tableMap === null || tableMap === void 0 ? void 0 : tableMap.hasMergedCells()) !== null && _tableMap$hasMergedCe !== void 0 ? _tableMap$hasMergedCe : false;
201
+ } else {
202
+ var hasMergedCells = direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
203
+ shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
204
+ hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
205
+ }
198
206
  var allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
199
207
  var dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, isTableScalingEnabled);
200
208
  var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig, formatMessage, selectionRect),
@@ -11,12 +11,13 @@ import EditorLayoutThreeEqualIcon from '@atlaskit/icon/glyph/editor/layout-three
11
11
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
12
12
  import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-down';
13
13
  import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
14
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
14
15
  import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, sortColumnWithAnalytics } from '../commands-with-analytics';
15
16
  import { moveSourceWithAnalytics } from '../pm-plugins/drag-and-drop/commands-with-analytics';
16
17
  import { getNewResizeStateFromSelectedColumns } from '../pm-plugins/table-resizing/utils/resize-state';
17
18
  import { getClosestSelectionRect } from '../toolbar';
18
19
  import { AddColLeftIcon, AddColRightIcon, AddRowAboveIcon, AddRowBelowIcon } from '../ui/icons';
19
- import { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsWithColumnNextToColumnIndex, hasMergedCellsWithRowNextToRowIndex } from './merged-cells';
20
+ import { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsInSelection, hasMergedCellsWithColumnNextToColumnIndex, hasMergedCellsWithRowNextToRowIndex } from './merged-cells';
20
21
  import { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
21
22
  export var getTargetIndex = function getTargetIndex(selectedIndexes, direction) {
22
23
  return Math[direction < 0 ? 'min' : 'max'].apply(Math, _toConsumableArray(selectedIndexes)) + direction;
@@ -33,17 +34,23 @@ export var canMove = function canMove(sourceType, direction, totalItemsOfSourceT
33
34
  return false;
34
35
  }
35
36
 
36
- // We can't move column when target has merges with other columns
37
- // We can't move row when target has merges with other rows
37
+ // We can't move column when target has merged cells with other columns
38
+ // We can't move row when target has merged cells with other rows
38
39
  var hasMergedCellsInTarget = isRow ? hasMergedCellsWithRowNextToRowIndex(targetIndex, selection) : hasMergedCellsWithColumnNextToColumnIndex(targetIndex, selection);
39
40
  if (hasMergedCellsInTarget) {
40
41
  return false;
41
42
  }
42
-
43
- // Currently we can't move in any direction if there are merged cells in the source
44
- var hasMergedCellsInSource = isRow ? hasMergedCellsInRow(selectedIndexes)(selection) : hasMergedCellsInColumn(selectedIndexes)(selection);
45
- if (hasMergedCellsInSource) {
46
- return false;
43
+ if (getBooleanFF('platform.editor.table.drag-move-options-logic-update_fp7xw')) {
44
+ // We can't move if selection in the source is not a rectangle
45
+ if (hasMergedCellsInSelection(selectedIndexes, isRow ? 'row' : 'column')(selection)) {
46
+ return false;
47
+ }
48
+ } else {
49
+ // Currently we can't move in any direction if there are merged cells in the source
50
+ var hasMergedCellsInSource = isRow ? hasMergedCellsInRow(selectedIndexes)(selection) : hasMergedCellsInColumn(selectedIndexes)(selection);
51
+ if (hasMergedCellsInSource) {
52
+ return false;
53
+ }
47
54
  }
48
55
  return true;
49
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.5.11",
3
+ "version": "7.5.12",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^35.6.0",
32
32
  "@atlaskit/custom-steps": "^0.0.15",
33
- "@atlaskit/editor-common": "^78.14.0",
33
+ "@atlaskit/editor-common": "^78.15.0",
34
34
  "@atlaskit/editor-palette": "1.5.2",
35
35
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
36
36
  "@atlaskit/editor-plugin-content-insertion": "^1.0.0",
@@ -110,6 +110,9 @@
110
110
  "platform.editor.table.insert-last-column-btn-stays-in-place": {
111
111
  "type": "boolean"
112
112
  },
113
+ "platform.editor.table.drag-move-options-logic-update_fp7xw": {
114
+ "type": "boolean"
115
+ },
113
116
  "platform.editor.resizing-table-height-improvement": {
114
117
  "type": "boolean"
115
118
  },
@@ -292,13 +292,23 @@ export const DragMenu = React.memo(
292
292
  ? getSelectionRect(selection)!
293
293
  : findCellRectClosestToPos(selection.$from);
294
294
 
295
- const hasMergedCells =
296
- direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
295
+ let shouldMoveDisabled;
296
+ let hasMergedCellsInTable;
297
+ if (
298
+ getBooleanFF('platform.editor.table.drag-move-options-logic-update_fp7xw')
299
+ ) {
300
+ shouldMoveDisabled = false;
301
+ hasMergedCellsInTable = tableMap?.hasMergedCells() ?? false;
302
+ } else {
303
+ const hasMergedCells =
304
+ direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
297
305
 
298
- const shouldMoveDisabled =
299
- index !== undefined && hasMergedCells(index)(selection);
306
+ shouldMoveDisabled =
307
+ index !== undefined && hasMergedCells(index)(selection);
308
+
309
+ hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
310
+ }
300
311
 
301
- const hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
302
312
  const allowBackgroundColor = pluginConfig?.allowBackgroundColor ?? false;
303
313
 
304
314
  const dragMenuConfig = getDragMenuConfig(
@@ -37,6 +37,7 @@ import EditorLayoutThreeEqualIcon from '@atlaskit/icon/glyph/editor/layout-three
37
37
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
38
38
  import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-down';
39
39
  import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
40
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
40
41
 
41
42
  import {
42
43
  deleteColumnsWithAnalytics,
@@ -61,6 +62,7 @@ import {
61
62
  import {
62
63
  hasMergedCellsInColumn,
63
64
  hasMergedCellsInRow,
65
+ hasMergedCellsInSelection,
64
66
  hasMergedCellsWithColumnNextToColumnIndex,
65
67
  hasMergedCellsWithRowNextToRowIndex,
66
68
  } from './merged-cells';
@@ -94,8 +96,8 @@ export const canMove = (
94
96
  return false;
95
97
  }
96
98
 
97
- // We can't move column when target has merges with other columns
98
- // We can't move row when target has merges with other rows
99
+ // We can't move column when target has merged cells with other columns
100
+ // We can't move row when target has merged cells with other rows
99
101
  const hasMergedCellsInTarget = isRow
100
102
  ? hasMergedCellsWithRowNextToRowIndex(targetIndex, selection)
101
103
  : hasMergedCellsWithColumnNextToColumnIndex(targetIndex, selection);
@@ -103,12 +105,27 @@ export const canMove = (
103
105
  return false;
104
106
  }
105
107
 
106
- // Currently we can't move in any direction if there are merged cells in the source
107
- const hasMergedCellsInSource = isRow
108
- ? hasMergedCellsInRow(selectedIndexes)(selection)
109
- : hasMergedCellsInColumn(selectedIndexes)(selection);
110
- if (hasMergedCellsInSource) {
111
- return false;
108
+ if (
109
+ getBooleanFF('platform.editor.table.drag-move-options-logic-update_fp7xw')
110
+ ) {
111
+ // We can't move if selection in the source is not a rectangle
112
+ if (
113
+ hasMergedCellsInSelection(
114
+ selectedIndexes,
115
+ isRow ? 'row' : 'column',
116
+ )(selection)
117
+ ) {
118
+ return false;
119
+ }
120
+ } else {
121
+ // Currently we can't move in any direction if there are merged cells in the source
122
+ const hasMergedCellsInSource = isRow
123
+ ? hasMergedCellsInRow(selectedIndexes)(selection)
124
+ : hasMergedCellsInColumn(selectedIndexes)(selection);
125
+
126
+ if (hasMergedCellsInSource) {
127
+ return false;
128
+ }
112
129
  }
113
130
 
114
131
  return true;