@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
@@ -4,30 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.arrowRightFromTable = exports.arrowLeftFromTable = exports.TableSelectionDirection = void 0;
7
-
8
7
  var _prosemirrorState = require("prosemirror-state");
9
-
10
8
  var _tableMap = require("@atlaskit/editor-tables/table-map");
11
-
12
9
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
13
-
14
10
  var _utils = require("@atlaskit/editor-tables/utils");
15
-
16
11
  var _selection = require("@atlaskit/editor-common/selection");
17
-
18
12
  var TableSelectionDirection;
19
13
  exports.TableSelectionDirection = TableSelectionDirection;
20
-
21
14
  (function (TableSelectionDirection) {
22
15
  TableSelectionDirection["TopToBottom"] = "TopToBottom";
23
16
  TableSelectionDirection["BottomToTop"] = "BottomToTop";
24
17
  })(TableSelectionDirection || (exports.TableSelectionDirection = TableSelectionDirection = {}));
25
-
26
18
  var arrowLeftFromTable = function arrowLeftFromTable(editorSelectionAPI) {
27
19
  return function () {
28
20
  return function (state, dispatch) {
29
21
  var selection = state.selection;
30
-
31
22
  if (selection instanceof _cellSelection.CellSelection) {
32
23
  return arrowLeftFromCellSelection(editorSelectionAPI)(selection)(state, dispatch);
33
24
  } else if (selection instanceof _selection.GapCursorSelection) {
@@ -35,19 +26,15 @@ var arrowLeftFromTable = function arrowLeftFromTable(editorSelectionAPI) {
35
26
  } else if (selection instanceof _prosemirrorState.TextSelection) {
36
27
  return arrowLeftFromText(editorSelectionAPI)(selection)(state, dispatch);
37
28
  }
38
-
39
29
  return false;
40
30
  };
41
31
  };
42
32
  };
43
-
44
33
  exports.arrowLeftFromTable = arrowLeftFromTable;
45
-
46
34
  var arrowRightFromTable = function arrowRightFromTable(editorSelectionAPI) {
47
35
  return function () {
48
36
  return function (state, dispatch) {
49
37
  var selection = state.selection;
50
-
51
38
  if (selection instanceof _cellSelection.CellSelection) {
52
39
  return arrowRightFromCellSelection(editorSelectionAPI)(selection)(state, dispatch);
53
40
  } else if (selection instanceof _selection.GapCursorSelection) {
@@ -55,21 +42,17 @@ var arrowRightFromTable = function arrowRightFromTable(editorSelectionAPI) {
55
42
  } else if (selection instanceof _prosemirrorState.TextSelection) {
56
43
  return arrowRightFromText(editorSelectionAPI)(selection)(state, dispatch);
57
44
  }
58
-
59
45
  return false;
60
46
  };
61
47
  };
62
48
  };
63
-
64
49
  exports.arrowRightFromTable = arrowRightFromTable;
65
-
66
50
  var arrowLeftFromCellSelection = function arrowLeftFromCellSelection(editorSelectionAPI) {
67
51
  return function (selection) {
68
52
  return function (state, dispatch) {
69
53
  if ((0, _utils.isTableSelected)(state.selection) && editorSelectionAPI) {
70
54
  var _editorSelectionAPI$g = editorSelectionAPI.getSelectionPluginState(state),
71
- selectionRelativeToNode = _editorSelectionAPI$g.selectionRelativeToNode;
72
-
55
+ selectionRelativeToNode = _editorSelectionAPI$g.selectionRelativeToNode;
73
56
  if (selectionRelativeToNode === _selection.RelativeSelectionPos.Start) {
74
57
  // we have full table cell selection and want to set gap cursor selection before table
75
58
  return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
@@ -81,19 +64,16 @@ var arrowLeftFromCellSelection = function arrowLeftFromCellSelection(editorSelec
81
64
  return setSelectionAtStartOfFirstCell(editorSelectionAPI)(selection, _selection.RelativeSelectionPos.Before)(state, dispatch);
82
65
  }
83
66
  }
84
-
85
67
  return false;
86
68
  };
87
69
  };
88
70
  };
89
-
90
71
  var arrowRightFromCellSelection = function arrowRightFromCellSelection(editorSelectionAPI) {
91
72
  return function (selection) {
92
73
  return function (state, dispatch) {
93
74
  if ((0, _utils.isTableSelected)(state.selection) && editorSelectionAPI) {
94
75
  var _editorSelectionAPI$g2 = editorSelectionAPI.getSelectionPluginState(state),
95
- selectionRelativeToNode = _editorSelectionAPI$g2.selectionRelativeToNode;
96
-
76
+ selectionRelativeToNode = _editorSelectionAPI$g2.selectionRelativeToNode;
97
77
  if (selectionRelativeToNode === _selection.RelativeSelectionPos.Start) {
98
78
  // we have full table cell selection and want to set selection at start of first cell
99
79
  return setSelectionAtStartOfFirstCell(editorSelectionAPI)(selection)(state, dispatch);
@@ -102,20 +82,17 @@ var arrowRightFromCellSelection = function arrowRightFromCellSelection(editorSel
102
82
  return setGapCursorAfterTable(editorSelectionAPI)()(state, dispatch);
103
83
  }
104
84
  }
105
-
106
85
  return false;
107
86
  };
108
87
  };
109
88
  };
110
-
111
89
  var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(editorSelectionAPI) {
112
90
  return function (selection) {
113
91
  return function (state, dispatch) {
114
92
  var doc = state.doc;
115
93
  var $from = selection.$from,
116
- from = selection.from,
117
- side = selection.side;
118
-
94
+ from = selection.from,
95
+ side = selection.side;
119
96
  if (side === _selection.Side.RIGHT) {
120
97
  if ($from.nodeBefore && $from.nodeBefore.type.name === 'table') {
121
98
  // we have a gap cursor after a table node and want to set a full table cell selection
@@ -127,11 +104,9 @@ var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(editorSelectionAPI)
127
104
  }
128
105
  } else if (side === _selection.Side.LEFT) {
129
106
  var table = (0, _utils.findTable)(selection);
130
-
131
107
  if (table && isSelectionAtStartOfTable($from, selection) && editorSelectionAPI) {
132
108
  var _editorSelectionAPI$g3 = editorSelectionAPI.getSelectionPluginState(state),
133
- selectionRelativeToNode = _editorSelectionAPI$g3.selectionRelativeToNode;
134
-
109
+ selectionRelativeToNode = _editorSelectionAPI$g3.selectionRelativeToNode;
135
110
  if (selectionRelativeToNode === _selection.RelativeSelectionPos.Before) {
136
111
  // we have a gap cursor at start of first table cell and want to set a gap cursor selection before table
137
112
  return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
@@ -145,20 +120,17 @@ var arrowLeftFromGapCursor = function arrowLeftFromGapCursor(editorSelectionAPI)
145
120
  }
146
121
  }
147
122
  }
148
-
149
123
  return false;
150
124
  };
151
125
  };
152
126
  };
153
-
154
127
  var arrowRightFromGapCursor = function arrowRightFromGapCursor(editorSelectionAPI) {
155
128
  return function (selection) {
156
129
  return function (state, dispatch) {
157
130
  var $from = selection.$from,
158
- from = selection.from,
159
- $to = selection.$to,
160
- side = selection.side;
161
-
131
+ from = selection.from,
132
+ $to = selection.$to,
133
+ side = selection.side;
162
134
  if (side === _selection.Side.LEFT) {
163
135
  if ($from.nodeAfter && $from.nodeAfter.type.name === 'table') {
164
136
  // we have a gap cursor before a table node and want to set a full table cell selection
@@ -170,7 +142,6 @@ var arrowRightFromGapCursor = function arrowRightFromGapCursor(editorSelectionAP
170
142
  }
171
143
  } else if (side === _selection.Side.RIGHT) {
172
144
  var table = (0, _utils.findTable)(selection);
173
-
174
145
  if (table && isSelectionAtEndOfTable($to, selection)) {
175
146
  // we have a gap cursor at end of last table cell and want to set a full table cell selection
176
147
  return selectFullTable(editorSelectionAPI)({
@@ -180,25 +151,21 @@ var arrowRightFromGapCursor = function arrowRightFromGapCursor(editorSelectionAP
180
151
  })(state, dispatch);
181
152
  }
182
153
  }
183
-
184
154
  return false;
185
155
  };
186
156
  };
187
157
  };
188
-
189
158
  var arrowLeftFromText = function arrowLeftFromText(editorSelectionAPI) {
190
159
  return function (selection) {
191
160
  return function (state, dispatch) {
192
161
  var table = (0, _utils.findTable)(selection);
193
-
194
162
  if (table) {
195
163
  var $from = selection.$from;
196
-
197
- if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 && // + 3 for: row, cell & paragraph nodes
164
+ if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 &&
165
+ // + 3 for: row, cell & paragraph nodes
198
166
  editorSelectionAPI) {
199
167
  var _editorSelectionAPI$g4 = editorSelectionAPI.getSelectionPluginState(state),
200
- selectionRelativeToNode = _editorSelectionAPI$g4.selectionRelativeToNode;
201
-
168
+ selectionRelativeToNode = _editorSelectionAPI$g4.selectionRelativeToNode;
202
169
  if (selectionRelativeToNode === _selection.RelativeSelectionPos.Before) {
203
170
  // we have a text selection at start of first table cell, directly inside a top level paragraph,
204
171
  // and want to set gap cursor selection before table
@@ -214,20 +181,16 @@ var arrowLeftFromText = function arrowLeftFromText(editorSelectionAPI) {
214
181
  }
215
182
  }
216
183
  }
217
-
218
184
  return false;
219
185
  };
220
186
  };
221
187
  };
222
-
223
188
  var arrowRightFromText = function arrowRightFromText(editorSelectionAPI) {
224
189
  return function (selection) {
225
190
  return function (state, dispatch) {
226
191
  var table = (0, _utils.findTable)(selection);
227
-
228
192
  if (table) {
229
193
  var $to = selection.$to;
230
-
231
194
  if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 // + 3 for: row, cell & paragraph nodes
232
195
  ) {
233
196
  // we have a text selection at end of last table cell, directly inside a top level paragraph,
@@ -239,35 +202,30 @@ var arrowRightFromText = function arrowRightFromText(editorSelectionAPI) {
239
202
  })(state, dispatch);
240
203
  }
241
204
  }
242
-
243
205
  return false;
244
206
  };
245
207
  };
246
208
  };
209
+
247
210
  /**
248
211
  * Sets a cell selection over all the cells in the table node
249
212
  * We use this instead of selectTable from prosemirror-utils so we can control which
250
213
  * cell is the anchor and which is the head, and also so we can set the relative selection
251
214
  * pos in the selection plugin
252
215
  */
253
-
254
-
255
216
  var selectFullTable = function selectFullTable(editorSelectionAPI) {
256
217
  return function (_ref) {
257
218
  var node = _ref.node,
258
- startPos = _ref.startPos,
259
- dir = _ref.dir;
219
+ startPos = _ref.startPos,
220
+ dir = _ref.dir;
260
221
  return function (state, dispatch) {
261
222
  var doc = state.doc;
262
-
263
223
  var _TableMap$get = _tableMap.TableMap.get(node),
264
- map = _TableMap$get.map;
265
-
224
+ map = _TableMap$get.map;
266
225
  var $firstCell = doc.resolve(startPos + map[0]);
267
226
  var $lastCell = doc.resolve(startPos + map[map.length - 1]);
268
227
  var fullTableSelection;
269
228
  var selectionRelativeToNode;
270
-
271
229
  if (dir === TableSelectionDirection.TopToBottom) {
272
230
  fullTableSelection = new _cellSelection.CellSelection($firstCell, $lastCell);
273
231
  selectionRelativeToNode = _selection.RelativeSelectionPos.End;
@@ -275,96 +233,82 @@ var selectFullTable = function selectFullTable(editorSelectionAPI) {
275
233
  fullTableSelection = new _cellSelection.CellSelection($lastCell, $firstCell);
276
234
  selectionRelativeToNode = _selection.RelativeSelectionPos.Start;
277
235
  }
278
-
279
236
  if (editorSelectionAPI) {
280
237
  var tr = editorSelectionAPI.setSelectionRelativeToNode({
281
238
  selectionRelativeToNode: selectionRelativeToNode,
282
239
  selection: fullTableSelection
283
240
  })(state);
284
-
285
241
  if (dispatch) {
286
242
  dispatch(tr);
287
243
  return true;
288
244
  }
289
245
  }
290
-
291
246
  return false;
292
247
  };
293
248
  };
294
249
  };
295
-
296
250
  var setSelectionAtStartOfFirstCell = function setSelectionAtStartOfFirstCell(editorSelectionAPI) {
297
251
  return function (selection, selectionRelativeToNode) {
298
252
  return function (state, dispatch) {
299
253
  var $anchorCell = selection.$anchorCell,
300
- $headCell = selection.$headCell;
254
+ $headCell = selection.$headCell;
301
255
  var $firstCell = $anchorCell.pos < $headCell.pos ? $anchorCell : $headCell;
302
- var $firstPosInsideCell = state.doc.resolve($firstCell.pos + 1); // check if first pos should have a gap cursor, otherwise find closest text selection
256
+ var $firstPosInsideCell = state.doc.resolve($firstCell.pos + 1);
303
257
 
258
+ // check if first pos should have a gap cursor, otherwise find closest text selection
304
259
  var selectionAtStartOfCell = _selection.GapCursorSelection.valid($firstPosInsideCell) ? new _selection.GapCursorSelection($firstPosInsideCell, _selection.Side.LEFT) : _prosemirrorState.Selection.findFrom($firstPosInsideCell, 1);
305
-
306
260
  if (editorSelectionAPI) {
307
261
  var tr = editorSelectionAPI.setSelectionRelativeToNode({
308
262
  selectionRelativeToNode: selectionRelativeToNode,
309
263
  selection: selectionAtStartOfCell
310
264
  })(state);
311
-
312
265
  if (dispatch) {
313
266
  dispatch(tr);
314
267
  return true;
315
268
  }
316
269
  }
317
-
318
270
  return false;
319
271
  };
320
272
  };
321
273
  };
322
-
323
274
  var setSelectionAtEndOfLastCell = function setSelectionAtEndOfLastCell(editorSelectionAPI) {
324
275
  return function (selection, selectionRelativeToNode) {
325
276
  return function (state, dispatch) {
326
277
  var $anchorCell = selection.$anchorCell,
327
- $headCell = selection.$headCell;
278
+ $headCell = selection.$headCell;
328
279
  var $lastCell = $anchorCell.pos > $headCell.pos ? $anchorCell : $headCell;
329
280
  var lastPosInsideCell = $lastCell.pos + ($lastCell.nodeAfter ? $lastCell.nodeAfter.content.size : 0) + 1;
330
- var $lastPosInsideCell = state.doc.resolve(lastPosInsideCell); // check if last pos should have a gap cursor, otherwise find closest text selection
281
+ var $lastPosInsideCell = state.doc.resolve(lastPosInsideCell);
331
282
 
283
+ // check if last pos should have a gap cursor, otherwise find closest text selection
332
284
  var selectionAtEndOfCell = _selection.GapCursorSelection.valid($lastPosInsideCell) ? new _selection.GapCursorSelection($lastPosInsideCell, _selection.Side.RIGHT) : _prosemirrorState.Selection.findFrom($lastPosInsideCell, -1);
333
-
334
285
  if (editorSelectionAPI) {
335
286
  var tr = editorSelectionAPI.setSelectionRelativeToNode({
336
287
  selectionRelativeToNode: selectionRelativeToNode,
337
288
  selection: selectionAtEndOfCell
338
289
  })(state);
339
-
340
290
  if (dispatch) {
341
291
  dispatch(tr);
342
292
  return true;
343
293
  }
344
294
  }
345
-
346
295
  return false;
347
296
  };
348
297
  };
349
298
  };
350
-
351
299
  var setGapCursorBeforeTable = function setGapCursorBeforeTable(editorSelectionAPI) {
352
300
  return function () {
353
301
  return function (state, dispatch) {
354
302
  var table = (0, _utils.findTable)(state.selection);
355
-
356
303
  if (table) {
357
304
  var $beforeTablePos = state.doc.resolve(table.pos);
358
-
359
305
  if (_selection.GapCursorSelection.valid($beforeTablePos)) {
360
306
  var selectionBeforeTable = new _selection.GapCursorSelection($beforeTablePos, _selection.Side.LEFT);
361
-
362
307
  if (editorSelectionAPI) {
363
308
  var tr = editorSelectionAPI.setSelectionRelativeToNode({
364
309
  selectionRelativeToNode: undefined,
365
310
  selection: selectionBeforeTable
366
311
  })(state);
367
-
368
312
  if (dispatch) {
369
313
  dispatch(tr);
370
314
  return true;
@@ -372,48 +316,38 @@ var setGapCursorBeforeTable = function setGapCursorBeforeTable(editorSelectionAP
372
316
  }
373
317
  }
374
318
  }
375
-
376
319
  return false;
377
320
  };
378
321
  };
379
322
  };
380
-
381
323
  var setGapCursorAfterTable = function setGapCursorAfterTable(editorSelectionAPI) {
382
324
  return function () {
383
325
  return function (state, dispatch) {
384
326
  var table = (0, _utils.findTable)(state.selection);
385
-
386
327
  if (table) {
387
328
  var $afterTablePos = state.doc.resolve(table.pos + table.node.nodeSize);
388
-
389
329
  if (_selection.GapCursorSelection.valid($afterTablePos)) {
390
330
  var selectionAfterTable = new _selection.GapCursorSelection($afterTablePos, _selection.Side.RIGHT);
391
-
392
331
  if (editorSelectionAPI) {
393
332
  var tr = editorSelectionAPI.setSelectionRelativeToNode({
394
333
  selectionRelativeToNode: undefined,
395
334
  selection: selectionAfterTable
396
335
  })(state);
397
-
398
336
  if (dispatch) {
399
337
  dispatch(tr);
400
338
  return true;
401
339
  }
402
340
  }
403
-
404
341
  return false;
405
342
  }
406
343
  }
407
-
408
344
  return false;
409
345
  };
410
346
  };
411
347
  };
412
-
413
348
  var isSelectionAtStartOfTable = function isSelectionAtStartOfTable($pos, selection) {
414
349
  return (0, _selection.isSelectionAtStartOfNode)($pos, (0, _utils.findTable)(selection));
415
350
  };
416
-
417
351
  var isSelectionAtEndOfTable = function isSelectionAtEndOfTable($pos, selection) {
418
352
  return (0, _selection.isSelectionAtEndOfNode)($pos, (0, _utils.findTable)(selection));
419
353
  };
@@ -4,34 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.sortByColumn = void 0;
7
-
8
7
  var _prosemirrorState = require("prosemirror-state");
9
-
10
8
  var _tableMap = require("@atlaskit/editor-tables/table-map");
11
-
12
9
  var _utils = require("@atlaskit/editor-tables/utils");
13
-
14
10
  var _utils2 = require("@atlaskit/editor-common/utils");
15
-
16
11
  var _pluginFactory = require("../pm-plugins/plugin-factory");
17
-
18
12
  var _steps = require("@atlaskit/adf-schema/steps");
19
-
20
13
  function createGetInlineCardTextFromStore(state) {
21
14
  return function (attrs) {
22
15
  var _ref = attrs,
23
- data = _ref.data;
24
-
16
+ data = _ref.data;
25
17
  if (data && (data.name || data.title)) {
26
18
  return data.name || data.title;
27
19
  }
28
-
29
20
  var _ref2 = attrs,
30
- cardUrl = _ref2.url;
21
+ cardUrl = _ref2.url;
31
22
  return cardUrl;
32
23
  };
33
24
  }
34
-
35
25
  var sortByColumn = function sortByColumn(columnIndex) {
36
26
  var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _steps.TableSortOrder.DESC;
37
27
  return (0, _pluginFactory.createCommand)(function (state) {
@@ -46,41 +36,31 @@ var sortByColumn = function sortByColumn(columnIndex) {
46
36
  };
47
37
  }, function (tr, state) {
48
38
  var table = (0, _utils.findTable)(tr.selection);
49
-
50
39
  if (!table || !table.node) {
51
40
  return tr;
52
41
  }
53
-
54
42
  var selectionRect = (0, _utils.isSelectionType)(tr.selection, 'cell') ? (0, _utils.getSelectionRect)(tr.selection) : (0, _utils.findCellRectClosestToPos)(tr.selection.$from);
55
-
56
43
  if (!selectionRect) {
57
44
  return tr;
58
45
  }
59
-
60
46
  var tablePluginState = (0, _pluginFactory.getPluginState)(state);
61
47
  var tableArray = (0, _utils.convertTableNodeToArrayOfRows)(table.node);
62
48
  var headerRow;
63
-
64
49
  if (tablePluginState.isHeaderRowEnabled) {
65
50
  headerRow = tableArray.shift();
66
51
  }
67
-
68
52
  var compareNodesInOrder = (0, _utils2.createCompareNodes)({
69
53
  getInlineCardTextFromStore: createGetInlineCardTextFromStore(state)
70
54
  }, order);
71
55
  var sortedTable = tableArray.sort(function (rowA, rowB) {
72
56
  return compareNodesInOrder(rowA[columnIndex], rowB[columnIndex]);
73
57
  });
74
-
75
58
  if (headerRow) {
76
59
  sortedTable.unshift(headerRow);
77
60
  }
78
-
79
61
  var newTableNode = (0, _utils.convertArrayOfRowsToTableNode)(table.node, sortedTable);
80
62
  tr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTableNode);
81
-
82
63
  var pos = _tableMap.TableMap.get(table.node).positionAt(selectionRect.top, columnIndex, table.node);
83
-
84
64
  var prev = tablePluginState.ordering;
85
65
  var next = {
86
66
  columnIndex: columnIndex,
@@ -90,5 +70,4 @@ var sortByColumn = function sortByColumn(columnIndex) {
90
70
  return tr.setSelection(_prosemirrorState.Selection.near(tr.doc.resolve(table.start + pos)));
91
71
  });
92
72
  };
93
-
94
73
  exports.sortByColumn = sortByColumn;
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.splitCell = void 0;
7
-
8
7
  var _utils = require("@atlaskit/editor-tables/utils");
9
-
10
8
  var _pluginFactory = require("../pm-plugins/plugin-factory");
11
-
12
9
  /**
13
10
  * We need to split cell keeping the right type of cell given current table configuration.
14
11
  * We are using editor-tables splitCellWithType that allows you to choose what cell type should be.
@@ -16,23 +13,18 @@ var _pluginFactory = require("../pm-plugins/plugin-factory");
16
13
  var splitCell = function splitCell(state, dispatch) {
17
14
  var tableState = (0, _pluginFactory.getPluginState)(state);
18
15
  var _state$schema$nodes = state.schema.nodes,
19
- tableHeader = _state$schema$nodes.tableHeader,
20
- tableCell = _state$schema$nodes.tableCell;
21
-
16
+ tableHeader = _state$schema$nodes.tableHeader,
17
+ tableCell = _state$schema$nodes.tableCell;
22
18
  if (dispatch) {
23
19
  return (0, _utils.splitCellWithType)(function (_ref) {
24
20
  var row = _ref.row,
25
- col = _ref.col;
26
-
21
+ col = _ref.col;
27
22
  if (row === 0 && tableState.isHeaderRowEnabled || col === 0 && tableState.isHeaderColumnEnabled) {
28
23
  return tableHeader;
29
24
  }
30
-
31
25
  return tableCell;
32
26
  })(state, dispatch);
33
27
  }
34
-
35
28
  return true;
36
29
  };
37
-
38
30
  exports.splitCell = splitCell;
@@ -1,25 +1,18 @@
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.toggleTableLayout = exports.toggleNumberColumn = exports.toggleHeaderRow = exports.toggleHeaderColumn = exports.toggleContextualMenu = exports.getNextLayout = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _utils = require("@atlaskit/editor-tables/utils");
13
-
14
10
  var _pluginFactory = require("../pm-plugins/plugin-factory");
15
-
16
11
  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; }
17
-
18
12
  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; }
19
-
20
13
  //#endregion
21
- // #region Utils
22
14
 
15
+ // #region Utils
23
16
  /**
24
17
  * Table layout toggle logic
25
18
  * default -> wide -> full-width -> default
@@ -28,22 +21,18 @@ var getNextLayout = function getNextLayout(currentLayout) {
28
21
  switch (currentLayout) {
29
22
  case 'default':
30
23
  return 'wide';
31
-
32
24
  case 'wide':
33
25
  return 'full-width';
34
-
35
26
  case 'full-width':
36
27
  return 'default';
37
-
38
28
  default:
39
29
  return 'default';
40
30
  }
41
- }; // #endregion
42
- // #region Actions
43
-
31
+ };
32
+ // #endregion
44
33
 
34
+ // #region Actions
45
35
  exports.getNextLayout = getNextLayout;
46
-
47
36
  var toggleHeaderRow = function toggleHeaderRow(state, dispatch) {
48
37
  return (0, _utils.toggleHeader)('row')(state, function (tr) {
49
38
  return (0, _pluginFactory.createCommand)({
@@ -53,9 +42,7 @@ var toggleHeaderRow = function toggleHeaderRow(state, dispatch) {
53
42
  })(state, dispatch);
54
43
  });
55
44
  };
56
-
57
45
  exports.toggleHeaderRow = toggleHeaderRow;
58
-
59
46
  var toggleHeaderColumn = function toggleHeaderColumn(state, dispatch) {
60
47
  return (0, _utils.toggleHeader)('column')(state, function (tr) {
61
48
  return (0, _pluginFactory.createCommand)({
@@ -65,37 +52,27 @@ var toggleHeaderColumn = function toggleHeaderColumn(state, dispatch) {
65
52
  })(state, dispatch);
66
53
  });
67
54
  };
68
-
69
55
  exports.toggleHeaderColumn = toggleHeaderColumn;
70
-
71
56
  var toggleNumberColumn = function toggleNumberColumn(state, dispatch) {
72
57
  var tr = state.tr;
73
-
74
58
  var _ref = (0, _utils.findTable)(state.selection),
75
- node = _ref.node,
76
- pos = _ref.pos;
77
-
59
+ node = _ref.node,
60
+ pos = _ref.pos;
78
61
  tr.setNodeMarkup(pos, state.schema.nodes.table, _objectSpread(_objectSpread({}, node.attrs), {}, {
79
62
  isNumberColumnEnabled: !node.attrs.isNumberColumnEnabled
80
63
  }));
81
64
  tr.setMeta('scrollIntoView', false);
82
-
83
65
  if (dispatch) {
84
66
  dispatch(tr);
85
67
  }
86
-
87
68
  return true;
88
69
  };
89
-
90
70
  exports.toggleNumberColumn = toggleNumberColumn;
91
-
92
71
  var toggleTableLayout = function toggleTableLayout(state, dispatch) {
93
72
  var table = (0, _utils.findTable)(state.selection);
94
-
95
73
  if (!table) {
96
74
  return false;
97
75
  }
98
-
99
76
  var layout = getNextLayout(table.node.attrs.layout);
100
77
  return (0, _pluginFactory.createCommand)({
101
78
  type: 'SET_TABLE_LAYOUT',
@@ -109,16 +86,13 @@ var toggleTableLayout = function toggleTableLayout(state, dispatch) {
109
86
  return tr.setMeta('scrollIntoView', false);
110
87
  })(state, dispatch);
111
88
  };
112
-
113
89
  exports.toggleTableLayout = toggleTableLayout;
114
-
115
90
  var toggleContextualMenu = function toggleContextualMenu() {
116
91
  return (0, _pluginFactory.createCommand)({
117
92
  type: 'TOGGLE_CONTEXTUAL_MENU'
118
93
  }, function (tr) {
119
94
  return tr.setMeta('addToHistory', false);
120
95
  });
121
- }; // #endregion
122
-
123
-
96
+ };
97
+ // #endregion
124
98
  exports.toggleContextualMenu = toggleContextualMenu;