@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
@@ -88,15 +88,15 @@ export const getToolbarMenuConfig = (config, state, {
88
88
  hidden: options.every(option => option.hidden),
89
89
  options
90
90
  };
91
- }; // Added these options for mobile. Mobile bridge translates this menu and
91
+ };
92
+
93
+ // Added these options for mobile. Mobile bridge translates this menu and
92
94
  // relay it to the native mobile. Native mobile displays the menu
93
95
  // with native widgets. It's enabled via a plugin config.
94
-
95
96
  export const getToolbarCellOptionsConfig = (editorState, editorView, initialSelectionRect, {
96
97
  formatMessage
97
98
  }, getEditorContainerWidth, editorAnalyticsAPI) => {
98
99
  var _pluginState$pluginCo, _pluginState$pluginCo2;
99
-
100
100
  const {
101
101
  top,
102
102
  bottom,
@@ -112,11 +112,9 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
112
112
  onClick: (state, dispatch, view) => {
113
113
  const selectionRect = getClosestSelectionRect(state);
114
114
  const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
115
-
116
115
  if (index) {
117
116
  insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
118
117
  }
119
-
120
118
  return true;
121
119
  },
122
120
  selected: false,
@@ -130,14 +128,12 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
130
128
  onClick: (state, dispatch) => {
131
129
  const selectionRect = getClosestSelectionRect(state);
132
130
  const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.bottom;
133
-
134
131
  if (index) {
135
132
  insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, {
136
133
  index,
137
134
  moveCursorToInsertedRow: true
138
135
  })(state, dispatch);
139
136
  }
140
-
141
137
  return true;
142
138
  },
143
139
  selected: false,
@@ -152,11 +148,9 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
152
148
  }),
153
149
  onClick: (state, dispatch, view) => {
154
150
  const selectionRect = getClosestSelectionRect(state);
155
-
156
151
  if (selectionRect) {
157
152
  deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch, view);
158
153
  }
159
-
160
154
  return true;
161
155
  },
162
156
  onFocus: highlightColumnsHandler,
@@ -172,11 +166,9 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
172
166
  }),
173
167
  onClick: (state, dispatch) => {
174
168
  const selectionRect = getClosestSelectionRect(state);
175
-
176
169
  if (selectionRect) {
177
170
  deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, selectionRect, false)(state, dispatch);
178
171
  }
179
-
180
172
  return true;
181
173
  },
182
174
  onFocus: highlightRowsHandler,
@@ -198,22 +190,17 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
198
190
  selected: false,
199
191
  disabled: !splitCell(editorState)
200
192
  }];
201
-
202
193
  if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
203
194
  var _newResizeStateWithAn;
204
-
205
195
  const newResizeStateWithAnalytics = editorView ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth) : undefined;
206
196
  const wouldChange = (_newResizeStateWithAn = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn !== void 0 ? _newResizeStateWithAn : false;
207
-
208
197
  const distributeColumnWidths = (state, dispatch) => {
209
198
  if (newResizeStateWithAnalytics) {
210
199
  distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
211
200
  return true;
212
201
  }
213
-
214
202
  return false;
215
203
  };
216
-
217
204
  options.push({
218
205
  id: 'editor.table.distributeColumns',
219
206
  title: formatMessage(ContextualMenuMessages.distributeColumns),
@@ -222,7 +209,6 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
222
209
  disabled: !wouldChange
223
210
  });
224
211
  }
225
-
226
212
  if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo2 = pluginState.pluginConfig) !== null && _pluginState$pluginCo2 !== void 0 && _pluginState$pluginCo2.allowColumnSorting) {
227
213
  const hasMergedCellsInTable = getMergedCellsPositions(editorState.tr).length > 0;
228
214
  const warning = hasMergedCellsInTable ? formatMessage(ContextualMenuMessages.canNotSortTable) : undefined;
@@ -234,7 +220,6 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
234
220
  hoverMergedCells()(state, dispatch);
235
221
  return true;
236
222
  }
237
-
238
223
  return false;
239
224
  },
240
225
  onMouseOut: (state, dispatch) => {
@@ -257,7 +242,6 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
257
242
  hoverMergedCells()(state, dispatch);
258
243
  return true;
259
244
  }
260
-
261
245
  return false;
262
246
  },
263
247
  onMouseOut: (state, dispatch) => {
@@ -273,7 +257,6 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
273
257
  tooltip: warning
274
258
  });
275
259
  }
276
-
277
260
  options.push({
278
261
  id: 'editor.table.clearCells',
279
262
  title: formatMessage(ContextualMenuMessages.clearCells, {
@@ -303,17 +286,14 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
303
286
  showSelected: false
304
287
  };
305
288
  };
306
-
307
289
  const getClosestSelectionRect = state => {
308
290
  const selection = state.selection;
309
291
  return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
310
292
  };
311
-
312
293
  export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) => config => (state, intl) => {
313
294
  const tableObject = findTable(state.selection);
314
295
  const pluginState = getPluginState(state);
315
296
  const resizeState = tableResizingPluginKey.getState(state);
316
-
317
297
  if (tableObject && pluginState.editorHasFocus) {
318
298
  const nodeType = state.schema.nodes.table;
319
299
  const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
@@ -321,10 +301,10 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
321
301
  tableCellOptionsInFloatingToolbar
322
302
  } = getEditorFeatureFlags() || {};
323
303
  const cellItems = getCellItems(config, state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
324
- const colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar); // Check if we need to show confirm dialog for delete button
304
+ const colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
325
305
 
306
+ // Check if we need to show confirm dialog for delete button
326
307
  let confirmDialog;
327
-
328
308
  if (isReferencedSource(state, tableObject.node)) {
329
309
  confirmDialog = () => ({
330
310
  title: intl.formatMessage(tableMessages.deleteElementTitle),
@@ -339,23 +319,18 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
339
319
  onConfirm: (isChecked = false) => clickWithCheckboxHandler(isChecked, tableObject.node)
340
320
  });
341
321
  }
342
-
343
322
  const getDomRef = editorView => {
344
323
  let element;
345
324
  const domAtPos = editorView.domAtPos.bind(editorView);
346
325
  const parent = findParentDomRefOfType(nodeType, domAtPos)(state.selection);
347
-
348
326
  if (parent) {
349
327
  const tableRef = parent.querySelector('table') || undefined;
350
-
351
328
  if (tableRef) {
352
329
  element = closestElement(tableRef, `.${TableCssClassName.TABLE_NODE_WRAPPER}`) || undefined;
353
330
  }
354
331
  }
355
-
356
332
  return element;
357
333
  };
358
-
359
334
  return {
360
335
  title: 'Table floating controls',
361
336
  getDomRef,
@@ -397,23 +372,19 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
397
372
  scrollable: true
398
373
  };
399
374
  }
400
-
401
375
  return;
402
376
  };
403
-
404
377
  const separator = hidden => {
405
378
  return {
406
379
  type: 'separator',
407
380
  hidden: hidden
408
381
  };
409
382
  };
410
-
411
383
  const getCellItems = (pluginConfig, state, view, {
412
384
  formatMessage
413
385
  }, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) => {
414
386
  if (pluginConfig.allowCellOptionsInFloatingToolbar || tableCellOptionsInFloatingToolbar) {
415
387
  const initialSelectionRect = getClosestSelectionRect(state);
416
-
417
388
  if (initialSelectionRect) {
418
389
  const cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
419
390
  formatMessage
@@ -421,24 +392,19 @@ const getCellItems = (pluginConfig, state, view, {
421
392
  return [cellOptions, separator(cellOptions.hidden)];
422
393
  }
423
394
  }
424
-
425
395
  return [];
426
396
  };
427
-
428
397
  const getColorPicker = (state, menu, {
429
398
  formatMessage
430
399
  }, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) => {
431
400
  var _node$attrs;
432
-
433
401
  const {
434
402
  targetCellPosition,
435
403
  pluginConfig
436
404
  } = getPluginState(state);
437
-
438
405
  if (!pluginConfig.allowBackgroundColor || !tableCellOptionsInFloatingToolbar) {
439
406
  return [];
440
407
  }
441
-
442
408
  const node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : undefined;
443
409
  const currentBackground = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff';
444
410
  const defaultPalette = cellBackgroundColorPalette.find(item => item.value === currentBackground) || {
@@ -456,39 +422,30 @@ const getColorPicker = (state, menu, {
456
422
  onChange: option => setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, option.value, targetCellPosition)
457
423
  }, separator(menu.hidden)];
458
424
  };
459
-
460
425
  const clickWithCheckboxHandler = (isChecked, node, editorAnalyticsAPI) => (state, dispatch) => {
461
426
  if (!node) {
462
427
  return false;
463
428
  }
464
-
465
429
  if (!isChecked) {
466
430
  return deleteTableWithAnalytics(editorAnalyticsAPI)(state, dispatch);
467
431
  } else {
468
432
  removeDescendantNodes(node)(state, dispatch);
469
433
  }
470
-
471
434
  return true;
472
435
  };
473
-
474
436
  const highlightRowsHandler = (state, dispatch) => {
475
437
  const selectionRect = getClosestSelectionRect(state);
476
-
477
438
  if (selectionRect) {
478
439
  hoverRows(getSelectedRowIndexes(selectionRect), true)(state, dispatch);
479
440
  return true;
480
441
  }
481
-
482
442
  return false;
483
443
  };
484
-
485
444
  const highlightColumnsHandler = (state, dispatch) => {
486
445
  const selectionRect = getClosestSelectionRect(state);
487
-
488
446
  if (selectionRect) {
489
447
  hoverColumns(getSelectedColumnIndexes(selectionRect), true)(state, dispatch);
490
448
  return true;
491
449
  }
492
-
493
450
  return false;
494
451
  };
@@ -8,8 +8,9 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
8
8
  import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
9
9
  export const updateColumnWidths = (resizeState, table, start) => tr => {
10
10
  const map = TableMap.get(table);
11
- const updatedCellsAttrs = {}; // calculating new attributes for each cell
11
+ const updatedCellsAttrs = {};
12
12
 
13
+ // calculating new attributes for each cell
13
14
  for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
14
15
  for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
15
16
  const {
@@ -17,10 +18,10 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
17
18
  } = resizeState.cols[columnIndex];
18
19
  const mapIndex = rowIndex * map.width + columnIndex;
19
20
  const cellPos = map.map[mapIndex];
20
- const attrs = updatedCellsAttrs[cellPos] || { ...table.nodeAt(cellPos).attrs
21
+ const attrs = updatedCellsAttrs[cellPos] || {
22
+ ...table.nodeAt(cellPos).attrs
21
23
  };
22
24
  const colspan = attrs.colspan || 1;
23
-
24
25
  if (attrs.colwidth && attrs.colwidth.length > colspan) {
25
26
  tr = setMeta({
26
27
  type: 'UPDATE_COLUMN_WIDTHS',
@@ -31,24 +32,20 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
31
32
  }
32
33
  })(tr);
33
34
  attrs.colwidth = attrs.colwidth.slice(0, colspan);
34
- } // Rowspanning cell that has already been handled
35
-
35
+ }
36
36
 
37
+ // Rowspanning cell that has already been handled
37
38
  if (rowIndex && map.map[mapIndex] === map.map[mapIndex - map.width]) {
38
39
  continue;
39
40
  }
40
-
41
41
  const colspanIndex = colspan === 1 ? 0 : columnIndex - map.colCount(cellPos);
42
-
43
42
  if (attrs.colwidth && attrs.colwidth[colspanIndex] === width) {
44
43
  continue;
45
44
  }
46
-
47
45
  let colwidths = attrs.colwidth ? attrs.colwidth.slice() : Array.from({
48
46
  length: colspan
49
47
  }, _ => 0);
50
48
  colwidths[colspanIndex] = width;
51
-
52
49
  if (colwidths.length > colspan) {
53
50
  tr = setMeta({
54
51
  type: 'UPDATE_COLUMN_WIDTHS',
@@ -60,35 +57,30 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
60
57
  })(tr);
61
58
  colwidths = colwidths.slice(0, colspan);
62
59
  }
63
-
64
- updatedCellsAttrs[cellPos] = { ...attrs,
60
+ updatedCellsAttrs[cellPos] = {
61
+ ...attrs,
65
62
  colwidth: colwidths.includes(0) ? undefined : colwidths
66
63
  };
67
64
  }
68
- } // updating all cells with new attributes
69
-
65
+ }
70
66
 
67
+ // updating all cells with new attributes
71
68
  const rows = [];
72
69
  const seen = {};
73
-
74
70
  for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
75
71
  const row = table.child(rowIndex);
76
72
  const cells = [];
77
-
78
73
  for (let columnIndex = 0; columnIndex < map.width; columnIndex++) {
79
74
  const mapIndex = rowIndex * map.width + columnIndex;
80
75
  const pos = map.map[mapIndex];
81
76
  const cell = table.nodeAt(pos);
82
-
83
77
  if (!seen[pos] && cell) {
84
78
  cells.push(cell.type.createChecked(updatedCellsAttrs[pos] || cell.attrs, cell.content, cell.marks));
85
79
  seen[pos] = true;
86
80
  }
87
81
  }
88
-
89
82
  rows.push(row.type.createChecked(row.attrs, cells, row.marks));
90
83
  }
91
-
92
84
  const tablePos = start - 1;
93
85
  const selectionBookmark = tr.selection.getBookmark();
94
86
  tr.replaceWith(tablePos, tablePos + table.nodeSize, table.type.createChecked(table.attrs, rows, table.marks));
@@ -102,9 +94,9 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
102
94
  *
103
95
  * @see https://github.com/ProseMirror/prosemirror/issues/645
104
96
  */
105
-
106
97
  return tr.setSelection(selectionBookmark.resolve(tr.doc));
107
98
  };
99
+
108
100
  /**
109
101
  * This function is called when user inserts/deletes a column in a table to;
110
102
  * - rescale all columns (if the table did not overflow before the insertion)
@@ -115,27 +107,23 @@ export const updateColumnWidths = (resizeState, table, start) => tr => {
115
107
  * @param view
116
108
  * @returns Updated transaction with rescaled columns for a given table
117
109
  */
118
-
119
110
  export const rescaleColumns = getEditorContainerWidth => (table, view) => tr => {
120
111
  // If the table has been not been resized we skip updating the size
121
112
  // of columns here.
122
113
  if (!view || !hasTableBeenResized(table.node)) {
123
114
  return tr;
124
115
  }
125
-
126
116
  const {
127
117
  state
128
118
  } = view;
129
119
  const domAtPos = view.domAtPos.bind(view);
130
120
  const maybeTable = domAtPos(table.start).node;
131
121
  const tableRef = maybeTable.closest('table');
132
-
133
122
  if (!tableRef) {
134
123
  return tr;
135
124
  }
136
-
137
- const layout = normaliseTableLayout(tableRef === null || tableRef === void 0 ? void 0 : tableRef.dataset.layout); // The is the width the table can reach before overflowing
138
-
125
+ const layout = normaliseTableLayout(tableRef === null || tableRef === void 0 ? void 0 : tableRef.dataset.layout);
126
+ // The is the width the table can reach before overflowing
139
127
  const maxSize = getTableMaxWidth({
140
128
  table: table.node,
141
129
  tableStart: table.start,
@@ -152,12 +140,12 @@ export const rescaleColumns = getEditorContainerWidth => (table, view) => tr =>
152
140
  maxSize
153
141
  });
154
142
  const previousTableWidth = resizeState.tableWidth - tableNewColumnMinWidth;
155
- const tableDidntPreviouslyOverflow = previousTableWidth <= maxSize; // If the new table width will result in the table going into an overflow state
156
- // we resize the cells to avoid the overflow occuring
143
+ const tableDidntPreviouslyOverflow = previousTableWidth <= maxSize;
157
144
 
145
+ // If the new table width will result in the table going into an overflow state
146
+ // we resize the cells to avoid the overflow occuring
158
147
  if (tableDidntPreviouslyOverflow && resizeState.overflow) {
159
148
  resizeState = scaleTableTo(resizeState, maxSize);
160
149
  }
161
-
162
150
  return updateColumnWidths(resizeState, table.node, table.start)(tr);
163
151
  };
@@ -4,87 +4,70 @@ import { findTable } from '@atlaskit/editor-tables/utils';
4
4
  import { AddColumnStep } from '@atlaskit/adf-schema/steps';
5
5
  import { setMeta } from './metadata';
6
6
  import { splitCellsInColumns } from './split';
7
-
8
7
  const deleteColumnsCustomStep = rect => tr => {
9
8
  const table = findTable(tr.selection);
10
-
11
9
  if (!table) {
12
10
  return tr;
13
- } // Need to split all the merge in the ranges (this is the current behaviour)
11
+ }
12
+
13
+ // Need to split all the merge in the ranges (this is the current behaviour)
14
14
  // Maybe is better to split only the last column?
15
15
  // TODO: After talking with Roto about this behaviour, he likes when we dont split the columns, I am keeping this for consistency of the current implementation.
16
+ splitCellsInColumns(tr, table.pos, rect.left, rect.right);
16
17
 
17
-
18
- splitCellsInColumns(tr, table.pos, rect.left, rect.right); // Delete the columns
19
-
18
+ // Delete the columns
20
19
  let mapStart = tr.mapping.maps.length;
21
20
  const originalDoc = tr.doc;
22
21
  const deletedColumns = [];
23
-
24
22
  for (let i = rect.left; i < rect.right; i++) {
25
23
  const step = AddColumnStep.create(originalDoc, table.pos, i, true);
26
24
  deletedColumns.push(i);
27
25
  tr.step(step.map(tr.mapping.slice(mapStart)));
28
26
  }
29
-
30
27
  const tablePosResult = tr.mapping.mapResult(table.pos);
31
-
32
28
  if (tablePosResult.deleted) {
33
29
  const pos = Math.min(tablePosResult.pos, tr.doc.nodeSize - 1);
34
30
  tr.setSelection(Selection.near(tr.doc.resolve(pos)));
35
31
  } else {
36
32
  const newTable = tr.doc.nodeAt(tablePosResult.pos);
37
-
38
33
  if (newTable) {
39
34
  const cursorPos = getNextCursorPos(newTable, deletedColumns);
40
35
  tr.setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos)));
41
36
  }
42
37
  }
43
-
44
38
  return tr;
45
39
  };
46
-
47
40
  const deleteColumnsLegacy = rect => tr => {
48
41
  const table = findTable(tr.selection);
49
-
50
42
  if (!table) {
51
43
  return tr;
52
44
  }
53
-
54
45
  const columnsToDelete = [];
55
-
56
46
  for (let i = rect.left; i < rect.right; i++) {
57
47
  columnsToDelete.push(i);
58
48
  }
59
-
60
49
  if (!columnsToDelete.length) {
61
50
  return tr;
62
51
  }
63
-
64
52
  const map = TableMap.get(table.node);
65
53
  const rows = [];
66
54
  const seen = {};
67
55
  const deletedCells = {};
68
-
69
56
  for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
70
57
  const rowCells = [];
71
58
  const row = table.node.child(rowIndex);
72
-
73
59
  for (let colIndex = 0; colIndex < map.width; colIndex++) {
74
60
  const cellPos = map.map[rowIndex * map.width + colIndex];
75
61
  const cell = table.node.nodeAt(cellPos);
76
-
77
62
  if (!cell) {
78
63
  continue;
79
64
  }
80
-
81
65
  const cellsInColumn = map.cellsInRect({
82
66
  left: colIndex,
83
67
  top: 0,
84
68
  right: colIndex + 1,
85
69
  bottom: map.height
86
70
  });
87
-
88
71
  if (columnsToDelete.indexOf(colIndex) === -1) {
89
72
  // decrement colspans for col-spanning cells that overlap deleted columns
90
73
  if (cellsInColumn.indexOf(cellPos) > -1 && !seen[cellPos]) {
@@ -94,12 +77,11 @@ const deleteColumnsLegacy = rect => tr => {
94
77
  overlappingCols += 1;
95
78
  }
96
79
  });
97
-
98
80
  if (overlappingCols > 0) {
99
- const attrs = { ...cell.attrs,
81
+ const attrs = {
82
+ ...cell.attrs,
100
83
  colspan: cell.attrs.colspan - overlappingCols
101
84
  };
102
-
103
85
  if (cell.attrs.colwidth) {
104
86
  const minColIndex = Math.min(...columnsToDelete);
105
87
  const pos = minColIndex > 0 ? minColIndex - map.colCount(cellPos) : 0;
@@ -107,7 +89,6 @@ const deleteColumnsLegacy = rect => tr => {
107
89
  colwidth.splice(pos, overlappingCols);
108
90
  attrs.colwidth = colwidth;
109
91
  }
110
-
111
92
  const newCell = cell.type.createChecked(attrs, cell.content, cell.marks);
112
93
  rowCells.push(newCell);
113
94
  seen[cellPos] = true;
@@ -115,22 +96,21 @@ const deleteColumnsLegacy = rect => tr => {
115
96
  }
116
97
  } else if (deletedCells[cellPos]) {
117
98
  // if we're removing a col-spanning cell, we need to add missing cells to columns to the right
118
- const attrs = { ...cell.attrs,
99
+ const attrs = {
100
+ ...cell.attrs,
119
101
  colspan: 1,
120
102
  rowspan: 1
121
103
  };
122
-
123
104
  if (cell.attrs.colwidth) {
124
105
  const pos = colIndex > 0 ? colIndex - map.colCount(cellPos) : 0;
125
106
  attrs.colwidth = cell.attrs.colwidth.slice().splice(pos, 1);
126
107
  }
127
-
128
108
  const newCell = cell.type.createChecked(attrs, cell.type.schema.nodes.paragraph.createChecked(), cell.marks);
129
109
  rowCells.push(newCell);
130
110
  continue;
131
- } // normal cells that we want to keep
132
-
111
+ }
133
112
 
113
+ // normal cells that we want to keep
134
114
  if (!seen[cellPos]) {
135
115
  seen[cellPos] = true;
136
116
  rowCells.push(cell);
@@ -139,109 +119,88 @@ const deleteColumnsLegacy = rect => tr => {
139
119
  deletedCells[cellPos] = true;
140
120
  }
141
121
  }
142
-
143
122
  if (rowCells.length) {
144
123
  rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
145
124
  }
146
125
  }
147
-
148
126
  if (!rows.length) {
149
127
  return setMeta({
150
128
  type: 'DELETE_COLUMNS',
151
129
  problem: 'EMPTY_TABLE'
152
130
  })(tr);
153
131
  }
154
-
155
132
  const newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
156
133
  const fixedTable = fixRowSpans(newTable);
157
-
158
134
  if (fixedTable === null) {
159
135
  return setMeta({
160
136
  type: 'DELETE_COLUMNS',
161
137
  problem: 'FIX_ROWSPANS'
162
138
  })(tr);
163
139
  }
164
-
165
140
  const cursorPos = getNextCursorPos(newTable, columnsToDelete);
166
141
  return setMeta({
167
142
  type: 'DELETE_COLUMNS'
168
- })(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable) // move cursor to the left of the deleted columns if possible, otherwise - to the first column
143
+ })(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
144
+ // move cursor to the left of the deleted columns if possible, otherwise - to the first column
169
145
  .setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos))));
170
146
  };
171
-
172
147
  function getNextCursorPos(table, deletedColumns) {
173
148
  const minColumn = Math.min(...deletedColumns);
174
149
  const nextColumnWithCursor = minColumn > 0 ? minColumn - 1 : 0;
175
150
  const map = TableMap.get(table);
176
151
  return map.map[nextColumnWithCursor];
177
- } // returns an array of numbers, each number indicates the minimum rowSpan in each row
178
-
152
+ }
179
153
 
154
+ // returns an array of numbers, each number indicates the minimum rowSpan in each row
180
155
  function getMinRowSpans(table) {
181
156
  const minRowSpans = [];
182
-
183
157
  for (let rowIndex = 0; rowIndex < table.childCount; rowIndex++) {
184
158
  const rowSpans = [];
185
159
  const row = table.child(rowIndex);
186
-
187
160
  for (let colIndex = 0; colIndex < row.childCount; colIndex++) {
188
161
  const cell = row.child(colIndex);
189
162
  rowSpans.push(cell.attrs.rowspan);
190
163
  }
191
-
192
164
  minRowSpans[rowIndex] = Math.min(...rowSpans);
193
165
  }
194
-
195
166
  return minRowSpans;
196
167
  }
197
-
198
168
  function fixRowSpans(table) {
199
169
  const map = TableMap.get(table);
200
170
  const minRowSpans = getMinRowSpans(table);
201
-
202
171
  if (!minRowSpans.some(rowspan => rowspan > 1)) {
203
172
  return table;
204
173
  }
205
-
206
174
  const rows = [];
207
-
208
175
  for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
209
176
  const row = table.child(rowIndex);
210
-
211
177
  if (minRowSpans[rowIndex] === 1) {
212
178
  rows.push(row);
213
179
  } else {
214
180
  const rowCells = [];
215
-
216
181
  for (let colIndex = 0; colIndex < row.childCount; colIndex++) {
217
182
  const cell = row.child(colIndex);
218
183
  const rowspan = cell.attrs.rowspan - minRowSpans[rowIndex] + 1;
219
-
220
184
  if (rowspan < 1) {
221
185
  return null;
222
186
  }
223
-
224
- const newCell = cell.type.createChecked({ ...cell.attrs,
187
+ const newCell = cell.type.createChecked({
188
+ ...cell.attrs,
225
189
  rowspan
226
190
  }, cell.content, cell.marks);
227
191
  rowCells.push(newCell);
228
192
  }
229
-
230
193
  rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
231
194
  }
232
195
  }
233
-
234
196
  if (!rows.length) {
235
197
  return null;
236
198
  }
237
-
238
199
  return table.type.createChecked(table.attrs, rows, table.marks);
239
200
  }
240
-
241
201
  export const deleteColumns = (rect, allowAddColumnCustomStep = false) => tr => {
242
202
  if (allowAddColumnCustomStep) {
243
203
  return deleteColumnsCustomStep(rect)(tr);
244
204
  }
245
-
246
205
  return deleteColumnsLegacy(rect)(tr);
247
206
  };