@atlaskit/editor-plugin-table 29.1.6 → 29.1.8

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,25 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 29.1.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [`aca1f7aaf3fd6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/aca1f7aaf3fd6) -
8
+ Remove the fully rolled-out `platform_editor_exp_lazy_node_views` experiment and call the block
9
+ card, embed card, extension, table, and task node views directly.
10
+ - Updated dependencies
11
+
12
+ ## 29.1.7
13
+
14
+ ### Patch Changes
15
+
16
+ - [`f4930ad3105bb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f4930ad3105bb) -
17
+ Fix column menu targeting for tables with merged final rows behind
18
+ `platform_editor_table_menu_updates_patch_5`.
19
+ - [`37382f7ca3e93`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/37382f7ca3e93) -
20
+ Clean up feature gate `platform_editor_max_width_default_width`
21
+ - Updated dependencies
22
+
3
23
  ## 29.1.6
4
24
 
5
25
  ### Patch Changes
@@ -15,7 +15,6 @@ var _hooks = require("@atlaskit/editor-common/hooks");
15
15
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
16
16
  var _resizer = require("@atlaskit/editor-common/styles/resizer");
17
17
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
18
- var _fg = require("@atlaskit/platform-feature-flags/fg");
19
18
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
20
19
  var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
21
20
  var _commandsWithAnalytics = require("../pm-plugins/commands/commands-with-analytics");
@@ -163,7 +162,7 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
163
162
  var mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
164
163
 
165
164
  // If the editor is in max width mode and the table has no width, use the max width value rather than the default table value
166
- var tableWidth = isMaxWidthModeEnabled && !node.attrs.width && (0, _fg.fg)('platform_editor_max_width_default_width') ? _consts.TABLE_MAX_WIDTH : (0, _nodeWidth.getTableContainerWidth)(node);
165
+ var tableWidth = isMaxWidthModeEnabled && !node.attrs.width ? _consts.TABLE_MAX_WIDTH : (0, _nodeWidth.getTableContainerWidth)(node);
167
166
  var updateContainerHeight = (0, _react.useCallback)(function (height) {
168
167
  var _containerRef$current;
169
168
  // current StickyHeader State is not stable to be fetch.
@@ -225,7 +224,7 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
225
224
  // issues when viwport width is less than full/max width Editor's width. To detect avoid them
226
225
  // we need to use lineLength to defined responsiveWidth instead of containerWidth
227
226
  // (which does not get updated when Mac setting changes) in Full-width/Max-width editor.
228
- if (isFullWidthModeEnabled || isMaxWidthModeEnabled && (0, _fg.fg)('platform_editor_max_width_default_width')) {
227
+ if (isFullWidthModeEnabled || isMaxWidthModeEnabled) {
229
228
  // When: Show scroll bars -> containerWidth = akEditorGutterPadding * 2 + lineLength;
230
229
  // When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
231
230
  // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
@@ -9,7 +9,6 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _ui = require("@atlaskit/editor-common/ui");
12
- var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
13
12
  var _types = require("../types");
14
13
  var TableStickyScrollbar = exports.TableStickyScrollbar = /*#__PURE__*/function () {
15
14
  function TableStickyScrollbar(wrapper, view) {
@@ -24,13 +23,9 @@ var TableStickyScrollbar = exports.TableStickyScrollbar = /*#__PURE__*/function
24
23
  });
25
24
  this.wrapper = wrapper;
26
25
  this.view = view;
27
- if ((0, _editorExperiment.editorExperiment)('platform_editor_exp_lazy_node_views', true)) {
28
- requestAnimationFrame(function () {
29
- _this.init();
30
- });
31
- } else {
32
- this.init();
33
- }
26
+ requestAnimationFrame(function () {
27
+ _this.init();
28
+ });
34
29
  }
35
30
  return (0, _createClass2.default)(TableStickyScrollbar, [{
36
31
  key: "dispose",
@@ -14,6 +14,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
14
14
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
15
15
  var _tableMap = require("@atlaskit/editor-tables/table-map");
16
16
  var _utils2 = require("@atlaskit/editor-tables/utils");
17
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
17
18
  var _types = require("../../types");
18
19
  var _plugin = require("../decorations/plugin");
19
20
  var _columnResizing = require("../decorations/utils/column-resizing");
@@ -26,6 +27,23 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
26
27
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
27
28
  var DARK_MODE_CELL_COLOR = '#1f1f21';
28
29
  var DARK_MODE_HEADER_COLOR = '#303134';
30
+ var selectColumnWithMergedEdgeRows = function selectColumnWithMergedEdgeRows(tr, column, expand) {
31
+ var _getCellsInColumn;
32
+ var transformedTr = (0, _utils2.selectColumn)(column, expand)(tr);
33
+ if (expand) {
34
+ return transformedTr;
35
+ }
36
+ var selectableCells = (_getCellsInColumn = (0, _utils2.getCellsInColumn)(column)(tr.selection)) === null || _getCellsInColumn === void 0 ? void 0 : _getCellsInColumn.filter(function (_ref) {
37
+ var node = _ref.node;
38
+ return node.attrs.colspan === 1;
39
+ });
40
+ var firstCell = selectableCells === null || selectableCells === void 0 ? void 0 : selectableCells[0];
41
+ var lastCell = selectableCells === null || selectableCells === void 0 ? void 0 : selectableCells[selectableCells.length - 1];
42
+ if (!firstCell || !lastCell) {
43
+ return transformedTr;
44
+ }
45
+ return transformedTr.setSelection(new _cellSelection.CellSelection(transformedTr.doc.resolve(lastCell.pos), transformedTr.doc.resolve(firstCell.pos)));
46
+ };
29
47
  var setEditorFocus = exports.setEditorFocus = function setEditorFocus(editorHasFocus) {
30
48
  return (0, _pluginFactory.createCommand)({
31
49
  type: 'SET_EDITOR_FOCUS',
@@ -270,8 +288,8 @@ var convertFirstRowToHeader = exports.convertFirstRowToHeader = function convert
270
288
  };
271
289
  };
272
290
  var moveCursorBackward = exports.moveCursorBackward = function moveCursorBackward(state, dispatch) {
273
- var _ref = state.selection,
274
- $cursor = _ref.$cursor;
291
+ var _ref2 = state.selection,
292
+ $cursor = _ref2.$cursor;
275
293
  // if cursor is in the middle of a text node, do nothing
276
294
  if (!$cursor || $cursor.parentOffset > 0) {
277
295
  return false;
@@ -370,8 +388,8 @@ var setMultipleCellAttrs = exports.setMultipleCellAttrs = function setMultipleCe
370
388
  * EditorCommand variant of `setMultipleCellAttrs`.
371
389
  */
372
390
  var setMultipleCellAttrsEditorCommand = exports.setMultipleCellAttrsEditorCommand = function setMultipleCellAttrsEditorCommand(attrs, targetCellPosition) {
373
- return function (_ref2) {
374
- var tr = _ref2.tr;
391
+ return function (_ref3) {
392
+ var tr = _ref3.tr;
375
393
  var cursorPos;
376
394
  if ((0, _utils2.isSelectionType)(tr.selection, 'cell')) {
377
395
  // Ignored via go/ees005
@@ -404,7 +422,13 @@ var selectColumn = exports.selectColumn = function selectColumn(column, expand)
404
422
  if (!cells || !cells.length || typeof cells[0].pos !== 'number') {
405
423
  return false;
406
424
  }
407
- var decorations = (0, _decoration.createColumnSelectedDecoration)((0, _utils2.selectColumn)(column, expand)(state.tr));
425
+ var selectionTransaction;
426
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_table_menu_updates_patch_5')) {
427
+ selectionTransaction = selectColumnWithMergedEdgeRows(state.tr, column, expand);
428
+ } else {
429
+ selectionTransaction = (0, _utils2.selectColumn)(column, expand)(state.tr);
430
+ }
431
+ var decorations = (0, _decoration.createColumnSelectedDecoration)(selectionTransaction);
408
432
  var decorationSet = (0, _updatePluginStateDecorations.updatePluginStateDecorations)(state, decorations, _types.TableDecorations.COLUMN_SELECTED);
409
433
  var targetCellPosition = cells[0].pos;
410
434
  return {
@@ -415,7 +439,13 @@ var selectColumn = exports.selectColumn = function selectColumn(column, expand)
415
439
  }
416
440
  };
417
441
  }, function (tr) {
418
- return (0, _utils2.selectColumn)(column, expand)(tr).setMeta('addToHistory', false).setMeta('selectedColumnViaKeyboard', triggeredByKeyboard);
442
+ var selectionTransaction;
443
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_table_menu_updates_patch_5')) {
444
+ selectionTransaction = selectColumnWithMergedEdgeRows(tr, column, expand);
445
+ } else {
446
+ selectionTransaction = (0, _utils2.selectColumn)(column, expand)(tr);
447
+ }
448
+ return selectionTransaction.setMeta('addToHistory', false).setMeta('selectedColumnViaKeyboard', triggeredByKeyboard);
419
449
  });
420
450
  };
421
451
  var selectColumns = exports.selectColumns = function selectColumns(columnIndexes) {
@@ -648,8 +678,8 @@ var updateWidthToWidest = exports.updateWidthToWidest = function updateWidthToWi
648
678
  });
649
679
  };
650
680
  var setTableAlignment = exports.setTableAlignment = function setTableAlignment(newAlignment, isCommentEditor) {
651
- return function (_ref3) {
652
- var tr = _ref3.tr;
681
+ return function (_ref4) {
682
+ var tr = _ref4.tr;
653
683
  var tableObject = (0, _utils2.findTable)(tr.selection);
654
684
  if (!tableObject) {
655
685
  return null;
@@ -671,8 +701,8 @@ var setTableAlignment = exports.setTableAlignment = function setTableAlignment(n
671
701
  };
672
702
  };
673
703
  var setTableAlignmentWithTableContentWithPos = exports.setTableAlignmentWithTableContentWithPos = function setTableAlignmentWithTableContentWithPos(newAlignment, tableNodeWithPos) {
674
- return function (_ref4) {
675
- var tr = _ref4.tr;
704
+ return function (_ref5) {
705
+ var tr = _ref5.tr;
676
706
  var table = tableNodeWithPos.node;
677
707
  var nextTableAttrs = _objectSpread(_objectSpread({}, table.attrs), {}, {
678
708
  layout: newAlignment
@@ -3,10 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isRowSelectionWithMergedFirstColumn = exports.isFullRowOrColumnSelected = exports.isColumnSelectionWithMergedFirstRow = exports.getSelectedRowIndexes = exports.getSelectedColumnIndexes = void 0;
6
+ exports.isRowSelectionWithMergedFirstColumn = exports.isFullRowOrColumnSelected = exports.isColumnSelectionWithMergedLastRow = exports.isColumnSelectionWithMergedFirstRow = exports.getSelectedRowIndexes = exports.getSelectedColumnIndexes = void 0;
7
7
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
8
8
  var _tableMap = require("@atlaskit/editor-tables/table-map");
9
9
  var _utils = require("@atlaskit/editor-tables/utils");
10
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
10
11
  var getSelectedColumnIndexes = exports.getSelectedColumnIndexes = function getSelectedColumnIndexes(selectionRect) {
11
12
  var columnIndexes = [];
12
13
  for (var i = selectionRect.left; i < selectionRect.right; i++) {
@@ -51,6 +52,35 @@ var isColumnSelectionWithMergedFirstRow = exports.isColumnSelectionWithMergedFir
51
52
  return true;
52
53
  };
53
54
 
55
+ /**
56
+ * Treats a column as fully selected when its last-row area is covered by a horizontal merge and
57
+ * the explicit `CellSelection` ends above that merged cell. Using that merged cell as an endpoint
58
+ * would expand the selection to the full width of the cell.
59
+ */
60
+ var isColumnSelectionWithMergedLastRow = exports.isColumnSelectionWithMergedLastRow = function isColumnSelectionWithMergedLastRow(selection) {
61
+ var rect = (0, _utils.getSelectionRect)(selection);
62
+ if (!rect) {
63
+ return false;
64
+ }
65
+ var table = (0, _utils.findTableClosestToPos)(selection.$anchorCell);
66
+ if (!table) {
67
+ return false;
68
+ }
69
+ var map = _tableMap.TableMap.get(table.node);
70
+ if (rect.top !== 0 || rect.bottom === map.height) {
71
+ return false;
72
+ }
73
+ for (var col = rect.left; col < rect.right; col++) {
74
+ var bottomCellRect = map.findCell(map.map[(map.height - 1) * map.width + col]);
75
+ var isHorizontallyMerged = bottomCellRect.right - bottomCellRect.left > 1;
76
+ var bridgesGapBelowSelection = bottomCellRect.top <= rect.bottom;
77
+ if (!isHorizontallyMerged || !bridgesGapBelowSelection) {
78
+ return false;
79
+ }
80
+ }
81
+ return true;
82
+ };
83
+
54
84
  /**
55
85
  * Treats a row as fully selected when its first-column area is covered by a vertical merge and the
56
86
  * explicit `CellSelection` starts to the right of that merged cell. `CellSelection.isRowSelection()`
@@ -89,5 +119,10 @@ var isFullRowOrColumnSelected = exports.isFullRowOrColumnSelected = function isF
89
119
  if (!(selection instanceof _cellSelection.CellSelection)) {
90
120
  return false;
91
121
  }
92
- return selection.isRowSelection() || selection.isColSelection() || isRowSelectionWithMergedFirstColumn(selection) || isColumnSelectionWithMergedFirstRow(selection);
122
+ var isExistingFullRowOrColumnSelection = selection.isRowSelection() || selection.isColSelection() || isRowSelectionWithMergedFirstColumn(selection) || isColumnSelectionWithMergedFirstRow(selection);
123
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_table_menu_updates_patch_5')) {
124
+ return isExistingFullRowOrColumnSelection || isColumnSelectionWithMergedLastRow(selection);
125
+ } else {
126
+ return isExistingFullRowOrColumnSelection;
127
+ }
93
128
  };
@@ -12,6 +12,7 @@ var _styles = require("@atlaskit/editor-common/styles");
12
12
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
13
13
  var _editorTables = require("@atlaskit/editor-tables");
14
14
  var _utils = require("@atlaskit/editor-tables/utils");
15
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
15
16
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
16
17
  var _commands = require("../../../pm-plugins/commands");
17
18
  var _commandsWithAnalytics = require("../../../pm-plugins/drag-and-drop/commands-with-analytics");
@@ -28,9 +29,13 @@ var getSelectedColumns = function getSelectedColumns(selection) {
28
29
  return [];
29
30
  }
30
31
  if ((0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true)) {
31
- // New behaviour: also treat a column selection that sits below a merged first-row cell as a
32
- // full column selection.
33
- if (!selection.isColSelection() && !(0, _selection.isColumnSelectionWithMergedFirstRow)(selection)) {
32
+ var isColumnSelection;
33
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_table_menu_updates_patch_5')) {
34
+ isColumnSelection = selection.isColSelection() || (0, _selection.isColumnSelectionWithMergedFirstRow)(selection) || (0, _selection.isColumnSelectionWithMergedLastRow)(selection);
35
+ } else {
36
+ isColumnSelection = selection.isColSelection() || (0, _selection.isColumnSelectionWithMergedFirstRow)(selection);
37
+ }
38
+ if (!isColumnSelection) {
34
39
  return [];
35
40
  }
36
41
  var rect = (0, _utils.getSelectionRect)(selection);
@@ -65,12 +70,14 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
65
70
  getScrollOffset = _ref.getScrollOffset,
66
71
  api = _ref.api;
67
72
  var columnControlsRef = (0, _react.useRef)(null);
68
- var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['selection'], function (states) {
69
- var _states$selectionStat;
73
+ var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['selection', 'table'], function (states) {
74
+ var _states$tableState, _states$selectionStat;
70
75
  return {
76
+ activeTableMenu: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.activeTableMenu,
71
77
  selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
72
78
  };
73
79
  }),
80
+ activeTableMenu = _useSharedPluginState.activeTableMenu,
74
81
  selection = _useSharedPluginState.selection;
75
82
  var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
76
83
  return (
@@ -83,6 +90,12 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
83
90
  var columnParams = (0, _rowControls.getRowsParams)(colWidths !== null && colWidths !== void 0 ? colWidths : []);
84
91
  var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
85
92
  var selectedColIndexes = getSelectedColumns(selection || editorView.state.selection);
93
+ var renderedSelectedColIndexes;
94
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_table_menu_updates_patch_5')) {
95
+ renderedSelectedColIndexes = (activeTableMenu === null || activeTableMenu === void 0 ? void 0 : activeTableMenu.type) === 'column' ? [activeTableMenu.index] : selectedColIndexes;
96
+ } else {
97
+ renderedSelectedColIndexes = selectedColIndexes;
98
+ }
86
99
  var firstRow = tableRef.querySelector('tr');
87
100
  var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
88
101
  var rowControlStickyTop = 45;
@@ -227,7 +240,7 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
227
240
  position: 'relative',
228
241
  pointerEvents: isPlaceholder ? 'none' : undefined
229
242
  },
230
- "data-testid": "table-floating-column-".concat(isHover ? colIndex : isPlaceholder ? appearance : selectedColIndexes[0], "-drag-handle")
243
+ "data-testid": "table-floating-column-".concat(isHover ? colIndex : isPlaceholder ? appearance : renderedSelectedColIndexes[0], "-drag-handle")
231
244
  }, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
232
245
  api: api,
233
246
  isDragMenuTarget: !isHover,
@@ -250,8 +263,8 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
250
263
  };
251
264
  var columnHandles = function columnHandles() {
252
265
  var handles = [];
253
- var isColumnSelected = selectedColIndexes.length > 0;
254
- var isEntireTableSelected = (colWidths || []).length > selectedColIndexes.length;
266
+ var isColumnSelected = renderedSelectedColIndexes.length > 0;
267
+ var isEntireTableSelected = (colWidths || []).length > renderedSelectedColIndexes.length;
255
268
  if (!tableActive) {
256
269
  return null;
257
270
  }
@@ -261,8 +274,8 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
261
274
  // so it can be focused via keyboard shortcuts
262
275
  handles.push(generateHandleByType('selected', selectedAppearance,
263
276
  // always position placeholder in first column to avoid overflow issues
264
- selectedAppearance === 'placeholder' ? '1 / span 1' : "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length), selectedColIndexes));
265
- if (hoveredCell && isTableHovered && colIndex !== undefined && !selectedColIndexes.includes(colIndex)) {
277
+ selectedAppearance === 'placeholder' ? '1 / span 1' : "".concat(renderedSelectedColIndexes[0] + 1, " / span ").concat(renderedSelectedColIndexes.length), renderedSelectedColIndexes));
278
+ if (hoveredCell && isTableHovered && colIndex !== undefined && !renderedSelectedColIndexes.includes(colIndex)) {
266
279
  handles.push(
267
280
  // Ignored via go/ees005
268
281
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -6,7 +6,6 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
6
6
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
7
7
  import { resizerHoverZoneClassName, resizerItemClassName } from '@atlaskit/editor-common/styles/resizer';
8
8
  import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
9
- import { fg } from '@atlaskit/platform-feature-flags/fg';
10
9
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
10
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
12
11
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
@@ -156,7 +155,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
156
155
  const mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
157
156
 
158
157
  // If the editor is in max width mode and the table has no width, use the max width value rather than the default table value
159
- const tableWidth = isMaxWidthModeEnabled && !node.attrs.width && fg('platform_editor_max_width_default_width') ? TABLE_MAX_WIDTH : getTableContainerWidth(node);
158
+ const tableWidth = isMaxWidthModeEnabled && !node.attrs.width ? TABLE_MAX_WIDTH : getTableContainerWidth(node);
160
159
  const updateContainerHeight = useCallback(height => {
161
160
  var _containerRef$current;
162
161
  // current StickyHeader State is not stable to be fetch.
@@ -221,7 +220,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
221
220
  // issues when viwport width is less than full/max width Editor's width. To detect avoid them
222
221
  // we need to use lineLength to defined responsiveWidth instead of containerWidth
223
222
  // (which does not get updated when Mac setting changes) in Full-width/Max-width editor.
224
- if (isFullWidthModeEnabled || isMaxWidthModeEnabled && fg('platform_editor_max_width_default_width')) {
223
+ if (isFullWidthModeEnabled || isMaxWidthModeEnabled) {
225
224
  // When: Show scroll bars -> containerWidth = akEditorGutterPadding * 2 + lineLength;
226
225
  // When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
227
226
  // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
@@ -1,6 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
3
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
4
3
  import { TableCssClassName as ClassName } from '../types';
5
4
  export class TableStickyScrollbar {
6
5
  constructor(wrapper, view) {
@@ -13,13 +12,9 @@ export class TableStickyScrollbar {
13
12
  });
14
13
  this.wrapper = wrapper;
15
14
  this.view = view;
16
- if (editorExperiment('platform_editor_exp_lazy_node_views', true)) {
17
- requestAnimationFrame(() => {
18
- this.init();
19
- });
20
- } else {
15
+ requestAnimationFrame(() => {
21
16
  this.init();
22
- }
17
+ });
23
18
  }
24
19
  dispose() {
25
20
  if (this.stickyScrollbarContainerElement) {
@@ -5,6 +5,7 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
6
6
  import { TableMap } from '@atlaskit/editor-tables/table-map';
7
7
  import { findCellClosestToPos, findTable, getCellsInColumn, getCellsInRow, getSelectionRect, isSelectionType, isTableSelected, removeTable, selectColumns as selectColumnsTransform, selectColumn as selectColumnTransform, selectionCell, selectRows as selectRowsTransform, selectRow as selectRowTransform, setCellAttrs } from '@atlaskit/editor-tables/utils';
8
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
8
9
  import { TableCssClassName as ClassName, TableDecorations } from '../../types';
9
10
  import { getDecorations } from '../decorations/plugin';
10
11
  import { buildColumnResizingDecorations, clearColumnResizingDecorations } from '../decorations/utils/column-resizing';
@@ -15,6 +16,22 @@ import { checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColum
15
16
  import { updatePluginStateDecorations } from '../utils/update-plugin-state-decorations';
16
17
  const DARK_MODE_CELL_COLOR = '#1f1f21';
17
18
  const DARK_MODE_HEADER_COLOR = '#303134';
19
+ const selectColumnWithMergedEdgeRows = (tr, column, expand) => {
20
+ var _getCellsInColumn;
21
+ const transformedTr = selectColumnTransform(column, expand)(tr);
22
+ if (expand) {
23
+ return transformedTr;
24
+ }
25
+ const selectableCells = (_getCellsInColumn = getCellsInColumn(column)(tr.selection)) === null || _getCellsInColumn === void 0 ? void 0 : _getCellsInColumn.filter(({
26
+ node
27
+ }) => node.attrs.colspan === 1);
28
+ const firstCell = selectableCells === null || selectableCells === void 0 ? void 0 : selectableCells[0];
29
+ const lastCell = selectableCells === null || selectableCells === void 0 ? void 0 : selectableCells[selectableCells.length - 1];
30
+ if (!firstCell || !lastCell) {
31
+ return transformedTr;
32
+ }
33
+ return transformedTr.setSelection(new CellSelection(transformedTr.doc.resolve(lastCell.pos), transformedTr.doc.resolve(firstCell.pos)));
34
+ };
18
35
  export const setEditorFocus = editorHasFocus => createCommand({
19
36
  type: 'SET_EDITOR_FOCUS',
20
37
  data: {
@@ -411,7 +428,13 @@ export const selectColumn = (column, expand, triggeredByKeyboard = false) => cre
411
428
  if (!cells || !cells.length || typeof cells[0].pos !== 'number') {
412
429
  return false;
413
430
  }
414
- const decorations = createColumnSelectedDecoration(selectColumnTransform(column, expand)(state.tr));
431
+ let selectionTransaction;
432
+ if (isExperimentEnabled('platform_editor_table_menu_updates_patch_5')) {
433
+ selectionTransaction = selectColumnWithMergedEdgeRows(state.tr, column, expand);
434
+ } else {
435
+ selectionTransaction = selectColumnTransform(column, expand)(state.tr);
436
+ }
437
+ const decorations = createColumnSelectedDecoration(selectionTransaction);
415
438
  const decorationSet = updatePluginStateDecorations(state, decorations, TableDecorations.COLUMN_SELECTED);
416
439
  const targetCellPosition = cells[0].pos;
417
440
  return {
@@ -421,7 +444,15 @@ export const selectColumn = (column, expand, triggeredByKeyboard = false) => cre
421
444
  decorationSet
422
445
  }
423
446
  };
424
- }, tr => selectColumnTransform(column, expand)(tr).setMeta('addToHistory', false).setMeta('selectedColumnViaKeyboard', triggeredByKeyboard));
447
+ }, tr => {
448
+ let selectionTransaction;
449
+ if (isExperimentEnabled('platform_editor_table_menu_updates_patch_5')) {
450
+ selectionTransaction = selectColumnWithMergedEdgeRows(tr, column, expand);
451
+ } else {
452
+ selectionTransaction = selectColumnTransform(column, expand)(tr);
453
+ }
454
+ return selectionTransaction.setMeta('addToHistory', false).setMeta('selectedColumnViaKeyboard', triggeredByKeyboard);
455
+ });
425
456
  export const selectColumns = columnIndexes => createCommand(state => {
426
457
  if (!columnIndexes) {
427
458
  return false;
@@ -1,6 +1,7 @@
1
1
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
2
2
  import { TableMap } from '@atlaskit/editor-tables/table-map';
3
3
  import { findTableClosestToPos, getSelectionRect } from '@atlaskit/editor-tables/utils';
4
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
4
5
  export const getSelectedColumnIndexes = selectionRect => {
5
6
  const columnIndexes = [];
6
7
  for (let i = selectionRect.left; i < selectionRect.right; i++) {
@@ -45,6 +46,35 @@ export const isColumnSelectionWithMergedFirstRow = selection => {
45
46
  return true;
46
47
  };
47
48
 
49
+ /**
50
+ * Treats a column as fully selected when its last-row area is covered by a horizontal merge and
51
+ * the explicit `CellSelection` ends above that merged cell. Using that merged cell as an endpoint
52
+ * would expand the selection to the full width of the cell.
53
+ */
54
+ export const isColumnSelectionWithMergedLastRow = selection => {
55
+ const rect = getSelectionRect(selection);
56
+ if (!rect) {
57
+ return false;
58
+ }
59
+ const table = findTableClosestToPos(selection.$anchorCell);
60
+ if (!table) {
61
+ return false;
62
+ }
63
+ const map = TableMap.get(table.node);
64
+ if (rect.top !== 0 || rect.bottom === map.height) {
65
+ return false;
66
+ }
67
+ for (let col = rect.left; col < rect.right; col++) {
68
+ const bottomCellRect = map.findCell(map.map[(map.height - 1) * map.width + col]);
69
+ const isHorizontallyMerged = bottomCellRect.right - bottomCellRect.left > 1;
70
+ const bridgesGapBelowSelection = bottomCellRect.top <= rect.bottom;
71
+ if (!isHorizontallyMerged || !bridgesGapBelowSelection) {
72
+ return false;
73
+ }
74
+ }
75
+ return true;
76
+ };
77
+
48
78
  /**
49
79
  * Treats a row as fully selected when its first-column area is covered by a vertical merge and the
50
80
  * explicit `CellSelection` starts to the right of that merged cell. `CellSelection.isRowSelection()`
@@ -83,5 +113,10 @@ export const isFullRowOrColumnSelected = selection => {
83
113
  if (!(selection instanceof CellSelection)) {
84
114
  return false;
85
115
  }
86
- return selection.isRowSelection() || selection.isColSelection() || isRowSelectionWithMergedFirstColumn(selection) || isColumnSelectionWithMergedFirstRow(selection);
116
+ const isExistingFullRowOrColumnSelection = selection.isRowSelection() || selection.isColSelection() || isRowSelectionWithMergedFirstColumn(selection) || isColumnSelectionWithMergedFirstRow(selection);
117
+ if (isExperimentEnabled('platform_editor_table_menu_updates_patch_5')) {
118
+ return isExistingFullRowOrColumnSelection || isColumnSelectionWithMergedLastRow(selection);
119
+ } else {
120
+ return isExistingFullRowOrColumnSelection;
121
+ }
87
122
  };
@@ -7,12 +7,13 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
7
7
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
8
8
  import { CellSelection } from '@atlaskit/editor-tables';
9
9
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
10
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
10
11
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
12
  import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns, toggleActiveTableMenu } from '../../../pm-plugins/commands';
12
13
  import { toggleDragMenuWithAnalytics } from '../../../pm-plugins/drag-and-drop/commands-with-analytics';
13
14
  import { getPluginState as getTablePluginState } from '../../../pm-plugins/plugin-factory';
14
15
  import { getRowsParams } from '../../../pm-plugins/utils/row-controls';
15
- import { getSelectedColumnIndexes, isColumnSelectionWithMergedFirstRow } from '../../../pm-plugins/utils/selection';
16
+ import { getSelectedColumnIndexes, isColumnSelectionWithMergedFirstRow, isColumnSelectionWithMergedLastRow } from '../../../pm-plugins/utils/selection';
16
17
  import { TableCssClassName as ClassName } from '../../../types';
17
18
  import { DragHandle } from '../../DragHandle';
18
19
  const getSelectedColumns = selection => {
@@ -20,9 +21,13 @@ const getSelectedColumns = selection => {
20
21
  return [];
21
22
  }
22
23
  if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
23
- // New behaviour: also treat a column selection that sits below a merged first-row cell as a
24
- // full column selection.
25
- if (!selection.isColSelection() && !isColumnSelectionWithMergedFirstRow(selection)) {
24
+ let isColumnSelection;
25
+ if (isExperimentEnabled('platform_editor_table_menu_updates_patch_5')) {
26
+ isColumnSelection = selection.isColSelection() || isColumnSelectionWithMergedFirstRow(selection) || isColumnSelectionWithMergedLastRow(selection);
27
+ } else {
28
+ isColumnSelection = selection.isColSelection() || isColumnSelectionWithMergedFirstRow(selection);
29
+ }
30
+ if (!isColumnSelection) {
26
31
  return [];
27
32
  }
28
33
  const rect = getSelectionRect(selection);
@@ -59,10 +64,12 @@ export const ColumnControls = ({
59
64
  var _colWidths$map$join;
60
65
  const columnControlsRef = useRef(null);
61
66
  const {
67
+ activeTableMenu,
62
68
  selection
63
- } = useSharedPluginStateWithSelector(api, ['selection'], states => {
64
- var _states$selectionStat;
69
+ } = useSharedPluginStateWithSelector(api, ['selection', 'table'], states => {
70
+ var _states$tableState, _states$selectionStat;
65
71
  return {
72
+ activeTableMenu: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.activeTableMenu,
66
73
  selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
67
74
  };
68
75
  });
@@ -74,6 +81,12 @@ export const ColumnControls = ({
74
81
  const columnParams = getRowsParams(colWidths !== null && colWidths !== void 0 ? colWidths : []);
75
82
  const colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
76
83
  const selectedColIndexes = getSelectedColumns(selection || editorView.state.selection);
84
+ let renderedSelectedColIndexes;
85
+ if (isExperimentEnabled('platform_editor_table_menu_updates_patch_5')) {
86
+ renderedSelectedColIndexes = (activeTableMenu === null || activeTableMenu === void 0 ? void 0 : activeTableMenu.type) === 'column' ? [activeTableMenu.index] : selectedColIndexes;
87
+ } else {
88
+ renderedSelectedColIndexes = selectedColIndexes;
89
+ }
77
90
  const firstRow = tableRef.querySelector('tr');
78
91
  const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
79
92
  const rowControlStickyTop = 45;
@@ -226,7 +239,7 @@ export const ColumnControls = ({
226
239
  position: 'relative',
227
240
  pointerEvents: isPlaceholder ? 'none' : undefined
228
241
  },
229
- "data-testid": `table-floating-column-${isHover ? colIndex : isPlaceholder ? appearance : selectedColIndexes[0]}-drag-handle`
242
+ "data-testid": `table-floating-column-${isHover ? colIndex : isPlaceholder ? appearance : renderedSelectedColIndexes[0]}-drag-handle`
230
243
  }, /*#__PURE__*/React.createElement(DragHandle, {
231
244
  api: api,
232
245
  isDragMenuTarget: !isHover,
@@ -249,8 +262,8 @@ export const ColumnControls = ({
249
262
  };
250
263
  const columnHandles = () => {
251
264
  const handles = [];
252
- const isColumnSelected = selectedColIndexes.length > 0;
253
- const isEntireTableSelected = (colWidths || []).length > selectedColIndexes.length;
265
+ const isColumnSelected = renderedSelectedColIndexes.length > 0;
266
+ const isEntireTableSelected = (colWidths || []).length > renderedSelectedColIndexes.length;
254
267
  if (!tableActive) {
255
268
  return null;
256
269
  }
@@ -260,8 +273,8 @@ export const ColumnControls = ({
260
273
  // so it can be focused via keyboard shortcuts
261
274
  handles.push(generateHandleByType('selected', selectedAppearance,
262
275
  // always position placeholder in first column to avoid overflow issues
263
- selectedAppearance === 'placeholder' ? '1 / span 1' : `${selectedColIndexes[0] + 1} / span ${selectedColIndexes.length}`, selectedColIndexes));
264
- if (hoveredCell && isTableHovered && colIndex !== undefined && !selectedColIndexes.includes(colIndex)) {
276
+ selectedAppearance === 'placeholder' ? '1 / span 1' : `${renderedSelectedColIndexes[0] + 1} / span ${renderedSelectedColIndexes.length}`, renderedSelectedColIndexes));
277
+ if (hoveredCell && isTableHovered && colIndex !== undefined && !renderedSelectedColIndexes.includes(colIndex)) {
265
278
  handles.push(
266
279
  // Ignored via go/ees005
267
280
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -7,7 +7,6 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
7
7
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
8
8
  import { resizerHoverZoneClassName, resizerItemClassName } from '@atlaskit/editor-common/styles/resizer';
9
9
  import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
10
- import { fg } from '@atlaskit/platform-feature-flags/fg';
11
10
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
13
12
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
@@ -154,7 +153,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
154
153
  var mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
155
154
 
156
155
  // If the editor is in max width mode and the table has no width, use the max width value rather than the default table value
157
- var tableWidth = isMaxWidthModeEnabled && !node.attrs.width && fg('platform_editor_max_width_default_width') ? TABLE_MAX_WIDTH : getTableContainerWidth(node);
156
+ var tableWidth = isMaxWidthModeEnabled && !node.attrs.width ? TABLE_MAX_WIDTH : getTableContainerWidth(node);
158
157
  var updateContainerHeight = useCallback(function (height) {
159
158
  var _containerRef$current;
160
159
  // current StickyHeader State is not stable to be fetch.
@@ -216,7 +215,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
216
215
  // issues when viwport width is less than full/max width Editor's width. To detect avoid them
217
216
  // we need to use lineLength to defined responsiveWidth instead of containerWidth
218
217
  // (which does not get updated when Mac setting changes) in Full-width/Max-width editor.
219
- if (isFullWidthModeEnabled || isMaxWidthModeEnabled && fg('platform_editor_max_width_default_width')) {
218
+ if (isFullWidthModeEnabled || isMaxWidthModeEnabled) {
220
219
  // When: Show scroll bars -> containerWidth = akEditorGutterPadding * 2 + lineLength;
221
220
  // When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
222
221
  // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
@@ -2,7 +2,6 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
5
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
6
5
  import { TableCssClassName as ClassName } from '../types';
7
6
  export var TableStickyScrollbar = /*#__PURE__*/function () {
8
7
  function TableStickyScrollbar(wrapper, view) {
@@ -17,13 +16,9 @@ export var TableStickyScrollbar = /*#__PURE__*/function () {
17
16
  });
18
17
  this.wrapper = wrapper;
19
18
  this.view = view;
20
- if (editorExperiment('platform_editor_exp_lazy_node_views', true)) {
21
- requestAnimationFrame(function () {
22
- _this.init();
23
- });
24
- } else {
25
- this.init();
26
- }
19
+ requestAnimationFrame(function () {
20
+ _this.init();
21
+ });
27
22
  }
28
23
  return _createClass(TableStickyScrollbar, [{
29
24
  key: "dispose",
@@ -9,6 +9,7 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
9
9
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
10
10
  import { TableMap } from '@atlaskit/editor-tables/table-map';
11
11
  import { findCellClosestToPos, findTable, getCellsInColumn, getCellsInRow, getSelectionRect, isSelectionType, isTableSelected, removeTable, selectColumns as selectColumnsTransform, selectColumn as selectColumnTransform, selectionCell, selectRows as selectRowsTransform, selectRow as selectRowTransform, setCellAttrs } from '@atlaskit/editor-tables/utils';
12
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
12
13
  import { TableCssClassName as ClassName, TableDecorations } from '../../types';
13
14
  import { getDecorations } from '../decorations/plugin';
14
15
  import { buildColumnResizingDecorations, clearColumnResizingDecorations } from '../decorations/utils/column-resizing';
@@ -19,6 +20,23 @@ import { checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColum
19
20
  import { updatePluginStateDecorations } from '../utils/update-plugin-state-decorations';
20
21
  var DARK_MODE_CELL_COLOR = '#1f1f21';
21
22
  var DARK_MODE_HEADER_COLOR = '#303134';
23
+ var selectColumnWithMergedEdgeRows = function selectColumnWithMergedEdgeRows(tr, column, expand) {
24
+ var _getCellsInColumn;
25
+ var transformedTr = selectColumnTransform(column, expand)(tr);
26
+ if (expand) {
27
+ return transformedTr;
28
+ }
29
+ var selectableCells = (_getCellsInColumn = getCellsInColumn(column)(tr.selection)) === null || _getCellsInColumn === void 0 ? void 0 : _getCellsInColumn.filter(function (_ref) {
30
+ var node = _ref.node;
31
+ return node.attrs.colspan === 1;
32
+ });
33
+ var firstCell = selectableCells === null || selectableCells === void 0 ? void 0 : selectableCells[0];
34
+ var lastCell = selectableCells === null || selectableCells === void 0 ? void 0 : selectableCells[selectableCells.length - 1];
35
+ if (!firstCell || !lastCell) {
36
+ return transformedTr;
37
+ }
38
+ return transformedTr.setSelection(new CellSelection(transformedTr.doc.resolve(lastCell.pos), transformedTr.doc.resolve(firstCell.pos)));
39
+ };
22
40
  export var setEditorFocus = function setEditorFocus(editorHasFocus) {
23
41
  return createCommand({
24
42
  type: 'SET_EDITOR_FOCUS',
@@ -263,8 +281,8 @@ export var convertFirstRowToHeader = function convertFirstRowToHeader(schema) {
263
281
  };
264
282
  };
265
283
  export var moveCursorBackward = function moveCursorBackward(state, dispatch) {
266
- var _ref = state.selection,
267
- $cursor = _ref.$cursor;
284
+ var _ref2 = state.selection,
285
+ $cursor = _ref2.$cursor;
268
286
  // if cursor is in the middle of a text node, do nothing
269
287
  if (!$cursor || $cursor.parentOffset > 0) {
270
288
  return false;
@@ -363,8 +381,8 @@ export var setMultipleCellAttrs = function setMultipleCellAttrs(attrs, editorVie
363
381
  * EditorCommand variant of `setMultipleCellAttrs`.
364
382
  */
365
383
  export var setMultipleCellAttrsEditorCommand = function setMultipleCellAttrsEditorCommand(attrs, targetCellPosition) {
366
- return function (_ref2) {
367
- var tr = _ref2.tr;
384
+ return function (_ref3) {
385
+ var tr = _ref3.tr;
368
386
  var cursorPos;
369
387
  if (isSelectionType(tr.selection, 'cell')) {
370
388
  // Ignored via go/ees005
@@ -397,7 +415,13 @@ export var selectColumn = function selectColumn(column, expand) {
397
415
  if (!cells || !cells.length || typeof cells[0].pos !== 'number') {
398
416
  return false;
399
417
  }
400
- var decorations = createColumnSelectedDecoration(selectColumnTransform(column, expand)(state.tr));
418
+ var selectionTransaction;
419
+ if (isExperimentEnabled('platform_editor_table_menu_updates_patch_5')) {
420
+ selectionTransaction = selectColumnWithMergedEdgeRows(state.tr, column, expand);
421
+ } else {
422
+ selectionTransaction = selectColumnTransform(column, expand)(state.tr);
423
+ }
424
+ var decorations = createColumnSelectedDecoration(selectionTransaction);
401
425
  var decorationSet = updatePluginStateDecorations(state, decorations, TableDecorations.COLUMN_SELECTED);
402
426
  var targetCellPosition = cells[0].pos;
403
427
  return {
@@ -408,7 +432,13 @@ export var selectColumn = function selectColumn(column, expand) {
408
432
  }
409
433
  };
410
434
  }, function (tr) {
411
- return selectColumnTransform(column, expand)(tr).setMeta('addToHistory', false).setMeta('selectedColumnViaKeyboard', triggeredByKeyboard);
435
+ var selectionTransaction;
436
+ if (isExperimentEnabled('platform_editor_table_menu_updates_patch_5')) {
437
+ selectionTransaction = selectColumnWithMergedEdgeRows(tr, column, expand);
438
+ } else {
439
+ selectionTransaction = selectColumnTransform(column, expand)(tr);
440
+ }
441
+ return selectionTransaction.setMeta('addToHistory', false).setMeta('selectedColumnViaKeyboard', triggeredByKeyboard);
412
442
  });
413
443
  };
414
444
  export var selectColumns = function selectColumns(columnIndexes) {
@@ -641,8 +671,8 @@ export var updateWidthToWidest = function updateWidthToWidest(widthToWidest) {
641
671
  });
642
672
  };
643
673
  export var setTableAlignment = function setTableAlignment(newAlignment, isCommentEditor) {
644
- return function (_ref3) {
645
- var tr = _ref3.tr;
674
+ return function (_ref4) {
675
+ var tr = _ref4.tr;
646
676
  var tableObject = findTable(tr.selection);
647
677
  if (!tableObject) {
648
678
  return null;
@@ -664,8 +694,8 @@ export var setTableAlignment = function setTableAlignment(newAlignment, isCommen
664
694
  };
665
695
  };
666
696
  export var setTableAlignmentWithTableContentWithPos = function setTableAlignmentWithTableContentWithPos(newAlignment, tableNodeWithPos) {
667
- return function (_ref4) {
668
- var tr = _ref4.tr;
697
+ return function (_ref5) {
698
+ var tr = _ref5.tr;
669
699
  var table = tableNodeWithPos.node;
670
700
  var nextTableAttrs = _objectSpread(_objectSpread({}, table.attrs), {}, {
671
701
  layout: newAlignment
@@ -1,6 +1,7 @@
1
1
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
2
2
  import { TableMap } from '@atlaskit/editor-tables/table-map';
3
3
  import { findTableClosestToPos, getSelectionRect } from '@atlaskit/editor-tables/utils';
4
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
4
5
  export var getSelectedColumnIndexes = function getSelectedColumnIndexes(selectionRect) {
5
6
  var columnIndexes = [];
6
7
  for (var i = selectionRect.left; i < selectionRect.right; i++) {
@@ -45,6 +46,35 @@ export var isColumnSelectionWithMergedFirstRow = function isColumnSelectionWithM
45
46
  return true;
46
47
  };
47
48
 
49
+ /**
50
+ * Treats a column as fully selected when its last-row area is covered by a horizontal merge and
51
+ * the explicit `CellSelection` ends above that merged cell. Using that merged cell as an endpoint
52
+ * would expand the selection to the full width of the cell.
53
+ */
54
+ export var isColumnSelectionWithMergedLastRow = function isColumnSelectionWithMergedLastRow(selection) {
55
+ var rect = getSelectionRect(selection);
56
+ if (!rect) {
57
+ return false;
58
+ }
59
+ var table = findTableClosestToPos(selection.$anchorCell);
60
+ if (!table) {
61
+ return false;
62
+ }
63
+ var map = TableMap.get(table.node);
64
+ if (rect.top !== 0 || rect.bottom === map.height) {
65
+ return false;
66
+ }
67
+ for (var col = rect.left; col < rect.right; col++) {
68
+ var bottomCellRect = map.findCell(map.map[(map.height - 1) * map.width + col]);
69
+ var isHorizontallyMerged = bottomCellRect.right - bottomCellRect.left > 1;
70
+ var bridgesGapBelowSelection = bottomCellRect.top <= rect.bottom;
71
+ if (!isHorizontallyMerged || !bridgesGapBelowSelection) {
72
+ return false;
73
+ }
74
+ }
75
+ return true;
76
+ };
77
+
48
78
  /**
49
79
  * Treats a row as fully selected when its first-column area is covered by a vertical merge and the
50
80
  * explicit `CellSelection` starts to the right of that merged cell. `CellSelection.isRowSelection()`
@@ -83,5 +113,10 @@ export var isFullRowOrColumnSelected = function isFullRowOrColumnSelected(select
83
113
  if (!(selection instanceof CellSelection)) {
84
114
  return false;
85
115
  }
86
- return selection.isRowSelection() || selection.isColSelection() || isRowSelectionWithMergedFirstColumn(selection) || isColumnSelectionWithMergedFirstRow(selection);
116
+ var isExistingFullRowOrColumnSelection = selection.isRowSelection() || selection.isColSelection() || isRowSelectionWithMergedFirstColumn(selection) || isColumnSelectionWithMergedFirstRow(selection);
117
+ if (isExperimentEnabled('platform_editor_table_menu_updates_patch_5')) {
118
+ return isExistingFullRowOrColumnSelection || isColumnSelectionWithMergedLastRow(selection);
119
+ } else {
120
+ return isExistingFullRowOrColumnSelection;
121
+ }
87
122
  };
@@ -7,12 +7,13 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
7
7
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
8
8
  import { CellSelection } from '@atlaskit/editor-tables';
9
9
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
10
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
10
11
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
12
  import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns, toggleActiveTableMenu } from '../../../pm-plugins/commands';
12
13
  import { toggleDragMenuWithAnalytics } from '../../../pm-plugins/drag-and-drop/commands-with-analytics';
13
14
  import { getPluginState as getTablePluginState } from '../../../pm-plugins/plugin-factory';
14
15
  import { getRowsParams } from '../../../pm-plugins/utils/row-controls';
15
- import { getSelectedColumnIndexes, isColumnSelectionWithMergedFirstRow } from '../../../pm-plugins/utils/selection';
16
+ import { getSelectedColumnIndexes, isColumnSelectionWithMergedFirstRow, isColumnSelectionWithMergedLastRow } from '../../../pm-plugins/utils/selection';
16
17
  import { TableCssClassName as ClassName } from '../../../types';
17
18
  import { DragHandle } from '../../DragHandle';
18
19
  var getSelectedColumns = function getSelectedColumns(selection) {
@@ -20,9 +21,13 @@ var getSelectedColumns = function getSelectedColumns(selection) {
20
21
  return [];
21
22
  }
22
23
  if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
23
- // New behaviour: also treat a column selection that sits below a merged first-row cell as a
24
- // full column selection.
25
- if (!selection.isColSelection() && !isColumnSelectionWithMergedFirstRow(selection)) {
24
+ var isColumnSelection;
25
+ if (isExperimentEnabled('platform_editor_table_menu_updates_patch_5')) {
26
+ isColumnSelection = selection.isColSelection() || isColumnSelectionWithMergedFirstRow(selection) || isColumnSelectionWithMergedLastRow(selection);
27
+ } else {
28
+ isColumnSelection = selection.isColSelection() || isColumnSelectionWithMergedFirstRow(selection);
29
+ }
30
+ if (!isColumnSelection) {
26
31
  return [];
27
32
  }
28
33
  var rect = getSelectionRect(selection);
@@ -57,12 +62,14 @@ export var ColumnControls = function ColumnControls(_ref) {
57
62
  getScrollOffset = _ref.getScrollOffset,
58
63
  api = _ref.api;
59
64
  var columnControlsRef = useRef(null);
60
- var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['selection'], function (states) {
61
- var _states$selectionStat;
65
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['selection', 'table'], function (states) {
66
+ var _states$tableState, _states$selectionStat;
62
67
  return {
68
+ activeTableMenu: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.activeTableMenu,
63
69
  selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
64
70
  };
65
71
  }),
72
+ activeTableMenu = _useSharedPluginState.activeTableMenu,
66
73
  selection = _useSharedPluginState.selection;
67
74
  var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
68
75
  return (
@@ -75,6 +82,12 @@ export var ColumnControls = function ColumnControls(_ref) {
75
82
  var columnParams = getRowsParams(colWidths !== null && colWidths !== void 0 ? colWidths : []);
76
83
  var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
77
84
  var selectedColIndexes = getSelectedColumns(selection || editorView.state.selection);
85
+ var renderedSelectedColIndexes;
86
+ if (isExperimentEnabled('platform_editor_table_menu_updates_patch_5')) {
87
+ renderedSelectedColIndexes = (activeTableMenu === null || activeTableMenu === void 0 ? void 0 : activeTableMenu.type) === 'column' ? [activeTableMenu.index] : selectedColIndexes;
88
+ } else {
89
+ renderedSelectedColIndexes = selectedColIndexes;
90
+ }
78
91
  var firstRow = tableRef.querySelector('tr');
79
92
  var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
80
93
  var rowControlStickyTop = 45;
@@ -219,7 +232,7 @@ export var ColumnControls = function ColumnControls(_ref) {
219
232
  position: 'relative',
220
233
  pointerEvents: isPlaceholder ? 'none' : undefined
221
234
  },
222
- "data-testid": "table-floating-column-".concat(isHover ? colIndex : isPlaceholder ? appearance : selectedColIndexes[0], "-drag-handle")
235
+ "data-testid": "table-floating-column-".concat(isHover ? colIndex : isPlaceholder ? appearance : renderedSelectedColIndexes[0], "-drag-handle")
223
236
  }, /*#__PURE__*/React.createElement(DragHandle, {
224
237
  api: api,
225
238
  isDragMenuTarget: !isHover,
@@ -242,8 +255,8 @@ export var ColumnControls = function ColumnControls(_ref) {
242
255
  };
243
256
  var columnHandles = function columnHandles() {
244
257
  var handles = [];
245
- var isColumnSelected = selectedColIndexes.length > 0;
246
- var isEntireTableSelected = (colWidths || []).length > selectedColIndexes.length;
258
+ var isColumnSelected = renderedSelectedColIndexes.length > 0;
259
+ var isEntireTableSelected = (colWidths || []).length > renderedSelectedColIndexes.length;
247
260
  if (!tableActive) {
248
261
  return null;
249
262
  }
@@ -253,8 +266,8 @@ export var ColumnControls = function ColumnControls(_ref) {
253
266
  // so it can be focused via keyboard shortcuts
254
267
  handles.push(generateHandleByType('selected', selectedAppearance,
255
268
  // always position placeholder in first column to avoid overflow issues
256
- selectedAppearance === 'placeholder' ? '1 / span 1' : "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length), selectedColIndexes));
257
- if (hoveredCell && isTableHovered && colIndex !== undefined && !selectedColIndexes.includes(colIndex)) {
269
+ selectedAppearance === 'placeholder' ? '1 / span 1' : "".concat(renderedSelectedColIndexes[0] + 1, " / span ").concat(renderedSelectedColIndexes.length), renderedSelectedColIndexes));
270
+ if (hoveredCell && isTableHovered && colIndex !== undefined && !renderedSelectedColIndexes.includes(colIndex)) {
258
271
  handles.push(
259
272
  // Ignored via go/ees005
260
273
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -9,6 +9,12 @@ export declare const getSelectedRowIndexes: (selectionRect: Rect) => number[];
9
9
  * returns `false` in this case because the selection does not include the merged first-row cell.
10
10
  */
11
11
  export declare const isColumnSelectionWithMergedFirstRow: (selection: CellSelection) => boolean;
12
+ /**
13
+ * Treats a column as fully selected when its last-row area is covered by a horizontal merge and
14
+ * the explicit `CellSelection` ends above that merged cell. Using that merged cell as an endpoint
15
+ * would expand the selection to the full width of the cell.
16
+ */
17
+ export declare const isColumnSelectionWithMergedLastRow: (selection: CellSelection) => boolean;
12
18
  /**
13
19
  * Treats a row as fully selected when its first-column area is covered by a vertical merge and the
14
20
  * explicit `CellSelection` starts to the right of that merged cell. `CellSelection.isRowSelection()`
@@ -4,7 +4,7 @@ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/stat
4
4
  import type { TablePlugin, TablePluginOptions } from '../../tablePluginType';
5
5
  type InsertTableFromQuickInsertParams = {
6
6
  api: ExtractInjectionAPI<TablePlugin> | undefined;
7
- inputMethod: INPUT_METHOD.ELEMENT_BROWSER | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR;
7
+ inputMethod: INPUT_METHOD.ELEMENT_BROWSER | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.TOOLBAR;
8
8
  insert: TypeAheadInsert;
9
9
  isTableSelectorEnabled: boolean | undefined;
10
10
  options: TablePluginOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "29.1.6",
3
+ "version": "29.1.8",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,7 +29,7 @@
29
29
  "@atlaskit/editor-plugin-batch-attribute-updates": "^17.0.0",
30
30
  "@atlaskit/editor-plugin-content-insertion": "^17.0.0",
31
31
  "@atlaskit/editor-plugin-editor-viewmode": "^19.0.0",
32
- "@atlaskit/editor-plugin-extension": "20.0.6",
32
+ "@atlaskit/editor-plugin-extension": "20.0.8",
33
33
  "@atlaskit/editor-plugin-guideline": "^17.0.0",
34
34
  "@atlaskit/editor-plugin-interaction": "^28.0.0",
35
35
  "@atlaskit/editor-plugin-limited-mode": "^14.1.0",
@@ -39,7 +39,7 @@
39
39
  "@atlaskit/editor-plugin-user-intent": "^15.0.0",
40
40
  "@atlaskit/editor-plugin-width": "^18.0.0",
41
41
  "@atlaskit/editor-prosemirror": "^8.0.0",
42
- "@atlaskit/editor-shared-styles": "^4.1.0",
42
+ "@atlaskit/editor-shared-styles": "^4.2.0",
43
43
  "@atlaskit/editor-tables": "^3.2.0",
44
44
  "@atlaskit/editor-toolbar": "^2.6.0",
45
45
  "@atlaskit/editor-ui-control-model": "^2.9.0",
@@ -53,9 +53,9 @@
53
53
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^3.2.0",
54
54
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^2.2.0",
55
55
  "@atlaskit/primitives": "^22.5.0",
56
- "@atlaskit/tmp-editor-statsig": "^184.0.0",
56
+ "@atlaskit/tmp-editor-statsig": "^186.0.0",
57
57
  "@atlaskit/toggle": "^17.3.0",
58
- "@atlaskit/tokens": "^16.11.0",
58
+ "@atlaskit/tokens": "^16.12.0",
59
59
  "@atlaskit/tooltip": "^24.3.0",
60
60
  "@babel/runtime": "^7.0.0",
61
61
  "@compiled/react": "^1.0.2",
@@ -68,7 +68,7 @@
68
68
  "uuid": "^11.1.1"
69
69
  },
70
70
  "peerDependencies": {
71
- "@atlaskit/editor-common": "^121.3.0",
71
+ "@atlaskit/editor-common": "^121.4.0",
72
72
  "react": "^18.2.0 || ^19.2.0",
73
73
  "react-dom": "^18.2.0 || ^19.2.0",
74
74
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -92,9 +92,6 @@
92
92
  "platform_editor_table_height_analytics": {
93
93
  "type": "boolean"
94
94
  },
95
- "platform_editor_max_width_default_width": {
96
- "type": "boolean"
97
- },
98
95
  "platform_editor_ai_table_ai_streaming_pos_fix": {
99
96
  "type": "boolean"
100
97
  },