@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
@@ -1,327 +1,245 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.handleMouseOver = exports.handleMouseOut = exports.handleMouseMove = exports.handleMouseLeave = exports.handleMouseDown = exports.handleFocus = exports.handleCut = exports.handleClick = exports.handleBlur = void 0;
9
8
  exports.handleTripleClick = handleTripleClick;
10
9
  exports.whenTableInFocus = void 0;
11
-
12
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
11
  var _prosemirrorState = require("prosemirror-state");
15
-
16
12
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
17
-
18
13
  var _tableMap = require("@atlaskit/editor-tables/table-map");
19
-
20
14
  var _utils = require("@atlaskit/editor-tables/utils");
21
-
22
15
  var _utils2 = require("@atlaskit/editor-common/utils");
23
-
24
16
  var _analytics = require("@atlaskit/editor-common/analytics");
25
-
26
17
  var _commands = require("./commands");
27
-
28
18
  var _pluginFactory = require("./pm-plugins/plugin-factory");
29
-
30
19
  var _pluginFactory2 = require("./pm-plugins/table-resizing/plugin-factory");
31
-
32
20
  var _transforms = require("./transforms");
33
-
34
21
  var _types = require("./types");
35
-
36
22
  var _utils3 = require("./utils");
37
-
38
23
  var _getAllowAddColumnCustomStep = require("./utils/get-allow-add-column-custom-step");
39
-
40
24
  var isFocusingCalendar = function isFocusingCalendar(event) {
41
25
  return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
42
26
  };
43
-
44
27
  var isFocusingModal = function isFocusingModal(event) {
45
28
  return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="dialog"]');
46
29
  };
47
-
48
30
  var isFocusingFloatingToolbar = function isFocusingFloatingToolbar(event) {
49
31
  return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="toolbar"]');
50
32
  };
51
-
52
33
  var handleBlur = function handleBlur(view, event) {
53
34
  var state = view.state,
54
- dispatch = view.dispatch; // IE version check for ED-4665
35
+ dispatch = view.dispatch;
36
+ // IE version check for ED-4665
55
37
  // Calendar focus check for ED-10466
56
-
57
38
  if (_utils2.browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event)) {
58
39
  (0, _commands.setEditorFocus)(false)(state, dispatch);
59
40
  }
60
-
61
41
  event.preventDefault();
62
42
  return false;
63
43
  };
64
-
65
44
  exports.handleBlur = handleBlur;
66
-
67
45
  var handleFocus = function handleFocus(view, event) {
68
46
  var state = view.state,
69
- dispatch = view.dispatch;
47
+ dispatch = view.dispatch;
70
48
  (0, _commands.setEditorFocus)(true)(state, dispatch);
71
49
  event.preventDefault();
72
50
  return false;
73
51
  };
74
-
75
52
  exports.handleFocus = handleFocus;
76
-
77
53
  var handleClick = function handleClick(view, event) {
78
54
  if (!(event.target instanceof HTMLElement)) {
79
55
  return false;
80
56
  }
81
-
82
57
  var element = event.target;
83
58
  var table = (0, _utils.findTable)(view.state.selection);
84
-
85
59
  if (event instanceof MouseEvent && (0, _utils3.isColumnControlsDecorations)(element)) {
86
60
  var _getColumnOrRowIndex = (0, _utils3.getColumnOrRowIndex)(element),
87
- _getColumnOrRowIndex2 = (0, _slicedToArray2.default)(_getColumnOrRowIndex, 1),
88
- startIndex = _getColumnOrRowIndex2[0];
89
-
61
+ _getColumnOrRowIndex2 = (0, _slicedToArray2.default)(_getColumnOrRowIndex, 1),
62
+ startIndex = _getColumnOrRowIndex2[0];
90
63
  var state = view.state,
91
- _dispatch = view.dispatch;
64
+ _dispatch = view.dispatch;
92
65
  return (0, _commands.selectColumn)(startIndex, event.shiftKey)(state, _dispatch);
93
66
  }
67
+ var matchfn = element.matches ? element.matches : element.msMatchesSelector;
94
68
 
95
- var matchfn = element.matches ? element.matches : element.msMatchesSelector; // check if the table cell with an image is clicked and its not the image itself
96
-
69
+ // check if the table cell with an image is clicked and its not the image itself
97
70
  if (!table || !(0, _utils2.isElementInTableCell)(element) || !matchfn || matchfn.call(element, 'table .image, table p, table .image div')) {
98
71
  return false;
99
72
  }
100
-
101
73
  var map = _tableMap.TableMap.get(table.node);
102
- /** Getting the offset of current item clicked */
103
-
104
74
 
75
+ /** Getting the offset of current item clicked */
105
76
  var colElement = (0, _utils2.closestElement)(element, 'td') || (0, _utils2.closestElement)(element, 'th');
106
77
  var colIndex = colElement && colElement.cellIndex;
107
78
  var rowElement = (0, _utils2.closestElement)(element, 'tr');
108
79
  var rowIndex = rowElement && rowElement.rowIndex;
109
80
  var cellIndex = map.width * rowIndex + colIndex;
110
81
  var dispatch = view.dispatch,
111
- _view$state = view.state,
112
- tr = _view$state.tr,
113
- paragraph = _view$state.schema.nodes.paragraph;
82
+ _view$state = view.state,
83
+ tr = _view$state.tr,
84
+ paragraph = _view$state.schema.nodes.paragraph;
114
85
  var cellPos = map.map[cellIndex];
115
-
116
86
  if (isNaN(cellPos) || cellPos === undefined || typeof cellPos !== 'number') {
117
87
  return false;
118
88
  }
119
-
120
89
  var editorElement = table.node.nodeAt(cellPos);
121
90
  /** Only if the last item is media group, insert a paragraph */
122
-
123
91
  if ((0, _utils2.isLastItemMediaGroup)(editorElement)) {
124
92
  var posInTable = map.map[cellIndex] + editorElement.nodeSize;
125
93
  tr.insert(posInTable + table.pos, paragraph.create());
126
94
  dispatch(tr);
127
95
  (0, _utils2.setNodeSelection)(view, posInTable + table.pos);
128
96
  }
129
-
130
97
  return true;
131
98
  };
132
-
133
99
  exports.handleClick = handleClick;
134
-
135
100
  var handleMouseOver = function handleMouseOver(view, mouseEvent) {
136
101
  if (!(mouseEvent.target instanceof HTMLElement)) {
137
102
  return false;
138
103
  }
139
-
140
104
  var state = view.state,
141
- dispatch = view.dispatch;
105
+ dispatch = view.dispatch;
142
106
  var target = mouseEvent.target;
143
-
144
107
  var _getPluginState = (0, _pluginFactory.getPluginState)(state),
145
- insertColumnButtonIndex = _getPluginState.insertColumnButtonIndex,
146
- insertRowButtonIndex = _getPluginState.insertRowButtonIndex;
147
-
108
+ insertColumnButtonIndex = _getPluginState.insertColumnButtonIndex,
109
+ insertRowButtonIndex = _getPluginState.insertRowButtonIndex;
148
110
  if ((0, _utils3.isInsertRowButton)(target)) {
149
111
  var _getColumnOrRowIndex3 = (0, _utils3.getColumnOrRowIndex)(target),
150
- _getColumnOrRowIndex4 = (0, _slicedToArray2.default)(_getColumnOrRowIndex3, 2),
151
- startIndex = _getColumnOrRowIndex4[0],
152
- endIndex = _getColumnOrRowIndex4[1];
153
-
112
+ _getColumnOrRowIndex4 = (0, _slicedToArray2.default)(_getColumnOrRowIndex3, 2),
113
+ startIndex = _getColumnOrRowIndex4[0],
114
+ endIndex = _getColumnOrRowIndex4[1];
154
115
  var positionRow = (0, _utils3.getMousePositionVerticalRelativeByElement)(mouseEvent) === 'bottom' ? endIndex : startIndex;
155
116
  return (0, _commands.showInsertRowButton)(positionRow)(state, dispatch);
156
117
  }
157
-
158
118
  if ((0, _utils3.isColumnControlsDecorations)(target)) {
159
119
  var _getColumnOrRowIndex5 = (0, _utils3.getColumnOrRowIndex)(target),
160
- _getColumnOrRowIndex6 = (0, _slicedToArray2.default)(_getColumnOrRowIndex5, 1),
161
- _startIndex = _getColumnOrRowIndex6[0];
162
-
120
+ _getColumnOrRowIndex6 = (0, _slicedToArray2.default)(_getColumnOrRowIndex5, 1),
121
+ _startIndex = _getColumnOrRowIndex6[0];
163
122
  var _state = view.state,
164
- _dispatch2 = view.dispatch;
123
+ _dispatch2 = view.dispatch;
165
124
  return (0, _commands.hoverColumns)([_startIndex], false)(_state, _dispatch2);
166
125
  }
167
-
168
126
  if (((0, _utils3.isCell)(target) || (0, _utils3.isCornerButton)(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
169
127
  return (0, _commands.hideInsertColumnOrRowButton)()(state, dispatch);
170
128
  }
171
-
172
129
  if ((0, _utils3.isResizeHandleDecoration)(target)) {
173
130
  var _getColumnOrRowIndex7 = (0, _utils3.getColumnOrRowIndex)(target),
174
- _getColumnOrRowIndex8 = (0, _slicedToArray2.default)(_getColumnOrRowIndex7, 2),
175
- _startIndex2 = _getColumnOrRowIndex8[0],
176
- _endIndex = _getColumnOrRowIndex8[1];
177
-
131
+ _getColumnOrRowIndex8 = (0, _slicedToArray2.default)(_getColumnOrRowIndex7, 2),
132
+ _startIndex2 = _getColumnOrRowIndex8[0],
133
+ _endIndex = _getColumnOrRowIndex8[1];
178
134
  return (0, _commands.showResizeHandleLine)({
179
135
  left: _startIndex2,
180
136
  right: _endIndex
181
137
  })(state, dispatch);
182
138
  }
183
-
184
139
  return false;
185
- }; // Ignore any `mousedown` `event` from control and numbered column buttons
186
- // PM end up changing selection during shift selection if not prevented
187
-
140
+ };
188
141
 
142
+ // Ignore any `mousedown` `event` from control and numbered column buttons
143
+ // PM end up changing selection during shift selection if not prevented
189
144
  exports.handleMouseOver = handleMouseOver;
190
-
191
145
  var handleMouseDown = function handleMouseDown(_, event) {
192
146
  var isControl = !!(event.target && event.target instanceof HTMLElement && ((0, _utils3.isTableContainerOrWrapper)(event.target) || (0, _utils3.isColumnControlsDecorations)(event.target) || (0, _utils3.isRowControlsButton)(event.target)));
193
-
194
147
  if (isControl) {
195
148
  event.preventDefault();
196
149
  }
197
-
198
150
  return isControl;
199
151
  };
200
-
201
152
  exports.handleMouseDown = handleMouseDown;
202
-
203
153
  var handleMouseOut = function handleMouseOut(view, mouseEvent) {
204
154
  if (!(mouseEvent instanceof MouseEvent) || !(mouseEvent.target instanceof HTMLElement)) {
205
155
  return false;
206
156
  }
207
-
208
157
  var target = mouseEvent.target;
209
-
210
158
  if ((0, _utils3.isColumnControlsDecorations)(target)) {
211
159
  var state = view.state,
212
- dispatch = view.dispatch;
160
+ dispatch = view.dispatch;
213
161
  return (0, _commands.clearHoverSelection)()(state, dispatch);
214
162
  }
215
-
216
- var relatedTarget = mouseEvent.relatedTarget; // In case the user is moving between cell at the same column
163
+ var relatedTarget = mouseEvent.relatedTarget;
164
+ // In case the user is moving between cell at the same column
217
165
  // we don't need to hide the resize handle decoration
218
-
219
166
  if ((0, _utils3.isResizeHandleDecoration)(target) && !(0, _utils3.isResizeHandleDecoration)(relatedTarget)) {
220
167
  var _state2 = view.state,
221
- _dispatch3 = view.dispatch;
168
+ _dispatch3 = view.dispatch;
222
169
  return (0, _commands.hideResizeHandleLine)()(_state2, _dispatch3);
223
170
  }
224
-
225
171
  return false;
226
172
  };
227
-
228
173
  exports.handleMouseOut = handleMouseOut;
229
-
230
174
  var handleMouseLeave = function handleMouseLeave(view, event) {
231
175
  if (!(event.target instanceof HTMLElement)) {
232
176
  return false;
233
177
  }
234
-
235
178
  var state = view.state,
236
- dispatch = view.dispatch;
237
-
179
+ dispatch = view.dispatch;
238
180
  var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
239
- insertColumnButtonIndex = _getPluginState2.insertColumnButtonIndex,
240
- insertRowButtonIndex = _getPluginState2.insertRowButtonIndex;
241
-
181
+ insertColumnButtonIndex = _getPluginState2.insertColumnButtonIndex,
182
+ insertRowButtonIndex = _getPluginState2.insertRowButtonIndex;
242
183
  var target = event.target;
243
-
244
184
  if ((0, _utils3.isTableControlsButton)(target)) {
245
185
  return true;
246
186
  }
247
-
248
187
  if ((typeof insertColumnButtonIndex !== 'undefined' || typeof insertRowButtonIndex !== 'undefined') && (0, _commands.hideInsertColumnOrRowButton)()(state, dispatch)) {
249
188
  return true;
250
189
  }
251
-
252
190
  return false;
253
191
  };
254
-
255
192
  exports.handleMouseLeave = handleMouseLeave;
256
-
257
193
  var handleMouseMove = function handleMouseMove(getEditorFeatureFlags) {
258
194
  return function (view, event, elementContentRects) {
259
195
  if (!(event.target instanceof HTMLElement)) {
260
196
  return false;
261
197
  }
262
-
263
198
  var element = event.target;
264
-
265
199
  if ((0, _utils3.isColumnControlsDecorations)(element)) {
266
200
  var state = view.state,
267
- dispatch = view.dispatch;
268
-
201
+ dispatch = view.dispatch;
269
202
  var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
270
- insertColumnButtonIndex = _getPluginState3.insertColumnButtonIndex;
271
-
203
+ insertColumnButtonIndex = _getPluginState3.insertColumnButtonIndex;
272
204
  var _getColumnOrRowIndex9 = (0, _utils3.getColumnOrRowIndex)(element),
273
- _getColumnOrRowIndex10 = (0, _slicedToArray2.default)(_getColumnOrRowIndex9, 2),
274
- startIndex = _getColumnOrRowIndex10[0],
275
- endIndex = _getColumnOrRowIndex10[1];
276
-
205
+ _getColumnOrRowIndex10 = (0, _slicedToArray2.default)(_getColumnOrRowIndex9, 2),
206
+ startIndex = _getColumnOrRowIndex10[0],
207
+ endIndex = _getColumnOrRowIndex10[1];
277
208
  var positionColumn = (0, _utils3.getMousePositionHorizontalRelativeByElement)(event, false, elementContentRects) === 'right' ? endIndex : startIndex;
278
-
279
209
  if (positionColumn !== insertColumnButtonIndex) {
280
210
  return (0, _commands.showInsertColumnButton)(positionColumn)(state, dispatch);
281
211
  }
282
212
  }
283
-
284
213
  if ((0, _utils3.isRowControlsButton)(element)) {
285
214
  var _state3 = view.state,
286
- _dispatch4 = view.dispatch;
287
-
215
+ _dispatch4 = view.dispatch;
288
216
  var _getPluginState4 = (0, _pluginFactory.getPluginState)(_state3),
289
- insertRowButtonIndex = _getPluginState4.insertRowButtonIndex;
290
-
217
+ insertRowButtonIndex = _getPluginState4.insertRowButtonIndex;
291
218
  var _getColumnOrRowIndex11 = (0, _utils3.getColumnOrRowIndex)(element),
292
- _getColumnOrRowIndex12 = (0, _slicedToArray2.default)(_getColumnOrRowIndex11, 2),
293
- _startIndex3 = _getColumnOrRowIndex12[0],
294
- _endIndex2 = _getColumnOrRowIndex12[1];
295
-
219
+ _getColumnOrRowIndex12 = (0, _slicedToArray2.default)(_getColumnOrRowIndex11, 2),
220
+ _startIndex3 = _getColumnOrRowIndex12[0],
221
+ _endIndex2 = _getColumnOrRowIndex12[1];
296
222
  var positionRow = (0, _utils3.getMousePositionVerticalRelativeByElement)(event) === 'bottom' ? _endIndex2 : _startIndex3;
297
-
298
223
  if (positionRow !== insertRowButtonIndex) {
299
224
  return (0, _commands.showInsertRowButton)(positionRow)(_state3, _dispatch4);
300
225
  }
301
226
  }
302
-
303
227
  var _getEditorFeatureFlag = getEditorFeatureFlags(),
304
- mouseMoveOptimization = _getEditorFeatureFlag.mouseMoveOptimization;
305
-
228
+ mouseMoveOptimization = _getEditorFeatureFlag.mouseMoveOptimization;
306
229
  if (!(0, _utils3.isResizeHandleDecoration)(element) && (0, _utils3.isCell)(element)) {
307
230
  var positionColumn = (0, _utils3.getMousePositionHorizontalRelativeByElement)(event, mouseMoveOptimization, elementContentRects, _types.RESIZE_HANDLE_AREA_DECORATION_GAP);
308
-
309
231
  if (positionColumn !== null) {
310
232
  var _state4 = view.state,
311
- _dispatch5 = view.dispatch;
312
-
233
+ _dispatch5 = view.dispatch;
313
234
  var _getPluginState5 = (0, _pluginFactory.getPluginState)(_state4),
314
- resizeHandleColumnIndex = _getPluginState5.resizeHandleColumnIndex,
315
- resizeHandleRowIndex = _getPluginState5.resizeHandleRowIndex;
316
-
235
+ resizeHandleColumnIndex = _getPluginState5.resizeHandleColumnIndex,
236
+ resizeHandleRowIndex = _getPluginState5.resizeHandleRowIndex;
317
237
  var tableCell = (0, _utils2.closestElement)(element, 'td, th');
318
238
  var cellStartPosition = view.posAtDOM(tableCell, 0);
319
239
  var rect = (0, _utils.findCellRectClosestToPos)(_state4.doc.resolve(cellStartPosition));
320
-
321
240
  if (rect) {
322
241
  var columnEndIndexTarget = positionColumn === 'left' ? rect.left : rect.right;
323
242
  var rowIndexTarget = rect.top;
324
-
325
243
  if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !(0, _utils3.hasResizeHandler)({
326
244
  target: element,
327
245
  columnEndIndexTarget: columnEndIndexTarget
@@ -331,60 +249,47 @@ var handleMouseMove = function handleMouseMove(getEditorFeatureFlags) {
331
249
  }
332
250
  }
333
251
  }
334
-
335
252
  return false;
336
253
  };
337
254
  };
338
-
339
255
  exports.handleMouseMove = handleMouseMove;
340
-
341
256
  function handleTripleClick(view, pos) {
342
257
  var state = view.state,
343
- dispatch = view.dispatch;
258
+ dispatch = view.dispatch;
344
259
  var $cellPos = (0, _utils.cellAround)(state.doc.resolve(pos));
345
-
346
260
  if (!$cellPos) {
347
261
  return false;
348
262
  }
349
-
350
263
  var cell = state.doc.nodeAt($cellPos.pos);
351
-
352
264
  if (cell) {
353
265
  var selFrom = _prosemirrorState.Selection.findFrom($cellPos, 1, true);
354
-
355
266
  var selTo = _prosemirrorState.Selection.findFrom(state.doc.resolve($cellPos.pos + cell.nodeSize), -1, true);
356
-
357
267
  if (selFrom && selTo) {
358
268
  dispatch(state.tr.setSelection(new _prosemirrorState.TextSelection(selFrom.$from, selTo.$to)));
359
269
  return true;
360
270
  }
361
271
  }
362
-
363
272
  return false;
364
273
  }
365
-
366
274
  var handleCut = function handleCut(oldTr, oldState, newState, editorAnalyticsAPI) {
367
275
  var oldSelection = oldState.tr.selection;
368
276
  var tr = newState.tr;
369
-
370
277
  if (oldSelection instanceof _cellSelection.CellSelection) {
371
278
  var $anchorCell = oldTr.doc.resolve(oldTr.mapping.map(oldSelection.$anchorCell.pos));
372
279
  var $headCell = oldTr.doc.resolve(oldTr.mapping.map(oldSelection.$headCell.pos));
373
280
  var cellSelection = new _cellSelection.CellSelection($anchorCell, $headCell);
374
281
  tr.setSelection(cellSelection);
375
-
376
282
  if (tr.selection instanceof _cellSelection.CellSelection) {
377
283
  var rect = (0, _utils.getSelectionRect)(cellSelection);
378
-
379
284
  if (rect) {
380
285
  var _getSelectedCellInfo = (0, _utils3.getSelectedCellInfo)(tr.selection),
381
- verticalCells = _getSelectedCellInfo.verticalCells,
382
- horizontalCells = _getSelectedCellInfo.horizontalCells,
383
- totalCells = _getSelectedCellInfo.totalCells,
384
- totalRowCount = _getSelectedCellInfo.totalRowCount,
385
- totalColumnCount = _getSelectedCellInfo.totalColumnCount; // Reassigning to make it more obvious and consistent
386
-
286
+ verticalCells = _getSelectedCellInfo.verticalCells,
287
+ horizontalCells = _getSelectedCellInfo.horizontalCells,
288
+ totalCells = _getSelectedCellInfo.totalCells,
289
+ totalRowCount = _getSelectedCellInfo.totalRowCount,
290
+ totalColumnCount = _getSelectedCellInfo.totalColumnCount;
387
291
 
292
+ // Reassigning to make it more obvious and consistent
388
293
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
389
294
  action: _analytics.TABLE_ACTION.CUT,
390
295
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
@@ -397,17 +302,16 @@ var handleCut = function handleCut(oldTr, oldState, newState, editorAnalyticsAPI
397
302
  totalColumnCount: totalColumnCount
398
303
  },
399
304
  eventType: _analytics.EVENT_TYPE.TRACK
400
- })(tr); // Need this check again since we are overriding the tr in previous statement
305
+ })(tr);
401
306
 
307
+ // Need this check again since we are overriding the tr in previous statement
402
308
  if (tr.selection instanceof _cellSelection.CellSelection) {
403
309
  var isTableSelected = tr.selection.isRowSelection() && tr.selection.isColSelection();
404
-
405
310
  if (isTableSelected) {
406
311
  tr = (0, _utils.removeTable)(tr);
407
312
  } else if (tr.selection.isRowSelection()) {
408
313
  var _getPluginState6 = (0, _pluginFactory.getPluginState)(newState),
409
- isHeaderRowRequired = _getPluginState6.pluginConfig.isHeaderRowRequired;
410
-
314
+ isHeaderRowRequired = _getPluginState6.pluginConfig.isHeaderRowRequired;
411
315
  tr = (0, _transforms.deleteRows)(rect, isHeaderRowRequired)(tr);
412
316
  } else if (tr.selection.isColSelection()) {
413
317
  tr = (0, _transforms.deleteColumns)(rect, (0, _getAllowAddColumnCustomStep.getAllowAddColumnCustomStep)(oldState))(tr);
@@ -416,25 +320,19 @@ var handleCut = function handleCut(oldTr, oldState, newState, editorAnalyticsAPI
416
320
  }
417
321
  }
418
322
  }
419
-
420
323
  return tr;
421
324
  };
422
-
423
325
  exports.handleCut = handleCut;
424
-
425
326
  var whenTableInFocus = function whenTableInFocus(eventHandler, elementContentRects) {
426
327
  return function (view, mouseEvent) {
427
328
  var tableResizePluginState = (0, _pluginFactory2.getPluginState)(view.state);
428
329
  var tablePluginState = (0, _pluginFactory.getPluginState)(view.state);
429
330
  var isDragging = tableResizePluginState && !!tableResizePluginState.dragging;
430
331
  var hasTableNode = tablePluginState && tablePluginState.tableNode;
431
-
432
332
  if (!hasTableNode || isDragging) {
433
333
  return false;
434
334
  }
435
-
436
335
  return eventHandler(view, mouseEvent, elementContentRects);
437
336
  };
438
337
  };
439
-
440
338
  exports.whenTableInFocus = whenTableInFocus;
@@ -1,87 +1,64 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.handleDocOrSelectionChanged = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _prosemirrorUtils = require("prosemirror-utils");
13
-
14
10
  var _utils = require("@atlaskit/editor-tables/utils");
15
-
16
11
  var _utils2 = require("@atlaskit/editor-common/utils");
17
-
18
12
  var _collapse = require("./utils/collapse");
19
-
20
13
  var _defaultTableSelection = require("./pm-plugins/default-table-selection");
21
-
22
14
  var _tableResizing = require("./pm-plugins/table-resizing");
23
-
24
15
  var _steps = require("@atlaskit/adf-schema/steps");
25
-
26
16
  var _nodes = require("./utils/nodes");
27
-
28
17
  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; }
29
-
30
18
  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) { (0, _defineProperty2.default)(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; }
31
-
32
19
  var nextTableSorting = function nextTableSorting(tr, table) {
33
20
  var tableSortStep = tr.steps.find(function (step) {
34
21
  return step instanceof _steps.TableSortStep;
35
22
  });
36
23
  return tableSortStep && table && table.pos === tableSortStep.pos ? tableSortStep.next : undefined;
37
24
  };
38
-
39
25
  var nextResizeHandleColumnIndex = function nextResizeHandleColumnIndex(tr, resizeHandleColumnIndex) {
40
26
  if (tr.getMeta(_tableResizing.pluginKey)) {
41
27
  return undefined;
42
28
  }
43
-
44
29
  return resizeHandleColumnIndex;
45
30
  };
46
-
47
31
  var updateTargetCellPosition = function updateTargetCellPosition(_ref) {
48
32
  var tr = _ref.tr,
49
- table = _ref.table;
33
+ table = _ref.table;
50
34
  return function (pluginState) {
51
35
  var tableNode = table && table.node;
52
-
53
36
  if (!tableNode) {
54
37
  return _objectSpread(_objectSpread({}, pluginState), {}, {
55
38
  targetCellPosition: undefined
56
39
  });
57
40
  }
58
-
59
41
  var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
60
- tableCell = _tr$doc$type$schema$n.tableCell,
61
- tableHeader = _tr$doc$type$schema$n.tableHeader;
42
+ tableCell = _tr$doc$type$schema$n.tableCell,
43
+ tableHeader = _tr$doc$type$schema$n.tableHeader;
62
44
  var cell = (0, _prosemirrorUtils.findParentNodeOfType)([tableCell, tableHeader])(tr.selection);
63
45
  var targetCellPosition = cell ? cell.pos : undefined;
64
-
65
46
  if (pluginState.targetCellPosition === targetCellPosition) {
66
47
  return pluginState;
67
48
  }
68
-
69
49
  return _objectSpread(_objectSpread({}, pluginState), {}, {
70
50
  targetCellPosition: targetCellPosition
71
51
  });
72
52
  };
73
53
  };
74
-
75
54
  var updateTableNodePluginState = function updateTableNodePluginState(_ref2) {
76
55
  var tr = _ref2.tr,
77
- table = _ref2.table;
56
+ table = _ref2.table;
78
57
  return function (pluginState) {
79
58
  var tableNode = table && table.node;
80
-
81
59
  if (!tableNode || (0, _utils2.isTextInput)(tr)) {
82
60
  return pluginState;
83
61
  }
84
-
85
62
  return _objectSpread(_objectSpread(_objectSpread({}, pluginState), _defaultTableSelection.defaultTableSelection), {}, {
86
63
  tableNode: tableNode,
87
64
  ordering: nextTableSorting(tr, table),
@@ -92,43 +69,40 @@ var updateTableNodePluginState = function updateTableNodePluginState(_ref2) {
92
69
  });
93
70
  };
94
71
  };
95
-
96
72
  var updateCollapseHandler = function updateCollapseHandler(_ref3) {
97
73
  var tr = _ref3.tr,
98
- table = _ref3.table;
74
+ table = _ref3.table;
99
75
  return function (pluginState) {
100
76
  var tableNode = table && table.node;
101
77
  var schema = tr.doc.type.schema;
102
78
  var allowCollapse = pluginState.pluginConfig.allowCollapse;
103
79
  var isExpandInSchema = schema.nodes.expand !== undefined;
104
80
  var isCollapseEnabled = allowCollapse && isExpandInSchema;
81
+
105
82
  /**
106
83
  * If we don't have focus, or collapse isn't allowed, or a table node doesn't
107
84
  * exist, we don't need to waste extra checks below
108
85
  */
109
-
110
86
  if (!pluginState.editorHasFocus || !isCollapseEnabled || !tableNode) {
111
87
  return pluginState;
112
88
  }
113
-
114
89
  var expandNodeType = schema.nodes.expand;
115
90
  var isTableCollapsed = expandNodeType && !!(0, _prosemirrorUtils.findParentNodeOfType)(expandNodeType)(tr.selection);
116
- var trCanBeCollapsed = (0, _collapse.isTableCollapsible)(tr).tableIsCollapsible; // We're focused on a table + we're not inside an expand
91
+ var trCanBeCollapsed = (0, _collapse.isTableCollapsible)(tr).tableIsCollapsible;
117
92
 
118
- var canCollapseTable = !!pluginState.tableNode && // is it already collapsed?
93
+ // We're focused on a table + we're not inside an expand
94
+ var canCollapseTable = !!pluginState.tableNode &&
95
+ // is it already collapsed?
119
96
  !isTableCollapsed && !!trCanBeCollapsed;
120
-
121
97
  if (pluginState.isTableCollapsed !== isTableCollapsed || pluginState.canCollapseTable !== canCollapseTable) {
122
98
  return _objectSpread(_objectSpread({}, pluginState), {}, {
123
99
  isTableCollapsed: isTableCollapsed,
124
100
  canCollapseTable: canCollapseTable
125
101
  });
126
102
  }
127
-
128
103
  return pluginState;
129
104
  };
130
105
  };
131
-
132
106
  var buildPluginState = function buildPluginState(builders) {
133
107
  return function (props) {
134
108
  return function (pluginState) {
@@ -137,19 +111,16 @@ var buildPluginState = function buildPluginState(builders) {
137
111
  targetCellPosition: undefined
138
112
  }) : pluginState;
139
113
  }
140
-
141
114
  return builders.reduce(function (_pluginState, transform) {
142
115
  return transform(props)(_pluginState);
143
116
  }, pluginState);
144
117
  };
145
118
  };
146
119
  };
147
-
148
120
  var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr, pluginState) {
149
121
  return buildPluginState([updateTargetCellPosition, updateTableNodePluginState, updateCollapseHandler])({
150
122
  tr: tr,
151
123
  table: (0, _utils.findTable)(tr.selection)
152
124
  })(pluginState);
153
125
  };
154
-
155
126
  exports.handleDocOrSelectionChanged = handleDocOrSelectionChanged;