@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
@@ -6,15 +6,10 @@ import _inherits from "@babel/runtime/helpers/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
-
10
9
  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; }
11
-
12
10
  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; }
13
-
14
11
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
15
-
16
12
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
17
-
18
13
  import React, { Component } from 'react';
19
14
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
20
15
  import { getSelectionRect, isTableSelected } from '@atlaskit/editor-tables/utils';
@@ -37,102 +32,78 @@ export function getSelectionType(selection) {
37
32
  if (selection.isRowSelection()) {
38
33
  return 'row';
39
34
  }
40
-
41
35
  if (selection.isColSelection()) {
42
36
  return 'column';
43
37
  }
44
38
  }
45
-
46
39
  return;
47
40
  }
48
-
49
41
  var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
50
42
  _inherits(FloatingDeleteButton, _Component);
51
-
52
43
  var _super = _createSuper(FloatingDeleteButton);
53
-
54
44
  function FloatingDeleteButton(props) {
55
45
  var _this;
56
-
57
46
  _classCallCheck(this, FloatingDeleteButton);
58
-
59
47
  _this = _super.call(this, props);
60
-
61
48
  _defineProperty(_assertThisInitialized(_this), "wrapper", null);
62
-
63
49
  _defineProperty(_assertThisInitialized(_this), "updateWrapper", function () {
64
50
  var tableWrapper = closestElement(_this.props.tableRef, ".".concat(ClassName.TABLE_NODE_WRAPPER));
65
-
66
51
  if (tableWrapper) {
67
52
  _this.wrapper = tableWrapper;
68
-
69
53
  _this.wrapper.addEventListener('scroll', _this.onWrapperScrolled);
70
-
71
54
  _this.setState({
72
55
  scrollLeft: tableWrapper.scrollLeft
73
56
  });
74
57
  } else {
75
58
  if (_this.wrapper) {
76
59
  // unsubscribe if we previously had one and it just went away
77
- _this.wrapper.removeEventListener('scroll', _this.onWrapperScrolled); // and reset scroll position
78
-
60
+ _this.wrapper.removeEventListener('scroll', _this.onWrapperScrolled);
79
61
 
62
+ // and reset scroll position
80
63
  _this.setState({
81
64
  scrollLeft: 0
82
65
  });
83
66
  }
84
-
85
67
  _this.wrapper = null;
86
68
  }
87
69
  });
88
-
89
70
  _defineProperty(_assertThisInitialized(_this), "onWrapperScrolled", function (e) {
90
71
  var wrapper = e.target;
91
-
92
72
  _this.setState({
93
73
  scrollLeft: wrapper.scrollLeft
94
74
  });
95
75
  });
96
-
97
76
  _defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function () {
98
77
  var _this$props$editorVie = _this.props.editorView,
99
- state = _this$props$editorVie.state,
100
- dispatch = _this$props$editorVie.dispatch;
101
-
78
+ state = _this$props$editorVie.state,
79
+ dispatch = _this$props$editorVie.dispatch;
102
80
  switch (_this.state.selectionType) {
103
81
  case 'row':
104
82
  {
105
83
  return hoverRows(_this.state.indexes, true)(state, dispatch, _this.props.editorView);
106
84
  }
107
-
108
85
  case 'column':
109
86
  {
110
87
  return hoverColumns(_this.state.indexes, true)(state, dispatch, _this.props.editorView);
111
88
  }
112
89
  }
113
-
114
90
  return false;
115
91
  });
116
-
117
92
  _defineProperty(_assertThisInitialized(_this), "handleMouseLeave", function () {
118
93
  var _this$props$editorVie2 = _this.props.editorView,
119
- state = _this$props$editorVie2.state,
120
- dispatch = _this$props$editorVie2.dispatch;
94
+ state = _this$props$editorVie2.state,
95
+ dispatch = _this$props$editorVie2.dispatch;
121
96
  return clearHoverSelection()(state, dispatch);
122
97
  });
123
-
124
98
  _defineProperty(_assertThisInitialized(_this), "handleClick", function (event) {
125
99
  event.preventDefault();
126
100
  var editorAnalyticsAPI = _this.props.editorAnalyticsAPI;
127
101
  var _this$props$editorVie3 = _this.props.editorView,
128
- state = _this$props$editorVie3.state,
129
- dispatch = _this$props$editorVie3.dispatch;
130
-
102
+ state = _this$props$editorVie3.state,
103
+ dispatch = _this$props$editorVie3.dispatch;
131
104
  var _getTablePluginState = getTablePluginState(state),
132
- isHeaderRowRequired = _getTablePluginState.pluginConfig.isHeaderRowRequired;
133
-
105
+ isHeaderRowRequired = _getTablePluginState.pluginConfig.isHeaderRowRequired;
134
106
  var rect = getSelectionRect(state.selection);
135
-
136
107
  if (rect) {
137
108
  switch (_this.state.selectionType) {
138
109
  case 'column':
@@ -140,7 +111,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
140
111
  deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, rect)(state, dispatch);
141
112
  return;
142
113
  }
143
-
144
114
  case 'row':
145
115
  {
146
116
  deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, rect, !!isHeaderRowRequired)(state, dispatch);
@@ -148,13 +118,11 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
148
118
  }
149
119
  }
150
120
  }
151
-
152
121
  var _this$props$editorVie4 = _this.props.editorView;
153
122
  state = _this$props$editorVie4.state;
154
123
  dispatch = _this$props$editorVie4.dispatch;
155
124
  clearHoverSelection()(state, dispatch);
156
125
  });
157
-
158
126
  _this.state = {
159
127
  selectionType: undefined,
160
128
  top: 0,
@@ -164,7 +132,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
164
132
  };
165
133
  return _this;
166
134
  }
167
-
168
135
  _createClass(FloatingDeleteButton, [{
169
136
  key: "shouldComponentUpdate",
170
137
  value: function shouldComponentUpdate(_, nextState) {
@@ -191,15 +158,13 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
191
158
  key: "render",
192
159
  value: function render() {
193
160
  var _this$props = this.props,
194
- mountPoint = _this$props.mountPoint,
195
- boundariesElement = _this$props.boundariesElement,
196
- tableRef = _this$props.tableRef;
161
+ mountPoint = _this$props.mountPoint,
162
+ boundariesElement = _this$props.boundariesElement,
163
+ tableRef = _this$props.tableRef;
197
164
  var selectionType = this.state.selectionType;
198
-
199
165
  if (!selectionType || !tableRef) {
200
166
  return null;
201
167
  }
202
-
203
168
  var tableContainerWrapper = closestElement(tableRef, ".".concat(ClassName.TABLE_CONTAINER));
204
169
  var button = /*#__PURE__*/React.createElement(DeleteButton, {
205
170
  removeLabel: selectionType === 'column' ? tableMessages.removeColumns : tableMessages.removeRows,
@@ -214,17 +179,13 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
214
179
  tableWrapper: this.wrapper
215
180
  });
216
181
  var mountTo = tableContainerWrapper || mountPoint;
217
-
218
182
  if (this.state.position === 'sticky' && mountTo) {
219
183
  var headerRow = tableRef.querySelector('tr.sticky');
220
-
221
184
  if (headerRow) {
222
185
  var rect = headerRow.getBoundingClientRect();
223
-
224
186
  var calculatePosition = popupOpts.onPositionCalculated || function (pos) {
225
187
  return pos;
226
188
  };
227
-
228
189
  var pos = calculatePosition({
229
190
  left: this.state.left,
230
191
  top: this.state.top
@@ -239,7 +200,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
239
200
  }, button), mountTo);
240
201
  }
241
202
  }
242
-
243
203
  return /*#__PURE__*/React.createElement(Popup, _extends({
244
204
  target: tableRef,
245
205
  mountTo: mountTo,
@@ -260,14 +220,14 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
260
220
  function getDerivedStateFromProps(nextProps, prevState) {
261
221
  var selectionType = getSelectionType(nextProps.selection);
262
222
  var inStickyMode = nextProps.stickyHeaders && nextProps.stickyHeaders.sticky;
263
- var rect = getSelectionRect(nextProps.selection); // only tie row delete to sticky header if it's the only thing
223
+ var rect = getSelectionRect(nextProps.selection);
224
+
225
+ // only tie row delete to sticky header if it's the only thing
264
226
  // in the selection, otherwise the row delete will hover around
265
227
  // the rest of the selection
266
-
267
228
  var firstRowInSelection = rect && rect.top === 0 && rect.bottom === 1;
268
229
  var shouldStickyButton = inStickyMode && firstRowInSelection;
269
230
  var stickyTop = nextProps.stickyHeaders ? nextProps.stickyHeaders.top + nextProps.stickyHeaders.padding : 0;
270
-
271
231
  if (selectionType) {
272
232
  switch (selectionType) {
273
233
  case 'column':
@@ -275,7 +235,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
275
235
  // Calculate the button position and indexes for columns
276
236
  var columnsWidths = getColumnsWidths(nextProps.editorView);
277
237
  var deleteBtnParams = getColumnDeleteButtonParams(columnsWidths, nextProps.editorView.state.selection);
278
-
279
238
  if (deleteBtnParams) {
280
239
  return _objectSpread(_objectSpread({}, deleteBtnParams), {}, {
281
240
  top: inStickyMode ? nextProps.stickyHeaders.top : 0,
@@ -283,19 +242,15 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
283
242
  selectionType: selectionType
284
243
  });
285
244
  }
286
-
287
245
  return null;
288
246
  }
289
-
290
247
  case 'row':
291
248
  {
292
249
  // Calculate the button position and indexes for rows
293
250
  if (nextProps.tableRef) {
294
251
  var rowHeights = getRowHeights(nextProps.tableRef);
295
252
  var offsetTop = inStickyMode ? -rowHeights[0] : 0;
296
-
297
253
  var _deleteBtnParams = getRowDeleteButtonParams(rowHeights, nextProps.editorView.state.selection, shouldStickyButton ? stickyTop : offsetTop);
298
-
299
254
  if (_deleteBtnParams) {
300
255
  return _objectSpread(_objectSpread({}, _deleteBtnParams), {}, {
301
256
  position: shouldStickyButton ? 'sticky' : undefined,
@@ -304,13 +259,12 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
304
259
  });
305
260
  }
306
261
  }
307
-
308
262
  return null;
309
263
  }
310
264
  }
311
- } // Clean state if no type
312
-
265
+ }
313
266
 
267
+ // Clean state if no type
314
268
  if (prevState.selectionType !== selectionType) {
315
269
  return {
316
270
  selectionType: undefined,
@@ -318,16 +272,13 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
318
272
  left: 0,
319
273
  indexes: []
320
274
  };
321
- } // Do nothing if doesn't change anything
322
-
275
+ }
323
276
 
277
+ // Do nothing if doesn't change anything
324
278
  return null;
325
279
  }
326
280
  }]);
327
-
328
281
  return FloatingDeleteButton;
329
282
  }(Component);
330
-
331
283
  _defineProperty(FloatingDeleteButton, "displayName", 'FloatingDeleteButton');
332
-
333
284
  export default FloatingDeleteButton;
@@ -8,7 +8,6 @@ import { closestElement } from '@atlaskit/editor-common/utils';
8
8
  import { TableCssClassName as ClassName } from '../../types';
9
9
  import tableMessages from '../messages';
10
10
  import { tableToolbarSize } from '../consts';
11
-
12
11
  var getInsertLineHeight = function getInsertLineHeight(tableRef, hasStickyHeaders) {
13
12
  // The line gets height 100% from the table,
14
13
  // but since we have an overflow on the left,
@@ -17,42 +16,36 @@ var getInsertLineHeight = function getInsertLineHeight(tableRef, hasStickyHeader
17
16
  var ADDITIONAL_HEIGHT = hasStickyHeaders ? tableRef.getBoundingClientRect().top - tableMarginTop * 4 - LINE_OFFSET : tableToolbarSize + LINE_OFFSET;
18
17
  return tableRef.offsetHeight + ADDITIONAL_HEIGHT;
19
18
  };
20
-
21
19
  var getToolbarSize = function getToolbarSize(tableRef) {
22
20
  var parent = closestElement(tableRef, ".".concat(ClassName.TABLE_CONTAINER));
23
-
24
21
  if (parent) {
25
22
  return parent.querySelector(".".concat(ClassName.NUMBERED_COLUMN)) ? tableToolbarSize + akEditorTableNumberColumnWidth - 1 : tableToolbarSize;
26
23
  }
27
-
28
24
  return tableToolbarSize;
29
25
  };
30
-
31
26
  var getInsertLineWidth = function getInsertLineWidth(tableRef) {
32
27
  // The line gets width 100% from the table,
33
28
  // but since we have an overflow on the left,
34
29
  // we should add an offset to make up for it.
35
30
  var LINE_OFFSET = 4;
36
31
  var parentElement = tableRef.parentElement,
37
- offsetWidth = tableRef.offsetWidth;
32
+ offsetWidth = tableRef.offsetWidth;
38
33
  var parentOffsetWidth = parentElement.offsetWidth;
39
34
  var _ref = parentElement,
40
- scrollLeft = _ref.scrollLeft;
35
+ scrollLeft = _ref.scrollLeft;
41
36
  var diff = offsetWidth - parentOffsetWidth;
42
37
  var toolbarSize = getToolbarSize(tableRef);
43
38
  return Math.min(offsetWidth + toolbarSize, parentOffsetWidth + toolbarSize - Math.max(scrollLeft - diff, 0)) + LINE_OFFSET;
44
39
  };
45
-
46
40
  var tooltipMessageByType = function tooltipMessageByType(type) {
47
41
  return type === 'row' ? tableMessages.insertRow : tableMessages.insertColumn;
48
42
  };
49
-
50
43
  var InsertButton = function InsertButton(_ref2) {
51
44
  var onMouseDown = _ref2.onMouseDown,
52
- tableRef = _ref2.tableRef,
53
- type = _ref2.type,
54
- formatMessage = _ref2.intl.formatMessage,
55
- hasStickyHeaders = _ref2.hasStickyHeaders;
45
+ tableRef = _ref2.tableRef,
46
+ type = _ref2.type,
47
+ formatMessage = _ref2.intl.formatMessage,
48
+ hasStickyHeaders = _ref2.hasStickyHeaders;
56
49
  var content = /*#__PURE__*/React.createElement(Tooltip, {
57
50
  content: /*#__PURE__*/React.createElement(keymaps.ToolTipContent, {
58
51
  description: formatMessage(tooltipMessageByType(type)),
@@ -86,5 +79,4 @@ var InsertButton = function InsertButton(_ref2) {
86
79
  className: "".concat(ClassName.CONTROLS_INSERT_BUTTON_WRAP, " ").concat(ClassName.CONTROLS_INSERT_ROW)
87
80
  }, content));
88
81
  };
89
-
90
82
  export default injectIntl(InsertButton);
@@ -1,9 +1,6 @@
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
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
8
5
  import { tableInsertColumnButtonOffset, tableInsertColumnButtonSize, tableToolbarSize } from '../consts';
9
6
  var HORIZONTAL_ALIGN_COLUMN_BUTTON = -(tableInsertColumnButtonSize / 2);
@@ -11,14 +8,12 @@ var HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON = HORIZONTAL_ALIGN_COLUMN_BUTTON + a
11
8
  var VERTICAL_ALIGN_COLUMN_BUTTON = tableToolbarSize + tableInsertColumnButtonOffset;
12
9
  var HORIZONTAL_ALIGN_ROW_BUTTON = -(tableToolbarSize + tableInsertColumnButtonOffset + tableInsertColumnButtonSize);
13
10
  var VERTICAL_ALIGN_ROW_BUTTON = tableInsertColumnButtonSize / 2;
14
-
15
11
  function getRowOptions(index) {
16
12
  var defaultOptions = {
17
13
  alignX: 'left',
18
14
  alignY: 'bottom',
19
15
  offset: [0, VERTICAL_ALIGN_ROW_BUTTON]
20
16
  };
21
-
22
17
  if (index === 0) {
23
18
  defaultOptions = _objectSpread(_objectSpread({}, defaultOptions), {}, {
24
19
  alignY: 'top',
@@ -26,7 +21,6 @@ function getRowOptions(index) {
26
21
  offset: [0, -VERTICAL_ALIGN_ROW_BUTTON]
27
22
  });
28
23
  }
29
-
30
24
  return _objectSpread(_objectSpread({}, defaultOptions), {}, {
31
25
  onPositionCalculated: function onPositionCalculated(position) {
32
26
  return _objectSpread(_objectSpread({}, position), {}, {
@@ -36,7 +30,6 @@ function getRowOptions(index) {
36
30
  }
37
31
  });
38
32
  }
39
-
40
33
  function getColumnOptions(index, tableContainer, hasNumberedColumns) {
41
34
  var options = {
42
35
  alignX: 'end',
@@ -49,48 +42,42 @@ function getColumnOptions(index, tableContainer, hasNumberedColumns) {
49
42
  // considering the offset from the first column
50
43
  onPositionCalculated: function onPositionCalculated(position) {
51
44
  var left = position.left;
52
-
53
45
  if (!left) {
54
46
  // If not left, lest skip expensive next calculations.
55
47
  return position;
56
48
  }
57
-
58
49
  if (index === 0) {
59
50
  return _objectSpread(_objectSpread({}, position), {}, {
60
51
  left: hasNumberedColumns ? HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON : HORIZONTAL_ALIGN_COLUMN_BUTTON
61
52
  });
62
- } // Check if current position is greater than the available container width
63
-
53
+ }
64
54
 
55
+ // Check if current position is greater than the available container width
65
56
  var rect = tableContainer ? tableContainer.getBoundingClientRect() : null;
66
57
  return _objectSpread(_objectSpread({}, position), {}, {
67
58
  left: rect && left > rect.width ? rect.width : left
68
59
  });
69
60
  }
70
- }; // We need to change the popup position when
71
- // the column index is zero
61
+ };
72
62
 
63
+ // We need to change the popup position when
64
+ // the column index is zero
73
65
  if (index === 0) {
74
66
  return _objectSpread(_objectSpread({}, options), {}, {
75
67
  alignX: 'left',
76
68
  alignY: 'top'
77
69
  });
78
70
  }
79
-
80
71
  return options;
81
72
  }
82
-
83
73
  function getPopupOptions(type, index, hasNumberedColumns, tableContainer) {
84
74
  switch (type) {
85
75
  case 'column':
86
76
  return getColumnOptions(index, tableContainer, hasNumberedColumns);
87
-
88
77
  case 'row':
89
78
  return getRowOptions(index);
90
-
91
79
  default:
92
80
  return {};
93
81
  }
94
82
  }
95
-
96
83
  export default getPopupOptions;
@@ -6,11 +6,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
-
10
9
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
-
12
10
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
-
14
11
  import React from 'react';
15
12
  import { TableMap } from '@atlaskit/editor-tables/table-map';
16
13
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
@@ -28,74 +25,59 @@ import InsertButton from './InsertButton';
28
25
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, CONTENT_COMPONENT } from '@atlaskit/editor-common/analytics';
29
26
  export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
30
27
  _inherits(FloatingInsertButton, _React$Component);
31
-
32
28
  var _super = _createSuper(FloatingInsertButton);
33
-
34
29
  function FloatingInsertButton(props) {
35
30
  var _this;
36
-
37
31
  _classCallCheck(this, FloatingInsertButton);
38
-
39
32
  _this = _super.call(this, props);
40
33
  _this.insertColumn = _this.insertColumn.bind(_assertThisInitialized(_this));
41
34
  _this.insertRow = _this.insertRow.bind(_assertThisInitialized(_this));
42
35
  return _this;
43
36
  }
44
-
45
37
  _createClass(FloatingInsertButton, [{
46
38
  key: "render",
47
39
  value: function render() {
48
40
  var _this$props = this.props,
49
- tableNode = _this$props.tableNode,
50
- editorView = _this$props.editorView,
51
- insertColumnButtonIndex = _this$props.insertColumnButtonIndex,
52
- insertRowButtonIndex = _this$props.insertRowButtonIndex,
53
- tableRef = _this$props.tableRef,
54
- mountPoint = _this$props.mountPoint,
55
- boundariesElement = _this$props.boundariesElement,
56
- isHeaderColumnEnabled = _this$props.isHeaderColumnEnabled,
57
- isHeaderRowEnabled = _this$props.isHeaderRowEnabled,
58
- dispatchAnalyticsEvent = _this$props.dispatchAnalyticsEvent;
41
+ tableNode = _this$props.tableNode,
42
+ editorView = _this$props.editorView,
43
+ insertColumnButtonIndex = _this$props.insertColumnButtonIndex,
44
+ insertRowButtonIndex = _this$props.insertRowButtonIndex,
45
+ tableRef = _this$props.tableRef,
46
+ mountPoint = _this$props.mountPoint,
47
+ boundariesElement = _this$props.boundariesElement,
48
+ isHeaderColumnEnabled = _this$props.isHeaderColumnEnabled,
49
+ isHeaderRowEnabled = _this$props.isHeaderRowEnabled,
50
+ dispatchAnalyticsEvent = _this$props.dispatchAnalyticsEvent;
59
51
  var type = typeof insertColumnButtonIndex !== 'undefined' ? 'column' : typeof insertRowButtonIndex !== 'undefined' ? 'row' : null;
60
-
61
52
  if (!tableNode || !tableRef || !type) {
62
53
  return null;
63
- } // We can’t display the insert button for row|colum index 0
64
- // when the header row|colum is enabled, this feature will be change on the future
65
-
54
+ }
66
55
 
56
+ // We can’t display the insert button for row|colum index 0
57
+ // when the header row|colum is enabled, this feature will be change on the future
67
58
  if (type === 'column' && isHeaderColumnEnabled && insertColumnButtonIndex === 0 || type === 'row' && isHeaderRowEnabled && insertRowButtonIndex === 0) {
68
59
  return null;
69
60
  }
70
-
71
61
  var tr = editorView.state.tr;
72
-
73
62
  if (tr.selection instanceof CellSelection && (tr.selection.isColSelection() || tr.selection.isRowSelection())) {
74
63
  return null;
75
64
  }
76
-
77
65
  var cellPosition = this.getCellPosition(type);
78
-
79
66
  if (!cellPosition) {
80
67
  return null;
81
68
  }
82
-
83
69
  var tablePos = findTable(editorView.state.selection);
84
-
85
70
  if (!tablePos) {
86
71
  return null;
87
72
  }
88
-
89
73
  var domAtPos = editorView.domAtPos.bind(editorView);
90
74
  var pos = cellPosition + tablePos.start + 1;
91
75
  var target;
92
-
93
76
  try {
94
77
  target = findDomRefAtPos(pos, domAtPos);
95
78
  } catch (error) {
96
79
  // eslint-disable-next-line no-console
97
80
  console.warn(error);
98
-
99
81
  if (dispatchAnalyticsEvent) {
100
82
  var payload = {
101
83
  action: ACTION.ERRORED,
@@ -115,17 +97,13 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
115
97
  dispatchAnalyticsEvent(payload);
116
98
  }
117
99
  }
118
-
119
100
  if (!target || !(target instanceof HTMLElement)) {
120
101
  return null;
121
102
  }
122
-
123
103
  var targetCellRef = type === 'row' ? closestElement(target, 'tr') : closestElement(target, 'td, th');
124
-
125
104
  if (!targetCellRef) {
126
105
  return null;
127
106
  }
128
-
129
107
  var tableContainerWrapper = closestElement(targetCellRef, ".".concat(ClassName.TABLE_CONTAINER));
130
108
  var tableWrapper = closestElement(targetCellRef, ".".concat(ClassName.TABLE_NODE_WRAPPER));
131
109
  var index = type === 'column' ? insertColumnButtonIndex : insertRowButtonIndex;
@@ -148,26 +126,21 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
148
126
  key: "getCellPosition",
149
127
  value: function getCellPosition(type) {
150
128
  var _this$props2 = this.props,
151
- tableNode = _this$props2.tableNode,
152
- insertColumnButtonIndex = _this$props2.insertColumnButtonIndex,
153
- insertRowButtonIndex = _this$props2.insertRowButtonIndex;
129
+ tableNode = _this$props2.tableNode,
130
+ insertColumnButtonIndex = _this$props2.insertColumnButtonIndex,
131
+ insertRowButtonIndex = _this$props2.insertRowButtonIndex;
154
132
  var tableMap = TableMap.get(tableNode);
155
-
156
133
  if (type === 'column') {
157
134
  var columnIndex = insertColumnButtonIndex === 0 ? 0 : insertColumnButtonIndex - 1;
158
-
159
135
  if (columnIndex > tableMap.width - 1) {
160
136
  return null;
161
137
  }
162
-
163
138
  return tableMap.positionAt(0, columnIndex, tableNode);
164
139
  } else {
165
140
  var rowIndex = insertRowButtonIndex === 0 ? 0 : insertRowButtonIndex - 1;
166
-
167
141
  if (rowIndex > tableMap.height - 1) {
168
142
  return null;
169
143
  }
170
-
171
144
  return tableMap.positionAt(rowIndex, 0, tableNode);
172
145
  }
173
146
  }
@@ -175,14 +148,13 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
175
148
  key: "insertRow",
176
149
  value: function insertRow(event) {
177
150
  var _this$props3 = this.props,
178
- editorView = _this$props3.editorView,
179
- insertRowButtonIndex = _this$props3.insertRowButtonIndex,
180
- editorAnalyticsAPI = _this$props3.editorAnalyticsAPI;
181
-
151
+ editorView = _this$props3.editorView,
152
+ insertRowButtonIndex = _this$props3.insertRowButtonIndex,
153
+ editorAnalyticsAPI = _this$props3.editorAnalyticsAPI;
182
154
  if (typeof insertRowButtonIndex !== 'undefined') {
183
155
  event.preventDefault();
184
156
  var state = editorView.state,
185
- dispatch = editorView.dispatch;
157
+ dispatch = editorView.dispatch;
186
158
  insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.BUTTON, {
187
159
  index: insertRowButtonIndex,
188
160
  moveCursorToInsertedRow: true
@@ -193,23 +165,19 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
193
165
  key: "insertColumn",
194
166
  value: function insertColumn(event) {
195
167
  var _this$props4 = this.props,
196
- editorView = _this$props4.editorView,
197
- insertColumnButtonIndex = _this$props4.insertColumnButtonIndex,
198
- editorAnalyticsAPI = _this$props4.editorAnalyticsAPI,
199
- getEditorContainerWidth = _this$props4.getEditorContainerWidth;
200
-
168
+ editorView = _this$props4.editorView,
169
+ insertColumnButtonIndex = _this$props4.insertColumnButtonIndex,
170
+ editorAnalyticsAPI = _this$props4.editorAnalyticsAPI,
171
+ getEditorContainerWidth = _this$props4.getEditorContainerWidth;
201
172
  if (typeof insertColumnButtonIndex !== 'undefined') {
202
173
  event.preventDefault();
203
174
  var state = editorView.state,
204
- dispatch = editorView.dispatch;
175
+ dispatch = editorView.dispatch;
205
176
  insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
206
177
  }
207
178
  }
208
179
  }]);
209
-
210
180
  return FloatingInsertButton;
211
181
  }(React.Component);
212
-
213
182
  _defineProperty(FloatingInsertButton, "displayName", 'FloatingInsertButton');
214
-
215
183
  export default injectIntl(FloatingInsertButton);