@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
@@ -1,16 +1,25 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
3
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
4
10
  import debounce from 'lodash/debounce';
5
11
  import throttle from 'lodash/throttle';
6
12
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
7
- import { browser, mapChildren } from '@atlaskit/editor-common/utils';
8
- import { TableCssClassName as ClassName, TableCssClassName } from '../../../types';
9
- import { STICKY_HEADER_TOGGLE_TOLERANCE_MS, stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableControlsSpacing, tableScrollbarOffset } from '../../../ui/consts';
10
- import { pluginKey as tablePluginKey } from '../../plugin-key';
11
- import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../../table-resizing/utils/dom';
12
- import { updateStickyState } from '../commands';
13
- import { getTop, getTree } from './dom';
13
+ import { browser } from '@atlaskit/editor-common/utils';
14
+ import { getPluginState } from '../pm-plugins/plugin-factory';
15
+ import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
16
+ import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
17
+ import { syncStickyRowToTable, updateStickyMargins as updateTableMargin } from '../pm-plugins/table-resizing/utils/dom';
18
+ import { TableCssClassName as ClassName, TableCssClassName } from '../types';
19
+ import { STICKY_HEADER_TOGGLE_TOLERANCE_MS, stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableControlsSpacing, tableScrollbarOffset } from '../ui/consts';
20
+ import { getTop, getTree } from '../utils/dom';
21
+ import { supportedHeaderRow } from '../utils/nodes';
22
+ import TableNodeView from './TableNodeViewBase';
14
23
 
15
24
  // limit scroll event calls
16
25
  var HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
@@ -18,268 +27,127 @@ var HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
18
27
  // timeout for resetting the scroll class - if it’s too long then users won’t be able to click on the header cells,
19
28
  // if too short it would trigger too many dom updates.
20
29
  var HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
21
- var anyChildCellMergedAcrossRow = function anyChildCellMergedAcrossRow(node) {
22
- return mapChildren(node, function (child) {
23
- return child.attrs.rowspan || 0;
24
- }).some(function (rowspan) {
25
- return rowspan > 1;
26
- });
27
- };
28
-
29
- /**
30
- * Check if a given node is a header row with this definition:
31
- * - all children are tableHeader cells
32
- * - no table cells have been have merged with other table row cells
33
- *
34
- * @param node ProseMirror node
35
- * @return boolean if it meets definition
36
- */
37
- export var supportedHeaderRow = function supportedHeaderRow(node) {
38
- var allHeaders = mapChildren(node, function (child) {
39
- return child.type.name === 'tableHeader';
40
- }).every(Boolean);
41
- var someMerged = anyChildCellMergedAcrossRow(node);
42
- return allHeaders && !someMerged;
43
- };
44
- export var TableRowNodeView = /*#__PURE__*/function () {
45
- function TableRowNodeView(node, view, getPos, eventDispatcher) {
46
- var _this = this;
47
- _classCallCheck(this, TableRowNodeView);
48
- // this is the sticky header table row
49
- _defineProperty(this, "colControlsOffset", 0);
50
- _defineProperty(this, "focused", false);
51
- _defineProperty(this, "topPosEditorElement", 0);
52
- _defineProperty(this, "sentinels", {});
53
- /* external events */
54
- _defineProperty(this, "listening", false);
55
- _defineProperty(this, "headerRowMouseScrollEnd", debounce(function () {
30
+ var TableRow = /*#__PURE__*/function (_ref) {
31
+ _inherits(TableRow, _ref);
32
+ var _super = _createSuper(TableRow);
33
+ function TableRow(node, view, getPos, eventDispatcher) {
34
+ var _this;
35
+ _classCallCheck(this, TableRow);
36
+ _this = _super.call(this, node, view, getPos, eventDispatcher);
37
+ _defineProperty(_assertThisInitialized(_this), "colControlsOffset", 0);
38
+ _defineProperty(_assertThisInitialized(_this), "focused", false);
39
+ _defineProperty(_assertThisInitialized(_this), "topPosEditorElement", 0);
40
+ _defineProperty(_assertThisInitialized(_this), "sentinels", {});
41
+ _defineProperty(_assertThisInitialized(_this), "listening", false);
42
+ _defineProperty(_assertThisInitialized(_this), "padding", 0);
43
+ _defineProperty(_assertThisInitialized(_this), "top", 0);
44
+ /**
45
+ * Methods
46
+ */
47
+ _defineProperty(_assertThisInitialized(_this), "headerRowMouseScrollEnd", debounce(function () {
56
48
  _this.dom.classList.remove('no-pointer-events');
57
49
  }, HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT));
58
50
  // When the header is sticky, the header row is set to position: fixed
59
51
  // This prevents mouse wheel scrolling on the scroll-parent div when user's mouse is hovering the header row.
60
52
  // This fix sets pointer-events: none on the header row briefly to avoid this behaviour
61
- _defineProperty(this, "headerRowMouseScroll", throttle(function () {
53
+ _defineProperty(_assertThisInitialized(_this), "headerRowMouseScroll", throttle(function () {
62
54
  if (_this.isSticky) {
63
55
  _this.dom.classList.add('no-pointer-events');
64
56
  _this.headerRowMouseScrollEnd();
65
57
  }
66
58
  }, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
67
- /* receive external events */
68
- _defineProperty(this, "onTablePluginState", function (state) {
69
- var tableRef = state.tableRef;
70
- var tree = _this.tree;
71
- if (!tree) {
72
- return;
73
- }
74
-
75
- // when header rows are toggled off - mark sentinels as unobserved
76
- if (!state.isHeaderRowEnabled) {
77
- [_this.sentinels.top, _this.sentinels.bottom].forEach(function (el) {
78
- if (el) {
79
- delete el.dataset.isObserved;
80
- }
81
- });
82
- }
83
- var isCurrentTableSelected = tableRef === tree.table;
84
-
85
- // If current table selected and header row is toggled off, turn off sticky header
86
- if (isCurrentTableSelected && !state.isHeaderRowEnabled && _this.tree) {
87
- _this.makeRowHeaderNotSticky(_this.tree.table);
88
- }
89
- _this.focused = isCurrentTableSelected;
90
- var wrapper = tree.wrapper;
91
- var tableContainer = wrapper.parentElement;
92
- var tableContentWrapper = tableContainer.parentElement;
93
- var layoutContainer = tableContentWrapper && tableContentWrapper.parentElement;
94
- if (isCurrentTableSelected) {
95
- _this.colControlsOffset = tableControlsSpacing;
96
- if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
97
- // move table a little out of the way
98
- // to provide spacing for table controls
99
- tableContentWrapper.style.paddingLeft = '11px';
100
- }
101
- } else {
102
- _this.colControlsOffset = 0;
103
- if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
104
- tableContentWrapper.style.removeProperty('padding-left');
105
- }
59
+ _this.isHeaderRow = supportedHeaderRow(node);
60
+ _this.isSticky = false;
61
+ var _getPluginState = getPluginState(view.state),
62
+ pluginConfig = _getPluginState.pluginConfig,
63
+ isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
64
+ _this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
65
+ _this.isDragAndDropEnabled = !!isDragAndDropEnabled;
66
+ if (_this.isHeaderRow) {
67
+ _this.dom.setAttribute('data-header-row', 'true');
68
+ if (_this.isStickyHeaderEnabled) {
69
+ _this.subscribe();
106
70
  }
71
+ }
72
+ return _this;
73
+ }
107
74
 
108
- // run after table style changes have been committed
109
- setTimeout(function () {
110
- syncStickyRowToTable(tree.table);
111
- }, 0);
112
- });
113
- _defineProperty(this, "updateStickyHeaderWidth", function () {
114
- // table width might have changed, sync that back to sticky row
115
- var tree = _this.tree;
116
- if (!tree) {
117
- return;
118
- }
119
- syncStickyRowToTable(tree.table);
120
- });
121
- _defineProperty(this, "shouldHeaderStick", function (tree) {
122
- var wrapper = tree.wrapper;
123
- var tableWrapperRect = wrapper.getBoundingClientRect();
124
- var editorAreaRect = _this.editorScrollableElement.getBoundingClientRect();
125
- var stickyHeaderRect = _this.contentDOM.getBoundingClientRect();
126
- var firstHeaderRow = !_this.dom.previousElementSibling;
127
- var subsequentRows = !!_this.dom.nextElementSibling;
128
- var isHeaderValid = firstHeaderRow && subsequentRows;
75
+ /**
76
+ * Variables
77
+ */
129
78
 
130
- // if the table wrapper is less than the editor top pos then make it sticky
131
- // Make header sticky if table wrapper top is outside viewport
132
- // but bottom is still in the viewport.
133
- if (tableWrapperRect.top < editorAreaRect.top && tableWrapperRect.bottom > editorAreaRect.top && isHeaderValid) {
79
+ // @ts-ignore
80
+ _createClass(TableRow, [{
81
+ key: "update",
82
+ value:
83
+ /**
84
+ * Methods: Nodeview Lifecycle
85
+ */
86
+ function update(node) {
87
+ // do nothing if nodes were identical
88
+ if (node === this.node) {
134
89
  return true;
135
90
  }
136
91
 
137
- // if the sticky header is below the editor area make it non-sticky
138
- if (stickyHeaderRect.top > editorAreaRect.top) {
139
- return false;
92
+ // see if we're changing into a header row or
93
+ // changing away from one
94
+ var newNodeIsHeaderRow = supportedHeaderRow(node);
95
+ if (this.isHeaderRow !== newNodeIsHeaderRow) {
96
+ return false; // re-create nodeview
140
97
  }
141
98
 
142
- // otherwise make it non-sticky
143
- return false;
144
- });
145
- /**
146
- * Manually refire the intersection observers.
147
- * Useful when the header may have detached from the table.
148
- */
149
- _defineProperty(this, "refireIntersectionObservers", function () {
150
- if (_this.isSticky) {
151
- [_this.sentinels.top, _this.sentinels.bottom].forEach(function (el) {
152
- if (el && _this.intersectionObserver) {
153
- _this.intersectionObserver.unobserve(el);
154
- _this.intersectionObserver.observe(el);
155
- }
156
- });
157
- }
158
- });
159
- _defineProperty(this, "makeHeaderRowSticky", function (tree, scrollTop) {
160
- var _tbody$firstChild;
161
- // If header row height is more than 50% of viewport height don't do this
162
- if (_this.isSticky || _this.stickyRowHeight && _this.stickyRowHeight > window.innerHeight / 2) {
163
- return;
164
- }
165
- var table = tree.table,
166
- wrapper = tree.wrapper;
99
+ // node is different but no need to re-create nodeview
100
+ this.node = node;
167
101
 
168
- // ED-16035 Make sure sticky header is only applied to first row
169
- var tbody = _this.dom.parentElement;
170
- var isFirstHeader = tbody === null || tbody === void 0 || (_tbody$firstChild = tbody.firstChild) === null || _tbody$firstChild === void 0 ? void 0 : _tbody$firstChild.isEqualNode(_this.dom);
171
- if (!isFirstHeader) {
172
- return;
173
- }
174
- var currentTableTop = _this.getCurrentTableTop(tree);
175
- if (!scrollTop) {
176
- scrollTop = getTop(_this.editorScrollableElement);
102
+ // don't do anything if we're just a regular tr
103
+ if (!this.isHeaderRow) {
104
+ return true;
177
105
  }
178
- var domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
179
- if (!_this.isSticky) {
180
- var _this$editorScrollabl;
181
- syncStickyRowToTable(table);
182
- _this.dom.classList.add('sticky');
183
- table.classList.add(ClassName.TABLE_STICKY);
184
- _this.isSticky = true;
185
106
 
186
- /**
187
- * The logic below is not desirable, but acts as a fail safe for scenarios where the sticky header
188
- * detaches from the table. This typically happens during a fast scroll by the user which causes
189
- * the intersection observer logic to not fire as expected.
190
- */
191
- (_this$editorScrollabl = _this.editorScrollableElement) === null || _this$editorScrollabl === void 0 || _this$editorScrollabl.addEventListener('scrollend', _this.refireIntersectionObservers, {
192
- passive: true,
193
- once: true
194
- });
195
- var fastScrollThresholdMs = 500;
196
- setTimeout(function () {
197
- _this.refireIntersectionObservers();
198
- }, fastScrollThresholdMs);
199
- }
200
- _this.dom.style.top = "".concat(domTop, "px");
201
- updateTableMargin(table);
202
- _this.dom.scrollLeft = wrapper.scrollLeft;
203
- _this.emitOn(domTop, _this.colControlsOffset);
204
- });
205
- _defineProperty(this, "makeRowHeaderNotSticky", function (table) {
206
- var isEditorDestroyed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
207
- if (!_this.isSticky || !table || !_this.dom) {
208
- return;
209
- }
210
- _this.dom.style.removeProperty('width');
211
- _this.dom.classList.remove('sticky');
212
- table.classList.remove(ClassName.TABLE_STICKY);
213
- _this.isSticky = false;
214
- _this.dom.style.top = '';
215
- table.style.removeProperty('margin-top');
216
- _this.emitOff(isEditorDestroyed);
217
- });
218
- _defineProperty(this, "getWrapperoffset", function () {
219
- var inverse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
220
- var focusValue = inverse ? !_this.focused : _this.focused;
221
- return focusValue ? 0 : tableControlsSpacing;
222
- });
223
- _defineProperty(this, "getWrapperRefTop", function (wrapper) {
224
- return Math.round(getTop(wrapper)) + _this.getWrapperoffset();
225
- });
226
- // TODO: rename!
227
- _defineProperty(this, "getScrolledTableTop", function (wrapper) {
228
- return _this.getWrapperRefTop(wrapper) - _this.topPosEditorElement;
229
- });
230
- _defineProperty(this, "getCurrentTableTop", function (tree) {
231
- return _this.getScrolledTableTop(tree.wrapper) + tree.table.clientHeight;
232
- });
233
- /* emit external events */
234
- _defineProperty(this, "padding", 0);
235
- _defineProperty(this, "top", 0);
236
- _defineProperty(this, "emitOn", function (top, padding) {
237
- if (top === _this.top && padding === _this.padding) {
238
- return;
239
- }
240
- _this.top = top;
241
- _this.padding = padding;
242
- updateStickyState({
243
- pos: _this.getPos(),
244
- top: top,
245
- sticky: true,
246
- padding: padding
247
- })(_this.view.state, _this.view.dispatch, _this.view);
248
- });
249
- _defineProperty(this, "emitOff", function (isEditorDestroyed) {
250
- if (_this.top === 0 && _this.padding === 0) {
251
- return;
107
+ // something changed, sync widths
108
+ if (this.isStickyHeaderEnabled) {
109
+ var tbody = this.dom.parentElement;
110
+ var table = tbody && tbody.parentElement;
111
+ syncStickyRowToTable(table);
252
112
  }
253
- _this.top = 0;
254
- _this.padding = 0;
255
- if (!isEditorDestroyed) {
256
- updateStickyState({
257
- pos: _this.getPos(),
258
- sticky: false,
259
- top: _this.top,
260
- padding: _this.padding
261
- })(_this.view.state, _this.view.dispatch, _this.view);
113
+ return true;
114
+ }
115
+ }, {
116
+ key: "destroy",
117
+ value: function destroy() {
118
+ if (this.isStickyHeaderEnabled) {
119
+ this.unsubscribe();
120
+ var tree = getTree(this.dom);
121
+ if (tree) {
122
+ this.makeRowHeaderNotSticky(tree.table, true);
123
+ }
124
+ this.emitOff(true);
262
125
  }
263
- });
264
- this.view = view;
265
- this.node = node;
266
- this.getPos = getPos;
267
- this.eventDispatcher = eventDispatcher;
268
- this.dom = document.createElement('tr');
269
- this.contentDOM = this.dom;
270
- this.lastTimePainted = 0;
271
- this.isHeaderRow = supportedHeaderRow(node);
272
- this.isSticky = false;
273
- this.lastStickyTimestamp = undefined;
274
- if (this.isHeaderRow) {
275
- this.dom.setAttribute('data-header-row', 'true');
276
- this.subscribe();
277
126
  }
278
- }
279
- _createClass(TableRowNodeView, [{
280
- key: "tree",
281
- get: function get() {
282
- return getTree(this.dom);
127
+ }, {
128
+ key: "ignoreMutation",
129
+ value: function ignoreMutation(mutationRecord) {
130
+ /* tableRows are not directly editable by the user
131
+ * so it should be safe to ignore mutations that we cause
132
+ * by updating styles and classnames on this DOM element
133
+ *
134
+ * Update: should not ignore mutations for row selection to avoid known issue with table selection highlight in firefox
135
+ * Related bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1289673
136
+ * */
137
+ var isTableSelection = mutationRecord.type === 'selection' && mutationRecord.target.nodeName === 'TR';
138
+ /**
139
+ * Update: should not ignore mutations when an node is added, as this interferes with
140
+ * prosemirrors handling of some language inputs in Safari (ie. Pinyin, Hiragana).
141
+ *
142
+ * In paticular, when a composition occurs at the start of the first node inside a table cell, if the resulting mutation
143
+ * from the composition end is ignored than prosemirror will end up with; invalid table markup nesting and a misplaced
144
+ * selection and insertion.
145
+ */
146
+ var isNodeInsertion = mutationRecord.type === 'childList' && mutationRecord.target.nodeName === 'TR' && mutationRecord.addedNodes.length;
147
+ if (isTableSelection || isNodeInsertion) {
148
+ return false;
149
+ }
150
+ return true;
283
151
  }
284
152
  }, {
285
153
  key: "subscribe",
@@ -289,8 +157,8 @@ export var TableRowNodeView = /*#__PURE__*/function () {
289
157
  this.initObservers();
290
158
  this.topPosEditorElement = getTop(this.editorScrollableElement);
291
159
  }
292
- this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth);
293
- this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState);
160
+ this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth.bind(this));
161
+ this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState.bind(this));
294
162
  this.listening = true;
295
163
  this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this), {
296
164
  passive: true
@@ -344,9 +212,9 @@ export var TableRowNodeView = /*#__PURE__*/function () {
344
212
  this.resizeObserver.observe(this.editorScrollableElement);
345
213
  }
346
214
  window.requestAnimationFrame(function () {
347
- var _this2$tree;
215
+ var _getTree;
348
216
  // we expect tree to be defined after animation frame
349
- var tableContainer = (_this2$tree = _this2.tree) === null || _this2$tree === void 0 ? void 0 : _this2$tree.wrapper.closest(".".concat(TableCssClassName.NODEVIEW_WRAPPER));
217
+ var tableContainer = (_getTree = getTree(_this2.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(TableCssClassName.NODEVIEW_WRAPPER));
350
218
  if (tableContainer) {
351
219
  _this2.sentinels.top = tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_TOP).item(0);
352
220
  _this2.sentinels.bottom = tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_BOTTOM).item(0);
@@ -368,10 +236,11 @@ export var TableRowNodeView = /*#__PURE__*/function () {
368
236
  value: function createResizeObserver() {
369
237
  var _this3 = this;
370
238
  this.resizeObserver = new ResizeObserver(function (entries) {
371
- if (!_this3.tree) {
239
+ var tree = getTree(_this3.dom);
240
+ if (!tree) {
372
241
  return;
373
242
  }
374
- var table = _this3.tree.table;
243
+ var table = tree.table;
375
244
  entries.forEach(function (entry) {
376
245
  var _this3$editorScrollab;
377
246
  // On resize of the parent scroll element we need to adjust the width
@@ -397,10 +266,11 @@ export var TableRowNodeView = /*#__PURE__*/function () {
397
266
  value: function createIntersectionObserver() {
398
267
  var _this4 = this;
399
268
  this.intersectionObserver = new IntersectionObserver(function (entries, _) {
400
- if (!_this4.tree) {
269
+ var tree = getTree(_this4.dom);
270
+ if (!tree) {
401
271
  return;
402
272
  }
403
- var table = _this4.tree.table;
273
+ var table = tree.table;
404
274
  if (table.rows.length < 2) {
405
275
  // ED-19307 - When there's only one row in a table the top & bottom sentinels become inverted. This creates some nasty visiblity
406
276
  // toggling side-effects because the intersection observers gets confused.
@@ -419,7 +289,7 @@ export var TableRowNodeView = /*#__PURE__*/function () {
419
289
  var sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
420
290
  if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
421
291
  var _entry$rootBounds3;
422
- _this4.tree && _this4.makeHeaderRowSticky(_this4.tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
292
+ tree && _this4.makeHeaderRowSticky(tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
423
293
  _this4.lastStickyTimestamp = Date.now();
424
294
  } else {
425
295
  table && _this4.makeRowHeaderNotSticky(table);
@@ -439,7 +309,7 @@ export var TableRowNodeView = /*#__PURE__*/function () {
439
309
  }
440
310
  } else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
441
311
  var _entry$rootBounds5;
442
- _this4.tree && _this4.makeHeaderRowSticky(_this4.tree, entry === null || entry === void 0 || (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
312
+ tree && _this4.makeHeaderRowSticky(tree, entry === null || entry === void 0 || (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
443
313
  _this4.lastStickyTimestamp = Date.now();
444
314
  }
445
315
  }
@@ -449,72 +319,209 @@ export var TableRowNodeView = /*#__PURE__*/function () {
449
319
  root: this.editorScrollableElement
450
320
  });
451
321
  }
452
-
453
- /* paint/update loop */
322
+ /* receive external events */
454
323
  }, {
455
- key: "update",
456
- value: /* nodeview lifecycle */
457
- function update(node) {
458
- // do nothing if nodes were identical
459
- if (node === this.node) {
460
- return true;
324
+ key: "onTablePluginState",
325
+ value: function onTablePluginState(state) {
326
+ var tableRef = state.tableRef;
327
+ var tree = getTree(this.dom);
328
+ if (!tree) {
329
+ return;
461
330
  }
462
331
 
463
- // see if we're changing into a header row or
464
- // changing away from one
465
- var newNodeIsHeaderRow = supportedHeaderRow(node);
466
- if (this.isHeaderRow !== newNodeIsHeaderRow) {
467
- return false; // re-create nodeview
332
+ // when header rows are toggled off - mark sentinels as unobserved
333
+ if (!state.isHeaderRowEnabled) {
334
+ [this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
335
+ if (el) {
336
+ delete el.dataset.isObserved;
337
+ }
338
+ });
468
339
  }
340
+ var isCurrentTableSelected = tableRef === tree.table;
469
341
 
470
- // node is different but no need to re-create nodeview
471
- this.node = node;
342
+ // If current table selected and header row is toggled off, turn off sticky header
343
+ if (isCurrentTableSelected && !state.isHeaderRowEnabled && tree) {
344
+ this.makeRowHeaderNotSticky(tree.table);
345
+ }
346
+ this.focused = isCurrentTableSelected;
347
+ var wrapper = tree.wrapper;
348
+ var tableContainer = wrapper.parentElement;
349
+ var tableContentWrapper = tableContainer.parentElement;
350
+ var layoutContainer = tableContentWrapper && tableContentWrapper.parentElement;
351
+ if (isCurrentTableSelected) {
352
+ this.colControlsOffset = tableControlsSpacing;
353
+ if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
354
+ // move table a little out of the way
355
+ // to provide spacing for table controls
356
+ tableContentWrapper.style.paddingLeft = '11px';
357
+ }
358
+ } else {
359
+ this.colControlsOffset = 0;
360
+ if (layoutContainer && layoutContainer.getAttribute('data-layout-content')) {
361
+ tableContentWrapper.style.removeProperty('padding-left');
362
+ }
363
+ }
472
364
 
473
- // don't do anything if we're just a regular tr
474
- if (!this.isHeaderRow) {
475
- return true;
365
+ // run after table style changes have been committed
366
+ setTimeout(function () {
367
+ syncStickyRowToTable(tree.table);
368
+ }, 0);
369
+ }
370
+ }, {
371
+ key: "updateStickyHeaderWidth",
372
+ value: function updateStickyHeaderWidth() {
373
+ // table width might have changed, sync that back to sticky row
374
+ var tree = getTree(this.dom);
375
+ if (!tree) {
376
+ return;
476
377
  }
378
+ syncStickyRowToTable(tree.table);
379
+ }
477
380
 
478
- // something changed, sync widths
381
+ /**
382
+ * Manually refire the intersection observers.
383
+ * Useful when the header may have detached from the table.
384
+ */
385
+ }, {
386
+ key: "refireIntersectionObservers",
387
+ value: function refireIntersectionObservers() {
388
+ var _this5 = this;
389
+ if (this.isSticky) {
390
+ [this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
391
+ if (el && _this5.intersectionObserver) {
392
+ _this5.intersectionObserver.unobserve(el);
393
+ _this5.intersectionObserver.observe(el);
394
+ }
395
+ });
396
+ }
397
+ }
398
+ }, {
399
+ key: "makeHeaderRowSticky",
400
+ value: function makeHeaderRowSticky(tree, scrollTop) {
401
+ var _tbody$firstChild,
402
+ _this6 = this;
403
+ // If header row height is more than 50% of viewport height don't do this
404
+ if (this.isSticky || this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2) {
405
+ return;
406
+ }
407
+ var table = tree.table,
408
+ wrapper = tree.wrapper;
409
+
410
+ // ED-16035 Make sure sticky header is only applied to first row
479
411
  var tbody = this.dom.parentElement;
480
- var table = tbody && tbody.parentElement;
481
- syncStickyRowToTable(table);
482
- return true;
412
+ var isFirstHeader = tbody === null || tbody === void 0 || (_tbody$firstChild = tbody.firstChild) === null || _tbody$firstChild === void 0 ? void 0 : _tbody$firstChild.isEqualNode(this.dom);
413
+ if (!isFirstHeader) {
414
+ return;
415
+ }
416
+ var currentTableTop = this.getCurrentTableTop(tree);
417
+ if (!scrollTop) {
418
+ scrollTop = getTop(this.editorScrollableElement);
419
+ }
420
+ var domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
421
+ if (!this.isSticky) {
422
+ var _this$editorScrollabl;
423
+ syncStickyRowToTable(table);
424
+ this.dom.classList.add('sticky');
425
+ table.classList.add(ClassName.TABLE_STICKY);
426
+ this.isSticky = true;
427
+
428
+ /**
429
+ * The logic below is not desirable, but acts as a fail safe for scenarios where the sticky header
430
+ * detaches from the table. This typically happens during a fast scroll by the user which causes
431
+ * the intersection observer logic to not fire as expected.
432
+ */
433
+ (_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 || _this$editorScrollabl.addEventListener('scrollend', this.refireIntersectionObservers, {
434
+ passive: true,
435
+ once: true
436
+ });
437
+ var fastScrollThresholdMs = 500;
438
+ setTimeout(function () {
439
+ _this6.refireIntersectionObservers();
440
+ }, fastScrollThresholdMs);
441
+ }
442
+ this.dom.style.top = "".concat(domTop, "px");
443
+ updateTableMargin(table);
444
+ this.dom.scrollLeft = wrapper.scrollLeft;
445
+ this.emitOn(domTop, this.colControlsOffset);
483
446
  }
484
447
  }, {
485
- key: "destroy",
486
- value: function destroy() {
487
- this.unsubscribe();
488
- if (this.tree) {
489
- this.makeRowHeaderNotSticky(this.tree.table, true);
448
+ key: "makeRowHeaderNotSticky",
449
+ value: function makeRowHeaderNotSticky(table) {
450
+ var isEditorDestroyed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
451
+ if (!this.isSticky || !table || !this.dom) {
452
+ return;
490
453
  }
491
- this.emitOff(true);
454
+ this.dom.style.removeProperty('width');
455
+ this.dom.classList.remove('sticky');
456
+ table.classList.remove(ClassName.TABLE_STICKY);
457
+ this.isSticky = false;
458
+ this.dom.style.top = '';
459
+ table.style.removeProperty('margin-top');
460
+ this.emitOff(isEditorDestroyed);
492
461
  }
493
462
  }, {
494
- key: "ignoreMutation",
495
- value: function ignoreMutation(mutationRecord) {
496
- /* tableRows are not directly editable by the user
497
- * so it should be safe to ignore mutations that we cause
498
- * by updating styles and classnames on this DOM element
499
- *
500
- * Update: should not ignore mutations for row selection to avoid known issue with table selection highlight in firefox
501
- * Related bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1289673
502
- * */
503
- var isTableSelection = mutationRecord.type === 'selection' && mutationRecord.target.nodeName === 'TR';
504
- /**
505
- * Update: should not ignore mutations when an node is added, as this interferes with
506
- * prosemirrors handling of some language inputs in Safari (ie. Pinyin, Hiragana).
507
- *
508
- * In paticular, when a composition occurs at the start of the first node inside a table cell, if the resulting mutation
509
- * from the composition end is ignored than prosemirror will end up with; invalid table markup nesting and a misplaced
510
- * selection and insertion.
511
- */
512
- var isNodeInsertion = mutationRecord.type === 'childList' && mutationRecord.target.nodeName === 'TR' && mutationRecord.addedNodes.length;
513
- if (isTableSelection || isNodeInsertion) {
514
- return false;
463
+ key: "getWrapperoffset",
464
+ value: function getWrapperoffset() {
465
+ var inverse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
466
+ var focusValue = inverse ? !this.focused : this.focused;
467
+ return focusValue ? 0 : tableControlsSpacing;
468
+ }
469
+ }, {
470
+ key: "getWrapperRefTop",
471
+ value: function getWrapperRefTop(wrapper) {
472
+ return Math.round(getTop(wrapper)) + this.getWrapperoffset();
473
+ }
474
+
475
+ // TODO: rename!
476
+ }, {
477
+ key: "getScrolledTableTop",
478
+ value: function getScrolledTableTop(wrapper) {
479
+ return this.getWrapperRefTop(wrapper) - this.topPosEditorElement;
480
+ }
481
+ }, {
482
+ key: "getCurrentTableTop",
483
+ value: function getCurrentTableTop(tree) {
484
+ return this.getScrolledTableTop(tree.wrapper) + tree.table.clientHeight;
485
+ }
486
+
487
+ /* emit external events */
488
+ }, {
489
+ key: "emitOn",
490
+ value: function emitOn(top, padding) {
491
+ if (top === this.top && padding === this.padding) {
492
+ return;
493
+ }
494
+ this.top = top;
495
+ this.padding = padding;
496
+ var pos = this.getPos();
497
+ if (Number.isFinite(pos)) {
498
+ updateStickyState({
499
+ pos: pos,
500
+ top: top,
501
+ sticky: true,
502
+ padding: padding
503
+ })(this.view.state, this.view.dispatch, this.view);
504
+ }
505
+ }
506
+ }, {
507
+ key: "emitOff",
508
+ value: function emitOff(isEditorDestroyed) {
509
+ if (this.top === 0 && this.padding === 0) {
510
+ return;
511
+ }
512
+ this.top = 0;
513
+ this.padding = 0;
514
+ var pos = this.getPos();
515
+ if (!isEditorDestroyed && Number.isFinite(pos)) {
516
+ updateStickyState({
517
+ pos: pos,
518
+ sticky: false,
519
+ top: this.top,
520
+ padding: this.padding
521
+ })(this.view.state, this.view.dispatch, this.view);
515
522
  }
516
- return true;
517
523
  }
518
524
  }]);
519
- return TableRowNodeView;
520
- }();
525
+ return TableRow;
526
+ }(TableNodeView);
527
+ export { TableRow as default };