@atlaskit/editor-plugin-table 0.0.10 → 0.1.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 (213) hide show
  1. package/.eslintrc.js +35 -0
  2. package/CHANGELOG.md +23 -0
  3. package/commands/package.json +14 -0
  4. package/dist/cjs/plugins/table/commands/hover.js +4 -4
  5. package/dist/cjs/plugins/table/commands-with-analytics.js +59 -58
  6. package/dist/cjs/plugins/table/event-handlers.js +0 -1
  7. package/dist/cjs/plugins/table/index.js +54 -37
  8. package/dist/cjs/plugins/table/pm-plugins/table-resizing/index.js +9 -1
  9. package/dist/cjs/plugins/table/toolbar.js +150 -22
  10. package/dist/cjs/plugins/table/transforms/fix-tables.js +7 -7
  11. package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +1 -2
  12. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
  13. package/dist/cjs/plugins/table/ui/LayoutButton/index.js +3 -5
  14. package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
  15. package/dist/cjs/plugins/table/utils/column-controls.js +0 -1
  16. package/dist/cjs/plugins/table/utils/decoration.js +53 -4
  17. package/dist/cjs/plugins/table/utils/dom.js +0 -2
  18. package/dist/cjs/plugins/table/utils/paste.js +0 -1
  19. package/dist/cjs/version.json +1 -1
  20. package/dist/es2019/plugins/table/commands/hover.js +4 -4
  21. package/dist/es2019/plugins/table/commands-with-analytics.js +6 -9
  22. package/dist/es2019/plugins/table/event-handlers.js +1 -2
  23. package/dist/es2019/plugins/table/handlers.js +1 -2
  24. package/dist/es2019/plugins/table/index.js +23 -5
  25. package/dist/es2019/plugins/table/pm-plugins/keymap.js +1 -1
  26. package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +1 -3
  27. package/dist/es2019/plugins/table/pm-plugins/table-resizing/index.js +2 -1
  28. package/dist/es2019/plugins/table/toolbar.js +133 -16
  29. package/dist/es2019/plugins/table/transforms/fix-tables.js +2 -4
  30. package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +1 -2
  31. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
  32. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +1 -2
  33. package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +1 -2
  34. package/dist/es2019/plugins/table/ui/LayoutButton/index.js +3 -5
  35. package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
  36. package/dist/es2019/plugins/table/utils/column-controls.js +0 -1
  37. package/dist/es2019/plugins/table/utils/decoration.js +60 -25
  38. package/dist/es2019/plugins/table/utils/dom.js +0 -2
  39. package/dist/es2019/plugins/table/utils/paste.js +1 -2
  40. package/dist/es2019/plugins/table/utils/row-controls.js +1 -2
  41. package/dist/es2019/version.json +1 -1
  42. package/dist/esm/plugins/table/commands/hover.js +4 -4
  43. package/dist/esm/plugins/table/commands-with-analytics.js +56 -55
  44. package/dist/esm/plugins/table/event-handlers.js +1 -2
  45. package/dist/esm/plugins/table/handlers.js +1 -2
  46. package/dist/esm/plugins/table/index.js +55 -38
  47. package/dist/esm/plugins/table/pm-plugins/keymap.js +1 -1
  48. package/dist/esm/plugins/table/pm-plugins/table-local-id.js +1 -3
  49. package/dist/esm/plugins/table/pm-plugins/table-resizing/index.js +2 -1
  50. package/dist/esm/plugins/table/toolbar.js +139 -17
  51. package/dist/esm/plugins/table/transforms/fix-tables.js +2 -4
  52. package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +1 -2
  53. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
  54. package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +1 -2
  55. package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +1 -2
  56. package/dist/esm/plugins/table/ui/LayoutButton/index.js +3 -5
  57. package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
  58. package/dist/esm/plugins/table/utils/column-controls.js +0 -1
  59. package/dist/esm/plugins/table/utils/decoration.js +50 -4
  60. package/dist/esm/plugins/table/utils/dom.js +0 -2
  61. package/dist/esm/plugins/table/utils/paste.js +1 -2
  62. package/dist/esm/plugins/table/utils/row-controls.js +1 -2
  63. package/dist/esm/version.json +1 -1
  64. package/dist/types/plugins/table/commands-with-analytics.d.ts +5 -5
  65. package/dist/types/plugins/table/pm-plugins/table-resizing/index.d.ts +1 -0
  66. package/dist/types/plugins/table/toolbar.d.ts +2 -2
  67. package/dist/types/plugins/table/transforms/fix-tables.d.ts +1 -1
  68. package/dist/types/plugins/table/utils/decoration.d.ts +1 -1
  69. package/dist/types-ts4.0/plugins/table/commands-with-analytics.d.ts +5 -5
  70. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/index.d.ts +1 -0
  71. package/dist/types-ts4.0/plugins/table/toolbar.d.ts +2 -2
  72. package/dist/types-ts4.0/plugins/table/transforms/fix-tables.d.ts +1 -1
  73. package/dist/types-ts4.0/plugins/table/utils/decoration.d.ts +1 -1
  74. package/examples/config.jsonc +14 -0
  75. package/package.json +15 -11
  76. package/plugin-key/package.json +14 -0
  77. package/report.api.md +1 -1
  78. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/auto-size-documents.ts +0 -0
  79. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/basic-table.ts +0 -0
  80. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/empty-paragraph-underneath-table.ts +0 -0
  81. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/even-columns.ts +0 -0
  82. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/layout-documents.ts +0 -0
  83. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/merged-rows-and-cols-document.ts +0 -0
  84. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/nested-in-extension.ts +0 -0
  85. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/paragraph-and-table-adf.json +0 -0
  86. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/resize-documents.ts +0 -0
  87. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/scale.ts +0 -0
  88. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-inside-layout.ts +0 -0
  89. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-min-width-columns-document.ts +0 -0
  90. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-multiline-date.adf.json +0 -0
  91. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-text-and-empty-row.ts +0 -0
  92. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/auto-size.ts.snap +0 -0
  93. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/change-date-inside-table.ts.snap +0 -0
  94. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/copy-button.ts.snap +0 -0
  95. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-columns.ts.snap +0 -0
  96. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-column-in-full-width.ts.snap +0 -0
  97. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-column-with-empty-action.ts.snap +0 -0
  98. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-row-with-empty-action.ts.snap +0 -0
  99. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-rows.ts.snap +0 -0
  100. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-table-when-selected.ts.snap +0 -0
  101. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/deleting-empty-paragraph-under-table.ts.snap +0 -0
  102. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/even-columns.ts.snap +0 -0
  103. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/insert-cell-header-with-strong-mark.ts.snap +0 -0
  104. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/insert-row-inside-layout.ts.snap +0 -0
  105. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/layout.ts.snap +0 -0
  106. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/resize.ts.snap +0 -0
  107. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/scale.ts.snap +0 -0
  108. package/src/{plugins/table/__tests__ → __tests__}/integration/arrow-down-into-table.ts +0 -0
  109. package/src/{plugins/table/__tests__ → __tests__}/integration/auto-size.ts +0 -0
  110. package/src/{plugins/table/__tests__ → __tests__}/integration/block-node-selection.ts +1 -0
  111. package/src/{plugins/table/__tests__ → __tests__}/integration/cell-selection.ts +0 -0
  112. package/src/{plugins/table/__tests__ → __tests__}/integration/change-date-inside-table.ts +0 -0
  113. package/src/{plugins/table/__tests__ → __tests__}/integration/copy-button.ts +1 -1
  114. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-columns.ts +2 -2
  115. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-column-in-full-width.ts +1 -1
  116. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-column-with-empty-action.ts +1 -1
  117. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-row-with-empty-action.ts +1 -1
  118. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-rows.ts +2 -2
  119. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-table-when-selected.ts +0 -0
  120. package/src/{plugins/table/__tests__ → __tests__}/integration/deleting-empty-paragraph-under-table.ts +0 -0
  121. package/src/{plugins/table/__tests__ → __tests__}/integration/even-columns.ts +0 -0
  122. package/src/{plugins/table/__tests__ → __tests__}/integration/insert-cell-header-with-strong-mark.ts +0 -0
  123. package/src/{plugins/table/__tests__ → __tests__}/integration/insert-long-smart-link.ts +1 -0
  124. package/src/{plugins/table/__tests__ → __tests__}/integration/insert-row-inside-layout.ts +0 -0
  125. package/src/{plugins/table/__tests__ → __tests__}/integration/layout.ts +0 -0
  126. package/src/{plugins/table/__tests__ → __tests__}/integration/resize-handler.ts +0 -0
  127. package/src/{plugins/table/__tests__ → __tests__}/integration/resize.ts +1 -1
  128. package/src/{plugins/table/__tests__ → __tests__}/integration/scale.ts +0 -0
  129. package/src/__tests__/integration/table-controls-selection.ts +71 -0
  130. package/src/__tests__/unit/analytics.ts +8 -9
  131. package/src/{plugins/table/__tests__ → __tests__}/unit/commands/go-to-next-cell.ts +4 -4
  132. package/src/{plugins/table/__tests__ → __tests__}/unit/commands/insert.ts +4 -4
  133. package/src/{plugins/table/__tests__ → __tests__}/unit/commands/misc.ts +12 -6
  134. package/src/{plugins/table/__tests__ → __tests__}/unit/commands.ts +7 -7
  135. package/src/__tests__/unit/copy-button.ts +22 -0
  136. package/src/__tests__/unit/event-handlers.ts +120 -1
  137. package/src/{plugins/table/__tests__ → __tests__}/unit/get-toolbar-config.ts +8 -3
  138. package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/OverflowShadowsObserver.ts +2 -2
  139. package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/TableComponent.tsx +11 -11
  140. package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/table.ts +5 -5
  141. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/column-controls.ts +2 -2
  142. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/column-resizing.ts +9 -6
  143. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/plugin.ts +5 -5
  144. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/main-with-allow-collapse.ts +4 -4
  145. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/main.ts +6 -6
  146. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +2 -2
  147. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/sticky-headers/tableRow.tsx +16 -13
  148. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-local-id.ts +3 -6
  149. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-resizing/colgroup.ts +1 -1
  150. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-resizing/event-handlers.ts +3 -3
  151. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-selection-keymap.ts +3 -3
  152. package/src/{plugins/table/__tests__ → __tests__}/unit/toolbar.ts +5 -9
  153. package/src/{plugins/table/__tests__ → __tests__}/unit/utils/collapse.ts +2 -2
  154. package/src/{plugins/table/__tests__ → __tests__}/unit/utils/column-controls.ts +1 -1
  155. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__fixtures__/table-with-100-numbered-list-items.json +0 -0
  156. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-should-remove-the-table-column-on-click-1-snap.png +0 -0
  157. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +0 -0
  158. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +0 -0
  159. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +0 -0
  160. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/copy-button-ts-floating-toolbar-copy-button-table-target-node-displays-blue-border-when-copy-button-is-hovered-1-snap.png +0 -0
  161. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-1-snap.png +0 -0
  162. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-2-snap.png +0 -0
  163. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-3-snap.png +0 -0
  164. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/cell-options-menu.ts +2 -0
  165. package/src/__tests__/visual-regression/copy-button.ts +181 -0
  166. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/index.ts +3 -1
  167. package/src/plugins/table/commands/hover.ts +4 -1
  168. package/src/plugins/table/commands-with-analytics.ts +12 -8
  169. package/src/plugins/table/event-handlers.ts +0 -1
  170. package/src/plugins/table/handlers.ts +0 -1
  171. package/src/plugins/table/index.tsx +28 -2
  172. package/src/plugins/table/pm-plugins/keymap.ts +1 -1
  173. package/src/plugins/table/pm-plugins/table-local-id.ts +0 -2
  174. package/src/plugins/table/pm-plugins/table-resizing/index.ts +1 -0
  175. package/src/plugins/table/{toolbar.ts → toolbar.tsx} +186 -14
  176. package/src/plugins/table/transforms/fix-tables.ts +2 -3
  177. package/src/plugins/table/ui/FloatingContextualButton/index.tsx +0 -1
  178. package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +13 -10
  179. package/src/plugins/table/ui/FloatingContextualMenu/__tests__/ContextualMenu.tsx +1 -0
  180. package/src/plugins/table/ui/FloatingContextualMenu/__tests__/FloatingContextualMenu.tsx +1 -0
  181. package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +0 -1
  182. package/src/plugins/table/ui/FloatingInsertButton/index.tsx +0 -1
  183. package/src/plugins/table/ui/LayoutButton/index.tsx +2 -4
  184. package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +1 -0
  185. package/src/plugins/table/utils/column-controls.ts +0 -1
  186. package/src/plugins/table/utils/decoration.ts +44 -5
  187. package/src/plugins/table/utils/dom.ts +0 -2
  188. package/src/plugins/table/utils/paste.ts +0 -1
  189. package/src/plugins/table/utils/row-controls.ts +0 -1
  190. package/types/package.json +5 -5
  191. package/ui/common-styles/package.json +14 -0
  192. package/ui/consts/package.json +14 -0
  193. package/dist/cjs/plugins/plugin-key.js +0 -17
  194. package/dist/cjs/plugins/table/todo-stubs.js +0 -10
  195. package/dist/cjs/types.js +0 -5
  196. package/dist/es2019/plugins/plugin-key.js +0 -3
  197. package/dist/es2019/plugins/table/todo-stubs.js +0 -1
  198. package/dist/es2019/types.js +0 -1
  199. package/dist/esm/plugins/plugin-key.js +0 -5
  200. package/dist/esm/plugins/table/todo-stubs.js +0 -1
  201. package/dist/esm/types.js +0 -1
  202. package/dist/types/plugins/plugin-key.d.ts +0 -4
  203. package/dist/types/plugins/table/todo-stubs.d.ts +0 -1
  204. package/dist/types/types.d.ts +0 -3
  205. package/dist/types-ts4.0/plugins/plugin-key.d.ts +0 -4
  206. package/dist/types-ts4.0/plugins/table/todo-stubs.d.ts +0 -1
  207. package/dist/types-ts4.0/types.d.ts +0 -3
  208. package/src/plugins/plugin-key.ts +0 -7
  209. package/src/plugins/table/__tests__/integration/table-controls-selection.ts +0 -70
  210. package/src/plugins/table/__tests__/unit/event-handlers.ts +0 -130
  211. package/src/plugins/table/todo-stubs.ts +0 -1
  212. package/src/types.ts +0 -3
  213. package/tmp/api-report-tmp.d.ts +0 -91
@@ -55,75 +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
- inputMethod: INPUT_METHOD.CONTEXT_MENU,
74
- // TODO: merge with floating toolbar once command is updated
75
- horizontalCells: horizontalCells,
76
- verticalCells: verticalCells,
77
- totalCells: totalCells,
78
- totalRowCount: totalRowCount,
79
- totalColumnCount: totalColumnCount
80
- },
81
- eventType: EVENT_TYPE.TRACK
82
- };
83
- })(editorAnalyticsAPI)(function (state, dispatch) {
84
- if (dispatch) {
85
- dispatch(mergeCells(state.tr));
86
- }
87
-
88
- return true;
89
- });
90
- };
91
- export var splitCellWithAnalytics = function splitCellWithAnalytics(editorAnalyticsAPI) {
92
- return withEditorAnalyticsAPI(function (_ref3) {
93
- var selection = _ref3.selection;
94
-
95
- var _getSelectedCellInfo3 = getSelectedCellInfo(selection),
96
- totalRowCount = _getSelectedCellInfo3.totalRowCount,
97
- totalColumnCount = _getSelectedCellInfo3.totalColumnCount;
58
+ return function (inputMethod) {
59
+ return withEditorAnalyticsAPI(function (_ref2) {
60
+ var selection = _ref2.selection;
98
61
 
99
- 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;
100
68
 
101
- if (cell) {
102
- var _cell$node$attrs = cell.node.attrs,
103
- verticalCells = _cell$node$attrs.rowspan,
104
- horizontalCells = _cell$node$attrs.colspan;
105
69
  return {
106
- action: TABLE_ACTION.SPLIT,
70
+ action: TABLE_ACTION.MERGED,
107
71
  actionSubject: ACTION_SUBJECT.TABLE,
108
72
  actionSubjectId: null,
109
73
  attributes: {
110
- inputMethod: INPUT_METHOD.CONTEXT_MENU,
111
- // TODO: merge with floating toolbar once command is updated
74
+ inputMethod: inputMethod,
112
75
  horizontalCells: horizontalCells,
113
76
  verticalCells: verticalCells,
114
- totalCells: horizontalCells * verticalCells,
77
+ totalCells: totalCells,
115
78
  totalRowCount: totalRowCount,
116
79
  totalColumnCount: totalColumnCount
117
80
  },
118
81
  eventType: EVENT_TYPE.TRACK
119
82
  };
120
- }
83
+ })(editorAnalyticsAPI)(function (state, dispatch) {
84
+ if (dispatch) {
85
+ dispatch(mergeCells(state.tr));
86
+ }
121
87
 
122
- return;
123
- })(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
+ };
124
126
  };
125
127
  export var setColorWithAnalytics = function setColorWithAnalytics(editorAnalyticsAPI) {
126
- return function (cellColor, targetCellPosition) {
128
+ return function (inputMethod, cellColor, targetCellPosition) {
127
129
  return withEditorAnalyticsAPI(function (_ref4) {
128
130
  var selection = _ref4.selection;
129
131
 
@@ -139,8 +141,7 @@ export var setColorWithAnalytics = function setColorWithAnalytics(editorAnalytic
139
141
  actionSubject: ACTION_SUBJECT.TABLE,
140
142
  actionSubjectId: null,
141
143
  attributes: {
142
- inputMethod: INPUT_METHOD.CONTEXT_MENU,
143
- // TODO: merge with floating toolbar once command is updated
144
+ inputMethod: inputMethod,
144
145
  cellColor: (tableBackgroundColorPalette.get(cellColor.toLowerCase()) || cellColor).toLowerCase(),
145
146
  horizontalCells: horizontalCells,
146
147
  verticalCells: verticalCells,
@@ -4,8 +4,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
4
4
  import { TableMap } from '@atlaskit/editor-tables/table-map';
5
5
  import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
6
6
  import { browser } from '@atlaskit/editor-common/utils';
7
- import { isElementInTableCell, isLastItemMediaGroup, setNodeSelection } from '@atlaskit/editor-common/utils'; // import { closestElement } from '@atlaskit/editor-core/src/utils/dom';
8
-
7
+ import { isElementInTableCell, isLastItemMediaGroup, setNodeSelection } from '@atlaskit/editor-common/utils';
9
8
  import { closestElement } from '@atlaskit/editor-common/utils';
10
9
  import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
11
10
  import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverColumns, selectColumn, setEditorFocus, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
@@ -6,8 +6,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
6
6
 
7
7
  // #region Imports
8
8
  import { findParentNodeOfType } from 'prosemirror-utils';
9
- import { findTable } from '@atlaskit/editor-tables/utils'; // import { isTextInput } from '../../utils/is-text-input';
10
-
9
+ import { findTable } from '@atlaskit/editor-tables/utils';
11
10
  import { isTextInput } from '@atlaskit/editor-common/utils';
12
11
  import { isTableCollapsible } from './utils/collapse';
13
12
  import { defaultTableSelection } from './pm-plugins/default-table-selection';
@@ -6,7 +6,7 @@ import { createTable } from '@atlaskit/editor-tables/utils';
6
6
  import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
7
7
  import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
8
8
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
9
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
9
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
10
10
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
11
11
  import { IconTable } from '@atlaskit/editor-common/icons';
12
12
  import { pluginConfig } from './create-plugin-config';
@@ -128,21 +128,38 @@ var tablesPlugin = function tablesPlugin(options) {
128
128
  }, {
129
129
  name: 'tableEditing',
130
130
  plugin: function plugin() {
131
- return tableEditing();
131
+ return tableEditing({
132
+ reportFixedTable: function reportFixedTable(_ref5) {
133
+ var _options$editorAnalyt;
134
+
135
+ var state = _ref5.state,
136
+ tr = _ref5.tr,
137
+ reason = _ref5.reason;
138
+ options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
139
+ action: TABLE_ACTION.FIXED,
140
+ actionSubject: ACTION_SUBJECT.TABLE,
141
+ actionSubjectId: null,
142
+ attributes: {
143
+ reason: reason
144
+ },
145
+ eventType: EVENT_TYPE.TRACK
146
+ })(tr);
147
+ }
148
+ });
132
149
  }
133
150
  }, {
134
151
  name: 'tableStickyHeaders',
135
- plugin: function plugin(_ref5) {
136
- var dispatch = _ref5.dispatch,
137
- eventDispatcher = _ref5.eventDispatcher;
152
+ plugin: function plugin(_ref6) {
153
+ var dispatch = _ref6.dispatch,
154
+ eventDispatcher = _ref6.eventDispatcher;
138
155
  return options && options.tableOptions.stickyHeaders ? createStickyHeadersPlugin(dispatch, eventDispatcher, function () {
139
156
  return [];
140
157
  }, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags) : undefined;
141
158
  }
142
159
  }, {
143
160
  name: 'tableLocalId',
144
- plugin: function plugin(_ref6) {
145
- var dispatch = _ref6.dispatch;
161
+ plugin: function plugin(_ref7) {
162
+ var dispatch = _ref7.dispatch;
146
163
  return createTableLocalIdPlugin(dispatch);
147
164
  }
148
165
  }, {
@@ -187,12 +204,12 @@ var tablesPlugin = function tablesPlugin(options) {
187
204
 
188
205
  return plugins;
189
206
  },
190
- contentComponent: function contentComponent(_ref7) {
191
- var editorView = _ref7.editorView,
192
- popupsMountPoint = _ref7.popupsMountPoint,
193
- popupsBoundariesElement = _ref7.popupsBoundariesElement,
194
- popupsScrollableElement = _ref7.popupsScrollableElement,
195
- dispatchAnalyticsEvent = _ref7.dispatchAnalyticsEvent;
207
+ contentComponent: function contentComponent(_ref8) {
208
+ var editorView = _ref8.editorView,
209
+ popupsMountPoint = _ref8.popupsMountPoint,
210
+ popupsBoundariesElement = _ref8.popupsBoundariesElement,
211
+ popupsScrollableElement = _ref8.popupsScrollableElement,
212
+ dispatchAnalyticsEvent = _ref8.dispatchAnalyticsEvent;
196
213
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
197
214
  component: ACTION_SUBJECT.TABLES_PLUGIN,
198
215
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -203,25 +220,25 @@ var tablesPlugin = function tablesPlugin(options) {
203
220
  tableResizingPluginState: tableResizingPluginKey,
204
221
  stickyHeadersState: stickyHeadersPluginKey
205
222
  },
206
- render: function render(_ref8) {
207
- var resizingPluginState = _ref8.tableResizingPluginState,
208
- stickyHeadersState = _ref8.stickyHeadersState,
209
- tablePluginState = _ref8.tablePluginState;
223
+ render: function render(_ref9) {
224
+ var resizingPluginState = _ref9.tableResizingPluginState,
225
+ stickyHeadersState = _ref9.stickyHeadersState,
226
+ tablePluginState = _ref9.tablePluginState;
210
227
  var state = editorView.state;
211
228
  var isDragging = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
212
- var _ref9 = tablePluginState,
213
- tableNode = _ref9.tableNode,
214
- tablePos = _ref9.tablePos,
215
- targetCellPosition = _ref9.targetCellPosition,
216
- isContextualMenuOpen = _ref9.isContextualMenuOpen,
217
- layout = _ref9.layout,
218
- tableRef = _ref9.tableRef,
219
- pluginConfig = _ref9.pluginConfig,
220
- insertColumnButtonIndex = _ref9.insertColumnButtonIndex,
221
- insertRowButtonIndex = _ref9.insertRowButtonIndex,
222
- isHeaderColumnEnabled = _ref9.isHeaderColumnEnabled,
223
- isHeaderRowEnabled = _ref9.isHeaderRowEnabled,
224
- tableWrapperTarget = _ref9.tableWrapperTarget;
229
+ var _ref10 = tablePluginState,
230
+ tableNode = _ref10.tableNode,
231
+ tablePos = _ref10.tablePos,
232
+ targetCellPosition = _ref10.targetCellPosition,
233
+ isContextualMenuOpen = _ref10.isContextualMenuOpen,
234
+ layout = _ref10.layout,
235
+ tableRef = _ref10.tableRef,
236
+ pluginConfig = _ref10.pluginConfig,
237
+ insertColumnButtonIndex = _ref10.insertColumnButtonIndex,
238
+ insertRowButtonIndex = _ref10.insertRowButtonIndex,
239
+ isHeaderColumnEnabled = _ref10.isHeaderColumnEnabled,
240
+ isHeaderRowEnabled = _ref10.isHeaderRowEnabled,
241
+ tableWrapperTarget = _ref10.tableWrapperTarget;
225
242
  var allowControls = pluginConfig.allowControls;
226
243
  var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
227
244
  return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !isDragging && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
@@ -286,9 +303,9 @@ var tablesPlugin = function tablesPlugin(options) {
286
303
  pluginsOptions: {
287
304
  // TODO: ED-14676 This is not the final API design
288
305
  // For now, we are using this on (insert-api/api.ts) but we may create a proper place for it
289
- createNodeHandler: function createNodeHandler(_ref10) {
290
- var nodeName = _ref10.nodeName,
291
- schema = _ref10.schema;
306
+ createNodeHandler: function createNodeHandler(_ref11) {
307
+ var nodeName = _ref11.nodeName,
308
+ schema = _ref11.schema;
292
309
 
293
310
  // An EditorPlugin may manage more than one node.
294
311
  if (nodeName !== 'table') {
@@ -300,8 +317,8 @@ var tablesPlugin = function tablesPlugin(options) {
300
317
  });
301
318
  return table;
302
319
  },
303
- quickInsert: function quickInsert(_ref11) {
304
- var formatMessage = _ref11.formatMessage;
320
+ quickInsert: function quickInsert(_ref12) {
321
+ var formatMessage = _ref12.formatMessage;
305
322
  return [{
306
323
  id: 'table',
307
324
  title: formatMessage(messages.table),
@@ -313,12 +330,12 @@ var tablesPlugin = function tablesPlugin(options) {
313
330
  return /*#__PURE__*/React.createElement(IconTable, null);
314
331
  },
315
332
  action: function action(insert, state) {
316
- var _options$editorAnalyt;
333
+ var _options$editorAnalyt2;
317
334
 
318
335
  var tr = insert(createTable({
319
336
  schema: state.schema
320
337
  }));
321
- options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
338
+ options === null || options === void 0 ? void 0 : (_options$editorAnalyt2 = options.editorAnalyticsAPI) === null || _options$editorAnalyt2 === void 0 ? void 0 : _options$editorAnalyt2.attachAnalyticsEvent({
322
339
  action: ACTION.INSERTED,
323
340
  actionSubject: ACTION_SUBJECT.DOCUMENT,
324
341
  actionSubjectId: ACTION_SUBJECT_ID.TABLE,
@@ -331,7 +348,7 @@ var tablesPlugin = function tablesPlugin(options) {
331
348
  }
332
349
  }];
333
350
  },
334
- floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
351
+ floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
335
352
  }
336
353
  };
337
354
  };
@@ -2,7 +2,7 @@ import { keymap } from 'prosemirror-keymap';
2
2
  import { chainCommands } from 'prosemirror-commands';
3
3
  import * as keymaps from '@atlaskit/editor-common/keymaps';
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
- import { createTable, goToNextCell, moveCursorBackward, triggerUnlessTableHeader } from '../commands';
5
+ import { triggerUnlessTableHeader, createTable, goToNextCell, moveCursorBackward } from '../commands';
6
6
  import { addRowAroundSelection, emptyMultipleCellsWithAnalytics, deleteTableIfSelectedWithAnalytics } from '../commands-with-analytics';
7
7
  import { addColumnAfter, addColumnBefore } from '../commands/insert';
8
8
  import { withEditorAnalyticsAPI } from '../utils/analytics';
@@ -16,12 +16,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
16
16
  * TODO: https://product-fabric.atlassian.net/browse/ED-12714
17
17
  *
18
18
  */
19
- // import { Dispatch } from '../../../event-dispatcher';
20
19
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
21
20
  import { PluginKey } from 'prosemirror-state';
22
21
  import rafSchedule from 'raf-schd';
23
- import { uuid } from '@atlaskit/adf-schema'; // import { stepAddsOneOf } from '../../../utils/step';
24
-
22
+ import { uuid } from '@atlaskit/adf-schema';
25
23
  import { stepAddsOneOf } from '@atlaskit/editor-common/utils';
26
24
  var pluginKey = new PluginKey('tableLocalIdPlugin');
27
25
 
@@ -1,3 +1,4 @@
1
1
  export { createPlugin } from './plugin';
2
2
  export { scaleTable } from './commands';
3
- export { pluginKey } from './plugin-key';
3
+ export { pluginKey } from './plugin-key';
4
+ export { getPluginState } from './plugin-factory';
@@ -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';
@@ -16,6 +20,11 @@ import tableMessages from './ui/messages';
16
20
  import { messages as ContextualMenuMessages } from './ui/FloatingContextualMenu/ContextualMenu';
17
21
  import { findParentDomRefOfType } from 'prosemirror-utils';
18
22
  import { closestElement } from '@atlaskit/editor-common/utils';
23
+ import { addColumnAfter, addRowAfter, tooltip, backspace } from '@atlaskit/editor-common/keymaps';
24
+ import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizing/utils/resize-state';
25
+ import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
26
+ import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
27
+ import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
19
28
  export var messages = defineMessages({
20
29
  tableOptions: {
21
30
  id: 'fabric.editor.tableOptions',
@@ -85,6 +94,8 @@ export var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _
85
94
  // with native widgets. It's enabled via a plugin config.
86
95
 
87
96
  export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorState, initialSelectionRect, _ref2, getEditorContainerWidth, editorAnalyticsAPI) {
97
+ var _pluginState$pluginCo, _pluginState$pluginCo2;
98
+
88
99
  var formatMessage = _ref2.formatMessage;
89
100
  var top = initialSelectionRect.top,
90
101
  bottom = initialSelectionRect.bottom,
@@ -92,6 +103,7 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
92
103
  left = initialSelectionRect.left;
93
104
  var numberOfColumns = right - left;
94
105
  var numberOfRows = bottom - top;
106
+ var pluginState = getPluginState(editorState);
95
107
  var options = [{
96
108
  id: 'editor.table.insertColumn',
97
109
  title: formatMessage(tableMessages.insertColumn),
@@ -106,7 +118,10 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
106
118
  return true;
107
119
  },
108
120
  selected: false,
109
- disabled: false
121
+ disabled: false,
122
+ elemAfter: jsx("div", {
123
+ css: shortcutStyle
124
+ }, tooltip(addColumnAfter))
110
125
  }, {
111
126
  id: 'editor.table.insertRow',
112
127
  title: formatMessage(tableMessages.insertRow),
@@ -124,7 +139,10 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
124
139
  return true;
125
140
  },
126
141
  selected: false,
127
- disabled: false
142
+ disabled: false,
143
+ elemAfter: jsx("div", {
144
+ css: shortcutStyle
145
+ }, tooltip(addRowAfter))
128
146
  }, {
129
147
  id: 'editor.table.removeColumns',
130
148
  title: formatMessage(tableMessages.removeColumns, {
@@ -160,16 +178,63 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
160
178
  }, {
161
179
  id: 'editor.table.mergeCells',
162
180
  title: formatMessage(ContextualMenuMessages.mergeCells),
163
- onClick: mergeCellsWithAnalytics(editorAnalyticsAPI),
181
+ onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
164
182
  selected: false,
165
183
  disabled: !canMergeCells(editorState.tr)
166
184
  }, {
167
185
  id: 'editor.table.splitCell',
168
186
  title: formatMessage(ContextualMenuMessages.splitCell),
169
- onClick: splitCellWithAnalytics(editorAnalyticsAPI),
187
+ onClick: splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
170
188
  selected: false,
171
189
  disabled: !splitCell(editorState)
172
- }, {
190
+ }];
191
+
192
+ if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
193
+ var distributeColumnWidths = function distributeColumnWidths(state, dispatch, view) {
194
+ var newResizeStateWithAnalytics = view ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, view.domAtPos.bind(view), getEditorContainerWidth) : undefined;
195
+
196
+ if (newResizeStateWithAnalytics) {
197
+ distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
198
+ return true;
199
+ }
200
+
201
+ return false;
202
+ };
203
+
204
+ options.push({
205
+ id: 'editor.table.distributeColumns',
206
+ title: formatMessage(ContextualMenuMessages.distributeColumns),
207
+ onClick: distributeColumnWidths,
208
+ selected: false,
209
+ disabled: numberOfColumns <= 1
210
+ });
211
+ }
212
+
213
+ if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo2 = pluginState.pluginConfig) !== null && _pluginState$pluginCo2 !== void 0 && _pluginState$pluginCo2.allowColumnSorting) {
214
+ var hasMergedCellsInTable = getMergedCellsPositions(editorState.tr).length > 0;
215
+ options.push({
216
+ id: 'editor.table.sortColumnAsc',
217
+ title: formatMessage(ContextualMenuMessages.sortColumnASC),
218
+ onClick: function onClick(state, dispatch) {
219
+ sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, initialSelectionRect.left, SortOrder.ASC)(state, dispatch);
220
+ return true;
221
+ },
222
+ selected: false,
223
+ disabled: hasMergedCellsInTable
224
+ });
225
+ options.push({
226
+ id: 'editor.table.sortColumnDesc',
227
+ title: formatMessage(ContextualMenuMessages.sortColumnDESC),
228
+ onClick: function onClick(state, dispatch) {
229
+ sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, initialSelectionRect.left, SortOrder.DESC)(state, dispatch);
230
+ return true;
231
+ },
232
+ selected: false,
233
+ disabled: hasMergedCellsInTable
234
+ });
235
+ }
236
+
237
+ options.push({
173
238
  id: 'editor.table.clearCells',
174
239
  title: formatMessage(ContextualMenuMessages.clearCells, {
175
240
  0: Math.max(numberOfColumns, numberOfRows)
@@ -182,14 +247,19 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
182
247
  return true;
183
248
  },
184
249
  selected: false,
185
- disabled: false
186
- }];
250
+ disabled: false,
251
+ elemAfter: jsx("div", {
252
+ css: shortcutStyle
253
+ }, tooltip(backspace))
254
+ });
187
255
  return {
188
256
  id: 'editor.table.cellOptions',
189
257
  type: 'dropdown',
190
258
  title: formatMessage(tableMessages.cellOptions),
191
- hidden: true,
192
- options: options
259
+ options: options,
260
+ // Increased dropdown item width to prevent labels from being truncated
261
+ dropdownWidth: 230,
262
+ showSelected: false
193
263
  };
194
264
  };
195
265
 
@@ -198,7 +268,7 @@ var getClosestSelectionRect = function getClosestSelectionRect(state) {
198
268
  return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
199
269
  };
200
270
 
201
- export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI) {
271
+ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags) {
202
272
  return function (config) {
203
273
  return function (state, intl) {
204
274
  var tableObject = findTable(state.selection);
@@ -208,7 +278,12 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
208
278
  if (tableObject && pluginState.editorHasFocus) {
209
279
  var nodeType = state.schema.nodes.table;
210
280
  var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
211
- var cellItems = getCellItems(config, state, intl, getEditorContainerWidth, editorAnalyticsAPI); // Check if we need to show confirm dialog for delete button
281
+
282
+ var _ref3 = getEditorFeatureFlags() || {},
283
+ tableCellOptionsInFloatingToolbar = _ref3.tableCellOptionsInFloatingToolbar;
284
+
285
+ var cellItems = getCellItems(config, state, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
286
+ var colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar); // Check if we need to show confirm dialog for delete button
212
287
 
213
288
  var confirmDialog;
214
289
  var localId = tableObject.node.attrs.localId;
@@ -241,9 +316,20 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
241
316
  getDomRef: getDomRef,
242
317
  nodeType: nodeType,
243
318
  offset: [0, 3],
244
- items: [menu, separator(menu.hidden)].concat(_toConsumableArray(cellItems), [{
319
+ items: [menu, separator(menu.hidden)].concat(_toConsumableArray(cellItems), _toConsumableArray(colorPicker), [{
245
320
  type: 'extensions-placeholder',
246
321
  separator: 'end'
322
+ }, {
323
+ type: 'copy-button',
324
+ items: [{
325
+ state: state,
326
+ formatMessage: intl.formatMessage,
327
+ nodeType: nodeType,
328
+ onMouseEnter: hoverTable(false, true),
329
+ onMouseLeave: clearHoverSelection()
330
+ }, {
331
+ type: 'separator'
332
+ }]
247
333
  }, {
248
334
  id: 'editor.table.delete',
249
335
  type: 'button',
@@ -255,7 +341,8 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
255
341
  onMouseLeave: clearHoverSelection(),
256
342
  title: intl.formatMessage(commonMessages.remove),
257
343
  confirmDialog: confirmDialog
258
- }])
344
+ }]),
345
+ scrollable: true
259
346
  };
260
347
  }
261
348
 
@@ -271,10 +358,10 @@ var separator = function separator(hidden) {
271
358
  };
272
359
  };
273
360
 
274
- var getCellItems = function getCellItems(pluginConfig, state, _ref3, getEditorContainerWidth, editorAnalyticsAPI) {
275
- var formatMessage = _ref3.formatMessage;
361
+ var getCellItems = function getCellItems(pluginConfig, state, _ref4, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) {
362
+ var formatMessage = _ref4.formatMessage;
276
363
 
277
- if (pluginConfig.allowCellOptionsInFloatingToolbar) {
364
+ if (pluginConfig.allowCellOptionsInFloatingToolbar || tableCellOptionsInFloatingToolbar) {
278
365
  var initialSelectionRect = getClosestSelectionRect(state);
279
366
 
280
367
  if (initialSelectionRect) {
@@ -286,4 +373,39 @@ var getCellItems = function getCellItems(pluginConfig, state, _ref3, getEditorCo
286
373
  }
287
374
 
288
375
  return [];
376
+ };
377
+
378
+ var getColorPicker = function getColorPicker(state, menu, _ref5, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) {
379
+ var _node$attrs;
380
+
381
+ var formatMessage = _ref5.formatMessage;
382
+
383
+ var _getPluginState2 = getPluginState(state),
384
+ targetCellPosition = _getPluginState2.targetCellPosition,
385
+ pluginConfig = _getPluginState2.pluginConfig;
386
+
387
+ if (!pluginConfig.allowBackgroundColor || !tableCellOptionsInFloatingToolbar) {
388
+ return [];
389
+ }
390
+
391
+ var node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : undefined;
392
+ var currentBackground = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff';
393
+ var defaultPalette = cellBackgroundColorPalette.find(function (item) {
394
+ return item.value === currentBackground;
395
+ }) || {
396
+ label: 'Custom',
397
+ value: currentBackground,
398
+ border: DEFAULT_BORDER_COLOR
399
+ };
400
+ return [{
401
+ id: 'editor.panel.colorPicker',
402
+ title: formatMessage(ContextualMenuMessages.cellBackground),
403
+ type: 'select',
404
+ selectType: 'color',
405
+ defaultValue: defaultPalette,
406
+ options: cellBackgroundColorPalette,
407
+ onChange: function onChange(option) {
408
+ return setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, option.value, targetCellPosition);
409
+ }
410
+ }, separator(menu.hidden)];
289
411
  };
@@ -5,10 +5,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
5
5
  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; }
6
6
 
7
7
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
8
- import { akEditorDefaultLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles'; // import { sendLogs } from '../../../utils/sendLogs';
9
- // import { sendLogs } from '@atlaskit/editor-core/src/utils/sendLogs';
10
-
11
- import { sendLogs } from '../todo-stubs';
8
+ import { akEditorDefaultLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
9
+ import { sendLogs } from '@atlaskit/editor-common/utils';
12
10
  import { calculateColumnWidth, contentWidth, getCellsRefsInColumn, getLayoutSize } from '../pm-plugins/table-resizing/utils';
13
11
  export var fireAnalytics = function fireAnalytics() {
14
12
  var properties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -148,8 +148,7 @@ export var FloatingContextualButtonInner = /*#__PURE__*/function (_React$Compone
148
148
  key: "shouldComponentUpdate",
149
149
  value: function shouldComponentUpdate(nextProps) {
150
150
  return this.props.tableNode !== nextProps.tableNode || this.props.targetCellPosition !== nextProps.targetCellPosition || this.props.layout !== nextProps.layout || this.props.isContextualMenuOpen !== nextProps.isContextualMenuOpen || this.props.isNumberColumnEnabled !== nextProps.isNumberColumnEnabled || this.props.stickyHeader !== nextProps.stickyHeader;
151
- } // TODO: restore
152
-
151
+ }
153
152
  }]);
154
153
 
155
154
  return FloatingContextualButtonInner;