@atlaskit/editor-plugin-table 22.4.17 → 22.4.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/nodeviews/TableCell.js +9 -2
  3. package/dist/cjs/pm-plugins/commands/active-table-menu.js +18 -21
  4. package/dist/cjs/pm-plugins/commands/commands-with-analytics.js +17 -10
  5. package/dist/cjs/pm-plugins/commands/index.js +6 -0
  6. package/dist/cjs/pm-plugins/commands/misc.js +37 -5
  7. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +23 -12
  8. package/dist/cjs/tablePlugin.js +5 -4
  9. package/dist/cjs/ui/FloatingContextualButton/index.js +32 -9
  10. package/dist/cjs/ui/FloatingContextualMenu/CellMenuPopup.js +2 -2
  11. package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +76 -0
  12. package/dist/cjs/ui/TableMenu/cell/items/MergeCellsItem.js +2 -1
  13. package/dist/cjs/ui/TableMenu/cell/items/SplitCellItem.js +2 -1
  14. package/dist/cjs/ui/TableMenu/cell/items/VerticalAlignDropdownItem.js +61 -0
  15. package/dist/cjs/ui/TableMenu/cell/items/VerticalAlignNestedMenu.js +56 -0
  16. package/dist/cjs/ui/TableMenu/cell/items/verticalAlignUtils.js +20 -0
  17. package/dist/cjs/ui/TableMenu/cell/keys.js +24 -2
  18. package/dist/cjs/ui/TableMenu/column/items/AddColumnLeftItem.js +3 -0
  19. package/dist/cjs/ui/TableMenu/column/items/AddColumnRightItem.js +3 -0
  20. package/dist/cjs/ui/TableMenu/column/items/DeleteColumnItem.js +2 -0
  21. package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +3 -0
  22. package/dist/cjs/ui/TableMenu/column/items/MoveColumnLeftItem.js +3 -0
  23. package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -0
  24. package/dist/cjs/ui/TableMenu/column/items/SortDecreasingItem.js +3 -0
  25. package/dist/cjs/ui/TableMenu/column/items/SortIncreasingItem.js +3 -0
  26. package/dist/cjs/ui/TableMenu/row/items/AddRowAboveItem.js +3 -0
  27. package/dist/cjs/ui/TableMenu/row/items/AddRowBelowItem.js +3 -0
  28. package/dist/cjs/ui/TableMenu/row/items/DeleteRowItem.js +2 -0
  29. package/dist/cjs/ui/TableMenu/row/items/MoveRowDownItem.js +3 -0
  30. package/dist/cjs/ui/TableMenu/row/items/MoveRowUpItem.js +3 -0
  31. package/dist/cjs/ui/TableMenu/shared/TableMenu.js +2 -11
  32. package/dist/cjs/ui/TableMenu/shared/items/BackgroundColorItem.js +4 -3
  33. package/dist/cjs/ui/TableMenu/shared/items/ClearCellsItem.js +2 -1
  34. package/dist/es2019/nodeviews/TableCell.js +9 -2
  35. package/dist/es2019/pm-plugins/commands/active-table-menu.js +19 -18
  36. package/dist/es2019/pm-plugins/commands/commands-with-analytics.js +10 -2
  37. package/dist/es2019/pm-plugins/commands/index.js +1 -1
  38. package/dist/es2019/pm-plugins/commands/misc.js +31 -0
  39. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +22 -10
  40. package/dist/es2019/tablePlugin.js +6 -5
  41. package/dist/es2019/ui/FloatingContextualButton/index.js +36 -9
  42. package/dist/es2019/ui/FloatingContextualMenu/CellMenuPopup.js +2 -2
  43. package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +67 -1
  44. package/dist/es2019/ui/TableMenu/cell/items/MergeCellsItem.js +2 -1
  45. package/dist/es2019/ui/TableMenu/cell/items/SplitCellItem.js +2 -1
  46. package/dist/es2019/ui/TableMenu/cell/items/VerticalAlignDropdownItem.js +56 -0
  47. package/dist/es2019/ui/TableMenu/cell/items/VerticalAlignNestedMenu.js +48 -0
  48. package/dist/es2019/ui/TableMenu/cell/items/verticalAlignUtils.js +15 -0
  49. package/dist/es2019/ui/TableMenu/cell/keys.js +31 -2
  50. package/dist/es2019/ui/TableMenu/column/items/AddColumnLeftItem.js +3 -0
  51. package/dist/es2019/ui/TableMenu/column/items/AddColumnRightItem.js +3 -0
  52. package/dist/es2019/ui/TableMenu/column/items/DeleteColumnItem.js +3 -1
  53. package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +3 -0
  54. package/dist/es2019/ui/TableMenu/column/items/MoveColumnLeftItem.js +3 -0
  55. package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -0
  56. package/dist/es2019/ui/TableMenu/column/items/SortDecreasingItem.js +3 -0
  57. package/dist/es2019/ui/TableMenu/column/items/SortIncreasingItem.js +3 -0
  58. package/dist/es2019/ui/TableMenu/row/items/AddRowAboveItem.js +3 -0
  59. package/dist/es2019/ui/TableMenu/row/items/AddRowBelowItem.js +3 -0
  60. package/dist/es2019/ui/TableMenu/row/items/DeleteRowItem.js +3 -1
  61. package/dist/es2019/ui/TableMenu/row/items/MoveRowDownItem.js +3 -0
  62. package/dist/es2019/ui/TableMenu/row/items/MoveRowUpItem.js +3 -0
  63. package/dist/es2019/ui/TableMenu/shared/TableMenu.js +2 -11
  64. package/dist/es2019/ui/TableMenu/shared/items/BackgroundColorItem.js +4 -3
  65. package/dist/es2019/ui/TableMenu/shared/items/ClearCellsItem.js +2 -1
  66. package/dist/esm/nodeviews/TableCell.js +9 -2
  67. package/dist/esm/pm-plugins/commands/active-table-menu.js +18 -21
  68. package/dist/esm/pm-plugins/commands/commands-with-analytics.js +17 -10
  69. package/dist/esm/pm-plugins/commands/index.js +1 -1
  70. package/dist/esm/pm-plugins/commands/misc.js +36 -4
  71. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +23 -12
  72. package/dist/esm/tablePlugin.js +6 -5
  73. package/dist/esm/ui/FloatingContextualButton/index.js +32 -9
  74. package/dist/esm/ui/FloatingContextualMenu/CellMenuPopup.js +2 -2
  75. package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +77 -1
  76. package/dist/esm/ui/TableMenu/cell/items/MergeCellsItem.js +2 -1
  77. package/dist/esm/ui/TableMenu/cell/items/SplitCellItem.js +2 -1
  78. package/dist/esm/ui/TableMenu/cell/items/VerticalAlignDropdownItem.js +53 -0
  79. package/dist/esm/ui/TableMenu/cell/items/VerticalAlignNestedMenu.js +47 -0
  80. package/dist/esm/ui/TableMenu/cell/items/verticalAlignUtils.js +14 -0
  81. package/dist/esm/ui/TableMenu/cell/keys.js +23 -1
  82. package/dist/esm/ui/TableMenu/column/items/AddColumnLeftItem.js +3 -0
  83. package/dist/esm/ui/TableMenu/column/items/AddColumnRightItem.js +3 -0
  84. package/dist/esm/ui/TableMenu/column/items/DeleteColumnItem.js +3 -1
  85. package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +3 -0
  86. package/dist/esm/ui/TableMenu/column/items/MoveColumnLeftItem.js +3 -0
  87. package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -0
  88. package/dist/esm/ui/TableMenu/column/items/SortDecreasingItem.js +3 -0
  89. package/dist/esm/ui/TableMenu/column/items/SortIncreasingItem.js +3 -0
  90. package/dist/esm/ui/TableMenu/row/items/AddRowAboveItem.js +3 -0
  91. package/dist/esm/ui/TableMenu/row/items/AddRowBelowItem.js +3 -0
  92. package/dist/esm/ui/TableMenu/row/items/DeleteRowItem.js +3 -1
  93. package/dist/esm/ui/TableMenu/row/items/MoveRowDownItem.js +3 -0
  94. package/dist/esm/ui/TableMenu/row/items/MoveRowUpItem.js +3 -0
  95. package/dist/esm/ui/TableMenu/shared/TableMenu.js +2 -11
  96. package/dist/esm/ui/TableMenu/shared/items/BackgroundColorItem.js +4 -3
  97. package/dist/esm/ui/TableMenu/shared/items/ClearCellsItem.js +2 -1
  98. package/dist/types/pm-plugins/commands/active-table-menu.d.ts +3 -3
  99. package/dist/types/pm-plugins/commands/index.d.ts +1 -1
  100. package/dist/types/pm-plugins/commands/misc.d.ts +4 -0
  101. package/dist/types/ui/TableMenu/cell/items/VerticalAlignDropdownItem.d.ts +12 -0
  102. package/dist/types/ui/TableMenu/cell/items/VerticalAlignNestedMenu.d.ts +4 -0
  103. package/dist/types/ui/TableMenu/cell/items/verticalAlignUtils.d.ts +3 -0
  104. package/dist/types/ui/TableMenu/cell/keys.d.ts +8 -1
  105. package/dist/types-ts4.5/pm-plugins/commands/active-table-menu.d.ts +3 -3
  106. package/dist/types-ts4.5/pm-plugins/commands/index.d.ts +1 -1
  107. package/dist/types-ts4.5/pm-plugins/commands/misc.d.ts +4 -0
  108. package/dist/types-ts4.5/ui/TableMenu/cell/items/VerticalAlignDropdownItem.d.ts +12 -0
  109. package/dist/types-ts4.5/ui/TableMenu/cell/items/VerticalAlignNestedMenu.d.ts +4 -0
  110. package/dist/types-ts4.5/ui/TableMenu/cell/items/verticalAlignUtils.d.ts +3 -0
  111. package/dist/types-ts4.5/ui/TableMenu/cell/keys.d.ts +8 -1
  112. package/package.json +5 -4
  113. package/dist/cjs/ui/TableMenu/shared/TableMenu.compiled.css +0 -4
  114. package/dist/es2019/ui/TableMenu/shared/TableMenu.compiled.css +0 -4
  115. package/dist/esm/ui/TableMenu/shared/TableMenu.compiled.css +0 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 22.4.19
4
+
5
+ ### Patch Changes
6
+
7
+ - [`304fee6127fd5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/304fee6127fd5) -
8
+ Add valign to table cell menu, support renderer.
9
+ - Updated dependencies
10
+
11
+ ## 22.4.18
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 22.4.17
4
18
 
5
19
  ### Patch Changes
@@ -46,6 +46,13 @@ function delayUntilIdle(cb) {
46
46
  // Ignored via go/ees005
47
47
  // eslint-disable-next-line require-unicode-regexp
48
48
  var cssVariablePattern = /^VAR\(--.*\)$/;
49
+ var getCellDomAttrsForTableMenuUpdates = function getCellDomAttrsForTableMenuUpdates(node) {
50
+ var attrs = (0, _adfSchema.getCellDomAttrs)(node);
51
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true) && node.attrs.valign) {
52
+ attrs['data-valign'] = node.attrs.valign;
53
+ }
54
+ return attrs;
55
+ };
49
56
  var TableCell = exports.default = /*#__PURE__*/function (_TableNodeView) {
50
57
  function TableCell(node, view, getPos, eventDispatcher, editorAnalyticsAPI) {
51
58
  var _this;
@@ -179,8 +186,8 @@ var TableCell = exports.default = /*#__PURE__*/function (_TableNodeView) {
179
186
  if (this.node.type !== node.type) {
180
187
  return false;
181
188
  }
182
- var attrs = (0, _adfSchema.getCellDomAttrs)(this.node);
183
- var nextAttrs = (0, _adfSchema.getCellDomAttrs)(node);
189
+ var attrs = getCellDomAttrsForTableMenuUpdates(this.node);
190
+ var nextAttrs = getCellDomAttrsForTableMenuUpdates(node);
184
191
  var _getCellAttrs = (0, _adfSchema.getCellAttrs)(this.dom),
185
192
  colspan = _getCellAttrs.colspan,
186
193
  rowspan = _getCellAttrs.rowspan;
@@ -4,25 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.toggleActiveTableMenu = exports.closeActiveTableMenu = void 0;
7
- var _pluginFactory = require("../plugin-factory");
7
+ var _pluginKey = require("../plugin-key");
8
8
  var closeActiveTableMenu = exports.closeActiveTableMenu = function closeActiveTableMenu() {
9
- return (0, _pluginFactory.createCommand)(function (state) {
10
- var _getPluginState = (0, _pluginFactory.getPluginState)(state),
11
- activeTableMenu = _getPluginState.activeTableMenu;
12
- if (!activeTableMenu || activeTableMenu.type === 'none') {
13
- return false;
14
- }
15
- return {
9
+ return function (_ref) {
10
+ var tr = _ref.tr;
11
+ tr.setMeta(_pluginKey.pluginKey, {
16
12
  type: 'SET_ACTIVE_TABLE_MENU',
17
13
  data: {
18
14
  activeTableMenu: {
19
15
  type: 'none'
20
16
  }
21
17
  }
22
- };
23
- }, function (tr) {
24
- return tr.setMeta('addToHistory', false);
25
- });
18
+ });
19
+ if (!tr.docChanged) {
20
+ tr.setMeta('addToHistory', false);
21
+ }
22
+ return tr;
23
+ };
26
24
  };
27
25
  var isSameActiveTableMenu = function isSameActiveTableMenu(current, next) {
28
26
  if (!current || current.type !== next.type) {
@@ -33,19 +31,18 @@ var isSameActiveTableMenu = function isSameActiveTableMenu(current, next) {
33
31
  }
34
32
  return true;
35
33
  };
36
- var toggleActiveTableMenu = exports.toggleActiveTableMenu = function toggleActiveTableMenu(activeTableMenu) {
37
- return (0, _pluginFactory.createCommand)(function (state) {
38
- var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
39
- currentActiveTableMenu = _getPluginState2.activeTableMenu;
40
- return {
34
+ var toggleActiveTableMenu = exports.toggleActiveTableMenu = function toggleActiveTableMenu(activeTableMenu, currentActiveTableMenu) {
35
+ return function (_ref2) {
36
+ var tr = _ref2.tr;
37
+ tr.setMeta(_pluginKey.pluginKey, {
41
38
  type: 'SET_ACTIVE_TABLE_MENU',
42
39
  data: {
43
40
  activeTableMenu: isSameActiveTableMenu(currentActiveTableMenu, activeTableMenu) ? {
44
41
  type: 'none'
45
42
  } : activeTableMenu
46
43
  }
47
- };
48
- }, function (tr) {
49
- return tr.setMeta('addToHistory', false);
50
- });
44
+ });
45
+ tr.setMeta('addToHistory', false);
46
+ return tr;
47
+ };
51
48
  };
@@ -53,11 +53,18 @@ var toggleActiveTableMenuWithAnalytics = exports.toggleActiveTableMenuWithAnalyt
53
53
  };
54
54
  })(editorAnalyticsAPI)(function (state, dispatch) {
55
55
  if (dispatch) {
56
- (0, _activeTableMenu.toggleActiveTableMenu)({
56
+ var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
57
+ currentActiveTableMenu = _getPluginState2.activeTableMenu;
58
+ var newTr = (0, _activeTableMenu.toggleActiveTableMenu)({
57
59
  type: direction,
58
60
  index: index,
59
61
  openedBy: trigger
60
- })(state, dispatch);
62
+ }, currentActiveTableMenu)({
63
+ tr: state.tr
64
+ });
65
+ if (newTr) {
66
+ dispatch(newTr);
67
+ }
61
68
  }
62
69
  return true;
63
70
  });
@@ -227,8 +234,8 @@ var changeColumnWidthByStepWithAnalytics = exports.changeColumnWidthByStepWithAn
227
234
  table = _getSelectedTableInfo2.table,
228
235
  totalRowCount = _getSelectedTableInfo2.totalRowCount,
229
236
  totalColumnCount = _getSelectedTableInfo2.totalColumnCount;
230
- var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
231
- colIndex = _getPluginState2.hoveredCell.colIndex;
237
+ var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
238
+ colIndex = _getPluginState3.hoveredCell.colIndex;
232
239
  return {
233
240
  action: _analytics.TABLE_ACTION.COLUMN_RESIZED,
234
241
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
@@ -348,8 +355,8 @@ var deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = exports.deleteSelected
348
355
  }
349
356
  var selectionType = (0, _misc.getTableSelectionType)(selection);
350
357
  if (selectionType === 'row') {
351
- var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
352
- pluginConfig = _getPluginState3.pluginConfig;
358
+ var _getPluginState4 = (0, _pluginFactory.getPluginState)(state),
359
+ pluginConfig = _getPluginState4.pluginConfig;
353
360
  var isHeaderRowRequired = pluginConfig.isHeaderRowRequired || false;
354
361
  return deleteRowsWithAnalytics(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT, rect, isHeaderRowRequired)(state, dispatch);
355
362
  } else if (selectionType === 'column') {
@@ -393,8 +400,8 @@ var toggleHeaderRowWithAnalytics = exports.toggleHeaderRowWithAnalytics = functi
393
400
  var _getSelectedTableInfo7 = (0, _analytics2.getSelectedTableInfo)(state.selection),
394
401
  totalRowCount = _getSelectedTableInfo7.totalRowCount,
395
402
  totalColumnCount = _getSelectedTableInfo7.totalColumnCount;
396
- var _getPluginState4 = (0, _pluginFactory.getPluginState)(state),
397
- isHeaderRowEnabled = _getPluginState4.isHeaderRowEnabled;
403
+ var _getPluginState5 = (0, _pluginFactory.getPluginState)(state),
404
+ isHeaderRowEnabled = _getPluginState5.isHeaderRowEnabled;
398
405
  return {
399
406
  action: _analytics.TABLE_ACTION.TOGGLED_HEADER_ROW,
400
407
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
@@ -413,8 +420,8 @@ var toggleHeaderColumnWithAnalytics = exports.toggleHeaderColumnWithAnalytics =
413
420
  var _getSelectedTableInfo8 = (0, _analytics2.getSelectedTableInfo)(state.selection),
414
421
  totalRowCount = _getSelectedTableInfo8.totalRowCount,
415
422
  totalColumnCount = _getSelectedTableInfo8.totalColumnCount;
416
- var _getPluginState5 = (0, _pluginFactory.getPluginState)(state),
417
- isHeaderColumnEnabled = _getPluginState5.isHeaderColumnEnabled;
423
+ var _getPluginState6 = (0, _pluginFactory.getPluginState)(state),
424
+ isHeaderColumnEnabled = _getPluginState6.isHeaderColumnEnabled;
418
425
  return {
419
426
  action: _analytics.TABLE_ACTION.TOGGLED_HEADER_COLUMN,
420
427
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
@@ -183,6 +183,12 @@ Object.defineProperty(exports, "setMultipleCellAttrs", {
183
183
  return _misc.setMultipleCellAttrs;
184
184
  }
185
185
  });
186
+ Object.defineProperty(exports, "setMultipleCellAttrsEditorCommand", {
187
+ enumerable: true,
188
+ get: function get() {
189
+ return _misc.setMultipleCellAttrsEditorCommand;
190
+ }
191
+ });
186
192
  Object.defineProperty(exports, "setTableDisplayMode", {
187
193
  enumerable: true,
188
194
  get: function get() {
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.updateWidthToWidest = exports.updateResizeHandleDecorations = exports.triggerUnlessTableHeader = exports.transformSliceToRemoveColumnsWidths = exports.transformSliceToFixDarkModeDefaultBackgroundColor = exports.transformSliceToAddTableHeaders = exports.transformSliceRemoveCellBackgroundColor = exports.showInsertRowButton = exports.showInsertColumnButton = exports.setTableRef = exports.setTableAlignmentWithTableContentWithPos = exports.setTableAlignment = exports.setMultipleCellAttrs = exports.setFocusToCellMenu = exports.setEditorFocus = exports.setCellAttr = exports.selectRows = exports.selectRow = exports.selectColumns = exports.selectColumn = exports.removeResizeHandleDecorations = exports.moveCursorBackward = exports.isInsideFirstCellOfRowOrColumn = exports.hideInsertColumnOrRowButton = exports.getTableSelectionType = exports.getTableElementMoveTypeBySlice = exports.deleteTableIfSelected = exports.deleteTable = exports.countCellsInSlice = exports.convertFirstRowToHeader = exports.autoSizeTable = exports.addResizeHandleDecorations = exports.addBoldInEmptyHeaderCells = void 0;
7
+ exports.updateWidthToWidest = exports.updateResizeHandleDecorations = exports.triggerUnlessTableHeader = exports.transformSliceToRemoveColumnsWidths = exports.transformSliceToFixDarkModeDefaultBackgroundColor = exports.transformSliceToAddTableHeaders = exports.transformSliceRemoveCellBackgroundColor = exports.showInsertRowButton = exports.showInsertColumnButton = exports.setTableRef = exports.setTableAlignmentWithTableContentWithPos = exports.setTableAlignment = exports.setMultipleCellAttrsEditorCommand = exports.setMultipleCellAttrs = exports.setFocusToCellMenu = exports.setEditorFocus = exports.setCellAttr = exports.selectRows = exports.selectRow = exports.selectColumns = exports.selectColumn = exports.removeResizeHandleDecorations = exports.moveCursorBackward = exports.isInsideFirstCellOfRowOrColumn = exports.hideInsertColumnOrRowButton = exports.getTableSelectionType = exports.getTableElementMoveTypeBySlice = exports.deleteTableIfSelected = exports.deleteTable = exports.countCellsInSlice = exports.convertFirstRowToHeader = exports.autoSizeTable = exports.addResizeHandleDecorations = exports.addBoldInEmptyHeaderCells = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
@@ -365,6 +365,38 @@ var setMultipleCellAttrs = exports.setMultipleCellAttrs = function setMultipleCe
365
365
  return false;
366
366
  };
367
367
  };
368
+
369
+ /**
370
+ * EditorCommand variant of `setMultipleCellAttrs`.
371
+ */
372
+ var setMultipleCellAttrsEditorCommand = exports.setMultipleCellAttrsEditorCommand = function setMultipleCellAttrsEditorCommand(attrs, targetCellPosition) {
373
+ return function (_ref2) {
374
+ var tr = _ref2.tr;
375
+ var cursorPos;
376
+ if ((0, _utils2.isSelectionType)(tr.selection, 'cell')) {
377
+ // Ignored via go/ees005
378
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
379
+ var selection = tr.selection;
380
+ selection.forEachCell(function (_cell, pos) {
381
+ var $pos = tr.doc.resolve(tr.mapping.map(pos + 1));
382
+ // Ignored via go/ees005
383
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
384
+ (0, _utils2.setCellAttrs)((0, _utils2.findCellClosestToPos)($pos), attrs)(tr);
385
+ });
386
+ cursorPos = selection.$headCell.pos;
387
+ } else if (typeof targetCellPosition === 'number') {
388
+ // Ignored via go/ees005
389
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
390
+ var cell = (0, _utils2.findCellClosestToPos)(tr.doc.resolve(targetCellPosition + 1));
391
+ (0, _utils2.setCellAttrs)(cell, attrs)(tr);
392
+ cursorPos = cell.pos;
393
+ }
394
+ if (tr.docChanged && cursorPos !== undefined) {
395
+ return tr;
396
+ }
397
+ return null;
398
+ };
399
+ };
368
400
  var selectColumn = exports.selectColumn = function selectColumn(column, expand) {
369
401
  var triggeredByKeyboard = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
370
402
  return (0, _pluginFactory.createCommand)(function (state) {
@@ -616,8 +648,8 @@ var updateWidthToWidest = exports.updateWidthToWidest = function updateWidthToWi
616
648
  });
617
649
  };
618
650
  var setTableAlignment = exports.setTableAlignment = function setTableAlignment(newAlignment, isCommentEditor) {
619
- return function (_ref2) {
620
- var tr = _ref2.tr;
651
+ return function (_ref3) {
652
+ var tr = _ref3.tr;
621
653
  var tableObject = (0, _utils2.findTable)(tr.selection);
622
654
  if (!tableObject) {
623
655
  return null;
@@ -639,8 +671,8 @@ var setTableAlignment = exports.setTableAlignment = function setTableAlignment(n
639
671
  };
640
672
  };
641
673
  var setTableAlignmentWithTableContentWithPos = exports.setTableAlignmentWithTableContentWithPos = function setTableAlignmentWithTableContentWithPos(newAlignment, tableNodeWithPos) {
642
- return function (_ref3) {
643
- var tr = _ref3.tr;
674
+ return function (_ref4) {
675
+ var tr = _ref4.tr;
644
676
  var table = tableNodeWithPos.node;
645
677
  var nextTableAttrs = _objectSpread(_objectSpread({}, table.attrs), {}, {
646
678
  layout: newAlignment
@@ -88,19 +88,30 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI, isTableScalin
88
88
  return localId === (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId);
89
89
  },
90
90
  onDragStart: function onDragStart() {
91
- var _api$userIntent;
92
91
  if ((0, _expValEquals.expValEquals)('cc_editor_interactivity_monitoring', 'isEnabled', true)) {
93
92
  var _insm$session3;
94
93
  (_insm$session3 = _insm.insm.session) === null || _insm$session3 === void 0 || _insm$session3.startFeature('tableDragAndDrop');
95
94
  }
96
- (0, _commands.toggleDragMenu)(false)(editorView.state, editorView.dispatch);
97
95
  if ((0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true)) {
98
- (0, _activeTableMenu.closeActiveTableMenu)()(editorView.state, editorView.dispatch);
96
+ api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
97
+ var _api$userIntent;
98
+ var tr = _ref7.tr;
99
+ (0, _activeTableMenu.closeActiveTableMenu)()({
100
+ tr: tr
101
+ });
102
+ api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || _api$userIntent.commands.setCurrentUserIntent('dragging')({
103
+ tr: tr
104
+ });
105
+ return tr;
106
+ });
107
+ } else {
108
+ var _api$userIntent2;
109
+ (0, _commands.toggleDragMenu)(false)(editorView.state, editorView.dispatch);
110
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('dragging'));
99
111
  }
100
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('dragging'));
101
112
  },
102
113
  onDrag: function onDrag(event) {
103
- var _api$userIntent2;
114
+ var _api$userIntent3;
104
115
  var data = (0, _monitor.getDraggableDataFromEvent)(event);
105
116
  // If no data can be found then it's most like we do not want to perform any drag actions
106
117
  if (!data) {
@@ -115,10 +126,10 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI, isTableScalin
115
126
  var dropTargetType = sourceType === 'table-row' ? _consts.DropTargetType.ROW : _consts.DropTargetType.COLUMN;
116
127
  var hasMergedCells = (0, _mergedCells.hasMergedCellsInBetween)([targetAdjustedIndex - 1, targetAdjustedIndex], dropTargetType)(editorView.state.selection);
117
128
  (0, _commands.setDropTarget)(dropTargetType, targetAdjustedIndex, hasMergedCells)(editorView.state, editorView.dispatch);
118
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('dragging'));
129
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent3 = api.userIntent) === null || _api$userIntent3 === void 0 ? void 0 : _api$userIntent3.commands.setCurrentUserIntent('dragging'));
119
130
  },
120
131
  onDrop: function onDrop(event) {
121
- var _cell$row, _cell$col, _api$userIntent3;
132
+ var _cell$row, _cell$col, _api$userIntent4;
122
133
  var data = (0, _monitor.getDraggableDataFromEvent)(event);
123
134
 
124
135
  // On Drop we need to update the table main plugin hoveredCell value with the current row/col that the mouse is
@@ -141,9 +152,9 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI, isTableScalin
141
152
  }
142
153
  };
143
154
  tr.setMeta(_pluginKey.pluginKey, action);
144
- if ((api === null || api === void 0 || (_api$userIntent3 = api.userIntent) === null || _api$userIntent3 === void 0 || (_api$userIntent3 = _api$userIntent3.sharedState.currentState()) === null || _api$userIntent3 === void 0 ? void 0 : _api$userIntent3.currentUserIntent) === 'dragging') {
145
- var _api$userIntent4;
146
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent4 = api.userIntent) === null || _api$userIntent4 === void 0 ? void 0 : _api$userIntent4.commands.setCurrentUserIntent('default'));
155
+ if ((api === null || api === void 0 || (_api$userIntent4 = api.userIntent) === null || _api$userIntent4 === void 0 || (_api$userIntent4 = _api$userIntent4.sharedState.currentState()) === null || _api$userIntent4 === void 0 ? void 0 : _api$userIntent4.currentUserIntent) === 'dragging') {
156
+ var _api$userIntent5;
157
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent5 = api.userIntent) === null || _api$userIntent5 === void 0 ? void 0 : _api$userIntent5.commands.setCurrentUserIntent('default'));
147
158
  }
148
159
  // If no data can be found then it's most like we do not want to perform any drop action
149
160
  if (!data) {
@@ -304,7 +315,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, editor
304
315
  return decorationSet;
305
316
  },
306
317
  handleKeyDown: function handleKeyDown(view, event) {
307
- var _ref7;
318
+ var _ref8;
308
319
  var tr = view.state.tr;
309
320
  var keysToTrapWhen = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
310
321
 
@@ -328,7 +339,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, editor
328
339
  var isDragHandleFocused = ['drag-handle-button-row', 'drag-handle-button-column'
329
340
  // Ignored via go/ees005
330
341
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
331
- ].includes((_ref7 = event.target || null) === null || _ref7 === void 0 ? void 0 : _ref7.id);
342
+ ].includes((_ref8 = event.target || null) === null || _ref8 === void 0 ? void 0 : _ref8.id);
332
343
  var keysToTrap = ['Enter', ' '];
333
344
  var _getPluginState3 = (0, _pluginFactory2.getPluginState)(view.state),
334
345
  _getPluginState3$isDr = _getPluginState3.isDragMenuOpen,
@@ -22,6 +22,7 @@ var _utils = require("@atlaskit/editor-prosemirror/utils");
22
22
  var _pmPlugins = require("@atlaskit/editor-tables/pm-plugins");
23
23
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
24
24
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
25
+ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
25
26
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
26
27
  var _toDOM = require("./nodeviews/toDOM");
27
28
  var _plugin = require("./pm-plugins/active-cell-highlight/plugin");
@@ -258,13 +259,13 @@ var tablePlugin = function tablePlugin(_ref) {
258
259
  })
259
260
  }, {
260
261
  name: 'tableHeader',
261
- node: (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.tableHeaderWithNestedTableWithLocalId : _adfSchema.tableHeaderWithNestedTable
262
+ node: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_table_menu_updates', 'isEnabled', true) ? _adfSchema.tableHeaderWithNestedTableStage0 : (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.tableHeaderWithNestedTableWithLocalId : _adfSchema.tableHeaderWithNestedTable
262
263
  }, {
263
264
  name: 'tableRow',
264
265
  node: (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.tableRowWithNestedTableWithLocalId : _adfSchema.tableRowWithNestedTable
265
266
  }, {
266
267
  name: 'tableCell',
267
- node: (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.tableCellWithNestedTableWithLocalId : _adfSchema.tableCellWithNestedTable
268
+ node: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_table_menu_updates', 'isEnabled', true) ? _adfSchema.tableCellWithNestedTableStage0 : (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.tableCellWithNestedTableWithLocalId : _adfSchema.tableCellWithNestedTable
268
269
  }] : [{
269
270
  name: 'table',
270
271
  node: (0, _toDOM.tableNodeSpecWithFixedToDOM)({
@@ -279,13 +280,13 @@ var tablePlugin = function tablePlugin(_ref) {
279
280
  })
280
281
  }, {
281
282
  name: 'tableHeader',
282
- node: (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.tableHeaderWithLocalId : _adfSchema.tableHeader
283
+ node: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_table_menu_updates', 'isEnabled', true) ? _adfSchema.tableHeaderStage0 : (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.tableHeaderWithLocalId : _adfSchema.tableHeader
283
284
  }, {
284
285
  name: 'tableRow',
285
286
  node: (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.tableRowWithLocalId : _adfSchema.tableRow
286
287
  }, {
287
288
  name: 'tableCell',
288
- node: (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.tableCellWithLocalId : _adfSchema.tableCell
289
+ node: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_table_menu_updates', 'isEnabled', true) ? _adfSchema.tableCellStage0 : (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.tableCellWithLocalId : _adfSchema.tableCell
289
290
  }];
290
291
  },
291
292
  pmPlugins: function pmPlugins() {
@@ -22,6 +22,7 @@ var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/core/chevron-d
22
22
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
23
23
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
24
24
  var _commands = require("../../pm-plugins/commands");
25
+ var _pluginFactory = require("../../pm-plugins/plugin-factory");
25
26
  var _stickyHeader = require("../../pm-plugins/utils/sticky-header");
26
27
  var _types = require("../../types");
27
28
  var _FixedButton = _interopRequireDefault(require("./FixedButton"));
@@ -67,10 +68,21 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
67
68
  var state = editorView.state,
68
69
  dispatch = editorView.dispatch;
69
70
  if ((0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true)) {
70
- (0, _commands.toggleActiveTableMenu)({
71
- type: 'cell',
72
- openedBy: 'mouse'
73
- })(state, dispatch);
71
+ if (!api) {
72
+ return;
73
+ }
74
+ var _getPluginState = (0, _pluginFactory.getPluginState)(state),
75
+ currentActiveTableMenu = _getPluginState.activeTableMenu;
76
+ api.core.actions.execute(function (_ref) {
77
+ var tr = _ref.tr;
78
+ (0, _commands.toggleActiveTableMenu)({
79
+ type: 'cell',
80
+ openedBy: 'mouse'
81
+ }, currentActiveTableMenu)({
82
+ tr: tr
83
+ });
84
+ return tr;
85
+ });
74
86
  return;
75
87
  }
76
88
 
@@ -91,15 +103,26 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
91
103
  dispatch = editorView.dispatch;
92
104
  // open the menu when the keyboard shortcut is pressed
93
105
  if ((0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true)) {
94
- (0, _commands.toggleActiveTableMenu)({
95
- type: 'cell',
96
- openedBy: 'keyboard'
97
- })(state, dispatch);
106
+ if (!api) {
107
+ return;
108
+ }
109
+ var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
110
+ currentActiveTableMenu = _getPluginState2.activeTableMenu;
111
+ api.core.actions.execute(function (_ref2) {
112
+ var tr = _ref2.tr;
113
+ (0, _commands.toggleActiveTableMenu)({
114
+ type: 'cell',
115
+ openedBy: 'keyboard'
116
+ }, currentActiveTableMenu)({
117
+ tr: tr
118
+ });
119
+ return tr;
120
+ });
98
121
  return;
99
122
  }
100
123
  (0, _commands.toggleContextualMenu)()(state, dispatch);
101
124
  }
102
- }, [isCellMenuOpenByKeyboard, isCellMenuOpen, editorView]);
125
+ }, [isCellMenuOpenByKeyboard, isCellMenuOpen, editorView, api]);
103
126
  if (!targetCellRef || !(targetCellRef instanceof HTMLElement)) {
104
127
  return null;
105
128
  }
@@ -37,11 +37,11 @@ var CellMenuPopup = exports.CellMenuPopup = function CellMenuPopup(_ref) {
37
37
  var closeCellMenu = (0, _react.useCallback)(function () {
38
38
  var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
39
39
  isCellMenuOpenByKeyboard = _getPluginState.isCellMenuOpenByKeyboard;
40
- (0, _commands.closeActiveTableMenu)()(editorView.state, editorView.dispatch);
40
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
41
41
  if (isCellMenuOpenByKeyboard) {
42
42
  (0, _commands.setFocusToCellMenu)(false)(editorView.state, editorView.dispatch);
43
43
  }
44
- }, [editorView]);
44
+ }, [api === null || api === void 0 ? void 0 : api.core.actions, editorView]);
45
45
  var isEventInsideCellMenu = (0, _react.useCallback)(function (event) {
46
46
  var _popupContentRef$curr;
47
47
  var target = event.target;
@@ -6,9 +6,15 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getCellMenuComponents = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _messages = require("@atlaskit/editor-common/messages");
9
10
  var _editorToolbar = require("@atlaskit/editor-toolbar");
11
+ var _alignPositionBottom = _interopRequireDefault(require("@atlaskit/icon-lab/core/align-position-bottom"));
12
+ var _alignPositionCenterVertical = _interopRequireDefault(require("@atlaskit/icon-lab/core/align-position-center-vertical"));
13
+ var _alignPositionTop = _interopRequireDefault(require("@atlaskit/icon-lab/core/align-position-top"));
10
14
  var _MergeCellsItem = require("./items/MergeCellsItem");
11
15
  var _SplitCellItem = require("./items/SplitCellItem");
16
+ var _VerticalAlignDropdownItem = require("./items/VerticalAlignDropdownItem");
17
+ var _VerticalAlignNestedMenu = require("./items/VerticalAlignNestedMenu");
12
18
  var _keys = require("./keys");
13
19
  var getCellMenuComponents = exports.getCellMenuComponents = function getCellMenuComponents(_ref) {
14
20
  var api = _ref.api;
@@ -30,6 +36,76 @@ var getCellMenuComponents = exports.getCellMenuComponents = function getCellMenu
30
36
  component: function component(props) {
31
37
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, null, props.children);
32
38
  }
39
+ }, {
40
+ type: _keys.VERTICAL_ALIGN_MENU.type,
41
+ key: _keys.VERTICAL_ALIGN_MENU.key,
42
+ parents: [{
43
+ type: _keys.CELL_ACTION_SECTION.type,
44
+ key: _keys.CELL_ACTION_SECTION.key,
45
+ rank: _keys.CELL_ACTION_SECTION_RANK[_keys.VERTICAL_ALIGN_MENU.key]
46
+ }],
47
+ component: function component(props) {
48
+ return /*#__PURE__*/_react.default.createElement(_VerticalAlignNestedMenu.VerticalAlignNestedMenu, null, props.children);
49
+ }
50
+ }, {
51
+ type: _keys.VERTICAL_ALIGN_MENU_SECTION.type,
52
+ key: _keys.VERTICAL_ALIGN_MENU_SECTION.key,
53
+ parents: [{
54
+ type: _keys.VERTICAL_ALIGN_MENU.type,
55
+ key: _keys.VERTICAL_ALIGN_MENU.key,
56
+ rank: _keys.VERTICAL_ALIGN_MENU_RANK[_keys.VERTICAL_ALIGN_MENU_SECTION.key]
57
+ }],
58
+ component: function component(props) {
59
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, null, props.children);
60
+ }
61
+ }, {
62
+ type: _keys.VERTICAL_ALIGN_TOP_ITEM.type,
63
+ key: _keys.VERTICAL_ALIGN_TOP_ITEM.key,
64
+ parents: [{
65
+ type: _keys.VERTICAL_ALIGN_MENU_SECTION.type,
66
+ key: _keys.VERTICAL_ALIGN_MENU_SECTION.key,
67
+ rank: _keys.VERTICAL_ALIGN_MENU_SECTION_RANK[_keys.VERTICAL_ALIGN_TOP_ITEM.key]
68
+ }],
69
+ component: function component() {
70
+ return /*#__PURE__*/_react.default.createElement(_VerticalAlignDropdownItem.VerticalAlignDropdownItem, {
71
+ api: api,
72
+ icon: _alignPositionTop.default,
73
+ label: _messages.tableMessages.cellAlignmentTop,
74
+ value: "top"
75
+ });
76
+ }
77
+ }, {
78
+ type: _keys.VERTICAL_ALIGN_MIDDLE_ITEM.type,
79
+ key: _keys.VERTICAL_ALIGN_MIDDLE_ITEM.key,
80
+ parents: [{
81
+ type: _keys.VERTICAL_ALIGN_MENU_SECTION.type,
82
+ key: _keys.VERTICAL_ALIGN_MENU_SECTION.key,
83
+ rank: _keys.VERTICAL_ALIGN_MENU_SECTION_RANK[_keys.VERTICAL_ALIGN_MIDDLE_ITEM.key]
84
+ }],
85
+ component: function component() {
86
+ return /*#__PURE__*/_react.default.createElement(_VerticalAlignDropdownItem.VerticalAlignDropdownItem, {
87
+ api: api,
88
+ icon: _alignPositionCenterVertical.default,
89
+ label: _messages.tableMessages.cellAlignmentMiddle,
90
+ value: "middle"
91
+ });
92
+ }
93
+ }, {
94
+ type: _keys.VERTICAL_ALIGN_BOTTOM_ITEM.type,
95
+ key: _keys.VERTICAL_ALIGN_BOTTOM_ITEM.key,
96
+ parents: [{
97
+ type: _keys.VERTICAL_ALIGN_MENU_SECTION.type,
98
+ key: _keys.VERTICAL_ALIGN_MENU_SECTION.key,
99
+ rank: _keys.VERTICAL_ALIGN_MENU_SECTION_RANK[_keys.VERTICAL_ALIGN_BOTTOM_ITEM.key]
100
+ }],
101
+ component: function component() {
102
+ return /*#__PURE__*/_react.default.createElement(_VerticalAlignDropdownItem.VerticalAlignDropdownItem, {
103
+ api: api,
104
+ icon: _alignPositionBottom.default,
105
+ label: _messages.tableMessages.cellAlignmentBottom,
106
+ value: "bottom"
107
+ });
108
+ }
33
109
  }, {
34
110
  type: _keys.MERGE_CELLS_ITEM.type,
35
111
  key: _keys.MERGE_CELLS_ITEM.key,
@@ -33,7 +33,8 @@ var MergeCellsItem = exports.MergeCellsItem = function MergeCellsItem(_ref) {
33
33
  return;
34
34
  }
35
35
  (0, _commandsWithAnalytics.mergeCellsWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.CONTEXT_MENU)(editorView.state, editorView.dispatch);
36
- (0, _commands.closeActiveTableMenu)()(editorView.state, editorView.dispatch);
36
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
37
+ api === null || api === void 0 || api.core.actions.focus();
37
38
  };
38
39
  if (!shouldShowMergeCells(tableMenuContext)) {
39
40
  return null;
@@ -33,7 +33,8 @@ var SplitCellItem = exports.SplitCellItem = function SplitCellItem(_ref) {
33
33
  return;
34
34
  }
35
35
  (0, _commandsWithAnalytics.splitCellWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.CONTEXT_MENU)(editorView.state, editorView.dispatch);
36
- (0, _commands.closeActiveTableMenu)()(editorView.state, editorView.dispatch);
36
+ api === null || api === void 0 || api.core.actions.execute((0, _commands.closeActiveTableMenu)());
37
+ api === null || api === void 0 || api.core.actions.focus();
37
38
  };
38
39
  if (!shouldShowSplitCell(tableMenuContext)) {
39
40
  return null;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.VerticalAlignDropdownItem = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactIntl = require("react-intl");
10
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
11
+ var _commands = require("../../../../pm-plugins/commands");
12
+ var _pluginFactory = require("../../../../pm-plugins/plugin-factory");
13
+ var _TableMenuContext = require("../../shared/TableMenuContext");
14
+ var _verticalAlignUtils = require("./verticalAlignUtils");
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
16
+ var VerticalAlignDropdownItem = exports.VerticalAlignDropdownItem = function VerticalAlignDropdownItem(_ref) {
17
+ var _useTableMenuContext;
18
+ var api = _ref.api,
19
+ Icon = _ref.icon,
20
+ label = _ref.label,
21
+ value = _ref.value;
22
+ var _ref2 = (_useTableMenuContext = (0, _TableMenuContext.useTableMenuContext)()) !== null && _useTableMenuContext !== void 0 ? _useTableMenuContext : {},
23
+ editorView = _ref2.editorView;
24
+ var _useIntl = (0, _reactIntl.useIntl)(),
25
+ formatMessage = _useIntl.formatMessage;
26
+ var selectedValign = (0, _react.useMemo)(function () {
27
+ return (0, _verticalAlignUtils.getSelectedCellValign)(editorView);
28
+ }, [editorView]);
29
+ var handleClick = (0, _react.useCallback)(function () {
30
+ if (!editorView || !api) {
31
+ return;
32
+ }
33
+ var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
34
+ targetCellPosition = _getPluginState.targetCellPosition;
35
+ api.core.actions.execute(function (_ref3) {
36
+ var tr = _ref3.tr;
37
+ (0, _commands.setMultipleCellAttrsEditorCommand)({
38
+ valign: value
39
+ }, targetCellPosition)({
40
+ tr: tr
41
+ });
42
+ (0, _commands.closeActiveTableMenu)()({
43
+ tr: tr
44
+ });
45
+ return tr;
46
+ });
47
+ api.core.actions.focus();
48
+ }, [api, editorView, value]);
49
+ if (!editorView) {
50
+ return null;
51
+ }
52
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
53
+ elemBefore: /*#__PURE__*/_react.default.createElement(Icon, {
54
+ color: "currentColor",
55
+ label: "",
56
+ size: "small"
57
+ }),
58
+ isSelected: selectedValign === value,
59
+ onClick: handleClick
60
+ }, formatMessage(label));
61
+ };