@atlaskit/editor-plugin-table 0.0.9 → 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 (219) hide show
  1. package/.eslintrc.js +35 -0
  2. package/CHANGELOG.md +29 -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/FloatingDeleteButton/DeleteButton.js +1 -1
  14. package/dist/cjs/plugins/table/ui/LayoutButton/index.js +3 -5
  15. package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
  16. package/dist/cjs/plugins/table/utils/column-controls.js +0 -1
  17. package/dist/cjs/plugins/table/utils/decoration.js +53 -4
  18. package/dist/cjs/plugins/table/utils/dom.js +0 -2
  19. package/dist/cjs/plugins/table/utils/paste.js +0 -1
  20. package/dist/cjs/version.json +1 -1
  21. package/dist/es2019/plugins/table/commands/hover.js +4 -4
  22. package/dist/es2019/plugins/table/commands-with-analytics.js +6 -9
  23. package/dist/es2019/plugins/table/event-handlers.js +1 -2
  24. package/dist/es2019/plugins/table/handlers.js +1 -2
  25. package/dist/es2019/plugins/table/index.js +23 -5
  26. package/dist/es2019/plugins/table/pm-plugins/keymap.js +1 -1
  27. package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +1 -3
  28. package/dist/es2019/plugins/table/pm-plugins/table-resizing/index.js +2 -1
  29. package/dist/es2019/plugins/table/toolbar.js +133 -16
  30. package/dist/es2019/plugins/table/transforms/fix-tables.js +2 -4
  31. package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +1 -2
  32. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
  33. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +2 -3
  34. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +1 -2
  35. package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +1 -2
  36. package/dist/es2019/plugins/table/ui/LayoutButton/index.js +3 -5
  37. package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
  38. package/dist/es2019/plugins/table/utils/column-controls.js +0 -1
  39. package/dist/es2019/plugins/table/utils/decoration.js +60 -25
  40. package/dist/es2019/plugins/table/utils/dom.js +0 -2
  41. package/dist/es2019/plugins/table/utils/paste.js +1 -2
  42. package/dist/es2019/plugins/table/utils/row-controls.js +1 -2
  43. package/dist/es2019/version.json +1 -1
  44. package/dist/esm/plugins/table/commands/hover.js +4 -4
  45. package/dist/esm/plugins/table/commands-with-analytics.js +56 -55
  46. package/dist/esm/plugins/table/event-handlers.js +1 -2
  47. package/dist/esm/plugins/table/handlers.js +1 -2
  48. package/dist/esm/plugins/table/index.js +55 -38
  49. package/dist/esm/plugins/table/pm-plugins/keymap.js +1 -1
  50. package/dist/esm/plugins/table/pm-plugins/table-local-id.js +1 -3
  51. package/dist/esm/plugins/table/pm-plugins/table-resizing/index.js +2 -1
  52. package/dist/esm/plugins/table/toolbar.js +139 -17
  53. package/dist/esm/plugins/table/transforms/fix-tables.js +2 -4
  54. package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +1 -2
  55. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
  56. package/dist/esm/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +2 -3
  57. package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +1 -2
  58. package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +1 -2
  59. package/dist/esm/plugins/table/ui/LayoutButton/index.js +3 -5
  60. package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
  61. package/dist/esm/plugins/table/utils/column-controls.js +0 -1
  62. package/dist/esm/plugins/table/utils/decoration.js +50 -4
  63. package/dist/esm/plugins/table/utils/dom.js +0 -2
  64. package/dist/esm/plugins/table/utils/paste.js +1 -2
  65. package/dist/esm/plugins/table/utils/row-controls.js +1 -2
  66. package/dist/esm/version.json +1 -1
  67. package/dist/types/plugins/table/commands-with-analytics.d.ts +5 -5
  68. package/dist/types/plugins/table/pm-plugins/table-resizing/index.d.ts +1 -0
  69. package/dist/types/plugins/table/toolbar.d.ts +2 -2
  70. package/dist/types/plugins/table/transforms/fix-tables.d.ts +1 -1
  71. package/dist/types/plugins/table/utils/decoration.d.ts +1 -1
  72. package/dist/types-ts4.0/plugins/table/commands-with-analytics.d.ts +5 -5
  73. package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/index.d.ts +1 -0
  74. package/dist/types-ts4.0/plugins/table/toolbar.d.ts +2 -2
  75. package/dist/types-ts4.0/plugins/table/transforms/fix-tables.d.ts +1 -1
  76. package/dist/types-ts4.0/plugins/table/utils/decoration.d.ts +1 -1
  77. package/examples/config.jsonc +14 -0
  78. package/package.json +15 -11
  79. package/plugin-key/package.json +14 -0
  80. package/report.api.md +1 -1
  81. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/auto-size-documents.ts +0 -0
  82. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/basic-table.ts +0 -0
  83. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/empty-paragraph-underneath-table.ts +0 -0
  84. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/even-columns.ts +0 -0
  85. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/layout-documents.ts +0 -0
  86. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/merged-rows-and-cols-document.ts +0 -0
  87. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/nested-in-extension.ts +0 -0
  88. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/paragraph-and-table-adf.json +0 -0
  89. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/resize-documents.ts +0 -0
  90. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/scale.ts +0 -0
  91. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-inside-layout.ts +0 -0
  92. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-min-width-columns-document.ts +0 -0
  93. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-multiline-date.adf.json +0 -0
  94. package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-text-and-empty-row.ts +0 -0
  95. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/auto-size.ts.snap +0 -0
  96. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/change-date-inside-table.ts.snap +0 -0
  97. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/copy-button.ts.snap +0 -0
  98. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-columns.ts.snap +0 -0
  99. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-column-in-full-width.ts.snap +0 -0
  100. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-column-with-empty-action.ts.snap +0 -0
  101. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-row-with-empty-action.ts.snap +0 -0
  102. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-rows.ts.snap +0 -0
  103. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-table-when-selected.ts.snap +0 -0
  104. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/deleting-empty-paragraph-under-table.ts.snap +0 -0
  105. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/even-columns.ts.snap +0 -0
  106. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/insert-cell-header-with-strong-mark.ts.snap +0 -0
  107. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/insert-row-inside-layout.ts.snap +0 -0
  108. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/layout.ts.snap +0 -0
  109. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/resize.ts.snap +0 -0
  110. package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/scale.ts.snap +0 -0
  111. package/src/{plugins/table/__tests__ → __tests__}/integration/arrow-down-into-table.ts +0 -0
  112. package/src/{plugins/table/__tests__ → __tests__}/integration/auto-size.ts +0 -0
  113. package/src/{plugins/table/__tests__ → __tests__}/integration/block-node-selection.ts +1 -0
  114. package/src/{plugins/table/__tests__ → __tests__}/integration/cell-selection.ts +0 -0
  115. package/src/{plugins/table/__tests__ → __tests__}/integration/change-date-inside-table.ts +0 -0
  116. package/src/{plugins/table/__tests__ → __tests__}/integration/copy-button.ts +1 -1
  117. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-columns.ts +2 -2
  118. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-column-in-full-width.ts +1 -1
  119. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-column-with-empty-action.ts +1 -1
  120. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-row-with-empty-action.ts +1 -1
  121. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-rows.ts +2 -2
  122. package/src/{plugins/table/__tests__ → __tests__}/integration/delete-table-when-selected.ts +0 -0
  123. package/src/{plugins/table/__tests__ → __tests__}/integration/deleting-empty-paragraph-under-table.ts +0 -0
  124. package/src/{plugins/table/__tests__ → __tests__}/integration/even-columns.ts +0 -0
  125. package/src/{plugins/table/__tests__ → __tests__}/integration/insert-cell-header-with-strong-mark.ts +0 -0
  126. package/src/{plugins/table/__tests__ → __tests__}/integration/insert-long-smart-link.ts +1 -0
  127. package/src/{plugins/table/__tests__ → __tests__}/integration/insert-row-inside-layout.ts +0 -0
  128. package/src/{plugins/table/__tests__ → __tests__}/integration/layout.ts +0 -0
  129. package/src/{plugins/table/__tests__ → __tests__}/integration/resize-handler.ts +0 -0
  130. package/src/{plugins/table/__tests__ → __tests__}/integration/resize.ts +1 -1
  131. package/src/{plugins/table/__tests__ → __tests__}/integration/scale.ts +0 -0
  132. package/src/__tests__/integration/table-controls-selection.ts +71 -0
  133. package/src/__tests__/unit/analytics.ts +8 -9
  134. package/src/{plugins/table/__tests__ → __tests__}/unit/commands/go-to-next-cell.ts +4 -4
  135. package/src/{plugins/table/__tests__ → __tests__}/unit/commands/insert.ts +4 -4
  136. package/src/{plugins/table/__tests__ → __tests__}/unit/commands/misc.ts +12 -6
  137. package/src/{plugins/table/__tests__ → __tests__}/unit/commands.ts +7 -7
  138. package/src/__tests__/unit/copy-button.ts +22 -0
  139. package/src/__tests__/unit/event-handlers.ts +120 -1
  140. package/src/{plugins/table/__tests__ → __tests__}/unit/get-toolbar-config.ts +8 -3
  141. package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/OverflowShadowsObserver.ts +2 -2
  142. package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/TableComponent.tsx +11 -11
  143. package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/table.ts +5 -5
  144. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/column-controls.ts +2 -2
  145. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/column-resizing.ts +9 -6
  146. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/plugin.ts +5 -5
  147. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/main-with-allow-collapse.ts +4 -4
  148. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/main.ts +6 -6
  149. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +2 -2
  150. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/sticky-headers/tableRow.tsx +16 -13
  151. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-local-id.ts +3 -6
  152. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-resizing/colgroup.ts +1 -1
  153. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-resizing/event-handlers.ts +3 -3
  154. package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-selection-keymap.ts +3 -3
  155. package/src/{plugins/table/__tests__ → __tests__}/unit/toolbar.ts +5 -9
  156. package/src/__tests__/unit/ui/DeleteButton.tsx +35 -0
  157. package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +26 -64
  158. package/src/{plugins/table/__tests__ → __tests__}/unit/utils/collapse.ts +2 -2
  159. package/src/{plugins/table/__tests__ → __tests__}/unit/utils/column-controls.ts +1 -1
  160. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__fixtures__/table-with-100-numbered-list-items.json +0 -0
  161. 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
  162. 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
  163. 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
  164. 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
  165. 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
  166. 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
  167. 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
  168. 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
  169. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/cell-options-menu.ts +2 -0
  170. package/src/__tests__/visual-regression/copy-button.ts +181 -0
  171. package/src/{plugins/table/__tests__ → __tests__}/visual-regression/index.ts +3 -1
  172. package/src/plugins/table/commands/hover.ts +4 -1
  173. package/src/plugins/table/commands-with-analytics.ts +12 -8
  174. package/src/plugins/table/event-handlers.ts +0 -1
  175. package/src/plugins/table/handlers.ts +0 -1
  176. package/src/plugins/table/index.tsx +28 -2
  177. package/src/plugins/table/pm-plugins/keymap.ts +1 -1
  178. package/src/plugins/table/pm-plugins/table-local-id.ts +0 -2
  179. package/src/plugins/table/pm-plugins/table-resizing/index.ts +1 -0
  180. package/src/plugins/table/{toolbar.ts → toolbar.tsx} +186 -14
  181. package/src/plugins/table/transforms/fix-tables.ts +2 -3
  182. package/src/plugins/table/ui/FloatingContextualButton/index.tsx +0 -1
  183. package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +13 -10
  184. package/src/plugins/table/ui/FloatingContextualMenu/__tests__/ContextualMenu.tsx +1 -0
  185. package/src/plugins/table/ui/FloatingContextualMenu/__tests__/FloatingContextualMenu.tsx +1 -0
  186. package/src/plugins/table/ui/FloatingDeleteButton/DeleteButton.tsx +1 -2
  187. package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +0 -1
  188. package/src/plugins/table/ui/FloatingInsertButton/index.tsx +0 -1
  189. package/src/plugins/table/ui/LayoutButton/index.tsx +2 -4
  190. package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +1 -0
  191. package/src/plugins/table/utils/column-controls.ts +0 -1
  192. package/src/plugins/table/utils/decoration.ts +44 -5
  193. package/src/plugins/table/utils/dom.ts +0 -2
  194. package/src/plugins/table/utils/paste.ts +0 -1
  195. package/src/plugins/table/utils/row-controls.ts +0 -1
  196. package/types/package.json +5 -5
  197. package/ui/common-styles/package.json +14 -0
  198. package/ui/consts/package.json +14 -0
  199. package/dist/cjs/plugins/plugin-key.js +0 -17
  200. package/dist/cjs/plugins/table/todo-stubs.js +0 -10
  201. package/dist/cjs/types.js +0 -5
  202. package/dist/es2019/plugins/plugin-key.js +0 -3
  203. package/dist/es2019/plugins/table/todo-stubs.js +0 -1
  204. package/dist/es2019/types.js +0 -1
  205. package/dist/esm/plugins/plugin-key.js +0 -5
  206. package/dist/esm/plugins/table/todo-stubs.js +0 -1
  207. package/dist/esm/types.js +0 -1
  208. package/dist/types/plugins/plugin-key.d.ts +0 -4
  209. package/dist/types/plugins/table/todo-stubs.d.ts +0 -1
  210. package/dist/types/types.d.ts +0 -3
  211. package/dist/types-ts4.0/plugins/plugin-key.d.ts +0 -4
  212. package/dist/types-ts4.0/plugins/table/todo-stubs.d.ts +0 -1
  213. package/dist/types-ts4.0/types.d.ts +0 -3
  214. package/src/plugins/plugin-key.ts +0 -7
  215. package/src/plugins/table/__tests__/integration/table-controls-selection.ts +0 -70
  216. package/src/plugins/table/__tests__/unit/event-handlers.ts +0 -130
  217. package/src/plugins/table/todo-stubs.ts +0 -1
  218. package/src/types.ts +0 -3
  219. package/tmp/api-report-tmp.d.ts +0 -91
@@ -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';
@@ -125,7 +125,25 @@ const tablesPlugin = options => {
125
125
  plugin: () => tableSelectionKeymapPlugin(options === null || options === void 0 ? void 0 : options.editorSelectionAPI)
126
126
  }, {
127
127
  name: 'tableEditing',
128
- plugin: () => tableEditing()
128
+ plugin: () => tableEditing({
129
+ reportFixedTable: ({
130
+ state,
131
+ tr,
132
+ reason
133
+ }) => {
134
+ var _options$editorAnalyt;
135
+
136
+ options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
137
+ action: TABLE_ACTION.FIXED,
138
+ actionSubject: ACTION_SUBJECT.TABLE,
139
+ actionSubjectId: null,
140
+ attributes: {
141
+ reason
142
+ },
143
+ eventType: EVENT_TYPE.TRACK
144
+ })(tr);
145
+ }
146
+ })
129
147
  }, {
130
148
  name: 'tableStickyHeaders',
131
149
  plugin: ({
@@ -313,12 +331,12 @@ const tablesPlugin = options => {
313
331
  icon: () => /*#__PURE__*/React.createElement(IconTable, null),
314
332
 
315
333
  action(insert, state) {
316
- var _options$editorAnalyt;
334
+ var _options$editorAnalyt2;
317
335
 
318
336
  const tr = insert(createTable({
319
337
  schema: state.schema
320
338
  }));
321
- options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
339
+ options === null || options === void 0 ? void 0 : (_options$editorAnalyt2 = options.editorAnalyticsAPI) === null || _options$editorAnalyt2 === void 0 ? void 0 : _options$editorAnalyt2.attachAnalyticsEvent({
322
340
  action: ACTION.INSERTED,
323
341
  actionSubject: ACTION_SUBJECT.DOCUMENT,
324
342
  actionSubjectId: ACTION_SUBJECT_ID.TABLE,
@@ -331,7 +349,7 @@ const tablesPlugin = options => {
331
349
  }
332
350
 
333
351
  }],
334
- floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
352
+ 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
353
  }
336
354
  };
337
355
  };
@@ -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';
@@ -10,12 +10,10 @@
10
10
  * TODO: https://product-fabric.atlassian.net/browse/ED-12714
11
11
  *
12
12
  */
13
- // import { Dispatch } from '../../../event-dispatcher';
14
13
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
15
14
  import { PluginKey } from 'prosemirror-state';
16
15
  import rafSchedule from 'raf-schd';
17
- import { uuid } from '@atlaskit/adf-schema'; // import { stepAddsOneOf } from '../../../utils/step';
18
-
16
+ import { uuid } from '@atlaskit/adf-schema';
19
17
  import { stepAddsOneOf } from '@atlaskit/editor-common/utils';
20
18
  const pluginKey = new PluginKey('tableLocalIdPlugin');
21
19
 
@@ -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,11 +1,14 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
1
3
  import { defineMessages } from 'react-intl-next';
2
4
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
3
5
  import commonMessages from '@atlaskit/editor-common/messages';
4
6
  import { clearHoverSelection, hoverTable } from './commands';
5
- import { deleteTableWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, insertRowWithAnalytics, deleteRowsWithAnalytics, mergeCellsWithAnalytics, splitCellWithAnalytics, deleteColumnsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
7
+ import { deleteTableWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, insertRowWithAnalytics, deleteRowsWithAnalytics, mergeCellsWithAnalytics, splitCellWithAnalytics, deleteColumnsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, wrapTableInExpandWithAnalytics, sortColumnWithAnalytics, setColorWithAnalytics, distributeColumnsWidthsWithAnalytics } from './commands-with-analytics';
6
8
  import { getPluginState } from './pm-plugins/plugin-factory';
7
9
  import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
8
10
  import { TableCssClassName } from './types';
11
+ import { getMergedCellsPositions } from './utils';
9
12
  import { isReferencedSource } from './utils/referentiality';
10
13
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
11
14
  import { findCellRectClosestToPos, findTable, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
@@ -15,6 +18,11 @@ import tableMessages from './ui/messages';
15
18
  import { messages as ContextualMenuMessages } from './ui/FloatingContextualMenu/ContextualMenu';
16
19
  import { findParentDomRefOfType } from 'prosemirror-utils';
17
20
  import { closestElement } from '@atlaskit/editor-common/utils';
21
+ import { addColumnAfter, addRowAfter, tooltip, backspace } from '@atlaskit/editor-common/keymaps';
22
+ import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizing/utils/resize-state';
23
+ import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
24
+ import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
25
+ import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
18
26
  export const messages = defineMessages({
19
27
  tableOptions: {
20
28
  id: 'fabric.editor.tableOptions',
@@ -85,6 +93,8 @@ export const getToolbarMenuConfig = (config, state, {
85
93
  export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
86
94
  formatMessage
87
95
  }, getEditorContainerWidth, editorAnalyticsAPI) => {
96
+ var _pluginState$pluginCo, _pluginState$pluginCo2;
97
+
88
98
  const {
89
99
  top,
90
100
  bottom,
@@ -93,6 +103,7 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
93
103
  } = initialSelectionRect;
94
104
  const numberOfColumns = right - left;
95
105
  const numberOfRows = bottom - top;
106
+ const pluginState = getPluginState(editorState);
96
107
  const options = [{
97
108
  id: 'editor.table.insertColumn',
98
109
  title: formatMessage(tableMessages.insertColumn),
@@ -107,7 +118,10 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
107
118
  return true;
108
119
  },
109
120
  selected: false,
110
- disabled: false
121
+ disabled: false,
122
+ elemAfter: jsx("div", {
123
+ css: shortcutStyle
124
+ }, tooltip(addColumnAfter))
111
125
  }, {
112
126
  id: 'editor.table.insertRow',
113
127
  title: formatMessage(tableMessages.insertRow),
@@ -125,7 +139,10 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
125
139
  return true;
126
140
  },
127
141
  selected: false,
128
- disabled: false
142
+ disabled: false,
143
+ elemAfter: jsx("div", {
144
+ css: shortcutStyle
145
+ }, tooltip(addRowAfter))
129
146
  }, {
130
147
  id: 'editor.table.removeColumns',
131
148
  title: formatMessage(tableMessages.removeColumns, {
@@ -161,16 +178,63 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
161
178
  }, {
162
179
  id: 'editor.table.mergeCells',
163
180
  title: formatMessage(ContextualMenuMessages.mergeCells),
164
- onClick: mergeCellsWithAnalytics(editorAnalyticsAPI),
181
+ onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
165
182
  selected: false,
166
183
  disabled: !canMergeCells(editorState.tr)
167
184
  }, {
168
185
  id: 'editor.table.splitCell',
169
186
  title: formatMessage(ContextualMenuMessages.splitCell),
170
- onClick: splitCellWithAnalytics(editorAnalyticsAPI),
187
+ onClick: splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
171
188
  selected: false,
172
189
  disabled: !splitCell(editorState)
173
- }, {
190
+ }];
191
+
192
+ if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
193
+ const distributeColumnWidths = (state, dispatch, view) => {
194
+ const 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
+ const hasMergedCellsInTable = getMergedCellsPositions(editorState.tr).length > 0;
215
+ options.push({
216
+ id: 'editor.table.sortColumnAsc',
217
+ title: formatMessage(ContextualMenuMessages.sortColumnASC),
218
+ 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: (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({
174
238
  id: 'editor.table.clearCells',
175
239
  title: formatMessage(ContextualMenuMessages.clearCells, {
176
240
  0: Math.max(numberOfColumns, numberOfRows)
@@ -183,14 +247,19 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
183
247
  return true;
184
248
  },
185
249
  selected: false,
186
- disabled: false
187
- }];
250
+ disabled: false,
251
+ elemAfter: jsx("div", {
252
+ css: shortcutStyle
253
+ }, tooltip(backspace))
254
+ });
188
255
  return {
189
256
  id: 'editor.table.cellOptions',
190
257
  type: 'dropdown',
191
258
  title: formatMessage(tableMessages.cellOptions),
192
- hidden: true,
193
- options
259
+ options,
260
+ // Increased dropdown item width to prevent labels from being truncated
261
+ dropdownWidth: 230,
262
+ showSelected: false
194
263
  };
195
264
  };
196
265
 
@@ -199,7 +268,7 @@ const getClosestSelectionRect = state => {
199
268
  return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
200
269
  };
201
270
 
202
- export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI) => config => (state, intl) => {
271
+ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags) => config => (state, intl) => {
203
272
  const tableObject = findTable(state.selection);
204
273
  const pluginState = getPluginState(state);
205
274
  const resizeState = tableResizingPluginKey.getState(state);
@@ -207,7 +276,11 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI) =>
207
276
  if (tableObject && pluginState.editorHasFocus) {
208
277
  const nodeType = state.schema.nodes.table;
209
278
  const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
210
- const cellItems = getCellItems(config, state, intl, getEditorContainerWidth, editorAnalyticsAPI); // Check if we need to show confirm dialog for delete button
279
+ const {
280
+ tableCellOptionsInFloatingToolbar
281
+ } = getEditorFeatureFlags() || {};
282
+ const cellItems = getCellItems(config, state, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
283
+ const colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar); // Check if we need to show confirm dialog for delete button
211
284
 
212
285
  let confirmDialog;
213
286
  const localId = tableObject.node.attrs.localId;
@@ -240,9 +313,20 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI) =>
240
313
  getDomRef,
241
314
  nodeType,
242
315
  offset: [0, 3],
243
- items: [menu, separator(menu.hidden), ...cellItems, {
316
+ items: [menu, separator(menu.hidden), ...cellItems, ...colorPicker, {
244
317
  type: 'extensions-placeholder',
245
318
  separator: 'end'
319
+ }, {
320
+ type: 'copy-button',
321
+ items: [{
322
+ state,
323
+ formatMessage: intl.formatMessage,
324
+ nodeType,
325
+ onMouseEnter: hoverTable(false, true),
326
+ onMouseLeave: clearHoverSelection()
327
+ }, {
328
+ type: 'separator'
329
+ }]
246
330
  }, {
247
331
  id: 'editor.table.delete',
248
332
  type: 'button',
@@ -254,7 +338,8 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI) =>
254
338
  onMouseLeave: clearHoverSelection(),
255
339
  title: intl.formatMessage(commonMessages.remove),
256
340
  confirmDialog
257
- }]
341
+ }],
342
+ scrollable: true
258
343
  };
259
344
  }
260
345
 
@@ -270,8 +355,8 @@ const separator = hidden => {
270
355
 
271
356
  const getCellItems = (pluginConfig, state, {
272
357
  formatMessage
273
- }, getEditorContainerWidth, editorAnalyticsAPI) => {
274
- if (pluginConfig.allowCellOptionsInFloatingToolbar) {
358
+ }, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) => {
359
+ if (pluginConfig.allowCellOptionsInFloatingToolbar || tableCellOptionsInFloatingToolbar) {
275
360
  const initialSelectionRect = getClosestSelectionRect(state);
276
361
 
277
362
  if (initialSelectionRect) {
@@ -283,4 +368,36 @@ const getCellItems = (pluginConfig, state, {
283
368
  }
284
369
 
285
370
  return [];
371
+ };
372
+
373
+ const getColorPicker = (state, menu, {
374
+ formatMessage
375
+ }, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) => {
376
+ var _node$attrs;
377
+
378
+ const {
379
+ targetCellPosition,
380
+ pluginConfig
381
+ } = getPluginState(state);
382
+
383
+ if (!pluginConfig.allowBackgroundColor || !tableCellOptionsInFloatingToolbar) {
384
+ return [];
385
+ }
386
+
387
+ const node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : undefined;
388
+ const currentBackground = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff';
389
+ const defaultPalette = cellBackgroundColorPalette.find(item => item.value === currentBackground) || {
390
+ label: 'Custom',
391
+ value: currentBackground,
392
+ border: DEFAULT_BORDER_COLOR
393
+ };
394
+ return [{
395
+ id: 'editor.panel.colorPicker',
396
+ title: formatMessage(ContextualMenuMessages.cellBackground),
397
+ type: 'select',
398
+ selectType: 'color',
399
+ defaultValue: defaultPalette,
400
+ options: cellBackgroundColorPalette,
401
+ onChange: option => setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, option.value, targetCellPosition)
402
+ }, separator(menu.hidden)];
286
403
  };
@@ -1,8 +1,6 @@
1
1
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
2
- import { akEditorDefaultLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles'; // import { sendLogs } from '../../../utils/sendLogs';
3
- // import { sendLogs } from '@atlaskit/editor-core/src/utils/sendLogs';
4
-
5
- import { sendLogs } from '../todo-stubs';
2
+ import { akEditorDefaultLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
3
+ import { sendLogs } from '@atlaskit/editor-common/utils';
6
4
  import { calculateColumnWidth, contentWidth, getCellsRefsInColumn, getLayoutSize } from '../pm-plugins/table-resizing/utils';
7
5
  export const fireAnalytics = (properties = {}) => sendLogs({
8
6
  events: [{
@@ -125,8 +125,7 @@ export class FloatingContextualButtonInner extends React.Component {
125
125
 
126
126
  shouldComponentUpdate(nextProps) {
127
127
  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;
128
- } // TODO: restore
129
-
128
+ }
130
129
 
131
130
  }
132
131
 
@@ -281,12 +281,12 @@ export class ContextualMenu extends Component {
281
281
  break;
282
282
 
283
283
  case 'merge':
284
- mergeCellsWithAnalytics(editorAnalyticsAPI)(state, dispatch);
284
+ mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU)(state, dispatch);
285
285
  this.toggleOpen();
286
286
  break;
287
287
 
288
288
  case 'split':
289
- splitCellWithAnalytics(editorAnalyticsAPI)(state, dispatch);
289
+ splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU)(state, dispatch);
290
290
  this.toggleOpen();
291
291
  break;
292
292
 
@@ -434,10 +434,8 @@ export class ContextualMenu extends Component {
434
434
  const {
435
435
  state,
436
436
  dispatch
437
- } = editorView; // setColorWithAnalytics(color, targetCellPosition)(state, dispatch);
438
- // TODO: restore
439
-
440
- setColorWithAnalytics(editorAnalyticsAPI)(color, targetCellPosition)(state, dispatch);
437
+ } = editorView;
438
+ setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, color, targetCellPosition)(state, dispatch);
441
439
  this.toggleOpen();
442
440
  });
443
441
  }
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { injectIntl } from 'react-intl-next'; // import { MessageDescriptor } from '../../../../types/i18n';
3
-
2
+ import { injectIntl } from 'react-intl-next';
4
3
  import { TableCssClassName as ClassName } from '../../types';
5
4
 
6
5
  const DeleteButton = ({
@@ -19,7 +18,7 @@ const DeleteButton = ({
19
18
  onMouseLeave: onMouseLeave
20
19
  }, /*#__PURE__*/React.createElement("button", {
21
20
  type: "button",
22
- title: formatMessage(removeLabel, {
21
+ "aria-label": formatMessage(removeLabel, {
23
22
  0: 1
24
23
  }),
25
24
  className: ClassName.CONTROLS_DELETE_BUTTON,
@@ -5,8 +5,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
5
5
  import { getSelectionRect, isTableSelected } from '@atlaskit/editor-tables/utils';
6
6
  import { createPortal } from 'react-dom';
7
7
  import { Popup } from '@atlaskit/editor-common/ui';
8
- import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles'; // import { closestElement } from '../../../../utils/dom';
9
-
8
+ import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
10
9
  import { closestElement } from '@atlaskit/editor-common/utils';
11
10
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
12
11
  import { clearHoverSelection, hoverColumns, hoverRows } from '../../commands';
@@ -6,8 +6,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
6
6
  import { findDomRefAtPos } from 'prosemirror-utils';
7
7
  import { findTable } from '@atlaskit/editor-tables/utils';
8
8
  import { injectIntl } from 'react-intl-next';
9
- import { Popup } from '@atlaskit/editor-common/ui'; // import { closestElement } from '../../../../utils/dom';
10
-
9
+ import { Popup } from '@atlaskit/editor-common/ui';
11
10
  import { closestElement } from '@atlaskit/editor-common/utils';
12
11
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
13
12
  import { insertColumnWithAnalytics, insertRowWithAnalytics } from '../../commands-with-analytics';
@@ -98,8 +98,7 @@ class LayoutButton extends React.Component {
98
98
  }
99
99
 
100
100
  renderSticky(button, targetRef, tableRef) {
101
- // const title = this.getTitle();
102
- const title = 'TODO MISSING TITLE';
101
+ const title = this.getTitle();
103
102
 
104
103
  if (!(targetRef instanceof HTMLElement) || !(tableRef instanceof HTMLElement)) {
105
104
  return null;
@@ -128,10 +127,9 @@ class LayoutButton extends React.Component {
128
127
 
129
128
  if (!targetRef) {
130
129
  return null;
131
- } // const title = this.getTitle();
132
-
130
+ }
133
131
 
134
- const title = 'TODO MISSING TITLE';
132
+ const title = this.getTitle();
135
133
  return /*#__PURE__*/React.createElement(Popup, {
136
134
  ariaLabel: title,
137
135
  target: targetRef,
@@ -84,7 +84,8 @@ class CornerControlComponent extends Component {
84
84
  }),
85
85
  style: {
86
86
  top: this.props.stickyTop !== undefined ? `${this.props.stickyTop}px` : undefined
87
- }
87
+ },
88
+ contentEditable: false
88
89
  }, /*#__PURE__*/React.createElement("button", {
89
90
  "aria-label": formatMessage(messages.cornerControl),
90
91
  type: "button",
@@ -2,7 +2,6 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
2
2
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
3
3
  import { findDomRefAtPos } from 'prosemirror-utils';
4
4
  import { findTable, getCellsInColumn, getSelectionRect, isColumnSelected, isTableSelected } from '@atlaskit/editor-tables/utils';
5
- // import { maphElem } from '@atlaskit/editor-core/src/utils/dom';
6
5
  import { maphElem } from '@atlaskit/editor-common/utils';
7
6
  import { TableCssClassName as ClassName } from '../types';
8
7
  import { tableDeleteButtonSize } from '../ui/consts';
@@ -1,7 +1,6 @@
1
1
  import { TableMap } from '@atlaskit/editor-tables/table-map';
2
2
  import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tables/utils';
3
3
  import { Decoration } from 'prosemirror-view';
4
- // import { nonNullable } from '@atlaskit/editor-core/src/utils';
5
4
  import { nonNullable } from '@atlaskit/editor-common/utils';
6
5
  import { TableCssClassName as ClassName, TableDecorations } from '../types';
7
6
 
@@ -14,40 +13,76 @@ export const createCellHoverDecoration = (cells, type) => cells.map(cell => Deco
14
13
  }, {
15
14
  key: TableDecorations.CELL_CONTROLS_HOVER
16
15
  }));
17
- export const createControlsHoverDecoration = (cells, type, danger, selected) => cells.map(cell => {
18
- const classes = [ClassName.HOVERED_CELL];
16
+ export const createControlsHoverDecoration = (cells, type, tr, danger, selected) => {
17
+ const table = findTable(tr.selection);
19
18
 
20
- if (danger) {
21
- classes.push(ClassName.HOVERED_CELL_IN_DANGER);
19
+ if (!table) {
20
+ return [];
22
21
  }
23
22
 
24
- if (selected) {
25
- classes.push(ClassName.SELECTED_CELL);
26
- }
23
+ const map = TableMap.get(table.node);
24
+ const [min, max] = cells.reduce(([min, max], cell) => {
25
+ if (min === null || cell.pos < min) {
26
+ min = cell.pos;
27
+ }
27
28
 
28
- classes.push(type === 'column' ? ClassName.HOVERED_COLUMN : type === 'row' ? ClassName.HOVERED_ROW : ClassName.HOVERED_TABLE);
29
- let key;
29
+ if (max === null || cell.pos > max) {
30
+ max = cell.pos;
31
+ }
32
+
33
+ return [min, max];
34
+ }, [null, null]);
30
35
 
31
- switch (type) {
32
- case 'row':
33
- key = TableDecorations.ROW_CONTROLS_HOVER;
34
- break;
36
+ if (min === null || max === null) {
37
+ return [];
38
+ }
35
39
 
36
- case 'column':
37
- key = TableDecorations.COLUMN_CONTROLS_HOVER;
38
- break;
40
+ let updatedCells = cells.map(x => x.pos); // ED-15246 fixed trello card table overflow issue
41
+ // If columns / rows have been merged the hovered selection is different to the actual selection
42
+ // So If the table cells are in danger we want to create a "rectangle" selection
43
+ // to match the "clicked" selection
39
44
 
40
- default:
41
- key = TableDecorations.TABLE_CONTROLS_HOVER;
42
- break;
45
+ if (danger) {
46
+ const rect = map.rectBetween(min - table.start, max - table.start);
47
+ updatedCells = map.cellsInRect(rect).map(x => x + table.start);
43
48
  }
44
49
 
45
- return Decoration.node(cell.pos, cell.pos + cell.node.nodeSize, {
46
- class: classes.join(' ')
47
- }, {
48
- key
50
+ return updatedCells.map(pos => {
51
+ const cell = tr.doc.nodeAt(pos);
52
+ const classes = [ClassName.HOVERED_CELL];
53
+
54
+ if (danger) {
55
+ classes.push(ClassName.HOVERED_CELL_IN_DANGER);
56
+ }
57
+
58
+ if (selected) {
59
+ classes.push(ClassName.SELECTED_CELL);
60
+ }
61
+
62
+ classes.push(type === 'column' ? ClassName.HOVERED_COLUMN : type === 'row' ? ClassName.HOVERED_ROW : ClassName.HOVERED_TABLE);
63
+ let key;
64
+
65
+ switch (type) {
66
+ case 'row':
67
+ key = TableDecorations.ROW_CONTROLS_HOVER;
68
+ break;
69
+
70
+ case 'column':
71
+ key = TableDecorations.COLUMN_CONTROLS_HOVER;
72
+ break;
73
+
74
+ default:
75
+ key = TableDecorations.TABLE_CONTROLS_HOVER;
76
+ break;
77
+ }
78
+
79
+ return Decoration.node(pos, pos + cell.nodeSize, {
80
+ class: classes.join(' ')
81
+ }, {
82
+ key
83
+ });
49
84
  });
50
- });
85
+ };
51
86
  export const createColumnSelectedDecoration = tr => {
52
87
  const {
53
88
  selection,
@@ -1,5 +1,3 @@
1
- // import { containsClassName } from '@atlaskit/editor-core/src/utils';
2
- // import { closestElement } from '@atlaskit/editor-core/src/utils/dom';
3
1
  import { closestElement, containsClassName } from '@atlaskit/editor-common/utils';
4
2
  import { TableCssClassName as ClassName } from '../types';
5
3
  import { tableToolbarSize } from '../ui/consts';
@@ -1,6 +1,5 @@
1
1
  import { Fragment, Slice } from 'prosemirror-model';
2
- import { flatten } from 'prosemirror-utils'; // import { flatmap, mapSlice } from '@atlaskit/editor-core/src/utils/slice';
3
-
2
+ import { flatten } from 'prosemirror-utils';
4
3
  import { flatmap, mapSlice } from '@atlaskit/editor-common/utils';
5
4
  import { getPluginState } from '../pm-plugins/plugin-factory'; // lifts up the content of each cell, returning an array of nodes
6
5
 
@@ -1,8 +1,7 @@
1
1
  import { TableMap } from '@atlaskit/editor-tables/table-map';
2
2
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
3
3
  import { safeInsert } from 'prosemirror-utils';
4
- import { findTable, getSelectionRect, isRowSelected, isTableSelected } from '@atlaskit/editor-tables/utils'; // import { parsePx } from '@atlaskit/editor-core/src/utils/dom';
5
-
4
+ import { findTable, getSelectionRect, isRowSelected, isTableSelected } from '@atlaskit/editor-tables/utils';
6
5
  import { parsePx } from '@atlaskit/editor-common/utils';
7
6
  import { TableCssClassName as ClassName } from '../types';
8
7
  import { tableDeleteButtonSize } from '../ui/consts';
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "0.0.9"
3
+ "version": "0.1.0"
4
4
  }