@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
@@ -3,31 +3,31 @@ import throttle from 'lodash/throttle';
3
3
 
4
4
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
5
5
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
6
- import { browser, mapChildren } from '@atlaskit/editor-common/utils';
7
- import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
6
+ import { browser } from '@atlaskit/editor-common/utils';
7
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
8
  import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
9
9
 
10
- import type { TablePluginState } from '../../../types';
10
+ import { getPluginState } from '../pm-plugins/plugin-factory';
11
+ import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
12
+ import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
11
13
  import {
12
- TableCssClassName as ClassName,
13
- TableCssClassName,
14
- } from '../../../types';
14
+ syncStickyRowToTable,
15
+ updateStickyMargins as updateTableMargin,
16
+ } from '../pm-plugins/table-resizing/utils/dom';
17
+ import type { TablePluginState } from '../types';
18
+ import { TableCssClassName as ClassName, TableCssClassName } from '../types';
15
19
  import {
16
20
  STICKY_HEADER_TOGGLE_TOLERANCE_MS,
17
21
  stickyHeaderBorderBottomWidth,
18
22
  stickyRowOffsetTop,
19
23
  tableControlsSpacing,
20
24
  tableScrollbarOffset,
21
- } from '../../../ui/consts';
22
- import { pluginKey as tablePluginKey } from '../../plugin-key';
23
- import {
24
- syncStickyRowToTable,
25
- updateStickyMargins as updateTableMargin,
26
- } from '../../table-resizing/utils/dom';
27
- import { updateStickyState } from '../commands';
25
+ } from '../ui/consts';
26
+ import type { TableDOMElements } from '../utils/dom';
27
+ import { getTop, getTree } from '../utils/dom';
28
+ import { supportedHeaderRow } from '../utils/nodes';
28
29
 
29
- import type { TableDOMElements } from './dom';
30
- import { getTop, getTree } from './dom';
30
+ import TableNodeView from './TableNodeViewBase';
31
31
 
32
32
  // limit scroll event calls
33
33
  const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
@@ -36,48 +36,47 @@ const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
36
36
  // if too short it would trigger too many dom updates.
37
37
  const HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
38
38
 
39
- const anyChildCellMergedAcrossRow = (node: PmNode) =>
40
- mapChildren(node, (child) => child.attrs.rowspan || 0).some(
41
- (rowspan) => rowspan > 1,
42
- );
43
-
44
- /**
45
- * Check if a given node is a header row with this definition:
46
- * - all children are tableHeader cells
47
- * - no table cells have been have merged with other table row cells
48
- *
49
- * @param node ProseMirror node
50
- * @return boolean if it meets definition
51
- */
52
- export const supportedHeaderRow = (node: PmNode) => {
53
- const allHeaders = mapChildren(
54
- node,
55
- (child) => child.type.name === 'tableHeader',
56
- ).every(Boolean);
57
-
58
- const someMerged = anyChildCellMergedAcrossRow(node);
59
-
60
- return allHeaders && !someMerged;
61
- };
62
-
63
- export class TableRowNodeView implements NodeView {
64
- view: EditorView;
65
- node: PmNode;
66
- getPos: () => number;
67
- eventDispatcher: EventDispatcher;
68
-
69
- dom: HTMLTableRowElement; // this is the sticky header table row
70
- contentDOM: HTMLElement;
71
-
72
- isHeaderRow: boolean;
73
- editorScrollableElement?: HTMLElement | Window;
74
- colControlsOffset = 0;
75
- focused = false;
76
- topPosEditorElement = 0;
77
- isSticky: boolean;
78
- lastStickyTimestamp: number | undefined;
79
- lastTimePainted: number;
39
+ export default class TableRow
40
+ extends TableNodeView<HTMLTableRowElement>
41
+ implements NodeView
42
+ {
43
+ constructor(
44
+ node: PMNode,
45
+ view: EditorView,
46
+ getPos: () => number | undefined,
47
+ eventDispatcher: EventDispatcher,
48
+ ) {
49
+ super(node, view, getPos, eventDispatcher);
50
+
51
+ this.isHeaderRow = supportedHeaderRow(node);
52
+ this.isSticky = false;
53
+
54
+ const { pluginConfig, isDragAndDropEnabled } = getPluginState(view.state);
55
+
56
+ this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
57
+ this.isDragAndDropEnabled = !!isDragAndDropEnabled;
58
+
59
+ if (this.isHeaderRow) {
60
+ this.dom.setAttribute('data-header-row', 'true');
61
+ if (this.isStickyHeaderEnabled) {
62
+ this.subscribe();
63
+ }
64
+ }
65
+ }
80
66
 
67
+ /**
68
+ * Variables
69
+ */
70
+ private isHeaderRow: boolean;
71
+ private isStickyHeaderEnabled: boolean;
72
+ // @ts-ignore
73
+ private isDragAndDropEnabled: boolean;
74
+ private editorScrollableElement?: HTMLElement | Window;
75
+ private colControlsOffset = 0;
76
+ private focused = false;
77
+ private topPosEditorElement = 0;
78
+ private isSticky: boolean;
79
+ private lastStickyTimestamp: number | undefined;
81
80
  private intersectionObserver?: IntersectionObserver;
82
81
  private resizeObserver?: ResizeObserver;
83
82
  private sentinels: {
@@ -85,54 +84,109 @@ export class TableRowNodeView implements NodeView {
85
84
  bottom?: HTMLElement | null;
86
85
  } = {};
87
86
  private stickyRowHeight?: number;
87
+ private listening = false;
88
+ private padding: number = 0;
89
+ private top: number = 0;
88
90
 
89
- get tree(): TableDOMElements | null | undefined {
90
- return getTree(this.dom);
91
- }
91
+ /**
92
+ * Methods: Nodeview Lifecycle
93
+ */
94
+ update(node: PMNode, ..._args: any[]) {
95
+ // do nothing if nodes were identical
96
+ if (node === this.node) {
97
+ return true;
98
+ }
92
99
 
93
- constructor(
94
- node: PmNode,
95
- view: EditorView,
96
- getPos: any,
97
- eventDispatcher: EventDispatcher,
98
- ) {
99
- this.view = view;
100
+ // see if we're changing into a header row or
101
+ // changing away from one
102
+ const newNodeIsHeaderRow = supportedHeaderRow(node);
103
+ if (this.isHeaderRow !== newNodeIsHeaderRow) {
104
+ return false; // re-create nodeview
105
+ }
106
+
107
+ // node is different but no need to re-create nodeview
100
108
  this.node = node;
101
- this.getPos = getPos;
102
- this.eventDispatcher = eventDispatcher;
103
109
 
104
- this.dom = document.createElement('tr');
105
- this.contentDOM = this.dom;
110
+ // don't do anything if we're just a regular tr
111
+ if (!this.isHeaderRow) {
112
+ return true;
113
+ }
106
114
 
107
- this.lastTimePainted = 0;
108
- this.isHeaderRow = supportedHeaderRow(node);
109
- this.isSticky = false;
110
- this.lastStickyTimestamp = undefined;
115
+ // something changed, sync widths
116
+ if (this.isStickyHeaderEnabled) {
117
+ const tbody = this.dom.parentElement;
118
+ const table = tbody && tbody.parentElement;
119
+ syncStickyRowToTable(table);
120
+ }
111
121
 
112
- if (this.isHeaderRow) {
113
- this.dom.setAttribute('data-header-row', 'true');
114
- this.subscribe();
122
+ return true;
123
+ }
124
+
125
+ destroy() {
126
+ if (this.isStickyHeaderEnabled) {
127
+ this.unsubscribe();
128
+
129
+ const tree = getTree(this.dom);
130
+ if (tree) {
131
+ this.makeRowHeaderNotSticky(tree.table, true);
132
+ }
133
+
134
+ this.emitOff(true);
135
+ }
136
+ }
137
+
138
+ ignoreMutation(
139
+ mutationRecord: MutationRecord | { type: 'selection'; target: Element },
140
+ ) {
141
+ /* tableRows are not directly editable by the user
142
+ * so it should be safe to ignore mutations that we cause
143
+ * by updating styles and classnames on this DOM element
144
+ *
145
+ * Update: should not ignore mutations for row selection to avoid known issue with table selection highlight in firefox
146
+ * Related bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1289673
147
+ * */
148
+ const isTableSelection =
149
+ mutationRecord.type === 'selection' &&
150
+ mutationRecord.target.nodeName === 'TR';
151
+ /**
152
+ * Update: should not ignore mutations when an node is added, as this interferes with
153
+ * prosemirrors handling of some language inputs in Safari (ie. Pinyin, Hiragana).
154
+ *
155
+ * In paticular, when a composition occurs at the start of the first node inside a table cell, if the resulting mutation
156
+ * from the composition end is ignored than prosemirror will end up with; invalid table markup nesting and a misplaced
157
+ * selection and insertion.
158
+ */
159
+ const isNodeInsertion =
160
+ mutationRecord.type === 'childList' &&
161
+ mutationRecord.target.nodeName === 'TR' &&
162
+ mutationRecord.addedNodes.length;
163
+
164
+ if (isTableSelection || isNodeInsertion) {
165
+ return false;
115
166
  }
167
+
168
+ return true;
116
169
  }
117
170
 
118
- /* external events */
119
- listening = false;
171
+ /**
172
+ * Methods
173
+ */
120
174
 
121
- headerRowMouseScrollEnd = debounce(() => {
175
+ private headerRowMouseScrollEnd = debounce(() => {
122
176
  this.dom.classList.remove('no-pointer-events');
123
177
  }, HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT);
124
178
 
125
179
  // When the header is sticky, the header row is set to position: fixed
126
180
  // This prevents mouse wheel scrolling on the scroll-parent div when user's mouse is hovering the header row.
127
181
  // This fix sets pointer-events: none on the header row briefly to avoid this behaviour
128
- headerRowMouseScroll = throttle(() => {
182
+ private headerRowMouseScroll = throttle(() => {
129
183
  if (this.isSticky) {
130
184
  this.dom.classList.add('no-pointer-events');
131
185
  this.headerRowMouseScrollEnd();
132
186
  }
133
187
  }, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT);
134
188
 
135
- subscribe() {
189
+ private subscribe() {
136
190
  this.editorScrollableElement =
137
191
  findOverflowScrollParent(this.view.dom as HTMLElement) || window;
138
192
 
@@ -141,11 +195,14 @@ export class TableRowNodeView implements NodeView {
141
195
  this.topPosEditorElement = getTop(this.editorScrollableElement);
142
196
  }
143
197
 
144
- this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth);
198
+ this.eventDispatcher.on(
199
+ 'widthPlugin',
200
+ this.updateStickyHeaderWidth.bind(this),
201
+ );
145
202
 
146
203
  this.eventDispatcher.on(
147
204
  (tablePluginKey as any).key,
148
- this.onTablePluginState,
205
+ this.onTablePluginState.bind(this),
149
206
  );
150
207
 
151
208
  this.listening = true;
@@ -160,7 +217,7 @@ export class TableRowNodeView implements NodeView {
160
217
  );
161
218
  }
162
219
 
163
- unsubscribe() {
220
+ private unsubscribe() {
164
221
  if (!this.listening) {
165
222
  return;
166
223
  }
@@ -211,7 +268,7 @@ export class TableRowNodeView implements NodeView {
211
268
 
212
269
  window.requestAnimationFrame(() => {
213
270
  // we expect tree to be defined after animation frame
214
- const tableContainer = this.tree?.wrapper.closest(
271
+ const tableContainer = getTree(this.dom)?.wrapper.closest(
215
272
  `.${TableCssClassName.NODEVIEW_WRAPPER}`,
216
273
  );
217
274
  if (tableContainer) {
@@ -236,10 +293,11 @@ export class TableRowNodeView implements NodeView {
236
293
  // to allocate for new header height
237
294
  private createResizeObserver() {
238
295
  this.resizeObserver = new ResizeObserver((entries) => {
239
- if (!this.tree) {
296
+ const tree = getTree(this.dom);
297
+ if (!tree) {
240
298
  return;
241
299
  }
242
- const { table } = this.tree;
300
+ const { table } = tree;
243
301
  entries.forEach((entry) => {
244
302
  // On resize of the parent scroll element we need to adjust the width
245
303
  // of the sticky header
@@ -275,10 +333,11 @@ export class TableRowNodeView implements NodeView {
275
333
  private createIntersectionObserver() {
276
334
  this.intersectionObserver = new IntersectionObserver(
277
335
  (entries: IntersectionObserverEntry[], _: IntersectionObserver) => {
278
- if (!this.tree) {
336
+ const tree = getTree(this.dom);
337
+ if (!tree) {
279
338
  return;
280
339
  }
281
- const { table } = this.tree;
340
+ const { table } = tree;
282
341
 
283
342
  if (table.rows.length < 2) {
284
343
  // ED-19307 - When there's only one row in a table the top & bottom sentinels become inverted. This creates some nasty visiblity
@@ -299,8 +358,7 @@ export class TableRowNodeView implements NodeView {
299
358
  (entry.rootBounds?.bottom || 0) < entry.boundingClientRect.bottom;
300
359
 
301
360
  if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
302
- this.tree &&
303
- this.makeHeaderRowSticky(this.tree, entry.rootBounds?.top);
361
+ tree && this.makeHeaderRowSticky(tree, entry.rootBounds?.top);
304
362
  this.lastStickyTimestamp = Date.now();
305
363
  } else {
306
364
  table && this.makeRowHeaderNotSticky(table);
@@ -328,8 +386,7 @@ export class TableRowNodeView implements NodeView {
328
386
  this.makeRowHeaderNotSticky(table);
329
387
  }
330
388
  } else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
331
- this.tree &&
332
- this.makeHeaderRowSticky(this.tree, entry?.rootBounds?.top);
389
+ tree && this.makeHeaderRowSticky(tree, entry?.rootBounds?.top);
333
390
  this.lastStickyTimestamp = Date.now();
334
391
  }
335
392
  }
@@ -339,94 +396,12 @@ export class TableRowNodeView implements NodeView {
339
396
  { root: this.editorScrollableElement as Element },
340
397
  );
341
398
  }
342
-
343
- /* paint/update loop */
344
- previousDomTop: number | undefined;
345
- previousPadding: number | undefined;
346
-
347
- latestDomTop: number | undefined;
348
-
349
- nextFrame: number | undefined;
350
-
351
- /* nodeview lifecycle */
352
- update(node: PmNode, ..._args: any[]) {
353
- // do nothing if nodes were identical
354
- if (node === this.node) {
355
- return true;
356
- }
357
-
358
- // see if we're changing into a header row or
359
- // changing away from one
360
- const newNodeIsHeaderRow = supportedHeaderRow(node);
361
- if (this.isHeaderRow !== newNodeIsHeaderRow) {
362
- return false; // re-create nodeview
363
- }
364
-
365
- // node is different but no need to re-create nodeview
366
- this.node = node;
367
-
368
- // don't do anything if we're just a regular tr
369
- if (!this.isHeaderRow) {
370
- return true;
371
- }
372
-
373
- // something changed, sync widths
374
- const tbody = this.dom.parentElement;
375
- const table = tbody && tbody.parentElement;
376
- syncStickyRowToTable(table);
377
-
378
- return true;
379
- }
380
-
381
- destroy() {
382
- this.unsubscribe();
383
-
384
- if (this.tree) {
385
- this.makeRowHeaderNotSticky(this.tree.table, true);
386
- }
387
-
388
- this.emitOff(true);
389
- }
390
-
391
- ignoreMutation(
392
- mutationRecord: MutationRecord | { type: 'selection'; target: Element },
393
- ) {
394
- /* tableRows are not directly editable by the user
395
- * so it should be safe to ignore mutations that we cause
396
- * by updating styles and classnames on this DOM element
397
- *
398
- * Update: should not ignore mutations for row selection to avoid known issue with table selection highlight in firefox
399
- * Related bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1289673
400
- * */
401
- const isTableSelection =
402
- mutationRecord.type === 'selection' &&
403
- mutationRecord.target.nodeName === 'TR';
404
- /**
405
- * Update: should not ignore mutations when an node is added, as this interferes with
406
- * prosemirrors handling of some language inputs in Safari (ie. Pinyin, Hiragana).
407
- *
408
- * In paticular, when a composition occurs at the start of the first node inside a table cell, if the resulting mutation
409
- * from the composition end is ignored than prosemirror will end up with; invalid table markup nesting and a misplaced
410
- * selection and insertion.
411
- */
412
- const isNodeInsertion =
413
- mutationRecord.type === 'childList' &&
414
- mutationRecord.target.nodeName === 'TR' &&
415
- mutationRecord.addedNodes.length;
416
-
417
- if (isTableSelection || isNodeInsertion) {
418
- return false;
419
- }
420
-
421
- return true;
422
- }
423
-
424
399
  /* receive external events */
425
400
 
426
- onTablePluginState = (state: TablePluginState) => {
401
+ private onTablePluginState(state: TablePluginState) {
427
402
  const tableRef = state.tableRef;
428
403
 
429
- const tree = this.tree;
404
+ const tree = getTree(this.dom);
430
405
  if (!tree) {
431
406
  return;
432
407
  }
@@ -443,8 +418,8 @@ export class TableRowNodeView implements NodeView {
443
418
  const isCurrentTableSelected = tableRef === tree.table;
444
419
 
445
420
  // If current table selected and header row is toggled off, turn off sticky header
446
- if (isCurrentTableSelected && !state.isHeaderRowEnabled && this.tree) {
447
- this.makeRowHeaderNotSticky(this.tree.table);
421
+ if (isCurrentTableSelected && !state.isHeaderRowEnabled && tree) {
422
+ this.makeRowHeaderNotSticky(tree.table);
448
423
  }
449
424
  this.focused = isCurrentTableSelected;
450
425
 
@@ -481,55 +456,23 @@ export class TableRowNodeView implements NodeView {
481
456
  setTimeout(() => {
482
457
  syncStickyRowToTable(tree.table);
483
458
  }, 0);
484
- };
459
+ }
485
460
 
486
- updateStickyHeaderWidth = () => {
461
+ private updateStickyHeaderWidth() {
487
462
  // table width might have changed, sync that back to sticky row
488
- const tree = this.tree;
463
+ const tree = getTree(this.dom);
489
464
  if (!tree) {
490
465
  return;
491
466
  }
492
467
 
493
468
  syncStickyRowToTable(tree.table);
494
- };
495
-
496
- shouldHeaderStick = (tree: TableDOMElements): boolean => {
497
- const { wrapper } = tree;
498
- const tableWrapperRect = wrapper.getBoundingClientRect();
499
- const editorAreaRect = (
500
- this.editorScrollableElement as HTMLElement
501
- ).getBoundingClientRect();
502
-
503
- const stickyHeaderRect = this.contentDOM.getBoundingClientRect();
504
- const firstHeaderRow = !this.dom.previousElementSibling;
505
- const subsequentRows = !!this.dom.nextElementSibling;
506
- const isHeaderValid = firstHeaderRow && subsequentRows;
507
-
508
- // if the table wrapper is less than the editor top pos then make it sticky
509
- // Make header sticky if table wrapper top is outside viewport
510
- // but bottom is still in the viewport.
511
- if (
512
- tableWrapperRect.top < editorAreaRect.top &&
513
- tableWrapperRect.bottom > editorAreaRect.top &&
514
- isHeaderValid
515
- ) {
516
- return true;
517
- }
518
-
519
- // if the sticky header is below the editor area make it non-sticky
520
- if (stickyHeaderRect.top > editorAreaRect.top) {
521
- return false;
522
- }
523
-
524
- // otherwise make it non-sticky
525
- return false;
526
- };
469
+ }
527
470
 
528
471
  /**
529
472
  * Manually refire the intersection observers.
530
473
  * Useful when the header may have detached from the table.
531
474
  */
532
- refireIntersectionObservers = () => {
475
+ private refireIntersectionObservers() {
533
476
  if (this.isSticky) {
534
477
  [this.sentinels.top, this.sentinels.bottom].forEach((el) => {
535
478
  if (el && this.intersectionObserver) {
@@ -538,9 +481,9 @@ export class TableRowNodeView implements NodeView {
538
481
  }
539
482
  });
540
483
  }
541
- };
484
+ }
542
485
 
543
- makeHeaderRowSticky = (tree: TableDOMElements, scrollTop?: number) => {
486
+ private makeHeaderRowSticky(tree: TableDOMElements, scrollTop?: number) {
544
487
  // If header row height is more than 50% of viewport height don't do this
545
488
  if (
546
489
  this.isSticky ||
@@ -596,12 +539,12 @@ export class TableRowNodeView implements NodeView {
596
539
  this.dom.scrollLeft = wrapper.scrollLeft;
597
540
 
598
541
  this.emitOn(domTop, this.colControlsOffset);
599
- };
542
+ }
600
543
 
601
- makeRowHeaderNotSticky = (
544
+ private makeRowHeaderNotSticky(
602
545
  table: HTMLElement,
603
546
  isEditorDestroyed: boolean = false,
604
- ) => {
547
+ ) {
605
548
  if (!this.isSticky || !table || !this.dom) {
606
549
  return;
607
550
  }
@@ -615,59 +558,63 @@ export class TableRowNodeView implements NodeView {
615
558
  table.style.removeProperty('margin-top');
616
559
 
617
560
  this.emitOff(isEditorDestroyed);
618
- };
561
+ }
619
562
 
620
- getWrapperoffset = (inverse: boolean = false): number => {
563
+ private getWrapperoffset(inverse: boolean = false): number {
621
564
  const focusValue = inverse ? !this.focused : this.focused;
622
565
  return focusValue ? 0 : tableControlsSpacing;
623
- };
566
+ }
624
567
 
625
- getWrapperRefTop = (wrapper: HTMLElement): number =>
626
- Math.round(getTop(wrapper)) + this.getWrapperoffset();
568
+ private getWrapperRefTop(wrapper: HTMLElement): number {
569
+ return Math.round(getTop(wrapper)) + this.getWrapperoffset();
570
+ }
627
571
 
628
572
  // TODO: rename!
629
- getScrolledTableTop = (wrapper: HTMLElement): number =>
630
- this.getWrapperRefTop(wrapper) - this.topPosEditorElement;
573
+ private getScrolledTableTop(wrapper: HTMLElement): number {
574
+ return this.getWrapperRefTop(wrapper) - this.topPosEditorElement;
575
+ }
631
576
 
632
- getCurrentTableTop = (tree: TableDOMElements): number =>
633
- this.getScrolledTableTop(tree.wrapper) + tree.table.clientHeight;
577
+ private getCurrentTableTop(tree: TableDOMElements): number {
578
+ return this.getScrolledTableTop(tree.wrapper) + tree.table.clientHeight;
579
+ }
634
580
 
635
581
  /* emit external events */
636
582
 
637
- padding = 0;
638
- top = 0;
639
-
640
- emitOn = (top: number, padding: number) => {
583
+ private emitOn(top: number, padding: number) {
641
584
  if (top === this.top && padding === this.padding) {
642
585
  return;
643
586
  }
644
587
 
645
588
  this.top = top;
646
589
  this.padding = padding;
590
+ const pos = this.getPos()!;
647
591
 
648
- updateStickyState({
649
- pos: this.getPos(),
650
- top,
651
- sticky: true,
652
- padding,
653
- })(this.view.state, this.view.dispatch, this.view);
654
- };
592
+ if (Number.isFinite(pos)) {
593
+ updateStickyState({
594
+ pos,
595
+ top,
596
+ sticky: true,
597
+ padding,
598
+ })(this.view.state, this.view.dispatch, this.view);
599
+ }
600
+ }
655
601
 
656
- emitOff = (isEditorDestroyed: boolean) => {
602
+ private emitOff(isEditorDestroyed: boolean) {
657
603
  if (this.top === 0 && this.padding === 0) {
658
604
  return;
659
605
  }
660
606
 
661
607
  this.top = 0;
662
608
  this.padding = 0;
609
+ const pos = this.getPos()!;
663
610
 
664
- if (!isEditorDestroyed) {
611
+ if (!isEditorDestroyed && Number.isFinite(pos)) {
665
612
  updateStickyState({
666
- pos: this.getPos(),
613
+ pos,
667
614
  sticky: false,
668
615
  top: this.top,
669
616
  padding: this.padding,
670
617
  })(this.view.state, this.view.dispatch, this.view);
671
618
  }
672
- };
619
+ }
673
620
  }
@@ -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;