@atlaskit/editor-core 172.3.2 → 173.0.0

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 (189) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/cjs/index.js +0 -6
  3. package/dist/cjs/plugins/base/index.js +8 -0
  4. package/dist/cjs/plugins/base/pm-plugins/composition.js +60 -0
  5. package/dist/cjs/plugins/breakout/index.js +5 -4
  6. package/dist/cjs/plugins/breakout/ui/LayoutButton.js +1 -3
  7. package/dist/cjs/plugins/card/pm-plugins/doc.js +8 -1
  8. package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +2 -36
  9. package/dist/cjs/plugins/collab-edit/plugin-state.js +16 -9
  10. package/dist/cjs/plugins/collab-edit/utils.js +16 -2
  11. package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
  12. package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +20 -15
  13. package/dist/cjs/plugins/floating-toolbar/ui/DropdownMenu.js +8 -5
  14. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +3 -3
  15. package/dist/cjs/plugins/paste/actions.js +13 -0
  16. package/dist/cjs/plugins/paste/commands.js +44 -0
  17. package/dist/cjs/plugins/paste/handlers.js +48 -7
  18. package/dist/cjs/plugins/paste/index.js +3 -2
  19. package/dist/cjs/plugins/paste/pm-plugins/main.js +34 -9
  20. package/dist/cjs/plugins/paste/pm-plugins/plugin-factory.js +62 -0
  21. package/dist/cjs/plugins/paste/reducer.js +47 -0
  22. package/dist/cjs/plugins/paste/types.js +5 -0
  23. package/dist/cjs/plugins/placeholder/index.js +3 -1
  24. package/dist/cjs/plugins/placeholder-text/index.js +9 -3
  25. package/dist/cjs/plugins/status/ui/statusPicker.js +4 -1
  26. package/dist/cjs/plugins/table/commands-with-analytics.js +59 -52
  27. package/dist/cjs/plugins/table/index.js +53 -36
  28. package/dist/cjs/plugins/table/toolbar.js +136 -20
  29. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  30. package/dist/cjs/plugins/tasks-and-decisions/commands.js +1 -16
  31. package/dist/cjs/plugins/type-ahead/constants.js +3 -1
  32. package/dist/cjs/plugins/type-ahead/messages.js +16 -1
  33. package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +1 -1
  34. package/dist/cjs/plugins/type-ahead/pm-plugins/reducer.js +2 -2
  35. package/dist/cjs/plugins/type-ahead/ui/AssistiveText.js +143 -0
  36. package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +59 -11
  37. package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +156 -31
  38. package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +55 -29
  39. package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
  40. package/dist/cjs/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
  41. package/dist/cjs/plugins/type-ahead/utils.js +1 -1
  42. package/dist/cjs/ui/MediaAndEmbedsToolbar/index.js +8 -0
  43. package/dist/cjs/ui/PortalProvider/PortalProviderThemesProvider.js +2 -6
  44. package/dist/cjs/ui/PortalProvider/index.js +26 -32
  45. package/dist/cjs/utils/index.js +8 -1
  46. package/dist/cjs/version-wrapper.js +1 -1
  47. package/dist/cjs/version.json +1 -1
  48. package/dist/es2019/index.js +1 -1
  49. package/dist/es2019/plugins/base/index.js +5 -0
  50. package/dist/es2019/plugins/base/pm-plugins/composition.js +45 -0
  51. package/dist/es2019/plugins/breakout/index.js +5 -4
  52. package/dist/es2019/plugins/breakout/ui/LayoutButton.js +1 -3
  53. package/dist/es2019/plugins/card/pm-plugins/doc.js +10 -1
  54. package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +3 -40
  55. package/dist/es2019/plugins/collab-edit/plugin-state.js +9 -3
  56. package/dist/es2019/plugins/collab-edit/utils.js +17 -3
  57. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
  58. package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +15 -7
  59. package/dist/es2019/plugins/floating-toolbar/ui/DropdownMenu.js +9 -5
  60. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +3 -3
  61. package/dist/es2019/plugins/paste/actions.js +6 -0
  62. package/dist/es2019/plugins/paste/commands.js +27 -0
  63. package/dist/es2019/plugins/paste/handlers.js +50 -8
  64. package/dist/es2019/plugins/paste/index.js +3 -2
  65. package/dist/es2019/plugins/paste/pm-plugins/main.js +29 -6
  66. package/dist/es2019/plugins/paste/pm-plugins/plugin-factory.js +33 -0
  67. package/dist/es2019/plugins/paste/reducer.js +24 -0
  68. package/dist/es2019/plugins/paste/types.js +1 -0
  69. package/dist/es2019/plugins/placeholder/index.js +2 -1
  70. package/dist/es2019/plugins/placeholder-text/index.js +13 -3
  71. package/dist/es2019/plugins/status/ui/statusPicker.js +5 -1
  72. package/dist/es2019/plugins/table/commands-with-analytics.js +6 -3
  73. package/dist/es2019/plugins/table/index.js +22 -4
  74. package/dist/es2019/plugins/table/toolbar.js +118 -14
  75. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  76. package/dist/es2019/plugins/tasks-and-decisions/commands.js +0 -9
  77. package/dist/es2019/plugins/type-ahead/constants.js +1 -0
  78. package/dist/es2019/plugins/type-ahead/messages.js +16 -1
  79. package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +1 -1
  80. package/dist/es2019/plugins/type-ahead/pm-plugins/reducer.js +2 -2
  81. package/dist/es2019/plugins/type-ahead/ui/AssistiveText.js +95 -0
  82. package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +49 -12
  83. package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +143 -29
  84. package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +64 -31
  85. package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
  86. package/dist/es2019/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
  87. package/dist/es2019/plugins/type-ahead/utils.js +1 -1
  88. package/dist/es2019/ui/MediaAndEmbedsToolbar/index.js +17 -0
  89. package/dist/es2019/ui/PortalProvider/PortalProviderThemesProvider.js +2 -5
  90. package/dist/es2019/ui/PortalProvider/index.js +5 -8
  91. package/dist/es2019/utils/index.js +6 -0
  92. package/dist/es2019/version-wrapper.js +1 -1
  93. package/dist/es2019/version.json +1 -1
  94. package/dist/esm/index.js +1 -1
  95. package/dist/esm/plugins/base/index.js +7 -0
  96. package/dist/esm/plugins/base/pm-plugins/composition.js +45 -0
  97. package/dist/esm/plugins/breakout/index.js +5 -4
  98. package/dist/esm/plugins/breakout/ui/LayoutButton.js +1 -3
  99. package/dist/esm/plugins/card/pm-plugins/doc.js +8 -1
  100. package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +3 -37
  101. package/dist/esm/plugins/collab-edit/plugin-state.js +9 -3
  102. package/dist/esm/plugins/collab-edit/utils.js +17 -3
  103. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
  104. package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +20 -15
  105. package/dist/esm/plugins/floating-toolbar/ui/DropdownMenu.js +8 -5
  106. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +3 -3
  107. package/dist/esm/plugins/paste/actions.js +6 -0
  108. package/dist/esm/plugins/paste/commands.js +31 -0
  109. package/dist/esm/plugins/paste/handlers.js +46 -8
  110. package/dist/esm/plugins/paste/index.js +3 -2
  111. package/dist/esm/plugins/paste/pm-plugins/main.js +27 -6
  112. package/dist/esm/plugins/paste/pm-plugins/plugin-factory.js +46 -0
  113. package/dist/esm/plugins/paste/reducer.js +34 -0
  114. package/dist/esm/plugins/paste/types.js +1 -0
  115. package/dist/esm/plugins/placeholder/index.js +2 -1
  116. package/dist/esm/plugins/placeholder-text/index.js +9 -3
  117. package/dist/esm/plugins/status/ui/statusPicker.js +4 -1
  118. package/dist/esm/plugins/table/commands-with-analytics.js +56 -49
  119. package/dist/esm/plugins/table/index.js +54 -37
  120. package/dist/esm/plugins/table/toolbar.js +124 -15
  121. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  122. package/dist/esm/plugins/tasks-and-decisions/commands.js +0 -12
  123. package/dist/esm/plugins/type-ahead/constants.js +1 -0
  124. package/dist/esm/plugins/type-ahead/messages.js +16 -1
  125. package/dist/esm/plugins/type-ahead/pm-plugins/main.js +1 -1
  126. package/dist/esm/plugins/type-ahead/pm-plugins/reducer.js +2 -2
  127. package/dist/esm/plugins/type-ahead/ui/AssistiveText.js +129 -0
  128. package/dist/esm/plugins/type-ahead/ui/InputQuery.js +56 -12
  129. package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +151 -32
  130. package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +54 -31
  131. package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
  132. package/dist/esm/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
  133. package/dist/esm/plugins/type-ahead/utils.js +1 -1
  134. package/dist/esm/ui/MediaAndEmbedsToolbar/index.js +7 -0
  135. package/dist/esm/ui/PortalProvider/PortalProviderThemesProvider.js +2 -5
  136. package/dist/esm/ui/PortalProvider/index.js +26 -35
  137. package/dist/esm/utils/index.js +4 -0
  138. package/dist/esm/version-wrapper.js +1 -1
  139. package/dist/esm/version.json +1 -1
  140. package/dist/types/index.d.ts +1 -1
  141. package/dist/types/plugins/base/pm-plugins/composition.d.ts +8 -0
  142. package/dist/types/plugins/code-block/pm-plugins/ide-ux.d.ts +1 -4
  143. package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +2 -0
  144. package/dist/types/plugins/floating-toolbar/ui/DropdownMenu.d.ts +1 -0
  145. package/dist/types/plugins/paste/actions.d.ts +15 -0
  146. package/dist/types/plugins/paste/commands.d.ts +16 -0
  147. package/dist/types/plugins/paste/handlers.d.ts +1 -1
  148. package/dist/types/plugins/paste/pm-plugins/main.d.ts +3 -3
  149. package/dist/types/plugins/paste/pm-plugins/plugin-factory.d.ts +3 -0
  150. package/dist/types/plugins/paste/reducer.d.ts +3 -0
  151. package/dist/types/plugins/paste/types.d.ts +6 -0
  152. package/dist/types/plugins/table/commands-with-analytics.d.ts +5 -5
  153. package/dist/types/plugins/tasks-and-decisions/commands.d.ts +0 -2
  154. package/dist/types/plugins/type-ahead/constants.d.ts +1 -0
  155. package/dist/types/plugins/type-ahead/messages.d.ts +15 -0
  156. package/dist/types/plugins/type-ahead/ui/AssistiveText.d.ts +33 -0
  157. package/dist/types/plugins/type-ahead/ui/InputQuery.d.ts +3 -0
  158. package/dist/types/plugins/type-ahead/ui/TypeAheadList.d.ts +6 -3
  159. package/dist/types/plugins/type-ahead/ui/TypeAheadListItem.d.ts +2 -2
  160. package/dist/types/plugins/type-ahead/ui/TypeAheadPopup.d.ts +1 -1
  161. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  162. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  163. package/dist/types/utils/index.d.ts +1 -0
  164. package/dist/types-ts4.0/index.d.ts +1 -1
  165. package/dist/types-ts4.0/plugins/base/pm-plugins/composition.d.ts +8 -0
  166. package/dist/types-ts4.0/plugins/code-block/pm-plugins/ide-ux.d.ts +1 -4
  167. package/dist/types-ts4.0/plugins/floating-toolbar/ui/Dropdown.d.ts +2 -0
  168. package/dist/types-ts4.0/plugins/floating-toolbar/ui/DropdownMenu.d.ts +1 -0
  169. package/dist/types-ts4.0/plugins/paste/actions.d.ts +15 -0
  170. package/dist/types-ts4.0/plugins/paste/commands.d.ts +16 -0
  171. package/dist/types-ts4.0/plugins/paste/handlers.d.ts +1 -1
  172. package/dist/types-ts4.0/plugins/paste/pm-plugins/main.d.ts +3 -3
  173. package/dist/types-ts4.0/plugins/paste/pm-plugins/plugin-factory.d.ts +3 -0
  174. package/dist/types-ts4.0/plugins/paste/reducer.d.ts +3 -0
  175. package/dist/types-ts4.0/plugins/paste/types.d.ts +6 -0
  176. package/dist/types-ts4.0/plugins/table/commands-with-analytics.d.ts +5 -5
  177. package/dist/types-ts4.0/plugins/tasks-and-decisions/commands.d.ts +0 -2
  178. package/dist/types-ts4.0/plugins/type-ahead/constants.d.ts +1 -0
  179. package/dist/types-ts4.0/plugins/type-ahead/messages.d.ts +15 -0
  180. package/dist/types-ts4.0/plugins/type-ahead/ui/AssistiveText.d.ts +33 -0
  181. package/dist/types-ts4.0/plugins/type-ahead/ui/InputQuery.d.ts +3 -0
  182. package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadList.d.ts +6 -3
  183. package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadListItem.d.ts +2 -2
  184. package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadPopup.d.ts +1 -1
  185. package/dist/types-ts4.0/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  186. package/dist/types-ts4.0/ui/ContentStyles/index.d.ts +2 -2
  187. package/dist/types-ts4.0/utils/index.d.ts +1 -0
  188. package/package.json +30 -31
  189. package/report.api.md +161 -49
@@ -0,0 +1,46 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
+
8
+ import { PluginKey } from 'prosemirror-state';
9
+ import { pluginFactory } from '../../../utils/plugin-state-factory';
10
+ import { reducer } from '../reducer';
11
+ export var pluginKey = new PluginKey('pastePlugin');
12
+
13
+ var _pluginFactory = pluginFactory(pluginKey, reducer, {
14
+ mapping: function mapping(tr, pluginState) {
15
+ if (tr.docChanged) {
16
+ var atLeastOnePositionChanged = false;
17
+ var positionsMappedThroughChanges = Object.entries(pluginState.pastedMacroPositions).reduce(function (acc, _ref) {
18
+ var _ref2 = _slicedToArray(_ref, 2),
19
+ key = _ref2[0],
20
+ position = _ref2[1];
21
+
22
+ var mappedPosition = tr.mapping.map(position);
23
+
24
+ if (position !== mappedPosition) {
25
+ atLeastOnePositionChanged = true;
26
+ }
27
+
28
+ acc[key] = tr.mapping.map(position);
29
+ return acc;
30
+ }, {});
31
+
32
+ if (atLeastOnePositionChanged) {
33
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
34
+ pastedMacroPositions: positionsMappedThroughChanges
35
+ });
36
+ }
37
+ }
38
+
39
+ return pluginState;
40
+ }
41
+ }),
42
+ createPluginState = _pluginFactory.createPluginState,
43
+ createCommand = _pluginFactory.createCommand,
44
+ getPluginState = _pluginFactory.getPluginState;
45
+
46
+ export { createPluginState, createCommand, getPluginState };
@@ -0,0 +1,34 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
+
8
+ import { PastePluginActionTypes as ActionTypes } from './actions';
9
+ export var reducer = function reducer(state, action) {
10
+ switch (action.type) {
11
+ case ActionTypes.START_TRACKING_PASTED_MACRO_POSITIONS:
12
+ {
13
+ return _objectSpread(_objectSpread({}, state), {}, {
14
+ pastedMacroPositions: _objectSpread(_objectSpread({}, state.pastedMacroPositions), action.pastedMacroPositions)
15
+ });
16
+ }
17
+
18
+ case ActionTypes.STOP_TRACKING_PASTED_MACRO_POSITIONS:
19
+ {
20
+ var filteredMacroPositions = Object.fromEntries(Object.entries(state.pastedMacroPositions).filter(function (_ref) {
21
+ var _ref2 = _slicedToArray(_ref, 1),
22
+ key = _ref2[0];
23
+
24
+ return !action.pastedMacroPositionKeys.includes(key);
25
+ }));
26
+ return _objectSpread(_objectSpread({}, state), {}, {
27
+ pastedMacroPositions: filteredMacroPositions
28
+ });
29
+ }
30
+
31
+ default:
32
+ return state;
33
+ }
34
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -8,6 +8,7 @@ import { placeHolderClassName } from './styles';
8
8
  export var pluginKey = new PluginKey('placeholderPlugin');
9
9
  import { focusStateKey } from '../base/pm-plugins/focus-handler';
10
10
  import { isTypeAheadOpen } from '../type-ahead/utils';
11
+ import { isComposing } from '../base/pm-plugins/composition';
11
12
 
12
13
  function getPlaceholderState(editorState) {
13
14
  return pluginKey.getState(editorState);
@@ -134,7 +135,7 @@ export function createPlugin(defaultPlaceholderText, placeholderHints, bracketPl
134
135
  placeholderText = _getPlaceholderState.placeholderText,
135
136
  pos = _getPlaceholderState.pos;
136
137
 
137
- if (hasPlaceholder && placeholderText && pos !== undefined) {
138
+ if (hasPlaceholder && placeholderText && pos !== undefined && !isComposing(editorState)) {
138
139
  return createPlaceholderDecoration(editorState, placeholderText, pos);
139
140
  }
140
141
 
@@ -72,10 +72,16 @@ export function createPlugin(dispatch, options) {
72
72
  var placeholderNodeType = newState.schema.nodes.placeholder;
73
73
 
74
74
  if (adjacentNode && adjacentNode.type === placeholderNodeType && didPlaceholderExistBeforeTxn) {
75
- // Check that cursor has moved forward in the document **and** that there is content before the cursor
76
- var wasContentAdded = oldState.selection.$head.pos < newState.selection.$head.pos && !isNodeEmpty(newState.selection.$head.nodeBefore);
75
+ var _$newHead$nodeBefore;
77
76
 
78
- if (wasContentAdded) {
77
+ var $newHead = newState.selection.$head;
78
+ var $oldHead = oldState.selection.$head; // Check that cursor has moved forward in the document **and** that there is content before the cursor
79
+
80
+ var cursorMoved = $oldHead.pos < $newHead.pos;
81
+ var nodeBeforeHasContent = !isNodeEmpty($newHead.nodeBefore);
82
+ var nodeBeforeIsInline = (_$newHead$nodeBefore = $newHead.nodeBefore) === null || _$newHead$nodeBefore === void 0 ? void 0 : _$newHead$nodeBefore.type.isInline;
83
+
84
+ if (cursorMoved && (nodeBeforeHasContent || nodeBeforeIsInline)) {
79
85
  var _NodeSelection$create = NodeSelection.create(newState.doc, adjacentNodePos),
80
86
  $from = _NodeSelection$create.$from,
81
87
  $to = _NodeSelection$create.$to;
@@ -51,8 +51,11 @@ export var StatusPickerWithoutAnalytcs = /*#__PURE__*/function (_React$Component
51
51
  _defineProperty(_assertThisInitialized(_this), "handleClickOutside", function (event) {
52
52
  event.preventDefault();
53
53
  _this.inputMethod = InputMethod.blur;
54
+ var selectedText = window.getSelection();
54
55
 
55
- _this.props.closeStatusPicker();
56
+ if (!selectedText) {
57
+ _this.props.closeStatusPicker();
58
+ }
56
59
  });
57
60
 
58
61
  _defineProperty(_assertThisInitialized(_this), "handleEscapeKeydown", function (event) {
@@ -55,71 +55,77 @@ export var emptyMultipleCellsWithAnalytics = function emptyMultipleCellsWithAnal
55
55
  };
56
56
  };
57
57
  export var mergeCellsWithAnalytics = function mergeCellsWithAnalytics(editorAnalyticsAPI) {
58
- return withEditorAnalyticsAPI(function (_ref2) {
59
- var selection = _ref2.selection;
60
-
61
- var _getSelectedCellInfo2 = getSelectedCellInfo(selection),
62
- horizontalCells = _getSelectedCellInfo2.horizontalCells,
63
- verticalCells = _getSelectedCellInfo2.verticalCells,
64
- totalCells = _getSelectedCellInfo2.totalCells,
65
- totalRowCount = _getSelectedCellInfo2.totalRowCount,
66
- totalColumnCount = _getSelectedCellInfo2.totalColumnCount;
67
-
68
- return {
69
- action: TABLE_ACTION.MERGED,
70
- actionSubject: ACTION_SUBJECT.TABLE,
71
- actionSubjectId: null,
72
- attributes: {
73
- horizontalCells: horizontalCells,
74
- verticalCells: verticalCells,
75
- totalCells: totalCells,
76
- totalRowCount: totalRowCount,
77
- totalColumnCount: totalColumnCount
78
- },
79
- eventType: EVENT_TYPE.TRACK
80
- };
81
- })(editorAnalyticsAPI)(function (state, dispatch) {
82
- if (dispatch) {
83
- dispatch(mergeCells(state.tr));
84
- }
85
-
86
- return true;
87
- });
88
- };
89
- export var splitCellWithAnalytics = function splitCellWithAnalytics(editorAnalyticsAPI) {
90
- return withEditorAnalyticsAPI(function (_ref3) {
91
- var selection = _ref3.selection;
92
-
93
- var _getSelectedCellInfo3 = getSelectedCellInfo(selection),
94
- totalRowCount = _getSelectedCellInfo3.totalRowCount,
95
- totalColumnCount = _getSelectedCellInfo3.totalColumnCount;
58
+ return function (inputMethod) {
59
+ return withEditorAnalyticsAPI(function (_ref2) {
60
+ var selection = _ref2.selection;
96
61
 
97
- var cell = findCellClosestToPos(selection.$anchor);
62
+ var _getSelectedCellInfo2 = getSelectedCellInfo(selection),
63
+ horizontalCells = _getSelectedCellInfo2.horizontalCells,
64
+ verticalCells = _getSelectedCellInfo2.verticalCells,
65
+ totalCells = _getSelectedCellInfo2.totalCells,
66
+ totalRowCount = _getSelectedCellInfo2.totalRowCount,
67
+ totalColumnCount = _getSelectedCellInfo2.totalColumnCount;
98
68
 
99
- if (cell) {
100
- var _cell$node$attrs = cell.node.attrs,
101
- verticalCells = _cell$node$attrs.rowspan,
102
- horizontalCells = _cell$node$attrs.colspan;
103
69
  return {
104
- action: TABLE_ACTION.SPLIT,
70
+ action: TABLE_ACTION.MERGED,
105
71
  actionSubject: ACTION_SUBJECT.TABLE,
106
72
  actionSubjectId: null,
107
73
  attributes: {
74
+ inputMethod: inputMethod,
108
75
  horizontalCells: horizontalCells,
109
76
  verticalCells: verticalCells,
110
- totalCells: horizontalCells * verticalCells,
77
+ totalCells: totalCells,
111
78
  totalRowCount: totalRowCount,
112
79
  totalColumnCount: totalColumnCount
113
80
  },
114
81
  eventType: EVENT_TYPE.TRACK
115
82
  };
116
- }
83
+ })(editorAnalyticsAPI)(function (state, dispatch) {
84
+ if (dispatch) {
85
+ dispatch(mergeCells(state.tr));
86
+ }
117
87
 
118
- return;
119
- })(editorAnalyticsAPI)(splitCell);
88
+ return true;
89
+ });
90
+ };
91
+ };
92
+ export var splitCellWithAnalytics = function splitCellWithAnalytics(editorAnalyticsAPI) {
93
+ return function (inputMethod) {
94
+ return withEditorAnalyticsAPI(function (_ref3) {
95
+ var selection = _ref3.selection;
96
+
97
+ var _getSelectedCellInfo3 = getSelectedCellInfo(selection),
98
+ totalRowCount = _getSelectedCellInfo3.totalRowCount,
99
+ totalColumnCount = _getSelectedCellInfo3.totalColumnCount;
100
+
101
+ var cell = findCellClosestToPos(selection.$anchor);
102
+
103
+ if (cell) {
104
+ var _cell$node$attrs = cell.node.attrs,
105
+ verticalCells = _cell$node$attrs.rowspan,
106
+ horizontalCells = _cell$node$attrs.colspan;
107
+ return {
108
+ action: TABLE_ACTION.SPLIT,
109
+ actionSubject: ACTION_SUBJECT.TABLE,
110
+ actionSubjectId: null,
111
+ attributes: {
112
+ inputMethod: inputMethod,
113
+ horizontalCells: horizontalCells,
114
+ verticalCells: verticalCells,
115
+ totalCells: horizontalCells * verticalCells,
116
+ totalRowCount: totalRowCount,
117
+ totalColumnCount: totalColumnCount
118
+ },
119
+ eventType: EVENT_TYPE.TRACK
120
+ };
121
+ }
122
+
123
+ return;
124
+ })(editorAnalyticsAPI)(splitCell);
125
+ };
120
126
  };
121
127
  export var setColorWithAnalytics = function setColorWithAnalytics(editorAnalyticsAPI) {
122
- return function (cellColor, targetCellPosition) {
128
+ return function (inputMethod, cellColor, targetCellPosition) {
123
129
  return withEditorAnalyticsAPI(function (_ref4) {
124
130
  var selection = _ref4.selection;
125
131
 
@@ -135,6 +141,7 @@ export var setColorWithAnalytics = function setColorWithAnalytics(editorAnalytic
135
141
  actionSubject: ACTION_SUBJECT.TABLE,
136
142
  actionSubjectId: null,
137
143
  attributes: {
144
+ inputMethod: inputMethod,
138
145
  cellColor: (tableBackgroundColorPalette.get(cellColor.toLowerCase()) || cellColor).toLowerCase(),
139
146
  horizontalCells: horizontalCells,
140
147
  verticalCells: verticalCells,
@@ -5,7 +5,7 @@ import { createTable } from '@atlaskit/editor-tables/utils';
5
5
  import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
6
6
  import { toggleTable, tooltip } from '../../keymaps';
7
7
  import WithPluginState from '../../ui/WithPluginState';
8
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
9
9
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
10
10
  import { IconTable } from '@atlaskit/editor-common/icons';
11
11
  import { pluginConfig } from './create-plugin-config';
@@ -116,21 +116,38 @@ var tablesPlugin = function tablesPlugin(options) {
116
116
  }, {
117
117
  name: 'tableEditing',
118
118
  plugin: function plugin() {
119
- return tableEditing();
119
+ return tableEditing({
120
+ reportFixedTable: function reportFixedTable(_ref5) {
121
+ var _options$editorAnalyt;
122
+
123
+ var state = _ref5.state,
124
+ tr = _ref5.tr,
125
+ reason = _ref5.reason;
126
+ options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
127
+ action: TABLE_ACTION.FIXED,
128
+ actionSubject: ACTION_SUBJECT.TABLE,
129
+ actionSubjectId: null,
130
+ attributes: {
131
+ reason: reason
132
+ },
133
+ eventType: EVENT_TYPE.TRACK
134
+ })(tr);
135
+ }
136
+ });
120
137
  }
121
138
  }, {
122
139
  name: 'tableStickyHeaders',
123
- plugin: function plugin(_ref5) {
124
- var dispatch = _ref5.dispatch,
125
- eventDispatcher = _ref5.eventDispatcher;
140
+ plugin: function plugin(_ref6) {
141
+ var dispatch = _ref6.dispatch,
142
+ eventDispatcher = _ref6.eventDispatcher;
126
143
  return options && options.tableOptions.stickyHeaders ? createStickyHeadersPlugin(dispatch, eventDispatcher, function () {
127
144
  return [];
128
145
  }, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags) : undefined;
129
146
  }
130
147
  }, {
131
148
  name: 'tableLocalId',
132
- plugin: function plugin(_ref6) {
133
- var dispatch = _ref6.dispatch;
149
+ plugin: function plugin(_ref7) {
150
+ var dispatch = _ref7.dispatch;
134
151
  return createTableLocalIdPlugin(dispatch);
135
152
  }
136
153
  }]; // workaround for prosemirrors delayed dom selection syncing during pointer drag
@@ -161,12 +178,12 @@ var tablesPlugin = function tablesPlugin(options) {
161
178
 
162
179
  return plugins;
163
180
  },
164
- contentComponent: function contentComponent(_ref7) {
165
- var editorView = _ref7.editorView,
166
- popupsMountPoint = _ref7.popupsMountPoint,
167
- popupsBoundariesElement = _ref7.popupsBoundariesElement,
168
- popupsScrollableElement = _ref7.popupsScrollableElement,
169
- dispatchAnalyticsEvent = _ref7.dispatchAnalyticsEvent;
181
+ contentComponent: function contentComponent(_ref8) {
182
+ var editorView = _ref8.editorView,
183
+ popupsMountPoint = _ref8.popupsMountPoint,
184
+ popupsBoundariesElement = _ref8.popupsBoundariesElement,
185
+ popupsScrollableElement = _ref8.popupsScrollableElement,
186
+ dispatchAnalyticsEvent = _ref8.dispatchAnalyticsEvent;
170
187
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
171
188
  component: ACTION_SUBJECT.TABLES_PLUGIN,
172
189
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -177,25 +194,25 @@ var tablesPlugin = function tablesPlugin(options) {
177
194
  tableResizingPluginState: tableResizingPluginKey,
178
195
  stickyHeadersState: stickyHeadersPluginKey
179
196
  },
180
- render: function render(_ref8) {
181
- var resizingPluginState = _ref8.tableResizingPluginState,
182
- stickyHeadersState = _ref8.stickyHeadersState,
183
- tablePluginState = _ref8.tablePluginState;
197
+ render: function render(_ref9) {
198
+ var resizingPluginState = _ref9.tableResizingPluginState,
199
+ stickyHeadersState = _ref9.stickyHeadersState,
200
+ tablePluginState = _ref9.tablePluginState;
184
201
  var state = editorView.state;
185
202
  var isDragging = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
186
- var _ref9 = tablePluginState,
187
- tableNode = _ref9.tableNode,
188
- tablePos = _ref9.tablePos,
189
- targetCellPosition = _ref9.targetCellPosition,
190
- isContextualMenuOpen = _ref9.isContextualMenuOpen,
191
- layout = _ref9.layout,
192
- tableRef = _ref9.tableRef,
193
- pluginConfig = _ref9.pluginConfig,
194
- insertColumnButtonIndex = _ref9.insertColumnButtonIndex,
195
- insertRowButtonIndex = _ref9.insertRowButtonIndex,
196
- isHeaderColumnEnabled = _ref9.isHeaderColumnEnabled,
197
- isHeaderRowEnabled = _ref9.isHeaderRowEnabled,
198
- tableWrapperTarget = _ref9.tableWrapperTarget;
203
+ var _ref10 = tablePluginState,
204
+ tableNode = _ref10.tableNode,
205
+ tablePos = _ref10.tablePos,
206
+ targetCellPosition = _ref10.targetCellPosition,
207
+ isContextualMenuOpen = _ref10.isContextualMenuOpen,
208
+ layout = _ref10.layout,
209
+ tableRef = _ref10.tableRef,
210
+ pluginConfig = _ref10.pluginConfig,
211
+ insertColumnButtonIndex = _ref10.insertColumnButtonIndex,
212
+ insertRowButtonIndex = _ref10.insertRowButtonIndex,
213
+ isHeaderColumnEnabled = _ref10.isHeaderColumnEnabled,
214
+ isHeaderRowEnabled = _ref10.isHeaderRowEnabled,
215
+ tableWrapperTarget = _ref10.tableWrapperTarget;
199
216
  var allowControls = pluginConfig.allowControls;
200
217
  var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
201
218
  return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !isDragging && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
@@ -260,9 +277,9 @@ var tablesPlugin = function tablesPlugin(options) {
260
277
  pluginsOptions: {
261
278
  // TODO: ED-14676 This is not the final API design
262
279
  // For now, we are using this on (insert-api/api.ts) but we may create a proper place for it
263
- createNodeHandler: function createNodeHandler(_ref10) {
264
- var nodeName = _ref10.nodeName,
265
- schema = _ref10.schema;
280
+ createNodeHandler: function createNodeHandler(_ref11) {
281
+ var nodeName = _ref11.nodeName,
282
+ schema = _ref11.schema;
266
283
 
267
284
  // An EditorPlugin may manage more than one node.
268
285
  if (nodeName !== 'table') {
@@ -274,8 +291,8 @@ var tablesPlugin = function tablesPlugin(options) {
274
291
  });
275
292
  return table;
276
293
  },
277
- quickInsert: function quickInsert(_ref11) {
278
- var formatMessage = _ref11.formatMessage;
294
+ quickInsert: function quickInsert(_ref12) {
295
+ var formatMessage = _ref12.formatMessage;
279
296
  return [{
280
297
  id: 'table',
281
298
  title: formatMessage(messages.table),
@@ -287,12 +304,12 @@ var tablesPlugin = function tablesPlugin(options) {
287
304
  return /*#__PURE__*/React.createElement(IconTable, null);
288
305
  },
289
306
  action: function action(insert, state) {
290
- var _options$editorAnalyt;
307
+ var _options$editorAnalyt2;
291
308
 
292
309
  var tr = insert(createTable({
293
310
  schema: state.schema
294
311
  }));
295
- options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
312
+ options === null || options === void 0 ? void 0 : (_options$editorAnalyt2 = options.editorAnalyticsAPI) === null || _options$editorAnalyt2 === void 0 ? void 0 : _options$editorAnalyt2.attachAnalyticsEvent({
296
313
  action: ACTION.INSERTED,
297
314
  actionSubject: ACTION_SUBJECT.DOCUMENT,
298
315
  actionSubjectId: ACTION_SUBJECT_ID.TABLE,
@@ -1,12 +1,16 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+
3
+ /** @jsx jsx */
4
+ import { jsx } from '@emotion/react';
2
5
  import { defineMessages } from 'react-intl-next';
3
6
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
4
7
  import commonMessages from '@atlaskit/editor-common/messages';
5
8
  import { clearHoverSelection, hoverTable } from './commands';
6
- import { deleteTableWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, insertRowWithAnalytics, deleteRowsWithAnalytics, mergeCellsWithAnalytics, splitCellWithAnalytics, deleteColumnsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
9
+ import { deleteTableWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, insertRowWithAnalytics, deleteRowsWithAnalytics, mergeCellsWithAnalytics, splitCellWithAnalytics, deleteColumnsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, wrapTableInExpandWithAnalytics, sortColumnWithAnalytics, setColorWithAnalytics, distributeColumnsWidthsWithAnalytics } from './commands-with-analytics';
7
10
  import { getPluginState } from './pm-plugins/plugin-factory';
8
11
  import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
9
12
  import { TableCssClassName } from './types';
13
+ import { getMergedCellsPositions } from './utils';
10
14
  import { isReferencedSource } from './utils/referentiality';
11
15
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
12
16
  import { findCellRectClosestToPos, findTable, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
@@ -17,6 +21,12 @@ import { messages as ContextualMenuMessages } from './ui/FloatingContextualMenu/
17
21
  import { findParentDomRefOfType } from 'prosemirror-utils';
18
22
  import { closestElement } from '@atlaskit/editor-common/utils';
19
23
  import { getCopyButtonConfig, showCopyButton } from '../copy-button/toolbar';
24
+ import { addColumnAfter, addRowAfter, tooltip, backspace } from '@atlaskit/editor-common/keymaps';
25
+ import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizing/utils/resize-state';
26
+ import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
27
+ import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
28
+ import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
29
+ import { getFeatureFlags } from '../feature-flags-context';
20
30
  // TODO: ED-14403 investigate why these translations don't work
21
31
  export var messages = defineMessages({
22
32
  tableOptions: {
@@ -94,6 +104,7 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
94
104
  left = initialSelectionRect.left;
95
105
  var numberOfColumns = right - left;
96
106
  var numberOfRows = bottom - top;
107
+ var pluginState = getPluginState(editorState);
97
108
  var options = [{
98
109
  id: 'editor.table.insertColumn',
99
110
  title: formatMessage(tableMessages.insertColumn),
@@ -108,7 +119,10 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
108
119
  return true;
109
120
  },
110
121
  selected: false,
111
- disabled: false
122
+ disabled: false,
123
+ elemAfter: jsx("div", {
124
+ css: shortcutStyle
125
+ }, tooltip(addColumnAfter))
112
126
  }, {
113
127
  id: 'editor.table.insertRow',
114
128
  title: formatMessage(tableMessages.insertRow),
@@ -126,7 +140,10 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
126
140
  return true;
127
141
  },
128
142
  selected: false,
129
- disabled: false
143
+ disabled: false,
144
+ elemAfter: jsx("div", {
145
+ css: shortcutStyle
146
+ }, tooltip(addRowAfter))
130
147
  }, {
131
148
  id: 'editor.table.removeColumns',
132
149
  title: formatMessage(tableMessages.removeColumns, {
@@ -162,16 +179,63 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
162
179
  }, {
163
180
  id: 'editor.table.mergeCells',
164
181
  title: formatMessage(ContextualMenuMessages.mergeCells),
165
- onClick: mergeCellsWithAnalytics(editorAnalyticsAPI),
182
+ onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
166
183
  selected: false,
167
184
  disabled: !canMergeCells(editorState.tr)
168
185
  }, {
169
186
  id: 'editor.table.splitCell',
170
187
  title: formatMessage(ContextualMenuMessages.splitCell),
171
- onClick: splitCellWithAnalytics(editorAnalyticsAPI),
188
+ onClick: splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
172
189
  selected: false,
173
190
  disabled: !splitCell(editorState)
174
- }, {
191
+ }];
192
+
193
+ if (pluginState.pluginConfig.allowDistributeColumns) {
194
+ var distributeColumnWidths = function distributeColumnWidths(state, dispatch, view) {
195
+ var newResizeStateWithAnalytics = view ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, view.domAtPos.bind(view), getEditorContainerWidth) : undefined;
196
+
197
+ if (newResizeStateWithAnalytics) {
198
+ distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
199
+ return true;
200
+ }
201
+
202
+ return false;
203
+ };
204
+
205
+ options.push({
206
+ id: 'editor.table.distributeColumns',
207
+ title: formatMessage(ContextualMenuMessages.distributeColumns),
208
+ onClick: distributeColumnWidths,
209
+ selected: false,
210
+ disabled: numberOfColumns <= 1
211
+ });
212
+ }
213
+
214
+ if (pluginState.pluginConfig.allowColumnSorting) {
215
+ var hasMergedCellsInTable = getMergedCellsPositions(editorState.tr).length > 0;
216
+ options.push({
217
+ id: 'editor.table.sortColumnAsc',
218
+ title: formatMessage(ContextualMenuMessages.sortColumnASC),
219
+ onClick: function onClick(state, dispatch) {
220
+ sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, initialSelectionRect.left, SortOrder.ASC)(state, dispatch);
221
+ return true;
222
+ },
223
+ selected: false,
224
+ disabled: hasMergedCellsInTable
225
+ });
226
+ options.push({
227
+ id: 'editor.table.sortColumnDesc',
228
+ title: formatMessage(ContextualMenuMessages.sortColumnDESC),
229
+ onClick: function onClick(state, dispatch) {
230
+ sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, initialSelectionRect.left, SortOrder.DESC)(state, dispatch);
231
+ return true;
232
+ },
233
+ selected: false,
234
+ disabled: hasMergedCellsInTable
235
+ });
236
+ }
237
+
238
+ options.push({
175
239
  id: 'editor.table.clearCells',
176
240
  title: formatMessage(ContextualMenuMessages.clearCells, {
177
241
  0: Math.max(numberOfColumns, numberOfRows)
@@ -184,14 +248,19 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
184
248
  return true;
185
249
  },
186
250
  selected: false,
187
- disabled: false
188
- }];
251
+ disabled: false,
252
+ elemAfter: jsx("div", {
253
+ css: shortcutStyle
254
+ }, tooltip(backspace))
255
+ });
189
256
  return {
190
257
  id: 'editor.table.cellOptions',
191
258
  type: 'dropdown',
192
259
  title: formatMessage(tableMessages.cellOptions),
193
- hidden: true,
194
- options: options
260
+ options: options,
261
+ // Increased dropdown item width to prevent labels from being truncated
262
+ dropdownWidth: 230,
263
+ showSelected: false
195
264
  };
196
265
  };
197
266
 
@@ -210,7 +279,12 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
210
279
  if (tableObject && pluginState.editorHasFocus) {
211
280
  var nodeType = state.schema.nodes.table;
212
281
  var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
213
- var cellItems = getCellItems(config, state, intl, getEditorContainerWidth, editorAnalyticsAPI); // Check if we need to show confirm dialog for delete button
282
+
283
+ var _ref3 = getFeatureFlags(state) || {},
284
+ tableCellOptionsInFloatingToolbar = _ref3.tableCellOptionsInFloatingToolbar;
285
+
286
+ var cellItems = getCellItems(config, state, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
287
+ var colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar); // Check if we need to show confirm dialog for delete button
214
288
 
215
289
  var confirmDialog;
216
290
  var localId = tableObject.node.attrs.localId;
@@ -243,7 +317,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
243
317
  getDomRef: getDomRef,
244
318
  nodeType: nodeType,
245
319
  offset: [0, 3],
246
- items: [menu, separator(menu.hidden)].concat(_toConsumableArray(cellItems), [{
320
+ items: [menu, separator(menu.hidden)].concat(_toConsumableArray(cellItems), _toConsumableArray(colorPicker), [{
247
321
  type: 'extensions-placeholder',
248
322
  separator: 'end'
249
323
  }], _toConsumableArray(state && showCopyButton(state) ? [getCopyButtonConfig(state, intl.formatMessage, nodeType, hoverTable(false, true), clearHoverSelection()), {
@@ -275,10 +349,10 @@ var separator = function separator(hidden) {
275
349
  };
276
350
  };
277
351
 
278
- var getCellItems = function getCellItems(pluginConfig, state, _ref3, getEditorContainerWidth, editorAnalyticsAPI) {
279
- var formatMessage = _ref3.formatMessage;
352
+ var getCellItems = function getCellItems(pluginConfig, state, _ref4, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) {
353
+ var formatMessage = _ref4.formatMessage;
280
354
 
281
- if (pluginConfig.allowCellOptionsInFloatingToolbar) {
355
+ if (pluginConfig.allowCellOptionsInFloatingToolbar || tableCellOptionsInFloatingToolbar) {
282
356
  var initialSelectionRect = getClosestSelectionRect(state);
283
357
 
284
358
  if (initialSelectionRect) {
@@ -290,4 +364,39 @@ var getCellItems = function getCellItems(pluginConfig, state, _ref3, getEditorCo
290
364
  }
291
365
 
292
366
  return [];
367
+ };
368
+
369
+ var getColorPicker = function getColorPicker(state, menu, _ref5, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) {
370
+ var _node$attrs;
371
+
372
+ var formatMessage = _ref5.formatMessage;
373
+
374
+ var _getPluginState2 = getPluginState(state),
375
+ targetCellPosition = _getPluginState2.targetCellPosition,
376
+ pluginConfig = _getPluginState2.pluginConfig;
377
+
378
+ if (!pluginConfig.allowBackgroundColor || !tableCellOptionsInFloatingToolbar) {
379
+ return [];
380
+ }
381
+
382
+ var node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : undefined;
383
+ var currentBackground = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff';
384
+ var defaultPalette = cellBackgroundColorPalette.find(function (item) {
385
+ return item.value === currentBackground;
386
+ }) || {
387
+ label: 'Custom',
388
+ value: currentBackground,
389
+ border: DEFAULT_BORDER_COLOR
390
+ };
391
+ return [{
392
+ id: 'editor.panel.colorPicker',
393
+ title: formatMessage(ContextualMenuMessages.cellBackground),
394
+ type: 'select',
395
+ selectType: 'color',
396
+ defaultValue: defaultPalette,
397
+ options: cellBackgroundColorPalette,
398
+ onChange: function onChange(option) {
399
+ return setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, option.value, targetCellPosition);
400
+ }
401
+ }, separator(menu.hidden)];
293
402
  };