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