@atlaskit/editor-plugin-table 1.1.0 → 1.1.2

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 (284) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/index.js +0 -2
  3. package/dist/cjs/plugins/table/commands/clear.js +4 -16
  4. package/dist/cjs/plugins/table/commands/collapse.js +0 -6
  5. package/dist/cjs/plugins/table/commands/go-to-next-cell.js +7 -18
  6. package/dist/cjs/plugins/table/commands/hover.js +7 -37
  7. package/dist/cjs/plugins/table/commands/index.js +0 -8
  8. package/dist/cjs/plugins/table/commands/insert.js +17 -56
  9. package/dist/cjs/plugins/table/commands/misc.js +36 -132
  10. package/dist/cjs/plugins/table/commands/referentiality.js +0 -4
  11. package/dist/cjs/plugins/table/commands/selection.js +21 -87
  12. package/dist/cjs/plugins/table/commands/sort.js +2 -23
  13. package/dist/cjs/plugins/table/commands/split-cell.js +3 -11
  14. package/dist/cjs/plugins/table/commands/toggle.js +8 -34
  15. package/dist/cjs/plugins/table/commands-with-analytics.js +50 -139
  16. package/dist/cjs/plugins/table/create-plugin-config.js +0 -6
  17. package/dist/cjs/plugins/table/event-handlers.js +58 -160
  18. package/dist/cjs/plugins/table/handlers.js +10 -39
  19. package/dist/cjs/plugins/table/index.js +47 -91
  20. package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -41
  21. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +82 -188
  22. package/dist/cjs/plugins/table/nodeviews/table.js +12 -70
  23. package/dist/cjs/plugins/table/nodeviews/tableCell.js +15 -39
  24. package/dist/cjs/plugins/table/nodeviews/update-overflow-shadows.js +3 -15
  25. package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +0 -18
  26. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -27
  27. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-resizing.js +8 -20
  28. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +1 -3
  29. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/index.js +0 -3
  30. package/dist/cjs/plugins/table/pm-plugins/keymap.js +2 -15
  31. package/dist/cjs/plugins/table/pm-plugins/main.js +20 -72
  32. package/dist/cjs/plugins/table/pm-plugins/plugin-factory.js +25 -42
  33. package/dist/cjs/plugins/table/pm-plugins/plugin-key.js +0 -2
  34. package/dist/cjs/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -8
  35. package/dist/cjs/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +4 -23
  36. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/commands.js +0 -5
  37. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/index.js +0 -5
  38. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -13
  39. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +56 -138
  40. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-key.js +0 -2
  41. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-state.js +15 -30
  42. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +0 -6
  43. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/util.js +0 -5
  44. package/dist/cjs/plugins/table/pm-plugins/table-local-id.js +13 -44
  45. package/dist/cjs/plugins/table/pm-plugins/table-resizing/commands.js +12 -42
  46. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -52
  47. package/dist/cjs/plugins/table/pm-plugins/table-resizing/index.js +0 -4
  48. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-factory.js +0 -10
  49. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-key.js +0 -2
  50. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin.js +5 -19
  51. package/dist/cjs/plugins/table/pm-plugins/table-resizing/reducer.js +0 -10
  52. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -15
  53. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -28
  54. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/content-width.js +3 -23
  55. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +4 -46
  56. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/index.js +0 -9
  57. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +15 -36
  58. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-column.js +1 -4
  59. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +15 -71
  60. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +34 -82
  61. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +12 -36
  62. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.js +0 -2
  63. package/dist/cjs/plugins/table/pm-plugins/table-selection-keymap.js +0 -5
  64. package/dist/cjs/plugins/table/reducer.js +0 -24
  65. package/dist/cjs/plugins/table/toolbar.js +14 -94
  66. package/dist/cjs/plugins/table/transforms/column-width.js +12 -45
  67. package/dist/cjs/plugins/table/transforms/delete-columns.js +11 -76
  68. package/dist/cjs/plugins/table/transforms/delete-rows.js +4 -42
  69. package/dist/cjs/plugins/table/transforms/fix-tables.js +24 -61
  70. package/dist/cjs/plugins/table/transforms/index.js +0 -7
  71. package/dist/cjs/plugins/table/transforms/merge.js +14 -90
  72. package/dist/cjs/plugins/table/transforms/metadata.js +0 -5
  73. package/dist/cjs/plugins/table/transforms/replace-table.js +2 -13
  74. package/dist/cjs/plugins/table/transforms/split.js +18 -32
  75. package/dist/cjs/plugins/table/types.js +0 -11
  76. package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +10 -51
  77. package/dist/cjs/plugins/table/ui/FloatingContextualButton/styles.js +0 -12
  78. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +46 -145
  79. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +12 -35
  80. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/styles.js +0 -11
  81. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +5 -12
  82. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +3 -16
  83. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +19 -89
  84. package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +6 -31
  85. package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +5 -22
  86. package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +25 -80
  87. package/dist/cjs/plugins/table/ui/LayoutButton/index.js +16 -64
  88. package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +14 -47
  89. package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +20 -48
  90. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +10 -43
  91. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +33 -74
  92. package/dist/cjs/plugins/table/ui/common-styles.js +6 -19
  93. package/dist/cjs/plugins/table/ui/consts.js +3 -8
  94. package/dist/cjs/plugins/table/ui/messages.js +0 -3
  95. package/dist/cjs/plugins/table/ui/ui-styles.js +0 -32
  96. package/dist/cjs/plugins/table/utils/analytics.js +4 -19
  97. package/dist/cjs/plugins/table/utils/collapse.js +4 -21
  98. package/dist/cjs/plugins/table/utils/column-controls.js +25 -61
  99. package/dist/cjs/plugins/table/utils/decoration.js +46 -114
  100. package/dist/cjs/plugins/table/utils/dom.js +4 -51
  101. package/dist/cjs/plugins/table/utils/get-allow-add-column-custom-step.js +0 -2
  102. package/dist/cjs/plugins/table/utils/index.js +0 -10
  103. package/dist/cjs/plugins/table/utils/nodes.js +5 -48
  104. package/dist/cjs/plugins/table/utils/paste.js +22 -47
  105. package/dist/cjs/plugins/table/utils/row-controls.js +6 -67
  106. package/dist/cjs/plugins/table/utils/selection.js +3 -36
  107. package/dist/cjs/plugins/table/utils/table.js +0 -11
  108. package/dist/cjs/plugins/table/utils/update-plugin-state-decorations.js +0 -4
  109. package/dist/cjs/plugins/table-plugin.js +0 -3
  110. package/dist/cjs/version.json +1 -1
  111. package/dist/es2019/plugins/table/commands/clear.js +3 -8
  112. package/dist/es2019/plugins/table/commands/collapse.js +0 -3
  113. package/dist/es2019/plugins/table/commands/go-to-next-cell.js +4 -7
  114. package/dist/es2019/plugins/table/commands/hover.js +7 -17
  115. package/dist/es2019/plugins/table/commands/insert.js +16 -36
  116. package/dist/es2019/plugins/table/commands/misc.js +37 -67
  117. package/dist/es2019/plugins/table/commands/selection.js +7 -62
  118. package/dist/es2019/plugins/table/commands/sort.js +0 -12
  119. package/dist/es2019/plugins/table/commands/split-cell.js +0 -4
  120. package/dist/es2019/plugins/table/commands/toggle.js +13 -15
  121. package/dist/es2019/plugins/table/commands-with-analytics.js +4 -14
  122. package/dist/es2019/plugins/table/event-handlers.js +14 -62
  123. package/dist/es2019/plugins/table/handlers.js +16 -26
  124. package/dist/es2019/plugins/table/index.js +12 -25
  125. package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -40
  126. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +27 -100
  127. package/dist/es2019/plugins/table/nodeviews/table.js +3 -33
  128. package/dist/es2019/plugins/table/nodeviews/tableCell.js +7 -16
  129. package/dist/es2019/plugins/table/nodeviews/update-overflow-shadows.js +3 -10
  130. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +0 -5
  131. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +4 -13
  132. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-resizing.js +0 -3
  133. package/dist/es2019/plugins/table/pm-plugins/keymap.js +2 -3
  134. package/dist/es2019/plugins/table/pm-plugins/main.js +19 -43
  135. package/dist/es2019/plugins/table/pm-plugins/plugin-factory.js +2 -6
  136. package/dist/es2019/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -3
  137. package/dist/es2019/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +0 -12
  138. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -9
  139. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +55 -130
  140. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin-state.js +2 -9
  141. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/util.js +0 -3
  142. package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +20 -39
  143. package/dist/es2019/plugins/table/pm-plugins/table-resizing/commands.js +7 -15
  144. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -27
  145. package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -4
  146. package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin.js +2 -5
  147. package/dist/es2019/plugins/table/pm-plugins/table-resizing/reducer.js +8 -8
  148. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -4
  149. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -11
  150. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/content-width.js +4 -21
  151. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/dom.js +3 -22
  152. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +10 -18
  153. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +29 -59
  154. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +54 -51
  155. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +9 -14
  156. package/dist/es2019/plugins/table/reducer.js +26 -30
  157. package/dist/es2019/plugins/table/toolbar.js +5 -48
  158. package/dist/es2019/plugins/table/transforms/column-width.js +16 -28
  159. package/dist/es2019/plugins/table/transforms/delete-columns.js +17 -58
  160. package/dist/es2019/plugins/table/transforms/delete-rows.js +8 -25
  161. package/dist/es2019/plugins/table/transforms/fix-tables.js +25 -42
  162. package/dist/es2019/plugins/table/transforms/merge.js +22 -70
  163. package/dist/es2019/plugins/table/transforms/metadata.js +3 -2
  164. package/dist/es2019/plugins/table/transforms/replace-table.js +0 -2
  165. package/dist/es2019/plugins/table/transforms/split.js +16 -19
  166. package/dist/es2019/plugins/table/types.js +2 -4
  167. package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +2 -16
  168. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +8 -54
  169. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +4 -13
  170. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +0 -2
  171. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +2 -11
  172. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +13 -49
  173. package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +0 -8
  174. package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +16 -24
  175. package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +3 -31
  176. package/dist/es2019/plugins/table/ui/LayoutButton/index.js +2 -29
  177. package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +0 -12
  178. package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +6 -12
  179. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +0 -9
  180. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -19
  181. package/dist/es2019/plugins/table/ui/common-styles.js +6 -5
  182. package/dist/es2019/plugins/table/ui/consts.js +4 -3
  183. package/dist/es2019/plugins/table/ui/ui-styles.js +0 -10
  184. package/dist/es2019/plugins/table/utils/analytics.js +0 -8
  185. package/dist/es2019/plugins/table/utils/collapse.js +3 -14
  186. package/dist/es2019/plugins/table/utils/column-controls.js +22 -37
  187. package/dist/es2019/plugins/table/utils/decoration.js +13 -51
  188. package/dist/es2019/plugins/table/utils/dom.js +3 -19
  189. package/dist/es2019/plugins/table/utils/nodes.js +2 -15
  190. package/dist/es2019/plugins/table/utils/paste.js +17 -22
  191. package/dist/es2019/plugins/table/utils/row-controls.js +12 -45
  192. package/dist/es2019/plugins/table/utils/selection.js +0 -21
  193. package/dist/es2019/plugins/table/utils/table.js +0 -2
  194. package/dist/es2019/version.json +1 -1
  195. package/dist/esm/plugins/table/commands/clear.js +3 -8
  196. package/dist/esm/plugins/table/commands/collapse.js +0 -3
  197. package/dist/esm/plugins/table/commands/go-to-next-cell.js +6 -9
  198. package/dist/esm/plugins/table/commands/hover.js +8 -18
  199. package/dist/esm/plugins/table/commands/insert.js +16 -36
  200. package/dist/esm/plugins/table/commands/misc.js +39 -78
  201. package/dist/esm/plugins/table/commands/selection.js +21 -78
  202. package/dist/esm/plugins/table/commands/sort.js +2 -14
  203. package/dist/esm/plugins/table/commands/split-cell.js +3 -8
  204. package/dist/esm/plugins/table/commands/toggle.js +11 -20
  205. package/dist/esm/plugins/table/commands-with-analytics.js +50 -85
  206. package/dist/esm/plugins/table/create-plugin-config.js +0 -3
  207. package/dist/esm/plugins/table/event-handlers.js +58 -123
  208. package/dist/esm/plugins/table/handlers.js +11 -29
  209. package/dist/esm/plugins/table/index.js +47 -60
  210. package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -44
  211. package/dist/esm/plugins/table/nodeviews/TableComponent.js +82 -181
  212. package/dist/esm/plugins/table/nodeviews/table.js +12 -52
  213. package/dist/esm/plugins/table/nodeviews/tableCell.js +15 -33
  214. package/dist/esm/plugins/table/nodeviews/update-overflow-shadows.js +3 -10
  215. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +0 -5
  216. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -19
  217. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-resizing.js +8 -13
  218. package/dist/esm/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +1 -1
  219. package/dist/esm/plugins/table/pm-plugins/keymap.js +2 -3
  220. package/dist/esm/plugins/table/pm-plugins/main.js +20 -47
  221. package/dist/esm/plugins/table/pm-plugins/plugin-factory.js +25 -37
  222. package/dist/esm/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -3
  223. package/dist/esm/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +3 -15
  224. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -9
  225. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +58 -147
  226. package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin-state.js +15 -27
  227. package/dist/esm/plugins/table/pm-plugins/sticky-headers/util.js +0 -3
  228. package/dist/esm/plugins/table/pm-plugins/table-local-id.js +14 -37
  229. package/dist/esm/plugins/table/pm-plugins/table-resizing/commands.js +12 -24
  230. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -36
  231. package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin-factory.js +0 -6
  232. package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin.js +5 -8
  233. package/dist/esm/plugins/table/pm-plugins/table-resizing/reducer.js +0 -7
  234. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -4
  235. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -12
  236. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/content-width.js +5 -22
  237. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/dom.js +4 -23
  238. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +15 -23
  239. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +15 -60
  240. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +34 -55
  241. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +12 -24
  242. package/dist/esm/plugins/table/reducer.js +0 -20
  243. package/dist/esm/plugins/table/toolbar.js +13 -63
  244. package/dist/esm/plugins/table/transforms/column-width.js +12 -32
  245. package/dist/esm/plugins/table/transforms/delete-columns.js +11 -62
  246. package/dist/esm/plugins/table/transforms/delete-rows.js +4 -30
  247. package/dist/esm/plugins/table/transforms/fix-tables.js +24 -49
  248. package/dist/esm/plugins/table/transforms/merge.js +16 -75
  249. package/dist/esm/plugins/table/transforms/metadata.js +3 -2
  250. package/dist/esm/plugins/table/transforms/replace-table.js +2 -6
  251. package/dist/esm/plugins/table/transforms/split.js +18 -29
  252. package/dist/esm/plugins/table/types.js +0 -6
  253. package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +10 -31
  254. package/dist/esm/plugins/table/ui/FloatingContextualButton/styles.js +0 -2
  255. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +46 -126
  256. package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +13 -24
  257. package/dist/esm/plugins/table/ui/FloatingContextualMenu/styles.js +0 -2
  258. package/dist/esm/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +5 -7
  259. package/dist/esm/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +3 -13
  260. package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +19 -68
  261. package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +6 -14
  262. package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +5 -18
  263. package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +25 -57
  264. package/dist/esm/plugins/table/ui/LayoutButton/index.js +16 -47
  265. package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +14 -35
  266. package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +20 -38
  267. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +10 -29
  268. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +33 -62
  269. package/dist/esm/plugins/table/ui/common-styles.js +6 -7
  270. package/dist/esm/plugins/table/ui/consts.js +4 -3
  271. package/dist/esm/plugins/table/ui/ui-styles.js +0 -12
  272. package/dist/esm/plugins/table/utils/analytics.js +4 -13
  273. package/dist/esm/plugins/table/utils/collapse.js +4 -15
  274. package/dist/esm/plugins/table/utils/column-controls.js +25 -41
  275. package/dist/esm/plugins/table/utils/decoration.js +46 -88
  276. package/dist/esm/plugins/table/utils/dom.js +4 -20
  277. package/dist/esm/plugins/table/utils/nodes.js +5 -18
  278. package/dist/esm/plugins/table/utils/paste.js +24 -29
  279. package/dist/esm/plugins/table/utils/row-controls.js +6 -46
  280. package/dist/esm/plugins/table/utils/selection.js +3 -26
  281. package/dist/esm/plugins/table/utils/table.js +0 -2
  282. package/dist/esm/version.json +1 -1
  283. package/package.json +2 -2
  284. package/src/__tests__/visual-regression/cell-options-menu.ts +1 -12
@@ -14,34 +14,29 @@ import { deleteColumns, deleteRows } from './transforms';
14
14
  import { RESIZE_HANDLE_AREA_DECORATION_GAP } from './types';
15
15
  import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, isCell, isColumnControlsDecorations, isCornerButton, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableControlsButton, isTableContainerOrWrapper, hasResizeHandler } from './utils';
16
16
  import { getAllowAddColumnCustomStep } from './utils/get-allow-add-column-custom-step';
17
-
18
17
  var isFocusingCalendar = function isFocusingCalendar(event) {
19
18
  return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
20
19
  };
21
-
22
20
  var isFocusingModal = function isFocusingModal(event) {
23
21
  return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="dialog"]');
24
22
  };
25
-
26
23
  var isFocusingFloatingToolbar = function isFocusingFloatingToolbar(event) {
27
24
  return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="toolbar"]');
28
25
  };
29
-
30
26
  export var handleBlur = function handleBlur(view, event) {
31
27
  var state = view.state,
32
- dispatch = view.dispatch; // IE version check for ED-4665
28
+ dispatch = view.dispatch;
29
+ // IE version check for ED-4665
33
30
  // Calendar focus check for ED-10466
34
-
35
31
  if (browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event)) {
36
32
  setEditorFocus(false)(state, dispatch);
37
33
  }
38
-
39
34
  event.preventDefault();
40
35
  return false;
41
36
  };
42
37
  export var handleFocus = function handleFocus(view, event) {
43
38
  var state = view.state,
44
- dispatch = view.dispatch;
39
+ dispatch = view.dispatch;
45
40
  setEditorFocus(true)(state, dispatch);
46
41
  event.preventDefault();
47
42
  return false;
@@ -50,164 +45,135 @@ export var handleClick = function handleClick(view, event) {
50
45
  if (!(event.target instanceof HTMLElement)) {
51
46
  return false;
52
47
  }
53
-
54
48
  var element = event.target;
55
49
  var table = findTable(view.state.selection);
56
-
57
50
  if (event instanceof MouseEvent && isColumnControlsDecorations(element)) {
58
51
  var _getColumnOrRowIndex = getColumnOrRowIndex(element),
59
- _getColumnOrRowIndex2 = _slicedToArray(_getColumnOrRowIndex, 1),
60
- startIndex = _getColumnOrRowIndex2[0];
61
-
52
+ _getColumnOrRowIndex2 = _slicedToArray(_getColumnOrRowIndex, 1),
53
+ startIndex = _getColumnOrRowIndex2[0];
62
54
  var state = view.state,
63
- _dispatch = view.dispatch;
55
+ _dispatch = view.dispatch;
64
56
  return selectColumn(startIndex, event.shiftKey)(state, _dispatch);
65
57
  }
58
+ var matchfn = element.matches ? element.matches : element.msMatchesSelector;
66
59
 
67
- var matchfn = element.matches ? element.matches : element.msMatchesSelector; // check if the table cell with an image is clicked and its not the image itself
68
-
60
+ // check if the table cell with an image is clicked and its not the image itself
69
61
  if (!table || !isElementInTableCell(element) || !matchfn || matchfn.call(element, 'table .image, table p, table .image div')) {
70
62
  return false;
71
63
  }
72
-
73
64
  var map = TableMap.get(table.node);
74
- /** Getting the offset of current item clicked */
75
65
 
66
+ /** Getting the offset of current item clicked */
76
67
  var colElement = closestElement(element, 'td') || closestElement(element, 'th');
77
68
  var colIndex = colElement && colElement.cellIndex;
78
69
  var rowElement = closestElement(element, 'tr');
79
70
  var rowIndex = rowElement && rowElement.rowIndex;
80
71
  var cellIndex = map.width * rowIndex + colIndex;
81
72
  var dispatch = view.dispatch,
82
- _view$state = view.state,
83
- tr = _view$state.tr,
84
- paragraph = _view$state.schema.nodes.paragraph;
73
+ _view$state = view.state,
74
+ tr = _view$state.tr,
75
+ paragraph = _view$state.schema.nodes.paragraph;
85
76
  var cellPos = map.map[cellIndex];
86
-
87
77
  if (isNaN(cellPos) || cellPos === undefined || typeof cellPos !== 'number') {
88
78
  return false;
89
79
  }
90
-
91
80
  var editorElement = table.node.nodeAt(cellPos);
92
81
  /** Only if the last item is media group, insert a paragraph */
93
-
94
82
  if (isLastItemMediaGroup(editorElement)) {
95
83
  var posInTable = map.map[cellIndex] + editorElement.nodeSize;
96
84
  tr.insert(posInTable + table.pos, paragraph.create());
97
85
  dispatch(tr);
98
86
  setNodeSelection(view, posInTable + table.pos);
99
87
  }
100
-
101
88
  return true;
102
89
  };
103
90
  export var handleMouseOver = function handleMouseOver(view, mouseEvent) {
104
91
  if (!(mouseEvent.target instanceof HTMLElement)) {
105
92
  return false;
106
93
  }
107
-
108
94
  var state = view.state,
109
- dispatch = view.dispatch;
95
+ dispatch = view.dispatch;
110
96
  var target = mouseEvent.target;
111
-
112
97
  var _getPluginState = getPluginState(state),
113
- insertColumnButtonIndex = _getPluginState.insertColumnButtonIndex,
114
- insertRowButtonIndex = _getPluginState.insertRowButtonIndex;
115
-
98
+ insertColumnButtonIndex = _getPluginState.insertColumnButtonIndex,
99
+ insertRowButtonIndex = _getPluginState.insertRowButtonIndex;
116
100
  if (isInsertRowButton(target)) {
117
101
  var _getColumnOrRowIndex3 = getColumnOrRowIndex(target),
118
- _getColumnOrRowIndex4 = _slicedToArray(_getColumnOrRowIndex3, 2),
119
- startIndex = _getColumnOrRowIndex4[0],
120
- endIndex = _getColumnOrRowIndex4[1];
121
-
102
+ _getColumnOrRowIndex4 = _slicedToArray(_getColumnOrRowIndex3, 2),
103
+ startIndex = _getColumnOrRowIndex4[0],
104
+ endIndex = _getColumnOrRowIndex4[1];
122
105
  var positionRow = getMousePositionVerticalRelativeByElement(mouseEvent) === 'bottom' ? endIndex : startIndex;
123
106
  return showInsertRowButton(positionRow)(state, dispatch);
124
107
  }
125
-
126
108
  if (isColumnControlsDecorations(target)) {
127
109
  var _getColumnOrRowIndex5 = getColumnOrRowIndex(target),
128
- _getColumnOrRowIndex6 = _slicedToArray(_getColumnOrRowIndex5, 1),
129
- _startIndex = _getColumnOrRowIndex6[0];
130
-
110
+ _getColumnOrRowIndex6 = _slicedToArray(_getColumnOrRowIndex5, 1),
111
+ _startIndex = _getColumnOrRowIndex6[0];
131
112
  var _state = view.state,
132
- _dispatch2 = view.dispatch;
113
+ _dispatch2 = view.dispatch;
133
114
  return hoverColumns([_startIndex], false)(_state, _dispatch2);
134
115
  }
135
-
136
116
  if ((isCell(target) || isCornerButton(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
137
117
  return hideInsertColumnOrRowButton()(state, dispatch);
138
118
  }
139
-
140
119
  if (isResizeHandleDecoration(target)) {
141
120
  var _getColumnOrRowIndex7 = getColumnOrRowIndex(target),
142
- _getColumnOrRowIndex8 = _slicedToArray(_getColumnOrRowIndex7, 2),
143
- _startIndex2 = _getColumnOrRowIndex8[0],
144
- _endIndex = _getColumnOrRowIndex8[1];
145
-
121
+ _getColumnOrRowIndex8 = _slicedToArray(_getColumnOrRowIndex7, 2),
122
+ _startIndex2 = _getColumnOrRowIndex8[0],
123
+ _endIndex = _getColumnOrRowIndex8[1];
146
124
  return showResizeHandleLine({
147
125
  left: _startIndex2,
148
126
  right: _endIndex
149
127
  })(state, dispatch);
150
128
  }
151
-
152
129
  return false;
153
- }; // Ignore any `mousedown` `event` from control and numbered column buttons
154
- // PM end up changing selection during shift selection if not prevented
130
+ };
155
131
 
132
+ // Ignore any `mousedown` `event` from control and numbered column buttons
133
+ // PM end up changing selection during shift selection if not prevented
156
134
  export var handleMouseDown = function handleMouseDown(_, event) {
157
135
  var isControl = !!(event.target && event.target instanceof HTMLElement && (isTableContainerOrWrapper(event.target) || isColumnControlsDecorations(event.target) || isRowControlsButton(event.target)));
158
-
159
136
  if (isControl) {
160
137
  event.preventDefault();
161
138
  }
162
-
163
139
  return isControl;
164
140
  };
165
141
  export var handleMouseOut = function handleMouseOut(view, mouseEvent) {
166
142
  if (!(mouseEvent instanceof MouseEvent) || !(mouseEvent.target instanceof HTMLElement)) {
167
143
  return false;
168
144
  }
169
-
170
145
  var target = mouseEvent.target;
171
-
172
146
  if (isColumnControlsDecorations(target)) {
173
147
  var state = view.state,
174
- dispatch = view.dispatch;
148
+ dispatch = view.dispatch;
175
149
  return clearHoverSelection()(state, dispatch);
176
150
  }
177
-
178
- var relatedTarget = mouseEvent.relatedTarget; // In case the user is moving between cell at the same column
151
+ var relatedTarget = mouseEvent.relatedTarget;
152
+ // In case the user is moving between cell at the same column
179
153
  // we don't need to hide the resize handle decoration
180
-
181
154
  if (isResizeHandleDecoration(target) && !isResizeHandleDecoration(relatedTarget)) {
182
155
  var _state2 = view.state,
183
- _dispatch3 = view.dispatch;
156
+ _dispatch3 = view.dispatch;
184
157
  return hideResizeHandleLine()(_state2, _dispatch3);
185
158
  }
186
-
187
159
  return false;
188
160
  };
189
161
  export var handleMouseLeave = function handleMouseLeave(view, event) {
190
162
  if (!(event.target instanceof HTMLElement)) {
191
163
  return false;
192
164
  }
193
-
194
165
  var state = view.state,
195
- dispatch = view.dispatch;
196
-
166
+ dispatch = view.dispatch;
197
167
  var _getPluginState2 = getPluginState(state),
198
- insertColumnButtonIndex = _getPluginState2.insertColumnButtonIndex,
199
- insertRowButtonIndex = _getPluginState2.insertRowButtonIndex;
200
-
168
+ insertColumnButtonIndex = _getPluginState2.insertColumnButtonIndex,
169
+ insertRowButtonIndex = _getPluginState2.insertRowButtonIndex;
201
170
  var target = event.target;
202
-
203
171
  if (isTableControlsButton(target)) {
204
172
  return true;
205
173
  }
206
-
207
174
  if ((typeof insertColumnButtonIndex !== 'undefined' || typeof insertRowButtonIndex !== 'undefined') && hideInsertColumnOrRowButton()(state, dispatch)) {
208
175
  return true;
209
176
  }
210
-
211
177
  return false;
212
178
  };
213
179
  export var handleMouseMove = function handleMouseMove(getEditorFeatureFlags) {
@@ -215,69 +181,51 @@ export var handleMouseMove = function handleMouseMove(getEditorFeatureFlags) {
215
181
  if (!(event.target instanceof HTMLElement)) {
216
182
  return false;
217
183
  }
218
-
219
184
  var element = event.target;
220
-
221
185
  if (isColumnControlsDecorations(element)) {
222
186
  var state = view.state,
223
- dispatch = view.dispatch;
224
-
187
+ dispatch = view.dispatch;
225
188
  var _getPluginState3 = getPluginState(state),
226
- insertColumnButtonIndex = _getPluginState3.insertColumnButtonIndex;
227
-
189
+ insertColumnButtonIndex = _getPluginState3.insertColumnButtonIndex;
228
190
  var _getColumnOrRowIndex9 = getColumnOrRowIndex(element),
229
- _getColumnOrRowIndex10 = _slicedToArray(_getColumnOrRowIndex9, 2),
230
- startIndex = _getColumnOrRowIndex10[0],
231
- endIndex = _getColumnOrRowIndex10[1];
232
-
191
+ _getColumnOrRowIndex10 = _slicedToArray(_getColumnOrRowIndex9, 2),
192
+ startIndex = _getColumnOrRowIndex10[0],
193
+ endIndex = _getColumnOrRowIndex10[1];
233
194
  var positionColumn = getMousePositionHorizontalRelativeByElement(event, false, elementContentRects) === 'right' ? endIndex : startIndex;
234
-
235
195
  if (positionColumn !== insertColumnButtonIndex) {
236
196
  return showInsertColumnButton(positionColumn)(state, dispatch);
237
197
  }
238
198
  }
239
-
240
199
  if (isRowControlsButton(element)) {
241
200
  var _state3 = view.state,
242
- _dispatch4 = view.dispatch;
243
-
201
+ _dispatch4 = view.dispatch;
244
202
  var _getPluginState4 = getPluginState(_state3),
245
- insertRowButtonIndex = _getPluginState4.insertRowButtonIndex;
246
-
203
+ insertRowButtonIndex = _getPluginState4.insertRowButtonIndex;
247
204
  var _getColumnOrRowIndex11 = getColumnOrRowIndex(element),
248
- _getColumnOrRowIndex12 = _slicedToArray(_getColumnOrRowIndex11, 2),
249
- _startIndex3 = _getColumnOrRowIndex12[0],
250
- _endIndex2 = _getColumnOrRowIndex12[1];
251
-
205
+ _getColumnOrRowIndex12 = _slicedToArray(_getColumnOrRowIndex11, 2),
206
+ _startIndex3 = _getColumnOrRowIndex12[0],
207
+ _endIndex2 = _getColumnOrRowIndex12[1];
252
208
  var positionRow = getMousePositionVerticalRelativeByElement(event) === 'bottom' ? _endIndex2 : _startIndex3;
253
-
254
209
  if (positionRow !== insertRowButtonIndex) {
255
210
  return showInsertRowButton(positionRow)(_state3, _dispatch4);
256
211
  }
257
212
  }
258
-
259
213
  var _getEditorFeatureFlag = getEditorFeatureFlags(),
260
- mouseMoveOptimization = _getEditorFeatureFlag.mouseMoveOptimization;
261
-
214
+ mouseMoveOptimization = _getEditorFeatureFlag.mouseMoveOptimization;
262
215
  if (!isResizeHandleDecoration(element) && isCell(element)) {
263
216
  var positionColumn = getMousePositionHorizontalRelativeByElement(event, mouseMoveOptimization, elementContentRects, RESIZE_HANDLE_AREA_DECORATION_GAP);
264
-
265
217
  if (positionColumn !== null) {
266
218
  var _state4 = view.state,
267
- _dispatch5 = view.dispatch;
268
-
219
+ _dispatch5 = view.dispatch;
269
220
  var _getPluginState5 = getPluginState(_state4),
270
- resizeHandleColumnIndex = _getPluginState5.resizeHandleColumnIndex,
271
- resizeHandleRowIndex = _getPluginState5.resizeHandleRowIndex;
272
-
221
+ resizeHandleColumnIndex = _getPluginState5.resizeHandleColumnIndex,
222
+ resizeHandleRowIndex = _getPluginState5.resizeHandleRowIndex;
273
223
  var tableCell = closestElement(element, 'td, th');
274
224
  var cellStartPosition = view.posAtDOM(tableCell, 0);
275
225
  var rect = findCellRectClosestToPos(_state4.doc.resolve(cellStartPosition));
276
-
277
226
  if (rect) {
278
227
  var columnEndIndexTarget = positionColumn === 'left' ? rect.left : rect.right;
279
228
  var rowIndexTarget = rect.top;
280
-
281
229
  if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !hasResizeHandler({
282
230
  target: element,
283
231
  columnEndIndexTarget: columnEndIndexTarget
@@ -287,55 +235,46 @@ export var handleMouseMove = function handleMouseMove(getEditorFeatureFlags) {
287
235
  }
288
236
  }
289
237
  }
290
-
291
238
  return false;
292
239
  };
293
240
  };
294
241
  export function handleTripleClick(view, pos) {
295
242
  var state = view.state,
296
- dispatch = view.dispatch;
243
+ dispatch = view.dispatch;
297
244
  var $cellPos = cellAround(state.doc.resolve(pos));
298
-
299
245
  if (!$cellPos) {
300
246
  return false;
301
247
  }
302
-
303
248
  var cell = state.doc.nodeAt($cellPos.pos);
304
-
305
249
  if (cell) {
306
250
  var selFrom = Selection.findFrom($cellPos, 1, true);
307
251
  var selTo = Selection.findFrom(state.doc.resolve($cellPos.pos + cell.nodeSize), -1, true);
308
-
309
252
  if (selFrom && selTo) {
310
253
  dispatch(state.tr.setSelection(new TextSelection(selFrom.$from, selTo.$to)));
311
254
  return true;
312
255
  }
313
256
  }
314
-
315
257
  return false;
316
258
  }
317
259
  export var handleCut = function handleCut(oldTr, oldState, newState, editorAnalyticsAPI) {
318
260
  var oldSelection = oldState.tr.selection;
319
261
  var tr = newState.tr;
320
-
321
262
  if (oldSelection instanceof CellSelection) {
322
263
  var $anchorCell = oldTr.doc.resolve(oldTr.mapping.map(oldSelection.$anchorCell.pos));
323
264
  var $headCell = oldTr.doc.resolve(oldTr.mapping.map(oldSelection.$headCell.pos));
324
265
  var cellSelection = new CellSelection($anchorCell, $headCell);
325
266
  tr.setSelection(cellSelection);
326
-
327
267
  if (tr.selection instanceof CellSelection) {
328
268
  var rect = getSelectionRect(cellSelection);
329
-
330
269
  if (rect) {
331
270
  var _getSelectedCellInfo = getSelectedCellInfo(tr.selection),
332
- verticalCells = _getSelectedCellInfo.verticalCells,
333
- horizontalCells = _getSelectedCellInfo.horizontalCells,
334
- totalCells = _getSelectedCellInfo.totalCells,
335
- totalRowCount = _getSelectedCellInfo.totalRowCount,
336
- totalColumnCount = _getSelectedCellInfo.totalColumnCount; // Reassigning to make it more obvious and consistent
337
-
271
+ verticalCells = _getSelectedCellInfo.verticalCells,
272
+ horizontalCells = _getSelectedCellInfo.horizontalCells,
273
+ totalCells = _getSelectedCellInfo.totalCells,
274
+ totalRowCount = _getSelectedCellInfo.totalRowCount,
275
+ totalColumnCount = _getSelectedCellInfo.totalColumnCount;
338
276
 
277
+ // Reassigning to make it more obvious and consistent
339
278
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
340
279
  action: TABLE_ACTION.CUT,
341
280
  actionSubject: ACTION_SUBJECT.TABLE,
@@ -348,17 +287,16 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
348
287
  totalColumnCount: totalColumnCount
349
288
  },
350
289
  eventType: EVENT_TYPE.TRACK
351
- })(tr); // Need this check again since we are overriding the tr in previous statement
290
+ })(tr);
352
291
 
292
+ // Need this check again since we are overriding the tr in previous statement
353
293
  if (tr.selection instanceof CellSelection) {
354
294
  var isTableSelected = tr.selection.isRowSelection() && tr.selection.isColSelection();
355
-
356
295
  if (isTableSelected) {
357
296
  tr = removeTable(tr);
358
297
  } else if (tr.selection.isRowSelection()) {
359
298
  var _getPluginState6 = getPluginState(newState),
360
- isHeaderRowRequired = _getPluginState6.pluginConfig.isHeaderRowRequired;
361
-
299
+ isHeaderRowRequired = _getPluginState6.pluginConfig.isHeaderRowRequired;
362
300
  tr = deleteRows(rect, isHeaderRowRequired)(tr);
363
301
  } else if (tr.selection.isColSelection()) {
364
302
  tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState))(tr);
@@ -367,7 +305,6 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
367
305
  }
368
306
  }
369
307
  }
370
-
371
308
  return tr;
372
309
  };
373
310
  export var whenTableInFocus = function whenTableInFocus(eventHandler, elementContentRects) {
@@ -376,11 +313,9 @@ export var whenTableInFocus = function whenTableInFocus(eventHandler, elementCon
376
313
  var tablePluginState = getPluginState(view.state);
377
314
  var isDragging = tableResizePluginState && !!tableResizePluginState.dragging;
378
315
  var hasTableNode = tablePluginState && tablePluginState.tableNode;
379
-
380
316
  if (!hasTableNode || isDragging) {
381
317
  return false;
382
318
  }
383
-
384
319
  return eventHandler(view, mouseEvent, elementContentRects);
385
320
  };
386
321
  };
@@ -1,10 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
4
  // #region Imports
5
+
8
6
  import { findParentNodeOfType } from 'prosemirror-utils';
9
7
  import { findTable } from '@atlaskit/editor-tables/utils';
10
8
  import { isTextInput } from '@atlaskit/editor-common/utils';
@@ -14,60 +12,49 @@ import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing
14
12
  import { TableSortStep } from '@atlaskit/adf-schema/steps';
15
13
  // #endregion
16
14
  import { checkIfNumberColumnEnabled, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled } from './utils/nodes';
17
-
18
15
  var nextTableSorting = function nextTableSorting(tr, table) {
19
16
  var tableSortStep = tr.steps.find(function (step) {
20
17
  return step instanceof TableSortStep;
21
18
  });
22
19
  return tableSortStep && table && table.pos === tableSortStep.pos ? tableSortStep.next : undefined;
23
20
  };
24
-
25
21
  var nextResizeHandleColumnIndex = function nextResizeHandleColumnIndex(tr, resizeHandleColumnIndex) {
26
22
  if (tr.getMeta(tableResizingPluginKey)) {
27
23
  return undefined;
28
24
  }
29
-
30
25
  return resizeHandleColumnIndex;
31
26
  };
32
-
33
27
  var updateTargetCellPosition = function updateTargetCellPosition(_ref) {
34
28
  var tr = _ref.tr,
35
- table = _ref.table;
29
+ table = _ref.table;
36
30
  return function (pluginState) {
37
31
  var tableNode = table && table.node;
38
-
39
32
  if (!tableNode) {
40
33
  return _objectSpread(_objectSpread({}, pluginState), {}, {
41
34
  targetCellPosition: undefined
42
35
  });
43
36
  }
44
-
45
37
  var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
46
- tableCell = _tr$doc$type$schema$n.tableCell,
47
- tableHeader = _tr$doc$type$schema$n.tableHeader;
38
+ tableCell = _tr$doc$type$schema$n.tableCell,
39
+ tableHeader = _tr$doc$type$schema$n.tableHeader;
48
40
  var cell = findParentNodeOfType([tableCell, tableHeader])(tr.selection);
49
41
  var targetCellPosition = cell ? cell.pos : undefined;
50
-
51
42
  if (pluginState.targetCellPosition === targetCellPosition) {
52
43
  return pluginState;
53
44
  }
54
-
55
45
  return _objectSpread(_objectSpread({}, pluginState), {}, {
56
46
  targetCellPosition: targetCellPosition
57
47
  });
58
48
  };
59
49
  };
60
-
61
50
  var updateTableNodePluginState = function updateTableNodePluginState(_ref2) {
62
51
  var tr = _ref2.tr,
63
- table = _ref2.table;
52
+ table = _ref2.table;
64
53
  return function (pluginState) {
65
54
  var tableNode = table && table.node;
66
-
67
55
  if (!tableNode || isTextInput(tr)) {
68
56
  return pluginState;
69
57
  }
70
-
71
58
  return _objectSpread(_objectSpread(_objectSpread({}, pluginState), defaultTableSelection), {}, {
72
59
  tableNode: tableNode,
73
60
  ordering: nextTableSorting(tr, table),
@@ -78,43 +65,40 @@ var updateTableNodePluginState = function updateTableNodePluginState(_ref2) {
78
65
  });
79
66
  };
80
67
  };
81
-
82
68
  var updateCollapseHandler = function updateCollapseHandler(_ref3) {
83
69
  var tr = _ref3.tr,
84
- table = _ref3.table;
70
+ table = _ref3.table;
85
71
  return function (pluginState) {
86
72
  var tableNode = table && table.node;
87
73
  var schema = tr.doc.type.schema;
88
74
  var allowCollapse = pluginState.pluginConfig.allowCollapse;
89
75
  var isExpandInSchema = schema.nodes.expand !== undefined;
90
76
  var isCollapseEnabled = allowCollapse && isExpandInSchema;
77
+
91
78
  /**
92
79
  * If we don't have focus, or collapse isn't allowed, or a table node doesn't
93
80
  * exist, we don't need to waste extra checks below
94
81
  */
95
-
96
82
  if (!pluginState.editorHasFocus || !isCollapseEnabled || !tableNode) {
97
83
  return pluginState;
98
84
  }
99
-
100
85
  var expandNodeType = schema.nodes.expand;
101
86
  var isTableCollapsed = expandNodeType && !!findParentNodeOfType(expandNodeType)(tr.selection);
102
- var trCanBeCollapsed = isTableCollapsible(tr).tableIsCollapsible; // We're focused on a table + we're not inside an expand
87
+ var trCanBeCollapsed = isTableCollapsible(tr).tableIsCollapsible;
103
88
 
104
- var canCollapseTable = !!pluginState.tableNode && // is it already collapsed?
89
+ // We're focused on a table + we're not inside an expand
90
+ var canCollapseTable = !!pluginState.tableNode &&
91
+ // is it already collapsed?
105
92
  !isTableCollapsed && !!trCanBeCollapsed;
106
-
107
93
  if (pluginState.isTableCollapsed !== isTableCollapsed || pluginState.canCollapseTable !== canCollapseTable) {
108
94
  return _objectSpread(_objectSpread({}, pluginState), {}, {
109
95
  isTableCollapsed: isTableCollapsed,
110
96
  canCollapseTable: canCollapseTable
111
97
  });
112
98
  }
113
-
114
99
  return pluginState;
115
100
  };
116
101
  };
117
-
118
102
  var buildPluginState = function buildPluginState(builders) {
119
103
  return function (props) {
120
104
  return function (pluginState) {
@@ -123,14 +107,12 @@ var buildPluginState = function buildPluginState(builders) {
123
107
  targetCellPosition: undefined
124
108
  }) : pluginState;
125
109
  }
126
-
127
110
  return builders.reduce(function (_pluginState, transform) {
128
111
  return transform(props)(_pluginState);
129
112
  }, pluginState);
130
113
  };
131
114
  };
132
115
  };
133
-
134
116
  export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr, pluginState) {
135
117
  return buildPluginState([updateTargetCellPosition, updateTableNodePluginState, updateCollapseHandler])({
136
118
  tr: tr,