@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,22 +1,15 @@
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.default = getPopupOptions;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _consts = require("../consts");
13
-
14
10
  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; }
15
-
16
11
  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; }
17
-
18
12
  var DELETE_BUTTON_CONTROLS_OFFSET = _consts.tableToolbarSize + _consts.tableDeleteButtonSize + _consts.tableDeleteButtonOffset;
19
-
20
13
  function getColumnOptions(left, tableWrapper) {
21
14
  return {
22
15
  alignX: 'left',
@@ -29,12 +22,10 @@ function getColumnOptions(left, tableWrapper) {
29
22
  var minVisibleLeftPosition = tableWrapper.scrollLeft;
30
23
  return maxVisibleLeftPosition - left > 0 && left > minVisibleLeftPosition;
31
24
  }
32
-
33
25
  return true;
34
26
  }
35
27
  };
36
28
  }
37
-
38
29
  function getRowOptions(top) {
39
30
  return {
40
31
  alignX: 'left',
@@ -49,20 +40,16 @@ function getRowOptions(top) {
49
40
  }
50
41
  };
51
42
  }
52
-
53
43
  function getPopupOptions(_ref) {
54
44
  var left = _ref.left,
55
- top = _ref.top,
56
- selectionType = _ref.selectionType,
57
- tableWrapper = _ref.tableWrapper;
58
-
45
+ top = _ref.top,
46
+ selectionType = _ref.selectionType,
47
+ tableWrapper = _ref.tableWrapper;
59
48
  switch (selectionType) {
60
49
  case 'column':
61
50
  return getColumnOptions(left, tableWrapper);
62
-
63
51
  case 'row':
64
52
  return getRowOptions(top);
65
-
66
53
  default:
67
54
  {
68
55
  return {};
@@ -1,171 +1,120 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.default = void 0;
11
9
  exports.getSelectionType = getSelectionType;
12
-
13
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
14
-
15
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
16
-
17
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
18
-
19
13
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
20
-
21
14
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
22
-
23
15
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
24
-
25
16
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
26
-
27
17
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
28
-
29
18
  var _react = _interopRequireWildcard(require("react"));
30
-
31
19
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
32
-
33
20
  var _utils = require("@atlaskit/editor-tables/utils");
34
-
35
21
  var _reactDom = require("react-dom");
36
-
37
22
  var _ui = require("@atlaskit/editor-common/ui");
38
-
39
23
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
40
-
41
24
  var _utils2 = require("@atlaskit/editor-common/utils");
42
-
43
25
  var _analytics = require("@atlaskit/editor-common/analytics");
44
-
45
26
  var _commands = require("../../commands");
46
-
47
27
  var _commandsWithAnalytics = require("../../commands-with-analytics");
48
-
49
28
  var _pluginFactory = require("../../pm-plugins/plugin-factory");
50
-
51
29
  var _types = require("../../types");
52
-
53
30
  var _utils3 = require("../../utils");
54
-
55
31
  var _messages = _interopRequireDefault(require("../messages"));
56
-
57
32
  var _consts = require("../consts");
58
-
59
33
  var _DeleteButton = _interopRequireDefault(require("./DeleteButton"));
60
-
61
34
  var _getPopUpOptions = _interopRequireDefault(require("./getPopUpOptions"));
62
-
63
35
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
64
-
65
36
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
66
-
67
37
  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; }
68
-
69
38
  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; }
70
-
71
39
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
72
-
73
40
  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; } }
74
-
75
41
  function getSelectionType(selection) {
76
42
  if (!(0, _utils.isTableSelected)(selection) && selection instanceof _cellSelection.CellSelection) {
77
43
  if (selection.isRowSelection()) {
78
44
  return 'row';
79
45
  }
80
-
81
46
  if (selection.isColSelection()) {
82
47
  return 'column';
83
48
  }
84
49
  }
85
-
86
50
  return;
87
51
  }
88
-
89
52
  var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
90
53
  (0, _inherits2.default)(FloatingDeleteButton, _Component);
91
-
92
54
  var _super = _createSuper(FloatingDeleteButton);
93
-
94
55
  function FloatingDeleteButton(props) {
95
56
  var _this;
96
-
97
57
  (0, _classCallCheck2.default)(this, FloatingDeleteButton);
98
58
  _this = _super.call(this, props);
99
59
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "wrapper", null);
100
60
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateWrapper", function () {
101
61
  var tableWrapper = (0, _utils2.closestElement)(_this.props.tableRef, ".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
102
-
103
62
  if (tableWrapper) {
104
63
  _this.wrapper = tableWrapper;
105
-
106
64
  _this.wrapper.addEventListener('scroll', _this.onWrapperScrolled);
107
-
108
65
  _this.setState({
109
66
  scrollLeft: tableWrapper.scrollLeft
110
67
  });
111
68
  } else {
112
69
  if (_this.wrapper) {
113
70
  // unsubscribe if we previously had one and it just went away
114
- _this.wrapper.removeEventListener('scroll', _this.onWrapperScrolled); // and reset scroll position
115
-
71
+ _this.wrapper.removeEventListener('scroll', _this.onWrapperScrolled);
116
72
 
73
+ // and reset scroll position
117
74
  _this.setState({
118
75
  scrollLeft: 0
119
76
  });
120
77
  }
121
-
122
78
  _this.wrapper = null;
123
79
  }
124
80
  });
125
81
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onWrapperScrolled", function (e) {
126
82
  var wrapper = e.target;
127
-
128
83
  _this.setState({
129
84
  scrollLeft: wrapper.scrollLeft
130
85
  });
131
86
  });
132
87
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleMouseEnter", function () {
133
88
  var _this$props$editorVie = _this.props.editorView,
134
- state = _this$props$editorVie.state,
135
- dispatch = _this$props$editorVie.dispatch;
136
-
89
+ state = _this$props$editorVie.state,
90
+ dispatch = _this$props$editorVie.dispatch;
137
91
  switch (_this.state.selectionType) {
138
92
  case 'row':
139
93
  {
140
94
  return (0, _commands.hoverRows)(_this.state.indexes, true)(state, dispatch, _this.props.editorView);
141
95
  }
142
-
143
96
  case 'column':
144
97
  {
145
98
  return (0, _commands.hoverColumns)(_this.state.indexes, true)(state, dispatch, _this.props.editorView);
146
99
  }
147
100
  }
148
-
149
101
  return false;
150
102
  });
151
103
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleMouseLeave", function () {
152
104
  var _this$props$editorVie2 = _this.props.editorView,
153
- state = _this$props$editorVie2.state,
154
- dispatch = _this$props$editorVie2.dispatch;
105
+ state = _this$props$editorVie2.state,
106
+ dispatch = _this$props$editorVie2.dispatch;
155
107
  return (0, _commands.clearHoverSelection)()(state, dispatch);
156
108
  });
157
109
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClick", function (event) {
158
110
  event.preventDefault();
159
111
  var editorAnalyticsAPI = _this.props.editorAnalyticsAPI;
160
112
  var _this$props$editorVie3 = _this.props.editorView,
161
- state = _this$props$editorVie3.state,
162
- dispatch = _this$props$editorVie3.dispatch;
163
-
113
+ state = _this$props$editorVie3.state,
114
+ dispatch = _this$props$editorVie3.dispatch;
164
115
  var _getTablePluginState = (0, _pluginFactory.getPluginState)(state),
165
- isHeaderRowRequired = _getTablePluginState.pluginConfig.isHeaderRowRequired;
166
-
116
+ isHeaderRowRequired = _getTablePluginState.pluginConfig.isHeaderRowRequired;
167
117
  var rect = (0, _utils.getSelectionRect)(state.selection);
168
-
169
118
  if (rect) {
170
119
  switch (_this.state.selectionType) {
171
120
  case 'column':
@@ -173,7 +122,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
173
122
  (0, _commandsWithAnalytics.deleteColumnsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.BUTTON, rect)(state, dispatch);
174
123
  return;
175
124
  }
176
-
177
125
  case 'row':
178
126
  {
179
127
  (0, _commandsWithAnalytics.deleteRowsWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.BUTTON, rect, !!isHeaderRowRequired)(state, dispatch);
@@ -181,7 +129,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
181
129
  }
182
130
  }
183
131
  }
184
-
185
132
  var _this$props$editorVie4 = _this.props.editorView;
186
133
  state = _this$props$editorVie4.state;
187
134
  dispatch = _this$props$editorVie4.dispatch;
@@ -196,7 +143,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
196
143
  };
197
144
  return _this;
198
145
  }
199
-
200
146
  (0, _createClass2.default)(FloatingDeleteButton, [{
201
147
  key: "shouldComponentUpdate",
202
148
  value: function shouldComponentUpdate(_, nextState) {
@@ -223,24 +169,20 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
223
169
  key: "render",
224
170
  value: function render() {
225
171
  var _this$props = this.props,
226
- mountPoint = _this$props.mountPoint,
227
- boundariesElement = _this$props.boundariesElement,
228
- tableRef = _this$props.tableRef;
172
+ mountPoint = _this$props.mountPoint,
173
+ boundariesElement = _this$props.boundariesElement,
174
+ tableRef = _this$props.tableRef;
229
175
  var selectionType = this.state.selectionType;
230
-
231
176
  if (!selectionType || !tableRef) {
232
177
  return null;
233
178
  }
234
-
235
179
  var tableContainerWrapper = (0, _utils2.closestElement)(tableRef, ".".concat(_types.TableCssClassName.TABLE_CONTAINER));
236
-
237
180
  var button = /*#__PURE__*/_react.default.createElement(_DeleteButton.default, {
238
181
  removeLabel: selectionType === 'column' ? _messages.default.removeColumns : _messages.default.removeRows,
239
182
  onClick: this.handleClick,
240
183
  onMouseEnter: this.handleMouseEnter,
241
184
  onMouseLeave: this.handleMouseLeave
242
185
  });
243
-
244
186
  var popupOpts = (0, _getPopUpOptions.default)({
245
187
  left: this.state.left,
246
188
  top: this.state.top,
@@ -248,17 +190,13 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
248
190
  tableWrapper: this.wrapper
249
191
  });
250
192
  var mountTo = tableContainerWrapper || mountPoint;
251
-
252
193
  if (this.state.position === 'sticky' && mountTo) {
253
194
  var headerRow = tableRef.querySelector('tr.sticky');
254
-
255
195
  if (headerRow) {
256
196
  var rect = headerRow.getBoundingClientRect();
257
-
258
197
  var calculatePosition = popupOpts.onPositionCalculated || function (pos) {
259
198
  return pos;
260
199
  };
261
-
262
200
  var pos = calculatePosition({
263
201
  left: this.state.left,
264
202
  top: this.state.top
@@ -273,7 +211,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
273
211
  }, button), mountTo);
274
212
  }
275
213
  }
276
-
277
214
  return /*#__PURE__*/_react.default.createElement(_ui.Popup, (0, _extends2.default)({
278
215
  target: tableRef,
279
216
  mountTo: mountTo,
@@ -294,14 +231,14 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
294
231
  function getDerivedStateFromProps(nextProps, prevState) {
295
232
  var selectionType = getSelectionType(nextProps.selection);
296
233
  var inStickyMode = nextProps.stickyHeaders && nextProps.stickyHeaders.sticky;
297
- var rect = (0, _utils.getSelectionRect)(nextProps.selection); // only tie row delete to sticky header if it's the only thing
234
+ var rect = (0, _utils.getSelectionRect)(nextProps.selection);
235
+
236
+ // only tie row delete to sticky header if it's the only thing
298
237
  // in the selection, otherwise the row delete will hover around
299
238
  // the rest of the selection
300
-
301
239
  var firstRowInSelection = rect && rect.top === 0 && rect.bottom === 1;
302
240
  var shouldStickyButton = inStickyMode && firstRowInSelection;
303
241
  var stickyTop = nextProps.stickyHeaders ? nextProps.stickyHeaders.top + nextProps.stickyHeaders.padding : 0;
304
-
305
242
  if (selectionType) {
306
243
  switch (selectionType) {
307
244
  case 'column':
@@ -309,7 +246,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
309
246
  // Calculate the button position and indexes for columns
310
247
  var columnsWidths = (0, _utils3.getColumnsWidths)(nextProps.editorView);
311
248
  var deleteBtnParams = (0, _utils3.getColumnDeleteButtonParams)(columnsWidths, nextProps.editorView.state.selection);
312
-
313
249
  if (deleteBtnParams) {
314
250
  return _objectSpread(_objectSpread({}, deleteBtnParams), {}, {
315
251
  top: inStickyMode ? nextProps.stickyHeaders.top : 0,
@@ -317,19 +253,15 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
317
253
  selectionType: selectionType
318
254
  });
319
255
  }
320
-
321
256
  return null;
322
257
  }
323
-
324
258
  case 'row':
325
259
  {
326
260
  // Calculate the button position and indexes for rows
327
261
  if (nextProps.tableRef) {
328
262
  var rowHeights = (0, _utils3.getRowHeights)(nextProps.tableRef);
329
263
  var offsetTop = inStickyMode ? -rowHeights[0] : 0;
330
-
331
264
  var _deleteBtnParams = (0, _utils3.getRowDeleteButtonParams)(rowHeights, nextProps.editorView.state.selection, shouldStickyButton ? stickyTop : offsetTop);
332
-
333
265
  if (_deleteBtnParams) {
334
266
  return _objectSpread(_objectSpread({}, _deleteBtnParams), {}, {
335
267
  position: shouldStickyButton ? 'sticky' : undefined,
@@ -338,13 +270,12 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
338
270
  });
339
271
  }
340
272
  }
341
-
342
273
  return null;
343
274
  }
344
275
  }
345
- } // Clean state if no type
346
-
276
+ }
347
277
 
278
+ // Clean state if no type
348
279
  if (prevState.selectionType !== selectionType) {
349
280
  return {
350
281
  selectionType: undefined,
@@ -352,15 +283,14 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
352
283
  left: 0,
353
284
  indexes: []
354
285
  };
355
- } // Do nothing if doesn't change anything
356
-
286
+ }
357
287
 
288
+ // Do nothing if doesn't change anything
358
289
  return null;
359
290
  }
360
291
  }]);
361
292
  return FloatingDeleteButton;
362
293
  }(_react.Component);
363
-
364
294
  (0, _defineProperty2.default)(FloatingDeleteButton, "displayName", 'FloatingDeleteButton');
365
295
  var _default = FloatingDeleteButton;
366
296
  exports.default = _default;
@@ -1,38 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.default = void 0;
11
-
12
9
  var _react = _interopRequireDefault(require("react"));
13
-
14
10
  var _reactIntlNext = require("react-intl-next");
15
-
16
11
  var _styles = require("@atlaskit/editor-common/styles");
17
-
18
12
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
19
-
20
13
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
21
-
22
14
  var keymaps = _interopRequireWildcard(require("@atlaskit/editor-common/keymaps"));
23
-
24
15
  var _utils = require("@atlaskit/editor-common/utils");
25
-
26
16
  var _types = require("../../types");
27
-
28
17
  var _messages = _interopRequireDefault(require("../messages"));
29
-
30
18
  var _consts = require("../consts");
31
-
32
19
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
33
-
34
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
35
-
36
21
  var getInsertLineHeight = function getInsertLineHeight(tableRef, hasStickyHeaders) {
37
22
  // The line gets height 100% from the table,
38
23
  // but since we have an overflow on the left,
@@ -41,43 +26,36 @@ var getInsertLineHeight = function getInsertLineHeight(tableRef, hasStickyHeader
41
26
  var ADDITIONAL_HEIGHT = hasStickyHeaders ? tableRef.getBoundingClientRect().top - _styles.tableMarginTop * 4 - LINE_OFFSET : _consts.tableToolbarSize + LINE_OFFSET;
42
27
  return tableRef.offsetHeight + ADDITIONAL_HEIGHT;
43
28
  };
44
-
45
29
  var getToolbarSize = function getToolbarSize(tableRef) {
46
30
  var parent = (0, _utils.closestElement)(tableRef, ".".concat(_types.TableCssClassName.TABLE_CONTAINER));
47
-
48
31
  if (parent) {
49
32
  return parent.querySelector(".".concat(_types.TableCssClassName.NUMBERED_COLUMN)) ? _consts.tableToolbarSize + _editorSharedStyles.akEditorTableNumberColumnWidth - 1 : _consts.tableToolbarSize;
50
33
  }
51
-
52
34
  return _consts.tableToolbarSize;
53
35
  };
54
-
55
36
  var getInsertLineWidth = function getInsertLineWidth(tableRef) {
56
37
  // The line gets width 100% from the table,
57
38
  // but since we have an overflow on the left,
58
39
  // we should add an offset to make up for it.
59
40
  var LINE_OFFSET = 4;
60
41
  var parentElement = tableRef.parentElement,
61
- offsetWidth = tableRef.offsetWidth;
42
+ offsetWidth = tableRef.offsetWidth;
62
43
  var parentOffsetWidth = parentElement.offsetWidth;
63
44
  var _ref = parentElement,
64
- scrollLeft = _ref.scrollLeft;
45
+ scrollLeft = _ref.scrollLeft;
65
46
  var diff = offsetWidth - parentOffsetWidth;
66
47
  var toolbarSize = getToolbarSize(tableRef);
67
48
  return Math.min(offsetWidth + toolbarSize, parentOffsetWidth + toolbarSize - Math.max(scrollLeft - diff, 0)) + LINE_OFFSET;
68
49
  };
69
-
70
50
  var tooltipMessageByType = function tooltipMessageByType(type) {
71
51
  return type === 'row' ? _messages.default.insertRow : _messages.default.insertColumn;
72
52
  };
73
-
74
53
  var InsertButton = function InsertButton(_ref2) {
75
54
  var onMouseDown = _ref2.onMouseDown,
76
- tableRef = _ref2.tableRef,
77
- type = _ref2.type,
78
- formatMessage = _ref2.intl.formatMessage,
79
- hasStickyHeaders = _ref2.hasStickyHeaders;
80
-
55
+ tableRef = _ref2.tableRef,
56
+ type = _ref2.type,
57
+ formatMessage = _ref2.intl.formatMessage,
58
+ hasStickyHeaders = _ref2.hasStickyHeaders;
81
59
  var content = /*#__PURE__*/_react.default.createElement(_tooltip.default, {
82
60
  content: /*#__PURE__*/_react.default.createElement(keymaps.ToolTipContent, {
83
61
  description: formatMessage(tooltipMessageByType(type)),
@@ -104,7 +82,6 @@ var InsertButton = function InsertButton(_ref2) {
104
82
  height: getInsertLineHeight(tableRef, hasStickyHeaders)
105
83
  }
106
84
  })));
107
-
108
85
  var floatingButtonClassName = type === 'column' ? _types.TableCssClassName.CONTROLS_FLOATING_BUTTON_COLUMN : _types.TableCssClassName.CONTROLS_FLOATING_BUTTON_ROW;
109
86
  return /*#__PURE__*/_react.default.createElement("div", {
110
87
  className: floatingButtonClassName
@@ -112,7 +89,5 @@ var InsertButton = function InsertButton(_ref2) {
112
89
  className: "".concat(_types.TableCssClassName.CONTROLS_INSERT_BUTTON_WRAP, " ").concat(_types.TableCssClassName.CONTROLS_INSERT_ROW)
113
90
  }, content));
114
91
  };
115
-
116
92
  var _default = (0, _reactIntlNext.injectIntl)(InsertButton);
117
-
118
93
  exports.default = _default;
@@ -1,35 +1,26 @@
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.default = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
13
-
14
10
  var _consts = require("../consts");
15
-
16
11
  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; }
17
-
18
12
  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; }
19
-
20
13
  var HORIZONTAL_ALIGN_COLUMN_BUTTON = -(_consts.tableInsertColumnButtonSize / 2);
21
14
  var HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON = HORIZONTAL_ALIGN_COLUMN_BUTTON + _editorSharedStyles.akEditorTableNumberColumnWidth;
22
15
  var VERTICAL_ALIGN_COLUMN_BUTTON = _consts.tableToolbarSize + _consts.tableInsertColumnButtonOffset;
23
16
  var HORIZONTAL_ALIGN_ROW_BUTTON = -(_consts.tableToolbarSize + _consts.tableInsertColumnButtonOffset + _consts.tableInsertColumnButtonSize);
24
17
  var VERTICAL_ALIGN_ROW_BUTTON = _consts.tableInsertColumnButtonSize / 2;
25
-
26
18
  function getRowOptions(index) {
27
19
  var defaultOptions = {
28
20
  alignX: 'left',
29
21
  alignY: 'bottom',
30
22
  offset: [0, VERTICAL_ALIGN_ROW_BUTTON]
31
23
  };
32
-
33
24
  if (index === 0) {
34
25
  defaultOptions = _objectSpread(_objectSpread({}, defaultOptions), {}, {
35
26
  alignY: 'top',
@@ -37,7 +28,6 @@ function getRowOptions(index) {
37
28
  offset: [0, -VERTICAL_ALIGN_ROW_BUTTON]
38
29
  });
39
30
  }
40
-
41
31
  return _objectSpread(_objectSpread({}, defaultOptions), {}, {
42
32
  onPositionCalculated: function onPositionCalculated(position) {
43
33
  return _objectSpread(_objectSpread({}, position), {}, {
@@ -47,7 +37,6 @@ function getRowOptions(index) {
47
37
  }
48
38
  });
49
39
  }
50
-
51
40
  function getColumnOptions(index, tableContainer, hasNumberedColumns) {
52
41
  var options = {
53
42
  alignX: 'end',
@@ -60,49 +49,43 @@ function getColumnOptions(index, tableContainer, hasNumberedColumns) {
60
49
  // considering the offset from the first column
61
50
  onPositionCalculated: function onPositionCalculated(position) {
62
51
  var left = position.left;
63
-
64
52
  if (!left) {
65
53
  // If not left, lest skip expensive next calculations.
66
54
  return position;
67
55
  }
68
-
69
56
  if (index === 0) {
70
57
  return _objectSpread(_objectSpread({}, position), {}, {
71
58
  left: hasNumberedColumns ? HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON : HORIZONTAL_ALIGN_COLUMN_BUTTON
72
59
  });
73
- } // Check if current position is greater than the available container width
74
-
60
+ }
75
61
 
62
+ // Check if current position is greater than the available container width
76
63
  var rect = tableContainer ? tableContainer.getBoundingClientRect() : null;
77
64
  return _objectSpread(_objectSpread({}, position), {}, {
78
65
  left: rect && left > rect.width ? rect.width : left
79
66
  });
80
67
  }
81
- }; // We need to change the popup position when
82
- // the column index is zero
68
+ };
83
69
 
70
+ // We need to change the popup position when
71
+ // the column index is zero
84
72
  if (index === 0) {
85
73
  return _objectSpread(_objectSpread({}, options), {}, {
86
74
  alignX: 'left',
87
75
  alignY: 'top'
88
76
  });
89
77
  }
90
-
91
78
  return options;
92
79
  }
93
-
94
80
  function getPopupOptions(type, index, hasNumberedColumns, tableContainer) {
95
81
  switch (type) {
96
82
  case 'column':
97
83
  return getColumnOptions(index, tableContainer, hasNumberedColumns);
98
-
99
84
  case 'row':
100
85
  return getRowOptions(index);
101
-
102
86
  default:
103
87
  return {};
104
88
  }
105
89
  }
106
-
107
90
  var _default = getPopupOptions;
108
91
  exports.default = _default;