@atlaskit/editor-plugin-table 4.2.1 → 5.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 (264) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/plugins/table/commands/selection.js +19 -22
  3. package/dist/cjs/plugins/table/index.js +45 -38
  4. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/actions.js +12 -0
  5. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +27 -0
  6. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/consts.js +11 -0
  7. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/index.js +32 -0
  8. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin-factory.js +13 -0
  9. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin-key.js +8 -0
  10. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +28 -0
  11. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/reducer.js +28 -0
  12. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/types.js +5 -0
  13. package/dist/es2019/plugins/table/commands/selection.js +14 -20
  14. package/dist/es2019/plugins/table/index.js +10 -5
  15. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/actions.js +6 -0
  16. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +14 -0
  17. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/consts.js +5 -0
  18. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/index.js +3 -0
  19. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin-factory.js +8 -0
  20. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin-key.js +2 -0
  21. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +22 -0
  22. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/reducer.js +20 -0
  23. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/types.js +1 -0
  24. package/dist/esm/plugins/table/commands/selection.js +19 -22
  25. package/dist/esm/plugins/table/index.js +45 -39
  26. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/actions.js +6 -0
  27. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +22 -0
  28. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/consts.js +5 -0
  29. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/index.js +3 -0
  30. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin-factory.js +7 -0
  31. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin-key.js +2 -0
  32. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +22 -0
  33. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/reducer.js +21 -0
  34. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/types.js +1 -0
  35. package/dist/types/plugins/table/commands/selection.d.ts +4 -4
  36. package/dist/types/plugins/table/index.d.ts +3 -10
  37. package/dist/types/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +15 -0
  38. package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +4 -0
  39. package/dist/types/plugins/table/pm-plugins/drag-and-drop/consts.d.ts +6 -0
  40. package/dist/types/plugins/table/pm-plugins/drag-and-drop/index.d.ts +4 -0
  41. package/dist/types/plugins/table/pm-plugins/drag-and-drop/plugin-factory.d.ts +2 -0
  42. package/dist/types/plugins/table/pm-plugins/drag-and-drop/plugin-key.d.ts +3 -0
  43. package/dist/types/plugins/table/pm-plugins/drag-and-drop/plugin.d.ts +3 -0
  44. package/dist/types/plugins/table/pm-plugins/drag-and-drop/reducer.d.ts +4 -0
  45. package/dist/types/plugins/table/pm-plugins/drag-and-drop/types.d.ts +5 -0
  46. package/dist/types/plugins/table/pm-plugins/table-selection-keymap.d.ts +4 -3
  47. package/dist/types-ts4.5/i18n/cs.d.ts +37 -0
  48. package/dist/types-ts4.5/i18n/da.d.ts +35 -0
  49. package/dist/types-ts4.5/i18n/de.d.ts +35 -0
  50. package/dist/types-ts4.5/i18n/en.d.ts +37 -0
  51. package/dist/types-ts4.5/i18n/en_GB.d.ts +37 -0
  52. package/dist/types-ts4.5/i18n/en_ZZ.d.ts +37 -0
  53. package/dist/types-ts4.5/i18n/es.d.ts +35 -0
  54. package/dist/types-ts4.5/i18n/fi.d.ts +35 -0
  55. package/dist/types-ts4.5/i18n/fr.d.ts +37 -0
  56. package/dist/types-ts4.5/i18n/hu.d.ts +37 -0
  57. package/dist/types-ts4.5/i18n/it.d.ts +37 -0
  58. package/dist/types-ts4.5/i18n/ja.d.ts +37 -0
  59. package/dist/types-ts4.5/i18n/ko.d.ts +35 -0
  60. package/dist/types-ts4.5/i18n/nb.d.ts +35 -0
  61. package/dist/types-ts4.5/i18n/nl.d.ts +37 -0
  62. package/dist/types-ts4.5/i18n/pl.d.ts +37 -0
  63. package/dist/types-ts4.5/i18n/pt_BR.d.ts +37 -0
  64. package/dist/types-ts4.5/i18n/ru.d.ts +37 -0
  65. package/dist/types-ts4.5/i18n/sv.d.ts +35 -0
  66. package/dist/types-ts4.5/i18n/th.d.ts +35 -0
  67. package/dist/types-ts4.5/i18n/tr.d.ts +37 -0
  68. package/dist/types-ts4.5/i18n/uk.d.ts +37 -0
  69. package/dist/types-ts4.5/i18n/vi.d.ts +35 -0
  70. package/dist/types-ts4.5/i18n/zh.d.ts +37 -0
  71. package/dist/types-ts4.5/i18n/zh_TW.d.ts +37 -0
  72. package/dist/types-ts4.5/index.d.ts +2 -0
  73. package/dist/types-ts4.5/plugins/table/commands/clear.d.ts +3 -0
  74. package/dist/types-ts4.5/plugins/table/commands/collapse.d.ts +2 -0
  75. package/dist/types-ts4.5/plugins/table/commands/delete.d.ts +3 -0
  76. package/dist/types-ts4.5/plugins/table/commands/go-to-next-cell.d.ts +4 -0
  77. package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +8 -0
  78. package/dist/types-ts4.5/plugins/table/commands/index.d.ts +8 -0
  79. package/dist/types-ts4.5/plugins/table/commands/insert.d.ts +9 -0
  80. package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +29 -0
  81. package/dist/types-ts4.5/plugins/table/commands/referentiality.d.ts +2 -0
  82. package/dist/types-ts4.5/plugins/table/commands/selection.d.ts +8 -0
  83. package/dist/types-ts4.5/plugins/table/commands/sort.d.ts +3 -0
  84. package/dist/types-ts4.5/plugins/table/commands/split-cell.d.ts +6 -0
  85. package/dist/types-ts4.5/plugins/table/commands/toggle.d.ts +12 -0
  86. package/dist/types-ts4.5/plugins/table/commands-with-analytics.d.ts +25 -0
  87. package/dist/types-ts4.5/plugins/table/create-plugin-config.d.ts +2 -0
  88. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +15 -0
  89. package/dist/types-ts4.5/plugins/table/handlers.d.ts +3 -0
  90. package/dist/types-ts4.5/plugins/table/index.d.ts +38 -0
  91. package/dist/types-ts4.5/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +24 -0
  92. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +73 -0
  93. package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +44 -0
  94. package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +25 -0
  95. package/dist/types-ts4.5/plugins/table/nodeviews/TableStickyScrollbar.d.ts +24 -0
  96. package/dist/types-ts4.5/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.d.ts +9 -0
  97. package/dist/types-ts4.5/plugins/table/nodeviews/__mocks__/OverridableMock.d.ts +9 -0
  98. package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +33 -0
  99. package/dist/types-ts4.5/plugins/table/nodeviews/tableCell.d.ts +17 -0
  100. package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +26 -0
  101. package/dist/types-ts4.5/plugins/table/nodeviews/update-overflow-shadows.d.ts +1 -0
  102. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +7 -0
  103. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -0
  104. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +4 -0
  105. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +2 -0
  106. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/index.d.ts +3 -0
  107. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/types.d.ts +6 -0
  108. package/dist/types-ts4.5/plugins/table/pm-plugins/default-table-selection.d.ts +4 -0
  109. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +15 -0
  110. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +4 -0
  111. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/consts.d.ts +6 -0
  112. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/index.d.ts +4 -0
  113. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/plugin-factory.d.ts +2 -0
  114. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/plugin-key.d.ts +3 -0
  115. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/plugin.d.ts +3 -0
  116. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/reducer.d.ts +4 -0
  117. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/types.d.ts +5 -0
  118. package/dist/types-ts4.5/plugins/table/pm-plugins/keymap.d.ts +5 -0
  119. package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +8 -0
  120. package/dist/types-ts4.5/plugins/table/pm-plugins/plugin-factory.d.ts +1 -0
  121. package/dist/types-ts4.5/plugins/table/pm-plugins/plugin-key.d.ts +3 -0
  122. package/dist/types-ts4.5/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +15 -0
  123. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/commands.d.ts +3 -0
  124. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/index.d.ts +6 -0
  125. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +6 -0
  126. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +73 -0
  127. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin-key.d.ts +3 -0
  128. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +3 -0
  129. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +4 -0
  130. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/types.d.ts +16 -0
  131. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/util.d.ts +2 -0
  132. package/dist/types-ts4.5/plugins/table/pm-plugins/table-analytics.d.ts +23 -0
  133. package/dist/types-ts4.5/plugins/table/pm-plugins/table-local-id.d.ts +10 -0
  134. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/commands.d.ts +23 -0
  135. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +4 -0
  136. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/index.d.ts +3 -0
  137. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +4 -0
  138. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin-key.d.ts +3 -0
  139. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin.d.ts +6 -0
  140. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/reducer.d.ts +3 -0
  141. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +23 -0
  142. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/column-state.d.ts +14 -0
  143. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
  144. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/content-width.d.ts +4 -0
  145. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +12 -0
  146. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +13 -0
  147. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +20 -0
  148. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -0
  149. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
  150. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +29 -0
  151. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +21 -0
  152. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/types.d.ts +22 -0
  153. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.d.ts +1 -0
  154. package/dist/types-ts4.5/plugins/table/pm-plugins/table-selection-keymap.d.ts +5 -0
  155. package/dist/types-ts4.5/plugins/table/pm-plugins/table-width.d.ts +17 -0
  156. package/dist/types-ts4.5/plugins/table/reducer.d.ts +3 -0
  157. package/dist/types-ts4.5/plugins/table/toolbar.d.ts +36 -0
  158. package/dist/types-ts4.5/plugins/table/transforms/column-width.d.ts +37 -0
  159. package/dist/types-ts4.5/plugins/table/transforms/delete-columns.d.ts +4 -0
  160. package/dist/types-ts4.5/plugins/table/transforms/delete-rows.d.ts +3 -0
  161. package/dist/types-ts4.5/plugins/table/transforms/fix-tables.d.ts +9 -0
  162. package/dist/types-ts4.5/plugins/table/transforms/index.d.ts +6 -0
  163. package/dist/types-ts4.5/plugins/table/transforms/merge.d.ts +5 -0
  164. package/dist/types-ts4.5/plugins/table/transforms/replace-table.d.ts +5 -0
  165. package/dist/types-ts4.5/plugins/table/transforms/split.d.ts +9 -0
  166. package/dist/types-ts4.5/plugins/table/types.d.ts +342 -0
  167. package/dist/types-ts4.5/plugins/table/ui/ColumnResizeWidget/index.d.ts +9 -0
  168. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualButton/FixedButton.d.ts +23 -0
  169. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualButton/index.d.ts +21 -0
  170. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualButton/styles.d.ts +3 -0
  171. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +87 -0
  172. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/index.d.ts +23 -0
  173. package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/styles.d.ts +2 -0
  174. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/DeleteButton.d.ts +13 -0
  175. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.d.ts +10 -0
  176. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +54 -0
  177. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/types.d.ts +1 -0
  178. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +13 -0
  179. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +3 -0
  180. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/index.d.ts +35 -0
  181. package/dist/types-ts4.5/plugins/table/ui/LayoutButton/index.d.ts +21 -0
  182. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +16 -0
  183. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +21 -0
  184. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +17 -0
  185. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +39 -0
  186. package/dist/types-ts4.5/plugins/table/ui/common-styles.d.ts +9 -0
  187. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +50 -0
  188. package/dist/types-ts4.5/plugins/table/ui/messages.d.ts +63 -0
  189. package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +15 -0
  190. package/dist/types-ts4.5/plugins/table/utils/analytics.d.ts +45 -0
  191. package/dist/types-ts4.5/plugins/table/utils/collapse.d.ts +29 -0
  192. package/dist/types-ts4.5/plugins/table/utils/column-controls.d.ts +10 -0
  193. package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +19 -0
  194. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +20 -0
  195. package/dist/types-ts4.5/plugins/table/utils/get-allow-add-column-custom-step.d.ts +2 -0
  196. package/dist/types-ts4.5/plugins/table/utils/guidelines.d.ts +2 -0
  197. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +11 -0
  198. package/dist/types-ts4.5/plugins/table/utils/nodes.d.ts +13 -0
  199. package/dist/types-ts4.5/plugins/table/utils/paste.d.ts +14 -0
  200. package/dist/types-ts4.5/plugins/table/utils/row-controls.d.ts +16 -0
  201. package/dist/types-ts4.5/plugins/table/utils/selection.d.ts +6 -0
  202. package/dist/types-ts4.5/plugins/table/utils/snapping.d.ts +10 -0
  203. package/dist/types-ts4.5/plugins/table/utils/table.d.ts +4 -0
  204. package/dist/types-ts4.5/plugins/table/utils/update-plugin-state-decorations.d.ts +4 -0
  205. package/dist/types-ts4.5/plugins/table-plugin.d.ts +2 -0
  206. package/dist/types-ts4.5/types/i18n.d.ts +5 -0
  207. package/package.json +4 -3
  208. package/report.api.md +2 -17
  209. package/src/__tests__/unit/analytics.ts +1 -1
  210. package/src/__tests__/unit/collab.ts +1 -1
  211. package/src/__tests__/unit/commands/go-to-next-cell.ts +1 -1
  212. package/src/__tests__/unit/commands/insert.ts +1 -1
  213. package/src/__tests__/unit/commands/misc.ts +1 -1
  214. package/src/__tests__/unit/commands/sort.ts +1 -1
  215. package/src/__tests__/unit/commands.ts +1 -1
  216. package/src/__tests__/unit/copy-paste.ts +1 -1
  217. package/src/__tests__/unit/event-handlers/index.ts +1 -1
  218. package/src/__tests__/unit/event-handlers.ts +1 -1
  219. package/src/__tests__/unit/fix-tables.ts +1 -1
  220. package/src/__tests__/unit/get-toolbar-config.ts +1 -1
  221. package/src/__tests__/unit/handlers.ts +1 -2
  222. package/src/__tests__/unit/hover-selection.ts +1 -2
  223. package/src/__tests__/unit/index.ts +1 -2
  224. package/src/__tests__/unit/layout.ts +1 -2
  225. package/src/__tests__/unit/nodeviews/cell.ts +1 -1
  226. package/src/__tests__/unit/nodeviews/table.ts +1 -1
  227. package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +1 -1
  228. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +1 -1
  229. package/src/__tests__/unit/pm-plugins/main.ts +1 -1
  230. package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +1 -1
  231. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +1 -1
  232. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +1 -1
  233. package/src/__tests__/unit/pm-plugins/table-width.ts +1 -1
  234. package/src/__tests__/unit/sort-column.ts +1 -1
  235. package/src/__tests__/unit/toolbar.ts +1 -1
  236. package/src/__tests__/unit/transforms/delete-columns.ts +1 -1
  237. package/src/__tests__/unit/transforms/delete-rows.ts +1 -1
  238. package/src/__tests__/unit/transforms/merging.ts +1 -1
  239. package/src/__tests__/unit/ui/ContextualMenu.tsx +1 -1
  240. package/src/__tests__/unit/ui/CornerControls.tsx +1 -1
  241. package/src/__tests__/unit/ui/FloatingContextualButton.tsx +1 -1
  242. package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +1 -1
  243. package/src/__tests__/unit/ui/RowControls.tsx +1 -1
  244. package/src/__tests__/unit/ui/TableFloatingControls.tsx +1 -1
  245. package/src/__tests__/unit/undo-redo.ts +1 -1
  246. package/src/__tests__/unit/utils/collapse.ts +1 -1
  247. package/src/__tests__/unit/utils/nodes.ts +1 -1
  248. package/src/__tests__/unit/utils/row-controls.ts +1 -1
  249. package/src/__tests__/unit/utils.ts +1 -1
  250. package/src/plugins/table/commands/selection.ts +101 -33
  251. package/src/plugins/table/index.tsx +15 -17
  252. package/src/plugins/table/pm-plugins/drag-and-drop/actions.ts +29 -0
  253. package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +32 -0
  254. package/src/plugins/table/pm-plugins/drag-and-drop/consts.ts +8 -0
  255. package/src/plugins/table/pm-plugins/drag-and-drop/index.ts +5 -0
  256. package/src/plugins/table/pm-plugins/drag-and-drop/plugin-factory.ts +8 -0
  257. package/src/plugins/table/pm-plugins/drag-and-drop/plugin-key.ts +7 -0
  258. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +32 -0
  259. package/src/plugins/table/pm-plugins/drag-and-drop/reducer.ts +26 -0
  260. package/src/plugins/table/pm-plugins/drag-and-drop/types.ts +6 -0
  261. package/src/plugins/table/pm-plugins/table-selection-keymap.ts +6 -3
  262. package/tmp/api-report-tmp.d.ts +100 -0
  263. package/tsconfig.app.json +3 -0
  264. package/tsconfig.dev.json +3 -0
@@ -1,11 +1,11 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
2
  import type { DocBuilder } from '@atlaskit/editor-common/types';
3
3
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
4
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
5
4
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
5
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
7
6
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
8
7
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
8
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
9
9
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
10
10
  import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
11
11
  import type { Rect } from '@atlaskit/editor-tables/table-map';
@@ -1,11 +1,11 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
2
  import type { DocBuilder } from '@atlaskit/editor-common/types';
3
3
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
4
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
5
4
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
5
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
7
6
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
8
7
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
8
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
9
9
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
10
10
  import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
11
11
  import type { Rect } from '@atlaskit/editor-tables/table-map';
@@ -1,11 +1,11 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
2
  import type { DocBuilder } from '@atlaskit/editor-common/types';
3
3
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
4
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
5
4
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
5
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
7
6
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
8
7
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
8
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
9
9
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
10
10
  import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
11
11
  import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
@@ -4,11 +4,11 @@ import { render, screen } from '@testing-library/react';
4
4
  import { createIntl } from 'react-intl-next';
5
5
 
6
6
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
7
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
8
7
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
9
8
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
10
9
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
11
10
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
11
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
12
12
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
13
13
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
14
14
  import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
@@ -5,11 +5,11 @@ import { IntlProvider } from 'react-intl-next';
5
5
 
6
6
  import type { DocBuilder } from '@atlaskit/editor-common/types';
7
7
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
8
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
9
8
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
10
9
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
11
10
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
12
11
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
12
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
13
13
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
14
14
  import { isTableSelected } from '@atlaskit/editor-tables/utils';
15
15
  import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
@@ -6,11 +6,11 @@ import { IntlProvider } from 'react-intl-next';
6
6
  import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
7
7
  import type { DocBuilder } from '@atlaskit/editor-common/types';
8
8
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
9
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
10
9
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
11
10
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
12
11
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
13
12
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
13
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
14
14
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
15
15
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
16
16
  import * as prosemirrorUtils from '@atlaskit/editor-prosemirror/utils';
@@ -4,11 +4,11 @@ import { render, screen } from '@testing-library/react';
4
4
  import { IntlProvider } from 'react-intl-next';
5
5
 
6
6
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
7
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
8
7
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
9
8
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
10
9
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
11
10
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
11
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
12
12
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
13
13
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
14
14
  import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
@@ -6,11 +6,11 @@ import { IntlProvider } from 'react-intl-next';
6
6
  import type { DocBuilder } from '@atlaskit/editor-common/types';
7
7
  import { setTextSelection } from '@atlaskit/editor-common/utils';
8
8
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
9
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
10
9
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
11
10
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
12
11
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
13
12
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
13
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
14
14
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
15
15
  import { getSelectionRect, selectRow } from '@atlaskit/editor-tables/utils';
16
16
  import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
@@ -5,11 +5,11 @@ import { IntlProvider } from 'react-intl-next';
5
5
 
6
6
  import type { DocBuilder } from '@atlaskit/editor-common/types';
7
7
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
8
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
9
8
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
10
9
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
11
10
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
12
11
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
12
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
13
13
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
14
14
  import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
15
15
  import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
@@ -2,11 +2,11 @@ import clone from 'lodash/clone';
2
2
 
3
3
  import type { DocBuilder } from '@atlaskit/editor-common/types';
4
4
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
5
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
6
5
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
6
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
8
7
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
9
8
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
9
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
10
10
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
11
11
  import { redo, undo } from '@atlaskit/editor-prosemirror/history';
12
12
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -1,10 +1,10 @@
1
1
  import type { DocBuilder } from '@atlaskit/editor-common/types';
2
2
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
3
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
4
3
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
4
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
6
5
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
7
6
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
7
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
8
8
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
9
9
  import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
10
10
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
@@ -1,10 +1,10 @@
1
1
  import type { DocBuilder } from '@atlaskit/editor-common/types';
2
2
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
3
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
4
3
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
4
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
6
5
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
7
6
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
7
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
8
8
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
9
9
  import { findTable } from '@atlaskit/editor-tables/utils';
10
10
  import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
@@ -1,11 +1,11 @@
1
1
  import { uuid } from '@atlaskit/adf-schema';
2
2
  import type { DocBuilder } from '@atlaskit/editor-common/types';
3
3
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
4
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
5
4
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
5
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
7
6
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
8
7
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
8
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
9
9
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
10
10
  import { TableMap } from '@atlaskit/editor-tables/table-map';
11
11
  import { findTable } from '@atlaskit/editor-tables/utils';
@@ -1,10 +1,10 @@
1
1
  import type { DocBuilder } from '@atlaskit/editor-common/types';
2
2
  // eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
3
- import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
4
3
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
4
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
6
5
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
7
6
  import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
7
+ import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
8
8
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
9
9
  import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
10
10
  import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
@@ -1,13 +1,16 @@
1
+ import type { SelectionSharedState } from '@atlaskit/editor-common/selection';
1
2
  import {
2
- EditorSelectionAPI,
3
3
  GapCursorSelection,
4
4
  isSelectionAtEndOfNode,
5
5
  isSelectionAtStartOfNode,
6
6
  RelativeSelectionPos,
7
7
  Side,
8
8
  } from '@atlaskit/editor-common/selection';
9
- import type { Command } from '@atlaskit/editor-common/types';
10
- import {
9
+ import type {
10
+ Command,
11
+ ExtractInjectionAPI,
12
+ } from '@atlaskit/editor-common/types';
13
+ import type {
11
14
  Node as PmNode,
12
15
  ResolvedPos,
13
16
  } from '@atlaskit/editor-prosemirror/model';
@@ -16,13 +19,19 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
16
19
  import { TableMap } from '@atlaskit/editor-tables/table-map';
17
20
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
18
21
 
22
+ import type tablePlugin from '../index';
23
+
19
24
  export enum TableSelectionDirection {
20
25
  TopToBottom = 'TopToBottom',
21
26
  BottomToTop = 'BottomToTop',
22
27
  }
23
28
 
24
29
  export const arrowLeftFromTable =
25
- (editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
30
+ (
31
+ editorSelectionAPI:
32
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
33
+ | undefined,
34
+ ) =>
26
35
  (): Command =>
27
36
  (state, dispatch) => {
28
37
  const { selection } = state;
@@ -43,7 +52,11 @@ export const arrowLeftFromTable =
43
52
  };
44
53
 
45
54
  export const arrowRightFromTable =
46
- (editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
55
+ (
56
+ editorSelectionAPI:
57
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
58
+ | undefined,
59
+ ) =>
47
60
  (): Command =>
48
61
  (state, dispatch) => {
49
62
  const { selection } = state;
@@ -65,22 +78,30 @@ export const arrowRightFromTable =
65
78
  };
66
79
 
67
80
  const arrowLeftFromCellSelection =
68
- (editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
81
+ (
82
+ editorSelectionAPI:
83
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
84
+ | undefined,
85
+ ) =>
69
86
  (selection: CellSelection): Command =>
70
87
  (state, dispatch) => {
71
88
  if (isTableSelected(state.selection) && editorSelectionAPI) {
72
- const { selectionRelativeToNode } =
73
- editorSelectionAPI.getSelectionPluginState(state);
74
- if (selectionRelativeToNode === RelativeSelectionPos.Start) {
89
+ const selectionState: SelectionSharedState =
90
+ editorSelectionAPI.sharedState.currentState() || {};
91
+ if (
92
+ selectionState?.selectionRelativeToNode === RelativeSelectionPos.Start
93
+ ) {
75
94
  // we have full table cell selection and want to set gap cursor selection before table
76
95
  return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
77
- } else if (selectionRelativeToNode === RelativeSelectionPos.End) {
96
+ } else if (
97
+ selectionState?.selectionRelativeToNode === RelativeSelectionPos.End
98
+ ) {
78
99
  // we have full table cell selection and want to set selection at end of last cell
79
100
  return setSelectionAtEndOfLastCell(editorSelectionAPI)(selection)(
80
101
  state,
81
102
  dispatch,
82
103
  );
83
- } else if (selectionRelativeToNode === undefined) {
104
+ } else if (selectionState?.selectionRelativeToNode === undefined) {
84
105
  // we have full table cell selection and want to set selection at start of first cell
85
106
  return setSelectionAtStartOfFirstCell(editorSelectionAPI)(
86
107
  selection,
@@ -92,12 +113,16 @@ const arrowLeftFromCellSelection =
92
113
  };
93
114
 
94
115
  const arrowRightFromCellSelection =
95
- (editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
116
+ (
117
+ editorSelectionAPI:
118
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
119
+ | undefined,
120
+ ) =>
96
121
  (selection: CellSelection): Command =>
97
122
  (state, dispatch) => {
98
123
  if (isTableSelected(state.selection) && editorSelectionAPI) {
99
124
  const { selectionRelativeToNode } =
100
- editorSelectionAPI.getSelectionPluginState(state);
125
+ editorSelectionAPI.sharedState.currentState() || {};
101
126
 
102
127
  if (selectionRelativeToNode === RelativeSelectionPos.Start) {
103
128
  // we have full table cell selection and want to set selection at start of first cell
@@ -117,7 +142,11 @@ const arrowRightFromCellSelection =
117
142
  };
118
143
 
119
144
  const arrowLeftFromGapCursor =
120
- (editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
145
+ (
146
+ editorSelectionAPI:
147
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
148
+ | undefined,
149
+ ) =>
121
150
  (selection: GapCursorSelection): Command =>
122
151
  (state, dispatch) => {
123
152
  const { doc } = state;
@@ -139,9 +168,12 @@ const arrowLeftFromGapCursor =
139
168
  isSelectionAtStartOfTable($from, selection) &&
140
169
  editorSelectionAPI
141
170
  ) {
142
- const { selectionRelativeToNode } =
143
- editorSelectionAPI.getSelectionPluginState(state);
144
- if (selectionRelativeToNode === RelativeSelectionPos.Before) {
171
+ const selectionState: SelectionSharedState =
172
+ editorSelectionAPI.sharedState.currentState() || {};
173
+ if (
174
+ selectionState?.selectionRelativeToNode ===
175
+ RelativeSelectionPos.Before
176
+ ) {
145
177
  // we have a gap cursor at start of first table cell and want to set a gap cursor selection before table
146
178
  return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
147
179
  } else {
@@ -158,7 +190,11 @@ const arrowLeftFromGapCursor =
158
190
  };
159
191
 
160
192
  const arrowRightFromGapCursor =
161
- (editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
193
+ (
194
+ editorSelectionAPI:
195
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
196
+ | undefined,
197
+ ) =>
162
198
  (selection: GapCursorSelection): Command =>
163
199
  (state, dispatch) => {
164
200
  const { $from, from, $to, side } = selection;
@@ -187,7 +223,11 @@ const arrowRightFromGapCursor =
187
223
  };
188
224
 
189
225
  const arrowLeftFromText =
190
- (editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
226
+ (
227
+ editorSelectionAPI:
228
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
229
+ | undefined,
230
+ ) =>
191
231
  (selection: TextSelection): Command =>
192
232
  (state, dispatch) => {
193
233
  const table = findTable(selection);
@@ -199,9 +239,13 @@ const arrowLeftFromText =
199
239
  $from.depth === table.depth + 3 && // + 3 for: row, cell & paragraph nodes
200
240
  editorSelectionAPI
201
241
  ) {
202
- const { selectionRelativeToNode } =
203
- editorSelectionAPI.getSelectionPluginState(state);
204
- if (selectionRelativeToNode === RelativeSelectionPos.Before) {
242
+ const selectionState: SelectionSharedState =
243
+ editorSelectionAPI.sharedState.currentState() || {};
244
+
245
+ if (
246
+ selectionState?.selectionRelativeToNode ===
247
+ RelativeSelectionPos.Before
248
+ ) {
205
249
  // we have a text selection at start of first table cell, directly inside a top level paragraph,
206
250
  // and want to set gap cursor selection before table
207
251
  return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
@@ -220,7 +264,11 @@ const arrowLeftFromText =
220
264
  };
221
265
 
222
266
  const arrowRightFromText =
223
- (editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
267
+ (
268
+ editorSelectionAPI:
269
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
270
+ | undefined,
271
+ ) =>
224
272
  (selection: TextSelection): Command =>
225
273
  (state, dispatch) => {
226
274
  const table = findTable(selection);
@@ -250,7 +298,11 @@ const arrowRightFromText =
250
298
  * pos in the selection plugin
251
299
  */
252
300
  const selectFullTable =
253
- (editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
301
+ (
302
+ editorSelectionAPI:
303
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
304
+ | undefined,
305
+ ) =>
254
306
  ({
255
307
  node,
256
308
  startPos,
@@ -276,7 +328,7 @@ const selectFullTable =
276
328
  selectionRelativeToNode = RelativeSelectionPos.Start;
277
329
  }
278
330
  if (editorSelectionAPI) {
279
- const tr = editorSelectionAPI.setSelectionRelativeToNode({
331
+ const tr = editorSelectionAPI.actions.selectNearNode({
280
332
  selectionRelativeToNode,
281
333
  selection: fullTableSelection,
282
334
  })(state);
@@ -290,7 +342,11 @@ const selectFullTable =
290
342
  };
291
343
 
292
344
  const setSelectionAtStartOfFirstCell =
293
- (editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
345
+ (
346
+ editorSelectionAPI:
347
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
348
+ | undefined,
349
+ ) =>
294
350
  (
295
351
  selection: CellSelection,
296
352
  selectionRelativeToNode?: RelativeSelectionPos,
@@ -307,7 +363,7 @@ const setSelectionAtStartOfFirstCell =
307
363
  : Selection.findFrom($firstPosInsideCell, 1);
308
364
 
309
365
  if (editorSelectionAPI) {
310
- const tr = editorSelectionAPI.setSelectionRelativeToNode({
366
+ const tr = editorSelectionAPI.actions.selectNearNode({
311
367
  selectionRelativeToNode,
312
368
  selection: selectionAtStartOfCell,
313
369
  })(state);
@@ -321,7 +377,11 @@ const setSelectionAtStartOfFirstCell =
321
377
  };
322
378
 
323
379
  const setSelectionAtEndOfLastCell =
324
- (editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
380
+ (
381
+ editorSelectionAPI:
382
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
383
+ | undefined,
384
+ ) =>
325
385
  (
326
386
  selection: CellSelection,
327
387
  selectionRelativeToNode?: RelativeSelectionPos,
@@ -341,7 +401,7 @@ const setSelectionAtEndOfLastCell =
341
401
  : Selection.findFrom($lastPosInsideCell, -1);
342
402
 
343
403
  if (editorSelectionAPI) {
344
- const tr = editorSelectionAPI.setSelectionRelativeToNode({
404
+ const tr = editorSelectionAPI.actions.selectNearNode({
345
405
  selectionRelativeToNode,
346
406
  selection: selectionAtEndOfCell,
347
407
  })(state);
@@ -355,7 +415,11 @@ const setSelectionAtEndOfLastCell =
355
415
  };
356
416
 
357
417
  const setGapCursorBeforeTable =
358
- (editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
418
+ (
419
+ editorSelectionAPI:
420
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
421
+ | undefined,
422
+ ) =>
359
423
  (): Command =>
360
424
  (state, dispatch) => {
361
425
  const table = findTable(state.selection);
@@ -367,7 +431,7 @@ const setGapCursorBeforeTable =
367
431
  Side.LEFT,
368
432
  );
369
433
  if (editorSelectionAPI) {
370
- const tr = editorSelectionAPI.setSelectionRelativeToNode({
434
+ const tr = editorSelectionAPI.actions.selectNearNode({
371
435
  selectionRelativeToNode: undefined,
372
436
  selection: selectionBeforeTable,
373
437
  })(state);
@@ -383,7 +447,11 @@ const setGapCursorBeforeTable =
383
447
  };
384
448
 
385
449
  const setGapCursorAfterTable =
386
- (editorSelectionAPI: EditorSelectionAPI | undefined | null) =>
450
+ (
451
+ editorSelectionAPI:
452
+ | ExtractInjectionAPI<typeof tablePlugin>['selection']
453
+ | undefined,
454
+ ) =>
387
455
  (): Command =>
388
456
  (state, dispatch) => {
389
457
  const table = findTable(state.selection);
@@ -396,7 +464,7 @@ const setGapCursorAfterTable =
396
464
  );
397
465
 
398
466
  if (editorSelectionAPI) {
399
- const tr = editorSelectionAPI.setSelectionRelativeToNode({
467
+ const tr = editorSelectionAPI.actions.selectNearNode({
400
468
  selectionRelativeToNode: undefined,
401
469
  selection: selectionAfterTable,
402
470
  })(state);
@@ -21,21 +21,19 @@ import { IconTable } from '@atlaskit/editor-common/icons';
21
21
  import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
22
22
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
23
23
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
24
- import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
25
24
  import type {
26
25
  Command,
27
- EditorCommand,
28
26
  EditorPlugin,
29
27
  GetEditorContainerWidth,
30
28
  GetEditorFeatureFlags,
31
29
  NextEditorPlugin,
32
- OptionalPlugin,
33
30
  } from '@atlaskit/editor-common/types';
34
31
  import { browser } from '@atlaskit/editor-common/utils';
35
32
  import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
36
33
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
37
34
  import type { ContentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
38
35
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
36
+ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
39
37
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
40
38
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
41
39
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -45,6 +43,10 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
45
43
 
46
44
  import { pluginConfig } from './create-plugin-config';
47
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';
48
50
  import { keymapPlugin } from './pm-plugins/keymap';
49
51
  import { createPlugin } from './pm-plugins/main';
50
52
  import { pluginKey } from './pm-plugins/plugin-key';
@@ -76,7 +78,6 @@ import FloatingDeleteButton from './ui/FloatingDeleteButton';
76
78
  import FloatingInsertButton from './ui/FloatingInsertButton';
77
79
  import LayoutButton from './ui/LayoutButton';
78
80
  import { isLayoutSupported } from './utils';
79
-
80
81
  interface TablePluginOptions {
81
82
  tableOptions: PluginConfig;
82
83
  // experimental custom table resizing experience, set inside editor-core behind a feature flag
@@ -88,22 +89,11 @@ interface TablePluginOptions {
88
89
  // TODO these two need to be rethought
89
90
  fullWidthEnabled?: boolean;
90
91
  wasFullWidthEnabled?: boolean;
91
- editorSelectionAPI?: EditorSelectionAPI;
92
92
  getEditorFeatureFlags?: GetEditorFeatureFlags;
93
93
  }
94
94
 
95
95
  type InsertTableAction = (analyticsPayload: AnalyticsEventPayload) => Command;
96
96
 
97
- // TODO: duplicated SelectionPlugin type as it's still in editor-core, doing this avoid
98
- // circular dependencies
99
- type SelectionPlugin = NextEditorPlugin<
100
- 'selection',
101
- {
102
- pluginConfiguration: unknown;
103
- commands: { displayGapCursor: (toggle: boolean) => EditorCommand };
104
- }
105
- >;
106
-
107
97
  const defaultGetEditorFeatureFlags = () => ({});
108
98
 
109
99
  export type TablePlugin = NextEditorPlugin<
@@ -118,7 +108,7 @@ export type TablePlugin = NextEditorPlugin<
118
108
  ContentInsertionPlugin,
119
109
  WidthPlugin,
120
110
  GuidelinePlugin,
121
- OptionalPlugin<SelectionPlugin>,
111
+ SelectionPlugin,
122
112
  ];
123
113
  }
124
114
  >;
@@ -242,7 +232,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
242
232
  },
243
233
  {
244
234
  name: 'tableSelectionKeymap',
245
- plugin: () => tableSelectionKeymapPlugin(options?.editorSelectionAPI),
235
+ plugin: () => tableSelectionKeymapPlugin(api?.selection),
246
236
  },
247
237
  {
248
238
  name: 'tableEditing',
@@ -280,6 +270,13 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
280
270
  )
281
271
  : undefined,
282
272
  },
273
+ {
274
+ name: 'tableDragAndDrop',
275
+ plugin: ({ dispatch, eventDispatcher }) =>
276
+ options?.dragAndDropEnabled
277
+ ? createDragAndDropPlugin(dispatch, eventDispatcher)
278
+ : undefined,
279
+ },
283
280
  {
284
281
  name: 'tableLocalId',
285
282
  plugin: ({ dispatch }) => createTableLocalIdPlugin(dispatch),
@@ -357,6 +354,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
357
354
  tableWidthPluginState: tableWidthPluginKey,
358
355
  tableResizingPluginState: tableResizingPluginKey,
359
356
  stickyHeadersState: stickyHeadersPluginKey,
357
+ dragAndDropState: dragAndDropPluginKey,
360
358
  }}
361
359
  render={({
362
360
  tableResizingPluginState: resizingPluginState,
@@ -0,0 +1,29 @@
1
+ import type { DropTargetType } from './consts';
2
+
3
+ export interface DragAndDropAction<T, D> {
4
+ type: T;
5
+ data: D;
6
+ }
7
+
8
+ export const DragAndDropActionType = {
9
+ SET_DROP_TARGET: 'SET_DROP_TARGET',
10
+ CLEAR_DROP_TARGET: 'CLEAR_DROP_TARGET',
11
+ } as const;
12
+
13
+ export type DragAndDropSetDropTargetAction = DragAndDropAction<
14
+ typeof DragAndDropActionType.SET_DROP_TARGET,
15
+ {
16
+ type: DropTargetType;
17
+ index: number;
18
+ }
19
+ >;
20
+
21
+ export type DragAndDropClearDropTargetAction = DragAndDropAction<
22
+ typeof DragAndDropActionType.CLEAR_DROP_TARGET,
23
+ undefined
24
+ >;
25
+
26
+ // NOTE: This should be a Union of all possible actions
27
+ export type DragAndDropPluginAction =
28
+ | DragAndDropSetDropTargetAction
29
+ | DragAndDropClearDropTargetAction;
@@ -0,0 +1,32 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+
3
+ import { DragAndDropActionType } from './actions';
4
+ import type { DropTargetType } from './consts';
5
+ import { createCommand } from './plugin-factory';
6
+
7
+ // TODO: This command is a placeholder example. Please replace this if required.
8
+ export const setDropTarget = (
9
+ type: DropTargetType,
10
+ index: number,
11
+ tr?: Transaction,
12
+ ) =>
13
+ createCommand(
14
+ {
15
+ type: DragAndDropActionType.SET_DROP_TARGET,
16
+ data: {
17
+ type,
18
+ index,
19
+ },
20
+ },
21
+ (originalTr: Transaction) =>
22
+ (tr || originalTr).setMeta('addToHistory', false),
23
+ );
24
+
25
+ export const clearDropTarget = (tr?: Transaction) =>
26
+ createCommand(
27
+ {
28
+ type: DragAndDropActionType.CLEAR_DROP_TARGET,
29
+ },
30
+ (originalTr: Transaction) =>
31
+ (tr || originalTr).setMeta('addToHistory', false),
32
+ );