@atlaskit/editor-plugin-table 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/index.js +0 -2
  3. package/dist/cjs/plugins/table/commands/clear.js +4 -16
  4. package/dist/cjs/plugins/table/commands/collapse.js +0 -6
  5. package/dist/cjs/plugins/table/commands/go-to-next-cell.js +7 -18
  6. package/dist/cjs/plugins/table/commands/hover.js +7 -37
  7. package/dist/cjs/plugins/table/commands/index.js +0 -8
  8. package/dist/cjs/plugins/table/commands/insert.js +17 -56
  9. package/dist/cjs/plugins/table/commands/misc.js +36 -132
  10. package/dist/cjs/plugins/table/commands/referentiality.js +0 -4
  11. package/dist/cjs/plugins/table/commands/selection.js +21 -87
  12. package/dist/cjs/plugins/table/commands/sort.js +2 -23
  13. package/dist/cjs/plugins/table/commands/split-cell.js +3 -11
  14. package/dist/cjs/plugins/table/commands/toggle.js +8 -34
  15. package/dist/cjs/plugins/table/commands-with-analytics.js +50 -139
  16. package/dist/cjs/plugins/table/create-plugin-config.js +0 -6
  17. package/dist/cjs/plugins/table/event-handlers.js +58 -160
  18. package/dist/cjs/plugins/table/handlers.js +10 -39
  19. package/dist/cjs/plugins/table/index.js +47 -91
  20. package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -41
  21. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +82 -188
  22. package/dist/cjs/plugins/table/nodeviews/table.js +12 -70
  23. package/dist/cjs/plugins/table/nodeviews/tableCell.js +15 -39
  24. package/dist/cjs/plugins/table/nodeviews/update-overflow-shadows.js +3 -15
  25. package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +0 -18
  26. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -27
  27. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-resizing.js +8 -20
  28. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +1 -3
  29. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/index.js +0 -3
  30. package/dist/cjs/plugins/table/pm-plugins/keymap.js +2 -15
  31. package/dist/cjs/plugins/table/pm-plugins/main.js +20 -72
  32. package/dist/cjs/plugins/table/pm-plugins/plugin-factory.js +25 -42
  33. package/dist/cjs/plugins/table/pm-plugins/plugin-key.js +0 -2
  34. package/dist/cjs/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -8
  35. package/dist/cjs/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +4 -23
  36. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/commands.js +0 -5
  37. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/index.js +0 -5
  38. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -13
  39. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +56 -138
  40. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-key.js +0 -2
  41. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-state.js +15 -30
  42. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +0 -6
  43. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/util.js +0 -5
  44. package/dist/cjs/plugins/table/pm-plugins/table-local-id.js +13 -44
  45. package/dist/cjs/plugins/table/pm-plugins/table-resizing/commands.js +12 -42
  46. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -52
  47. package/dist/cjs/plugins/table/pm-plugins/table-resizing/index.js +0 -4
  48. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-factory.js +0 -10
  49. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-key.js +0 -2
  50. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin.js +5 -19
  51. package/dist/cjs/plugins/table/pm-plugins/table-resizing/reducer.js +0 -10
  52. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -15
  53. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -28
  54. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/content-width.js +3 -23
  55. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +4 -46
  56. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/index.js +0 -9
  57. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +15 -36
  58. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-column.js +1 -4
  59. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +15 -71
  60. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +34 -82
  61. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +12 -36
  62. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.js +0 -2
  63. package/dist/cjs/plugins/table/pm-plugins/table-selection-keymap.js +0 -5
  64. package/dist/cjs/plugins/table/reducer.js +0 -24
  65. package/dist/cjs/plugins/table/toolbar.js +14 -94
  66. package/dist/cjs/plugins/table/transforms/column-width.js +12 -45
  67. package/dist/cjs/plugins/table/transforms/delete-columns.js +11 -76
  68. package/dist/cjs/plugins/table/transforms/delete-rows.js +4 -42
  69. package/dist/cjs/plugins/table/transforms/fix-tables.js +24 -61
  70. package/dist/cjs/plugins/table/transforms/index.js +0 -7
  71. package/dist/cjs/plugins/table/transforms/merge.js +14 -90
  72. package/dist/cjs/plugins/table/transforms/metadata.js +0 -5
  73. package/dist/cjs/plugins/table/transforms/replace-table.js +2 -13
  74. package/dist/cjs/plugins/table/transforms/split.js +18 -32
  75. package/dist/cjs/plugins/table/types.js +0 -11
  76. package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +10 -51
  77. package/dist/cjs/plugins/table/ui/FloatingContextualButton/styles.js +0 -12
  78. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +46 -145
  79. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +12 -35
  80. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/styles.js +0 -11
  81. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +5 -12
  82. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +3 -16
  83. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +19 -89
  84. package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +6 -31
  85. package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +5 -22
  86. package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +25 -80
  87. package/dist/cjs/plugins/table/ui/LayoutButton/index.js +16 -64
  88. package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +14 -47
  89. package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +20 -48
  90. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +10 -43
  91. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +33 -74
  92. package/dist/cjs/plugins/table/ui/common-styles.js +6 -19
  93. package/dist/cjs/plugins/table/ui/consts.js +3 -8
  94. package/dist/cjs/plugins/table/ui/messages.js +0 -3
  95. package/dist/cjs/plugins/table/ui/ui-styles.js +0 -32
  96. package/dist/cjs/plugins/table/utils/analytics.js +4 -19
  97. package/dist/cjs/plugins/table/utils/collapse.js +4 -21
  98. package/dist/cjs/plugins/table/utils/column-controls.js +25 -61
  99. package/dist/cjs/plugins/table/utils/decoration.js +46 -114
  100. package/dist/cjs/plugins/table/utils/dom.js +4 -51
  101. package/dist/cjs/plugins/table/utils/get-allow-add-column-custom-step.js +0 -2
  102. package/dist/cjs/plugins/table/utils/index.js +0 -10
  103. package/dist/cjs/plugins/table/utils/nodes.js +5 -48
  104. package/dist/cjs/plugins/table/utils/paste.js +22 -47
  105. package/dist/cjs/plugins/table/utils/row-controls.js +6 -67
  106. package/dist/cjs/plugins/table/utils/selection.js +3 -36
  107. package/dist/cjs/plugins/table/utils/table.js +0 -11
  108. package/dist/cjs/plugins/table/utils/update-plugin-state-decorations.js +0 -4
  109. package/dist/cjs/plugins/table-plugin.js +0 -3
  110. package/dist/cjs/version.json +1 -1
  111. package/dist/es2019/plugins/table/commands/clear.js +3 -8
  112. package/dist/es2019/plugins/table/commands/collapse.js +0 -3
  113. package/dist/es2019/plugins/table/commands/go-to-next-cell.js +4 -7
  114. package/dist/es2019/plugins/table/commands/hover.js +7 -17
  115. package/dist/es2019/plugins/table/commands/insert.js +16 -36
  116. package/dist/es2019/plugins/table/commands/misc.js +37 -67
  117. package/dist/es2019/plugins/table/commands/selection.js +7 -62
  118. package/dist/es2019/plugins/table/commands/sort.js +0 -12
  119. package/dist/es2019/plugins/table/commands/split-cell.js +0 -4
  120. package/dist/es2019/plugins/table/commands/toggle.js +13 -15
  121. package/dist/es2019/plugins/table/commands-with-analytics.js +4 -14
  122. package/dist/es2019/plugins/table/event-handlers.js +14 -62
  123. package/dist/es2019/plugins/table/handlers.js +16 -26
  124. package/dist/es2019/plugins/table/index.js +12 -25
  125. package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -40
  126. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +27 -100
  127. package/dist/es2019/plugins/table/nodeviews/table.js +3 -33
  128. package/dist/es2019/plugins/table/nodeviews/tableCell.js +7 -16
  129. package/dist/es2019/plugins/table/nodeviews/update-overflow-shadows.js +3 -10
  130. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +0 -5
  131. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +4 -13
  132. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-resizing.js +0 -3
  133. package/dist/es2019/plugins/table/pm-plugins/keymap.js +2 -3
  134. package/dist/es2019/plugins/table/pm-plugins/main.js +19 -43
  135. package/dist/es2019/plugins/table/pm-plugins/plugin-factory.js +2 -6
  136. package/dist/es2019/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -3
  137. package/dist/es2019/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +0 -12
  138. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -9
  139. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +55 -130
  140. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin-state.js +2 -9
  141. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/util.js +0 -3
  142. package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +20 -39
  143. package/dist/es2019/plugins/table/pm-plugins/table-resizing/commands.js +7 -15
  144. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -27
  145. package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -4
  146. package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin.js +2 -5
  147. package/dist/es2019/plugins/table/pm-plugins/table-resizing/reducer.js +8 -8
  148. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -4
  149. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -11
  150. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/content-width.js +4 -21
  151. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/dom.js +3 -22
  152. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +10 -18
  153. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +29 -59
  154. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +54 -51
  155. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +9 -14
  156. package/dist/es2019/plugins/table/reducer.js +26 -30
  157. package/dist/es2019/plugins/table/toolbar.js +5 -48
  158. package/dist/es2019/plugins/table/transforms/column-width.js +16 -28
  159. package/dist/es2019/plugins/table/transforms/delete-columns.js +17 -58
  160. package/dist/es2019/plugins/table/transforms/delete-rows.js +8 -25
  161. package/dist/es2019/plugins/table/transforms/fix-tables.js +25 -42
  162. package/dist/es2019/plugins/table/transforms/merge.js +22 -70
  163. package/dist/es2019/plugins/table/transforms/metadata.js +3 -2
  164. package/dist/es2019/plugins/table/transforms/replace-table.js +0 -2
  165. package/dist/es2019/plugins/table/transforms/split.js +16 -19
  166. package/dist/es2019/plugins/table/types.js +2 -4
  167. package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +2 -16
  168. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +8 -54
  169. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +4 -13
  170. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +0 -2
  171. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +2 -11
  172. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +13 -49
  173. package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +0 -8
  174. package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +16 -24
  175. package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +3 -31
  176. package/dist/es2019/plugins/table/ui/LayoutButton/index.js +2 -29
  177. package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +0 -12
  178. package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +6 -12
  179. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +0 -9
  180. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -19
  181. package/dist/es2019/plugins/table/ui/common-styles.js +6 -5
  182. package/dist/es2019/plugins/table/ui/consts.js +4 -3
  183. package/dist/es2019/plugins/table/ui/ui-styles.js +0 -10
  184. package/dist/es2019/plugins/table/utils/analytics.js +0 -8
  185. package/dist/es2019/plugins/table/utils/collapse.js +3 -14
  186. package/dist/es2019/plugins/table/utils/column-controls.js +22 -37
  187. package/dist/es2019/plugins/table/utils/decoration.js +13 -51
  188. package/dist/es2019/plugins/table/utils/dom.js +3 -19
  189. package/dist/es2019/plugins/table/utils/nodes.js +2 -15
  190. package/dist/es2019/plugins/table/utils/paste.js +17 -22
  191. package/dist/es2019/plugins/table/utils/row-controls.js +12 -45
  192. package/dist/es2019/plugins/table/utils/selection.js +0 -21
  193. package/dist/es2019/plugins/table/utils/table.js +0 -2
  194. package/dist/es2019/version.json +1 -1
  195. package/dist/esm/plugins/table/commands/clear.js +3 -8
  196. package/dist/esm/plugins/table/commands/collapse.js +0 -3
  197. package/dist/esm/plugins/table/commands/go-to-next-cell.js +6 -9
  198. package/dist/esm/plugins/table/commands/hover.js +8 -18
  199. package/dist/esm/plugins/table/commands/insert.js +16 -36
  200. package/dist/esm/plugins/table/commands/misc.js +39 -78
  201. package/dist/esm/plugins/table/commands/selection.js +21 -78
  202. package/dist/esm/plugins/table/commands/sort.js +2 -14
  203. package/dist/esm/plugins/table/commands/split-cell.js +3 -8
  204. package/dist/esm/plugins/table/commands/toggle.js +11 -20
  205. package/dist/esm/plugins/table/commands-with-analytics.js +50 -85
  206. package/dist/esm/plugins/table/create-plugin-config.js +0 -3
  207. package/dist/esm/plugins/table/event-handlers.js +58 -123
  208. package/dist/esm/plugins/table/handlers.js +11 -29
  209. package/dist/esm/plugins/table/index.js +47 -60
  210. package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -44
  211. package/dist/esm/plugins/table/nodeviews/TableComponent.js +82 -181
  212. package/dist/esm/plugins/table/nodeviews/table.js +12 -52
  213. package/dist/esm/plugins/table/nodeviews/tableCell.js +15 -33
  214. package/dist/esm/plugins/table/nodeviews/update-overflow-shadows.js +3 -10
  215. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +0 -5
  216. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -19
  217. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-resizing.js +8 -13
  218. package/dist/esm/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +1 -1
  219. package/dist/esm/plugins/table/pm-plugins/keymap.js +2 -3
  220. package/dist/esm/plugins/table/pm-plugins/main.js +20 -47
  221. package/dist/esm/plugins/table/pm-plugins/plugin-factory.js +25 -37
  222. package/dist/esm/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -3
  223. package/dist/esm/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +3 -15
  224. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -9
  225. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +58 -147
  226. package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin-state.js +15 -27
  227. package/dist/esm/plugins/table/pm-plugins/sticky-headers/util.js +0 -3
  228. package/dist/esm/plugins/table/pm-plugins/table-local-id.js +14 -37
  229. package/dist/esm/plugins/table/pm-plugins/table-resizing/commands.js +12 -24
  230. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -36
  231. package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin-factory.js +0 -6
  232. package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin.js +5 -8
  233. package/dist/esm/plugins/table/pm-plugins/table-resizing/reducer.js +0 -7
  234. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -4
  235. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -12
  236. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/content-width.js +5 -22
  237. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/dom.js +4 -23
  238. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +15 -23
  239. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +15 -60
  240. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +34 -55
  241. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +12 -24
  242. package/dist/esm/plugins/table/reducer.js +0 -20
  243. package/dist/esm/plugins/table/toolbar.js +13 -63
  244. package/dist/esm/plugins/table/transforms/column-width.js +12 -32
  245. package/dist/esm/plugins/table/transforms/delete-columns.js +11 -62
  246. package/dist/esm/plugins/table/transforms/delete-rows.js +4 -30
  247. package/dist/esm/plugins/table/transforms/fix-tables.js +24 -49
  248. package/dist/esm/plugins/table/transforms/merge.js +16 -75
  249. package/dist/esm/plugins/table/transforms/metadata.js +3 -2
  250. package/dist/esm/plugins/table/transforms/replace-table.js +2 -6
  251. package/dist/esm/plugins/table/transforms/split.js +18 -29
  252. package/dist/esm/plugins/table/types.js +0 -6
  253. package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +10 -31
  254. package/dist/esm/plugins/table/ui/FloatingContextualButton/styles.js +0 -2
  255. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +46 -126
  256. package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +13 -24
  257. package/dist/esm/plugins/table/ui/FloatingContextualMenu/styles.js +0 -2
  258. package/dist/esm/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +5 -7
  259. package/dist/esm/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +3 -13
  260. package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +19 -68
  261. package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +6 -14
  262. package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +5 -18
  263. package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +25 -57
  264. package/dist/esm/plugins/table/ui/LayoutButton/index.js +16 -47
  265. package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +14 -35
  266. package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +20 -38
  267. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +10 -29
  268. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +33 -62
  269. package/dist/esm/plugins/table/ui/common-styles.js +6 -7
  270. package/dist/esm/plugins/table/ui/consts.js +4 -3
  271. package/dist/esm/plugins/table/ui/ui-styles.js +0 -12
  272. package/dist/esm/plugins/table/utils/analytics.js +4 -13
  273. package/dist/esm/plugins/table/utils/collapse.js +4 -15
  274. package/dist/esm/plugins/table/utils/column-controls.js +25 -41
  275. package/dist/esm/plugins/table/utils/decoration.js +46 -88
  276. package/dist/esm/plugins/table/utils/dom.js +4 -20
  277. package/dist/esm/plugins/table/utils/nodes.js +5 -18
  278. package/dist/esm/plugins/table/utils/paste.js +24 -29
  279. package/dist/esm/plugins/table/utils/row-controls.js +6 -46
  280. package/dist/esm/plugins/table/utils/selection.js +3 -26
  281. package/dist/esm/plugins/table/utils/table.js +0 -2
  282. package/dist/esm/version.json +1 -1
  283. package/package.json +2 -2
  284. package/src/__tests__/visual-regression/cell-options-menu.ts +1 -12
@@ -1,26 +1,17 @@
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.removeExtraneousColumnWidths = exports.fixTables = exports.fixAutoSizedTable = exports.fireAnalytics = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _styles = require("@atlaskit/editor-common/styles");
13
-
14
10
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
15
-
16
11
  var _utils = require("@atlaskit/editor-common/utils");
17
-
18
12
  var _utils2 = require("../pm-plugins/table-resizing/utils");
19
-
20
13
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
-
22
14
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
-
24
15
  var fireAnalytics = function fireAnalytics() {
25
16
  var properties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26
17
  return (0, _utils.sendLogs)({
@@ -34,14 +25,11 @@ var fireAnalytics = function fireAnalytics() {
34
25
  }]
35
26
  });
36
27
  };
37
-
38
28
  exports.fireAnalytics = fireAnalytics;
39
-
40
29
  var validateTableCellNodeAttrs = function validateTableCellNodeAttrs(_ref, reportInvalidTableCellSpanAttrs) {
41
30
  var colspan = _ref.colspan,
42
- rowspan = _ref.rowspan,
43
- tableLocalId = _ref.tableLocalId;
44
-
31
+ rowspan = _ref.rowspan,
32
+ tableLocalId = _ref.tableLocalId;
45
33
  if (colspan && colspan < 0) {
46
34
  reportInvalidTableCellSpanAttrs({
47
35
  nodeType: 'tableCell',
@@ -51,7 +39,6 @@ var validateTableCellNodeAttrs = function validateTableCellNodeAttrs(_ref, repor
51
39
  spanValue: colspan
52
40
  });
53
41
  }
54
-
55
42
  if (rowspan && rowspan < 0) {
56
43
  reportInvalidTableCellSpanAttrs({
57
44
  nodeType: 'tableCell',
@@ -61,25 +48,23 @@ var validateTableCellNodeAttrs = function validateTableCellNodeAttrs(_ref, repor
61
48
  spanValue: rowspan
62
49
  });
63
50
  }
64
-
65
51
  return;
66
- }; // We attempt to patch the document when we have extra, unneeded, column widths
52
+ };
53
+
54
+ // We attempt to patch the document when we have extra, unneeded, column widths
67
55
  // Take this node for example:
68
56
  //
69
57
  // ['td', { colwidth: [100, 100, 100], colspan: 2 }]
70
58
  //
71
59
  // This row only spans two columns, yet it contains widths for 3.
72
60
  // We remove the third width here, assumed duplicate content.
73
-
74
-
75
61
  var removeExtraneousColumnWidths = function removeExtraneousColumnWidths(node, basePos, tr, reportInvalidTableCellSpanAttrs) {
76
62
  var hasProblems = false;
77
63
  tr = replaceCells(tr, node, basePos, function (cell) {
78
64
  var _cell$attrs = cell.attrs,
79
- colwidth = _cell$attrs.colwidth,
80
- colspan = _cell$attrs.colspan,
81
- rowspan = _cell$attrs.rowspan;
82
-
65
+ colwidth = _cell$attrs.colwidth,
66
+ colspan = _cell$attrs.colspan,
67
+ rowspan = _cell$attrs.rowspan;
83
68
  if (reportInvalidTableCellSpanAttrs) {
84
69
  validateTableCellNodeAttrs({
85
70
  colspan: colspan,
@@ -87,29 +72,23 @@ var removeExtraneousColumnWidths = function removeExtraneousColumnWidths(node, b
87
72
  tableLocalId: node.attrs.localId
88
73
  }, reportInvalidTableCellSpanAttrs);
89
74
  }
90
-
91
75
  if (colwidth && colwidth.length > colspan) {
92
76
  hasProblems = true;
93
77
  return cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
94
78
  colwidth: colwidth.slice(0, colspan)
95
79
  }), cell.content, cell.marks);
96
80
  }
97
-
98
81
  return cell;
99
82
  });
100
-
101
83
  if (hasProblems) {
102
84
  fireAnalytics({
103
85
  message: 'removeExtraneousColumnWidths'
104
86
  });
105
87
  return true;
106
88
  }
107
-
108
89
  return false;
109
90
  };
110
-
111
91
  exports.removeExtraneousColumnWidths = removeExtraneousColumnWidths;
112
-
113
92
  var fixTables = function fixTables(tr, reportInvalidTableCellSpanAttrs) {
114
93
  var hasProblems = false;
115
94
  tr.doc.descendants(function (node, pos) {
@@ -118,11 +97,12 @@ var fixTables = function fixTables(tr, reportInvalidTableCellSpanAttrs) {
118
97
  hasProblems = removeExtraneousColumnWidths(node, tr.mapping.map(pos), tr, reportInvalidTableCellSpanAttrs);
119
98
  }
120
99
  });
121
-
122
100
  if (hasProblems) {
123
101
  return tr;
124
102
  }
125
- }; // When we get a table with an 'auto' attribute, we want to:
103
+ };
104
+
105
+ // When we get a table with an 'auto' attribute, we want to:
126
106
  // 1. render with table-layout: auto
127
107
  // 2. capture the column widths
128
108
  // 3. set the column widths as attributes, and remove the 'auto' attribute,
@@ -133,10 +113,7 @@ var fixTables = function fixTables(tr, reportInvalidTableCellSpanAttrs) {
133
113
  //
134
114
  // We use this when migrating TinyMCE tables for Confluence, for example:
135
115
  // https://pug.jira-dev.com/wiki/spaces/AEC/pages/3362882215/How+do+we+map+TinyMCE+tables+to+Fabric+tables
136
-
137
-
138
116
  exports.fixTables = fixTables;
139
-
140
117
  var fixAutoSizedTable = function fixAutoSizedTable(view, tableNode, tableRef, tablePos, opts) {
141
118
  var tr = view.state.tr;
142
119
  var domAtPos = view.domAtPos.bind(view);
@@ -146,16 +123,15 @@ var fixAutoSizedTable = function fixAutoSizedTable(view, tableNode, tableRef, ta
146
123
  return acc + current;
147
124
  }, 0);
148
125
  var tableLayout = getLayoutBasedOnWidth(totalContentWidth);
149
- var maxLayoutSize = (0, _utils2.getLayoutSize)(tableLayout, opts.containerWidth, {}); // Content width will generally not meet the constraints of the layout
126
+ var maxLayoutSize = (0, _utils2.getLayoutSize)(tableLayout, opts.containerWidth, {});
127
+
128
+ // Content width will generally not meet the constraints of the layout
150
129
  // whether it be below or above, so we scale our columns widths
151
130
  // to meet these requirements
152
-
153
131
  var scale = 1;
154
-
155
132
  if (totalContentWidth !== maxLayoutSize) {
156
133
  scale = maxLayoutSize / totalContentWidth;
157
134
  }
158
-
159
135
  var scaledColumnWidths = colWidths.map(function (width) {
160
136
  return Math.floor(width * scale);
161
137
  });
@@ -164,16 +140,15 @@ var fixAutoSizedTable = function fixAutoSizedTable(view, tableNode, tableRef, ta
164
140
  return cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
165
141
  colwidth: newColWidths.length ? newColWidths : null
166
142
  }), cell.content, cell.marks);
167
- }); // clear autosizing on the table node
143
+ });
168
144
 
145
+ // clear autosizing on the table node
169
146
  return tr.setNodeMarkup(tablePos, undefined, _objectSpread(_objectSpread({}, tableNode.attrs), {}, {
170
147
  layout: tableLayout,
171
148
  __autoSize: false
172
149
  })).setMeta('addToHistory', false);
173
150
  };
174
-
175
151
  exports.fixAutoSizedTable = fixAutoSizedTable;
176
-
177
152
  var getLayoutBasedOnWidth = function getLayoutBasedOnWidth(totalWidth) {
178
153
  if (totalWidth > _editorSharedStyles.akEditorWideLayoutWidth) {
179
154
  return 'full-width';
@@ -183,20 +158,15 @@ var getLayoutBasedOnWidth = function getLayoutBasedOnWidth(totalWidth) {
183
158
  return 'default';
184
159
  }
185
160
  };
186
-
187
161
  function parseDOMColumnWidths(domAtPos, tableNode, tableStart, tableRef) {
188
162
  var row = tableRef.querySelector('tr');
189
-
190
163
  if (!row) {
191
164
  return [];
192
165
  }
193
-
194
166
  var cols = [];
195
-
196
167
  for (var col = 0; col < row.childElementCount; col++) {
197
168
  var currentCol = row.children[col];
198
169
  var colspan = Number(currentCol.getAttribute('colspan') || 1);
199
-
200
170
  for (var span = 0; span < colspan; span++) {
201
171
  var colIdx = col + span;
202
172
  var cells = (0, _utils2.getCellsRefsInColumn)(colIdx, tableNode, tableStart, domAtPos);
@@ -206,45 +176,38 @@ function parseDOMColumnWidths(domAtPos, tableNode, tableStart, tableRef) {
206
176
  cols[colIdx] = Math.max(colWidth, _styles.tableCellMinWidth);
207
177
  }
208
178
  }
209
-
210
179
  return cols;
211
- } // TODO: move to prosemirror-utils
212
-
180
+ }
213
181
 
182
+ // TODO: move to prosemirror-utils
214
183
  var replaceCells = function replaceCells(tr, table, tablePos, modifyCell) {
215
184
  var rows = [];
216
185
  var modifiedCells = 0;
217
-
218
186
  for (var _rowIndex2 = 0; _rowIndex2 < table.childCount; _rowIndex2++) {
219
187
  var row = table.child(_rowIndex2);
220
188
  var cells = [];
221
-
222
189
  for (var _colIndex = 0; _colIndex < row.childCount; _colIndex++) {
223
- var _cell = row.child(_colIndex); // FIXME
190
+ var _cell = row.child(_colIndex);
191
+
192
+ // FIXME
224
193
  // The rowIndex and colIndex are not accurate in a merged cell scenario
225
194
  // e.g. table with 5 columns might have only one cell in a row, colIndex will be 1, where it should be 4
226
-
227
-
228
195
  var node = modifyCell(_cell, _rowIndex2, _colIndex);
229
-
230
196
  if (node.sameMarkup(_cell) === false) {
231
197
  modifiedCells++;
232
198
  }
233
-
234
199
  cells.push(node);
235
200
  }
236
-
237
201
  if (cells.length) {
238
202
  rows.push(row.type.createChecked(row.attrs, cells, row.marks));
239
203
  }
240
- } // Check if the table has changed before replacing.
241
- // If no cells are modified our counter will be zero.
242
-
204
+ }
243
205
 
206
+ // Check if the table has changed before replacing.
207
+ // If no cells are modified our counter will be zero.
244
208
  if (rows.length && modifiedCells !== 0) {
245
209
  var newTable = table.type.createChecked(table.attrs, rows, table.marks);
246
210
  return tr.replaceWith(tablePos, tablePos + table.nodeSize, newTable);
247
211
  }
248
-
249
212
  return tr;
250
213
  };
@@ -69,17 +69,10 @@ Object.defineProperty(exports, "updateColumnWidths", {
69
69
  return _columnWidth.updateColumnWidths;
70
70
  }
71
71
  });
72
-
73
72
  var _merge = require("./merge");
74
-
75
73
  var _fixTables = require("./fix-tables");
76
-
77
74
  var _deleteColumns = require("./delete-columns");
78
-
79
75
  var _deleteRows = require("./delete-rows");
80
-
81
76
  var _columnWidth = require("./column-width");
82
-
83
77
  var _metadata = require("./metadata");
84
-
85
78
  var _replaceTable = require("./replace-table");
@@ -1,99 +1,73 @@
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.canMergeCells = canMergeCells;
9
8
  exports.mergeCells = mergeCells;
10
9
  exports.removeEmptyColumns = removeEmptyColumns;
11
-
12
10
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
13
-
14
11
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
-
16
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
-
18
13
  var _prosemirrorModel = require("prosemirror-model");
19
-
20
14
  var _prosemirrorState = require("prosemirror-state");
21
-
22
15
  var _tableMap = require("@atlaskit/editor-tables/table-map");
23
-
24
16
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
25
-
26
17
  var _utils = require("@atlaskit/editor-tables/utils");
27
-
28
18
  var _metadata = require("./metadata");
29
-
30
19
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
31
-
32
20
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
33
-
34
21
  // re-creates table node with merged cells
35
22
  function mergeCells(tr) {
36
23
  var selection = tr.selection;
37
-
38
24
  if (!(selection instanceof _cellSelection.CellSelection) || !canMergeCells(tr)) {
39
25
  return tr;
40
26
  }
41
-
42
27
  var rect = (0, _utils.getSelectionRect)(selection);
43
28
  var table = (0, _utils.findTable)(selection);
44
-
45
29
  var map = _tableMap.TableMap.get(table.node);
46
-
47
30
  var seen = [];
48
31
  var selectedCells = map.cellsInRect(rect);
49
32
  var mergedCellPos;
50
33
  var rows = [];
51
-
52
34
  for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
53
35
  var rowCells = [];
54
36
  var row = table.node.child(rowIndex);
55
-
56
37
  for (var colIndex = 0; colIndex < map.width; colIndex++) {
57
38
  var cellPos = map.map[rowIndex * map.width + colIndex];
58
39
  var cell = table.node.nodeAt(cellPos);
59
-
60
40
  if (!cell || seen.indexOf(cellPos) > -1) {
61
41
  continue;
62
42
  }
43
+ seen.push(cellPos);
63
44
 
64
- seen.push(cellPos); // merged cell
65
-
45
+ // merged cell
66
46
  if (colIndex === rect.left && rowIndex === rect.top) {
67
- mergedCellPos = cellPos; // merge content of the selected cells, dropping empty cells
68
-
47
+ mergedCellPos = cellPos;
48
+ // merge content of the selected cells, dropping empty cells
69
49
  var content = isEmptyCell(cell) ? _prosemirrorModel.Fragment.empty : cell.content;
70
50
  var seenContent = [mergedCellPos];
71
-
72
51
  for (var i = rect.top; i < rect.bottom; i++) {
73
52
  for (var j = rect.left; j < rect.right; j++) {
74
53
  var pos = map.map[i * map.width + j];
75
-
76
54
  if (seenContent.indexOf(pos) === -1) {
77
55
  seenContent.push(pos);
78
56
  var copyCell = table.node.nodeAt(pos);
79
-
80
57
  if (copyCell && !isEmptyCell(copyCell)) {
81
58
  content = content.append(copyCell.content);
82
59
  }
83
60
  }
84
61
  }
85
62
  }
86
-
87
63
  var rowspan = rect.bottom - rect.top;
88
-
89
64
  if (rowspan < 1) {
90
65
  return (0, _metadata.setMeta)({
91
66
  type: 'MERGE_CELLS',
92
67
  problem: 'NEGATIVE_ROWSPAN'
93
68
  })(tr);
94
- } // update colspan and rowspan of the merged cell to span the selection
95
-
96
-
69
+ }
70
+ // update colspan and rowspan of the merged cell to span the selection
97
71
  var attrs = addColSpan(_objectSpread(_objectSpread({}, cell.attrs), {}, {
98
72
  rowspan: rowspan
99
73
  }), cell.attrs.colspan, rect.right - rect.left - cell.attrs.colspan);
@@ -105,7 +79,6 @@ function mergeCells(tr) {
105
79
  rowCells.push(cell);
106
80
  }
107
81
  }
108
-
109
82
  if (rowCells.length) {
110
83
  rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
111
84
  } else {
@@ -114,22 +87,17 @@ function mergeCells(tr) {
114
87
  var prevRow = rows[_i];
115
88
  var cells = [];
116
89
  var rowChanged = false;
117
-
118
90
  for (var _j = 0; _j < prevRow.childCount; _j++) {
119
91
  var _cell = prevRow.child(_j);
120
-
121
92
  var _rowspan = _cell.attrs.rowspan;
122
-
123
93
  if (_rowspan && _rowspan + _i - 1 >= rows.length) {
124
94
  rowChanged = true;
125
-
126
95
  if (_rowspan < 2) {
127
96
  return (0, _metadata.setMeta)({
128
97
  type: 'MERGE_CELLS',
129
98
  problem: 'NEGATIVE_ROWSPAN'
130
99
  })(tr);
131
100
  }
132
-
133
101
  cells.push(_cell.type.createChecked(_objectSpread(_objectSpread({}, _cell.attrs), {}, {
134
102
  rowspan: _rowspan - 1
135
103
  }), _cell.content, _cell.marks));
@@ -137,120 +105,94 @@ function mergeCells(tr) {
137
105
  cells.push(_cell);
138
106
  }
139
107
  }
140
-
141
108
  if (rowChanged) {
142
109
  rows[_i] = row.type.createChecked(prevRow.attrs, cells, prevRow.marks);
143
110
  }
144
111
  }
145
112
  }
146
- } // empty tables? cancel merging like nothing happened
147
-
113
+ }
148
114
 
115
+ // empty tables? cancel merging like nothing happened
149
116
  if (!rows.length) {
150
117
  return (0, _metadata.setMeta)({
151
118
  type: 'MERGE_CELLS',
152
119
  problem: 'EMPTY_TABLE'
153
120
  })(tr);
154
121
  }
155
-
156
122
  var newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
157
123
  var fixedTable = removeEmptyColumns(newTable);
158
-
159
124
  if (fixedTable === null) {
160
125
  return (0, _metadata.setMeta)({
161
126
  type: 'MERGE_CELLS',
162
127
  problem: 'REMOVE_EMPTY_COLUMNS'
163
128
  })(tr);
164
129
  }
165
-
166
130
  return (0, _metadata.setMeta)({
167
131
  type: 'MERGE_CELLS'
168
132
  })(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable).setSelection(_prosemirrorState.Selection.near(tr.doc.resolve((mergedCellPos || 0) + table.start))));
169
133
  }
170
-
171
134
  function canMergeCells(tr) {
172
135
  var selection = tr.selection;
173
-
174
136
  if (!(selection instanceof _cellSelection.CellSelection) || selection.$anchorCell.pos === selection.$headCell.pos) {
175
137
  return false;
176
138
  }
177
-
178
139
  var rect = (0, _utils.getSelectionRect)(selection);
179
-
180
140
  if (!rect) {
181
141
  return false;
182
142
  }
183
-
184
143
  var table = selection.$anchorCell.node(-1);
185
-
186
144
  var map = _tableMap.TableMap.get(table);
187
-
188
145
  if (cellsOverlapRectangle(map, rect)) {
189
146
  return false;
190
147
  }
191
-
192
148
  return true;
193
149
  }
194
-
195
150
  function isEmptyCell(cell) {
196
151
  var content = cell.content;
197
152
  return content.childCount === 1 && content.firstChild && content.firstChild.isTextblock && content.firstChild.childCount === 0;
198
153
  }
199
-
200
154
  function addColSpan(attrs, pos) {
201
155
  var span = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
202
-
203
156
  var newAttrs = _objectSpread(_objectSpread({}, attrs), {}, {
204
157
  colspan: (attrs.colspan || 1) + span
205
158
  });
206
-
207
159
  if (newAttrs.colwidth) {
208
160
  newAttrs.colwidth = newAttrs.colwidth.slice();
209
-
210
161
  for (var i = 0; i < span; i++) {
211
162
  newAttrs.colwidth.splice(pos, 0, 0);
212
163
  }
213
164
  }
214
-
215
165
  return newAttrs;
216
166
  }
217
-
218
167
  function cellsOverlapRectangle(_ref, rect) {
219
168
  var width = _ref.width,
220
- height = _ref.height,
221
- map = _ref.map;
169
+ height = _ref.height,
170
+ map = _ref.map;
222
171
  var indexTop = rect.top * width + rect.left;
223
172
  var indexLeft = indexTop;
224
173
  var indexBottom = (rect.bottom - 1) * width + rect.left;
225
174
  var indexRight = indexTop + (rect.right - rect.left - 1);
226
-
227
175
  for (var i = rect.top; i < rect.bottom; i++) {
228
176
  if (rect.left > 0 && map[indexLeft] === map[indexLeft - 1] || rect.right < width && map[indexRight] === map[indexRight + 1]) {
229
177
  return true;
230
178
  }
231
-
232
179
  indexLeft += width;
233
180
  indexRight += width;
234
181
  }
235
-
236
182
  for (var _i2 = rect.left; _i2 < rect.right; _i2++) {
237
183
  if (rect.top > 0 && map[indexTop] === map[indexTop - width] || rect.bottom < height && map[indexBottom] === map[indexBottom + width]) {
238
184
  return true;
239
185
  }
240
-
241
186
  indexTop++;
242
187
  indexBottom++;
243
188
  }
244
-
245
189
  return false;
246
- } // returns an array of numbers, each number indicates the minimum colSpan in each column
247
-
190
+ }
248
191
 
192
+ // returns an array of numbers, each number indicates the minimum colSpan in each column
249
193
  function getMinColSpans(table) {
250
194
  var map = _tableMap.TableMap.get(table);
251
-
252
195
  var minColspans = [];
253
-
254
196
  for (var colIndex = map.width - 1; colIndex >= 0; colIndex--) {
255
197
  var cellsPositions = map.cellsInRect({
256
198
  left: colIndex,
@@ -258,17 +200,15 @@ function getMinColSpans(table) {
258
200
  top: 0,
259
201
  bottom: map.height
260
202
  });
261
-
262
203
  if (cellsPositions.length) {
263
204
  var colspans = cellsPositions.map(function (cellPos) {
264
205
  var cell = table.nodeAt(cellPos);
265
-
266
206
  if (cell) {
267
207
  return cell.attrs.colspan;
268
208
  }
269
209
  });
270
- var minColspan = Math.min.apply(Math, (0, _toConsumableArray2.default)(colspans)); // only care about the case when the next column is invisible
271
-
210
+ var minColspan = Math.min.apply(Math, (0, _toConsumableArray2.default)(colspans));
211
+ // only care about the case when the next column is invisible
272
212
  if (!minColspans[colIndex + 1]) {
273
213
  minColspans[colIndex] = minColspan;
274
214
  } else {
@@ -276,43 +216,33 @@ function getMinColSpans(table) {
276
216
  }
277
217
  }
278
218
  }
279
-
280
219
  return minColspans;
281
220
  }
282
-
283
221
  function removeEmptyColumns(table) {
284
222
  var map = _tableMap.TableMap.get(table);
285
-
286
223
  var minColSpans = getMinColSpans(table);
287
-
288
224
  if (!minColSpans.some(function (colspan) {
289
225
  return colspan > 1;
290
226
  })) {
291
227
  return table;
292
228
  }
293
-
294
229
  var rows = [];
295
-
296
230
  var _loop = function _loop(rowIndex) {
297
231
  var cellsByCols = {};
298
232
  var cols = Object.keys(minColSpans).map(Number);
299
-
300
233
  for (var idx in cols) {
301
234
  var colIndex = cols[idx];
302
235
  var cellPos = map.map[colIndex + rowIndex * map.width];
303
236
  var rect = map.findCell(cellPos);
304
237
  var cell = cellsByCols[rect.left] || table.nodeAt(cellPos);
305
-
306
238
  if (cell && rect.top === rowIndex) {
307
239
  if (minColSpans[colIndex] > 1) {
308
240
  var colspan = cell.attrs.colspan - minColSpans[colIndex] + 1;
309
-
310
241
  if (colspan < 1) {
311
242
  return {
312
243
  v: null
313
244
  };
314
245
  }
315
-
316
246
  var colwidth = cell.attrs.colwidth;
317
247
  var newCell = cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
318
248
  colspan: colspan,
@@ -324,26 +254,20 @@ function removeEmptyColumns(table) {
324
254
  }
325
255
  }
326
256
  }
327
-
328
257
  var rowCells = Object.keys(cellsByCols).map(function (col) {
329
258
  return cellsByCols[col];
330
259
  });
331
260
  var row = table.child(rowIndex);
332
-
333
261
  if (row) {
334
262
  rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
335
263
  }
336
264
  };
337
-
338
265
  for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
339
266
  var _ret = _loop(rowIndex);
340
-
341
267
  if ((0, _typeof2.default)(_ret) === "object") return _ret.v;
342
268
  }
343
-
344
269
  if (!rows.length) {
345
270
  return null;
346
271
  }
347
-
348
272
  return table.type.createChecked(table.attrs, rows, table.marks);
349
273
  }
@@ -4,20 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.setMeta = void 0;
7
-
8
7
  var _pluginKey = require("../pm-plugins/plugin-key");
9
-
10
8
  var _fixTables = require("./fix-tables");
11
-
12
9
  var setMeta = function setMeta(meta) {
13
10
  return function (tr) {
14
11
  if ('problem' in meta) {
15
12
  // Send analytics event whenever we encounter with a problem
16
13
  (0, _fixTables.fireAnalytics)(meta);
17
14
  }
18
-
19
15
  return tr.setMeta(_pluginKey.pluginKey, meta);
20
16
  };
21
17
  };
22
-
23
18
  exports.setMeta = setMeta;
@@ -4,30 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.replaceSelectedTable = void 0;
7
-
8
7
  var _prosemirrorState = require("prosemirror-state");
9
-
10
8
  var _prosemirrorModel = require("prosemirror-model");
11
-
12
9
  var _utils = require("@atlaskit/editor-tables/utils");
13
-
14
10
  var _analytics = require("@atlaskit/editor-common/analytics");
15
-
16
11
  var _utils2 = require("../utils");
17
-
18
12
  var replaceSelectedTable = function replaceSelectedTable(state, content, inputMethod, editorAnalyticsAPI) {
19
13
  if ((0, _utils.isTableSelected)(state.selection)) {
20
14
  var table = (0, _utils.findTable)(state.selection);
21
-
22
15
  if (table) {
23
16
  var slice = typeof content === 'string' ? new _prosemirrorModel.Slice(_prosemirrorModel.Fragment.from(state.schema.text(content)), 0, 0) : content;
24
17
  var tr = state.tr.replace(table.pos, table.pos + table.node.nodeSize, slice);
25
18
  tr.setSelection(_prosemirrorState.TextSelection.create(tr.doc, table.pos + slice.size + 1));
26
-
27
19
  var _getSelectedTableInfo = (0, _utils2.getSelectedTableInfo)(state.selection),
28
- totalRowCount = _getSelectedTableInfo.totalRowCount,
29
- totalColumnCount = _getSelectedTableInfo.totalColumnCount;
30
-
20
+ totalRowCount = _getSelectedTableInfo.totalRowCount,
21
+ totalColumnCount = _getSelectedTableInfo.totalColumnCount;
31
22
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
32
23
  action: _analytics.TABLE_ACTION.REPLACED,
33
24
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
@@ -41,8 +32,6 @@ var replaceSelectedTable = function replaceSelectedTable(state, content, inputMe
41
32
  return tr;
42
33
  }
43
34
  }
44
-
45
35
  return state.tr;
46
36
  };
47
-
48
37
  exports.replaceSelectedTable = replaceSelectedTable;