@atlaskit/editor-plugin-table 7.5.10 → 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,19 @@
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
+
10
+ ## 7.5.11
11
+
12
+ ### Patch Changes
13
+
14
+ - [#82119](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/82119) [`0358b8d41041`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0358b8d41041) - insert table at full width via shortcut in full width page
15
+ - Updated dependencies
16
+
3
17
  ## 7.5.10
4
18
 
5
19
  ### Patch Changes
@@ -157,8 +157,10 @@ var tablesPlugin = function tablesPlugin(_ref) {
157
157
  var _ref6 = options || {},
158
158
  dragAndDropEnabled = _ref6.dragAndDropEnabled,
159
159
  _ref6$isTableScalingE = _ref6.isTableScalingEnabled,
160
- isTableScalingEnabled = _ref6$isTableScalingE === void 0 ? false : _ref6$isTableScalingE;
161
- return (0, _keymap.keymapPlugin)(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled);
160
+ isTableScalingEnabled = _ref6$isTableScalingE === void 0 ? false : _ref6$isTableScalingE,
161
+ _ref6$fullWidthEnable = _ref6.fullWidthEnabled,
162
+ fullWidthEnabled = _ref6$fullWidthEnable === void 0 ? false : _ref6$fullWidthEnable;
163
+ return (0, _keymap.keymapPlugin)(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, fullWidthEnabled);
162
164
  }
163
165
  }, {
164
166
  name: 'tableSelectionKeymap',
@@ -16,7 +16,7 @@ var _columnResize = require("../commands/column-resize");
16
16
  var _insert = require("../commands/insert");
17
17
  var _commandsWithAnalytics2 = require("../pm-plugins/drag-and-drop/commands-with-analytics");
18
18
  var _analytics2 = require("../utils/analytics");
19
- var createTableWithAnalytics = function createTableWithAnalytics(editorAnalyticsAPI) {
19
+ var createTableWithAnalytics = function createTableWithAnalytics(isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) {
20
20
  return (0, _analytics2.withEditorAnalyticsAPI)({
21
21
  action: _analytics.ACTION.INSERTED,
22
22
  actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
@@ -25,14 +25,15 @@ var createTableWithAnalytics = function createTableWithAnalytics(editorAnalytics
25
25
  inputMethod: _analytics.INPUT_METHOD.SHORTCUT
26
26
  },
27
27
  eventType: _analytics.EVENT_TYPE.TRACK
28
- })(editorAnalyticsAPI)((0, _commands2.createTable)());
28
+ })(editorAnalyticsAPI)((0, _commands2.createTable)(isTableScalingEnabled, isFullWidthModeEnabled));
29
29
  };
30
30
  function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled) {
31
31
  var isTableScalingEnabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
32
+ var isFullWidthEnabled = arguments.length > 4 ? arguments[4] : undefined;
32
33
  var list = {};
33
34
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.nextCell.common, (0, _commands2.goToNextCell)(editorAnalyticsAPI)(1), list);
34
35
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.previousCell.common, (0, _commands2.goToNextCell)(editorAnalyticsAPI)(-1), list);
35
- (0, _keymaps.bindKeymapWithCommand)(_keymaps.toggleTable.common, createTableWithAnalytics(editorAnalyticsAPI), list);
36
+ (0, _keymaps.bindKeymapWithCommand)(_keymaps.toggleTable.common, createTableWithAnalytics(isTableScalingEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
36
37
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.backspace.common, (0, _commands.chainCommands)((0, _commandsWithAnalytics.deleteTableIfSelectedWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.KEYBOARD), (0, _commandsWithAnalytics.emptyMultipleCellsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.KEYBOARD)), list);
37
38
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.backspace.common, _commands2.moveCursorBackward, list);
38
39
 
@@ -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),
@@ -14,7 +14,8 @@ var DragHandleDisabledIcon = exports.DragHandleDisabledIcon = function DragHandl
14
14
  viewBox: "0 0 24 16",
15
15
  fill: "none",
16
16
  xmlns: "http://www.w3.org/2000/svg",
17
- style: style
17
+ style: style,
18
+ "data-testid": "drag-icon-disabled"
18
19
  }, /*#__PURE__*/_react.default.createElement("rect", {
19
20
  width: "24",
20
21
  height: "16",
@@ -11,7 +11,8 @@ var DragHandleIcon = exports.DragHandleIcon = function DragHandleIcon() {
11
11
  xmlns: "http://www.w3.org/2000/svg",
12
12
  width: "24",
13
13
  height: "16",
14
- fill: "none"
14
+ fill: "none",
15
+ "data-testid": "drag-icon-enabled"
15
16
  }, /*#__PURE__*/_react.default.createElement("rect", {
16
17
  width: "24",
17
18
  height: "16",
@@ -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
  };
@@ -149,9 +149,10 @@ const tablesPlugin = ({
149
149
  plugin: () => {
150
150
  const {
151
151
  dragAndDropEnabled,
152
- isTableScalingEnabled = false
152
+ isTableScalingEnabled = false,
153
+ fullWidthEnabled = false
153
154
  } = options || {};
154
- return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled);
155
+ return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, fullWidthEnabled);
155
156
  }
156
157
  }, {
157
158
  name: 'tableSelectionKeymap',
@@ -9,7 +9,7 @@ import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardCol
9
9
  import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand } from '../commands/insert';
10
10
  import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
11
11
  import { withEditorAnalyticsAPI } from '../utils/analytics';
12
- const createTableWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsAPI({
12
+ const createTableWithAnalytics = (isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) => withEditorAnalyticsAPI({
13
13
  action: ACTION.INSERTED,
14
14
  actionSubject: ACTION_SUBJECT.DOCUMENT,
15
15
  actionSubjectId: ACTION_SUBJECT_ID.TABLE,
@@ -17,12 +17,12 @@ const createTableWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsAPI({
17
17
  inputMethod: INPUT_METHOD.SHORTCUT
18
18
  },
19
19
  eventType: EVENT_TYPE.TRACK
20
- })(editorAnalyticsAPI)(createTable());
21
- export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false) {
20
+ })(editorAnalyticsAPI)(createTable(isTableScalingEnabled, isFullWidthModeEnabled));
21
+ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false, isFullWidthEnabled) {
22
22
  const list = {};
23
23
  bindKeymapWithCommand(nextCell.common, goToNextCell(editorAnalyticsAPI)(1), list);
24
24
  bindKeymapWithCommand(previousCell.common, goToNextCell(editorAnalyticsAPI)(-1), list);
25
- bindKeymapWithCommand(toggleTable.common, createTableWithAnalytics(editorAnalyticsAPI), list);
25
+ bindKeymapWithCommand(toggleTable.common, createTableWithAnalytics(isTableScalingEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
26
26
  bindKeymapWithCommand(backspace.common, chainCommands(deleteTableIfSelectedWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)), list);
27
27
  bindKeymapWithCommand(backspace.common, moveCursorBackward, list);
28
28
 
@@ -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 {
@@ -7,7 +7,8 @@ export const DragHandleDisabledIcon = ({
7
7
  viewBox: "0 0 24 16",
8
8
  fill: "none",
9
9
  xmlns: "http://www.w3.org/2000/svg",
10
- style: style
10
+ style: style,
11
+ "data-testid": "drag-icon-disabled"
11
12
  }, /*#__PURE__*/React.createElement("rect", {
12
13
  width: "24",
13
14
  height: "16",
@@ -3,7 +3,8 @@ export const DragHandleIcon = () => /*#__PURE__*/React.createElement("svg", {
3
3
  xmlns: "http://www.w3.org/2000/svg",
4
4
  width: "24",
5
5
  height: "16",
6
- fill: "none"
6
+ fill: "none",
7
+ "data-testid": "drag-icon-enabled"
7
8
  }, /*#__PURE__*/React.createElement("rect", {
8
9
  width: "24",
9
10
  height: "16",
@@ -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
  };
@@ -150,8 +150,10 @@ var tablesPlugin = function tablesPlugin(_ref) {
150
150
  var _ref6 = options || {},
151
151
  dragAndDropEnabled = _ref6.dragAndDropEnabled,
152
152
  _ref6$isTableScalingE = _ref6.isTableScalingEnabled,
153
- isTableScalingEnabled = _ref6$isTableScalingE === void 0 ? false : _ref6$isTableScalingE;
154
- return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled);
153
+ isTableScalingEnabled = _ref6$isTableScalingE === void 0 ? false : _ref6$isTableScalingE,
154
+ _ref6$fullWidthEnable = _ref6.fullWidthEnabled,
155
+ fullWidthEnabled = _ref6$fullWidthEnable === void 0 ? false : _ref6$fullWidthEnable;
156
+ return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled, fullWidthEnabled);
155
157
  }
156
158
  }, {
157
159
  name: 'tableSelectionKeymap',
@@ -9,7 +9,7 @@ import { activateNextResizeArea, initiateKeyboardColumnResizing, stopKeyboardCol
9
9
  import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand } from '../commands/insert';
10
10
  import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
11
11
  import { withEditorAnalyticsAPI } from '../utils/analytics';
12
- var createTableWithAnalytics = function createTableWithAnalytics(editorAnalyticsAPI) {
12
+ var createTableWithAnalytics = function createTableWithAnalytics(isTableScalingEnabled, isFullWidthModeEnabled, editorAnalyticsAPI) {
13
13
  return withEditorAnalyticsAPI({
14
14
  action: ACTION.INSERTED,
15
15
  actionSubject: ACTION_SUBJECT.DOCUMENT,
@@ -18,14 +18,15 @@ var createTableWithAnalytics = function createTableWithAnalytics(editorAnalytics
18
18
  inputMethod: INPUT_METHOD.SHORTCUT
19
19
  },
20
20
  eventType: EVENT_TYPE.TRACK
21
- })(editorAnalyticsAPI)(createTable());
21
+ })(editorAnalyticsAPI)(createTable(isTableScalingEnabled, isFullWidthModeEnabled));
22
22
  };
23
23
  export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled) {
24
24
  var isTableScalingEnabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
25
+ var isFullWidthEnabled = arguments.length > 4 ? arguments[4] : undefined;
25
26
  var list = {};
26
27
  bindKeymapWithCommand(nextCell.common, goToNextCell(editorAnalyticsAPI)(1), list);
27
28
  bindKeymapWithCommand(previousCell.common, goToNextCell(editorAnalyticsAPI)(-1), list);
28
- bindKeymapWithCommand(toggleTable.common, createTableWithAnalytics(editorAnalyticsAPI), list);
29
+ bindKeymapWithCommand(toggleTable.common, createTableWithAnalytics(isTableScalingEnabled, !!isFullWidthEnabled, editorAnalyticsAPI), list);
29
30
  bindKeymapWithCommand(backspace.common, chainCommands(deleteTableIfSelectedWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)), list);
30
31
  bindKeymapWithCommand(backspace.common, moveCursorBackward, list);
31
32
 
@@ -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),
@@ -7,7 +7,8 @@ export var DragHandleDisabledIcon = function DragHandleDisabledIcon(_ref) {
7
7
  viewBox: "0 0 24 16",
8
8
  fill: "none",
9
9
  xmlns: "http://www.w3.org/2000/svg",
10
- style: style
10
+ style: style,
11
+ "data-testid": "drag-icon-disabled"
11
12
  }, /*#__PURE__*/React.createElement("rect", {
12
13
  width: "24",
13
14
  height: "16",
@@ -4,7 +4,8 @@ export var DragHandleIcon = function DragHandleIcon() {
4
4
  xmlns: "http://www.w3.org/2000/svg",
5
5
  width: "24",
6
6
  height: "16",
7
- fill: "none"
7
+ fill: "none",
8
+ "data-testid": "drag-icon-enabled"
8
9
  }, /*#__PURE__*/React.createElement("rect", {
9
10
  width: "24",
10
11
  height: "16",
@@ -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
  };
@@ -1,5 +1,5 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
4
- export declare function keymapPlugin(getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, dragAndDropEnabled?: boolean, isTableScalingEnabled?: boolean): SafePlugin;
4
+ export declare function keymapPlugin(getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, dragAndDropEnabled?: boolean, isTableScalingEnabled?: boolean, isFullWidthEnabled?: boolean): SafePlugin;
5
5
  export default keymapPlugin;
@@ -1,5 +1,5 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
4
- export declare function keymapPlugin(getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, dragAndDropEnabled?: boolean, isTableScalingEnabled?: boolean): SafePlugin;
4
+ export declare function keymapPlugin(getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, dragAndDropEnabled?: boolean, isTableScalingEnabled?: boolean, isFullWidthEnabled?: boolean): SafePlugin;
5
5
  export default keymapPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.5.10",
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",
@@ -46,7 +46,7 @@
46
46
  "@atlaskit/pragmatic-drag-and-drop": "^1.0.0",
47
47
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.0.0",
48
48
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
49
- "@atlaskit/primitives": "^4.1.0",
49
+ "@atlaskit/primitives": "^5.0.0",
50
50
  "@atlaskit/theme": "^12.6.0",
51
51
  "@atlaskit/toggle": "^13.0.0",
52
52
  "@atlaskit/tokens": "^1.41.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
  },
package/src/plugin.tsx CHANGED
@@ -266,14 +266,17 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
266
266
  {
267
267
  name: 'tableKeymap',
268
268
  plugin: () => {
269
- const { dragAndDropEnabled, isTableScalingEnabled = false } =
270
- options || ({} as TablePluginOptions);
271
-
269
+ const {
270
+ dragAndDropEnabled,
271
+ isTableScalingEnabled = false,
272
+ fullWidthEnabled = false,
273
+ } = options || ({} as TablePluginOptions);
272
274
  return keymapPlugin(
273
275
  defaultGetEditorContainerWidth,
274
276
  editorAnalyticsAPI,
275
277
  dragAndDropEnabled,
276
278
  isTableScalingEnabled,
279
+ fullWidthEnabled,
277
280
  );
278
281
  },
279
282
  },
@@ -56,6 +56,8 @@ import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/
56
56
  import { withEditorAnalyticsAPI } from '../utils/analytics';
57
57
 
58
58
  const createTableWithAnalytics = (
59
+ isTableScalingEnabled: boolean,
60
+ isFullWidthModeEnabled: boolean,
59
61
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
60
62
  ) =>
61
63
  withEditorAnalyticsAPI({
@@ -64,13 +66,16 @@ const createTableWithAnalytics = (
64
66
  actionSubjectId: ACTION_SUBJECT_ID.TABLE,
65
67
  attributes: { inputMethod: INPUT_METHOD.SHORTCUT },
66
68
  eventType: EVENT_TYPE.TRACK,
67
- })(editorAnalyticsAPI)(createTable());
69
+ })(editorAnalyticsAPI)(
70
+ createTable(isTableScalingEnabled, isFullWidthModeEnabled),
71
+ );
68
72
 
69
73
  export function keymapPlugin(
70
74
  getEditorContainerWidth: GetEditorContainerWidth,
71
75
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
72
76
  dragAndDropEnabled?: boolean,
73
77
  isTableScalingEnabled = false,
78
+ isFullWidthEnabled?: boolean,
74
79
  ): SafePlugin {
75
80
  const list = {};
76
81
 
@@ -86,7 +91,11 @@ export function keymapPlugin(
86
91
  );
87
92
  bindKeymapWithCommand(
88
93
  toggleTable.common!,
89
- createTableWithAnalytics(editorAnalyticsAPI),
94
+ createTableWithAnalytics(
95
+ isTableScalingEnabled,
96
+ !!isFullWidthEnabled,
97
+ editorAnalyticsAPI,
98
+ ),
90
99
  list,
91
100
  );
92
101
  bindKeymapWithCommand(
@@ -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(
@@ -14,6 +14,7 @@ export const DragHandleDisabledIcon = ({
14
14
  fill="none"
15
15
  xmlns="http://www.w3.org/2000/svg"
16
16
  style={style}
17
+ data-testid="drag-icon-disabled"
17
18
  >
18
19
  <rect width="24" height="16" rx="4" />
19
20
  <g>
@@ -1,7 +1,13 @@
1
1
  import React from 'react';
2
2
 
3
3
  export const DragHandleIcon = () => (
4
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="16" fill="none">
4
+ <svg
5
+ xmlns="http://www.w3.org/2000/svg"
6
+ width="24"
7
+ height="16"
8
+ fill="none"
9
+ data-testid="drag-icon-enabled"
10
+ >
5
11
  <rect width="24" height="16" rx="4" />
6
12
  <g>
7
13
  <path d="M9 10a1 1 0 1 0-2 0 1 1 0 0 0 2 0ZM9 6a1 1 0 1 0-2 0 1 1 0 0 0 2 0ZM17 10a1 1 0 1 0-2 0 1 1 0 0 0 2 0ZM17 6a1 1 0 1 0-2 0 1 1 0 0 0 2 0ZM13 10a1 1 0 1 0-2 0 1 1 0 0 0 2 0ZM13 6a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z" />
@@ -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;