@atlaskit/editor-plugin-table 5.0.0 → 5.2.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 (271) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/plugins/table/index.js +47 -37
  3. package/dist/cjs/plugins/table/nodeviews/TableCell.js +111 -0
  4. package/dist/cjs/plugins/table/nodeviews/TableNodeViewBase.js +30 -0
  5. package/dist/cjs/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +313 -307
  6. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/actions.js +12 -0
  7. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +27 -0
  8. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/consts.js +11 -0
  9. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/index.js +32 -0
  10. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin-factory.js +13 -0
  11. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin-key.js +8 -0
  12. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +28 -0
  13. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/reducer.js +28 -0
  14. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/types.js +5 -0
  15. package/dist/cjs/plugins/table/pm-plugins/main.js +16 -13
  16. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/index.js +1 -8
  17. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
  18. package/dist/cjs/plugins/table/utils/dom.js +31 -1
  19. package/dist/cjs/plugins/table/utils/index.js +12 -0
  20. package/dist/cjs/plugins/table/utils/nodes.js +31 -7
  21. package/dist/es2019/plugins/table/index.js +12 -3
  22. package/dist/es2019/plugins/table/nodeviews/{tableCell.js → TableCell.js} +28 -24
  23. package/dist/es2019/plugins/table/nodeviews/TableNodeViewBase.js +22 -0
  24. package/dist/es2019/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +273 -284
  25. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/actions.js +6 -0
  26. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +14 -0
  27. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/consts.js +5 -0
  28. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/index.js +3 -0
  29. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin-factory.js +8 -0
  30. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin-key.js +2 -0
  31. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +22 -0
  32. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/reducer.js +20 -0
  33. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/types.js +1 -0
  34. package/dist/es2019/plugins/table/pm-plugins/main.js +8 -8
  35. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/index.js +1 -2
  36. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
  37. package/dist/es2019/plugins/table/utils/dom.js +30 -0
  38. package/dist/es2019/plugins/table/utils/index.js +1 -1
  39. package/dist/es2019/plugins/table/utils/nodes.js +16 -0
  40. package/dist/esm/plugins/table/index.js +47 -37
  41. package/dist/esm/plugins/table/nodeviews/TableCell.js +105 -0
  42. package/dist/esm/plugins/table/nodeviews/TableNodeViewBase.js +24 -0
  43. package/dist/esm/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +314 -307
  44. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/actions.js +6 -0
  45. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +22 -0
  46. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/consts.js +5 -0
  47. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/index.js +3 -0
  48. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin-factory.js +7 -0
  49. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin-key.js +2 -0
  50. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +22 -0
  51. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/reducer.js +21 -0
  52. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/types.js +1 -0
  53. package/dist/esm/plugins/table/pm-plugins/main.js +16 -13
  54. package/dist/esm/plugins/table/pm-plugins/sticky-headers/index.js +1 -2
  55. package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
  56. package/dist/esm/plugins/table/utils/dom.js +30 -0
  57. package/dist/esm/plugins/table/utils/index.js +1 -1
  58. package/dist/esm/plugins/table/utils/nodes.js +24 -0
  59. package/dist/types/plugins/table/nodeviews/TableCell.d.ts +13 -0
  60. package/dist/types/plugins/table/nodeviews/TableNodeViewBase.d.ts +18 -0
  61. package/dist/types/plugins/table/nodeviews/TableRow.d.ts +60 -0
  62. package/dist/types/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +15 -0
  63. package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +4 -0
  64. package/dist/types/plugins/table/pm-plugins/drag-and-drop/consts.d.ts +6 -0
  65. package/dist/types/plugins/table/pm-plugins/drag-and-drop/index.d.ts +4 -0
  66. package/dist/types/plugins/table/pm-plugins/drag-and-drop/plugin-factory.d.ts +2 -0
  67. package/dist/types/plugins/table/pm-plugins/drag-and-drop/plugin-key.d.ts +3 -0
  68. package/dist/types/plugins/table/pm-plugins/drag-and-drop/plugin.d.ts +3 -0
  69. package/dist/types/plugins/table/pm-plugins/drag-and-drop/reducer.d.ts +4 -0
  70. package/dist/types/plugins/table/pm-plugins/drag-and-drop/types.d.ts +5 -0
  71. package/dist/types/plugins/table/pm-plugins/main.d.ts +1 -1
  72. package/dist/types/plugins/table/pm-plugins/sticky-headers/index.d.ts +0 -1
  73. package/dist/types/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +1 -1
  74. package/dist/types/plugins/table/types.d.ts +1 -0
  75. package/dist/types/plugins/table/utils/dom.d.ts +6 -0
  76. package/dist/types/plugins/table/utils/index.d.ts +1 -1
  77. package/dist/types/plugins/table/utils/nodes.d.ts +12 -2
  78. package/dist/types-ts4.5/i18n/cs.d.ts +37 -0
  79. package/dist/types-ts4.5/i18n/da.d.ts +35 -0
  80. package/dist/types-ts4.5/i18n/de.d.ts +35 -0
  81. package/dist/types-ts4.5/i18n/en.d.ts +37 -0
  82. package/dist/types-ts4.5/i18n/en_GB.d.ts +37 -0
  83. package/dist/types-ts4.5/i18n/en_ZZ.d.ts +37 -0
  84. package/dist/types-ts4.5/i18n/es.d.ts +35 -0
  85. package/dist/types-ts4.5/i18n/fi.d.ts +35 -0
  86. package/dist/types-ts4.5/i18n/fr.d.ts +37 -0
  87. package/dist/types-ts4.5/i18n/hu.d.ts +37 -0
  88. package/dist/types-ts4.5/i18n/it.d.ts +37 -0
  89. package/dist/types-ts4.5/i18n/ja.d.ts +37 -0
  90. package/dist/types-ts4.5/i18n/ko.d.ts +35 -0
  91. package/dist/types-ts4.5/i18n/nb.d.ts +35 -0
  92. package/dist/types-ts4.5/i18n/nl.d.ts +37 -0
  93. package/dist/types-ts4.5/i18n/pl.d.ts +37 -0
  94. package/dist/types-ts4.5/i18n/pt_BR.d.ts +37 -0
  95. package/dist/types-ts4.5/i18n/ru.d.ts +37 -0
  96. package/dist/types-ts4.5/i18n/sv.d.ts +35 -0
  97. package/dist/types-ts4.5/i18n/th.d.ts +35 -0
  98. package/dist/types-ts4.5/i18n/tr.d.ts +37 -0
  99. package/dist/types-ts4.5/i18n/uk.d.ts +37 -0
  100. package/dist/types-ts4.5/i18n/vi.d.ts +35 -0
  101. package/dist/types-ts4.5/i18n/zh.d.ts +37 -0
  102. package/dist/types-ts4.5/i18n/zh_TW.d.ts +37 -0
  103. package/dist/types-ts4.5/index.d.ts +2 -0
  104. package/dist/types-ts4.5/plugins/table/commands/clear.d.ts +3 -0
  105. package/dist/types-ts4.5/plugins/table/commands/collapse.d.ts +2 -0
  106. package/dist/types-ts4.5/plugins/table/commands/delete.d.ts +3 -0
  107. package/dist/types-ts4.5/plugins/table/commands/go-to-next-cell.d.ts +4 -0
  108. package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +8 -0
  109. package/dist/types-ts4.5/plugins/table/commands/index.d.ts +8 -0
  110. package/dist/types-ts4.5/plugins/table/commands/insert.d.ts +9 -0
  111. package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +29 -0
  112. package/dist/types-ts4.5/plugins/table/commands/referentiality.d.ts +2 -0
  113. package/dist/types-ts4.5/plugins/table/commands/selection.d.ts +8 -0
  114. package/dist/types-ts4.5/plugins/table/commands/sort.d.ts +3 -0
  115. package/dist/types-ts4.5/plugins/table/commands/split-cell.d.ts +6 -0
  116. package/dist/types-ts4.5/plugins/table/commands/toggle.d.ts +12 -0
  117. package/dist/types-ts4.5/plugins/table/commands-with-analytics.d.ts +25 -0
  118. package/dist/types-ts4.5/plugins/table/create-plugin-config.d.ts +2 -0
  119. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +15 -0
  120. package/dist/types-ts4.5/plugins/table/handlers.d.ts +3 -0
  121. package/dist/types-ts4.5/plugins/table/index.d.ts +38 -0
  122. package/dist/types-ts4.5/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +24 -0
  123. package/dist/types-ts4.5/plugins/table/nodeviews/TableCell.d.ts +13 -0
  124. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +73 -0
  125. package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +44 -0
  126. package/dist/types-ts4.5/plugins/table/nodeviews/TableNodeViewBase.d.ts +18 -0
  127. package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +25 -0
  128. package/dist/types-ts4.5/plugins/table/nodeviews/TableRow.d.ts +60 -0
  129. package/dist/types-ts4.5/plugins/table/nodeviews/TableStickyScrollbar.d.ts +24 -0
  130. package/dist/types-ts4.5/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.d.ts +9 -0
  131. package/dist/types-ts4.5/plugins/table/nodeviews/__mocks__/OverridableMock.d.ts +9 -0
  132. package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +33 -0
  133. package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +26 -0
  134. package/dist/types-ts4.5/plugins/table/nodeviews/update-overflow-shadows.d.ts +1 -0
  135. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +7 -0
  136. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -0
  137. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +4 -0
  138. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +2 -0
  139. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/index.d.ts +3 -0
  140. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/types.d.ts +6 -0
  141. package/dist/types-ts4.5/plugins/table/pm-plugins/default-table-selection.d.ts +4 -0
  142. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +15 -0
  143. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +4 -0
  144. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/consts.d.ts +6 -0
  145. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/index.d.ts +4 -0
  146. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/plugin-factory.d.ts +2 -0
  147. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/plugin-key.d.ts +3 -0
  148. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/plugin.d.ts +3 -0
  149. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/reducer.d.ts +4 -0
  150. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/types.d.ts +5 -0
  151. package/dist/types-ts4.5/plugins/table/pm-plugins/keymap.d.ts +5 -0
  152. package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +8 -0
  153. package/dist/types-ts4.5/plugins/table/pm-plugins/plugin-factory.d.ts +1 -0
  154. package/dist/types-ts4.5/plugins/table/pm-plugins/plugin-key.d.ts +3 -0
  155. package/dist/types-ts4.5/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +15 -0
  156. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/commands.d.ts +3 -0
  157. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/index.d.ts +5 -0
  158. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin-key.d.ts +3 -0
  159. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +3 -0
  160. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +4 -0
  161. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/types.d.ts +16 -0
  162. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/util.d.ts +2 -0
  163. package/dist/types-ts4.5/plugins/table/pm-plugins/table-analytics.d.ts +23 -0
  164. package/dist/types-ts4.5/plugins/table/pm-plugins/table-local-id.d.ts +10 -0
  165. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/commands.d.ts +23 -0
  166. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +4 -0
  167. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/index.d.ts +3 -0
  168. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +4 -0
  169. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin-key.d.ts +3 -0
  170. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin.d.ts +6 -0
  171. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/reducer.d.ts +3 -0
  172. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +23 -0
  173. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/column-state.d.ts +14 -0
  174. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
  175. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/content-width.d.ts +4 -0
  176. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +12 -0
  177. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +13 -0
  178. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +20 -0
  179. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -0
  180. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
  181. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +29 -0
  182. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +21 -0
  183. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/types.d.ts +22 -0
  184. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.d.ts +1 -0
  185. package/dist/types-ts4.5/plugins/table/pm-plugins/table-selection-keymap.d.ts +5 -0
  186. package/dist/types-ts4.5/plugins/table/pm-plugins/table-width.d.ts +17 -0
  187. package/dist/types-ts4.5/plugins/table/reducer.d.ts +3 -0
  188. package/dist/types-ts4.5/plugins/table/toolbar.d.ts +36 -0
  189. package/dist/types-ts4.5/plugins/table/transforms/column-width.d.ts +37 -0
  190. package/dist/types-ts4.5/plugins/table/transforms/delete-columns.d.ts +4 -0
  191. package/dist/types-ts4.5/plugins/table/transforms/delete-rows.d.ts +3 -0
  192. package/dist/types-ts4.5/plugins/table/transforms/fix-tables.d.ts +9 -0
  193. package/dist/types-ts4.5/plugins/table/transforms/index.d.ts +6 -0
  194. package/dist/types-ts4.5/plugins/table/transforms/merge.d.ts +5 -0
  195. package/dist/types-ts4.5/plugins/table/transforms/replace-table.d.ts +5 -0
  196. package/dist/types-ts4.5/plugins/table/transforms/split.d.ts +9 -0
  197. package/dist/types-ts4.5/plugins/table/types.d.ts +343 -0
  198. package/dist/types-ts4.5/plugins/table/ui/ColumnResizeWidget/index.d.ts +9 -0
  199. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualButton/FixedButton.d.ts +23 -0
  200. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualButton/index.d.ts +21 -0
  201. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualButton/styles.d.ts +3 -0
  202. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +87 -0
  203. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/index.d.ts +23 -0
  204. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/styles.d.ts +2 -0
  205. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/DeleteButton.d.ts +13 -0
  206. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.d.ts +10 -0
  207. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +54 -0
  208. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/types.d.ts +1 -0
  209. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +13 -0
  210. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +3 -0
  211. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/index.d.ts +35 -0
  212. package/dist/types-ts4.5/plugins/table/ui/LayoutButton/index.d.ts +21 -0
  213. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +16 -0
  214. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +21 -0
  215. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +17 -0
  216. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +39 -0
  217. package/dist/types-ts4.5/plugins/table/ui/common-styles.d.ts +9 -0
  218. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +50 -0
  219. package/dist/types-ts4.5/plugins/table/ui/messages.d.ts +63 -0
  220. package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +15 -0
  221. package/dist/types-ts4.5/plugins/table/utils/analytics.d.ts +45 -0
  222. package/dist/types-ts4.5/plugins/table/utils/collapse.d.ts +29 -0
  223. package/dist/types-ts4.5/plugins/table/utils/column-controls.d.ts +10 -0
  224. package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +19 -0
  225. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +26 -0
  226. package/dist/types-ts4.5/plugins/table/utils/get-allow-add-column-custom-step.d.ts +2 -0
  227. package/dist/types-ts4.5/plugins/table/utils/guidelines.d.ts +2 -0
  228. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +11 -0
  229. package/dist/types-ts4.5/plugins/table/utils/nodes.d.ts +23 -0
  230. package/dist/types-ts4.5/plugins/table/utils/paste.d.ts +14 -0
  231. package/dist/types-ts4.5/plugins/table/utils/row-controls.d.ts +16 -0
  232. package/dist/types-ts4.5/plugins/table/utils/selection.d.ts +6 -0
  233. package/dist/types-ts4.5/plugins/table/utils/snapping.d.ts +10 -0
  234. package/dist/types-ts4.5/plugins/table/utils/table.d.ts +4 -0
  235. package/dist/types-ts4.5/plugins/table/utils/update-plugin-state-decorations.d.ts +4 -0
  236. package/dist/types-ts4.5/plugins/table-plugin.d.ts +2 -0
  237. package/dist/types-ts4.5/types/i18n.d.ts +5 -0
  238. package/package.json +3 -3
  239. package/report.api.md +2 -17
  240. package/src/__tests__/unit/nodeviews/cell.ts +2 -2
  241. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +25 -148
  242. package/src/plugins/table/index.tsx +14 -0
  243. package/src/plugins/table/nodeviews/{tableCell.tsx → TableCell.ts} +41 -46
  244. package/src/plugins/table/nodeviews/TableNodeViewBase.ts +32 -0
  245. package/src/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.ts → nodeviews/TableRow.ts} +193 -246
  246. package/src/plugins/table/pm-plugins/drag-and-drop/actions.ts +29 -0
  247. package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +32 -0
  248. package/src/plugins/table/pm-plugins/drag-and-drop/consts.ts +8 -0
  249. package/src/plugins/table/pm-plugins/drag-and-drop/index.ts +5 -0
  250. package/src/plugins/table/pm-plugins/drag-and-drop/plugin-factory.ts +8 -0
  251. package/src/plugins/table/pm-plugins/drag-and-drop/plugin-key.ts +7 -0
  252. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +32 -0
  253. package/src/plugins/table/pm-plugins/drag-and-drop/reducer.ts +26 -0
  254. package/src/plugins/table/pm-plugins/drag-and-drop/types.ts +6 -0
  255. package/src/plugins/table/pm-plugins/main.ts +10 -19
  256. package/src/plugins/table/pm-plugins/sticky-headers/index.ts +0 -1
  257. package/src/plugins/table/pm-plugins/sticky-headers/plugin.ts +1 -9
  258. package/src/plugins/table/types.ts +2 -0
  259. package/src/plugins/table/utils/dom.ts +38 -0
  260. package/src/plugins/table/utils/index.ts +2 -0
  261. package/src/plugins/table/utils/nodes.ts +30 -2
  262. package/tmp/api-report-tmp.d.ts +100 -0
  263. package/dist/cjs/plugins/table/nodeviews/tableCell.js +0 -99
  264. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -35
  265. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -29
  266. package/dist/esm/plugins/table/nodeviews/tableCell.js +0 -93
  267. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -29
  268. package/dist/types/plugins/table/nodeviews/tableCell.d.ts +0 -17
  269. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +0 -6
  270. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +0 -73
  271. package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.ts +0 -37
@@ -0,0 +1,2 @@
1
+ import { EditorState } from '@atlaskit/editor-prosemirror/state';
2
+ export declare function getAllowAddColumnCustomStep(state: EditorState): boolean;
@@ -0,0 +1,2 @@
1
+ import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
2
+ export declare const defaultGuidelines: GuidelineConfig[];
@@ -0,0 +1,11 @@
1
+ export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, isSelectionUpdated, } from './selection';
2
+ export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnLineResize, } from './decoration';
3
+ export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow, } from './nodes';
4
+ export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, } from './paste';
5
+ export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler, } from './dom';
6
+ export { getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, } from './column-controls';
7
+ export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow, } from './row-controls';
8
+ export type { RowParams } from './row-controls';
9
+ export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';
10
+ export { getMergedCellsPositions } from './table';
11
+ export { updatePluginStateDecorations } from './update-plugin-state-decorations';
@@ -0,0 +1,23 @@
1
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
2
+ import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
3
+ export declare const isIsolating: (node: PmNode) => boolean;
4
+ export declare const containsHeaderColumn: (table: PmNode) => boolean;
5
+ export declare const containsHeaderRow: (table: PmNode) => boolean;
6
+ export declare const checkIfHeaderColumnEnabled: (selection: Selection) => boolean;
7
+ export declare const checkIfHeaderRowEnabled: (selection: Selection) => boolean;
8
+ export declare const checkIfNumberColumnEnabled: (selection: Selection) => boolean;
9
+ export declare const isLayoutSupported: (state: EditorState) => boolean;
10
+ export declare const getTableWidth: (node: PmNode) => number;
11
+ export declare const tablesHaveDifferentColumnWidths: (currentTable: PmNode, previousTable: PmNode) => boolean;
12
+ export declare const tablesHaveDifferentNoOfColumns: (currentTable: PmNode, previousTable: PmNode) => boolean;
13
+ export declare const isTableNested: (state: EditorState, tablePos?: number) => boolean;
14
+ export declare const anyChildCellMergedAcrossRow: (node: PmNode) => boolean;
15
+ /**
16
+ * Check if a given node is a header row with this definition:
17
+ * - all children are tableHeader cells
18
+ * - no table cells have been have merged with other table row cells
19
+ *
20
+ * @param node ProseMirror node
21
+ * @return boolean if it meets definition
22
+ */
23
+ export declare const supportedHeaderRow: (node: PmNode) => boolean;
@@ -0,0 +1,14 @@
1
+ import { Fragment, Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
2
+ import { EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ export declare const unwrapContentFromTable: (maybeTable: PMNode) => PMNode | PMNode[];
4
+ export declare const removeTableFromFirstChild: (node: PMNode, i: number) => PMNode | PMNode[];
5
+ export declare const removeTableFromLastChild: (node: PMNode, i: number, fragment: Fragment) => PMNode | PMNode[];
6
+ /**
7
+ * When we copy from a table cell with a hardBreak at the end,
8
+ * the slice generated will come with a hardBreak outside of the table.
9
+ * This code will look for that pattern and fix it.
10
+ */
11
+ export declare const transformSliceToFixHardBreakProblemOnCopyFromCell: (slice: Slice, schema: Schema) => Slice;
12
+ export declare const transformSliceToRemoveOpenTable: (slice: Slice, schema: Schema) => Slice;
13
+ export declare const transformSliceToCorrectEmptyTableCells: (slice: Slice, schema: Schema) => Slice;
14
+ export declare function isHeaderRowRequired(state: EditorState): boolean | undefined;
@@ -0,0 +1,16 @@
1
+ import { Schema } from '@atlaskit/editor-prosemirror/model';
2
+ import { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ export interface RowParams {
4
+ startIndex: number;
5
+ endIndex: number;
6
+ height: number;
7
+ }
8
+ export declare const getRowHeights: (tableRef: HTMLTableElement) => number[];
9
+ export declare const isRowDeleteButtonVisible: (selection: Selection) => boolean;
10
+ export declare const getRowDeleteButtonParams: (rowsHeights: Array<number | undefined>, selection: Selection, offsetTop?: number) => {
11
+ top: number;
12
+ indexes: number[];
13
+ } | null;
14
+ export declare const getRowsParams: (rowsHeights: Array<number | undefined>) => RowParams[];
15
+ export declare const getRowClassNames: (index: number, selection: Selection, hoveredRows?: number[], isInDanger?: boolean, isResizing?: boolean) => string;
16
+ export declare const copyPreviousRow: (schema: Schema) => (insertNewRowIndex: number) => (tr: Transaction) => Transaction;
@@ -0,0 +1,6 @@
1
+ import { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import { Rect } from '@atlaskit/editor-tables/table-map';
3
+ export declare const isSelectionUpdated: (oldSelection: Selection, newSelection?: Selection) => boolean;
4
+ export declare const normalizeSelection: (tr: Transaction) => Transaction;
5
+ export declare const getSelectedColumnIndexes: (selectionRect: Rect) => number[];
6
+ export declare const getSelectedRowIndexes: (selectionRect: Rect) => number[];
@@ -0,0 +1,10 @@
1
+ import { type GuidelineConfig } from '@atlaskit/editor-common/guideline';
2
+ export declare const calculateDefaultSnappings: (lengthOffset?: number) => number[];
3
+ export declare const defaultSnappingWidths: number[];
4
+ /**
5
+ * Returns keys of guidelines that are closest to the table and withthin the snapGap
6
+ */
7
+ export declare const findClosestSnap: (currentWidth: number, snapWidths: number[], guidelines: GuidelineConfig[], snapGap?: number, tolerance?: number) => {
8
+ gap: number;
9
+ keys: string[];
10
+ };
@@ -0,0 +1,4 @@
1
+ import { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import { Rect } from '@atlaskit/editor-tables/table-map';
3
+ export declare const getMergedCellsPositions: (tr: Transaction) => number[];
4
+ export declare const colsToRect: (cols: Array<number>, noOfRows: number) => Rect;
@@ -0,0 +1,4 @@
1
+ import { EditorState } from '@atlaskit/editor-prosemirror/state';
2
+ import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
+ import { TableDecorations } from '../types';
4
+ export declare const updatePluginStateDecorations: (state: EditorState, decorations: Decoration[], key: TableDecorations) => DecorationSet;
@@ -0,0 +1,2 @@
1
+ import { default as tablesPlugin } from './table';
2
+ export default tablesPlugin;
@@ -0,0 +1,5 @@
1
+ export interface MessageDescriptor {
2
+ id: string;
3
+ description: string;
4
+ defaultMessage: string;
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "5.0.0",
3
+ "version": "5.2.0",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@atlaskit/adf-schema": "^32.0.0",
31
31
  "@atlaskit/custom-steps": "^0.0.2",
32
- "@atlaskit/editor-common": "^76.8.0",
32
+ "@atlaskit/editor-common": "^76.9.0",
33
33
  "@atlaskit/editor-palette": "1.5.1",
34
34
  "@atlaskit/editor-plugin-analytics": "^0.2.0",
35
35
  "@atlaskit/editor-plugin-content-insertion": "^0.1.0",
@@ -39,7 +39,7 @@
39
39
  "@atlaskit/icon": "^21.12.0",
40
40
  "@atlaskit/platform-feature-flags": "^0.2.1",
41
41
  "@atlaskit/theme": "^12.6.0",
42
- "@atlaskit/tokens": "^1.25.0",
42
+ "@atlaskit/tokens": "^1.26.0",
43
43
  "@atlaskit/tooltip": "^17.8.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "@emotion/react": "^11.7.1",
package/report.api.md CHANGED
@@ -19,12 +19,10 @@ import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
19
19
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
20
20
  import type { Command } from '@atlaskit/editor-common/types';
21
21
  import type { ContentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
22
- import type { EditorCommand } from '@atlaskit/editor-common/types';
23
- import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
24
22
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
25
23
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
26
24
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
27
- import type { OptionalPlugin } from '@atlaskit/editor-common/types';
25
+ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
28
26
  import type { TableLayout } from '@atlaskit/adf-schema';
29
27
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
30
28
 
@@ -70,17 +68,6 @@ interface PluginConfig {
70
68
  stickyHeaders?: boolean;
71
69
  }
72
70
 
73
- // @public (undocumented)
74
- type SelectionPlugin = NextEditorPlugin<
75
- 'selection',
76
- {
77
- pluginConfiguration: unknown;
78
- commands: {
79
- displayGapCursor: (toggle: boolean) => EditorCommand;
80
- };
81
- }
82
- >;
83
-
84
71
  // @public (undocumented)
85
72
  export type TablePlugin = NextEditorPlugin<
86
73
  'table',
@@ -94,7 +81,7 @@ export type TablePlugin = NextEditorPlugin<
94
81
  ContentInsertionPlugin,
95
82
  WidthPlugin,
96
83
  GuidelinePlugin,
97
- OptionalPlugin<SelectionPlugin>,
84
+ SelectionPlugin,
98
85
  ];
99
86
  }
100
87
  >;
@@ -108,8 +95,6 @@ interface TablePluginOptions {
108
95
  // (undocumented)
109
96
  dragAndDropEnabled?: boolean;
110
97
  // (undocumented)
111
- editorSelectionAPI?: EditorSelectionAPI;
112
- // (undocumented)
113
98
  fullWidthEnabled?: boolean;
114
99
  // (undocumented)
115
100
  getEditorFeatureFlags?: GetEditorFeatureFlags;
@@ -32,7 +32,7 @@ import {
32
32
  } from '@atlaskit/editor-test-helpers/doc-builder';
33
33
 
34
34
  import tablePlugin from '../../../plugins/table-plugin';
35
- import TableCellViews from '../../../plugins/table/nodeviews/tableCell';
35
+ import TableCell from '../../../plugins/table/nodeviews/TableCell';
36
36
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
37
37
  import type { PluginConfig } from '../../../plugins/table/types';
38
38
 
@@ -121,7 +121,7 @@ describe('table -> nodeviews -> tableCell.tsx', () => {
121
121
  const { state, dispatch } = editorView;
122
122
  const cell = findCellClosestToPos(state.doc.resolve(pos))!;
123
123
  const background = tableBackgroundColorNames.get('red');
124
- const updateSpy = jest.spyOn(TableCellViews.prototype, 'update');
124
+ const updateSpy = jest.spyOn(TableCell.prototype, 'update');
125
125
  dispatch(setCellAttrs(cell, { background })(state.tr));
126
126
  expect(updateSpy).toHaveReturnedWith(true);
127
127
  const cellDomNode = document.querySelector('td')!;
@@ -33,10 +33,11 @@ import {
33
33
 
34
34
  import tablePlugin from '../../../../plugins/table';
35
35
  import TableComponent from '../../../../plugins/table/nodeviews/TableComponent';
36
+ import TableRow from '../../../../plugins/table/nodeviews/TableRow';
36
37
  import { pluginKey } from '../../../../plugins/table/pm-plugins/plugin-key';
37
- import { TableRowNodeView } from '../../../../plugins/table/pm-plugins/sticky-headers';
38
38
  import { updateStickyState } from '../../../../plugins/table/pm-plugins/sticky-headers/commands';
39
39
  import { TableCssClassName } from '../../../../plugins/table/types';
40
+ import type { PluginConfig } from '../../../../plugins/table/types';
40
41
  import {
41
42
  stickyRowOffsetTop,
42
43
  tableScrollbarOffset,
@@ -56,8 +57,17 @@ jest.mock('@atlaskit/editor-common/ui', () => ({
56
57
  findOverflowScrollParent: jest.fn(() => jest.fn()),
57
58
  }));
58
59
 
59
- describe('TableRowNodeView', () => {
60
- let tableRowNodeView: TableRowNodeView;
60
+ describe('TableRow', () => {
61
+ const tableOptions = {
62
+ allowNumberColumn: true,
63
+ allowHeaderRow: true,
64
+ allowHeaderColumn: true,
65
+ permittedLayouts: 'all',
66
+ allowColumnResizing: true,
67
+ stickyHeaders: true,
68
+ } as PluginConfig;
69
+
70
+ let tableRowNodeView: TableRow;
61
71
  const fakeGetEditorFeatureFlags = jest.fn(() => ({}));
62
72
  const createEditor = createProsemirrorEditorFactory();
63
73
  const editor = (doc: DocBuilder) => {
@@ -72,7 +82,12 @@ describe('TableRowNodeView', () => {
72
82
  .add(widthPlugin)
73
83
  .add(guidelinePlugin)
74
84
  .add(selectionPlugin)
75
- .add(tablePlugin),
85
+ .add([
86
+ tablePlugin,
87
+ {
88
+ tableOptions,
89
+ },
90
+ ]),
76
91
  pluginKey,
77
92
  attachTo: document.body,
78
93
  });
@@ -94,121 +109,6 @@ describe('TableRowNodeView', () => {
94
109
  toJSON: jest.fn(),
95
110
  };
96
111
 
97
- describe('stickyHeader', () => {
98
- beforeEach(() => {
99
- const editorWithTableSticky = (doc: DocBuilder) =>
100
- createEditor({
101
- doc,
102
- preset: new Preset<LightEditorPlugin>()
103
- .add([featureFlagsPlugin, {}])
104
- .add([analyticsPlugin, {}])
105
- .add(contentInsertionPlugin)
106
- .add(widthPlugin)
107
- .add(guidelinePlugin)
108
- .add(selectionPlugin)
109
- .add(tablePlugin),
110
- pluginKey,
111
- });
112
- const editorData = editorWithTableSticky(
113
- doc(table({ localId: '' })(tr(tdEmpty, tdEmpty))),
114
- );
115
- editorView = editorData.editorView;
116
- eventDispatcher = editorData.eventDispatcher;
117
- tableRowNode = editorView.state.doc.firstChild!.firstChild!;
118
- tableRowDom = editorView.dom.getElementsByTagName('tr')[0];
119
- tableRowNodeView = new TableRowNodeView(
120
- tableRowNode,
121
- editorView,
122
- jest.fn(),
123
- eventDispatcher,
124
- );
125
- });
126
- afterEach(() => {
127
- jest.clearAllMocks();
128
- });
129
-
130
- function createBoundingClientRect(rect: any) {
131
- return {
132
- getBoundingClientRect: () => {
133
- return rect;
134
- },
135
- };
136
- }
137
-
138
- function setupMocks(
139
- tableRowNodeView: any,
140
- editorRect: any,
141
- tableRect: any,
142
- ) {
143
- jest.spyOn(tableRowNodeView as any, 'tree', 'get').mockReturnValue({
144
- wrapper: createBoundingClientRect(tableRect),
145
- });
146
-
147
- Object.defineProperty(tableRowNodeView, 'editorScrollableElement', {
148
- get() {
149
- return createBoundingClientRect(editorRect);
150
- },
151
- });
152
- Object.defineProperty(tableRowNodeView, 'dom', {
153
- get() {
154
- return {
155
- previousElementSibling: false,
156
- nextElementSibling: true,
157
- clientHeight: 20,
158
- };
159
- },
160
- });
161
-
162
- Object.defineProperty(tableRowNodeView, 'topPosEditorElement', {
163
- get() {
164
- return 50;
165
- },
166
- });
167
- }
168
-
169
- it('should make it sticky if table is taller than viewport', () => {
170
- const tableRect = { top: 10, bottom: 110, height: 100 };
171
- const editorRect = { top: 50, bottom: 100, height: 50 };
172
- setupMocks(tableRowNodeView, editorRect, tableRect);
173
- const res = tableRowNodeView.shouldHeaderStick(
174
- tableRowNodeView.tree as any,
175
- );
176
- expect(res).toBe(true);
177
- });
178
-
179
- it('should make it sticky if table is lower than the editor', () => {
180
- const tableRect = { top: 20, bottom: 120, height: 100 };
181
- const editorRect = { top: 50, bottom: 100, height: 50 };
182
- setupMocks(tableRowNodeView, editorRect, tableRect);
183
- const res = tableRowNodeView.shouldHeaderStick(
184
- tableRowNodeView.tree as any,
185
- );
186
- expect(res).toBe(true);
187
- });
188
-
189
- it('should make it non-sticky if table is higher than the editor', () => {
190
- const tableRect = { top: 60, bottom: 70, height: 50 };
191
- const editorRect = { top: 50, bottom: 150, height: 100 };
192
- setupMocks(tableRowNodeView, editorRect, tableRect);
193
-
194
- const res = tableRowNodeView.shouldHeaderStick(
195
- tableRowNodeView.tree as any,
196
- );
197
- expect(res).toBe(false);
198
- });
199
-
200
- it('should make it non-sticky if table out of viewport', () => {
201
- const tableRect = { top: -50, bottom: 20, height: 70 };
202
- const editorRect = { top: 50, bottom: 150, height: 100 };
203
- setupMocks(tableRowNodeView, editorRect, tableRect);
204
-
205
- const res = tableRowNodeView.shouldHeaderStick(
206
- tableRowNodeView.tree as any,
207
- );
208
- expect(res).toBe(false);
209
- });
210
- });
211
-
212
112
  describe('ignoreMutation', () => {
213
113
  beforeEach(() => {
214
114
  const editorData = editor(
@@ -217,10 +117,10 @@ describe('TableRowNodeView', () => {
217
117
  editorView = editorData.editorView;
218
118
  eventDispatcher = editorData.eventDispatcher;
219
119
  tableRowNode = editorView.state.doc.firstChild!.firstChild!;
220
- tableRowNodeView = new TableRowNodeView(
120
+ tableRowNodeView = new TableRow(
221
121
  tableRowNode,
222
122
  editorView,
223
- jest.fn(),
123
+ () => 0,
224
124
  eventDispatcher,
225
125
  );
226
126
  tableRowDom = editorView.dom.getElementsByTagName('tr')[0];
@@ -363,10 +263,10 @@ describe('TableRowNodeView', () => {
363
263
  tableRowDom = editorView.dom.getElementsByTagName('tr')[0];
364
264
  scrollContainer = mockScrollPositions(tableRowDom)!;
365
265
 
366
- tableRowNodeView = new TableRowNodeView(
266
+ tableRowNodeView = new TableRow(
367
267
  tableRowNode,
368
268
  editorView,
369
- jest.fn(),
269
+ () => 0,
370
270
  eventDispatcher,
371
271
  );
372
272
  tableRowNodeView.dom = tableRowDom;
@@ -616,19 +516,14 @@ describe('TableRowNodeView', () => {
616
516
  tableRowNode = editorView.state.doc.firstChild!.firstChild!;
617
517
  tableRowDom = editorView.dom.getElementsByTagName('tr')[0];
618
518
 
619
- tableRowNodeView = new TableRowNodeView(
519
+ tableRowNodeView = new TableRow(
620
520
  tableRowNode,
621
521
  editorView,
622
- jest.fn(),
522
+ () => 0,
623
523
  eventDispatcher,
624
524
  );
625
525
  tableRowNodeView.dom = tableRowDom;
626
526
 
627
- // Initialize with sticky off
628
- tableRowNodeView.isSticky = false;
629
- tableRowNodeView.top = 0;
630
- tableRowNodeView.padding = 0;
631
-
632
527
  makeRowHeaderNotStickySpy = jest.spyOn(
633
528
  tableRowNodeView as any,
634
529
  'makeRowHeaderNotSticky',
@@ -665,23 +560,5 @@ describe('TableRowNodeView', () => {
665
560
  });
666
561
  expect(makeRowHeaderNotStickySpy).toHaveBeenCalled();
667
562
  });
668
-
669
- it('should cause isSticky state to be set to false when called', () => {
670
- // Begin test with stickyheaders state on
671
- tableRowNodeView.isSticky = true;
672
- tableRowNodeView.top = 1;
673
- tableRowNodeView.padding = 1;
674
-
675
- tableRowNodeView.makeRowHeaderNotSticky(tableRef);
676
-
677
- expect(updateStickyState).toHaveBeenCalledWith(
678
- expect.objectContaining({
679
- sticky: false,
680
- }),
681
- );
682
- expect(tableRowNodeView.isSticky).toBe(false);
683
- expect(tableRowNodeView.top).toBe(0);
684
- expect(tableRowNodeView.padding).toBe(0);
685
- });
686
563
  });
687
564
  });
@@ -43,6 +43,10 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
43
43
 
44
44
  import { pluginConfig } from './create-plugin-config';
45
45
  import { createPlugin as createDecorationsPlugin } from './pm-plugins/decorations/plugin';
46
+ import {
47
+ createPlugin as createDragAndDropPlugin,
48
+ pluginKey as dragAndDropPluginKey,
49
+ } from './pm-plugins/drag-and-drop';
46
50
  import { keymapPlugin } from './pm-plugins/keymap';
47
51
  import { createPlugin } from './pm-plugins/main';
48
52
  import { pluginKey } from './pm-plugins/plugin-key';
@@ -180,6 +184,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
180
184
  breakoutEnabled,
181
185
  tableOptions,
182
186
  getEditorFeatureFlags,
187
+ dragAndDropEnabled,
183
188
  } = options || ({} as TablePluginOptions);
184
189
  return createPlugin(
185
190
  dispatchAnalyticsEvent,
@@ -194,6 +199,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
194
199
  fullWidthEnabled,
195
200
  tableResizingEnabled,
196
201
  wasFullWidthEnabled,
202
+ dragAndDropEnabled,
197
203
  editorAnalyticsAPI,
198
204
  api,
199
205
  );
@@ -266,6 +272,13 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
266
272
  )
267
273
  : undefined,
268
274
  },
275
+ {
276
+ name: 'tableDragAndDrop',
277
+ plugin: ({ dispatch, eventDispatcher }) =>
278
+ options?.dragAndDropEnabled
279
+ ? createDragAndDropPlugin(dispatch, eventDispatcher)
280
+ : undefined,
281
+ },
269
282
  {
270
283
  name: 'tableLocalId',
271
284
  plugin: ({ dispatch }) => createTableLocalIdPlugin(dispatch),
@@ -343,6 +356,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
343
356
  tableWidthPluginState: tableWidthPluginKey,
344
357
  tableResizingPluginState: tableResizingPluginKey,
345
358
  stickyHeadersState: stickyHeadersPluginKey,
359
+ dragAndDropState: dragAndDropPluginKey,
346
360
  }}
347
361
  render={({
348
362
  tableResizingPluginState: resizingPluginState,
@@ -1,53 +1,62 @@
1
1
  import uuid from 'uuid';
2
2
 
3
- import {
4
- CellDomAttrs,
5
- getCellAttrs,
6
- getCellDomAttrs,
7
- } from '@atlaskit/adf-schema';
8
- import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
9
- import type { getPosHandler } from '@atlaskit/editor-common/types';
10
- import { DOMSerializer, Node } from '@atlaskit/editor-prosemirror/model';
11
- import { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { CellDomAttrs } from '@atlaskit/adf-schema';
4
+ import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
5
+ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
6
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
7
+ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
8
+
9
+ import { getPluginState } from '../pm-plugins/plugin-factory';
10
+
11
+ import TableNodeView from './TableNodeViewBase';
12
12
 
13
13
  const DEFAULT_COL_SPAN = 1;
14
14
  const DEFAULT_ROW_SPAN = 1;
15
15
 
16
- export default class TableCellNodeView implements NodeView {
17
- node: Node;
18
- dom: HTMLElement;
19
- contentDOM: HTMLElement;
20
- getPos: getPosHandler;
21
- view: EditorView;
22
- providerFactory?: ProviderFactory;
23
- observer?: ResizeObserver;
24
-
16
+ export default class TableCell
17
+ extends TableNodeView<HTMLElement>
18
+ implements NodeView
19
+ {
25
20
  constructor(
26
- node: Node,
21
+ node: PMNode,
27
22
  view: EditorView,
28
- getPos: any,
29
- observer?: ResizeObserver,
23
+ getPos: () => number | undefined,
24
+ eventDispatcher: EventDispatcher,
25
+ private readonly observer?: ResizeObserver,
30
26
  ) {
31
- this.view = view;
32
- this.node = node;
27
+ super(node, view, getPos, eventDispatcher);
33
28
 
34
- const { dom, contentDOM } = DOMSerializer.renderSpec(
35
- document,
36
- node.type.spec.toDOM!(node),
37
- );
29
+ const { pluginConfig, isDragAndDropEnabled } = getPluginState(view.state);
38
30
 
39
- this.getPos = getPos;
40
- this.dom = dom as HTMLElement;
41
- this.contentDOM = contentDOM as HTMLElement;
31
+ this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
32
+ this.isDragAndDropEnabled = !!isDragAndDropEnabled;
42
33
 
43
34
  if (observer) {
44
35
  this.contentDOM.id = uuid();
45
- this.observer = observer;
46
36
  observer.observe(this.contentDOM);
47
37
  }
48
38
  }
49
39
 
50
- private updateNodeView(node: Node) {
40
+ // @ts-ignore
41
+ private isStickyHeaderEnabled: boolean;
42
+ // @ts-ignore
43
+ private isDragAndDropEnabled: boolean;
44
+
45
+ update(node: PMNode) {
46
+ const didUpdate = this.updateNodeView(node);
47
+ if (didUpdate) {
48
+ this.node = node;
49
+ }
50
+ return didUpdate;
51
+ }
52
+
53
+ destroy() {
54
+ if (this.observer) {
55
+ this.observer.unobserve(this.contentDOM);
56
+ }
57
+ }
58
+
59
+ private updateNodeView(node: PMNode) {
51
60
  if (this.node.type !== node.type) {
52
61
  return false;
53
62
  }
@@ -90,18 +99,4 @@ export default class TableCellNodeView implements NodeView {
90
99
 
91
100
  return false;
92
101
  }
93
-
94
- update(node: Node) {
95
- const didUpdate = this.updateNodeView(node);
96
- if (didUpdate) {
97
- this.node = node;
98
- }
99
- return didUpdate;
100
- }
101
-
102
- destroy() {
103
- if (this.observer) {
104
- this.observer.unobserve(this.contentDOM);
105
- }
106
- }
107
102
  }
@@ -0,0 +1,32 @@
1
+ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
3
+ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
4
+ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
5
+
6
+ export default abstract class TableNodeView<T extends HTMLElement>
7
+ implements NodeView
8
+ {
9
+ /**
10
+ * @constructor
11
+ */
12
+ constructor(
13
+ protected node: PmNode,
14
+ protected readonly view: EditorView,
15
+ protected readonly getPos: () => number | undefined,
16
+ protected readonly eventDispatcher: EventDispatcher,
17
+ ) {
18
+ const { dom, contentDOM } = DOMSerializer.renderSpec(
19
+ document,
20
+ node.type.spec.toDOM!(node),
21
+ );
22
+
23
+ this.dom = dom as T;
24
+ this.contentDOM = contentDOM as T;
25
+ }
26
+
27
+ /**
28
+ * Variables
29
+ */
30
+ dom: T;
31
+ contentDOM: T;
32
+ }