@atlaskit/editor-plugin-table 7.25.10 → 7.25.12

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 (361) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/commands/clear.js +2 -14
  3. package/dist/cjs/commands/column-resize.js +11 -5
  4. package/dist/cjs/commands/delete.js +2 -1
  5. package/dist/cjs/commands/insert.js +8 -5
  6. package/dist/cjs/commands/selection.js +3 -3
  7. package/dist/cjs/commands-with-analytics.js +23 -52
  8. package/dist/cjs/nodeviews/TableComponent.js +29 -14
  9. package/dist/cjs/nodeviews/TableContainer.js +2 -2
  10. package/dist/cjs/nodeviews/TableResizer.js +1 -1
  11. package/dist/cjs/plugin.js +4 -2
  12. package/dist/cjs/pm-plugins/analytics/plugin.js +2 -1
  13. package/dist/cjs/pm-plugins/decorations/utils/index.js +1 -8
  14. package/dist/cjs/pm-plugins/drag-and-drop/commands.js +3 -3
  15. package/dist/cjs/pm-plugins/drag-and-drop/index.js +1 -14
  16. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +4 -1
  17. package/dist/cjs/pm-plugins/drag-and-drop/utils/index.js +0 -7
  18. package/dist/cjs/pm-plugins/safari-delete-composition-text-issue-workaround.js +2 -2
  19. package/dist/cjs/pm-plugins/sticky-headers/index.js +1 -14
  20. package/dist/cjs/pm-plugins/table-analytics.js +2 -2
  21. package/dist/cjs/pm-plugins/table-resizing/commands.js +2 -2
  22. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +33 -15
  23. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +15 -6
  24. package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +1 -2
  25. package/dist/cjs/pm-plugins/table-resizing/utils/dom.js +3 -3
  26. package/dist/cjs/pm-plugins/table-resizing/utils/index.js +0 -103
  27. package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +23 -15
  28. package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +6 -7
  29. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +23 -18
  30. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +13 -8
  31. package/dist/cjs/pm-plugins/table-selection-keymap.js +1 -3
  32. package/dist/cjs/pm-plugins/view-mode-sort/utils.js +2 -2
  33. package/dist/cjs/toolbar.js +9 -9
  34. package/dist/cjs/transforms/column-width.js +3 -1
  35. package/dist/cjs/transforms/delete-columns.js +2 -1
  36. package/dist/cjs/transforms/index.js +0 -6
  37. package/dist/cjs/ui/FloatingContextualButton/FixedButton.js +2 -2
  38. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  39. package/dist/cjs/ui/FloatingDeleteButton/index.js +0 -1
  40. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +5 -4
  41. package/dist/cjs/ui/FloatingDragMenu/index.js +4 -2
  42. package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +2 -2
  43. package/dist/cjs/ui/FloatingInsertButton/index.js +3 -2
  44. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -3
  45. package/dist/cjs/ui/TableFloatingColumnControls/index.js +2 -2
  46. package/dist/cjs/ui/icons/index.js +0 -7
  47. package/dist/cjs/utils/column-controls.js +1 -22
  48. package/dist/cjs/utils/dom.js +1 -4
  49. package/dist/cjs/utils/drag-menu.js +3 -2
  50. package/dist/cjs/utils/index.js +0 -108
  51. package/dist/cjs/utils/merged-cells.js +1 -60
  52. package/dist/cjs/utils/nodes.js +2 -2
  53. package/dist/cjs/utils/row-controls.js +1 -8
  54. package/dist/cjs/utils/selection.js +1 -60
  55. package/dist/cjs/utils/table.js +1 -11
  56. package/dist/es2019/commands/clear.js +1 -14
  57. package/dist/es2019/commands/column-resize.js +11 -5
  58. package/dist/es2019/commands/delete.js +2 -2
  59. package/dist/es2019/commands/insert.js +8 -8
  60. package/dist/es2019/commands/selection.js +2 -2
  61. package/dist/es2019/commands-with-analytics.js +6 -36
  62. package/dist/es2019/nodeviews/TableComponent.js +30 -15
  63. package/dist/es2019/nodeviews/TableContainer.js +1 -1
  64. package/dist/es2019/nodeviews/TableResizer.js +1 -1
  65. package/dist/es2019/plugin.js +4 -2
  66. package/dist/es2019/pm-plugins/analytics/plugin.js +2 -1
  67. package/dist/es2019/pm-plugins/decorations/utils/index.js +1 -2
  68. package/dist/es2019/pm-plugins/drag-and-drop/commands.js +2 -2
  69. package/dist/es2019/pm-plugins/drag-and-drop/index.js +1 -2
  70. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +4 -1
  71. package/dist/es2019/pm-plugins/drag-and-drop/utils/index.js +0 -1
  72. package/dist/es2019/pm-plugins/safari-delete-composition-text-issue-workaround.js +1 -1
  73. package/dist/es2019/pm-plugins/sticky-headers/index.js +1 -2
  74. package/dist/es2019/pm-plugins/table-analytics.js +1 -1
  75. package/dist/es2019/pm-plugins/table-resizing/commands.js +1 -1
  76. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +32 -14
  77. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +15 -7
  78. package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +0 -1
  79. package/dist/es2019/pm-plugins/table-resizing/utils/dom.js +2 -2
  80. package/dist/es2019/pm-plugins/table-resizing/utils/index.js +5 -6
  81. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +22 -14
  82. package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +6 -7
  83. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +21 -15
  84. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +10 -7
  85. package/dist/es2019/pm-plugins/table-selection-keymap.js +1 -2
  86. package/dist/es2019/pm-plugins/view-mode-sort/utils.js +1 -1
  87. package/dist/es2019/toolbar.js +8 -8
  88. package/dist/es2019/transforms/column-width.js +3 -2
  89. package/dist/es2019/transforms/delete-columns.js +2 -2
  90. package/dist/es2019/transforms/index.js +1 -1
  91. package/dist/es2019/ui/FloatingContextualButton/FixedButton.js +1 -1
  92. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  93. package/dist/es2019/ui/FloatingDeleteButton/index.js +1 -1
  94. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +4 -3
  95. package/dist/es2019/ui/FloatingDragMenu/index.js +4 -2
  96. package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +1 -1
  97. package/dist/es2019/ui/FloatingInsertButton/index.js +3 -2
  98. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -2
  99. package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -1
  100. package/dist/es2019/ui/icons/index.js +0 -1
  101. package/dist/es2019/utils/column-controls.js +1 -19
  102. package/dist/es2019/utils/dom.js +0 -1
  103. package/dist/es2019/utils/drag-menu.js +3 -3
  104. package/dist/es2019/utils/index.js +8 -8
  105. package/dist/es2019/utils/merged-cells.js +0 -47
  106. package/dist/es2019/utils/nodes.js +1 -1
  107. package/dist/es2019/utils/row-controls.js +1 -8
  108. package/dist/es2019/utils/selection.js +0 -60
  109. package/dist/es2019/utils/table.js +0 -6
  110. package/dist/esm/commands/clear.js +1 -14
  111. package/dist/esm/commands/column-resize.js +11 -5
  112. package/dist/esm/commands/delete.js +2 -1
  113. package/dist/esm/commands/insert.js +8 -5
  114. package/dist/esm/commands/selection.js +2 -2
  115. package/dist/esm/commands-with-analytics.js +24 -52
  116. package/dist/esm/nodeviews/TableComponent.js +30 -15
  117. package/dist/esm/nodeviews/TableContainer.js +1 -1
  118. package/dist/esm/nodeviews/TableResizer.js +1 -1
  119. package/dist/esm/plugin.js +4 -2
  120. package/dist/esm/pm-plugins/analytics/plugin.js +2 -1
  121. package/dist/esm/pm-plugins/decorations/utils/index.js +1 -2
  122. package/dist/esm/pm-plugins/drag-and-drop/commands.js +2 -2
  123. package/dist/esm/pm-plugins/drag-and-drop/index.js +1 -2
  124. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +4 -1
  125. package/dist/esm/pm-plugins/drag-and-drop/utils/index.js +0 -1
  126. package/dist/esm/pm-plugins/safari-delete-composition-text-issue-workaround.js +1 -1
  127. package/dist/esm/pm-plugins/sticky-headers/index.js +1 -2
  128. package/dist/esm/pm-plugins/table-analytics.js +1 -1
  129. package/dist/esm/pm-plugins/table-resizing/commands.js +1 -1
  130. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +33 -15
  131. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +15 -6
  132. package/dist/esm/pm-plugins/table-resizing/utils/consts.js +0 -1
  133. package/dist/esm/pm-plugins/table-resizing/utils/dom.js +2 -2
  134. package/dist/esm/pm-plugins/table-resizing/utils/index.js +5 -6
  135. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +24 -14
  136. package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +6 -7
  137. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +22 -17
  138. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +12 -6
  139. package/dist/esm/pm-plugins/table-selection-keymap.js +1 -2
  140. package/dist/esm/pm-plugins/view-mode-sort/utils.js +1 -1
  141. package/dist/esm/toolbar.js +8 -8
  142. package/dist/esm/transforms/column-width.js +3 -1
  143. package/dist/esm/transforms/delete-columns.js +2 -1
  144. package/dist/esm/transforms/index.js +1 -1
  145. package/dist/esm/ui/FloatingContextualButton/FixedButton.js +1 -1
  146. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  147. package/dist/esm/ui/FloatingDeleteButton/index.js +1 -1
  148. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +4 -3
  149. package/dist/esm/ui/FloatingDragMenu/index.js +4 -2
  150. package/dist/esm/ui/FloatingInsertButton/InsertButton.js +1 -1
  151. package/dist/esm/ui/FloatingInsertButton/index.js +3 -2
  152. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -2
  153. package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -1
  154. package/dist/esm/ui/icons/index.js +0 -1
  155. package/dist/esm/utils/column-controls.js +1 -22
  156. package/dist/esm/utils/dom.js +0 -3
  157. package/dist/esm/utils/drag-menu.js +3 -2
  158. package/dist/esm/utils/index.js +8 -8
  159. package/dist/esm/utils/merged-cells.js +0 -59
  160. package/dist/esm/utils/nodes.js +1 -1
  161. package/dist/esm/utils/row-controls.js +1 -8
  162. package/dist/esm/utils/selection.js +0 -59
  163. package/dist/esm/utils/table.js +0 -9
  164. package/dist/types/commands/clear.d.ts +0 -1
  165. package/dist/types/commands/delete.d.ts +1 -1
  166. package/dist/types/commands/insert.d.ts +4 -4
  167. package/dist/types/commands/selection.d.ts +0 -4
  168. package/dist/types/commands-with-analytics.d.ts +2 -3
  169. package/dist/types/nodeviews/TableComponent.d.ts +1 -1
  170. package/dist/types/nodeviews/TableContainer.d.ts +0 -11
  171. package/dist/types/nodeviews/TableResizer.d.ts +1 -3
  172. package/dist/types/pm-plugins/analytics/actions.d.ts +3 -2
  173. package/dist/types/pm-plugins/decorations/utils/index.d.ts +0 -1
  174. package/dist/types/pm-plugins/decorations/utils/types.d.ts +2 -1
  175. package/dist/types/pm-plugins/drag-and-drop/actions.d.ts +5 -4
  176. package/dist/types/pm-plugins/drag-and-drop/commands.d.ts +1 -6
  177. package/dist/types/pm-plugins/drag-and-drop/index.d.ts +0 -2
  178. package/dist/types/pm-plugins/drag-and-drop/utils/index.d.ts +0 -1
  179. package/dist/types/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +0 -2
  180. package/dist/types/pm-plugins/sticky-headers/index.d.ts +0 -1
  181. package/dist/types/pm-plugins/sticky-headers/types.d.ts +3 -2
  182. package/dist/types/pm-plugins/table-analytics.d.ts +0 -12
  183. package/dist/types/pm-plugins/table-resizing/commands.d.ts +0 -5
  184. package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +3 -2
  185. package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +0 -1
  186. package/dist/types/pm-plugins/table-resizing/utils/dom.d.ts +0 -2
  187. package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +5 -8
  188. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -2
  189. package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +3 -2
  190. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +3 -5
  191. package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -4
  192. package/dist/types/pm-plugins/table-selection-keymap.d.ts +0 -1
  193. package/dist/types/pm-plugins/view-mode-sort/types.d.ts +2 -1
  194. package/dist/types/pm-plugins/view-mode-sort/utils.d.ts +0 -6
  195. package/dist/types/toolbar.d.ts +1 -14
  196. package/dist/types/transforms/column-width.d.ts +1 -1
  197. package/dist/types/transforms/delete-columns.d.ts +1 -1
  198. package/dist/types/transforms/index.d.ts +1 -1
  199. package/dist/types/ui/FloatingContextualButton/FixedButton.d.ts +1 -2
  200. package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -2
  201. package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
  202. package/dist/types/ui/FloatingDeleteButton/DeleteButton.d.ts +1 -1
  203. package/dist/types/ui/FloatingDeleteButton/index.d.ts +2 -3
  204. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +1 -2
  205. package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -2
  206. package/dist/types/ui/FloatingInsertButton/InsertButton.d.ts +1 -2
  207. package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -0
  208. package/dist/types/ui/FloatingToolbarLabel/FloatingToolbarLabel.d.ts +2 -1
  209. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -2
  210. package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -1
  211. package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -1
  212. package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -2
  213. package/dist/types/ui/TableFloatingControls/NumberColumn/index.d.ts +2 -1
  214. package/dist/types/ui/TableFloatingControls/RowDropTarget/index.d.ts +1 -1
  215. package/dist/types/ui/TableFloatingControls/index.d.ts +1 -1
  216. package/dist/types/ui/icons/index.d.ts +0 -1
  217. package/dist/types/utils/column-controls.d.ts +0 -2
  218. package/dist/types/utils/dom.d.ts +0 -1
  219. package/dist/types/utils/drag-menu.d.ts +1 -1
  220. package/dist/types/utils/index.d.ts +8 -8
  221. package/dist/types/utils/merged-cells.d.ts +0 -2
  222. package/dist/types/utils/nodes.d.ts +0 -1
  223. package/dist/types/utils/row-controls.d.ts +0 -1
  224. package/dist/types/utils/selection.d.ts +0 -3
  225. package/dist/types/utils/table.d.ts +0 -2
  226. package/dist/types-ts4.5/commands/clear.d.ts +0 -1
  227. package/dist/types-ts4.5/commands/delete.d.ts +1 -1
  228. package/dist/types-ts4.5/commands/insert.d.ts +4 -4
  229. package/dist/types-ts4.5/commands/selection.d.ts +0 -4
  230. package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -3
  231. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +1 -1
  232. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +0 -11
  233. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +1 -3
  234. package/dist/types-ts4.5/pm-plugins/analytics/actions.d.ts +3 -2
  235. package/dist/types-ts4.5/pm-plugins/decorations/utils/index.d.ts +0 -1
  236. package/dist/types-ts4.5/pm-plugins/decorations/utils/types.d.ts +2 -1
  237. package/dist/types-ts4.5/pm-plugins/drag-and-drop/actions.d.ts +5 -4
  238. package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands.d.ts +1 -6
  239. package/dist/types-ts4.5/pm-plugins/drag-and-drop/index.d.ts +0 -2
  240. package/dist/types-ts4.5/pm-plugins/drag-and-drop/utils/index.d.ts +0 -1
  241. package/dist/types-ts4.5/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +0 -2
  242. package/dist/types-ts4.5/pm-plugins/sticky-headers/index.d.ts +0 -1
  243. package/dist/types-ts4.5/pm-plugins/sticky-headers/types.d.ts +3 -2
  244. package/dist/types-ts4.5/pm-plugins/table-analytics.d.ts +0 -12
  245. package/dist/types-ts4.5/pm-plugins/table-resizing/commands.d.ts +0 -5
  246. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +3 -2
  247. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +0 -1
  248. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/dom.d.ts +0 -2
  249. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +5 -8
  250. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -2
  251. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +3 -2
  252. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +3 -5
  253. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -4
  254. package/dist/types-ts4.5/pm-plugins/table-selection-keymap.d.ts +0 -1
  255. package/dist/types-ts4.5/pm-plugins/view-mode-sort/types.d.ts +2 -1
  256. package/dist/types-ts4.5/pm-plugins/view-mode-sort/utils.d.ts +0 -6
  257. package/dist/types-ts4.5/toolbar.d.ts +1 -14
  258. package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
  259. package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
  260. package/dist/types-ts4.5/transforms/index.d.ts +1 -1
  261. package/dist/types-ts4.5/ui/FloatingContextualButton/FixedButton.d.ts +1 -2
  262. package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -2
  263. package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
  264. package/dist/types-ts4.5/ui/FloatingDeleteButton/DeleteButton.d.ts +1 -1
  265. package/dist/types-ts4.5/ui/FloatingDeleteButton/index.d.ts +2 -3
  266. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +1 -2
  267. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -2
  268. package/dist/types-ts4.5/ui/FloatingInsertButton/InsertButton.d.ts +1 -2
  269. package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -0
  270. package/dist/types-ts4.5/ui/FloatingToolbarLabel/FloatingToolbarLabel.d.ts +2 -1
  271. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -2
  272. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -1
  273. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -1
  274. package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -2
  275. package/dist/types-ts4.5/ui/TableFloatingControls/NumberColumn/index.d.ts +2 -1
  276. package/dist/types-ts4.5/ui/TableFloatingControls/RowDropTarget/index.d.ts +1 -1
  277. package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +1 -1
  278. package/dist/types-ts4.5/ui/icons/index.d.ts +0 -1
  279. package/dist/types-ts4.5/utils/column-controls.d.ts +0 -2
  280. package/dist/types-ts4.5/utils/dom.d.ts +0 -1
  281. package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
  282. package/dist/types-ts4.5/utils/index.d.ts +8 -8
  283. package/dist/types-ts4.5/utils/merged-cells.d.ts +0 -2
  284. package/dist/types-ts4.5/utils/nodes.d.ts +0 -1
  285. package/dist/types-ts4.5/utils/row-controls.d.ts +0 -1
  286. package/dist/types-ts4.5/utils/selection.d.ts +0 -3
  287. package/dist/types-ts4.5/utils/table.d.ts +0 -2
  288. package/package.json +3 -3
  289. package/src/commands/clear.ts +0 -14
  290. package/src/commands/column-resize.ts +19 -6
  291. package/src/commands/delete.ts +2 -0
  292. package/src/commands/insert.ts +8 -0
  293. package/src/commands/selection.ts +1 -1
  294. package/src/commands-with-analytics.ts +5 -40
  295. package/src/nodeviews/TableComponent.tsx +43 -9
  296. package/src/nodeviews/TableContainer.tsx +1 -1
  297. package/src/nodeviews/TableResizer.tsx +2 -4
  298. package/src/plugin.tsx +2 -0
  299. package/src/pm-plugins/analytics/actions.ts +2 -2
  300. package/src/pm-plugins/analytics/plugin.ts +2 -1
  301. package/src/pm-plugins/decorations/utils/index.ts +0 -1
  302. package/src/pm-plugins/decorations/utils/types.ts +1 -1
  303. package/src/pm-plugins/drag-and-drop/actions.ts +4 -4
  304. package/src/pm-plugins/drag-and-drop/commands.ts +2 -2
  305. package/src/pm-plugins/drag-and-drop/index.ts +0 -3
  306. package/src/pm-plugins/drag-and-drop/plugin.ts +4 -0
  307. package/src/pm-plugins/drag-and-drop/utils/index.ts +0 -2
  308. package/src/pm-plugins/safari-delete-composition-text-issue-workaround.ts +1 -1
  309. package/src/pm-plugins/sticky-headers/index.ts +0 -1
  310. package/src/pm-plugins/sticky-headers/types.ts +2 -2
  311. package/src/pm-plugins/table-analytics.ts +1 -1
  312. package/src/pm-plugins/table-resizing/commands.ts +1 -1
  313. package/src/pm-plugins/table-resizing/event-handlers.ts +39 -15
  314. package/src/pm-plugins/table-resizing/utils/colgroup.ts +18 -7
  315. package/src/pm-plugins/table-resizing/utils/consts.ts +0 -1
  316. package/src/pm-plugins/table-resizing/utils/dom.ts +2 -5
  317. package/src/pm-plugins/table-resizing/utils/index.ts +4 -30
  318. package/src/pm-plugins/table-resizing/utils/misc.ts +25 -17
  319. package/src/pm-plugins/table-resizing/utils/resize-column.ts +14 -13
  320. package/src/pm-plugins/table-resizing/utils/resize-state.ts +28 -21
  321. package/src/pm-plugins/table-resizing/utils/scale-table.ts +18 -6
  322. package/src/pm-plugins/table-selection-keymap.ts +0 -2
  323. package/src/pm-plugins/view-mode-sort/types.ts +1 -1
  324. package/src/pm-plugins/view-mode-sort/utils.ts +1 -5
  325. package/src/toolbar.tsx +8 -5
  326. package/src/transforms/column-width.ts +2 -0
  327. package/src/transforms/delete-columns.ts +2 -0
  328. package/src/transforms/index.ts +1 -1
  329. package/src/ui/FloatingContextualButton/FixedButton.tsx +2 -2
  330. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +5 -2
  331. package/src/ui/FloatingContextualMenu/index.tsx +1 -1
  332. package/src/ui/FloatingDeleteButton/DeleteButton.tsx +1 -1
  333. package/src/ui/FloatingDeleteButton/index.tsx +2 -2
  334. package/src/ui/FloatingDragMenu/DragMenu.tsx +4 -1
  335. package/src/ui/FloatingDragMenu/index.tsx +4 -1
  336. package/src/ui/FloatingInsertButton/InsertButton.tsx +2 -2
  337. package/src/ui/FloatingInsertButton/index.tsx +3 -0
  338. package/src/ui/FloatingToolbarLabel/FloatingToolbarLabel.tsx +1 -1
  339. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +1 -3
  340. package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +1 -1
  341. package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +1 -1
  342. package/src/ui/TableFloatingColumnControls/index.tsx +2 -2
  343. package/src/ui/TableFloatingControls/NumberColumn/index.tsx +1 -1
  344. package/src/ui/TableFloatingControls/RowDropTarget/index.tsx +1 -1
  345. package/src/ui/TableFloatingControls/index.tsx +1 -1
  346. package/src/ui/icons/index.ts +0 -1
  347. package/src/utils/column-controls.ts +2 -38
  348. package/src/utils/dom.ts +0 -4
  349. package/src/utils/drag-menu.ts +3 -0
  350. package/src/utils/index.ts +1 -22
  351. package/src/utils/merged-cells.ts +0 -62
  352. package/src/utils/nodes.ts +1 -1
  353. package/src/utils/row-controls.ts +1 -19
  354. package/src/utils/selection.ts +0 -84
  355. package/src/utils/table.ts +0 -8
  356. package/dist/cjs/utils/transforms.js +0 -11
  357. package/dist/es2019/utils/transforms.js +0 -5
  358. package/dist/esm/utils/transforms.js +0 -5
  359. package/dist/types/utils/transforms.d.ts +0 -2
  360. package/dist/types-ts4.5/utils/transforms.d.ts +0 -2
  361. package/src/utils/transforms.ts +0 -10
@@ -4,7 +4,7 @@ import type { TableDirection } from '../../types';
4
4
 
5
5
  import type { DropTargetType } from './consts';
6
6
 
7
- export interface DragAndDropAction<T, D> {
7
+ interface DragAndDropAction<T, D> {
8
8
  type: T;
9
9
  data: D;
10
10
  }
@@ -15,7 +15,7 @@ export const DragAndDropActionType = {
15
15
  TOGGLE_DRAG_MENU: 'TOGGLE_DRAG_MENU',
16
16
  } as const;
17
17
 
18
- export type DragAndDropSetDropTargetAction = DragAndDropAction<
18
+ type DragAndDropSetDropTargetAction = DragAndDropAction<
19
19
  typeof DragAndDropActionType.SET_DROP_TARGET,
20
20
  {
21
21
  type: DropTargetType;
@@ -24,14 +24,14 @@ export type DragAndDropSetDropTargetAction = DragAndDropAction<
24
24
  }
25
25
  >;
26
26
 
27
- export type DragAndDropClearDropTargetAction = DragAndDropAction<
27
+ type DragAndDropClearDropTargetAction = DragAndDropAction<
28
28
  typeof DragAndDropActionType.CLEAR_DROP_TARGET,
29
29
  {
30
30
  decorationSet: DecorationSet;
31
31
  }
32
32
  >;
33
33
 
34
- export type DragAndDropToggleDragMenuAction = DragAndDropAction<
34
+ type DragAndDropToggleDragMenuAction = DragAndDropAction<
35
35
  typeof DragAndDropActionType.TOGGLE_DRAG_MENU,
36
36
  {
37
37
  isDragMenuOpen: boolean;
@@ -14,11 +14,11 @@ import { pluginKey } from './plugin-key';
14
14
  import type { TriggerType } from './types';
15
15
 
16
16
  // TODO: This command is a placeholder example. Please replace this if required.
17
- export const getDecorations = (state: EditorState): DecorationSet => {
17
+ const getDecorations = (state: EditorState): DecorationSet => {
18
18
  return pluginKey.getState(state)?.decorationSet || DecorationSet.empty;
19
19
  };
20
20
 
21
- export const updatePluginStateDecorations = (
21
+ const updatePluginStateDecorations = (
22
22
  state: EditorState,
23
23
  decorations: Decoration[],
24
24
  key: TableDecorations,
@@ -1,5 +1,2 @@
1
1
  export { createPlugin } from './plugin';
2
2
  export { pluginKey } from './plugin-key';
3
- export type { DragAndDropPluginState } from './types';
4
-
5
- export { setDropTarget, clearDropTarget } from './commands';
@@ -224,6 +224,9 @@ const destroyFn = (
224
224
  isTableScalingEnabledOnCurrentTable = tableNode.attrs.displayMode !== 'fixed';
225
225
  }
226
226
 
227
+ if (isTableScalingEnabled && isCommentEditor) {
228
+ isTableScalingEnabledOnCurrentTable = true;
229
+ }
227
230
  const shouldUseIncreasedScalingPercent =
228
231
  (isTableScalingWithFixedColumnWidthsOptionEnabled &&
229
232
  fg('platform.editor.table.use-increased-scaling-percent')) ||
@@ -236,6 +239,7 @@ const destroyFn = (
236
239
  isTableScalingEnabledOnCurrentTable,
237
240
  undefined,
238
241
  shouldUseIncreasedScalingPercent,
242
+ isCommentEditor,
239
243
  );
240
244
  }
241
245
  }
@@ -1,3 +1 @@
1
- export { getDraggableDataFromEvent } from './monitor';
2
-
3
1
  export { autoScrollerFactory } from './autoscrollers';
@@ -13,7 +13,7 @@ interface SafariDeleteCompositionTextIssueWorkaroundPluginState {
13
13
  decorations: DecorationSet;
14
14
  }
15
15
 
16
- export const tableSafariDeleteCompositionTextIssueWorkaroundKey =
16
+ const tableSafariDeleteCompositionTextIssueWorkaroundKey =
17
17
  new PluginKey<SafariDeleteCompositionTextIssueWorkaroundPluginState>(
18
18
  'tableSafariDeleteCompositionTextIssueWorkaround',
19
19
  );
@@ -3,4 +3,3 @@ export { pluginKey } from './plugin-key';
3
3
  export type { StickyPluginState, RowStickyState } from './types';
4
4
 
5
5
  export { findStickyHeaderForTable } from './util';
6
- export { updateStickyState, removeStickyState } from './commands';
@@ -7,12 +7,12 @@ export type RowStickyState = {
7
7
 
8
8
  export type StickyPluginState = RowStickyState[];
9
9
 
10
- export type UpdateSticky = {
10
+ type UpdateSticky = {
11
11
  name: 'UPDATE';
12
12
  state: RowStickyState;
13
13
  };
14
14
 
15
- export type RemoveSticky = {
15
+ type RemoveSticky = {
16
16
  name: 'REMOVE';
17
17
  pos: number;
18
18
  };
@@ -20,7 +20,7 @@ type TableAnalyticsPluginState = {
20
20
  lastTrigger: LastTrigger | undefined;
21
21
  };
22
22
 
23
- export const pluginKey = new PluginKey<TableAnalyticsPluginState>('tableOverflowAnalyticsPlugin');
23
+ const pluginKey = new PluginKey<TableAnalyticsPluginState>('tableOverflowAnalyticsPlugin');
24
24
 
25
25
  export const META_KEYS = {
26
26
  OVERFLOW_TRIGGER: 'tableOverflowTrigger',
@@ -100,7 +100,7 @@ export const setDragging = (
100
100
  (originalTr) => (tr || originalTr).setMeta('is-resizer-resizing', true),
101
101
  );
102
102
 
103
- export const setLastClick = (
103
+ const setLastClick = (
104
104
  lastClick: { x: number; y: number; time: number } | null,
105
105
  transform?: (tr: Transaction) => Transaction,
106
106
  ) =>
@@ -39,6 +39,8 @@ import {
39
39
  resizeColumnAndTable,
40
40
  updateControls,
41
41
  } from './utils';
42
+ import { TABLE_OFFSET_IN_COMMENT_EDITOR } from './utils/consts';
43
+ import { getScalingPercentForTableWithoutWidth, getTableScalingPercent } from './utils/misc';
42
44
  import { scaleResizeState } from './utils/resize-column';
43
45
 
44
46
  export const handleMouseDown = (
@@ -88,13 +90,18 @@ export const handleMouseDown = (
88
90
  dom = dom.closest('table') as HTMLTableElement;
89
91
  }
90
92
 
91
- const maxSize = getTableMaxWidth({
92
- table: originalTable,
93
- tableStart: start,
94
- state,
95
- layout: originalTable.attrs.layout,
96
- getEditorContainerWidth,
97
- });
93
+ let maxSize = 0;
94
+ if (isTableScalingEnabled && isCommentEditor && !originalTable.attrs?.width) {
95
+ maxSize = editorWidth - TABLE_OFFSET_IN_COMMENT_EDITOR;
96
+ } else {
97
+ maxSize = getTableMaxWidth({
98
+ table: originalTable,
99
+ tableStart: start,
100
+ state,
101
+ layout: originalTable.attrs.layout,
102
+ getEditorContainerWidth,
103
+ });
104
+ }
98
105
 
99
106
  let shouldScale = tableDepth === 0 && isTableScalingEnabled;
100
107
  const { tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags();
@@ -106,6 +113,15 @@ export const handleMouseDown = (
106
113
  shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
107
114
  }
108
115
 
116
+ let shouldUseIncreasedScalingPercent =
117
+ isTableScalingWithFixedColumnWidthsOptionEnabled &&
118
+ fg('platform.editor.table.use-increased-scaling-percent');
119
+
120
+ if (isTableScalingEnabled && isCommentEditor) {
121
+ shouldScale = tableDepth === 0;
122
+ shouldUseIncreasedScalingPercent = true;
123
+ }
124
+
109
125
  let resizeState = getResizeState({
110
126
  minWidth: tableCellMinWidth,
111
127
  maxSize,
@@ -114,11 +130,8 @@ export const handleMouseDown = (
114
130
  start,
115
131
  domAtPos,
116
132
  isTableScalingEnabled: shouldScale,
117
- shouldUseIncreasedScalingPercent:
118
- (isTableScalingWithFixedColumnWidthsOptionEnabled &&
119
- fg('platform.editor.table.use-increased-scaling-percent')) ||
120
- // When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
121
- (isTableScalingEnabled && !!isCommentEditor),
133
+ shouldUseIncreasedScalingPercent,
134
+ isCommentEditor: isCommentEditor || false,
122
135
  });
123
136
 
124
137
  if (
@@ -150,6 +163,7 @@ export const handleMouseDown = (
150
163
  tableRef: dom,
151
164
  tableNode: originalTable,
152
165
  editorWidth,
166
+ shouldUseIncreasedScalingPercent,
153
167
  });
154
168
  }
155
169
 
@@ -269,6 +283,11 @@ export const handleMouseDown = (
269
283
  tr.setNodeAttribute(start - 1, 'width', newResizeState.maxSize);
270
284
  }
271
285
  } else {
286
+ const scalePercent =
287
+ isTableScalingEnabled && isCommentEditor && !table.attrs?.width
288
+ ? getScalingPercentForTableWithoutWidth(originalTable, dom)
289
+ : getTableScalingPercent(originalTable, dom, shouldUseIncreasedScalingPercent);
290
+
272
291
  const newResizeState = resizeColumn(
273
292
  resizeState,
274
293
  colIndex,
@@ -277,7 +296,7 @@ export const handleMouseDown = (
277
296
  originalTable,
278
297
  resizingSelectedColumns ? selectedColumns : undefined,
279
298
  shouldScale,
280
- shouldUseIncreasedScalingPercent,
299
+ scalePercent,
281
300
  );
282
301
  tr = updateColumnWidths(newResizeState, table, start, api)(tr);
283
302
  }
@@ -362,7 +381,7 @@ export const handleMouseDown = (
362
381
 
363
382
  const resizedDelta = clientX - dragging.startX;
364
383
 
365
- if (isNewColumnResizingEnabled && !isTableNested(state, tablePos)) {
384
+ if (isNewColumnResizingEnabled && !isTableNested(state, tablePos) && !isCommentEditor) {
366
385
  resizeColumnAndTable({
367
386
  resizeState,
368
387
  colIndex,
@@ -374,6 +393,11 @@ export const handleMouseDown = (
374
393
  isTableAlignmentEnabled,
375
394
  });
376
395
  } else {
396
+ const scalePercent =
397
+ isTableScalingEnabled && isCommentEditor && !table.attrs?.width
398
+ ? getScalingPercentForTableWithoutWidth(table, dom)
399
+ : getTableScalingPercent(originalTable, dom, shouldUseIncreasedScalingPercent);
400
+ // This function is called for Full-page/Fixed-page tables and table that have width attr value in Comment editor
377
401
  resizeColumn(
378
402
  resizeState,
379
403
  colIndex,
@@ -382,7 +406,7 @@ export const handleMouseDown = (
382
406
  table,
383
407
  undefined,
384
408
  shouldScale,
385
- shouldUseIncreasedScalingPercent,
409
+ scalePercent,
386
410
  );
387
411
  }
388
412
 
@@ -4,7 +4,7 @@ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
5
5
  import { TableMap } from '@atlaskit/editor-tables/table-map';
6
6
 
7
- import { getTableScalingPercent } from './misc';
7
+ import { getScalingPercentForTableWithoutWidth, getTableScalingPercent } from './misc';
8
8
 
9
9
  type Col = Array<string | { [name: string]: string }>;
10
10
 
@@ -21,20 +21,26 @@ export const generateColgroup = (
21
21
  table: PmNode,
22
22
  tableRef?: HTMLElement,
23
23
  shouldUseIncreasedScalingPercent?: boolean,
24
+ isCommentEditor?: boolean,
24
25
  ) => {
25
26
  const cols: Col[] = [];
26
27
  const map = TableMap.get(table);
28
+
27
29
  table.content.firstChild!.content.forEach((cell) => {
28
30
  const colspan = cell.attrs.colspan || 1;
29
31
  if (Array.isArray(cell.attrs.colwidth)) {
30
32
  // We slice here to guard against our colwidth array having more entries
31
33
  // Than the we actually span. We'll patch the document at a later point.
32
34
  if (tableRef) {
33
- const scalePercent = getTableScalingPercent(
34
- table,
35
- tableRef,
36
- shouldUseIncreasedScalingPercent,
37
- );
35
+ // if we have tableRef here, isTableScalingEnabled is true
36
+ let scalePercent = 1;
37
+
38
+ if (isCommentEditor && !table.attrs?.width) {
39
+ scalePercent = getScalingPercentForTableWithoutWidth(table, tableRef);
40
+ } else {
41
+ scalePercent = getTableScalingPercent(table, tableRef, shouldUseIncreasedScalingPercent);
42
+ }
43
+
38
44
  cell.attrs.colwidth.slice(0, colspan).forEach((width) => {
39
45
  const fixedColWidth = getColWidthFix(width, map.width);
40
46
  const scaledWidth = fixedColWidth * scalePercent;
@@ -81,6 +87,7 @@ export const insertColgroupFromNode = (
81
87
  isTableScalingEnabled = false,
82
88
  shouldRemove = true,
83
89
  shouldUseIncreasedScalingPercent = false,
90
+ isCommentEditor = false,
84
91
  ): HTMLCollection => {
85
92
  let colgroup = tableRef?.querySelector('colgroup') as HTMLElement;
86
93
  if (colgroup && shouldRemove) {
@@ -91,6 +98,7 @@ export const insertColgroupFromNode = (
91
98
  table,
92
99
  isTableScalingEnabled ? tableRef ?? undefined : undefined,
93
100
  shouldUseIncreasedScalingPercent,
101
+ isCommentEditor,
94
102
  );
95
103
  if (shouldRemove) {
96
104
  tableRef?.insertBefore(colgroup, tableRef?.firstChild);
@@ -105,6 +113,8 @@ export const hasTableBeenResized = (table: PmNode) => {
105
113
  );
106
114
  };
107
115
 
116
+ export const hasTableColumnBeenResized = hasTableBeenResized;
117
+
108
118
  /**
109
119
  * Check if a table has all the column width set to tableCellMinWidth(48px) or null
110
120
  *
@@ -127,11 +137,12 @@ function renderColgroupFromNode(
127
137
  table: PmNode,
128
138
  maybeTableRef: HTMLElement | undefined,
129
139
  shouldUseIncreasedScalingPercent: boolean,
140
+ isCommentEditor: boolean,
130
141
  ): HTMLElement {
131
142
  const rendered = DOMSerializer.renderSpec(document, [
132
143
  'colgroup',
133
144
  {},
134
- ...generateColgroup(table, maybeTableRef, shouldUseIncreasedScalingPercent),
145
+ ...generateColgroup(table, maybeTableRef, shouldUseIncreasedScalingPercent, isCommentEditor),
135
146
  ]);
136
147
 
137
148
  return rendered.dom as HTMLElement;
@@ -1,5 +1,4 @@
1
1
  export const COLUMN_MIN_WIDTH = 48;
2
- export const TABLE_DEFAULT_WIDTH = 760;
3
2
  export const TABLE_MAX_WIDTH = 1800;
4
3
  export const FULL_WIDTH_EDITOR_CONTENT_WIDTH = 1800;
5
4
  export const MAX_SCALING_PERCENT = 0.3;
@@ -83,7 +83,7 @@ export const updateStickyMargins = (table: HTMLElement) => {
83
83
  table.style.marginTop = `${tableMarginTop + firstRowHeight}px`;
84
84
  };
85
85
 
86
- export const applyColWidthsToStickyRow = (
86
+ const applyColWidthsToStickyRow = (
87
87
  // @ts-ignore - CCFE error TS6133: 'colGroup' is declared but its value is never read.
88
88
  colGroup: HTMLTableColElement | null,
89
89
  headerRow: HTMLTableRowElement,
@@ -111,10 +111,7 @@ export const syncStickyRowToTable = (tableRef?: HTMLElement | null) => {
111
111
  applyTableWidthToStickyRow(tableRef, headerRow);
112
112
  };
113
113
 
114
- export const applyTableWidthToStickyRow = (
115
- tableRef: HTMLElement,
116
- headerRow: HTMLTableRowElement,
117
- ) => {
114
+ const applyTableWidthToStickyRow = (tableRef: HTMLElement, headerRow: HTMLTableRowElement) => {
118
115
  const tbody = tableRef.querySelector('tbody')!;
119
116
  const wrapper = tableRef.parentElement;
120
117
 
@@ -5,44 +5,18 @@ export {
5
5
  getColgroupChildrenLength,
6
6
  } from './colgroup';
7
7
  export { contentWidth } from './content-width';
8
- export {
9
- getColumnStateFromDOM,
10
- getFreeSpace,
11
- getCellsRefsInColumn,
12
- calculateColumnWidth,
13
- addContainerLeftRightPadding,
14
- } from './column-state';
15
- export type { ColumnState } from './column-state';
16
- export { growColumn, shrinkColumn, reduceSpace } from './resize-logic';
17
- export {
18
- getResizeState,
19
- updateColgroup,
20
- getTotalWidth,
21
- evenAllColumnsWidths,
22
- bulkColumnsResize,
23
- areColumnsEven,
24
- adjustColumnsWidths,
25
- } from './resize-state';
8
+ export { getCellsRefsInColumn, calculateColumnWidth } from './column-state';
9
+ export { getResizeState, updateColgroup, evenAllColumnsWidths } from './resize-state';
26
10
  export {
27
11
  getLayoutSize,
28
- getDefaultLayoutMaxWidth,
29
12
  pointsAtCell,
30
13
  currentColWidth,
31
- domCellAround,
32
14
  getTableMaxWidth,
33
15
  getTableElementWidth,
34
16
  getTableContainerElementWidth,
35
17
  } from './misc';
36
18
  export { updateControls, isClickNear, getResizeCellPos } from './dom';
37
- export { scale, scaleWithParent, scaleTable, previewScaleTable } from './scale-table';
38
- export type { ScaleOptions } from './scale-table';
19
+ export { scaleTable, previewScaleTable } from './scale-table';
39
20
  export type { ResizeState, ResizeStateWithAnalytics } from './types';
40
21
  export { resizeColumn, resizeColumnAndTable } from './resize-column';
41
- export {
42
- COLUMN_MIN_WIDTH,
43
- TABLE_MAX_WIDTH,
44
- TABLE_DEFAULT_WIDTH,
45
- MAX_SCALING_PERCENT,
46
- MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION,
47
- TABLE_OFFSET_IN_COMMENT_EDITOR,
48
- } from './consts';
22
+ export { COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH, TABLE_OFFSET_IN_COMMENT_EDITOR } from './consts';
@@ -6,8 +6,7 @@ import {
6
6
  } from '@atlaskit/editor-common/node-width';
7
7
  import { calcTableWidth } from '@atlaskit/editor-common/styles';
8
8
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
9
- import { getBreakpoint, mapBreakpointToLayoutMaxWidth } from '@atlaskit/editor-common/ui';
10
- import { calcTableColumnWidths, containsClassName } from '@atlaskit/editor-common/utils';
9
+ import { calcTableColumnWidths } from '@atlaskit/editor-common/utils';
11
10
  import type { NodeSpec, Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
12
11
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
13
12
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -19,7 +18,7 @@ import {
19
18
 
20
19
  import type { TableOptions } from '../../../nodeviews/types';
21
20
 
22
- import { hasTableBeenResized } from './colgroup';
21
+ import { hasTableBeenResized, hasTableColumnBeenResized } from './colgroup';
23
22
  import {
24
23
  MAX_SCALING_PERCENT,
25
24
  MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION,
@@ -47,10 +46,6 @@ export function getLayoutSize(
47
46
  return layoutToWidth[tableLayout] || containerWidth;
48
47
  }
49
48
 
50
- export function getDefaultLayoutMaxWidth(containerWidth?: number): number {
51
- return mapBreakpointToLayoutMaxWidth(getBreakpoint(containerWidth));
52
- }
53
-
54
49
  // Does the current position point at a cell.
55
50
  export function pointsAtCell($pos: ResolvedPos) {
56
51
  return (
@@ -84,16 +79,6 @@ export function currentColWidth(
84
79
  return domWidth / parts;
85
80
  }
86
81
 
87
- // Attempts to find a parent TD/TH depending on target element.
88
- export function domCellAround(target: HTMLElement | null): HTMLElement | null {
89
- while (target && target.nodeName !== 'TD' && target.nodeName !== 'TH') {
90
- target = containsClassName(target, 'ProseMirror')
91
- ? null
92
- : (target.parentNode as HTMLElement | null);
93
- }
94
- return target;
95
- }
96
-
97
82
  interface getTableMaxWidthProps {
98
83
  table: PMNode;
99
84
  tableStart: number;
@@ -154,9 +139,32 @@ export const getTableScalingPercent = (
154
139
  // minus 1 here to avoid any 1px scroll in Firefox
155
140
  let scalePercent = (renderWidth - 1) / tableWidth;
156
141
  scalePercent = Math.max(scalePercent, 1 - maxScalingPercent);
142
+
157
143
  return Math.min(scalePercent, 1);
158
144
  };
159
145
 
146
+ // This function is used to default and full-width tables in Comment/Chromeless editors
147
+ // These tables don't have node.attrs.width set. Their pm-table-wrapper width depend on the editor container width.
148
+ // actual table node width can be calculated as sum of colwidth values if table's columns were resized.
149
+ // If colwidth are not set, table columns are not resized, they all are equal widths.
150
+ export const getScalingPercentForTableWithoutWidth = (
151
+ table: PMNode,
152
+ tableRef: HTMLElement | null,
153
+ ) => {
154
+ // are table columns resized
155
+ if (hasTableColumnBeenResized(table)) {
156
+ const tableWidth = calcTableColumnWidths(table).reduce((sum, width) => sum + width, 0);
157
+ let renderWidth = tableRef?.parentElement?.clientWidth || tableWidth;
158
+
159
+ // minus 1 here to avoid any 1px scroll in Firefox
160
+ return (renderWidth - 1) / tableWidth;
161
+ }
162
+
163
+ // When table cols are not resized and table width is not set,
164
+ // tableWidth is equal to renderWidth
165
+ return 1;
166
+ };
167
+
160
168
  export const getStaticTableScalingPercent = (
161
169
  table: PMNode,
162
170
  tableRenderWidth: number,
@@ -28,13 +28,11 @@ export const resizeColumn = (
28
28
  tableNode: PmNode,
29
29
  selectedColumns?: number[],
30
30
  isTableScalingEnabled = false,
31
- shouldUseIncreasedScalingPercent = false,
31
+ scalePercent = 1,
32
32
  ): ResizeState => {
33
- let scalePercent = 1;
34
33
  let resizeAmount = amount;
35
34
 
36
35
  if (isTableScalingEnabled) {
37
- scalePercent = getTableScalingPercent(tableNode, tableRef, shouldUseIncreasedScalingPercent);
38
36
  resizeAmount = amount / scalePercent;
39
37
  }
40
38
 
@@ -45,13 +43,7 @@ export const resizeColumn = (
45
43
  ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns)
46
44
  : resizeState;
47
45
 
48
- updateColgroup(
49
- newState,
50
- tableRef,
51
- tableNode,
52
- isTableScalingEnabled,
53
- shouldUseIncreasedScalingPercent,
54
- );
46
+ updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled, scalePercent);
55
47
 
56
48
  return newState;
57
49
  };
@@ -143,7 +135,7 @@ export const resizeColumnAndTable = ({
143
135
  );
144
136
 
145
137
  // do not apply scaling logic because resize state is already scaled
146
- updateColgroup(newState, tableRef, tableNode, false, false);
138
+ updateColgroup(newState, tableRef, tableNode, false, 1);
147
139
 
148
140
  updateTablePreview(
149
141
  tableRef,
@@ -190,7 +182,12 @@ export const scaleResizeState = ({
190
182
  tableRef,
191
183
  tableNode,
192
184
  editorWidth,
193
- }: TableReferences & { resizeState: ResizeState; editorWidth: number }): ResizeState => {
185
+ shouldUseIncreasedScalingPercent,
186
+ }: TableReferences & {
187
+ resizeState: ResizeState;
188
+ editorWidth: number;
189
+ shouldUseIncreasedScalingPercent: boolean;
190
+ }): ResizeState => {
194
191
  const isNumberColumnEnabled = tableNode.attrs.isNumberColumnEnabled;
195
192
  const isTableScaled =
196
193
  isNumberColumnEnabled || resizeState.maxSize > getEditorContainerWidth(editorWidth);
@@ -205,7 +202,11 @@ export const scaleResizeState = ({
205
202
  return resizeState;
206
203
  }
207
204
 
208
- const scalePercent = getTableScalingPercent(tableNode, tableRef);
205
+ const scalePercent = getTableScalingPercent(
206
+ tableNode,
207
+ tableRef,
208
+ shouldUseIncreasedScalingPercent,
209
+ );
209
210
  const scaledTableWidth = Math.round(resizeState.tableWidth * scalePercent);
210
211
  let cols = resizeState.cols.map((col) => {
211
212
  return {