@atlaskit/editor-plugin-table 7.25.10 → 7.25.11

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 (357) hide show
  1. package/CHANGELOG.md +15 -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/decorations/utils/index.js +1 -8
  13. package/dist/cjs/pm-plugins/drag-and-drop/commands.js +3 -3
  14. package/dist/cjs/pm-plugins/drag-and-drop/index.js +1 -14
  15. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +4 -1
  16. package/dist/cjs/pm-plugins/drag-and-drop/utils/index.js +0 -7
  17. package/dist/cjs/pm-plugins/safari-delete-composition-text-issue-workaround.js +2 -2
  18. package/dist/cjs/pm-plugins/sticky-headers/index.js +1 -14
  19. package/dist/cjs/pm-plugins/table-analytics.js +2 -2
  20. package/dist/cjs/pm-plugins/table-resizing/commands.js +2 -2
  21. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +33 -15
  22. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +15 -6
  23. package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +1 -2
  24. package/dist/cjs/pm-plugins/table-resizing/utils/dom.js +3 -3
  25. package/dist/cjs/pm-plugins/table-resizing/utils/index.js +0 -103
  26. package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +23 -15
  27. package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +6 -7
  28. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +23 -18
  29. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +13 -8
  30. package/dist/cjs/pm-plugins/table-selection-keymap.js +1 -3
  31. package/dist/cjs/pm-plugins/view-mode-sort/utils.js +2 -2
  32. package/dist/cjs/toolbar.js +9 -9
  33. package/dist/cjs/transforms/column-width.js +3 -1
  34. package/dist/cjs/transforms/delete-columns.js +2 -1
  35. package/dist/cjs/transforms/index.js +0 -6
  36. package/dist/cjs/ui/FloatingContextualButton/FixedButton.js +2 -2
  37. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  38. package/dist/cjs/ui/FloatingDeleteButton/index.js +0 -1
  39. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +5 -4
  40. package/dist/cjs/ui/FloatingDragMenu/index.js +4 -2
  41. package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +2 -2
  42. package/dist/cjs/ui/FloatingInsertButton/index.js +3 -2
  43. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -3
  44. package/dist/cjs/ui/TableFloatingColumnControls/index.js +2 -2
  45. package/dist/cjs/ui/icons/index.js +0 -7
  46. package/dist/cjs/utils/column-controls.js +1 -22
  47. package/dist/cjs/utils/dom.js +1 -4
  48. package/dist/cjs/utils/drag-menu.js +3 -2
  49. package/dist/cjs/utils/index.js +0 -108
  50. package/dist/cjs/utils/merged-cells.js +1 -60
  51. package/dist/cjs/utils/nodes.js +2 -2
  52. package/dist/cjs/utils/row-controls.js +1 -8
  53. package/dist/cjs/utils/selection.js +1 -60
  54. package/dist/cjs/utils/table.js +1 -11
  55. package/dist/es2019/commands/clear.js +1 -14
  56. package/dist/es2019/commands/column-resize.js +11 -5
  57. package/dist/es2019/commands/delete.js +2 -2
  58. package/dist/es2019/commands/insert.js +8 -8
  59. package/dist/es2019/commands/selection.js +2 -2
  60. package/dist/es2019/commands-with-analytics.js +6 -36
  61. package/dist/es2019/nodeviews/TableComponent.js +30 -15
  62. package/dist/es2019/nodeviews/TableContainer.js +1 -1
  63. package/dist/es2019/nodeviews/TableResizer.js +1 -1
  64. package/dist/es2019/plugin.js +4 -2
  65. package/dist/es2019/pm-plugins/decorations/utils/index.js +1 -2
  66. package/dist/es2019/pm-plugins/drag-and-drop/commands.js +2 -2
  67. package/dist/es2019/pm-plugins/drag-and-drop/index.js +1 -2
  68. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +4 -1
  69. package/dist/es2019/pm-plugins/drag-and-drop/utils/index.js +0 -1
  70. package/dist/es2019/pm-plugins/safari-delete-composition-text-issue-workaround.js +1 -1
  71. package/dist/es2019/pm-plugins/sticky-headers/index.js +1 -2
  72. package/dist/es2019/pm-plugins/table-analytics.js +1 -1
  73. package/dist/es2019/pm-plugins/table-resizing/commands.js +1 -1
  74. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +32 -14
  75. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +15 -7
  76. package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +0 -1
  77. package/dist/es2019/pm-plugins/table-resizing/utils/dom.js +2 -2
  78. package/dist/es2019/pm-plugins/table-resizing/utils/index.js +5 -6
  79. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +22 -14
  80. package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +6 -7
  81. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +21 -15
  82. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +10 -7
  83. package/dist/es2019/pm-plugins/table-selection-keymap.js +1 -2
  84. package/dist/es2019/pm-plugins/view-mode-sort/utils.js +1 -1
  85. package/dist/es2019/toolbar.js +8 -8
  86. package/dist/es2019/transforms/column-width.js +3 -2
  87. package/dist/es2019/transforms/delete-columns.js +2 -2
  88. package/dist/es2019/transforms/index.js +1 -1
  89. package/dist/es2019/ui/FloatingContextualButton/FixedButton.js +1 -1
  90. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  91. package/dist/es2019/ui/FloatingDeleteButton/index.js +1 -1
  92. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +4 -3
  93. package/dist/es2019/ui/FloatingDragMenu/index.js +4 -2
  94. package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +1 -1
  95. package/dist/es2019/ui/FloatingInsertButton/index.js +3 -2
  96. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -2
  97. package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -1
  98. package/dist/es2019/ui/icons/index.js +0 -1
  99. package/dist/es2019/utils/column-controls.js +1 -19
  100. package/dist/es2019/utils/dom.js +0 -1
  101. package/dist/es2019/utils/drag-menu.js +3 -3
  102. package/dist/es2019/utils/index.js +8 -8
  103. package/dist/es2019/utils/merged-cells.js +0 -47
  104. package/dist/es2019/utils/nodes.js +1 -1
  105. package/dist/es2019/utils/row-controls.js +1 -8
  106. package/dist/es2019/utils/selection.js +0 -60
  107. package/dist/es2019/utils/table.js +0 -6
  108. package/dist/esm/commands/clear.js +1 -14
  109. package/dist/esm/commands/column-resize.js +11 -5
  110. package/dist/esm/commands/delete.js +2 -1
  111. package/dist/esm/commands/insert.js +8 -5
  112. package/dist/esm/commands/selection.js +2 -2
  113. package/dist/esm/commands-with-analytics.js +24 -52
  114. package/dist/esm/nodeviews/TableComponent.js +30 -15
  115. package/dist/esm/nodeviews/TableContainer.js +1 -1
  116. package/dist/esm/nodeviews/TableResizer.js +1 -1
  117. package/dist/esm/plugin.js +4 -2
  118. package/dist/esm/pm-plugins/decorations/utils/index.js +1 -2
  119. package/dist/esm/pm-plugins/drag-and-drop/commands.js +2 -2
  120. package/dist/esm/pm-plugins/drag-and-drop/index.js +1 -2
  121. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +4 -1
  122. package/dist/esm/pm-plugins/drag-and-drop/utils/index.js +0 -1
  123. package/dist/esm/pm-plugins/safari-delete-composition-text-issue-workaround.js +1 -1
  124. package/dist/esm/pm-plugins/sticky-headers/index.js +1 -2
  125. package/dist/esm/pm-plugins/table-analytics.js +1 -1
  126. package/dist/esm/pm-plugins/table-resizing/commands.js +1 -1
  127. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +33 -15
  128. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +15 -6
  129. package/dist/esm/pm-plugins/table-resizing/utils/consts.js +0 -1
  130. package/dist/esm/pm-plugins/table-resizing/utils/dom.js +2 -2
  131. package/dist/esm/pm-plugins/table-resizing/utils/index.js +5 -6
  132. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +24 -14
  133. package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +6 -7
  134. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +22 -17
  135. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +12 -6
  136. package/dist/esm/pm-plugins/table-selection-keymap.js +1 -2
  137. package/dist/esm/pm-plugins/view-mode-sort/utils.js +1 -1
  138. package/dist/esm/toolbar.js +8 -8
  139. package/dist/esm/transforms/column-width.js +3 -1
  140. package/dist/esm/transforms/delete-columns.js +2 -1
  141. package/dist/esm/transforms/index.js +1 -1
  142. package/dist/esm/ui/FloatingContextualButton/FixedButton.js +1 -1
  143. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  144. package/dist/esm/ui/FloatingDeleteButton/index.js +1 -1
  145. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +4 -3
  146. package/dist/esm/ui/FloatingDragMenu/index.js +4 -2
  147. package/dist/esm/ui/FloatingInsertButton/InsertButton.js +1 -1
  148. package/dist/esm/ui/FloatingInsertButton/index.js +3 -2
  149. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -2
  150. package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -1
  151. package/dist/esm/ui/icons/index.js +0 -1
  152. package/dist/esm/utils/column-controls.js +1 -22
  153. package/dist/esm/utils/dom.js +0 -3
  154. package/dist/esm/utils/drag-menu.js +3 -2
  155. package/dist/esm/utils/index.js +8 -8
  156. package/dist/esm/utils/merged-cells.js +0 -59
  157. package/dist/esm/utils/nodes.js +1 -1
  158. package/dist/esm/utils/row-controls.js +1 -8
  159. package/dist/esm/utils/selection.js +0 -59
  160. package/dist/esm/utils/table.js +0 -9
  161. package/dist/types/commands/clear.d.ts +0 -1
  162. package/dist/types/commands/delete.d.ts +1 -1
  163. package/dist/types/commands/insert.d.ts +4 -4
  164. package/dist/types/commands/selection.d.ts +0 -4
  165. package/dist/types/commands-with-analytics.d.ts +2 -3
  166. package/dist/types/nodeviews/TableComponent.d.ts +1 -1
  167. package/dist/types/nodeviews/TableContainer.d.ts +0 -11
  168. package/dist/types/nodeviews/TableResizer.d.ts +1 -3
  169. package/dist/types/pm-plugins/analytics/actions.d.ts +3 -2
  170. package/dist/types/pm-plugins/decorations/utils/index.d.ts +0 -1
  171. package/dist/types/pm-plugins/decorations/utils/types.d.ts +2 -1
  172. package/dist/types/pm-plugins/drag-and-drop/actions.d.ts +5 -4
  173. package/dist/types/pm-plugins/drag-and-drop/commands.d.ts +1 -6
  174. package/dist/types/pm-plugins/drag-and-drop/index.d.ts +0 -2
  175. package/dist/types/pm-plugins/drag-and-drop/utils/index.d.ts +0 -1
  176. package/dist/types/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +0 -2
  177. package/dist/types/pm-plugins/sticky-headers/index.d.ts +0 -1
  178. package/dist/types/pm-plugins/sticky-headers/types.d.ts +3 -2
  179. package/dist/types/pm-plugins/table-analytics.d.ts +0 -12
  180. package/dist/types/pm-plugins/table-resizing/commands.d.ts +0 -5
  181. package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +3 -2
  182. package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +0 -1
  183. package/dist/types/pm-plugins/table-resizing/utils/dom.d.ts +0 -2
  184. package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +5 -8
  185. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -2
  186. package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +3 -2
  187. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +3 -5
  188. package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -4
  189. package/dist/types/pm-plugins/table-selection-keymap.d.ts +0 -1
  190. package/dist/types/pm-plugins/view-mode-sort/types.d.ts +2 -1
  191. package/dist/types/pm-plugins/view-mode-sort/utils.d.ts +0 -6
  192. package/dist/types/toolbar.d.ts +1 -14
  193. package/dist/types/transforms/column-width.d.ts +1 -1
  194. package/dist/types/transforms/delete-columns.d.ts +1 -1
  195. package/dist/types/transforms/index.d.ts +1 -1
  196. package/dist/types/ui/FloatingContextualButton/FixedButton.d.ts +1 -2
  197. package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -2
  198. package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
  199. package/dist/types/ui/FloatingDeleteButton/DeleteButton.d.ts +1 -1
  200. package/dist/types/ui/FloatingDeleteButton/index.d.ts +2 -3
  201. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +1 -2
  202. package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -2
  203. package/dist/types/ui/FloatingInsertButton/InsertButton.d.ts +1 -2
  204. package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -0
  205. package/dist/types/ui/FloatingToolbarLabel/FloatingToolbarLabel.d.ts +2 -1
  206. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -2
  207. package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -1
  208. package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -1
  209. package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -2
  210. package/dist/types/ui/TableFloatingControls/NumberColumn/index.d.ts +2 -1
  211. package/dist/types/ui/TableFloatingControls/RowDropTarget/index.d.ts +1 -1
  212. package/dist/types/ui/TableFloatingControls/index.d.ts +1 -1
  213. package/dist/types/ui/icons/index.d.ts +0 -1
  214. package/dist/types/utils/column-controls.d.ts +0 -2
  215. package/dist/types/utils/dom.d.ts +0 -1
  216. package/dist/types/utils/drag-menu.d.ts +1 -1
  217. package/dist/types/utils/index.d.ts +8 -8
  218. package/dist/types/utils/merged-cells.d.ts +0 -2
  219. package/dist/types/utils/nodes.d.ts +0 -1
  220. package/dist/types/utils/row-controls.d.ts +0 -1
  221. package/dist/types/utils/selection.d.ts +0 -3
  222. package/dist/types/utils/table.d.ts +0 -2
  223. package/dist/types-ts4.5/commands/clear.d.ts +0 -1
  224. package/dist/types-ts4.5/commands/delete.d.ts +1 -1
  225. package/dist/types-ts4.5/commands/insert.d.ts +4 -4
  226. package/dist/types-ts4.5/commands/selection.d.ts +0 -4
  227. package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -3
  228. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +1 -1
  229. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +0 -11
  230. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +1 -3
  231. package/dist/types-ts4.5/pm-plugins/analytics/actions.d.ts +3 -2
  232. package/dist/types-ts4.5/pm-plugins/decorations/utils/index.d.ts +0 -1
  233. package/dist/types-ts4.5/pm-plugins/decorations/utils/types.d.ts +2 -1
  234. package/dist/types-ts4.5/pm-plugins/drag-and-drop/actions.d.ts +5 -4
  235. package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands.d.ts +1 -6
  236. package/dist/types-ts4.5/pm-plugins/drag-and-drop/index.d.ts +0 -2
  237. package/dist/types-ts4.5/pm-plugins/drag-and-drop/utils/index.d.ts +0 -1
  238. package/dist/types-ts4.5/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +0 -2
  239. package/dist/types-ts4.5/pm-plugins/sticky-headers/index.d.ts +0 -1
  240. package/dist/types-ts4.5/pm-plugins/sticky-headers/types.d.ts +3 -2
  241. package/dist/types-ts4.5/pm-plugins/table-analytics.d.ts +0 -12
  242. package/dist/types-ts4.5/pm-plugins/table-resizing/commands.d.ts +0 -5
  243. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +3 -2
  244. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +0 -1
  245. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/dom.d.ts +0 -2
  246. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +5 -8
  247. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -2
  248. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +3 -2
  249. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +3 -5
  250. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -4
  251. package/dist/types-ts4.5/pm-plugins/table-selection-keymap.d.ts +0 -1
  252. package/dist/types-ts4.5/pm-plugins/view-mode-sort/types.d.ts +2 -1
  253. package/dist/types-ts4.5/pm-plugins/view-mode-sort/utils.d.ts +0 -6
  254. package/dist/types-ts4.5/toolbar.d.ts +1 -14
  255. package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
  256. package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
  257. package/dist/types-ts4.5/transforms/index.d.ts +1 -1
  258. package/dist/types-ts4.5/ui/FloatingContextualButton/FixedButton.d.ts +1 -2
  259. package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -2
  260. package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
  261. package/dist/types-ts4.5/ui/FloatingDeleteButton/DeleteButton.d.ts +1 -1
  262. package/dist/types-ts4.5/ui/FloatingDeleteButton/index.d.ts +2 -3
  263. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +1 -2
  264. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -2
  265. package/dist/types-ts4.5/ui/FloatingInsertButton/InsertButton.d.ts +1 -2
  266. package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -0
  267. package/dist/types-ts4.5/ui/FloatingToolbarLabel/FloatingToolbarLabel.d.ts +2 -1
  268. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -2
  269. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -1
  270. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -1
  271. package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -2
  272. package/dist/types-ts4.5/ui/TableFloatingControls/NumberColumn/index.d.ts +2 -1
  273. package/dist/types-ts4.5/ui/TableFloatingControls/RowDropTarget/index.d.ts +1 -1
  274. package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +1 -1
  275. package/dist/types-ts4.5/ui/icons/index.d.ts +0 -1
  276. package/dist/types-ts4.5/utils/column-controls.d.ts +0 -2
  277. package/dist/types-ts4.5/utils/dom.d.ts +0 -1
  278. package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
  279. package/dist/types-ts4.5/utils/index.d.ts +8 -8
  280. package/dist/types-ts4.5/utils/merged-cells.d.ts +0 -2
  281. package/dist/types-ts4.5/utils/nodes.d.ts +0 -1
  282. package/dist/types-ts4.5/utils/row-controls.d.ts +0 -1
  283. package/dist/types-ts4.5/utils/selection.d.ts +0 -3
  284. package/dist/types-ts4.5/utils/table.d.ts +0 -2
  285. package/package.json +2 -2
  286. package/src/commands/clear.ts +0 -14
  287. package/src/commands/column-resize.ts +19 -6
  288. package/src/commands/delete.ts +2 -0
  289. package/src/commands/insert.ts +8 -0
  290. package/src/commands/selection.ts +1 -1
  291. package/src/commands-with-analytics.ts +5 -40
  292. package/src/nodeviews/TableComponent.tsx +43 -9
  293. package/src/nodeviews/TableContainer.tsx +1 -1
  294. package/src/nodeviews/TableResizer.tsx +2 -4
  295. package/src/plugin.tsx +2 -0
  296. package/src/pm-plugins/analytics/actions.ts +2 -2
  297. package/src/pm-plugins/decorations/utils/index.ts +0 -1
  298. package/src/pm-plugins/decorations/utils/types.ts +1 -1
  299. package/src/pm-plugins/drag-and-drop/actions.ts +4 -4
  300. package/src/pm-plugins/drag-and-drop/commands.ts +2 -2
  301. package/src/pm-plugins/drag-and-drop/index.ts +0 -3
  302. package/src/pm-plugins/drag-and-drop/plugin.ts +4 -0
  303. package/src/pm-plugins/drag-and-drop/utils/index.ts +0 -2
  304. package/src/pm-plugins/safari-delete-composition-text-issue-workaround.ts +1 -1
  305. package/src/pm-plugins/sticky-headers/index.ts +0 -1
  306. package/src/pm-plugins/sticky-headers/types.ts +2 -2
  307. package/src/pm-plugins/table-analytics.ts +1 -1
  308. package/src/pm-plugins/table-resizing/commands.ts +1 -1
  309. package/src/pm-plugins/table-resizing/event-handlers.ts +39 -15
  310. package/src/pm-plugins/table-resizing/utils/colgroup.ts +18 -7
  311. package/src/pm-plugins/table-resizing/utils/consts.ts +0 -1
  312. package/src/pm-plugins/table-resizing/utils/dom.ts +2 -5
  313. package/src/pm-plugins/table-resizing/utils/index.ts +4 -30
  314. package/src/pm-plugins/table-resizing/utils/misc.ts +25 -17
  315. package/src/pm-plugins/table-resizing/utils/resize-column.ts +14 -13
  316. package/src/pm-plugins/table-resizing/utils/resize-state.ts +28 -21
  317. package/src/pm-plugins/table-resizing/utils/scale-table.ts +18 -6
  318. package/src/pm-plugins/table-selection-keymap.ts +0 -2
  319. package/src/pm-plugins/view-mode-sort/types.ts +1 -1
  320. package/src/pm-plugins/view-mode-sort/utils.ts +1 -5
  321. package/src/toolbar.tsx +8 -5
  322. package/src/transforms/column-width.ts +2 -0
  323. package/src/transforms/delete-columns.ts +2 -0
  324. package/src/transforms/index.ts +1 -1
  325. package/src/ui/FloatingContextualButton/FixedButton.tsx +2 -2
  326. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +5 -2
  327. package/src/ui/FloatingContextualMenu/index.tsx +1 -1
  328. package/src/ui/FloatingDeleteButton/DeleteButton.tsx +1 -1
  329. package/src/ui/FloatingDeleteButton/index.tsx +2 -2
  330. package/src/ui/FloatingDragMenu/DragMenu.tsx +4 -1
  331. package/src/ui/FloatingDragMenu/index.tsx +4 -1
  332. package/src/ui/FloatingInsertButton/InsertButton.tsx +2 -2
  333. package/src/ui/FloatingInsertButton/index.tsx +3 -0
  334. package/src/ui/FloatingToolbarLabel/FloatingToolbarLabel.tsx +1 -1
  335. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +1 -3
  336. package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +1 -1
  337. package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +1 -1
  338. package/src/ui/TableFloatingColumnControls/index.tsx +2 -2
  339. package/src/ui/TableFloatingControls/NumberColumn/index.tsx +1 -1
  340. package/src/ui/TableFloatingControls/RowDropTarget/index.tsx +1 -1
  341. package/src/ui/TableFloatingControls/index.tsx +1 -1
  342. package/src/ui/icons/index.ts +0 -1
  343. package/src/utils/column-controls.ts +2 -38
  344. package/src/utils/dom.ts +0 -4
  345. package/src/utils/drag-menu.ts +3 -0
  346. package/src/utils/index.ts +1 -22
  347. package/src/utils/merged-cells.ts +0 -62
  348. package/src/utils/nodes.ts +1 -1
  349. package/src/utils/row-controls.ts +1 -19
  350. package/src/utils/selection.ts +0 -84
  351. package/src/utils/table.ts +0 -8
  352. package/dist/cjs/utils/transforms.js +0 -11
  353. package/dist/es2019/utils/transforms.js +0 -5
  354. package/dist/esm/utils/transforms.js +0 -5
  355. package/dist/types/utils/transforms.d.ts +0 -2
  356. package/dist/types-ts4.5/utils/transforms.d.ts +0 -2
  357. package/src/utils/transforms.ts +0 -10
@@ -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 {
@@ -25,6 +25,7 @@ export const getResizeState = ({
25
25
  domAtPos,
26
26
  isTableScalingEnabled = false,
27
27
  shouldUseIncreasedScalingPercent = false,
28
+ isCommentEditor = false,
28
29
  }: {
29
30
  minWidth: number;
30
31
  maxSize: number;
@@ -34,13 +35,18 @@ export const getResizeState = ({
34
35
  domAtPos: (pos: number) => { node: Node; offset: number };
35
36
  isTableScalingEnabled: boolean;
36
37
  shouldUseIncreasedScalingPercent: boolean;
38
+ isCommentEditor: boolean;
37
39
  }): ResizeState => {
38
- if (isTableScalingEnabled) {
40
+ if (
41
+ (isTableScalingEnabled && !isCommentEditor) ||
42
+ (isTableScalingEnabled && isCommentEditor && table.attrs?.width)
43
+ ) {
39
44
  const scalePercent = getTableScalingPercent(table, tableRef, shouldUseIncreasedScalingPercent);
40
45
  minWidth = Math.ceil(minWidth / scalePercent);
41
46
  }
42
- // If the table has been resized, we can use the column widths from the table node
47
+
43
48
  if (hasTableBeenResized(table)) {
49
+ // If the table has been resized, we can use the column widths from the table node
44
50
  const cols = calcTableColumnWidths(table).map((width, index) => ({
45
51
  width: width === 0 ? tableNewColumnMinWidth : width,
46
52
  minWidth: width === 0 ? tableNewColumnMinWidth : minWidth,
@@ -70,12 +76,16 @@ export const getResizeState = ({
70
76
  isTableScalingEnabled,
71
77
  shouldReinsertColgroup, // don't reinsert colgroup when preserving table width - this causes widths to jump
72
78
  shouldUseIncreasedScalingPercent,
79
+ isCommentEditor,
73
80
  );
74
81
  const cols = Array.from(colgroupChildren).map((_, index) => {
75
82
  // If the table hasn't been resized and we have a table width attribute, we can use it
76
83
  // to calculate the widths of the columns
77
84
  if (isTableScalingEnabled) {
78
- const tableNodeWidth = getTableContainerWidth(table);
85
+ // isCommentEditor when table cols were not resized,
86
+ // we want to use tableRef.parentElement.clientWidth, which is the same as maxSize
87
+ const tableNodeWidth =
88
+ isCommentEditor && !table.attrs?.width ? maxSize : getTableContainerWidth(table);
79
89
  return {
80
90
  index,
81
91
  width: tableNodeWidth / colgroupChildren.length,
@@ -107,7 +117,7 @@ export const updateColgroup = (
107
117
  tableRef: HTMLElement | null,
108
118
  tableNode?: PMNode,
109
119
  isTableScalingEnabled?: boolean,
110
- shouldUseIncreasedScalingPercent?: boolean,
120
+ scalePercent?: number,
111
121
  ): void => {
112
122
  const cols = tableRef?.querySelectorAll('col');
113
123
  const columnsCount = cols?.length;
@@ -117,16 +127,11 @@ export const updateColgroup = (
117
127
  We need to remove !isColumnResizing if we handled auto scale table when mouseUp event.
118
128
  * */
119
129
  if (isTableScalingEnabled && tableNode) {
120
- const scalePercent = getTableScalingPercent(
121
- tableNode,
122
- tableRef,
123
- shouldUseIncreasedScalingPercent,
124
- );
125
130
  state.cols
126
131
  .filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
127
132
  .forEach((column, i) => {
128
133
  const fixedColWidth = getColWidthFix(column.width, columnsCount ?? 0);
129
- const scaledWidth = fixedColWidth * scalePercent;
134
+ const scaledWidth = fixedColWidth * (scalePercent || 1);
130
135
  const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
131
136
  // we aren't handling the remaining pixels here when the 48px min width is reached
132
137
  if (cols?.[i]) {
@@ -187,7 +192,7 @@ const getSpace = (columns: ColumnState[], start: number, end: number) =>
187
192
  .map((col) => col.width)
188
193
  .reduce((sum, width) => sum + width, 0);
189
194
 
190
- export const evenSelectedColumnsWidths = (resizeState: ResizeState, rect: Rect): ResizeState => {
195
+ const evenSelectedColumnsWidths = (resizeState: ResizeState, rect: Rect): ResizeState => {
191
196
  const cols = resizeState.cols;
192
197
  const selectedSpace = getSpace(cols, rect.left, rect.right);
193
198
  const allSpace = getSpace(cols, 0, cols.length);
@@ -302,13 +307,8 @@ export const bulkColumnsResize = (
302
307
  return adjustColumnsWidths(newState, resizeState.maxSize);
303
308
  };
304
309
 
305
- export const areColumnsEven = (resizeState: ResizeState): boolean => {
306
- const newResizeState = evenAllColumnsWidths(resizeState);
307
- return newResizeState.cols.every((col, i) => col.width === resizeState.cols[i].width);
308
- };
309
-
310
310
  // Get the layout
311
- export const normaliseTableLayout = (input: string | undefined | null) => {
311
+ const normaliseTableLayout = (input: string | undefined | null) => {
312
312
  switch (input) {
313
313
  case 'wide':
314
314
  return input;
@@ -373,6 +373,15 @@ export const getNewResizeStateFromSelectedColumns = (
373
373
  isTableScalingEnabledOnCurrentTable = table.node.attrs.displayMode !== 'fixed';
374
374
  }
375
375
 
376
+ let shouldUseIncreasedScalingPercent =
377
+ isTableScalingWithFixedColumnWidthsOptionEnabled &&
378
+ fg('platform.editor.table.use-increased-scaling-percent');
379
+
380
+ if (isTableScalingEnabled && isCommentEditor) {
381
+ isTableScalingEnabledOnCurrentTable = true;
382
+ shouldUseIncreasedScalingPercent = true;
383
+ }
384
+
376
385
  resizeState = getResizeState({
377
386
  minWidth: tableCellMinWidth,
378
387
  maxSize,
@@ -381,10 +390,8 @@ export const getNewResizeStateFromSelectedColumns = (
381
390
  start: table.start,
382
391
  domAtPos,
383
392
  isTableScalingEnabled: isTableScalingEnabledOnCurrentTable,
384
- shouldUseIncreasedScalingPercent:
385
- (isTableScalingWithFixedColumnWidthsOptionEnabled &&
386
- fg('platform.editor.table.use-increased-scaling-percent')) ||
387
- (isTableScalingEnabled && isCommentEditor),
393
+ shouldUseIncreasedScalingPercent,
394
+ isCommentEditor,
388
395
  });
389
396
 
390
397
  const newResizeState = evenSelectedColumnsWidths(resizeState, rect);