@atlaskit/editor-plugin-table 1.1.1 → 1.1.3

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 (305) hide show
  1. package/CHANGELOG.md +18 -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 +95 -191
  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 +18 -43
  46. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +20 -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 +16 -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 +51 -40
  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 +17 -73
  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 +58 -49
  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 +10 -22
  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 +40 -103
  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 +14 -17
  144. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +13 -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 +14 -3
  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 +46 -21
  153. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +31 -61
  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 +60 -32
  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 +11 -7
  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 +95 -184
  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 +18 -25
  230. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +20 -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 +14 -3
  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 +49 -26
  239. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +17 -62
  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 +58 -36
  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 +9 -10
  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/dist/types/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +7 -0
  284. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +2 -1
  285. package/dist/types/plugins/table/ui/common-styles.d.ts +1 -0
  286. package/package.json +8 -6
  287. package/src/__tests__/integration/__fixtures__/empty-layout.ts +35 -0
  288. package/src/__tests__/integration/__fixtures__/nested-in-expand.ts +129 -0
  289. package/src/__tests__/integration/horizontal-scroll.ts +489 -0
  290. package/src/__tests__/unit/commands/insert.ts +3 -3
  291. package/src/__tests__/unit/keymap.ts +3 -1
  292. package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +38 -0
  293. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +5 -2
  294. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +2 -2
  295. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +2 -2
  296. package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-2-snap.png +2 -2
  297. package/src/__tests__/visual-regression/sticky-header.ts +2 -1
  298. package/src/plugins/table/nodeviews/TableComponent.tsx +16 -3
  299. package/src/plugins/table/pm-plugins/table-resizing/commands.ts +6 -2
  300. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +9 -1
  301. package/src/plugins/table/pm-plugins/table-resizing/utils/colgroup.ts +19 -1
  302. package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +57 -5
  303. package/src/plugins/table/pm-plugins/table-resizing/utils/resize-logic.ts +2 -2
  304. package/src/plugins/table/transforms/column-width.ts +60 -6
  305. package/src/plugins/table/ui/common-styles.ts +5 -2
@@ -1,46 +1,33 @@
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.isColumnDeleteButtonVisible = exports.getColumnsWidths = exports.getColumnDeleteButtonParams = exports.getColumnClassNames = exports.colWidthsForRow = void 0;
9
-
10
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
9
  var _tableMap = require("@atlaskit/editor-tables/table-map");
13
-
14
10
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
15
-
16
11
  var _prosemirrorUtils = require("prosemirror-utils");
17
-
18
12
  var _utils = require("@atlaskit/editor-tables/utils");
19
-
20
13
  var _utils2 = require("@atlaskit/editor-common/utils");
21
-
22
14
  var _types = require("../types");
23
-
24
15
  var _consts = require("../ui/consts");
25
-
26
16
  var getColumnsWidths = function getColumnsWidths(view) {
27
17
  var selection = view.state.selection;
28
18
  var widths = [];
29
19
  var table = (0, _utils.findTable)(selection);
30
-
31
20
  if (table) {
32
21
  var map = _tableMap.TableMap.get(table.node);
22
+ var domAtPos = view.domAtPos.bind(view);
33
23
 
34
- var domAtPos = view.domAtPos.bind(view); // When there is no cell we need to fill it with undefined
35
-
24
+ // When there is no cell we need to fill it with undefined
36
25
  widths = Array.from({
37
26
  length: map.width
38
27
  });
39
-
40
28
  for (var i = 0; i < map.width; i++) {
41
29
  var cells = (0, _utils.getCellsInColumn)(i)(selection);
42
30
  var cell = cells[0];
43
-
44
31
  if (cell) {
45
32
  var cellRef = (0, _prosemirrorUtils.findDomRefAtPos)(cell.pos, domAtPos);
46
33
  var rect = cellRef.getBoundingClientRect();
@@ -49,82 +36,63 @@ var getColumnsWidths = function getColumnsWidths(view) {
49
36
  }
50
37
  }
51
38
  }
52
-
53
39
  return widths;
54
40
  };
55
-
56
41
  exports.getColumnsWidths = getColumnsWidths;
57
-
58
42
  var isColumnDeleteButtonVisible = function isColumnDeleteButtonVisible(selection) {
59
43
  if (!(0, _utils.isTableSelected)(selection) && selection instanceof _cellSelection.CellSelection && selection.isColSelection()) {
60
44
  return true;
61
45
  }
62
-
63
46
  return false;
64
47
  };
65
-
66
48
  exports.isColumnDeleteButtonVisible = isColumnDeleteButtonVisible;
67
-
68
49
  var getColumnDeleteButtonParams = function getColumnDeleteButtonParams(columnsWidths, selection) {
69
50
  var rect = (0, _utils.getSelectionRect)(selection);
70
-
71
51
  if (!rect) {
72
52
  return null;
73
53
  }
74
-
75
54
  var width = 0;
76
- var offset = 0; // find the columns before the selection
77
-
55
+ var offset = 0;
56
+ // find the columns before the selection
78
57
  for (var i = 0; i < rect.left; i++) {
79
58
  var colWidth = columnsWidths[i];
80
-
81
59
  if (colWidth) {
82
60
  offset += colWidth - 1;
83
61
  }
84
- } // these are the selected columns widths
85
-
86
-
62
+ }
63
+ // these are the selected columns widths
87
64
  var indexes = [];
88
-
89
65
  for (var _i = rect.left; _i < rect.right; _i++) {
90
66
  var _colWidth = columnsWidths[_i];
91
-
92
67
  if (_colWidth) {
93
68
  width += _colWidth;
94
69
  indexes.push(_i);
95
70
  }
96
71
  }
97
-
98
72
  var left = offset + width / 2 - _consts.tableDeleteButtonSize / 2;
99
73
  return {
100
74
  left: left,
101
75
  indexes: indexes
102
76
  };
103
77
  };
104
-
105
78
  exports.getColumnDeleteButtonParams = getColumnDeleteButtonParams;
106
-
107
79
  var getColumnClassNames = function getColumnClassNames(index, selection) {
108
80
  var hoveredColumns = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
109
81
  var isInDanger = arguments.length > 3 ? arguments[3] : undefined;
110
82
  var isResizing = arguments.length > 4 ? arguments[4] : undefined;
111
83
  var classNames = [];
112
-
113
84
  if ((0, _utils.isColumnSelected)(index)(selection) || hoveredColumns.indexOf(index) > -1 && !isResizing) {
114
85
  classNames.push(_types.TableCssClassName.HOVERED_CELL_ACTIVE);
115
-
116
86
  if (isInDanger) {
117
87
  classNames.push(_types.TableCssClassName.HOVERED_CELL_IN_DANGER);
118
88
  }
119
89
  }
120
-
121
90
  return classNames.join(' ');
122
- }; // give a row colspan and a colwidths
123
- // and map to a row's colwidths
124
-
91
+ };
125
92
 
93
+ // give a row colspan and a colwidths
94
+ // and map to a row's colwidths
126
95
  exports.getColumnClassNames = getColumnClassNames;
127
-
128
96
  var mapTableColwidthsToRow = function mapTableColwidthsToRow(rowColSpans, tableColWidths) {
129
97
  var curColIdx = 0;
130
98
  var colWidths = [];
@@ -137,12 +105,10 @@ var mapTableColwidthsToRow = function mapTableColwidthsToRow(rowColSpans, tableC
137
105
  });
138
106
  return colWidths;
139
107
  };
140
-
141
108
  var getRelativeDomCellWidths = function getRelativeDomCellWidths(_ref) {
142
109
  var width = _ref.width,
143
- colspan = _ref.colspan,
144
- colwidth = _ref.colwidth;
145
-
110
+ colspan = _ref.colspan,
111
+ colwidth = _ref.colwidth;
146
112
  // For cells with colSpan 1
147
113
  // or
148
114
  // for cells in a table with unchanged column widths,
@@ -150,20 +116,22 @@ var getRelativeDomCellWidths = function getRelativeDomCellWidths(_ref) {
150
116
  // return equally partitioned total cell width in DOM for each cell.
151
117
  if (colspan === 1 || !colwidth) {
152
118
  return new Array(colspan).fill(width / colspan);
153
- } // For cells that have colSpan > 1 and
119
+ }
120
+
121
+ // For cells that have colSpan > 1 and
154
122
  // are part of a table with resized columns
155
123
  // return the current total DOM width of the cell multiplied
156
124
  // by the percentage of the each individual cell's size.
157
125
  // The cell size percentage is calculated using individual colwidth of the cell,
158
126
  // from data-colwidth attribute on the cell,
159
127
  // divided by the total width of the cells from colwidths for merged cells.
128
+
160
129
  // Ex:
161
130
  // colwidth = ‘201,102’
162
131
  // Total colWidth = 303
163
132
  // returned cellWidths = [303 * (201/303), 303 * (102/303)]
164
- // For merged cells we get back colwidth as `201,102`
165
-
166
133
 
134
+ // For merged cells we get back colwidth as `201,102`
167
135
  var cellColWidths = colwidth.split(',').map(function (colwidth) {
168
136
  return Number(colwidth);
169
137
  });
@@ -174,14 +142,13 @@ var getRelativeDomCellWidths = function getRelativeDomCellWidths(_ref) {
174
142
  return width * (cellColWidth / totalCalculatedCellWidth);
175
143
  });
176
144
  };
177
-
178
145
  var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
179
146
  // get the colspans
180
147
  var rowColSpans = (0, _utils2.maphElem)(tr, function (cell) {
181
- return Number(cell.getAttribute('colspan') || 1
182
- /* default to span of 1 */
183
- );
184
- }); // Chrome has trouble aligning borders with auto tables
148
+ return Number(cell.getAttribute('colspan') || 1 /* default to span of 1 */);
149
+ });
150
+
151
+ // Chrome has trouble aligning borders with auto tables
185
152
  // and the rest of the page grid. tables with defined
186
153
  // column widths align fine.
187
154
  //
@@ -189,9 +156,7 @@ var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
189
156
  //
190
157
  // prefer copying the widths via the DOM
191
158
  // or inferring from the next row if one exists
192
-
193
159
  var copyTarget = tr.nextElementSibling || tr;
194
-
195
160
  if (copyTarget) {
196
161
  // either from the first row while it's still in the table
197
162
  var cellInfos = (0, _utils2.maphElem)(copyTarget, function (cell) {
@@ -200,13 +165,13 @@ var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
200
165
  colspan: Number(cell.getAttribute('colspan') || 1),
201
166
  colwidth: cell.dataset.colwidth
202
167
  };
203
- }); // reverse engineer cell widths from table widths
168
+ });
204
169
 
170
+ // reverse engineer cell widths from table widths
205
171
  var domBasedCellWidths = [];
206
172
  cellInfos.map(function (cell, idx) {
207
173
  domBasedCellWidths.push.apply(domBasedCellWidths, (0, _toConsumableArray2.default)(getRelativeDomCellWidths(cell)));
208
174
  });
209
-
210
175
  if (cellInfos.reduce(function (acc, cell) {
211
176
  return acc + cell.width;
212
177
  }, 0) !== 0) {
@@ -215,10 +180,10 @@ var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
215
180
  return "".concat(px, "px");
216
181
  }).join(' ');
217
182
  }
218
- } // as a fallback, just calculate a %, and hope that
219
- // it aligns perfectly in the user's browser
220
-
183
+ }
221
184
 
185
+ // as a fallback, just calculate a %, and hope that
186
+ // it aligns perfectly in the user's browser
222
187
  var visualColCount = rowColSpans.reduce(function (acc, val) {
223
188
  return acc + val;
224
189
  }, 0);
@@ -229,5 +194,4 @@ var colWidthsForRow = function colWidthsForRow(colGroup, tr) {
229
194
  return "".concat(pct, "%");
230
195
  }).join(' ');
231
196
  };
232
-
233
197
  exports.colWidthsForRow = colWidthsForRow;
@@ -1,42 +1,29 @@
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.updateDecorations = exports.findControlsHoverDecoration = exports.findColumnControlSelectedDecoration = exports.createResizeHandleDecoration = exports.createControlsHoverDecoration = exports.createColumnSelectedDecoration = exports.createColumnLineResize = exports.createColumnControlsDecoration = exports.createCellHoverDecoration = void 0;
9
-
10
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
9
  var _tableMap = require("@atlaskit/editor-tables/table-map");
13
-
14
10
  var _utils = require("@atlaskit/editor-tables/utils");
15
-
16
11
  var _prosemirrorView = require("prosemirror-view");
17
-
18
12
  var _utils2 = require("@atlaskit/editor-common/utils");
19
-
20
13
  var _types = require("../types");
21
-
22
14
  var filterDecorationByKey = function filterDecorationByKey(key, decorationSet) {
23
15
  return decorationSet.find(undefined, undefined, function (spec) {
24
16
  return spec.key.indexOf(key) > -1;
25
17
  });
26
18
  };
27
-
28
19
  var findColumnControlSelectedDecoration = function findColumnControlSelectedDecoration(decorationSet) {
29
20
  return filterDecorationByKey(_types.TableDecorations.COLUMN_SELECTED, decorationSet);
30
21
  };
31
-
32
22
  exports.findColumnControlSelectedDecoration = findColumnControlSelectedDecoration;
33
-
34
23
  var findControlsHoverDecoration = function findControlsHoverDecoration(decorationSet) {
35
24
  return filterDecorationByKey(_types.TableDecorations.ALL_CONTROLS_HOVER, decorationSet);
36
25
  };
37
-
38
26
  exports.findControlsHoverDecoration = findControlsHoverDecoration;
39
-
40
27
  var createCellHoverDecoration = function createCellHoverDecoration(cells, type) {
41
28
  return cells.map(function (cell) {
42
29
  return _prosemirrorView.Decoration.node(cell.pos, cell.pos + cell.node.nodeSize, {
@@ -46,44 +33,36 @@ var createCellHoverDecoration = function createCellHoverDecoration(cells, type)
46
33
  });
47
34
  });
48
35
  };
49
-
50
36
  exports.createCellHoverDecoration = createCellHoverDecoration;
51
-
52
37
  var createControlsHoverDecoration = function createControlsHoverDecoration(cells, type, tr, danger, selected) {
53
38
  var table = (0, _utils.findTable)(tr.selection);
54
-
55
39
  if (!table) {
56
40
  return [];
57
41
  }
58
-
59
42
  var map = _tableMap.TableMap.get(table.node);
60
-
61
43
  var _cells$reduce = cells.reduce(function (_ref, cell) {
62
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
44
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
63
45
  min = _ref2[0],
64
46
  max = _ref2[1];
65
-
66
- if (min === null || cell.pos < min) {
67
- min = cell.pos;
68
- }
69
-
70
- if (max === null || cell.pos > max) {
71
- max = cell.pos;
72
- }
73
-
74
- return [min, max];
75
- }, [null, null]),
76
- _cells$reduce2 = (0, _slicedToArray2.default)(_cells$reduce, 2),
77
- min = _cells$reduce2[0],
78
- max = _cells$reduce2[1];
79
-
47
+ if (min === null || cell.pos < min) {
48
+ min = cell.pos;
49
+ }
50
+ if (max === null || cell.pos > max) {
51
+ max = cell.pos;
52
+ }
53
+ return [min, max];
54
+ }, [null, null]),
55
+ _cells$reduce2 = (0, _slicedToArray2.default)(_cells$reduce, 2),
56
+ min = _cells$reduce2[0],
57
+ max = _cells$reduce2[1];
80
58
  if (min === null || max === null) {
81
59
  return [];
82
60
  }
83
-
84
61
  var updatedCells = cells.map(function (x) {
85
62
  return x.pos;
86
- }); // ED-15246 fixed trello card table overflow issue
63
+ });
64
+
65
+ // ED-15246 fixed trello card table overflow issue
87
66
  // If columns / rows have been merged the hovered selection is different to the actual selection
88
67
  // So If the table cells are in danger we want to create a "rectangle" selection
89
68
  // to match the "clicked" selection
@@ -92,68 +71,59 @@ var createControlsHoverDecoration = function createControlsHoverDecoration(cells
92
71
  // Find the bounding rectangle of all the given cells, also considering
93
72
  // merged cells.
94
73
  var _cells$reduce3 = cells.reduce(function (acc, cell) {
95
- var _map$findCell = map.findCell(cell.pos - table.start),
74
+ var _map$findCell = map.findCell(cell.pos - table.start),
96
75
  left = _map$findCell.left,
97
76
  right = _map$findCell.right,
98
77
  bottom = _map$findCell.bottom,
99
- top = _map$findCell.top; // Finding the bounding rect requires finding the min left and top positions,
100
- // and the max right and bottom positions of the cells
101
-
102
-
103
- return {
104
- recLeft: Math.min(acc.recLeft, left),
105
- recTop: Math.min(acc.recTop, top),
106
- recRight: Math.max(acc.recRight, right),
107
- recBottom: Math.max(acc.recBottom, bottom)
108
- };
109
- }, // +-Infinity as initialisation vars which will always be overwritten
110
- // by smaller/larger values respectively
111
- {
112
- recLeft: Infinity,
113
- recTop: Infinity,
114
- recRight: -Infinity,
115
- recBottom: -Infinity
116
- }),
117
- recLeft = _cells$reduce3.recLeft,
118
- recTop = _cells$reduce3.recTop,
119
- recRight = _cells$reduce3.recRight,
120
- recBottom = _cells$reduce3.recBottom;
121
-
78
+ top = _map$findCell.top;
79
+ // Finding the bounding rect requires finding the min left and top positions,
80
+ // and the max right and bottom positions of the cells
81
+ return {
82
+ recLeft: Math.min(acc.recLeft, left),
83
+ recTop: Math.min(acc.recTop, top),
84
+ recRight: Math.max(acc.recRight, right),
85
+ recBottom: Math.max(acc.recBottom, bottom)
86
+ };
87
+ },
88
+ // +-Infinity as initialisation vars which will always be overwritten
89
+ // by smaller/larger values respectively
90
+ {
91
+ recLeft: Infinity,
92
+ recTop: Infinity,
93
+ recRight: -Infinity,
94
+ recBottom: -Infinity
95
+ }),
96
+ recLeft = _cells$reduce3.recLeft,
97
+ recTop = _cells$reduce3.recTop,
98
+ recRight = _cells$reduce3.recRight,
99
+ recBottom = _cells$reduce3.recBottom;
122
100
  var rect = new _tableMap.Rect(recLeft, recTop, recRight, recBottom);
123
101
  updatedCells = map.cellsInRect(rect).map(function (x) {
124
102
  return x + table.start;
125
103
  });
126
104
  }
127
-
128
105
  return updatedCells.map(function (pos) {
129
106
  var cell = tr.doc.nodeAt(pos);
130
107
  var classes = [_types.TableCssClassName.HOVERED_CELL];
131
-
132
108
  if (danger) {
133
109
  classes.push(_types.TableCssClassName.HOVERED_CELL_IN_DANGER);
134
110
  }
135
-
136
111
  if (selected) {
137
112
  classes.push(_types.TableCssClassName.SELECTED_CELL);
138
113
  }
139
-
140
114
  classes.push(type === 'column' ? _types.TableCssClassName.HOVERED_COLUMN : type === 'row' ? _types.TableCssClassName.HOVERED_ROW : _types.TableCssClassName.HOVERED_TABLE);
141
115
  var key;
142
-
143
116
  switch (type) {
144
117
  case 'row':
145
118
  key = _types.TableDecorations.ROW_CONTROLS_HOVER;
146
119
  break;
147
-
148
120
  case 'column':
149
121
  key = _types.TableDecorations.COLUMN_CONTROLS_HOVER;
150
122
  break;
151
-
152
123
  default:
153
124
  key = _types.TableDecorations.TABLE_CONTROLS_HOVER;
154
125
  break;
155
126
  }
156
-
157
127
  return _prosemirrorView.Decoration.node(pos, pos + cell.nodeSize, {
158
128
  class: classes.join(' ')
159
129
  }, {
@@ -161,21 +131,16 @@ var createControlsHoverDecoration = function createControlsHoverDecoration(cells
161
131
  });
162
132
  });
163
133
  };
164
-
165
134
  exports.createControlsHoverDecoration = createControlsHoverDecoration;
166
-
167
135
  var createColumnSelectedDecoration = function createColumnSelectedDecoration(tr) {
168
136
  var selection = tr.selection,
169
- doc = tr.doc;
137
+ doc = tr.doc;
170
138
  var table = (0, _utils.findTable)(selection);
171
139
  var rect = (0, _utils.getSelectionRect)(selection);
172
-
173
140
  if (!table || !rect) {
174
141
  return [];
175
142
  }
176
-
177
143
  var map = _tableMap.TableMap.get(table.node);
178
-
179
144
  var cellPositions = map.cellsInRect(rect);
180
145
  return cellPositions.map(function (pos, index) {
181
146
  var cell = doc.nodeAt(pos + table.start);
@@ -186,19 +151,18 @@ var createColumnSelectedDecoration = function createColumnSelectedDecoration(tr)
186
151
  });
187
152
  });
188
153
  };
189
-
190
154
  exports.createColumnSelectedDecoration = createColumnSelectedDecoration;
191
-
192
155
  var createColumnControlsDecoration = function createColumnControlsDecoration(selection) {
193
156
  var cells = (0, _utils.getCellsInRow)(0)(selection) || [];
194
157
  var index = 0;
195
158
  return cells.map(function (cell) {
196
- var 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
159
+ var colspan = cell.node.attrs.colspan || 1;
160
+ // It's important these values are scoped locally as the widget callback could be executed anytime in the future
197
161
  // and we want to avoid value leak
198
-
199
162
  var startIndex = index;
200
- var endIndex = startIndex + colspan; // The next cell start index will commence from the current cell end index.
163
+ var endIndex = startIndex + colspan;
201
164
 
165
+ // The next cell start index will commence from the current cell end index.
202
166
  index = endIndex;
203
167
  return _prosemirrorView.Decoration.widget(cell.pos + 1, function () {
204
168
  var element = document.createElement('div');
@@ -213,20 +177,17 @@ var createColumnControlsDecoration = function createColumnControlsDecoration(sel
213
177
  });
214
178
  });
215
179
  };
216
-
217
180
  exports.createColumnControlsDecoration = createColumnControlsDecoration;
218
-
219
181
  var updateDecorations = function updateDecorations(node, decorationSet, decorations, key) {
220
182
  var filteredDecorations = filterDecorationByKey(key, decorationSet);
221
183
  var decorationSetFiltered = decorationSet.remove(filteredDecorations);
222
184
  return decorationSetFiltered.add(node, decorations);
223
185
  };
224
-
225
186
  exports.updateDecorations = updateDecorations;
226
-
227
187
  var makeArray = function makeArray(n) {
228
188
  return Array.from(Array(n).keys());
229
189
  };
190
+
230
191
  /*
231
192
  * This function will create two specific decorations for each cell in a column index target,
232
193
  * for example given that table:
@@ -306,22 +267,16 @@ var makeArray = function makeArray(n) {
306
267
  * we will add a new class on the last item for each cell,
307
268
  * hence the second media will receive this class `ClassName.LAST_ITEM_IN_CELL`
308
269
  */
309
-
310
-
311
270
  var createResizeHandleDecoration = function createResizeHandleDecoration(tr, rowIndexTarget, columnEndIndexTarget) {
312
271
  var emptyResult = [[], []];
313
272
  var table = (0, _utils.findTable)(tr.selection);
314
-
315
273
  if (!table || !table.node) {
316
274
  return emptyResult;
317
275
  }
318
-
319
276
  var map = _tableMap.TableMap.get(table.node);
320
-
321
277
  if (!map.width) {
322
278
  return emptyResult;
323
279
  }
324
-
325
280
  var createResizerHandleDecoration = function createResizerHandleDecoration(cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode) {
326
281
  var position = cellPos + cellNode.nodeSize - 1;
327
282
  return _prosemirrorView.Decoration.widget(position, function () {
@@ -334,7 +289,6 @@ var createResizeHandleDecoration = function createResizeHandleDecoration(tr, row
334
289
  key: "".concat(_types.TableDecorations.COLUMN_RESIZING_HANDLE, "_").concat(rowIndex, "_").concat(columnIndex)
335
290
  });
336
291
  };
337
-
338
292
  var createLastCellElementDecoration = function createLastCellElementDecoration(cellColumnPositioning, cellPos, cellNode) {
339
293
  var lastItemPositions;
340
294
  cellNode.forEach(function (childNode, offset, index) {
@@ -346,51 +300,39 @@ var createResizeHandleDecoration = function createResizeHandleDecoration(tr, row
346
300
  };
347
301
  }
348
302
  });
349
-
350
303
  if (!lastItemPositions) {
351
304
  return null;
352
305
  }
353
-
354
306
  return _prosemirrorView.Decoration.node(lastItemPositions.from, lastItemPositions.to, {
355
307
  class: _types.TableCssClassName.LAST_ITEM_IN_CELL
356
308
  }, {
357
309
  key: "".concat(_types.TableDecorations.LAST_CELL_ELEMENT, "_").concat(cellColumnPositioning.left, "_").concat(cellColumnPositioning.right)
358
310
  });
359
311
  };
360
-
361
312
  var resizeHandleCellDecorations = [];
362
313
  var lastCellElementsDecorations = [];
363
-
364
314
  for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
365
315
  var seen = {};
366
-
367
316
  if (rowIndex !== rowIndexTarget) {
368
317
  continue;
369
318
  }
370
-
371
319
  for (var columnIndex = 0; columnIndex < map.width; columnIndex++) {
372
320
  var cellPosition = map.map[map.width * rowIndex + columnIndex];
373
-
374
321
  if (seen[cellPosition]) {
375
322
  continue;
376
323
  }
377
-
378
324
  seen[cellPosition] = true;
379
325
  var cellPos = table.start + cellPosition;
380
326
  var cell = tr.doc.nodeAt(cellPos);
381
-
382
327
  if (!cell) {
383
328
  continue;
384
329
  }
385
-
386
330
  var colspan = cell.attrs.colspan || 1;
387
331
  var startIndex = columnIndex;
388
332
  var endIndex = colspan + startIndex;
389
-
390
333
  if (endIndex !== columnEndIndexTarget.right) {
391
334
  continue;
392
335
  }
393
-
394
336
  var resizerHandleDec = createResizerHandleDecoration({
395
337
  left: startIndex,
396
338
  right: endIndex
@@ -403,9 +345,9 @@ var createResizeHandleDecoration = function createResizeHandleDecoration(tr, row
403
345
  lastCellElementsDecorations.push(lastCellDec);
404
346
  }
405
347
  }
406
-
407
348
  return [resizeHandleCellDecorations, lastCellElementsDecorations.filter(_utils2.nonNullable)];
408
349
  };
350
+
409
351
  /*
410
352
  * This function will create a decoration for each cell using the right position on the CellColumnPositioning
411
353
  * for example given that table:
@@ -448,27 +390,18 @@ var createResizeHandleDecoration = function createResizeHandleDecoration(tr, row
448
390
  * this function will return two decorations applying a new class `ClassName.WITH_RESIZE_LINE`
449
391
  * only on the cells: `C1` and `D1`.
450
392
  */
451
-
452
-
453
393
  exports.createResizeHandleDecoration = createResizeHandleDecoration;
454
-
455
394
  var createColumnLineResize = function createColumnLineResize(selection, cellColumnPositioning) {
456
395
  var table = (0, _utils.findTable)(selection);
457
-
458
396
  if (!table || cellColumnPositioning.right === null) {
459
397
  return [];
460
398
  }
461
-
462
399
  var columnIndex = cellColumnPositioning.right;
463
-
464
400
  var map = _tableMap.TableMap.get(table.node);
465
-
466
401
  var isLastColumn = columnIndex === map.width;
467
-
468
402
  if (isLastColumn) {
469
403
  columnIndex -= 1;
470
404
  }
471
-
472
405
  var decorationClassName = isLastColumn ? _types.TableCssClassName.WITH_RESIZE_LINE_LAST_COLUMN : _types.TableCssClassName.WITH_RESIZE_LINE;
473
406
  var cellPositions = makeArray(map.height).map(function (rowIndex) {
474
407
  return map.map[map.width * rowIndex + columnIndex];
@@ -480,6 +413,7 @@ var createColumnLineResize = function createColumnLineResize(selection, cellColu
480
413
  var nextPosition = map.map[map.width * rowIndex + columnIndex - 1];
481
414
  return cellPosition !== nextPosition; // Removed it if next position is merged
482
415
  });
416
+
483
417
  var cells = cellPositions.map(function (pos) {
484
418
  return {
485
419
  pos: pos + table.start,
@@ -490,7 +424,6 @@ var createColumnLineResize = function createColumnLineResize(selection, cellColu
490
424
  if (!cell || !cell.node) {
491
425
  return;
492
426
  }
493
-
494
427
  return _prosemirrorView.Decoration.node(cell.pos, cell.pos + cell.node.nodeSize, {
495
428
  class: decorationClassName
496
429
  }, {
@@ -498,5 +431,4 @@ var createColumnLineResize = function createColumnLineResize(selection, cellColu
498
431
  });
499
432
  }).filter(_utils2.nonNullable);
500
433
  };
501
-
502
434
  exports.createColumnLineResize = createColumnLineResize;