@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,25 +1,21 @@
1
1
  import { NodeRange } from 'prosemirror-model';
2
2
  import { findWrapping } from 'prosemirror-transform';
3
3
  import { findTable } from '@atlaskit/editor-tables/utils';
4
-
5
4
  const bail = () => ({
6
5
  tableIsCollapsible: false
7
6
  });
7
+
8
8
  /**
9
9
  * Checks whether we can wrap the selected table into an expand via
10
10
  * prosemirror-transform's `findWrapping` helper
11
11
  */
12
-
13
-
14
12
  export const isTableCollapsible = tr => {
15
13
  const selection = tr.selection;
16
14
  const schema = tr.doc.type.schema;
17
15
  const nodePos = findTable(selection);
18
-
19
16
  if (!nodePos) {
20
17
  return bail();
21
18
  }
22
-
23
19
  const expand = schema.nodes.expand;
24
20
  const {
25
21
  node,
@@ -27,21 +23,16 @@ export const isTableCollapsible = tr => {
27
23
  } = nodePos;
28
24
  const $pos = tr.doc.resolve(pos);
29
25
  const range = new NodeRange($pos, tr.doc.resolve(pos + node.nodeSize), $pos.depth);
30
-
31
26
  if (!range) {
32
27
  return bail();
33
28
  }
34
-
35
29
  const canWrap = findWrapping(range, expand);
36
-
37
30
  if (canWrap === null) {
38
31
  return bail();
39
32
  }
40
-
41
33
  return {
42
34
  tableIsCollapsible: true,
43
35
  range,
44
-
45
36
  /**
46
37
  * Do we ever want to deal with the result of `findWrapping`? Probably not,
47
38
  * but we have it anyway.
@@ -49,6 +40,7 @@ export const isTableCollapsible = tr => {
49
40
  findWrappingRes: canWrap
50
41
  };
51
42
  };
43
+
52
44
  /**
53
45
  * Collapses the selected table into an expand given a transaction via
54
46
  * `Transform.wrap`.
@@ -59,14 +51,13 @@ export const isTableCollapsible = tr => {
59
51
  * @param tr
60
52
  * @returns Transaction | undefined
61
53
  */
62
-
63
54
  export const collapseSelectedTable = tr => {
64
55
  const canCollapse = isTableCollapsible(tr);
65
56
  const expand = tr.doc.type.schema.nodes.expand;
66
-
67
57
  if (!canCollapse.range || !canCollapse.tableIsCollapsible) {
68
58
  return undefined;
69
59
  }
60
+
70
61
  /**
71
62
  * TODO: add attrs: { __expanded: false } when
72
63
  * - it is working with new collab (CEMS-1204)
@@ -75,8 +66,6 @@ export const collapseSelectedTable = tr => {
75
66
  * (via confluence-frontend, "this feature" referencing allowInteractiveExpand)
76
67
  * `we can NEVER allow this feature to be enabled for the synchrony-powered editor
77
68
  */
78
-
79
-
80
69
  tr.wrap(canCollapse.range, [{
81
70
  type: expand
82
71
  }]).setMeta('scrollIntoView', true);
@@ -11,19 +11,17 @@ export const getColumnsWidths = view => {
11
11
  } = view.state;
12
12
  let widths = [];
13
13
  const table = findTable(selection);
14
-
15
14
  if (table) {
16
15
  const map = TableMap.get(table.node);
17
- const domAtPos = view.domAtPos.bind(view); // When there is no cell we need to fill it with undefined
16
+ const domAtPos = view.domAtPos.bind(view);
18
17
 
18
+ // When there is no cell we need to fill it with undefined
19
19
  widths = Array.from({
20
20
  length: map.width
21
21
  });
22
-
23
22
  for (let i = 0; i < map.width; i++) {
24
23
  const cells = getCellsInColumn(i)(selection);
25
24
  const cell = cells[0];
26
-
27
25
  if (cell) {
28
26
  const cellRef = findDomRefAtPos(cell.pos, domAtPos);
29
27
  const rect = cellRef.getBoundingClientRect();
@@ -32,46 +30,37 @@ export const getColumnsWidths = view => {
32
30
  }
33
31
  }
34
32
  }
35
-
36
33
  return widths;
37
34
  };
38
35
  export const isColumnDeleteButtonVisible = selection => {
39
36
  if (!isTableSelected(selection) && selection instanceof CellSelection && selection.isColSelection()) {
40
37
  return true;
41
38
  }
42
-
43
39
  return false;
44
40
  };
45
41
  export const getColumnDeleteButtonParams = (columnsWidths, selection) => {
46
42
  const rect = getSelectionRect(selection);
47
-
48
43
  if (!rect) {
49
44
  return null;
50
45
  }
51
-
52
46
  let width = 0;
53
- let offset = 0; // find the columns before the selection
54
-
47
+ let offset = 0;
48
+ // find the columns before the selection
55
49
  for (let i = 0; i < rect.left; i++) {
56
50
  const colWidth = columnsWidths[i];
57
-
58
51
  if (colWidth) {
59
52
  offset += colWidth - 1;
60
53
  }
61
- } // these are the selected columns widths
62
-
63
-
54
+ }
55
+ // these are the selected columns widths
64
56
  const indexes = [];
65
-
66
57
  for (let i = rect.left; i < rect.right; i++) {
67
58
  const colWidth = columnsWidths[i];
68
-
69
59
  if (colWidth) {
70
60
  width += colWidth;
71
61
  indexes.push(i);
72
62
  }
73
63
  }
74
-
75
64
  const left = offset + width / 2 - tableDeleteButtonSize / 2;
76
65
  return {
77
66
  left,
@@ -80,19 +69,17 @@ export const getColumnDeleteButtonParams = (columnsWidths, selection) => {
80
69
  };
81
70
  export const getColumnClassNames = (index, selection, hoveredColumns = [], isInDanger, isResizing) => {
82
71
  const classNames = [];
83
-
84
72
  if (isColumnSelected(index)(selection) || hoveredColumns.indexOf(index) > -1 && !isResizing) {
85
73
  classNames.push(ClassName.HOVERED_CELL_ACTIVE);
86
-
87
74
  if (isInDanger) {
88
75
  classNames.push(ClassName.HOVERED_CELL_IN_DANGER);
89
76
  }
90
77
  }
91
-
92
78
  return classNames.join(' ');
93
- }; // give a row colspan and a colwidths
94
- // and map to a row's colwidths
79
+ };
95
80
 
81
+ // give a row colspan and a colwidths
82
+ // and map to a row's colwidths
96
83
  const mapTableColwidthsToRow = (rowColSpans, tableColWidths) => {
97
84
  let curColIdx = 0;
98
85
  const colWidths = [];
@@ -103,7 +90,6 @@ const mapTableColwidthsToRow = (rowColSpans, tableColWidths) => {
103
90
  });
104
91
  return colWidths;
105
92
  };
106
-
107
93
  const getRelativeDomCellWidths = ({
108
94
  width,
109
95
  colspan,
@@ -116,30 +102,31 @@ const getRelativeDomCellWidths = ({
116
102
  // return equally partitioned total cell width in DOM for each cell.
117
103
  if (colspan === 1 || !colwidth) {
118
104
  return new Array(colspan).fill(width / colspan);
119
- } // For cells that have colSpan > 1 and
105
+ }
106
+
107
+ // For cells that have colSpan > 1 and
120
108
  // are part of a table with resized columns
121
109
  // return the current total DOM width of the cell multiplied
122
110
  // by the percentage of the each individual cell's size.
123
111
  // The cell size percentage is calculated using individual colwidth of the cell,
124
112
  // from data-colwidth attribute on the cell,
125
113
  // divided by the total width of the cells from colwidths for merged cells.
114
+
126
115
  // Ex:
127
116
  // colwidth = ‘201,102’
128
117
  // Total colWidth = 303
129
118
  // returned cellWidths = [303 * (201/303), 303 * (102/303)]
130
- // For merged cells we get back colwidth as `201,102`
131
-
132
119
 
120
+ // For merged cells we get back colwidth as `201,102`
133
121
  const cellColWidths = colwidth.split(',').map(colwidth => Number(colwidth));
134
122
  const totalCalculatedCellWidth = cellColWidths.reduce((acc, cellColWidth) => acc + cellColWidth, 0);
135
123
  return cellColWidths.map(cellColWidth => width * (cellColWidth / totalCalculatedCellWidth));
136
124
  };
137
-
138
125
  export const colWidthsForRow = (colGroup, tr) => {
139
126
  // get the colspans
140
- const rowColSpans = maphElem(tr, cell => Number(cell.getAttribute('colspan') || 1
141
- /* default to span of 1 */
142
- )); // Chrome has trouble aligning borders with auto tables
127
+ const rowColSpans = maphElem(tr, cell => Number(cell.getAttribute('colspan') || 1 /* default to span of 1 */));
128
+
129
+ // Chrome has trouble aligning borders with auto tables
143
130
  // and the rest of the page grid. tables with defined
144
131
  // column widths align fine.
145
132
  //
@@ -147,30 +134,28 @@ export const colWidthsForRow = (colGroup, tr) => {
147
134
  //
148
135
  // prefer copying the widths via the DOM
149
136
  // or inferring from the next row if one exists
150
-
151
137
  const copyTarget = tr.nextElementSibling || tr;
152
-
153
138
  if (copyTarget) {
154
139
  // either from the first row while it's still in the table
155
140
  const cellInfos = maphElem(copyTarget, cell => ({
156
141
  width: cell.getBoundingClientRect().width,
157
142
  colspan: Number(cell.getAttribute('colspan') || 1),
158
143
  colwidth: cell.dataset.colwidth
159
- })); // reverse engineer cell widths from table widths
144
+ }));
160
145
 
146
+ // reverse engineer cell widths from table widths
161
147
  let domBasedCellWidths = [];
162
148
  cellInfos.map((cell, idx) => {
163
149
  domBasedCellWidths.push(...getRelativeDomCellWidths(cell));
164
150
  });
165
-
166
151
  if (cellInfos.reduce((acc, cell) => acc + cell.width, 0) !== 0) {
167
152
  const newWidths = mapTableColwidthsToRow(rowColSpans, domBasedCellWidths);
168
153
  return newWidths.map(px => `${px}px`).join(' ');
169
154
  }
170
- } // as a fallback, just calculate a %, and hope that
171
- // it aligns perfectly in the user's browser
172
-
155
+ }
173
156
 
157
+ // as a fallback, just calculate a %, and hope that
158
+ // it aligns perfectly in the user's browser
174
159
  const visualColCount = rowColSpans.reduce((acc, val) => acc + val, 0);
175
160
  const pctWidths = rowColSpans.map(cellColSpan => cellColSpan / visualColCount * 100);
176
161
  return pctWidths.map(pct => `${pct}%`).join(' ');
@@ -3,9 +3,7 @@ import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tab
3
3
  import { Decoration } from 'prosemirror-view';
4
4
  import { nonNullable } from '@atlaskit/editor-common/utils';
5
5
  import { TableCssClassName as ClassName, TableDecorations } from '../types';
6
-
7
6
  const filterDecorationByKey = (key, decorationSet) => decorationSet.find(undefined, undefined, spec => spec.key.indexOf(key) > -1);
8
-
9
7
  export const findColumnControlSelectedDecoration = decorationSet => filterDecorationByKey(TableDecorations.COLUMN_SELECTED, decorationSet);
10
8
  export const findControlsHoverDecoration = decorationSet => filterDecorationByKey(TableDecorations.ALL_CONTROLS_HOVER, decorationSet);
11
9
  export const createCellHoverDecoration = (cells, type) => cells.map(cell => Decoration.node(cell.pos, cell.pos + cell.node.nodeSize, {
@@ -15,29 +13,25 @@ export const createCellHoverDecoration = (cells, type) => cells.map(cell => Deco
15
13
  }));
16
14
  export const createControlsHoverDecoration = (cells, type, tr, danger, selected) => {
17
15
  const table = findTable(tr.selection);
18
-
19
16
  if (!table) {
20
17
  return [];
21
18
  }
22
-
23
19
  const map = TableMap.get(table.node);
24
20
  const [min, max] = cells.reduce(([min, max], cell) => {
25
21
  if (min === null || cell.pos < min) {
26
22
  min = cell.pos;
27
23
  }
28
-
29
24
  if (max === null || cell.pos > max) {
30
25
  max = cell.pos;
31
26
  }
32
-
33
27
  return [min, max];
34
28
  }, [null, null]);
35
-
36
29
  if (min === null || max === null) {
37
30
  return [];
38
31
  }
32
+ let updatedCells = cells.map(x => x.pos);
39
33
 
40
- let updatedCells = cells.map(x => x.pos); // ED-15246 fixed trello card table overflow issue
34
+ // ED-15246 fixed trello card table overflow issue
41
35
  // If columns / rows have been merged the hovered selection is different to the actual selection
42
36
  // So If the table cells are in danger we want to create a "rectangle" selection
43
37
  // to match the "clicked" selection
@@ -56,16 +50,17 @@ export const createControlsHoverDecoration = (cells, type, tr, danger, selected)
56
50
  right,
57
51
  bottom,
58
52
  top
59
- } = map.findCell(cell.pos - table.start); // Finding the bounding rect requires finding the min left and top positions,
53
+ } = map.findCell(cell.pos - table.start);
54
+ // Finding the bounding rect requires finding the min left and top positions,
60
55
  // and the max right and bottom positions of the cells
61
-
62
56
  return {
63
57
  recLeft: Math.min(acc.recLeft, left),
64
58
  recTop: Math.min(acc.recTop, top),
65
59
  recRight: Math.max(acc.recRight, right),
66
60
  recBottom: Math.max(acc.recBottom, bottom)
67
61
  };
68
- }, // +-Infinity as initialisation vars which will always be overwritten
62
+ },
63
+ // +-Infinity as initialisation vars which will always be overwritten
69
64
  // by smaller/larger values respectively
70
65
  {
71
66
  recLeft: Infinity,
@@ -76,36 +71,28 @@ export const createControlsHoverDecoration = (cells, type, tr, danger, selected)
76
71
  const rect = new Rect(recLeft, recTop, recRight, recBottom);
77
72
  updatedCells = map.cellsInRect(rect).map(x => x + table.start);
78
73
  }
79
-
80
74
  return updatedCells.map(pos => {
81
75
  const cell = tr.doc.nodeAt(pos);
82
76
  const classes = [ClassName.HOVERED_CELL];
83
-
84
77
  if (danger) {
85
78
  classes.push(ClassName.HOVERED_CELL_IN_DANGER);
86
79
  }
87
-
88
80
  if (selected) {
89
81
  classes.push(ClassName.SELECTED_CELL);
90
82
  }
91
-
92
83
  classes.push(type === 'column' ? ClassName.HOVERED_COLUMN : type === 'row' ? ClassName.HOVERED_ROW : ClassName.HOVERED_TABLE);
93
84
  let key;
94
-
95
85
  switch (type) {
96
86
  case 'row':
97
87
  key = TableDecorations.ROW_CONTROLS_HOVER;
98
88
  break;
99
-
100
89
  case 'column':
101
90
  key = TableDecorations.COLUMN_CONTROLS_HOVER;
102
91
  break;
103
-
104
92
  default:
105
93
  key = TableDecorations.TABLE_CONTROLS_HOVER;
106
94
  break;
107
95
  }
108
-
109
96
  return Decoration.node(pos, pos + cell.nodeSize, {
110
97
  class: classes.join(' ')
111
98
  }, {
@@ -120,11 +107,9 @@ export const createColumnSelectedDecoration = tr => {
120
107
  } = tr;
121
108
  const table = findTable(selection);
122
109
  const rect = getSelectionRect(selection);
123
-
124
110
  if (!table || !rect) {
125
111
  return [];
126
112
  }
127
-
128
113
  const map = TableMap.get(table.node);
129
114
  const cellPositions = map.cellsInRect(rect);
130
115
  return cellPositions.map((pos, index) => {
@@ -140,12 +125,13 @@ export const createColumnControlsDecoration = selection => {
140
125
  const cells = getCellsInRow(0)(selection) || [];
141
126
  let index = 0;
142
127
  return cells.map(cell => {
143
- const colspan = cell.node.attrs.colspan || 1; // It's important these values are scoped locally as the widget callback could be executed anytime in the future
128
+ const colspan = cell.node.attrs.colspan || 1;
129
+ // It's important these values are scoped locally as the widget callback could be executed anytime in the future
144
130
  // and we want to avoid value leak
145
-
146
131
  const startIndex = index;
147
- const endIndex = startIndex + colspan; // The next cell start index will commence from the current cell end index.
132
+ const endIndex = startIndex + colspan;
148
133
 
134
+ // The next cell start index will commence from the current cell end index.
149
135
  index = endIndex;
150
136
  return Decoration.widget(cell.pos + 1, () => {
151
137
  const element = document.createElement('div');
@@ -165,8 +151,8 @@ export const updateDecorations = (node, decorationSet, decorations, key) => {
165
151
  const decorationSetFiltered = decorationSet.remove(filteredDecorations);
166
152
  return decorationSetFiltered.add(node, decorations);
167
153
  };
168
-
169
154
  const makeArray = n => Array.from(Array(n).keys());
155
+
170
156
  /*
171
157
  * This function will create two specific decorations for each cell in a column index target,
172
158
  * for example given that table:
@@ -246,22 +232,16 @@ const makeArray = n => Array.from(Array(n).keys());
246
232
  * we will add a new class on the last item for each cell,
247
233
  * hence the second media will receive this class `ClassName.LAST_ITEM_IN_CELL`
248
234
  */
249
-
250
-
251
235
  export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexTarget) => {
252
236
  const emptyResult = [[], []];
253
237
  const table = findTable(tr.selection);
254
-
255
238
  if (!table || !table.node) {
256
239
  return emptyResult;
257
240
  }
258
-
259
241
  const map = TableMap.get(table.node);
260
-
261
242
  if (!map.width) {
262
243
  return emptyResult;
263
244
  }
264
-
265
245
  const createResizerHandleDecoration = (cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode) => {
266
246
  const position = cellPos + cellNode.nodeSize - 1;
267
247
  return Decoration.widget(position, () => {
@@ -274,7 +254,6 @@ export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexT
274
254
  key: `${TableDecorations.COLUMN_RESIZING_HANDLE}_${rowIndex}_${columnIndex}`
275
255
  });
276
256
  };
277
-
278
257
  const createLastCellElementDecoration = (cellColumnPositioning, cellPos, cellNode) => {
279
258
  let lastItemPositions;
280
259
  cellNode.forEach((childNode, offset, index) => {
@@ -286,51 +265,39 @@ export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexT
286
265
  };
287
266
  }
288
267
  });
289
-
290
268
  if (!lastItemPositions) {
291
269
  return null;
292
270
  }
293
-
294
271
  return Decoration.node(lastItemPositions.from, lastItemPositions.to, {
295
272
  class: ClassName.LAST_ITEM_IN_CELL
296
273
  }, {
297
274
  key: `${TableDecorations.LAST_CELL_ELEMENT}_${cellColumnPositioning.left}_${cellColumnPositioning.right}`
298
275
  });
299
276
  };
300
-
301
277
  const resizeHandleCellDecorations = [];
302
278
  const lastCellElementsDecorations = [];
303
-
304
279
  for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
305
280
  const seen = {};
306
-
307
281
  if (rowIndex !== rowIndexTarget) {
308
282
  continue;
309
283
  }
310
-
311
284
  for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
312
285
  const cellPosition = map.map[map.width * rowIndex + columnIndex];
313
-
314
286
  if (seen[cellPosition]) {
315
287
  continue;
316
288
  }
317
-
318
289
  seen[cellPosition] = true;
319
290
  const cellPos = table.start + cellPosition;
320
291
  const cell = tr.doc.nodeAt(cellPos);
321
-
322
292
  if (!cell) {
323
293
  continue;
324
294
  }
325
-
326
295
  const colspan = cell.attrs.colspan || 1;
327
296
  const startIndex = columnIndex;
328
297
  const endIndex = colspan + startIndex;
329
-
330
298
  if (endIndex !== columnEndIndexTarget.right) {
331
299
  continue;
332
300
  }
333
-
334
301
  const resizerHandleDec = createResizerHandleDecoration({
335
302
  left: startIndex,
336
303
  right: endIndex
@@ -343,9 +310,9 @@ export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexT
343
310
  lastCellElementsDecorations.push(lastCellDec);
344
311
  }
345
312
  }
346
-
347
313
  return [resizeHandleCellDecorations, lastCellElementsDecorations.filter(nonNullable)];
348
314
  };
315
+
349
316
  /*
350
317
  * This function will create a decoration for each cell using the right position on the CellColumnPositioning
351
318
  * for example given that table:
@@ -388,22 +355,17 @@ export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexT
388
355
  * this function will return two decorations applying a new class `ClassName.WITH_RESIZE_LINE`
389
356
  * only on the cells: `C1` and `D1`.
390
357
  */
391
-
392
358
  export const createColumnLineResize = (selection, cellColumnPositioning) => {
393
359
  const table = findTable(selection);
394
-
395
360
  if (!table || cellColumnPositioning.right === null) {
396
361
  return [];
397
362
  }
398
-
399
363
  let columnIndex = cellColumnPositioning.right;
400
364
  const map = TableMap.get(table.node);
401
365
  const isLastColumn = columnIndex === map.width;
402
-
403
366
  if (isLastColumn) {
404
367
  columnIndex -= 1;
405
368
  }
406
-
407
369
  const decorationClassName = isLastColumn ? ClassName.WITH_RESIZE_LINE_LAST_COLUMN : ClassName.WITH_RESIZE_LINE;
408
370
  const cellPositions = makeArray(map.height).map(rowIndex => map.map[map.width * rowIndex + columnIndex]).filter((cellPosition, rowIndex) => {
409
371
  if (isLastColumn) {
@@ -413,6 +375,7 @@ export const createColumnLineResize = (selection, cellColumnPositioning) => {
413
375
  const nextPosition = map.map[map.width * rowIndex + columnIndex - 1];
414
376
  return cellPosition !== nextPosition; // Removed it if next position is merged
415
377
  });
378
+
416
379
  const cells = cellPositions.map(pos => ({
417
380
  pos: pos + table.start,
418
381
  node: table.node.nodeAt(pos)
@@ -421,7 +384,6 @@ export const createColumnLineResize = (selection, cellColumnPositioning) => {
421
384
  if (!cell || !cell.node) {
422
385
  return;
423
386
  }
424
-
425
387
  return Decoration.node(cell.pos, cell.pos + cell.node.nodeSize, {
426
388
  class: decorationClassName
427
389
  }, {
@@ -13,6 +13,7 @@ export const isRowControlsButton = node => containsClassName(node, ClassName.ROW
13
13
  export const isResizeHandleDecoration = node => containsClassName(node, ClassName.RESIZE_HANDLE_DECORATION);
14
14
  export const isTableControlsButton = node => containsClassName(node, ClassName.CONTROLS_BUTTON) || containsClassName(node, ClassName.ROW_CONTROLS_BUTTON_WRAP);
15
15
  export const isTableContainerOrWrapper = node => containsClassName(node, ClassName.TABLE_CONTAINER) || containsClassName(node, ClassName.TABLE_NODE_WRAPPER);
16
+
16
17
  /*
17
18
  * This function returns which side of a given element the mouse cursor is,
18
19
  * using as a base the half of the width by default, for example:
@@ -69,14 +70,11 @@ export const isTableContainerOrWrapper = node => containsClassName(node, ClassNa
69
70
 
70
71
  export const getMousePositionHorizontalRelativeByElement = (mouseEvent, mouseMoveOptimization, elementContentRects, gapInPixels) => {
71
72
  const element = mouseEvent.target;
72
-
73
73
  if (element instanceof HTMLElement) {
74
74
  let width, x;
75
75
  const closestCell = element.closest(SELECTOR_TABLE_LEAFS);
76
-
77
76
  if (mouseMoveOptimization) {
78
77
  var _closestCell$id, _elementContentRects$, _elementContentRects$2;
79
-
80
78
  const id = (_closestCell$id = closestCell === null || closestCell === void 0 ? void 0 : closestCell.id) !== null && _closestCell$id !== void 0 ? _closestCell$id : '';
81
79
  width = (_elementContentRects$ = elementContentRects === null || elementContentRects === void 0 ? void 0 : (_elementContentRects$2 = elementContentRects[id]) === null || _elementContentRects$2 === void 0 ? void 0 : _elementContentRects$2.width) !== null && _elementContentRects$ !== void 0 ? _elementContentRects$ : 0;
82
80
  x = mouseEvent.offsetX;
@@ -86,11 +84,9 @@ export const getMousePositionHorizontalRelativeByElement = (mouseEvent, mouseMov
86
84
  const left = elementRect.left;
87
85
  x = mouseEvent.clientX - left;
88
86
  }
89
-
90
87
  if (width <= 0) {
91
88
  return null;
92
89
  }
93
-
94
90
  if (!gapInPixels) {
95
91
  return x / width > 0.5 ? 'right' : 'left';
96
92
  } else {
@@ -101,38 +97,30 @@ export const getMousePositionHorizontalRelativeByElement = (mouseEvent, mouseMov
101
97
  }
102
98
  }
103
99
  }
104
-
105
100
  return null;
106
101
  };
107
102
  export const getMousePositionVerticalRelativeByElement = mouseEvent => {
108
103
  const element = mouseEvent.target;
109
-
110
104
  if (element instanceof HTMLElement) {
111
105
  const elementRect = element.getBoundingClientRect();
112
-
113
106
  if (elementRect.height <= 0) {
114
107
  return null;
115
108
  }
116
-
117
109
  const y = mouseEvent.clientY - elementRect.top;
118
110
  return y / elementRect.height > 0.5 ? 'bottom' : 'top';
119
111
  }
120
-
121
112
  return null;
122
113
  };
123
114
  export const updateResizeHandles = tableRef => {
124
115
  if (!tableRef) {
125
116
  return;
126
117
  }
127
-
128
- const height = tableRef.offsetHeight + tableToolbarSize; // see ED-7600
129
-
118
+ const height = tableRef.offsetHeight + tableToolbarSize;
119
+ // see ED-7600
130
120
  const nodes = Array.from(tableRef.querySelectorAll(`.${ClassName.RESIZE_HANDLE}`));
131
-
132
121
  if (!nodes || !nodes.length) {
133
122
  return;
134
123
  }
135
-
136
124
  nodes.forEach(node => {
137
125
  node.style.height = `${height}px`;
138
126
  });
@@ -142,17 +130,13 @@ export const hasResizeHandler = ({
142
130
  target
143
131
  }) => {
144
132
  const tableElement = closestElement(target, 'table');
145
-
146
133
  if (!tableElement) {
147
134
  return false;
148
135
  }
149
-
150
136
  const query = [`.${ClassName.RESIZE_HANDLE_DECORATION}`, `[data-end-index="${columnEndIndexTarget}"]`];
151
137
  const decorationElement = tableElement.querySelectorAll(query.join(''));
152
-
153
138
  if (!decorationElement || decorationElement.length === 0) {
154
139
  return false;
155
140
  }
156
-
157
141
  return true;
158
142
  };
@@ -6,19 +6,17 @@ export const isIsolating = node => {
6
6
  return !!node.type.spec.isolating;
7
7
  };
8
8
  export const containsHeaderColumn = table => {
9
- const map = TableMap.get(table); // Get cell positions for first column.
10
-
9
+ const map = TableMap.get(table);
10
+ // Get cell positions for first column.
11
11
  const cellPositions = map.cellsInRect({
12
12
  left: 0,
13
13
  top: 0,
14
14
  right: 1,
15
15
  bottom: map.height
16
16
  });
17
-
18
17
  for (let i = 0; i < cellPositions.length; i++) {
19
18
  try {
20
19
  const cell = table.nodeAt(cellPositions[i]);
21
-
22
20
  if (cell && cell.type !== table.type.schema.nodes.tableHeader) {
23
21
  return false;
24
22
  }
@@ -26,20 +24,16 @@ export const containsHeaderColumn = table => {
26
24
  return false;
27
25
  }
28
26
  }
29
-
30
27
  return true;
31
28
  };
32
29
  export const containsHeaderRow = table => {
33
30
  const map = TableMap.get(table);
34
-
35
31
  for (let i = 0; i < map.width; i++) {
36
32
  const cell = table.nodeAt(map.map[i]);
37
-
38
33
  if (cell && cell.type !== table.type.schema.nodes.tableHeader) {
39
34
  return false;
40
35
  }
41
36
  }
42
-
43
37
  return true;
44
38
  };
45
39
  export const checkIfHeaderColumnEnabled = selection => filterNearSelection(selection, findTable, containsHeaderColumn, false);
@@ -62,11 +56,9 @@ export const getTableWidth = node => {
62
56
  export const tablesHaveDifferentColumnWidths = (currentTable, previousTable) => {
63
57
  let currentTableWidths = getTableWidths(currentTable);
64
58
  let previousTableWidths = getTableWidths(previousTable);
65
-
66
59
  if (currentTableWidths.length !== previousTableWidths.length) {
67
60
  return true;
68
61
  }
69
-
70
62
  const sameWidths = currentTableWidths.every((value, index) => {
71
63
  return value === previousTableWidths[index];
72
64
  });
@@ -77,22 +69,17 @@ export const tablesHaveDifferentNoOfColumns = (currentTable, previousTable) => {
77
69
  const currentMap = TableMap.get(currentTable);
78
70
  return prevMap.width !== currentMap.width;
79
71
  };
80
-
81
72
  function filterNearSelection(selection, findNode, predicate, defaultValue) {
82
73
  const found = findNode(selection);
83
-
84
74
  if (!found) {
85
75
  return defaultValue;
86
76
  }
87
-
88
77
  return predicate(found.node, found.pos);
89
78
  }
90
-
91
79
  function getTableWidths(node) {
92
80
  if (!node.content.firstChild) {
93
81
  return [];
94
82
  }
95
-
96
83
  let tableWidths = [];
97
84
  node.content.firstChild.content.forEach(cell => {
98
85
  if (Array.isArray(cell.attrs.colwidth)) {