@atlaskit/editor-plugin-table 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/index.js +0 -2
  3. package/dist/cjs/plugins/table/commands/clear.js +4 -16
  4. package/dist/cjs/plugins/table/commands/collapse.js +0 -6
  5. package/dist/cjs/plugins/table/commands/go-to-next-cell.js +7 -18
  6. package/dist/cjs/plugins/table/commands/hover.js +7 -37
  7. package/dist/cjs/plugins/table/commands/index.js +0 -8
  8. package/dist/cjs/plugins/table/commands/insert.js +17 -56
  9. package/dist/cjs/plugins/table/commands/misc.js +36 -132
  10. package/dist/cjs/plugins/table/commands/referentiality.js +0 -4
  11. package/dist/cjs/plugins/table/commands/selection.js +21 -87
  12. package/dist/cjs/plugins/table/commands/sort.js +2 -23
  13. package/dist/cjs/plugins/table/commands/split-cell.js +3 -11
  14. package/dist/cjs/plugins/table/commands/toggle.js +8 -34
  15. package/dist/cjs/plugins/table/commands-with-analytics.js +50 -139
  16. package/dist/cjs/plugins/table/create-plugin-config.js +0 -6
  17. package/dist/cjs/plugins/table/event-handlers.js +58 -160
  18. package/dist/cjs/plugins/table/handlers.js +10 -39
  19. package/dist/cjs/plugins/table/index.js +47 -91
  20. package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -41
  21. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +82 -188
  22. package/dist/cjs/plugins/table/nodeviews/table.js +12 -70
  23. package/dist/cjs/plugins/table/nodeviews/tableCell.js +15 -39
  24. package/dist/cjs/plugins/table/nodeviews/update-overflow-shadows.js +3 -15
  25. package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +0 -18
  26. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -27
  27. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-resizing.js +8 -20
  28. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +1 -3
  29. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/index.js +0 -3
  30. package/dist/cjs/plugins/table/pm-plugins/keymap.js +2 -15
  31. package/dist/cjs/plugins/table/pm-plugins/main.js +20 -72
  32. package/dist/cjs/plugins/table/pm-plugins/plugin-factory.js +25 -42
  33. package/dist/cjs/plugins/table/pm-plugins/plugin-key.js +0 -2
  34. package/dist/cjs/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -8
  35. package/dist/cjs/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +4 -23
  36. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/commands.js +0 -5
  37. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/index.js +0 -5
  38. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -13
  39. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +56 -138
  40. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-key.js +0 -2
  41. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin-state.js +15 -30
  42. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +0 -6
  43. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/util.js +0 -5
  44. package/dist/cjs/plugins/table/pm-plugins/table-local-id.js +13 -44
  45. package/dist/cjs/plugins/table/pm-plugins/table-resizing/commands.js +12 -42
  46. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -52
  47. package/dist/cjs/plugins/table/pm-plugins/table-resizing/index.js +0 -4
  48. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-factory.js +0 -10
  49. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-key.js +0 -2
  50. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin.js +5 -19
  51. package/dist/cjs/plugins/table/pm-plugins/table-resizing/reducer.js +0 -10
  52. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -15
  53. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -28
  54. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/content-width.js +3 -23
  55. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +4 -46
  56. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/index.js +0 -9
  57. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +15 -36
  58. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-column.js +1 -4
  59. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +15 -71
  60. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +34 -82
  61. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +12 -36
  62. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.js +0 -2
  63. package/dist/cjs/plugins/table/pm-plugins/table-selection-keymap.js +0 -5
  64. package/dist/cjs/plugins/table/reducer.js +0 -24
  65. package/dist/cjs/plugins/table/toolbar.js +14 -94
  66. package/dist/cjs/plugins/table/transforms/column-width.js +12 -45
  67. package/dist/cjs/plugins/table/transforms/delete-columns.js +11 -76
  68. package/dist/cjs/plugins/table/transforms/delete-rows.js +4 -42
  69. package/dist/cjs/plugins/table/transforms/fix-tables.js +24 -61
  70. package/dist/cjs/plugins/table/transforms/index.js +0 -7
  71. package/dist/cjs/plugins/table/transforms/merge.js +14 -90
  72. package/dist/cjs/plugins/table/transforms/metadata.js +0 -5
  73. package/dist/cjs/plugins/table/transforms/replace-table.js +2 -13
  74. package/dist/cjs/plugins/table/transforms/split.js +18 -32
  75. package/dist/cjs/plugins/table/types.js +0 -11
  76. package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +10 -51
  77. package/dist/cjs/plugins/table/ui/FloatingContextualButton/styles.js +0 -12
  78. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +46 -145
  79. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +12 -35
  80. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/styles.js +0 -11
  81. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +5 -12
  82. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +3 -16
  83. package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +19 -89
  84. package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +6 -31
  85. package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +5 -22
  86. package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +25 -80
  87. package/dist/cjs/plugins/table/ui/LayoutButton/index.js +16 -64
  88. package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +14 -47
  89. package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +20 -48
  90. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +10 -43
  91. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +33 -74
  92. package/dist/cjs/plugins/table/ui/common-styles.js +6 -19
  93. package/dist/cjs/plugins/table/ui/consts.js +3 -8
  94. package/dist/cjs/plugins/table/ui/messages.js +0 -3
  95. package/dist/cjs/plugins/table/ui/ui-styles.js +0 -32
  96. package/dist/cjs/plugins/table/utils/analytics.js +4 -19
  97. package/dist/cjs/plugins/table/utils/collapse.js +4 -21
  98. package/dist/cjs/plugins/table/utils/column-controls.js +25 -61
  99. package/dist/cjs/plugins/table/utils/decoration.js +46 -114
  100. package/dist/cjs/plugins/table/utils/dom.js +4 -51
  101. package/dist/cjs/plugins/table/utils/get-allow-add-column-custom-step.js +0 -2
  102. package/dist/cjs/plugins/table/utils/index.js +0 -10
  103. package/dist/cjs/plugins/table/utils/nodes.js +5 -48
  104. package/dist/cjs/plugins/table/utils/paste.js +22 -47
  105. package/dist/cjs/plugins/table/utils/row-controls.js +6 -67
  106. package/dist/cjs/plugins/table/utils/selection.js +3 -36
  107. package/dist/cjs/plugins/table/utils/table.js +0 -11
  108. package/dist/cjs/plugins/table/utils/update-plugin-state-decorations.js +0 -4
  109. package/dist/cjs/plugins/table-plugin.js +0 -3
  110. package/dist/cjs/version.json +1 -1
  111. package/dist/es2019/plugins/table/commands/clear.js +3 -8
  112. package/dist/es2019/plugins/table/commands/collapse.js +0 -3
  113. package/dist/es2019/plugins/table/commands/go-to-next-cell.js +4 -7
  114. package/dist/es2019/plugins/table/commands/hover.js +7 -17
  115. package/dist/es2019/plugins/table/commands/insert.js +16 -36
  116. package/dist/es2019/plugins/table/commands/misc.js +37 -67
  117. package/dist/es2019/plugins/table/commands/selection.js +7 -62
  118. package/dist/es2019/plugins/table/commands/sort.js +0 -12
  119. package/dist/es2019/plugins/table/commands/split-cell.js +0 -4
  120. package/dist/es2019/plugins/table/commands/toggle.js +13 -15
  121. package/dist/es2019/plugins/table/commands-with-analytics.js +4 -14
  122. package/dist/es2019/plugins/table/event-handlers.js +14 -62
  123. package/dist/es2019/plugins/table/handlers.js +16 -26
  124. package/dist/es2019/plugins/table/index.js +12 -25
  125. package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -40
  126. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +27 -100
  127. package/dist/es2019/plugins/table/nodeviews/table.js +3 -33
  128. package/dist/es2019/plugins/table/nodeviews/tableCell.js +7 -16
  129. package/dist/es2019/plugins/table/nodeviews/update-overflow-shadows.js +3 -10
  130. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +0 -5
  131. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +4 -13
  132. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-resizing.js +0 -3
  133. package/dist/es2019/plugins/table/pm-plugins/keymap.js +2 -3
  134. package/dist/es2019/plugins/table/pm-plugins/main.js +19 -43
  135. package/dist/es2019/plugins/table/pm-plugins/plugin-factory.js +2 -6
  136. package/dist/es2019/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -3
  137. package/dist/es2019/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +0 -12
  138. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -9
  139. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +55 -130
  140. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin-state.js +2 -9
  141. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/util.js +0 -3
  142. package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +20 -39
  143. package/dist/es2019/plugins/table/pm-plugins/table-resizing/commands.js +7 -15
  144. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +9 -27
  145. package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -4
  146. package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin.js +2 -5
  147. package/dist/es2019/plugins/table/pm-plugins/table-resizing/reducer.js +8 -8
  148. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -4
  149. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -11
  150. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/content-width.js +4 -21
  151. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/dom.js +3 -22
  152. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +10 -18
  153. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +29 -59
  154. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +54 -51
  155. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +9 -14
  156. package/dist/es2019/plugins/table/reducer.js +26 -30
  157. package/dist/es2019/plugins/table/toolbar.js +5 -48
  158. package/dist/es2019/plugins/table/transforms/column-width.js +16 -28
  159. package/dist/es2019/plugins/table/transforms/delete-columns.js +17 -58
  160. package/dist/es2019/plugins/table/transforms/delete-rows.js +8 -25
  161. package/dist/es2019/plugins/table/transforms/fix-tables.js +25 -42
  162. package/dist/es2019/plugins/table/transforms/merge.js +22 -70
  163. package/dist/es2019/plugins/table/transforms/metadata.js +3 -2
  164. package/dist/es2019/plugins/table/transforms/replace-table.js +0 -2
  165. package/dist/es2019/plugins/table/transforms/split.js +16 -19
  166. package/dist/es2019/plugins/table/types.js +2 -4
  167. package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +2 -16
  168. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +8 -54
  169. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +4 -13
  170. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +0 -2
  171. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +2 -11
  172. package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +13 -49
  173. package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +0 -8
  174. package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +16 -24
  175. package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +3 -31
  176. package/dist/es2019/plugins/table/ui/LayoutButton/index.js +2 -29
  177. package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +0 -12
  178. package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +6 -12
  179. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +0 -9
  180. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -19
  181. package/dist/es2019/plugins/table/ui/common-styles.js +6 -5
  182. package/dist/es2019/plugins/table/ui/consts.js +4 -3
  183. package/dist/es2019/plugins/table/ui/ui-styles.js +0 -10
  184. package/dist/es2019/plugins/table/utils/analytics.js +0 -8
  185. package/dist/es2019/plugins/table/utils/collapse.js +3 -14
  186. package/dist/es2019/plugins/table/utils/column-controls.js +22 -37
  187. package/dist/es2019/plugins/table/utils/decoration.js +13 -51
  188. package/dist/es2019/plugins/table/utils/dom.js +3 -19
  189. package/dist/es2019/plugins/table/utils/nodes.js +2 -15
  190. package/dist/es2019/plugins/table/utils/paste.js +17 -22
  191. package/dist/es2019/plugins/table/utils/row-controls.js +12 -45
  192. package/dist/es2019/plugins/table/utils/selection.js +0 -21
  193. package/dist/es2019/plugins/table/utils/table.js +0 -2
  194. package/dist/es2019/version.json +1 -1
  195. package/dist/esm/plugins/table/commands/clear.js +3 -8
  196. package/dist/esm/plugins/table/commands/collapse.js +0 -3
  197. package/dist/esm/plugins/table/commands/go-to-next-cell.js +6 -9
  198. package/dist/esm/plugins/table/commands/hover.js +8 -18
  199. package/dist/esm/plugins/table/commands/insert.js +16 -36
  200. package/dist/esm/plugins/table/commands/misc.js +39 -78
  201. package/dist/esm/plugins/table/commands/selection.js +21 -78
  202. package/dist/esm/plugins/table/commands/sort.js +2 -14
  203. package/dist/esm/plugins/table/commands/split-cell.js +3 -8
  204. package/dist/esm/plugins/table/commands/toggle.js +11 -20
  205. package/dist/esm/plugins/table/commands-with-analytics.js +50 -85
  206. package/dist/esm/plugins/table/create-plugin-config.js +0 -3
  207. package/dist/esm/plugins/table/event-handlers.js +58 -123
  208. package/dist/esm/plugins/table/handlers.js +11 -29
  209. package/dist/esm/plugins/table/index.js +47 -60
  210. package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +8 -44
  211. package/dist/esm/plugins/table/nodeviews/TableComponent.js +82 -181
  212. package/dist/esm/plugins/table/nodeviews/table.js +12 -52
  213. package/dist/esm/plugins/table/nodeviews/tableCell.js +15 -33
  214. package/dist/esm/plugins/table/nodeviews/update-overflow-shadows.js +3 -10
  215. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +0 -5
  216. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +8 -19
  217. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-resizing.js +8 -13
  218. package/dist/esm/plugins/table/pm-plugins/decorations/utils/compose-decorations.js +1 -1
  219. package/dist/esm/plugins/table/pm-plugins/keymap.js +2 -3
  220. package/dist/esm/plugins/table/pm-plugins/main.js +20 -47
  221. package/dist/esm/plugins/table/pm-plugins/plugin-factory.js +25 -37
  222. package/dist/esm/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +8 -3
  223. package/dist/esm/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +3 -15
  224. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +4 -9
  225. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +58 -147
  226. package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin-state.js +15 -27
  227. package/dist/esm/plugins/table/pm-plugins/sticky-headers/util.js +0 -3
  228. package/dist/esm/plugins/table/pm-plugins/table-local-id.js +14 -37
  229. package/dist/esm/plugins/table/pm-plugins/table-resizing/commands.js +12 -24
  230. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +16 -36
  231. package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin-factory.js +0 -6
  232. package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin.js +5 -8
  233. package/dist/esm/plugins/table/pm-plugins/table-resizing/reducer.js +0 -7
  234. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +0 -4
  235. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/column-state.js +8 -12
  236. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/content-width.js +5 -22
  237. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/dom.js +4 -23
  238. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +15 -23
  239. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +15 -60
  240. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +34 -55
  241. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +12 -24
  242. package/dist/esm/plugins/table/reducer.js +0 -20
  243. package/dist/esm/plugins/table/toolbar.js +13 -63
  244. package/dist/esm/plugins/table/transforms/column-width.js +12 -32
  245. package/dist/esm/plugins/table/transforms/delete-columns.js +11 -62
  246. package/dist/esm/plugins/table/transforms/delete-rows.js +4 -30
  247. package/dist/esm/plugins/table/transforms/fix-tables.js +24 -49
  248. package/dist/esm/plugins/table/transforms/merge.js +16 -75
  249. package/dist/esm/plugins/table/transforms/metadata.js +3 -2
  250. package/dist/esm/plugins/table/transforms/replace-table.js +2 -6
  251. package/dist/esm/plugins/table/transforms/split.js +18 -29
  252. package/dist/esm/plugins/table/types.js +0 -6
  253. package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +10 -31
  254. package/dist/esm/plugins/table/ui/FloatingContextualButton/styles.js +0 -2
  255. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +46 -126
  256. package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +13 -24
  257. package/dist/esm/plugins/table/ui/FloatingContextualMenu/styles.js +0 -2
  258. package/dist/esm/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +5 -7
  259. package/dist/esm/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.js +3 -13
  260. package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +19 -68
  261. package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +6 -14
  262. package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +5 -18
  263. package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +25 -57
  264. package/dist/esm/plugins/table/ui/LayoutButton/index.js +16 -47
  265. package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +14 -35
  266. package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +20 -38
  267. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +10 -29
  268. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +33 -62
  269. package/dist/esm/plugins/table/ui/common-styles.js +6 -7
  270. package/dist/esm/plugins/table/ui/consts.js +4 -3
  271. package/dist/esm/plugins/table/ui/ui-styles.js +0 -12
  272. package/dist/esm/plugins/table/utils/analytics.js +4 -13
  273. package/dist/esm/plugins/table/utils/collapse.js +4 -15
  274. package/dist/esm/plugins/table/utils/column-controls.js +25 -41
  275. package/dist/esm/plugins/table/utils/decoration.js +46 -88
  276. package/dist/esm/plugins/table/utils/dom.js +4 -20
  277. package/dist/esm/plugins/table/utils/nodes.js +5 -18
  278. package/dist/esm/plugins/table/utils/paste.js +24 -29
  279. package/dist/esm/plugins/table/utils/row-controls.js +6 -46
  280. package/dist/esm/plugins/table/utils/selection.js +3 -26
  281. package/dist/esm/plugins/table/utils/table.js +0 -2
  282. package/dist/esm/version.json +1 -1
  283. package/package.json +2 -2
  284. package/src/__tests__/visual-regression/cell-options-menu.ts +1 -12
@@ -1,4 +1,5 @@
1
1
  // #region Imports
2
+
2
3
  import { Selection, TextSelection } from 'prosemirror-state';
3
4
  import { TableMap } from '@atlaskit/editor-tables/table-map';
4
5
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
@@ -11,10 +12,12 @@ import { fixAutoSizedTable } from '../transforms';
11
12
  import { TableCssClassName as ClassName, TableDecorations } from '../types';
12
13
  import { createColumnControlsDecoration, createColumnSelectedDecoration } from '../utils/decoration';
13
14
  import { checkIfNumberColumnEnabled, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, isIsolating } from '../utils/nodes';
14
- import { updatePluginStateDecorations } from '../utils/update-plugin-state-decorations'; // #endregion
15
+ import { updatePluginStateDecorations } from '../utils/update-plugin-state-decorations';
16
+ // #endregion
17
+
15
18
  // #endregion
16
- // #region Commands
17
19
 
20
+ // #region Commands
18
21
  export const setEditorFocus = editorHasFocus => createCommand({
19
22
  type: 'SET_EDITOR_FOCUS',
20
23
  data: {
@@ -51,41 +54,36 @@ export const setCellAttr = (name, value) => (state, dispatch) => {
51
54
  tr,
52
55
  selection
53
56
  } = state;
54
-
55
57
  if (selection instanceof CellSelection) {
56
58
  let updated = false;
57
59
  selection.forEachCell((cell, pos) => {
58
60
  if (cell.attrs[name] !== value) {
59
- tr.setNodeMarkup(pos, cell.type, { ...cell.attrs,
61
+ tr.setNodeMarkup(pos, cell.type, {
62
+ ...cell.attrs,
60
63
  [name]: value
61
64
  });
62
65
  updated = true;
63
66
  }
64
67
  });
65
-
66
68
  if (updated) {
67
69
  if (dispatch) {
68
70
  dispatch(tr);
69
71
  }
70
-
71
72
  return true;
72
73
  }
73
74
  } else {
74
75
  const cell = selectionCell(state.selection);
75
-
76
76
  if (cell) {
77
77
  if (dispatch) {
78
78
  var _cell$nodeAfter, _cell$nodeAfter2;
79
-
80
- dispatch(tr.setNodeMarkup(cell.pos, (_cell$nodeAfter = cell.nodeAfter) === null || _cell$nodeAfter === void 0 ? void 0 : _cell$nodeAfter.type, { ...((_cell$nodeAfter2 = cell.nodeAfter) === null || _cell$nodeAfter2 === void 0 ? void 0 : _cell$nodeAfter2.attrs),
79
+ dispatch(tr.setNodeMarkup(cell.pos, (_cell$nodeAfter = cell.nodeAfter) === null || _cell$nodeAfter === void 0 ? void 0 : _cell$nodeAfter.type, {
80
+ ...((_cell$nodeAfter2 = cell.nodeAfter) === null || _cell$nodeAfter2 === void 0 ? void 0 : _cell$nodeAfter2.attrs),
81
81
  [name]: value
82
82
  }));
83
83
  }
84
-
85
84
  return true;
86
85
  }
87
86
  }
88
-
89
87
  return false;
90
88
  };
91
89
  export const triggerUnlessTableHeader = command => (state, dispatch, view) => {
@@ -97,23 +95,18 @@ export const triggerUnlessTableHeader = command => (state, dispatch, view) => {
97
95
  }
98
96
  }
99
97
  } = state;
100
-
101
98
  if (selection instanceof TextSelection) {
102
99
  const cell = findCellClosestToPos(selection.$from);
103
-
104
100
  if (cell && cell.node.type !== tableHeader) {
105
101
  return command(state, dispatch, view);
106
102
  }
107
103
  }
108
-
109
104
  if (selection instanceof CellSelection) {
110
105
  const rect = getSelectionRect(selection);
111
-
112
106
  if (!checkIfHeaderRowEnabled(selection) || rect && rect.top > 0) {
113
107
  return command(state, dispatch, view);
114
108
  }
115
109
  }
116
-
117
110
  return false;
118
111
  };
119
112
  export const transformSliceRemoveCellBackgroundColor = (slice, schema) => {
@@ -123,12 +116,12 @@ export const transformSliceRemoveCellBackgroundColor = (slice, schema) => {
123
116
  } = schema.nodes;
124
117
  return mapSlice(slice, maybeCell => {
125
118
  if (maybeCell.type === tableCell || maybeCell.type === tableHeader) {
126
- const cellAttrs = { ...maybeCell.attrs
119
+ const cellAttrs = {
120
+ ...maybeCell.attrs
127
121
  };
128
122
  cellAttrs.background = undefined;
129
123
  return maybeCell.type.createChecked(cellAttrs, maybeCell.content, maybeCell.marks);
130
124
  }
131
-
132
125
  return maybeCell;
133
126
  });
134
127
  };
@@ -141,7 +134,6 @@ export const transformSliceToAddTableHeaders = (slice, schema) => {
141
134
  return mapSlice(slice, maybeTable => {
142
135
  if (maybeTable.type === table) {
143
136
  const firstRow = maybeTable.firstChild;
144
-
145
137
  if (firstRow) {
146
138
  const headerCols = [];
147
139
  firstRow.forEach(oldCol => {
@@ -151,7 +143,6 @@ export const transformSliceToAddTableHeaders = (slice, schema) => {
151
143
  return maybeTable.copy(maybeTable.content.replaceChild(0, headerRow));
152
144
  }
153
145
  }
154
-
155
146
  return maybeTable;
156
147
  });
157
148
  };
@@ -165,12 +156,11 @@ export const transformSliceToRemoveColumnsWidths = (slice, schema) => {
165
156
  if (!maybeCell.attrs.colwidth) {
166
157
  return maybeCell;
167
158
  }
168
-
169
- return maybeCell.type.createChecked({ ...maybeCell.attrs,
159
+ return maybeCell.type.createChecked({
160
+ ...maybeCell.attrs,
170
161
  colwidth: undefined
171
162
  }, maybeCell.content, maybeCell.marks);
172
163
  }
173
-
174
164
  return maybeCell;
175
165
  });
176
166
  };
@@ -178,98 +168,88 @@ export const deleteTable = (state, dispatch) => {
178
168
  if (dispatch) {
179
169
  dispatch(removeTable(state.tr));
180
170
  }
181
-
182
171
  return true;
183
172
  };
184
173
  export const deleteTableIfSelected = (state, dispatch) => {
185
174
  if (isTableSelected(state.selection)) {
186
175
  return deleteTable(state, dispatch);
187
176
  }
188
-
189
177
  return false;
190
178
  };
191
179
  export const convertFirstRowToHeader = schema => tr => {
192
180
  const table = findTable(tr.selection);
193
181
  const map = TableMap.get(table.node);
194
-
195
182
  for (let i = 0; i < map.width; i++) {
196
183
  const cell = table.node.child(0).child(i);
197
184
  tr.setNodeMarkup(table.start + map.map[i], schema.nodes.tableHeader, cell.attrs);
198
185
  }
199
-
200
186
  return tr;
201
187
  };
202
188
  export const moveCursorBackward = (state, dispatch) => {
203
189
  const {
204
190
  $cursor
205
- } = state.selection; // if cursor is in the middle of a text node, do nothing
206
-
191
+ } = state.selection;
192
+ // if cursor is in the middle of a text node, do nothing
207
193
  if (!$cursor || $cursor.parentOffset > 0) {
208
194
  return false;
209
- } // find the node before the cursor
210
-
195
+ }
211
196
 
197
+ // find the node before the cursor
212
198
  let before;
213
199
  let cut;
214
-
215
200
  if (!isIsolating($cursor.parent)) {
216
201
  for (let i = $cursor.depth - 1; !before && i >= 0; i--) {
217
202
  if ($cursor.index(i) > 0) {
218
203
  cut = $cursor.before(i + 1);
219
204
  before = $cursor.node(i).child($cursor.index(i) - 1);
220
205
  }
221
-
222
206
  if (isIsolating($cursor.node(i))) {
223
207
  break;
224
208
  }
225
209
  }
226
- } // if the node before is not a table node - do nothing
227
-
210
+ }
228
211
 
212
+ // if the node before is not a table node - do nothing
229
213
  if (!before || before.type !== state.schema.nodes.table) {
230
214
  return false;
231
215
  }
216
+
232
217
  /*
233
218
  ensure we're just at a top level paragraph
234
219
  otherwise, perform regular backspace behaviour
235
220
  */
236
-
237
-
238
221
  const grandparent = $cursor.node($cursor.depth - 1);
239
-
240
222
  if ($cursor.parent.type !== state.schema.nodes.paragraph || grandparent && grandparent.type !== state.schema.nodes.doc) {
241
223
  return false;
242
224
  }
243
-
244
225
  const {
245
226
  tr
246
227
  } = state;
247
- const lastCellPos = (cut || 0) - 4; // need to move cursor inside the table to be able to calculate table's offset
248
-
228
+ const lastCellPos = (cut || 0) - 4;
229
+ // need to move cursor inside the table to be able to calculate table's offset
249
230
  tr.setSelection(new TextSelection(state.doc.resolve(lastCellPos)));
250
231
  const {
251
232
  $from
252
233
  } = tr.selection;
253
234
  const start = $from.start(-1);
254
- const pos = start + $from.parent.nodeSize - 1; // move cursor to the last cell
235
+ const pos = start + $from.parent.nodeSize - 1;
236
+
237
+ // move cursor to the last cell
255
238
  // it doesn't join node before (last cell) with node after (content after the cursor)
256
239
  // due to ridiculous amount of PM code that would have been required to overwrite
240
+ tr.setSelection(new TextSelection(state.doc.resolve(pos)));
257
241
 
258
- tr.setSelection(new TextSelection(state.doc.resolve(pos))); // if we are inside an empty paragraph not at the end of the doc we delete it
259
-
242
+ // if we are inside an empty paragraph not at the end of the doc we delete it
260
243
  const cursorNode = $cursor.node();
261
244
  const docEnd = state.doc.content.size;
262
245
  const paragraphWrapStart = $cursor.pos - 1;
263
246
  const paragraphWrapEnd = $cursor.pos + 1;
264
-
265
247
  if (cursorNode.content.size === 0 && $cursor.pos + 1 !== docEnd) {
266
248
  tr.delete(paragraphWrapStart, paragraphWrapEnd);
267
249
  }
268
-
269
250
  if (dispatch) {
270
251
  dispatch(tr);
271
252
  }
272
-
273
253
  return true;
274
254
  };
275
255
  export const setMultipleCellAttrs = (attrs, targetCellPosition) => (state, dispatch) => {
@@ -277,7 +257,6 @@ export const setMultipleCellAttrs = (attrs, targetCellPosition) => (state, dispa
277
257
  let {
278
258
  tr
279
259
  } = state;
280
-
281
260
  if (isSelectionType(tr.selection, 'cell')) {
282
261
  const selection = tr.selection;
283
262
  selection.forEachCell((_cell, pos) => {
@@ -290,26 +269,20 @@ export const setMultipleCellAttrs = (attrs, targetCellPosition) => (state, dispa
290
269
  tr = setCellAttrs(cell, attrs)(tr);
291
270
  cursorPos = cell.pos;
292
271
  }
293
-
294
272
  if (tr.docChanged && cursorPos !== undefined) {
295
273
  const $pos = tr.doc.resolve(tr.mapping.map(cursorPos));
296
-
297
274
  if (dispatch) {
298
275
  dispatch(tr.setSelection(Selection.near($pos)));
299
276
  }
300
-
301
277
  return true;
302
278
  }
303
-
304
279
  return false;
305
280
  };
306
281
  export const selectColumn = (column, expand) => createCommand(state => {
307
282
  const cells = getCellsInColumn(column)(state.tr.selection);
308
-
309
283
  if (!cells || !cells.length || typeof cells[0].pos !== 'number') {
310
284
  return false;
311
285
  }
312
-
313
286
  const decorations = createColumnSelectedDecoration(selectColumnTransform(column, expand)(state.tr));
314
287
  const decorationSet = updatePluginStateDecorations(state, decorations, TableDecorations.COLUMN_SELECTED);
315
288
  const targetCellPosition = cells[0].pos;
@@ -324,11 +297,9 @@ export const selectColumn = (column, expand) => createCommand(state => {
324
297
  export const selectRow = (row, expand) => createCommand(state => {
325
298
  let targetCellPosition;
326
299
  const cells = getCellsInRow(row)(state.tr.selection);
327
-
328
300
  if (cells && cells.length) {
329
301
  targetCellPosition = cells[0].pos;
330
302
  }
331
-
332
303
  return {
333
304
  type: 'SET_TARGET_CELL_POSITION',
334
305
  data: {
@@ -358,11 +329,9 @@ export const addResizeHandleDecorations = (rowIndex, columnIndex) => createComma
358
329
  allowColumnResizing
359
330
  }
360
331
  } = getPluginState(state);
361
-
362
332
  if (!tableNode || !allowColumnResizing) {
363
333
  return false;
364
334
  }
365
-
366
335
  return {
367
336
  type: 'ADD_RESIZE_HANDLE_DECORATIONS',
368
337
  data: {
@@ -383,25 +352,26 @@ export const addBoldInEmptyHeaderCells = tableCellHeader => (state, dispatch) =>
383
352
  const {
384
353
  tr
385
354
  } = state;
386
-
387
- if ( // Avoid infinite loop when the current selection is not a TextSelection
388
- isTextSelection(tr.selection) && tr.selection.$cursor && // When storedMark is null that means this is the initial state
355
+ if (
356
+ // Avoid infinite loop when the current selection is not a TextSelection
357
+ isTextSelection(tr.selection) && tr.selection.$cursor &&
358
+ // When storedMark is null that means this is the initial state
389
359
  // if the user press to remove the mark storedMark will be an empty array
390
360
  // and we shouldn't apply the strong mark
391
- tr.storedMarks == null && // Check if the current node is a direct child from paragraph
392
- tr.selection.$from.depth === tableCellHeader.depth + 1 && // this logic is applied only for empty paragraph
361
+ tr.storedMarks == null &&
362
+ // Check if the current node is a direct child from paragraph
363
+ tr.selection.$from.depth === tableCellHeader.depth + 1 &&
364
+ // this logic is applied only for empty paragraph
393
365
  tableCellHeader.node.nodeSize === 4 && isParagraph(tableCellHeader.node.firstChild, state.schema)) {
394
366
  const {
395
367
  strong
396
368
  } = state.schema.marks;
397
369
  tr.setStoredMarks([strong.create()]).setMeta('addToHistory', false);
398
-
399
370
  if (dispatch) {
400
371
  dispatch(tr);
401
372
  }
402
-
403
373
  return true;
404
374
  }
405
-
406
375
  return false;
407
- }; // #endregion
376
+ };
377
+ // #endregion
@@ -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 let TableSelectionDirection;
7
-
8
7
  (function (TableSelectionDirection) {
9
8
  TableSelectionDirection["TopToBottom"] = "TopToBottom";
10
9
  TableSelectionDirection["BottomToTop"] = "BottomToTop";
11
10
  })(TableSelectionDirection || (TableSelectionDirection = {}));
12
-
13
11
  export const arrowLeftFromTable = editorSelectionAPI => () => (state, dispatch) => {
14
12
  const {
15
13
  selection
16
14
  } = state;
17
-
18
15
  if (selection instanceof CellSelection) {
19
16
  return arrowLeftFromCellSelection(editorSelectionAPI)(selection)(state, dispatch);
20
17
  } else if (selection instanceof GapCursorSelection) {
@@ -22,14 +19,12 @@ export const arrowLeftFromTable = editorSelectionAPI => () => (state, dispatch)
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
  export const arrowRightFromTable = editorSelectionAPI => () => (state, dispatch) => {
29
25
  const {
30
26
  selection
31
27
  } = state;
32
-
33
28
  if (selection instanceof CellSelection) {
34
29
  return arrowRightFromCellSelection(editorSelectionAPI)(selection)(state, dispatch);
35
30
  } else if (selection instanceof GapCursorSelection) {
@@ -37,16 +32,13 @@ export const arrowRightFromTable = editorSelectionAPI => () => (state, dispatch)
37
32
  } else if (selection instanceof TextSelection) {
38
33
  return arrowRightFromText(editorSelectionAPI)(selection)(state, dispatch);
39
34
  }
40
-
41
35
  return false;
42
36
  };
43
-
44
37
  const arrowLeftFromCellSelection = editorSelectionAPI => selection => (state, dispatch) => {
45
38
  if (isTableSelected(state.selection) && editorSelectionAPI) {
46
39
  const {
47
40
  selectionRelativeToNode
48
41
  } = editorSelectionAPI.getSelectionPluginState(state);
49
-
50
42
  if (selectionRelativeToNode === RelativeSelectionPos.Start) {
51
43
  // we have full table cell selection and want to set gap cursor selection before table
52
44
  return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
@@ -58,16 +50,13 @@ const arrowLeftFromCellSelection = editorSelectionAPI => selection => (state, di
58
50
  return setSelectionAtStartOfFirstCell(editorSelectionAPI)(selection, RelativeSelectionPos.Before)(state, dispatch);
59
51
  }
60
52
  }
61
-
62
53
  return false;
63
54
  };
64
-
65
55
  const arrowRightFromCellSelection = editorSelectionAPI => selection => (state, dispatch) => {
66
56
  if (isTableSelected(state.selection) && editorSelectionAPI) {
67
57
  const {
68
58
  selectionRelativeToNode
69
59
  } = editorSelectionAPI.getSelectionPluginState(state);
70
-
71
60
  if (selectionRelativeToNode === RelativeSelectionPos.Start) {
72
61
  // we have full table cell selection and want to set selection at start of first cell
73
62
  return setSelectionAtStartOfFirstCell(editorSelectionAPI)(selection)(state, dispatch);
@@ -76,10 +65,8 @@ const arrowRightFromCellSelection = editorSelectionAPI => selection => (state, d
76
65
  return setGapCursorAfterTable(editorSelectionAPI)()(state, dispatch);
77
66
  }
78
67
  }
79
-
80
68
  return false;
81
69
  };
82
-
83
70
  const arrowLeftFromGapCursor = editorSelectionAPI => selection => (state, dispatch) => {
84
71
  const {
85
72
  doc
@@ -89,7 +76,6 @@ const arrowLeftFromGapCursor = editorSelectionAPI => selection => (state, dispat
89
76
  from,
90
77
  side
91
78
  } = selection;
92
-
93
79
  if (side === Side.RIGHT) {
94
80
  if ($from.nodeBefore && $from.nodeBefore.type.name === 'table') {
95
81
  // we have a gap cursor after a table node and want to set a full table cell selection
@@ -101,12 +87,10 @@ const arrowLeftFromGapCursor = editorSelectionAPI => selection => (state, dispat
101
87
  }
102
88
  } else if (side === Side.LEFT) {
103
89
  const table = findTable(selection);
104
-
105
90
  if (table && isSelectionAtStartOfTable($from, selection) && editorSelectionAPI) {
106
91
  const {
107
92
  selectionRelativeToNode
108
93
  } = editorSelectionAPI.getSelectionPluginState(state);
109
-
110
94
  if (selectionRelativeToNode === RelativeSelectionPos.Before) {
111
95
  // we have a gap cursor at start of first table cell and want to set a gap cursor selection before table
112
96
  return setGapCursorBeforeTable(editorSelectionAPI)()(state, dispatch);
@@ -120,10 +104,8 @@ const arrowLeftFromGapCursor = editorSelectionAPI => selection => (state, dispat
120
104
  }
121
105
  }
122
106
  }
123
-
124
107
  return false;
125
108
  };
126
-
127
109
  const arrowRightFromGapCursor = editorSelectionAPI => selection => (state, dispatch) => {
128
110
  const {
129
111
  $from,
@@ -131,7 +113,6 @@ const arrowRightFromGapCursor = editorSelectionAPI => selection => (state, dispa
131
113
  $to,
132
114
  side
133
115
  } = selection;
134
-
135
116
  if (side === Side.LEFT) {
136
117
  if ($from.nodeAfter && $from.nodeAfter.type.name === 'table') {
137
118
  // we have a gap cursor before a table node and want to set a full table cell selection
@@ -143,7 +124,6 @@ const arrowRightFromGapCursor = editorSelectionAPI => selection => (state, dispa
143
124
  }
144
125
  } else if (side === Side.RIGHT) {
145
126
  const table = findTable(selection);
146
-
147
127
  if (table && isSelectionAtEndOfTable($to, selection)) {
148
128
  // we have a gap cursor at end of last table cell and want to set a full table cell selection
149
129
  return selectFullTable(editorSelectionAPI)({
@@ -153,24 +133,20 @@ const arrowRightFromGapCursor = editorSelectionAPI => selection => (state, dispa
153
133
  })(state, dispatch);
154
134
  }
155
135
  }
156
-
157
136
  return false;
158
137
  };
159
-
160
138
  const arrowLeftFromText = editorSelectionAPI => selection => (state, dispatch) => {
161
139
  const table = findTable(selection);
162
-
163
140
  if (table) {
164
141
  const {
165
142
  $from
166
143
  } = selection;
167
-
168
- if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 && // + 3 for: row, cell & paragraph nodes
144
+ if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 &&
145
+ // + 3 for: row, cell & paragraph nodes
169
146
  editorSelectionAPI) {
170
147
  const {
171
148
  selectionRelativeToNode
172
149
  } = editorSelectionAPI.getSelectionPluginState(state);
173
-
174
150
  if (selectionRelativeToNode === RelativeSelectionPos.Before) {
175
151
  // we have a text selection at start of first table cell, directly inside a top level paragraph,
176
152
  // and want to set gap cursor selection before table
@@ -186,18 +162,14 @@ const arrowLeftFromText = editorSelectionAPI => selection => (state, dispatch) =
186
162
  }
187
163
  }
188
164
  }
189
-
190
165
  return false;
191
166
  };
192
-
193
167
  const arrowRightFromText = editorSelectionAPI => selection => (state, dispatch) => {
194
168
  const table = findTable(selection);
195
-
196
169
  if (table) {
197
170
  const {
198
171
  $to
199
172
  } = selection;
200
-
201
173
  if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 // + 3 for: row, cell & paragraph nodes
202
174
  ) {
203
175
  // we have a text selection at end of last table cell, directly inside a top level paragraph,
@@ -209,17 +181,15 @@ const arrowRightFromText = editorSelectionAPI => selection => (state, dispatch)
209
181
  })(state, dispatch);
210
182
  }
211
183
  }
212
-
213
184
  return false;
214
185
  };
186
+
215
187
  /**
216
188
  * Sets a cell selection over all the cells in the table node
217
189
  * We use this instead of selectTable from prosemirror-utils so we can control which
218
190
  * cell is the anchor and which is the head, and also so we can set the relative selection
219
191
  * pos in the selection plugin
220
192
  */
221
-
222
-
223
193
  const selectFullTable = editorSelectionAPI => ({
224
194
  node,
225
195
  startPos,
@@ -235,7 +205,6 @@ const selectFullTable = editorSelectionAPI => ({
235
205
  const $lastCell = doc.resolve(startPos + map[map.length - 1]);
236
206
  let fullTableSelection;
237
207
  let selectionRelativeToNode;
238
-
239
208
  if (dir === TableSelectionDirection.TopToBottom) {
240
209
  fullTableSelection = new CellSelection($firstCell, $lastCell);
241
210
  selectionRelativeToNode = RelativeSelectionPos.End;
@@ -243,47 +212,40 @@ const selectFullTable = editorSelectionAPI => ({
243
212
  fullTableSelection = new CellSelection($lastCell, $firstCell);
244
213
  selectionRelativeToNode = RelativeSelectionPos.Start;
245
214
  }
246
-
247
215
  if (editorSelectionAPI) {
248
216
  const tr = editorSelectionAPI.setSelectionRelativeToNode({
249
217
  selectionRelativeToNode,
250
218
  selection: fullTableSelection
251
219
  })(state);
252
-
253
220
  if (dispatch) {
254
221
  dispatch(tr);
255
222
  return true;
256
223
  }
257
224
  }
258
-
259
225
  return false;
260
226
  };
261
-
262
227
  const setSelectionAtStartOfFirstCell = editorSelectionAPI => (selection, selectionRelativeToNode) => (state, dispatch) => {
263
228
  const {
264
229
  $anchorCell,
265
230
  $headCell
266
231
  } = selection;
267
232
  const $firstCell = $anchorCell.pos < $headCell.pos ? $anchorCell : $headCell;
268
- const $firstPosInsideCell = state.doc.resolve($firstCell.pos + 1); // check if first pos should have a gap cursor, otherwise find closest text selection
233
+ const $firstPosInsideCell = state.doc.resolve($firstCell.pos + 1);
269
234
 
235
+ // check if first pos should have a gap cursor, otherwise find closest text selection
270
236
  const selectionAtStartOfCell = GapCursorSelection.valid($firstPosInsideCell) ? new GapCursorSelection($firstPosInsideCell, Side.LEFT) : Selection.findFrom($firstPosInsideCell, 1);
271
-
272
237
  if (editorSelectionAPI) {
273
238
  const tr = editorSelectionAPI.setSelectionRelativeToNode({
274
239
  selectionRelativeToNode,
275
240
  selection: selectionAtStartOfCell
276
241
  })(state);
277
-
278
242
  if (dispatch) {
279
243
  dispatch(tr);
280
244
  return true;
281
245
  }
282
246
  }
283
-
284
247
  return false;
285
248
  };
286
-
287
249
  const setSelectionAtEndOfLastCell = editorSelectionAPI => (selection, selectionRelativeToNode) => (state, dispatch) => {
288
250
  const {
289
251
  $anchorCell,
@@ -291,40 +253,33 @@ const setSelectionAtEndOfLastCell = editorSelectionAPI => (selection, selectionR
291
253
  } = selection;
292
254
  const $lastCell = $anchorCell.pos > $headCell.pos ? $anchorCell : $headCell;
293
255
  const lastPosInsideCell = $lastCell.pos + ($lastCell.nodeAfter ? $lastCell.nodeAfter.content.size : 0) + 1;
294
- const $lastPosInsideCell = state.doc.resolve(lastPosInsideCell); // check if last pos should have a gap cursor, otherwise find closest text selection
256
+ const $lastPosInsideCell = state.doc.resolve(lastPosInsideCell);
295
257
 
258
+ // check if last pos should have a gap cursor, otherwise find closest text selection
296
259
  const selectionAtEndOfCell = GapCursorSelection.valid($lastPosInsideCell) ? new GapCursorSelection($lastPosInsideCell, Side.RIGHT) : Selection.findFrom($lastPosInsideCell, -1);
297
-
298
260
  if (editorSelectionAPI) {
299
261
  const tr = editorSelectionAPI.setSelectionRelativeToNode({
300
262
  selectionRelativeToNode,
301
263
  selection: selectionAtEndOfCell
302
264
  })(state);
303
-
304
265
  if (dispatch) {
305
266
  dispatch(tr);
306
267
  return true;
307
268
  }
308
269
  }
309
-
310
270
  return false;
311
271
  };
312
-
313
272
  const setGapCursorBeforeTable = editorSelectionAPI => () => (state, dispatch) => {
314
273
  const table = findTable(state.selection);
315
-
316
274
  if (table) {
317
275
  const $beforeTablePos = state.doc.resolve(table.pos);
318
-
319
276
  if (GapCursorSelection.valid($beforeTablePos)) {
320
277
  const selectionBeforeTable = new GapCursorSelection($beforeTablePos, Side.LEFT);
321
-
322
278
  if (editorSelectionAPI) {
323
279
  const tr = editorSelectionAPI.setSelectionRelativeToNode({
324
280
  selectionRelativeToNode: undefined,
325
281
  selection: selectionBeforeTable
326
282
  })(state);
327
-
328
283
  if (dispatch) {
329
284
  dispatch(tr);
330
285
  return true;
@@ -332,38 +287,28 @@ const setGapCursorBeforeTable = editorSelectionAPI => () => (state, dispatch) =>
332
287
  }
333
288
  }
334
289
  }
335
-
336
290
  return false;
337
291
  };
338
-
339
292
  const setGapCursorAfterTable = editorSelectionAPI => () => (state, dispatch) => {
340
293
  const table = findTable(state.selection);
341
-
342
294
  if (table) {
343
295
  const $afterTablePos = state.doc.resolve(table.pos + table.node.nodeSize);
344
-
345
296
  if (GapCursorSelection.valid($afterTablePos)) {
346
297
  const selectionAfterTable = new GapCursorSelection($afterTablePos, Side.RIGHT);
347
-
348
298
  if (editorSelectionAPI) {
349
299
  const tr = editorSelectionAPI.setSelectionRelativeToNode({
350
300
  selectionRelativeToNode: undefined,
351
301
  selection: selectionAfterTable
352
302
  })(state);
353
-
354
303
  if (dispatch) {
355
304
  dispatch(tr);
356
305
  return true;
357
306
  }
358
307
  }
359
-
360
308
  return false;
361
309
  }
362
310
  }
363
-
364
311
  return false;
365
312
  };
366
-
367
313
  const isSelectionAtStartOfTable = ($pos, selection) => isSelectionAtStartOfNode($pos, findTable(selection));
368
-
369
314
  const isSelectionAtEndOfTable = ($pos, selection) => isSelectionAtEndOfNode($pos, findTable(selection));