@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,35 +1,31 @@
1
- import { unitToNumber } from './unit-to-number'; // calculates content width of a cell
1
+ import { unitToNumber } from './unit-to-number';
2
2
 
3
+ // calculates content width of a cell
3
4
  export function contentWidth(elem, container, colWidths = [], canvas = document.createElement('canvas')) {
4
5
  return calcContentWidth(elem, container || elem, canvas, colWidths);
5
6
  }
6
-
7
7
  function calcContentWidth(elem, container, canvas, colWidths) {
8
8
  const flowWidths = [];
9
9
  let curWidth = 0;
10
-
11
10
  for (let i = 0; i < elem.childNodes.length; i++) {
12
11
  const child = elem.childNodes[i];
13
-
14
12
  if (child.nodeType === Node.COMMENT_NODE) {
15
13
  continue;
16
14
  }
17
-
18
15
  if (child.nodeType === Node.TEXT_NODE) {
19
16
  const parent = child.parentNode;
20
17
  const parentStyle = getComputedStyle(parent);
21
18
  let contentLength = 0;
22
-
23
19
  if (parent.nodeName === 'CODE' || parent.nodeName === 'PRE') {
24
20
  contentLength = handlePreText(canvas, parent, child.textContent, parentStyle.font);
25
21
  } else {
26
22
  contentLength = measureText(canvas, child.textContent, parentStyle.font);
27
23
  }
28
-
29
24
  const left = parent.offsetLeft - container.offsetLeft;
30
25
  flowWidths.push(curWidth);
31
- curWidth += contentLength + left; // If the text isn't meant to wrap, we should set that as a hard limit.
26
+ curWidth += contentLength + left;
32
27
 
28
+ // If the text isn't meant to wrap, we should set that as a hard limit.
33
29
  if (parentStyle.whiteSpace === 'nowrap') {
34
30
  // + 3 is for date offset plus cursor
35
31
  // TODO There should be a programmatic way to get this.
@@ -38,15 +34,12 @@ function calcContentWidth(elem, container, canvas, colWidths) {
38
34
  } else {
39
35
  // FIXME: doesn't quite work right with spacing
40
36
  const style = getComputedStyle(child);
41
-
42
37
  if (style.minWidth && style.minWidth.endsWith('px') && style.minWidth !== '0px') {
43
38
  colWidths.push(unitToNumber(style.minWidth));
44
39
  }
45
-
46
40
  const {
47
41
  width
48
42
  } = contentWidth(child, container, colWidths, canvas);
49
-
50
43
  if (style.display && style.display.indexOf('inline') > -1) {
51
44
  // is inline element, add to curWidth
52
45
  curWidth += width;
@@ -57,41 +50,31 @@ function calcContentWidth(elem, container, canvas, colWidths) {
57
50
  }
58
51
  }
59
52
  }
60
-
61
53
  flowWidths.push(curWidth);
62
54
  return {
63
55
  minWidth: colWidths.reduce((oldMax, width) => Math.max(width, oldMax), 0),
64
56
  width: flowWidths.reduce((oldMax, width) => Math.max(width, oldMax), 0)
65
57
  };
66
58
  }
67
-
68
59
  function measureText(canvas, text, font) {
69
60
  const ctx = canvas.getContext('2d');
70
-
71
61
  if (!ctx) {
72
62
  return 0;
73
63
  }
74
-
75
64
  if (font) {
76
65
  ctx.font = font;
77
66
  }
78
-
79
67
  return Math.round(ctx.measureText(text || '').width);
80
68
  }
81
-
82
69
  function handlePreText(canvas, node, textContent, font) {
83
70
  let parent = node;
84
-
85
71
  if (node.nodeName === 'CODE') {
86
72
  parent = node.parentNode;
87
73
  }
88
-
89
74
  const computedStyle = getComputedStyle(parent);
90
-
91
75
  if (textContent && computedStyle.whiteSpace === 'pre') {
92
76
  // If white space is pre grab the longest line in the block.
93
77
  return textContent.split('\n').reduce((acc, current) => Math.max(measureText(canvas, current, font), acc), 0);
94
78
  }
95
-
96
79
  return measureText(canvas, textContent, font);
97
80
  }
@@ -9,73 +9,59 @@ export const updateControls = getEditorFeatureFlags => state => {
9
9
  const {
10
10
  tableRef
11
11
  } = getMainPluginState(state);
12
-
13
12
  if (!tableRef) {
14
13
  return;
15
14
  }
16
-
17
15
  const tr = tableRef.querySelector('tr');
18
-
19
16
  if (!tr) {
20
17
  return;
21
18
  }
22
-
23
19
  const wrapper = tableRef.parentElement;
24
-
25
20
  if (!(wrapper && wrapper.parentElement)) {
26
21
  return;
27
22
  }
28
-
29
23
  const rowControls = wrapper.parentElement.querySelectorAll(`.${ClassName.ROW_CONTROLS_BUTTON_WRAP}`);
30
24
  const numberedRows = wrapper.parentElement.querySelectorAll(ClassName.NUMBERED_COLUMN_BUTTON);
31
25
  syncStickyRowToTable(tableRef);
32
- const rowHeights = getRowHeights(tableRef); // update rows controls height on resize
26
+ const rowHeights = getRowHeights(tableRef);
33
27
 
28
+ // update rows controls height on resize
34
29
  for (let i = 0, count = rowControls.length; i < count; i++) {
35
30
  const height = rowHeights[i];
36
-
37
31
  if (height) {
38
32
  rowControls[i].style.height = `${height}px`;
39
-
40
33
  if (numberedRows.length) {
41
34
  numberedRows[i].style.height = `${height}px`;
42
35
  }
43
36
  }
44
37
  }
45
-
46
38
  const rightShadows = wrapper.parentElement.querySelectorAll(`.${ClassName.TABLE_RIGHT_SHADOW}`);
47
39
  const leftShadows = wrapper.parentElement.querySelectorAll(`.${ClassName.TABLE_LEFT_SHADOW}`);
48
40
  updateOverflowShadows(getEditorFeatureFlags)(state, wrapper, tableRef, rightShadows, leftShadows);
49
41
  };
50
42
  export const isClickNear = (event, click) => {
51
43
  const dx = click.x - event.clientX,
52
- dy = click.y - event.clientY;
44
+ dy = click.y - event.clientY;
53
45
  return dx * dx + dy * dy < 100;
54
46
  };
55
47
  export const getResizeCellPos = (view, event, lastColumnResizable) => {
56
48
  const target = event.target;
57
-
58
49
  if (!containsClassName(target, ClassName.RESIZE_HANDLE_DECORATION)) {
59
50
  return null;
60
51
  }
61
-
62
52
  const tableCell = closestElement(target, 'td, th');
63
-
64
53
  if (!tableCell) {
65
54
  return null;
66
55
  }
67
-
68
56
  const cellStartPosition = view.posAtDOM(tableCell, 0);
69
57
  return cellStartPosition - 1;
70
58
  };
71
59
  export const updateStickyMargins = table => {
72
60
  const row = table.querySelector('tr.sticky');
73
-
74
61
  if (!row) {
75
62
  table.style.marginTop = '';
76
63
  return;
77
64
  }
78
-
79
65
  const paddingTop = parsePx(window.getComputedStyle(row).paddingTop || '') || 0;
80
66
  const firstRowHeight = row.getBoundingClientRect().height - paddingTop - tableCellBorderWidth;
81
67
  table.style.marginTop = `${tableMarginTop + firstRowHeight}px`;
@@ -83,7 +69,6 @@ export const updateStickyMargins = table => {
83
69
  export const applyColWidthsToStickyRow = (colGroup, headerRow) => {
84
70
  // sync column widths for the sticky row
85
71
  const newCols = colWidthsForRow(colGroup, headerRow);
86
-
87
72
  if (newCols) {
88
73
  headerRow.style.gridTemplateColumns = newCols;
89
74
  }
@@ -92,20 +77,16 @@ export const syncStickyRowToTable = tableRef => {
92
77
  if (!tableRef) {
93
78
  return;
94
79
  }
95
-
96
80
  const headerRow = tableRef.querySelector('tr[data-header-row]');
97
-
98
81
  if (!headerRow) {
99
82
  return;
100
83
  }
101
-
102
84
  applyColWidthsToStickyRow(tableRef.querySelector('colgroup'), headerRow);
103
85
  applyTableWidthToStickyRow(tableRef, headerRow);
104
86
  };
105
87
  export const applyTableWidthToStickyRow = (tableRef, headerRow) => {
106
88
  const tbody = tableRef.querySelector('tbody');
107
89
  const wrapper = tableRef.parentElement;
108
-
109
90
  if (tbody && wrapper) {
110
91
  // when resizing in Chrome, clientWidth will give us 759px
111
92
  // but toggling the sticky class will reset it to 760px.
@@ -7,51 +7,46 @@ export const tableLayoutToSize = {
7
7
  default: akEditorDefaultLayoutWidth,
8
8
  wide: akEditorWideLayoutWidth,
9
9
  'full-width': akEditorFullWidthLayoutWidth
10
- }; // Translates named layouts in number values.
10
+ };
11
11
 
12
+ // Translates named layouts in number values.
12
13
  export function getLayoutSize(tableLayout, containerWidth = 0, options) {
13
14
  const {
14
15
  isFullWidthModeEnabled
15
16
  } = options;
16
-
17
17
  if (isFullWidthModeEnabled) {
18
18
  return containerWidth ? Math.min(containerWidth - akEditorGutterPadding * 2, akEditorFullWidthLayoutWidth) : akEditorFullWidthLayoutWidth;
19
19
  }
20
-
21
20
  const calculatedTableWidth = calcTableWidth(tableLayout, containerWidth, true);
22
-
23
21
  if (calculatedTableWidth.endsWith('px')) {
24
22
  return parseInt(calculatedTableWidth, 10);
25
23
  }
26
-
27
24
  if (tableLayout === 'default') {
28
25
  return getDefaultLayoutMaxWidth(containerWidth);
29
26
  }
30
-
31
27
  return tableLayoutToSize[tableLayout] || containerWidth;
32
28
  }
33
29
  export function getDefaultLayoutMaxWidth(containerWidth) {
34
30
  return mapBreakpointToLayoutMaxWidth(getBreakpoint(containerWidth));
35
- } // Does the current position point at a cell.
31
+ }
36
32
 
33
+ // Does the current position point at a cell.
37
34
  export function pointsAtCell($pos) {
38
35
  return $pos.parent.type.spec.tableRole === 'row' && $pos.nodeAfter;
39
- } // Get the current col width, handles colspan.
36
+ }
40
37
 
38
+ // Get the current col width, handles colspan.
41
39
  export function currentColWidth(view, cellPos, {
42
40
  colspan,
43
41
  colwidth
44
42
  }) {
45
43
  let width = colwidth && colwidth[colwidth.length - 1];
46
-
47
44
  if (width) {
48
45
  return width;
49
- } // Not fixed, read current width from DOM
50
-
51
-
46
+ }
47
+ // Not fixed, read current width from DOM
52
48
  let domWidth = view.domAtPos(cellPos + 1).node.offsetWidth;
53
49
  let parts = colspan || 0;
54
-
55
50
  if (colwidth) {
56
51
  for (let i = 0; i < (colspan || 0); i++) {
57
52
  if (colwidth[i]) {
@@ -60,15 +55,14 @@ export function currentColWidth(view, cellPos, {
60
55
  }
61
56
  }
62
57
  }
63
-
64
58
  return domWidth / parts;
65
- } // Attempts to find a parent TD/TH depending on target element.
59
+ }
66
60
 
61
+ // Attempts to find a parent TD/TH depending on target element.
67
62
  export function domCellAround(target) {
68
63
  while (target && target.nodeName !== 'TD' && target.nodeName !== 'TH') {
69
64
  target = containsClassName(target, 'ProseMirror') ? null : target.parentNode;
70
65
  }
71
-
72
66
  return target;
73
67
  }
74
68
  export const getTableMaxWidth = ({
@@ -81,10 +75,8 @@ export const getTableMaxWidth = ({
81
75
  const containerWidth = getEditorContainerWidth();
82
76
  const parentWidth = getParentNodeWidth(tableStart, state, containerWidth);
83
77
  let maxWidth = parentWidth || getLayoutSize(layout, containerWidth.width, {});
84
-
85
78
  if (table.attrs.isNumberColumnEnabled) {
86
79
  maxWidth -= akEditorTableNumberColumnWidth;
87
80
  }
88
-
89
81
  return maxWidth;
90
82
  };
@@ -5,72 +5,59 @@ export const growColumn = (state, colIndex, amount, selectedColumns) => {
5
5
  if (!state.cols[colIndex] || !state.cols[colIndex + 1]) {
6
6
  return state;
7
7
  }
8
-
9
8
  const res = moveSpaceFrom(state, colIndex + 1, colIndex, amount);
10
9
  const remaining = amount - res.amount;
11
10
  let newState = res.state;
12
-
13
11
  if (remaining > 0) {
14
12
  newState = stackSpace(newState, colIndex, remaining).state;
15
13
  }
16
-
17
14
  if (selectedColumns) {
18
15
  return bulkColumnsResize(newState, selectedColumns, colIndex);
19
16
  }
20
-
21
17
  return newState;
22
18
  };
23
19
  export const shrinkColumn = (state, colIndex, amount, selectedColumns) => {
24
20
  // can't shrink if columns don't exist
25
21
  if (!state.cols[colIndex]) {
26
22
  return state;
27
- } // try to shrink dragging column by giving from the column to the right first
28
-
29
-
23
+ }
24
+ // try to shrink dragging column by giving from the column to the right first
30
25
  const res = moveSpaceFrom(state, colIndex, colIndex + 1, -amount);
31
26
  let newState = res.state;
32
27
  const isOverflownTable = getTotalWidth(newState) > newState.maxSize;
33
- const isLastColumn = !newState.cols[colIndex + 1]; // stop resizing the last column once table is not overflown
34
-
28
+ const isLastColumn = !newState.cols[colIndex + 1];
29
+ // stop resizing the last column once table is not overflown
35
30
  if (isLastColumn && !isOverflownTable) {
36
31
  return newState;
37
32
  }
38
-
39
33
  const remaining = amount + res.amount;
40
-
41
34
  if (remaining < 0) {
42
35
  newState = stackSpace(newState, colIndex + 1, remaining).state;
43
36
  }
44
-
45
37
  if (selectedColumns) {
46
38
  return bulkColumnsResize(newState, selectedColumns, colIndex);
47
39
  }
48
-
49
40
  return newState;
50
41
  };
51
42
  export function reduceSpace(state, amount, ignoreCols = []) {
52
- let remaining = amount; // keep trying to resolve resize request until we run out of free space,
53
- // or nothing to resize
43
+ let remaining = amount;
54
44
 
45
+ // keep trying to resolve resize request until we run out of free space,
46
+ // or nothing to resize
55
47
  while (remaining > 0) {
56
48
  // filter candidates only with free space
57
49
  const candidates = state.cols.filter(column => {
58
50
  return getFreeSpace(column) && ignoreCols.indexOf(column.index) === -1;
59
51
  });
60
-
61
52
  if (candidates.length === 0) {
62
53
  break;
63
54
  }
64
-
65
55
  const requestedResize = Math.floor(remaining / candidates.length);
66
-
67
56
  if (requestedResize === 0) {
68
57
  break;
69
58
  }
70
-
71
59
  candidates.forEach(candidate => {
72
60
  let newWidth = candidate.width - requestedResize;
73
-
74
61
  if (newWidth < candidate.minWidth) {
75
62
  // If the new requested width is less than our min
76
63
  // Calc what width we didn't use, we'll try extract that
@@ -81,146 +68,129 @@ export function reduceSpace(state, amount, ignoreCols = []) {
81
68
  } else {
82
69
  remaining -= requestedResize;
83
70
  }
84
-
85
- state = { ...state,
86
- cols: [...state.cols.slice(0, candidate.index), { ...candidate,
71
+ state = {
72
+ ...state,
73
+ cols: [...state.cols.slice(0, candidate.index), {
74
+ ...candidate,
87
75
  width: newWidth
88
76
  }, ...state.cols.slice(candidate.index + 1)]
89
77
  };
90
78
  });
91
79
  }
92
-
93
80
  return state;
94
81
  }
95
82
  var ColType; // TODO: should handle when destIdx:
96
83
  // - is beyond the range, and then not give it back
97
-
98
84
  (function (ColType) {
99
85
  ColType["SOURCE"] = "src";
100
86
  ColType["DEST"] = "dest";
101
87
  })(ColType || (ColType = {}));
102
-
103
88
  function moveSpaceFrom(state, srcIdx, destIdx, amount, useFreeSpace = true) {
104
89
  const srcCol = state.cols[srcIdx];
105
90
  const destCol = state.cols[destIdx];
106
-
107
91
  if (useFreeSpace) {
108
- const freeSpace = getFreeSpace(srcCol); // if taking more than source column's free space, only take that much
109
-
92
+ const freeSpace = getFreeSpace(srcCol);
93
+ // if taking more than source column's free space, only take that much
110
94
  if (amountFor(ColType.DEST)(amount) > freeSpace) {
111
95
  amount = amount > 0 ? freeSpace : -freeSpace;
112
96
  }
113
- } // if the source column shrinks past its min size, don't give the space away
114
-
97
+ }
115
98
 
99
+ // if the source column shrinks past its min size, don't give the space away
116
100
  if (amountFor(ColType.SOURCE)(amount) < 0 && widthFor(ColType.SOURCE)(amount, srcCol, destCol) < srcCol.minWidth) {
117
101
  amount = srcCol.width - srcCol.minWidth;
118
102
  }
119
-
120
- const newDest = destCol ? { ...destCol,
103
+ const newDest = destCol ? {
104
+ ...destCol,
121
105
  width: widthFor(ColType.DEST)(amount, srcCol, destCol)
122
106
  } : undefined;
123
-
124
107
  if (!newDest && amountFor(ColType.SOURCE)(amount) < 0) {
125
108
  // non-zero-sum game, ensure that we're not removing more than the total table width either
126
109
  const totalWidth = getTotalWidth(state);
127
-
128
110
  if (totalWidth - srcCol.width + widthFor(ColType.SOURCE)(amount, srcCol, destCol) < state.maxSize) {
129
111
  // would shrink table below max width, stop it
130
112
  amount = state.maxSize - (totalWidth - srcCol.width) - srcCol.width - 1;
131
113
  }
132
114
  }
133
-
134
- const newSrc = { ...srcCol,
115
+ const newSrc = {
116
+ ...srcCol,
135
117
  width: widthFor(ColType.SOURCE)(amount, srcCol, destCol)
136
118
  };
137
119
  const newCols = state.cols.map((existingCol, idx) => idx === srcIdx ? newSrc : idx === destIdx ? newDest : existingCol).filter(Boolean);
138
120
  return {
139
- state: { ...state,
121
+ state: {
122
+ ...state,
140
123
  cols: newCols
141
124
  },
142
125
  amount
143
126
  };
144
127
  }
145
-
146
128
  function stackSpace(state, destIdx, amount) {
147
129
  let candidates = getCandidates(state, destIdx, amount);
148
-
149
130
  while (candidates.length && amount) {
150
131
  // search for most (or least) free space in candidates
151
132
  let candidateIdx = findNextFreeColumn(candidates, amount);
152
-
153
133
  if (candidateIdx === -1) {
154
134
  // stack to the right -> growing the dragging column and go overflow
155
135
  if (amount > 0) {
156
136
  return {
157
- state: { ...state,
158
- cols: [...state.cols.slice(0, destIdx), { ...state.cols[destIdx],
137
+ state: {
138
+ ...state,
139
+ cols: [...state.cols.slice(0, destIdx), {
140
+ ...state.cols[destIdx],
159
141
  width: state.cols[destIdx].width + amount
160
142
  }, ...state.cols.slice(destIdx + 1)]
161
143
  },
162
144
  remaining: amount
163
145
  };
164
- } // stacking to the left, if no free space remains
165
-
146
+ }
166
147
 
148
+ // stacking to the left, if no free space remains
167
149
  break;
168
150
  }
169
-
170
151
  const column = candidates.find(col => col.index === candidateIdx);
171
-
172
152
  if (!column || getFreeSpace(column) <= 0) {
173
153
  // no more columns with free space remain
174
154
  break;
175
155
  }
176
-
177
156
  const res = moveSpaceFrom(state, column.index, destIdx, amount);
178
157
  state = res.state;
179
158
  amount -= res.amount;
180
159
  candidates = candidates.filter(col => col.index !== candidateIdx);
181
160
  }
182
-
183
161
  return {
184
162
  state,
185
163
  remaining: amount
186
164
  };
187
165
  }
188
-
189
166
  function findNextFreeColumn(columns, amount) {
190
167
  if (columns.length === 0) {
191
168
  return -1;
192
169
  }
193
-
194
170
  const direction = amount < 0 ? 'left' : 'right';
195
-
196
171
  if (direction === 'left') {
197
172
  columns = columns.slice().reverse();
198
173
  }
199
-
200
174
  let freeIndex = -1;
201
175
  columns.forEach(column => {
202
176
  if (getFreeSpace(column) && freeIndex === -1) {
203
177
  freeIndex = column.index;
204
178
  }
205
179
  });
206
-
207
180
  if (freeIndex === -1) {
208
181
  return -1;
209
182
  }
210
-
211
183
  return freeIndex;
212
184
  }
213
-
214
185
  function amountFor(colType) {
215
186
  return amount => colType === ColType.SOURCE ? amount > 0 ? -amount : amount : amount < 0 ? -amount : amount;
216
187
  }
217
-
218
188
  function widthFor(colType) {
219
189
  return (amount, srcCol, destCol) => (colType === ColType.SOURCE ? srcCol : destCol).width + amountFor(colType)(amount);
220
190
  }
221
-
222
191
  function getCandidates(state, destIdx, amount) {
223
- const candidates = state.cols; // only consider rows after the selected column in the direction of resize
192
+ const candidates = state.cols;
224
193
 
194
+ // only consider rows after the selected column in the direction of resize
225
195
  return amount < 0 ? candidates.slice(0, destIdx) : candidates.slice(destIdx + 1);
226
196
  }