@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,100 +1,80 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
-
4
3
  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; }
5
-
6
4
  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) { _defineProperty(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; }
7
-
8
5
  import { Selection } from 'prosemirror-state';
9
6
  import { TableMap } from '@atlaskit/editor-tables/table-map';
10
7
  import { findTable } from '@atlaskit/editor-tables/utils';
11
8
  import { AddColumnStep } from '@atlaskit/adf-schema/steps';
12
9
  import { setMeta } from './metadata';
13
10
  import { splitCellsInColumns } from './split';
14
-
15
11
  var deleteColumnsCustomStep = function deleteColumnsCustomStep(rect) {
16
12
  return function (tr) {
17
13
  var table = findTable(tr.selection);
18
-
19
14
  if (!table) {
20
15
  return tr;
21
- } // Need to split all the merge in the ranges (this is the current behaviour)
16
+ }
17
+
18
+ // Need to split all the merge in the ranges (this is the current behaviour)
22
19
  // Maybe is better to split only the last column?
23
20
  // 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.
21
+ splitCellsInColumns(tr, table.pos, rect.left, rect.right);
24
22
 
25
-
26
- splitCellsInColumns(tr, table.pos, rect.left, rect.right); // Delete the columns
27
-
23
+ // Delete the columns
28
24
  var mapStart = tr.mapping.maps.length;
29
25
  var originalDoc = tr.doc;
30
26
  var deletedColumns = [];
31
-
32
27
  for (var i = rect.left; i < rect.right; i++) {
33
28
  var step = AddColumnStep.create(originalDoc, table.pos, i, true);
34
29
  deletedColumns.push(i);
35
30
  tr.step(step.map(tr.mapping.slice(mapStart)));
36
31
  }
37
-
38
32
  var tablePosResult = tr.mapping.mapResult(table.pos);
39
-
40
33
  if (tablePosResult.deleted) {
41
34
  var pos = Math.min(tablePosResult.pos, tr.doc.nodeSize - 1);
42
35
  tr.setSelection(Selection.near(tr.doc.resolve(pos)));
43
36
  } else {
44
37
  var newTable = tr.doc.nodeAt(tablePosResult.pos);
45
-
46
38
  if (newTable) {
47
39
  var cursorPos = getNextCursorPos(newTable, deletedColumns);
48
40
  tr.setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos)));
49
41
  }
50
42
  }
51
-
52
43
  return tr;
53
44
  };
54
45
  };
55
-
56
46
  var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
57
47
  return function (tr) {
58
48
  var table = findTable(tr.selection);
59
-
60
49
  if (!table) {
61
50
  return tr;
62
51
  }
63
-
64
52
  var columnsToDelete = [];
65
-
66
53
  for (var i = rect.left; i < rect.right; i++) {
67
54
  columnsToDelete.push(i);
68
55
  }
69
-
70
56
  if (!columnsToDelete.length) {
71
57
  return tr;
72
58
  }
73
-
74
59
  var map = TableMap.get(table.node);
75
60
  var rows = [];
76
61
  var seen = {};
77
62
  var deletedCells = {};
78
-
79
63
  for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
80
64
  var rowCells = [];
81
65
  var row = table.node.child(rowIndex);
82
-
83
66
  var _loop = function _loop(colIndex) {
84
67
  var cellPos = map.map[rowIndex * map.width + colIndex];
85
68
  var cell = table.node.nodeAt(cellPos);
86
-
87
69
  if (!cell) {
88
70
  return "continue";
89
71
  }
90
-
91
72
  var cellsInColumn = map.cellsInRect({
92
73
  left: colIndex,
93
74
  top: 0,
94
75
  right: colIndex + 1,
95
76
  bottom: map.height
96
77
  });
97
-
98
78
  if (columnsToDelete.indexOf(colIndex) === -1) {
99
79
  // decrement colspans for col-spanning cells that overlap deleted columns
100
80
  if (cellsInColumn.indexOf(cellPos) > -1 && !seen[cellPos]) {
@@ -104,12 +84,10 @@ var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
104
84
  overlappingCols += 1;
105
85
  }
106
86
  });
107
-
108
87
  if (overlappingCols > 0) {
109
88
  var attrs = _objectSpread(_objectSpread({}, cell.attrs), {}, {
110
89
  colspan: cell.attrs.colspan - overlappingCols
111
90
  });
112
-
113
91
  if (cell.attrs.colwidth) {
114
92
  var minColIndex = Math.min.apply(Math, columnsToDelete);
115
93
  var pos = minColIndex > 0 ? minColIndex - map.colCount(cellPos) : 0;
@@ -117,7 +95,6 @@ var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
117
95
  colwidth.splice(pos, overlappingCols);
118
96
  attrs.colwidth = colwidth;
119
97
  }
120
-
121
98
  var newCell = cell.type.createChecked(attrs, cell.content, cell.marks);
122
99
  rowCells.push(newCell);
123
100
  seen[cellPos] = true;
@@ -129,20 +106,16 @@ var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
129
106
  colspan: 1,
130
107
  rowspan: 1
131
108
  });
132
-
133
109
  if (cell.attrs.colwidth) {
134
110
  var _pos = colIndex > 0 ? colIndex - map.colCount(cellPos) : 0;
135
-
136
111
  _attrs.colwidth = cell.attrs.colwidth.slice().splice(_pos, 1);
137
112
  }
138
-
139
113
  var _newCell = cell.type.createChecked(_attrs, cell.type.schema.nodes.paragraph.createChecked(), cell.marks);
140
-
141
114
  rowCells.push(_newCell);
142
115
  return "continue";
143
- } // normal cells that we want to keep
144
-
116
+ }
145
117
 
118
+ // normal cells that we want to keep
146
119
  if (!seen[cellPos]) {
147
120
  seen[cellPos] = true;
148
121
  rowCells.push(cell);
@@ -151,121 +124,97 @@ var deleteColumnsLegacy = function deleteColumnsLegacy(rect) {
151
124
  deletedCells[cellPos] = true;
152
125
  }
153
126
  };
154
-
155
127
  for (var colIndex = 0; colIndex < map.width; colIndex++) {
156
128
  var _ret = _loop(colIndex);
157
-
158
129
  if (_ret === "continue") continue;
159
130
  }
160
-
161
131
  if (rowCells.length) {
162
132
  rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
163
133
  }
164
134
  }
165
-
166
135
  if (!rows.length) {
167
136
  return setMeta({
168
137
  type: 'DELETE_COLUMNS',
169
138
  problem: 'EMPTY_TABLE'
170
139
  })(tr);
171
140
  }
172
-
173
141
  var newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
174
142
  var fixedTable = fixRowSpans(newTable);
175
-
176
143
  if (fixedTable === null) {
177
144
  return setMeta({
178
145
  type: 'DELETE_COLUMNS',
179
146
  problem: 'FIX_ROWSPANS'
180
147
  })(tr);
181
148
  }
182
-
183
149
  var cursorPos = getNextCursorPos(newTable, columnsToDelete);
184
150
  return setMeta({
185
151
  type: 'DELETE_COLUMNS'
186
- })(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
152
+ })(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
153
+ // move cursor to the left of the deleted columns if possible, otherwise - to the first column
187
154
  .setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos))));
188
155
  };
189
156
  };
190
-
191
157
  function getNextCursorPos(table, deletedColumns) {
192
158
  var minColumn = Math.min.apply(Math, _toConsumableArray(deletedColumns));
193
159
  var nextColumnWithCursor = minColumn > 0 ? minColumn - 1 : 0;
194
160
  var map = TableMap.get(table);
195
161
  return map.map[nextColumnWithCursor];
196
- } // returns an array of numbers, each number indicates the minimum rowSpan in each row
197
-
162
+ }
198
163
 
164
+ // returns an array of numbers, each number indicates the minimum rowSpan in each row
199
165
  function getMinRowSpans(table) {
200
166
  var minRowSpans = [];
201
-
202
167
  for (var rowIndex = 0; rowIndex < table.childCount; rowIndex++) {
203
168
  var rowSpans = [];
204
169
  var row = table.child(rowIndex);
205
-
206
170
  for (var colIndex = 0; colIndex < row.childCount; colIndex++) {
207
171
  var cell = row.child(colIndex);
208
172
  rowSpans.push(cell.attrs.rowspan);
209
173
  }
210
-
211
174
  minRowSpans[rowIndex] = Math.min.apply(Math, rowSpans);
212
175
  }
213
-
214
176
  return minRowSpans;
215
177
  }
216
-
217
178
  function fixRowSpans(table) {
218
179
  var map = TableMap.get(table);
219
180
  var minRowSpans = getMinRowSpans(table);
220
-
221
181
  if (!minRowSpans.some(function (rowspan) {
222
182
  return rowspan > 1;
223
183
  })) {
224
184
  return table;
225
185
  }
226
-
227
186
  var rows = [];
228
-
229
187
  for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
230
188
  var row = table.child(rowIndex);
231
-
232
189
  if (minRowSpans[rowIndex] === 1) {
233
190
  rows.push(row);
234
191
  } else {
235
192
  var rowCells = [];
236
-
237
193
  for (var colIndex = 0; colIndex < row.childCount; colIndex++) {
238
194
  var cell = row.child(colIndex);
239
195
  var rowspan = cell.attrs.rowspan - minRowSpans[rowIndex] + 1;
240
-
241
196
  if (rowspan < 1) {
242
197
  return null;
243
198
  }
244
-
245
199
  var newCell = cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
246
200
  rowspan: rowspan
247
201
  }), cell.content, cell.marks);
248
202
  rowCells.push(newCell);
249
203
  }
250
-
251
204
  rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
252
205
  }
253
206
  }
254
-
255
207
  if (!rows.length) {
256
208
  return null;
257
209
  }
258
-
259
210
  return table.type.createChecked(table.attrs, rows, table.marks);
260
211
  }
261
-
262
212
  export var deleteColumns = function deleteColumns(rect) {
263
213
  var allowAddColumnCustomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
264
214
  return function (tr) {
265
215
  if (allowAddColumnCustomStep) {
266
216
  return deleteColumnsCustomStep(rect)(tr);
267
217
  }
268
-
269
218
  return deleteColumnsLegacy(rect)(tr);
270
219
  };
271
220
  };
@@ -1,10 +1,7 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
-
4
3
  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; }
5
-
6
4
  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) { _defineProperty(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; }
7
-
8
5
  import { Selection } from 'prosemirror-state';
9
6
  import { TableMap } from '@atlaskit/editor-tables/table-map';
10
7
  import { findTable } from '@atlaskit/editor-tables/utils';
@@ -14,19 +11,15 @@ export var deleteRows = function deleteRows(rect) {
14
11
  var isHeaderRowRequired = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
15
12
  return function (tr) {
16
13
  var table = findTable(tr.selection);
17
-
18
14
  if (!table) {
19
15
  return tr;
20
16
  }
21
-
22
17
  var rowsToDelete = [];
23
18
  var map = TableMap.get(table.node);
24
-
25
19
  for (var i = rect.top; i < rect.bottom; i++) {
26
20
  // skip header row if its required
27
21
  if (isHeaderRowRequired) {
28
22
  var cell = table.node.nodeAt(map.map[i * map.width]);
29
-
30
23
  if (cell && cell.type !== cell.type.schema.nodes.tableHeader) {
31
24
  rowsToDelete.push(i);
32
25
  }
@@ -34,34 +27,27 @@ export var deleteRows = function deleteRows(rect) {
34
27
  rowsToDelete.push(i);
35
28
  }
36
29
  }
37
-
38
30
  if (!rowsToDelete.length) {
39
31
  return tr;
40
32
  }
41
-
42
33
  var rows = [];
43
34
  var seen = {};
44
35
  var deletedCells = {};
45
-
46
36
  var _loop = function _loop(rowIndex) {
47
37
  var rowCells = [];
48
38
  var row = table.node.child(rowIndex);
49
-
50
39
  var _loop2 = function _loop2(colIndex) {
51
40
  var cellPos = map.map[rowIndex * map.width + colIndex];
52
41
  var cell = table.node.nodeAt(cellPos);
53
-
54
42
  if (!cell) {
55
43
  return "continue";
56
44
  }
57
-
58
45
  var cellsInRow = map.cellsInRect({
59
46
  left: 0,
60
47
  top: rowIndex,
61
48
  right: map.width,
62
49
  bottom: rowIndex + 1
63
50
  });
64
-
65
51
  if (rowsToDelete.indexOf(rowIndex) === -1 && !seen[cellPos]) {
66
52
  // decrement rowspans for row-spanning cells that overlap deleted rows
67
53
  if (cellsInRow.indexOf(cellPos) > -1) {
@@ -71,7 +57,6 @@ export var deleteRows = function deleteRows(rect) {
71
57
  overlappingRows += 1;
72
58
  }
73
59
  });
74
-
75
60
  if (overlappingRows > 0) {
76
61
  var newCell = cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
77
62
  rowspan: cell.attrs.rowspan - overlappingRows
@@ -86,19 +71,16 @@ export var deleteRows = function deleteRows(rect) {
86
71
  colspan: 1,
87
72
  rowspan: 1
88
73
  });
89
-
90
74
  if (cell.attrs.colwidth) {
91
75
  var pos = colIndex > 0 ? colIndex - map.colCount(cellPos) : 0;
92
76
  attrs.colwidth = cell.attrs.colwidth.slice().splice(pos, 1);
93
77
  }
94
-
95
78
  var _newCell = cell.type.createChecked(attrs, cell.type.schema.nodes.paragraph.createChecked(), cell.marks);
96
-
97
79
  rowCells.push(_newCell);
98
80
  return "continue";
99
- } // normal cells that we want to keep
100
-
81
+ }
101
82
 
83
+ // normal cells that we want to keep
102
84
  if (!seen[cellPos]) {
103
85
  seen[cellPos] = true;
104
86
  rowCells.push(cell);
@@ -107,47 +89,39 @@ export var deleteRows = function deleteRows(rect) {
107
89
  deletedCells[cellPos] = true;
108
90
  }
109
91
  };
110
-
111
92
  for (var colIndex = 0; colIndex < map.width; colIndex++) {
112
93
  var _ret = _loop2(colIndex);
113
-
114
94
  if (_ret === "continue") continue;
115
95
  }
116
-
117
96
  if (rowCells.length) {
118
97
  rows.push(row.type.createChecked(row.attrs, rowCells, row.marks));
119
98
  }
120
99
  };
121
-
122
100
  for (var rowIndex = 0; rowIndex < map.height; rowIndex++) {
123
101
  _loop(rowIndex);
124
102
  }
125
-
126
103
  if (!rows.length) {
127
104
  return setMeta({
128
105
  type: 'DELETE_ROWS',
129
106
  problem: 'EMPTY_TABLE'
130
107
  })(tr);
131
108
  }
132
-
133
109
  var newTable = table.node.type.createChecked(table.node.attrs, rows, table.node.marks);
134
110
  var fixedTable = removeEmptyColumns(newTable);
135
-
136
111
  if (fixedTable === null) {
137
112
  return setMeta({
138
113
  type: 'DELETE_ROWS',
139
114
  problem: 'REMOVE_EMPTY_COLUMNS'
140
115
  })(tr);
141
116
  }
142
-
143
117
  var cursorPos = getNextCursorPos(newTable, rowsToDelete);
144
118
  return setMeta({
145
119
  type: 'DELETE_ROWS'
146
- })(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable) // move cursor before the deleted rows if possible, otherwise - to the first row
120
+ })(tr.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
121
+ // move cursor before the deleted rows if possible, otherwise - to the first row
147
122
  .setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos))));
148
123
  };
149
124
  };
150
-
151
125
  function getNextCursorPos(table, deletedRows) {
152
126
  var minRow = Math.min.apply(Math, _toConsumableArray(deletedRows));
153
127
  var nextRowWithCursor = minRow > 0 ? minRow - 1 : 0;
@@ -1,9 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  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; }
4
-
5
3
  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) { _defineProperty(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; }
6
-
7
4
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
8
5
  import { akEditorDefaultLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
9
6
  import { sendLogs } from '@atlaskit/editor-common/utils';
@@ -21,12 +18,10 @@ export var fireAnalytics = function fireAnalytics() {
21
18
  }]
22
19
  });
23
20
  };
24
-
25
21
  var validateTableCellNodeAttrs = function validateTableCellNodeAttrs(_ref, reportInvalidTableCellSpanAttrs) {
26
22
  var colspan = _ref.colspan,
27
- rowspan = _ref.rowspan,
28
- tableLocalId = _ref.tableLocalId;
29
-
23
+ rowspan = _ref.rowspan,
24
+ tableLocalId = _ref.tableLocalId;
30
25
  if (colspan && colspan < 0) {
31
26
  reportInvalidTableCellSpanAttrs({
32
27
  nodeType: 'tableCell',
@@ -36,7 +31,6 @@ var validateTableCellNodeAttrs = function validateTableCellNodeAttrs(_ref, repor
36
31
  spanValue: colspan
37
32
  });
38
33
  }
39
-
40
34
  if (rowspan && rowspan < 0) {
41
35
  reportInvalidTableCellSpanAttrs({
42
36
  nodeType: 'tableCell',
@@ -46,25 +40,23 @@ var validateTableCellNodeAttrs = function validateTableCellNodeAttrs(_ref, repor
46
40
  spanValue: rowspan
47
41
  });
48
42
  }
49
-
50
43
  return;
51
- }; // We attempt to patch the document when we have extra, unneeded, column widths
44
+ };
45
+
46
+ // We attempt to patch the document when we have extra, unneeded, column widths
52
47
  // Take this node for example:
53
48
  //
54
49
  // ['td', { colwidth: [100, 100, 100], colspan: 2 }]
55
50
  //
56
51
  // This row only spans two columns, yet it contains widths for 3.
57
52
  // We remove the third width here, assumed duplicate content.
58
-
59
-
60
53
  export var removeExtraneousColumnWidths = function removeExtraneousColumnWidths(node, basePos, tr, reportInvalidTableCellSpanAttrs) {
61
54
  var hasProblems = false;
62
55
  tr = replaceCells(tr, node, basePos, function (cell) {
63
56
  var _cell$attrs = cell.attrs,
64
- colwidth = _cell$attrs.colwidth,
65
- colspan = _cell$attrs.colspan,
66
- rowspan = _cell$attrs.rowspan;
67
-
57
+ colwidth = _cell$attrs.colwidth,
58
+ colspan = _cell$attrs.colspan,
59
+ rowspan = _cell$attrs.rowspan;
68
60
  if (reportInvalidTableCellSpanAttrs) {
69
61
  validateTableCellNodeAttrs({
70
62
  colspan: colspan,
@@ -72,24 +64,20 @@ export var removeExtraneousColumnWidths = function removeExtraneousColumnWidths(
72
64
  tableLocalId: node.attrs.localId
73
65
  }, reportInvalidTableCellSpanAttrs);
74
66
  }
75
-
76
67
  if (colwidth && colwidth.length > colspan) {
77
68
  hasProblems = true;
78
69
  return cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
79
70
  colwidth: colwidth.slice(0, colspan)
80
71
  }), cell.content, cell.marks);
81
72
  }
82
-
83
73
  return cell;
84
74
  });
85
-
86
75
  if (hasProblems) {
87
76
  fireAnalytics({
88
77
  message: 'removeExtraneousColumnWidths'
89
78
  });
90
79
  return true;
91
80
  }
92
-
93
81
  return false;
94
82
  };
95
83
  export var fixTables = function fixTables(tr, reportInvalidTableCellSpanAttrs) {
@@ -100,11 +88,12 @@ export var fixTables = function fixTables(tr, reportInvalidTableCellSpanAttrs) {
100
88
  hasProblems = removeExtraneousColumnWidths(node, tr.mapping.map(pos), tr, reportInvalidTableCellSpanAttrs);
101
89
  }
102
90
  });
103
-
104
91
  if (hasProblems) {
105
92
  return tr;
106
93
  }
107
- }; // When we get a table with an 'auto' attribute, we want to:
94
+ };
95
+
96
+ // When we get a table with an 'auto' attribute, we want to:
108
97
  // 1. render with table-layout: auto
109
98
  // 2. capture the column widths
110
99
  // 3. set the column widths as attributes, and remove the 'auto' attribute,
@@ -115,7 +104,6 @@ export var fixTables = function fixTables(tr, reportInvalidTableCellSpanAttrs) {
115
104
  //
116
105
  // We use this when migrating TinyMCE tables for Confluence, for example:
117
106
  // https://pug.jira-dev.com/wiki/spaces/AEC/pages/3362882215/How+do+we+map+TinyMCE+tables+to+Fabric+tables
118
-
119
107
  export var fixAutoSizedTable = function fixAutoSizedTable(view, tableNode, tableRef, tablePos, opts) {
120
108
  var tr = view.state.tr;
121
109
  var domAtPos = view.domAtPos.bind(view);
@@ -125,16 +113,15 @@ export var fixAutoSizedTable = function fixAutoSizedTable(view, tableNode, table
125
113
  return acc + current;
126
114
  }, 0);
127
115
  var tableLayout = getLayoutBasedOnWidth(totalContentWidth);
128
- var maxLayoutSize = getLayoutSize(tableLayout, opts.containerWidth, {}); // Content width will generally not meet the constraints of the layout
116
+ var maxLayoutSize = getLayoutSize(tableLayout, opts.containerWidth, {});
117
+
118
+ // Content width will generally not meet the constraints of the layout
129
119
  // whether it be below or above, so we scale our columns widths
130
120
  // to meet these requirements
131
-
132
121
  var scale = 1;
133
-
134
122
  if (totalContentWidth !== maxLayoutSize) {
135
123
  scale = maxLayoutSize / totalContentWidth;
136
124
  }
137
-
138
125
  var scaledColumnWidths = colWidths.map(function (width) {
139
126
  return Math.floor(width * scale);
140
127
  });
@@ -143,14 +130,14 @@ export var fixAutoSizedTable = function fixAutoSizedTable(view, tableNode, table
143
130
  return cell.type.createChecked(_objectSpread(_objectSpread({}, cell.attrs), {}, {
144
131
  colwidth: newColWidths.length ? newColWidths : null
145
132
  }), cell.content, cell.marks);
146
- }); // clear autosizing on the table node
133
+ });
147
134
 
135
+ // clear autosizing on the table node
148
136
  return tr.setNodeMarkup(tablePos, undefined, _objectSpread(_objectSpread({}, tableNode.attrs), {}, {
149
137
  layout: tableLayout,
150
138
  __autoSize: false
151
139
  })).setMeta('addToHistory', false);
152
140
  };
153
-
154
141
  var getLayoutBasedOnWidth = function getLayoutBasedOnWidth(totalWidth) {
155
142
  if (totalWidth > akEditorWideLayoutWidth) {
156
143
  return 'full-width';
@@ -160,20 +147,15 @@ var getLayoutBasedOnWidth = function getLayoutBasedOnWidth(totalWidth) {
160
147
  return 'default';
161
148
  }
162
149
  };
163
-
164
150
  function parseDOMColumnWidths(domAtPos, tableNode, tableStart, tableRef) {
165
151
  var row = tableRef.querySelector('tr');
166
-
167
152
  if (!row) {
168
153
  return [];
169
154
  }
170
-
171
155
  var cols = [];
172
-
173
156
  for (var col = 0; col < row.childElementCount; col++) {
174
157
  var currentCol = row.children[col];
175
158
  var colspan = Number(currentCol.getAttribute('colspan') || 1);
176
-
177
159
  for (var span = 0; span < colspan; span++) {
178
160
  var colIdx = col + span;
179
161
  var cells = getCellsRefsInColumn(colIdx, tableNode, tableStart, domAtPos);
@@ -183,45 +165,38 @@ function parseDOMColumnWidths(domAtPos, tableNode, tableStart, tableRef) {
183
165
  cols[colIdx] = Math.max(colWidth, tableCellMinWidth);
184
166
  }
185
167
  }
186
-
187
168
  return cols;
188
- } // TODO: move to prosemirror-utils
189
-
169
+ }
190
170
 
171
+ // TODO: move to prosemirror-utils
191
172
  var replaceCells = function replaceCells(tr, table, tablePos, modifyCell) {
192
173
  var rows = [];
193
174
  var modifiedCells = 0;
194
-
195
175
  for (var _rowIndex2 = 0; _rowIndex2 < table.childCount; _rowIndex2++) {
196
176
  var row = table.child(_rowIndex2);
197
177
  var cells = [];
198
-
199
178
  for (var _colIndex = 0; _colIndex < row.childCount; _colIndex++) {
200
- var _cell = row.child(_colIndex); // FIXME
179
+ var _cell = row.child(_colIndex);
180
+
181
+ // FIXME
201
182
  // The rowIndex and colIndex are not accurate in a merged cell scenario
202
183
  // e.g. table with 5 columns might have only one cell in a row, colIndex will be 1, where it should be 4
203
-
204
-
205
184
  var node = modifyCell(_cell, _rowIndex2, _colIndex);
206
-
207
185
  if (node.sameMarkup(_cell) === false) {
208
186
  modifiedCells++;
209
187
  }
210
-
211
188
  cells.push(node);
212
189
  }
213
-
214
190
  if (cells.length) {
215
191
  rows.push(row.type.createChecked(row.attrs, cells, row.marks));
216
192
  }
217
- } // Check if the table has changed before replacing.
218
- // If no cells are modified our counter will be zero.
219
-
193
+ }
220
194
 
195
+ // Check if the table has changed before replacing.
196
+ // If no cells are modified our counter will be zero.
221
197
  if (rows.length && modifiedCells !== 0) {
222
198
  var newTable = table.type.createChecked(table.attrs, rows, table.marks);
223
199
  return tr.replaceWith(tablePos, tablePos + table.nodeSize, newTable);
224
200
  }
225
-
226
201
  return tr;
227
202
  };