@atlaskit/editor-plugin-table 1.1.1 → 1.1.3

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 (305) hide show
  1. package/CHANGELOG.md +18 -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 +95 -191
  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 +18 -43
  46. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +20 -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 +16 -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 +51 -40
  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 +17 -73
  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 +58 -49
  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 +10 -22
  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 +40 -103
  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 +14 -17
  144. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +13 -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 +14 -3
  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 +46 -21
  153. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +31 -61
  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 +60 -32
  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 +11 -7
  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 +95 -184
  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 +18 -25
  230. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +20 -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 +14 -3
  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 +49 -26
  239. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +17 -62
  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 +58 -36
  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 +9 -10
  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/dist/types/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +7 -0
  284. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +2 -1
  285. package/dist/types/plugins/table/ui/common-styles.d.ts +1 -0
  286. package/package.json +8 -6
  287. package/src/__tests__/integration/__fixtures__/empty-layout.ts +35 -0
  288. package/src/__tests__/integration/__fixtures__/nested-in-expand.ts +129 -0
  289. package/src/__tests__/integration/horizontal-scroll.ts +489 -0
  290. package/src/__tests__/unit/commands/insert.ts +3 -3
  291. package/src/__tests__/unit/keymap.ts +3 -1
  292. package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +38 -0
  293. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +5 -2
  294. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +2 -2
  295. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +2 -2
  296. package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-2-snap.png +2 -2
  297. package/src/__tests__/visual-regression/sticky-header.ts +2 -1
  298. package/src/plugins/table/nodeviews/TableComponent.tsx +16 -3
  299. package/src/plugins/table/pm-plugins/table-resizing/commands.ts +6 -2
  300. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +9 -1
  301. package/src/plugins/table/pm-plugins/table-resizing/utils/colgroup.ts +19 -1
  302. package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +57 -5
  303. package/src/plugins/table/pm-plugins/table-resizing/utils/resize-logic.ts +2 -2
  304. package/src/plugins/table/transforms/column-width.ts +60 -6
  305. package/src/plugins/table/ui/common-styles.ts +5 -2
@@ -13,24 +13,19 @@ import { deleteColumns, deleteRows } from './transforms';
13
13
  import { RESIZE_HANDLE_AREA_DECORATION_GAP } from './types';
14
14
  import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, isCell, isColumnControlsDecorations, isCornerButton, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableControlsButton, isTableContainerOrWrapper, hasResizeHandler } from './utils';
15
15
  import { getAllowAddColumnCustomStep } from './utils/get-allow-add-column-custom-step';
16
-
17
16
  const isFocusingCalendar = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
18
-
19
17
  const isFocusingModal = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="dialog"]');
20
-
21
18
  const isFocusingFloatingToolbar = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="toolbar"]');
22
-
23
19
  export const handleBlur = (view, event) => {
24
20
  const {
25
21
  state,
26
22
  dispatch
27
- } = view; // IE version check for ED-4665
23
+ } = view;
24
+ // IE version check for ED-4665
28
25
  // Calendar focus check for ED-10466
29
-
30
26
  if (browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event)) {
31
27
  setEditorFocus(false)(state, dispatch);
32
28
  }
33
-
34
29
  event.preventDefault();
35
30
  return false;
36
31
  };
@@ -47,10 +42,8 @@ export const handleClick = (view, event) => {
47
42
  if (!(event.target instanceof HTMLElement)) {
48
43
  return false;
49
44
  }
50
-
51
45
  const element = event.target;
52
46
  const table = findTable(view.state.selection);
53
-
54
47
  if (event instanceof MouseEvent && isColumnControlsDecorations(element)) {
55
48
  const [startIndex] = getColumnOrRowIndex(element);
56
49
  const {
@@ -59,16 +52,15 @@ export const handleClick = (view, event) => {
59
52
  } = view;
60
53
  return selectColumn(startIndex, event.shiftKey)(state, dispatch);
61
54
  }
55
+ const matchfn = element.matches ? element.matches : element.msMatchesSelector;
62
56
 
63
- const matchfn = element.matches ? element.matches : element.msMatchesSelector; // check if the table cell with an image is clicked and its not the image itself
64
-
57
+ // check if the table cell with an image is clicked and its not the image itself
65
58
  if (!table || !isElementInTableCell(element) || !matchfn || matchfn.call(element, 'table .image, table p, table .image div')) {
66
59
  return false;
67
60
  }
68
-
69
61
  const map = TableMap.get(table.node);
70
- /** Getting the offset of current item clicked */
71
62
 
63
+ /** Getting the offset of current item clicked */
72
64
  const colElement = closestElement(element, 'td') || closestElement(element, 'th');
73
65
  const colIndex = colElement && colElement.cellIndex;
74
66
  const rowElement = closestElement(element, 'tr');
@@ -86,28 +78,23 @@ export const handleClick = (view, event) => {
86
78
  }
87
79
  } = view;
88
80
  const cellPos = map.map[cellIndex];
89
-
90
81
  if (isNaN(cellPos) || cellPos === undefined || typeof cellPos !== 'number') {
91
82
  return false;
92
83
  }
93
-
94
84
  const editorElement = table.node.nodeAt(cellPos);
95
85
  /** Only if the last item is media group, insert a paragraph */
96
-
97
86
  if (isLastItemMediaGroup(editorElement)) {
98
87
  const posInTable = map.map[cellIndex] + editorElement.nodeSize;
99
88
  tr.insert(posInTable + table.pos, paragraph.create());
100
89
  dispatch(tr);
101
90
  setNodeSelection(view, posInTable + table.pos);
102
91
  }
103
-
104
92
  return true;
105
93
  };
106
94
  export const handleMouseOver = (view, mouseEvent) => {
107
95
  if (!(mouseEvent.target instanceof HTMLElement)) {
108
96
  return false;
109
97
  }
110
-
111
98
  const {
112
99
  state,
113
100
  dispatch
@@ -117,13 +104,11 @@ export const handleMouseOver = (view, mouseEvent) => {
117
104
  insertColumnButtonIndex,
118
105
  insertRowButtonIndex
119
106
  } = getPluginState(state);
120
-
121
107
  if (isInsertRowButton(target)) {
122
108
  const [startIndex, endIndex] = getColumnOrRowIndex(target);
123
109
  const positionRow = getMousePositionVerticalRelativeByElement(mouseEvent) === 'bottom' ? endIndex : startIndex;
124
110
  return showInsertRowButton(positionRow)(state, dispatch);
125
111
  }
126
-
127
112
  if (isColumnControlsDecorations(target)) {
128
113
  const [startIndex] = getColumnOrRowIndex(target);
129
114
  const {
@@ -132,11 +117,9 @@ export const handleMouseOver = (view, mouseEvent) => {
132
117
  } = view;
133
118
  return hoverColumns([startIndex], false)(state, dispatch);
134
119
  }
135
-
136
120
  if ((isCell(target) || isCornerButton(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
137
121
  return hideInsertColumnOrRowButton()(state, dispatch);
138
122
  }
139
-
140
123
  if (isResizeHandleDecoration(target)) {
141
124
  const [startIndex, endIndex] = getColumnOrRowIndex(target);
142
125
  return showResizeHandleLine({
@@ -144,27 +127,23 @@ export const handleMouseOver = (view, mouseEvent) => {
144
127
  right: endIndex
145
128
  })(state, dispatch);
146
129
  }
147
-
148
130
  return false;
149
- }; // Ignore any `mousedown` `event` from control and numbered column buttons
150
- // PM end up changing selection during shift selection if not prevented
131
+ };
151
132
 
133
+ // Ignore any `mousedown` `event` from control and numbered column buttons
134
+ // PM end up changing selection during shift selection if not prevented
152
135
  export const handleMouseDown = (_, event) => {
153
136
  const isControl = !!(event.target && event.target instanceof HTMLElement && (isTableContainerOrWrapper(event.target) || isColumnControlsDecorations(event.target) || isRowControlsButton(event.target)));
154
-
155
137
  if (isControl) {
156
138
  event.preventDefault();
157
139
  }
158
-
159
140
  return isControl;
160
141
  };
161
142
  export const handleMouseOut = (view, mouseEvent) => {
162
143
  if (!(mouseEvent instanceof MouseEvent) || !(mouseEvent.target instanceof HTMLElement)) {
163
144
  return false;
164
145
  }
165
-
166
146
  const target = mouseEvent.target;
167
-
168
147
  if (isColumnControlsDecorations(target)) {
169
148
  const {
170
149
  state,
@@ -172,10 +151,9 @@ export const handleMouseOut = (view, mouseEvent) => {
172
151
  } = view;
173
152
  return clearHoverSelection()(state, dispatch);
174
153
  }
175
-
176
- const relatedTarget = mouseEvent.relatedTarget; // In case the user is moving between cell at the same column
154
+ const relatedTarget = mouseEvent.relatedTarget;
155
+ // In case the user is moving between cell at the same column
177
156
  // we don't need to hide the resize handle decoration
178
-
179
157
  if (isResizeHandleDecoration(target) && !isResizeHandleDecoration(relatedTarget)) {
180
158
  const {
181
159
  state,
@@ -183,14 +161,12 @@ export const handleMouseOut = (view, mouseEvent) => {
183
161
  } = view;
184
162
  return hideResizeHandleLine()(state, dispatch);
185
163
  }
186
-
187
164
  return false;
188
165
  };
189
166
  export const handleMouseLeave = (view, event) => {
190
167
  if (!(event.target instanceof HTMLElement)) {
191
168
  return false;
192
169
  }
193
-
194
170
  const {
195
171
  state,
196
172
  dispatch
@@ -200,24 +176,19 @@ export const handleMouseLeave = (view, event) => {
200
176
  insertRowButtonIndex
201
177
  } = getPluginState(state);
202
178
  const target = event.target;
203
-
204
179
  if (isTableControlsButton(target)) {
205
180
  return true;
206
181
  }
207
-
208
182
  if ((typeof insertColumnButtonIndex !== 'undefined' || typeof insertRowButtonIndex !== 'undefined') && hideInsertColumnOrRowButton()(state, dispatch)) {
209
183
  return true;
210
184
  }
211
-
212
185
  return false;
213
186
  };
214
187
  export const handleMouseMove = getEditorFeatureFlags => (view, event, elementContentRects) => {
215
188
  if (!(event.target instanceof HTMLElement)) {
216
189
  return false;
217
190
  }
218
-
219
191
  const element = event.target;
220
-
221
192
  if (isColumnControlsDecorations(element)) {
222
193
  const {
223
194
  state,
@@ -228,12 +199,10 @@ export const handleMouseMove = getEditorFeatureFlags => (view, event, elementCon
228
199
  } = getPluginState(state);
229
200
  const [startIndex, endIndex] = getColumnOrRowIndex(element);
230
201
  const positionColumn = getMousePositionHorizontalRelativeByElement(event, false, elementContentRects) === 'right' ? endIndex : startIndex;
231
-
232
202
  if (positionColumn !== insertColumnButtonIndex) {
233
203
  return showInsertColumnButton(positionColumn)(state, dispatch);
234
204
  }
235
205
  }
236
-
237
206
  if (isRowControlsButton(element)) {
238
207
  const {
239
208
  state,
@@ -244,19 +213,15 @@ export const handleMouseMove = getEditorFeatureFlags => (view, event, elementCon
244
213
  } = getPluginState(state);
245
214
  const [startIndex, endIndex] = getColumnOrRowIndex(element);
246
215
  const positionRow = getMousePositionVerticalRelativeByElement(event) === 'bottom' ? endIndex : startIndex;
247
-
248
216
  if (positionRow !== insertRowButtonIndex) {
249
217
  return showInsertRowButton(positionRow)(state, dispatch);
250
218
  }
251
219
  }
252
-
253
220
  const {
254
221
  mouseMoveOptimization
255
222
  } = getEditorFeatureFlags();
256
-
257
223
  if (!isResizeHandleDecoration(element) && isCell(element)) {
258
224
  const positionColumn = getMousePositionHorizontalRelativeByElement(event, mouseMoveOptimization, elementContentRects, RESIZE_HANDLE_AREA_DECORATION_GAP);
259
-
260
225
  if (positionColumn !== null) {
261
226
  const {
262
227
  state,
@@ -269,11 +234,9 @@ export const handleMouseMove = getEditorFeatureFlags => (view, event, elementCon
269
234
  const tableCell = closestElement(element, 'td, th');
270
235
  const cellStartPosition = view.posAtDOM(tableCell, 0);
271
236
  const rect = findCellRectClosestToPos(state.doc.resolve(cellStartPosition));
272
-
273
237
  if (rect) {
274
238
  const columnEndIndexTarget = positionColumn === 'left' ? rect.left : rect.right;
275
239
  const rowIndexTarget = rect.top;
276
-
277
240
  if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !hasResizeHandler({
278
241
  target: element,
279
242
  columnEndIndexTarget
@@ -283,7 +246,6 @@ export const handleMouseMove = getEditorFeatureFlags => (view, event, elementCon
283
246
  }
284
247
  }
285
248
  }
286
-
287
249
  return false;
288
250
  };
289
251
  export function handleTripleClick(view, pos) {
@@ -292,23 +254,18 @@ export function handleTripleClick(view, pos) {
292
254
  dispatch
293
255
  } = view;
294
256
  const $cellPos = cellAround(state.doc.resolve(pos));
295
-
296
257
  if (!$cellPos) {
297
258
  return false;
298
259
  }
299
-
300
260
  const cell = state.doc.nodeAt($cellPos.pos);
301
-
302
261
  if (cell) {
303
262
  const selFrom = Selection.findFrom($cellPos, 1, true);
304
263
  const selTo = Selection.findFrom(state.doc.resolve($cellPos.pos + cell.nodeSize), -1, true);
305
-
306
264
  if (selFrom && selTo) {
307
265
  dispatch(state.tr.setSelection(new TextSelection(selFrom.$from, selTo.$to)));
308
266
  return true;
309
267
  }
310
268
  }
311
-
312
269
  return false;
313
270
  }
314
271
  export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
@@ -316,16 +273,13 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
316
273
  let {
317
274
  tr
318
275
  } = newState;
319
-
320
276
  if (oldSelection instanceof CellSelection) {
321
277
  const $anchorCell = oldTr.doc.resolve(oldTr.mapping.map(oldSelection.$anchorCell.pos));
322
278
  const $headCell = oldTr.doc.resolve(oldTr.mapping.map(oldSelection.$headCell.pos));
323
279
  const cellSelection = new CellSelection($anchorCell, $headCell);
324
280
  tr.setSelection(cellSelection);
325
-
326
281
  if (tr.selection instanceof CellSelection) {
327
282
  const rect = getSelectionRect(cellSelection);
328
-
329
283
  if (rect) {
330
284
  const {
331
285
  verticalCells,
@@ -333,8 +287,9 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
333
287
  totalCells,
334
288
  totalRowCount,
335
289
  totalColumnCount
336
- } = getSelectedCellInfo(tr.selection); // Reassigning to make it more obvious and consistent
290
+ } = getSelectedCellInfo(tr.selection);
337
291
 
292
+ // Reassigning to make it more obvious and consistent
338
293
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
339
294
  action: TABLE_ACTION.CUT,
340
295
  actionSubject: ACTION_SUBJECT.TABLE,
@@ -347,11 +302,11 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
347
302
  totalColumnCount
348
303
  },
349
304
  eventType: EVENT_TYPE.TRACK
350
- })(tr); // Need this check again since we are overriding the tr in previous statement
305
+ })(tr);
351
306
 
307
+ // Need this check again since we are overriding the tr in previous statement
352
308
  if (tr.selection instanceof CellSelection) {
353
309
  const isTableSelected = tr.selection.isRowSelection() && tr.selection.isColSelection();
354
-
355
310
  if (isTableSelected) {
356
311
  tr = removeTable(tr);
357
312
  } else if (tr.selection.isRowSelection()) {
@@ -368,7 +323,6 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
368
323
  }
369
324
  }
370
325
  }
371
-
372
326
  return tr;
373
327
  };
374
328
  export const whenTableInFocus = (eventHandler, elementContentRects) => (view, mouseEvent) => {
@@ -376,10 +330,8 @@ export const whenTableInFocus = (eventHandler, elementContentRects) => (view, mo
376
330
  const tablePluginState = getPluginState(view.state);
377
331
  const isDragging = tableResizePluginState && !!tableResizePluginState.dragging;
378
332
  const hasTableNode = tablePluginState && tablePluginState.tableNode;
379
-
380
333
  if (!hasTableNode || isDragging) {
381
334
  return false;
382
335
  }
383
-
384
336
  return eventHandler(view, mouseEvent, elementContentRects);
385
337
  };
@@ -1,4 +1,5 @@
1
1
  // #region Imports
2
+
2
3
  import { findParentNodeOfType } from 'prosemirror-utils';
3
4
  import { findTable } from '@atlaskit/editor-tables/utils';
4
5
  import { isTextInput } from '@atlaskit/editor-common/utils';
@@ -8,59 +9,51 @@ import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing
8
9
  import { TableSortStep } from '@atlaskit/adf-schema/steps';
9
10
  // #endregion
10
11
  import { checkIfNumberColumnEnabled, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled } from './utils/nodes';
11
-
12
12
  const nextTableSorting = (tr, table) => {
13
13
  const tableSortStep = tr.steps.find(step => step instanceof TableSortStep);
14
14
  return tableSortStep && table && table.pos === tableSortStep.pos ? tableSortStep.next : undefined;
15
15
  };
16
-
17
16
  const nextResizeHandleColumnIndex = (tr, resizeHandleColumnIndex) => {
18
17
  if (tr.getMeta(tableResizingPluginKey)) {
19
18
  return undefined;
20
19
  }
21
-
22
20
  return resizeHandleColumnIndex;
23
21
  };
24
-
25
22
  const updateTargetCellPosition = ({
26
23
  tr,
27
24
  table
28
25
  }) => pluginState => {
29
26
  const tableNode = table && table.node;
30
-
31
27
  if (!tableNode) {
32
- return { ...pluginState,
28
+ return {
29
+ ...pluginState,
33
30
  targetCellPosition: undefined
34
31
  };
35
32
  }
36
-
37
33
  const {
38
34
  tableCell,
39
35
  tableHeader
40
36
  } = tr.doc.type.schema.nodes;
41
37
  const cell = findParentNodeOfType([tableCell, tableHeader])(tr.selection);
42
38
  const targetCellPosition = cell ? cell.pos : undefined;
43
-
44
39
  if (pluginState.targetCellPosition === targetCellPosition) {
45
40
  return pluginState;
46
41
  }
47
-
48
- return { ...pluginState,
42
+ return {
43
+ ...pluginState,
49
44
  targetCellPosition
50
45
  };
51
46
  };
52
-
53
47
  const updateTableNodePluginState = ({
54
48
  tr,
55
49
  table
56
50
  }) => pluginState => {
57
51
  const tableNode = table && table.node;
58
-
59
52
  if (!tableNode || isTextInput(tr)) {
60
53
  return pluginState;
61
54
  }
62
-
63
- return { ...pluginState,
55
+ return {
56
+ ...pluginState,
64
57
  ...defaultTableSelection,
65
58
  tableNode,
66
59
  ordering: nextTableSorting(tr, table),
@@ -70,7 +63,6 @@ const updateTableNodePluginState = ({
70
63
  isHeaderRowEnabled: checkIfHeaderRowEnabled(tr.selection)
71
64
  };
72
65
  };
73
-
74
66
  const updateCollapseHandler = ({
75
67
  tr,
76
68
  table
@@ -80,42 +72,40 @@ const updateCollapseHandler = ({
80
72
  const allowCollapse = pluginState.pluginConfig.allowCollapse;
81
73
  const isExpandInSchema = schema.nodes.expand !== undefined;
82
74
  const isCollapseEnabled = allowCollapse && isExpandInSchema;
75
+
83
76
  /**
84
77
  * If we don't have focus, or collapse isn't allowed, or a table node doesn't
85
78
  * exist, we don't need to waste extra checks below
86
79
  */
87
-
88
80
  if (!pluginState.editorHasFocus || !isCollapseEnabled || !tableNode) {
89
81
  return pluginState;
90
82
  }
91
-
92
83
  const expandNodeType = schema.nodes.expand;
93
84
  const isTableCollapsed = expandNodeType && !!findParentNodeOfType(expandNodeType)(tr.selection);
94
- const trCanBeCollapsed = isTableCollapsible(tr).tableIsCollapsible; // We're focused on a table + we're not inside an expand
85
+ const trCanBeCollapsed = isTableCollapsible(tr).tableIsCollapsible;
95
86
 
96
- const canCollapseTable = !!pluginState.tableNode && // is it already collapsed?
87
+ // We're focused on a table + we're not inside an expand
88
+ const canCollapseTable = !!pluginState.tableNode &&
89
+ // is it already collapsed?
97
90
  !isTableCollapsed && !!trCanBeCollapsed;
98
-
99
91
  if (pluginState.isTableCollapsed !== isTableCollapsed || pluginState.canCollapseTable !== canCollapseTable) {
100
- return { ...pluginState,
92
+ return {
93
+ ...pluginState,
101
94
  isTableCollapsed,
102
95
  canCollapseTable
103
96
  };
104
97
  }
105
-
106
98
  return pluginState;
107
99
  };
108
-
109
100
  const buildPluginState = builders => props => pluginState => {
110
101
  if (!props.table) {
111
- return pluginState.targetCellPosition ? { ...pluginState,
102
+ return pluginState.targetCellPosition ? {
103
+ ...pluginState,
112
104
  targetCellPosition: undefined
113
105
  } : pluginState;
114
106
  }
115
-
116
107
  return builders.reduce((_pluginState, transform) => transform(props)(_pluginState), pluginState);
117
108
  };
118
-
119
109
  export const handleDocOrSelectionChanged = (tr, pluginState) => buildPluginState([updateTargetCellPosition, updateTableNodePluginState, updateCollapseHandler])({
120
110
  tr,
121
111
  table: findTable(tr.selection)
@@ -28,37 +28,31 @@ import FloatingInsertButton from './ui/FloatingInsertButton';
28
28
  import LayoutButton from './ui/LayoutButton';
29
29
  import { isLayoutSupported } from './utils';
30
30
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
31
-
32
31
  const defaultGetEditorFeatureFlags = () => ({});
33
-
34
32
  const tablesPlugin = options => {
35
33
  const editorViewRef = {
36
34
  current: null
37
35
  };
38
-
39
36
  const defaultGetEditorContainerWidth = () => {
40
37
  if (!editorViewRef.current) {
41
38
  var _document, _document$body;
42
-
43
39
  return {
44
40
  width: ((_document = document) === null || _document === void 0 ? void 0 : (_document$body = _document.body) === null || _document$body === void 0 ? void 0 : _document$body.offsetWidth) || 500
45
41
  };
46
42
  }
47
-
48
43
  const {
49
44
  current: {
50
45
  state
51
46
  }
52
- } = editorViewRef; // TODO: ED-15663
47
+ } = editorViewRef;
48
+
49
+ // TODO: ED-15663
53
50
  // Please, do not copy or use this kind of code below
54
51
  // @ts-ignore
55
-
56
52
  return state['widthPlugin$'];
57
53
  };
58
-
59
54
  return {
60
55
  name: 'table',
61
-
62
56
  nodes() {
63
57
  return [{
64
58
  name: 'table',
@@ -74,7 +68,6 @@ const tablesPlugin = options => {
74
68
  node: tableCell
75
69
  }];
76
70
  },
77
-
78
71
  pmPlugins() {
79
72
  const plugins = [{
80
73
  name: 'table',
@@ -115,7 +108,8 @@ const tablesPlugin = options => {
115
108
  }, {
116
109
  name: 'tableEditing',
117
110
  plugin: () => createDecorationsPlugin()
118
- }, // Needs to be lower priority than editor-tables.tableEditing
111
+ },
112
+ // Needs to be lower priority than editor-tables.tableEditing
119
113
  // plugin as it is currently swallowing backspace events inside tables
120
114
  {
121
115
  name: 'tableKeymap',
@@ -132,7 +126,6 @@ const tablesPlugin = options => {
132
126
  reason
133
127
  }) => {
134
128
  var _options$editorAnalyt;
135
-
136
129
  options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
137
130
  action: TABLE_ACTION.FIXED,
138
131
  actionSubject: ACTION_SUBJECT.TABLE,
@@ -169,12 +162,14 @@ const tablesPlugin = options => {
169
162
  }
170
163
  });
171
164
  }
172
- }]; // workaround for prosemirrors delayed dom selection syncing during pointer drag
165
+ }];
166
+
167
+ // workaround for prosemirrors delayed dom selection syncing during pointer drag
173
168
  // causing issues with table selections in Safari
174
169
  // https://github.com/ProseMirror/prosemirror-view/commit/885258b80551ac87b81601d3ed25f552aeb22293
170
+
175
171
  // NOTE: this workaround can be removed when next upgrading prosemirror as the issue will be fixed
176
172
  // https://github.com/ProseMirror/prosemirror-view/pull/116
177
-
178
173
  if (browser.safari) {
179
174
  plugins.push({
180
175
  name: 'tableSafariDelayedDomSelectionSyncingWorkaround',
@@ -182,10 +177,10 @@ const tablesPlugin = options => {
182
177
  return createTableSafariDelayedDomSelectionSyncingWorkaroundPlugin();
183
178
  }
184
179
  });
185
- } // Workaround for table element breaking issue caused by composition event with an inputType of deleteCompositionText.
186
- // https://github.com/ProseMirror/prosemirror/issues/934
187
-
180
+ }
188
181
 
182
+ // Workaround for table element breaking issue caused by composition event with an inputType of deleteCompositionText.
183
+ // https://github.com/ProseMirror/prosemirror/issues/934
189
184
  if (browser.safari) {
190
185
  plugins.push({
191
186
  name: 'tableSafariDeleteCompositionTextIssueWorkaround',
@@ -194,10 +189,8 @@ const tablesPlugin = options => {
194
189
  }
195
190
  });
196
191
  }
197
-
198
192
  return plugins;
199
193
  },
200
-
201
194
  contentComponent({
202
195
  editorView,
203
196
  popupsMountPoint,
@@ -301,7 +294,6 @@ const tablesPlugin = options => {
301
294
  }
302
295
  }));
303
296
  },
304
-
305
297
  pluginsOptions: {
306
298
  // TODO: ED-14676 This is not the final API design
307
299
  // For now, we are using this on (insert-api/api.ts) but we may create a proper place for it
@@ -313,7 +305,6 @@ const tablesPlugin = options => {
313
305
  if (nodeName !== 'table') {
314
306
  return null;
315
307
  }
316
-
317
308
  const table = createTable({
318
309
  schema
319
310
  });
@@ -329,10 +320,8 @@ const tablesPlugin = options => {
329
320
  priority: 600,
330
321
  keyshortcut: tooltip(toggleTable),
331
322
  icon: () => /*#__PURE__*/React.createElement(IconTable, null),
332
-
333
323
  action(insert, state) {
334
324
  var _options$editorAnalyt2;
335
-
336
325
  const tr = insert(createTable({
337
326
  schema: state.schema
338
327
  }));
@@ -347,11 +336,9 @@ const tablesPlugin = options => {
347
336
  })(tr);
348
337
  return tr;
349
338
  }
350
-
351
339
  }],
352
340
  floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
353
341
  }
354
342
  };
355
343
  };
356
-
357
344
  export default tablesPlugin;