@atlaskit/editor-plugin-table 22.4.14 → 22.4.16

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 (213) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/nodeviews/TableComponent.js +2 -2
  3. package/dist/cjs/nodeviews/table.js +2 -2
  4. package/dist/cjs/nodeviews/toDOM.js +2 -2
  5. package/dist/cjs/pm-plugins/commands/active-table-menu.js +51 -0
  6. package/dist/cjs/pm-plugins/commands/commands-with-analytics.js +42 -10
  7. package/dist/cjs/pm-plugins/commands/index.js +13 -0
  8. package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +2 -0
  9. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +4 -0
  10. package/dist/cjs/pm-plugins/handlers.js +8 -1
  11. package/dist/cjs/pm-plugins/main.js +4 -3
  12. package/dist/cjs/pm-plugins/reducer.js +2 -0
  13. package/dist/cjs/pm-plugins/table-width.js +2 -2
  14. package/dist/cjs/pm-plugins/transforms/content-mode.js +3 -2
  15. package/dist/cjs/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.js +70 -0
  16. package/dist/cjs/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.js +41 -0
  17. package/dist/cjs/pm-plugins/utils/tableMode/is-content-mode-supported.js +12 -0
  18. package/dist/cjs/pm-plugins/utils/tableMode/measure-table-with-auto-layout.js +113 -0
  19. package/dist/cjs/pm-plugins/utils/tableMode/smart-adjust/constants.js +10 -0
  20. package/dist/cjs/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.js +83 -0
  21. package/dist/cjs/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.js +56 -0
  22. package/dist/cjs/tablePlugin.js +1 -0
  23. package/dist/cjs/ui/ContentComponent.js +1 -1
  24. package/dist/cjs/ui/FloatingContextualButton/index.js +28 -9
  25. package/dist/cjs/ui/FloatingContextualMenu/CellMenuPopup.js +58 -73
  26. package/dist/cjs/ui/FloatingContextualMenu/index.js +26 -12
  27. package/dist/cjs/ui/FloatingDragMenu/index.js +21 -8
  28. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +13 -5
  29. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +14 -5
  30. package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +8 -3
  31. package/dist/cjs/ui/TableMenu/cell/items/MergeCellsItem.js +16 -1
  32. package/dist/cjs/ui/TableMenu/cell/items/SplitCellItem.js +16 -1
  33. package/dist/cjs/ui/TableMenu/column/items/AddColumnLeftItem.js +4 -4
  34. package/dist/cjs/ui/TableMenu/column/items/AddColumnRightItem.js +4 -4
  35. package/dist/cjs/ui/TableMenu/column/items/DeleteColumnItem.js +2 -3
  36. package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -3
  37. package/dist/cjs/ui/TableMenu/column/items/HeaderColumnToggleItem.js +2 -3
  38. package/dist/cjs/ui/TableMenu/column/items/MoveColumnLeftItem.js +2 -3
  39. package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -3
  40. package/dist/cjs/ui/TableMenu/column/items/SortDecreasingItem.js +2 -3
  41. package/dist/cjs/ui/TableMenu/column/items/SortIncreasingItem.js +2 -3
  42. package/dist/cjs/ui/TableMenu/row/items/AddRowAboveItem.js +4 -4
  43. package/dist/cjs/ui/TableMenu/row/items/AddRowBelowItem.js +4 -4
  44. package/dist/cjs/ui/TableMenu/row/items/DeleteRowItem.js +2 -3
  45. package/dist/cjs/ui/TableMenu/row/items/HeaderRowToggleItem.js +2 -3
  46. package/dist/cjs/ui/TableMenu/row/items/MoveRowDownItem.js +2 -3
  47. package/dist/cjs/ui/TableMenu/row/items/MoveRowUpItem.js +2 -3
  48. package/dist/cjs/ui/TableMenu/row/items/NumberedRowsToggleItem.js +4 -3
  49. package/dist/cjs/ui/TableMenu/shared/TableMenu.compiled.css +0 -2
  50. package/dist/cjs/ui/TableMenu/shared/TableMenu.js +8 -9
  51. package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +3 -1
  52. package/dist/cjs/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
  53. package/dist/cjs/ui/TableMenu/shared/items/BackgroundColorItem.js +30 -4
  54. package/dist/cjs/ui/TableMenu/shared/items/ClearCellsItem.js +4 -3
  55. package/dist/cjs/ui/toolbar.js +4 -3
  56. package/dist/es2019/nodeviews/TableComponent.js +1 -1
  57. package/dist/es2019/nodeviews/table.js +1 -1
  58. package/dist/es2019/nodeviews/toDOM.js +1 -1
  59. package/dist/es2019/pm-plugins/commands/active-table-menu.js +39 -0
  60. package/dist/es2019/pm-plugins/commands/commands-with-analytics.js +31 -2
  61. package/dist/es2019/pm-plugins/commands/index.js +1 -0
  62. package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +2 -0
  63. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +4 -0
  64. package/dist/es2019/pm-plugins/handlers.js +8 -1
  65. package/dist/es2019/pm-plugins/main.js +2 -1
  66. package/dist/es2019/pm-plugins/reducer.js +5 -0
  67. package/dist/es2019/pm-plugins/table-width.js +1 -1
  68. package/dist/es2019/pm-plugins/transforms/content-mode.js +2 -1
  69. package/dist/es2019/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.js +70 -0
  70. package/dist/es2019/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.js +38 -0
  71. package/dist/es2019/pm-plugins/utils/tableMode/is-content-mode-supported.js +7 -0
  72. package/dist/es2019/pm-plugins/utils/tableMode/measure-table-with-auto-layout.js +97 -0
  73. package/dist/es2019/pm-plugins/utils/tableMode/smart-adjust/constants.js +4 -0
  74. package/dist/es2019/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.js +63 -0
  75. package/dist/es2019/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.js +47 -0
  76. package/dist/es2019/tablePlugin.js +1 -0
  77. package/dist/es2019/ui/ContentComponent.js +1 -1
  78. package/dist/es2019/ui/FloatingContextualButton/index.js +29 -9
  79. package/dist/es2019/ui/FloatingContextualMenu/CellMenuPopup.js +60 -77
  80. package/dist/es2019/ui/FloatingContextualMenu/index.js +27 -12
  81. package/dist/es2019/ui/FloatingDragMenu/index.js +22 -8
  82. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -4
  83. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +13 -4
  84. package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +9 -3
  85. package/dist/es2019/ui/TableMenu/cell/items/MergeCellsItem.js +18 -2
  86. package/dist/es2019/ui/TableMenu/cell/items/SplitCellItem.js +18 -2
  87. package/dist/es2019/ui/TableMenu/column/items/AddColumnLeftItem.js +3 -3
  88. package/dist/es2019/ui/TableMenu/column/items/AddColumnRightItem.js +3 -3
  89. package/dist/es2019/ui/TableMenu/column/items/DeleteColumnItem.js +2 -3
  90. package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -3
  91. package/dist/es2019/ui/TableMenu/column/items/HeaderColumnToggleItem.js +2 -3
  92. package/dist/es2019/ui/TableMenu/column/items/MoveColumnLeftItem.js +2 -3
  93. package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -3
  94. package/dist/es2019/ui/TableMenu/column/items/SortDecreasingItem.js +2 -3
  95. package/dist/es2019/ui/TableMenu/column/items/SortIncreasingItem.js +2 -3
  96. package/dist/es2019/ui/TableMenu/row/items/AddRowAboveItem.js +3 -3
  97. package/dist/es2019/ui/TableMenu/row/items/AddRowBelowItem.js +3 -3
  98. package/dist/es2019/ui/TableMenu/row/items/DeleteRowItem.js +2 -3
  99. package/dist/es2019/ui/TableMenu/row/items/HeaderRowToggleItem.js +2 -3
  100. package/dist/es2019/ui/TableMenu/row/items/MoveRowDownItem.js +2 -3
  101. package/dist/es2019/ui/TableMenu/row/items/MoveRowUpItem.js +2 -3
  102. package/dist/es2019/ui/TableMenu/row/items/NumberedRowsToggleItem.js +3 -2
  103. package/dist/es2019/ui/TableMenu/shared/TableMenu.compiled.css +0 -2
  104. package/dist/es2019/ui/TableMenu/shared/TableMenu.js +8 -9
  105. package/dist/es2019/ui/TableMenu/shared/getSharedItems.js +3 -1
  106. package/dist/es2019/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
  107. package/dist/es2019/ui/TableMenu/shared/items/BackgroundColorItem.js +33 -4
  108. package/dist/es2019/ui/TableMenu/shared/items/ClearCellsItem.js +4 -3
  109. package/dist/es2019/ui/toolbar.js +2 -1
  110. package/dist/esm/nodeviews/TableComponent.js +1 -1
  111. package/dist/esm/nodeviews/table.js +1 -1
  112. package/dist/esm/nodeviews/toDOM.js +1 -1
  113. package/dist/esm/pm-plugins/commands/active-table-menu.js +45 -0
  114. package/dist/esm/pm-plugins/commands/commands-with-analytics.js +41 -10
  115. package/dist/esm/pm-plugins/commands/index.js +1 -0
  116. package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +2 -0
  117. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +4 -0
  118. package/dist/esm/pm-plugins/handlers.js +8 -1
  119. package/dist/esm/pm-plugins/main.js +2 -1
  120. package/dist/esm/pm-plugins/reducer.js +2 -0
  121. package/dist/esm/pm-plugins/table-width.js +1 -1
  122. package/dist/esm/pm-plugins/transforms/content-mode.js +2 -1
  123. package/dist/esm/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.js +65 -0
  124. package/dist/esm/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.js +36 -0
  125. package/dist/esm/pm-plugins/utils/tableMode/is-content-mode-supported.js +6 -0
  126. package/dist/esm/pm-plugins/utils/tableMode/measure-table-with-auto-layout.js +107 -0
  127. package/dist/esm/pm-plugins/utils/tableMode/smart-adjust/constants.js +4 -0
  128. package/dist/esm/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.js +77 -0
  129. package/dist/esm/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.js +49 -0
  130. package/dist/esm/tablePlugin.js +1 -0
  131. package/dist/esm/ui/ContentComponent.js +1 -1
  132. package/dist/esm/ui/FloatingContextualButton/index.js +29 -10
  133. package/dist/esm/ui/FloatingContextualMenu/CellMenuPopup.js +60 -75
  134. package/dist/esm/ui/FloatingContextualMenu/index.js +26 -12
  135. package/dist/esm/ui/FloatingDragMenu/index.js +21 -8
  136. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +12 -4
  137. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +13 -4
  138. package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +8 -3
  139. package/dist/esm/ui/TableMenu/cell/items/MergeCellsItem.js +16 -2
  140. package/dist/esm/ui/TableMenu/cell/items/SplitCellItem.js +16 -2
  141. package/dist/esm/ui/TableMenu/column/items/AddColumnLeftItem.js +4 -4
  142. package/dist/esm/ui/TableMenu/column/items/AddColumnRightItem.js +4 -4
  143. package/dist/esm/ui/TableMenu/column/items/DeleteColumnItem.js +2 -3
  144. package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +2 -3
  145. package/dist/esm/ui/TableMenu/column/items/HeaderColumnToggleItem.js +2 -3
  146. package/dist/esm/ui/TableMenu/column/items/MoveColumnLeftItem.js +2 -3
  147. package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -3
  148. package/dist/esm/ui/TableMenu/column/items/SortDecreasingItem.js +2 -3
  149. package/dist/esm/ui/TableMenu/column/items/SortIncreasingItem.js +2 -3
  150. package/dist/esm/ui/TableMenu/row/items/AddRowAboveItem.js +4 -4
  151. package/dist/esm/ui/TableMenu/row/items/AddRowBelowItem.js +4 -4
  152. package/dist/esm/ui/TableMenu/row/items/DeleteRowItem.js +2 -3
  153. package/dist/esm/ui/TableMenu/row/items/HeaderRowToggleItem.js +2 -3
  154. package/dist/esm/ui/TableMenu/row/items/MoveRowDownItem.js +2 -3
  155. package/dist/esm/ui/TableMenu/row/items/MoveRowUpItem.js +2 -3
  156. package/dist/esm/ui/TableMenu/row/items/NumberedRowsToggleItem.js +4 -3
  157. package/dist/esm/ui/TableMenu/shared/TableMenu.compiled.css +0 -2
  158. package/dist/esm/ui/TableMenu/shared/TableMenu.js +8 -9
  159. package/dist/esm/ui/TableMenu/shared/getSharedItems.js +3 -1
  160. package/dist/esm/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
  161. package/dist/esm/ui/TableMenu/shared/items/BackgroundColorItem.js +30 -4
  162. package/dist/esm/ui/TableMenu/shared/items/ClearCellsItem.js +4 -3
  163. package/dist/esm/ui/toolbar.js +2 -1
  164. package/dist/types/entry-points/types.d.ts +1 -1
  165. package/dist/types/pm-plugins/commands/active-table-menu.d.ts +6 -0
  166. package/dist/types/pm-plugins/commands/commands-with-analytics.d.ts +3 -1
  167. package/dist/types/pm-plugins/commands/index.d.ts +1 -0
  168. package/dist/types/pm-plugins/transforms/content-mode.d.ts +1 -0
  169. package/dist/types/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.d.ts +8 -0
  170. package/dist/types/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.d.ts +6 -0
  171. package/dist/types/pm-plugins/utils/tableMode/is-content-mode-supported.d.ts +7 -0
  172. package/dist/types/pm-plugins/utils/tableMode/measure-table-with-auto-layout.d.ts +2 -0
  173. package/dist/types/pm-plugins/utils/tableMode/smart-adjust/constants.d.ts +4 -0
  174. package/dist/types/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.d.ts +8 -0
  175. package/dist/types/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.d.ts +7 -0
  176. package/dist/types/types/index.d.ts +21 -1
  177. package/dist/types/ui/FloatingContextualButton/index.d.ts +2 -0
  178. package/dist/types/ui/FloatingContextualMenu/CellMenuPopup.d.ts +7 -5
  179. package/dist/types/ui/FloatingContextualMenu/index.d.ts +0 -1
  180. package/dist/types/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -1
  181. package/dist/types/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -1
  182. package/dist/types/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -1
  183. package/dist/types/ui/TableMenu/column/getColumnMenuComponents.d.ts +1 -1
  184. package/dist/types/ui/TableMenu/shared/TableMenuContext.d.ts +2 -0
  185. package/dist/types/ui/TableMenu/shared/items/BackgroundColorItem.d.ts +2 -1
  186. package/dist/types-ts4.5/entry-points/types.d.ts +1 -1
  187. package/dist/types-ts4.5/pm-plugins/commands/active-table-menu.d.ts +6 -0
  188. package/dist/types-ts4.5/pm-plugins/commands/commands-with-analytics.d.ts +3 -1
  189. package/dist/types-ts4.5/pm-plugins/commands/index.d.ts +1 -0
  190. package/dist/types-ts4.5/pm-plugins/transforms/content-mode.d.ts +1 -0
  191. package/dist/types-ts4.5/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.d.ts +8 -0
  192. package/dist/types-ts4.5/pm-plugins/utils/tableMode/apply-measured-width-to-selected-table.d.ts +6 -0
  193. package/dist/types-ts4.5/pm-plugins/utils/tableMode/is-content-mode-supported.d.ts +7 -0
  194. package/dist/types-ts4.5/pm-plugins/utils/tableMode/measure-table-with-auto-layout.d.ts +2 -0
  195. package/dist/types-ts4.5/pm-plugins/utils/tableMode/smart-adjust/constants.d.ts +4 -0
  196. package/dist/types-ts4.5/pm-plugins/utils/tableMode/smart-adjust/distribute-column-widths.d.ts +8 -0
  197. package/dist/types-ts4.5/pm-plugins/utils/tableMode/smart-adjust/run-smart-adjust.d.ts +7 -0
  198. package/dist/types-ts4.5/types/index.d.ts +21 -1
  199. package/dist/types-ts4.5/ui/FloatingContextualButton/index.d.ts +2 -0
  200. package/dist/types-ts4.5/ui/FloatingContextualMenu/CellMenuPopup.d.ts +7 -5
  201. package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +0 -1
  202. package/dist/types-ts4.5/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -1
  203. package/dist/types-ts4.5/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -1
  204. package/dist/types-ts4.5/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -1
  205. package/dist/types-ts4.5/ui/TableMenu/column/getColumnMenuComponents.d.ts +1 -1
  206. package/dist/types-ts4.5/ui/TableMenu/shared/TableMenuContext.d.ts +2 -0
  207. package/dist/types-ts4.5/ui/TableMenu/shared/items/BackgroundColorItem.d.ts +2 -1
  208. package/package.json +10 -7
  209. package/dist/cjs/pm-plugins/utils/tableMode.js +0 -162
  210. package/dist/es2019/pm-plugins/utils/tableMode.js +0 -158
  211. package/dist/esm/pm-plugins/utils/tableMode.js +0 -156
  212. package/dist/types/pm-plugins/utils/tableMode.d.ts +0 -26
  213. package/dist/types-ts4.5/pm-plugins/utils/tableMode.d.ts +0 -26
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 22.4.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [`6291bc0777dc2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6291bc0777dc2) -
8
+ Converge updated table menu state behind the table menu experiment
9
+
10
+ Make table cell menu items interactive
11
+
12
+ ## 22.4.15
13
+
14
+ ### Patch Changes
15
+
16
+ - [`122438a5ab2b7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/122438a5ab2b7) -
17
+ Improve fit to content table column width distribution
18
+ - Updated dependencies
19
+
3
20
  ## 22.4.14
4
21
 
5
22
  ### Patch Changes
@@ -41,7 +41,7 @@ var _resizeState = require("../pm-plugins/table-resizing/utils/resize-state");
41
41
  var _scaleTable = require("../pm-plugins/table-resizing/utils/scale-table");
42
42
  var _nodes = require("../pm-plugins/utils/nodes");
43
43
  var _table2 = require("../pm-plugins/utils/table");
44
- var _tableMode = require("../pm-plugins/utils/tableMode");
44
+ var _isContentModeSupported = require("../pm-plugins/utils/tableMode/is-content-mode-supported");
45
45
  var _types = require("../types");
46
46
  var _eventHandlers = require("../ui/event-handlers");
47
47
  var _TableFloatingColumnControls = _interopRequireDefault(require("../ui/TableFloatingColumnControls"));
@@ -785,7 +785,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
785
785
  // Deferred from setDomAttrs — remove only once colgroup is updated and table has left content mode.
786
786
  if ((_this$table7 = this.table) !== null && _this$table7 !== void 0 && _this$table7.hasAttribute('data-initial-width-mode') && !(0, _table.isTableInContentMode)({
787
787
  tableNode: currentTable,
788
- isSupported: (0, _tableMode.isContentModeSupported)({
788
+ isSupported: (0, _isContentModeSupported.isContentModeSupported)({
789
789
  allowColumnResizing: !!allowColumnResizing,
790
790
  allowTableResizing: !!allowTableResizing,
791
791
  isFullPageEditor: !((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor) && !((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isChromelessEditor)
@@ -27,7 +27,7 @@ var _createPluginConfig = require("../pm-plugins/create-plugin-config");
27
27
  var _pluginFactory = require("../pm-plugins/plugin-factory");
28
28
  var _tableWidth = require("../pm-plugins/table-width");
29
29
  var _nodes = require("../pm-plugins/utils/nodes");
30
- var _tableMode = require("../pm-plugins/utils/tableMode");
30
+ var _isContentModeSupported = require("../pm-plugins/utils/tableMode/is-content-mode-supported");
31
31
  var _TableComponentWithSharedState = require("./TableComponentWithSharedState");
32
32
  var _toDOM = require("./toDOM");
33
33
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
@@ -253,7 +253,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
253
253
  // fire exposure here
254
254
  if ((0, _table.isTableInContentMode)({
255
255
  tableNode: node,
256
- isSupported: (0, _tableMode.isContentModeSupported)({
256
+ isSupported: (0, _isContentModeSupported.isContentModeSupported)({
257
257
  allowColumnResizing: !!this.reactComponentProps.allowColumnResizing,
258
258
  allowTableResizing: !!this.reactComponentProps.allowTableResizing,
259
259
  isFullPageEditor: !((_this$reactComponentP6 = this.reactComponentProps.options) !== null && _this$reactComponentP6 !== void 0 && _this$reactComponentP6.isCommentEditor) && !((_this$reactComponentP7 = this.reactComponentProps.options) !== null && _this$reactComponentP7 !== void 0 && _this$reactComponentP7.isChromelessEditor)
@@ -17,7 +17,7 @@ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
17
17
  var _colgroup = require("../pm-plugins/table-resizing/utils/colgroup");
18
18
  var _consts = require("../pm-plugins/table-resizing/utils/consts");
19
19
  var _misc = require("../pm-plugins/table-resizing/utils/misc");
20
- var _tableMode = require("../pm-plugins/utils/tableMode");
20
+ var _isContentModeSupported = require("../pm-plugins/utils/tableMode/is-content-mode-supported");
21
21
  var _tableContainerStyles = require("./table-container-styles");
22
22
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
23
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -28,7 +28,7 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
28
28
  var isFullPageEditor = !config.isChromelessEditor && !config.isCommentEditor;
29
29
  var isInContentMode = (0, _table.isTableInContentMode)({
30
30
  tableNode: node,
31
- isSupported: (0, _tableMode.isContentModeSupported)({
31
+ isSupported: (0, _isContentModeSupported.isContentModeSupported)({
32
32
  allowColumnResizing: config.allowColumnResizing,
33
33
  allowTableResizing: config.tableResizingEnabled,
34
34
  isFullPageEditor: isFullPageEditor
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toggleActiveTableMenu = exports.closeActiveTableMenu = void 0;
7
+ var _pluginFactory = require("../plugin-factory");
8
+ var closeActiveTableMenu = exports.closeActiveTableMenu = function closeActiveTableMenu() {
9
+ return (0, _pluginFactory.createCommand)(function (state) {
10
+ var _getPluginState = (0, _pluginFactory.getPluginState)(state),
11
+ activeTableMenu = _getPluginState.activeTableMenu;
12
+ if (!activeTableMenu || activeTableMenu.type === 'none') {
13
+ return false;
14
+ }
15
+ return {
16
+ type: 'SET_ACTIVE_TABLE_MENU',
17
+ data: {
18
+ activeTableMenu: {
19
+ type: 'none'
20
+ }
21
+ }
22
+ };
23
+ }, function (tr) {
24
+ return tr.setMeta('addToHistory', false);
25
+ });
26
+ };
27
+ var isSameActiveTableMenu = function isSameActiveTableMenu(current, next) {
28
+ if (!current || current.type !== next.type) {
29
+ return false;
30
+ }
31
+ if (current.type === 'row' || current.type === 'column') {
32
+ return next.type === current.type && current.index === next.index;
33
+ }
34
+ return true;
35
+ };
36
+ var toggleActiveTableMenu = exports.toggleActiveTableMenu = function toggleActiveTableMenu(activeTableMenu) {
37
+ return (0, _pluginFactory.createCommand)(function (state) {
38
+ var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
39
+ currentActiveTableMenu = _getPluginState2.activeTableMenu;
40
+ return {
41
+ type: 'SET_ACTIVE_TABLE_MENU',
42
+ data: {
43
+ activeTableMenu: isSameActiveTableMenu(currentActiveTableMenu, activeTableMenu) ? {
44
+ type: 'none'
45
+ } : activeTableMenu
46
+ }
47
+ };
48
+ }, function (tr) {
49
+ return tr.setMeta('addToHistory', false);
50
+ });
51
+ };
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.wrapTableInExpandWithAnalytics = exports.toggleNumberColumnWithAnalytics = exports.toggleHeaderRowWithAnalytics = exports.toggleHeaderColumnWithAnalytics = exports.toggleFixedColumnWidthsOptionAnalytics = exports.splitCellWithAnalytics = exports.sortColumnWithAnalytics = exports.setTableAlignmentWithTableContentWithPosWithAnalytics = exports.setTableAlignmentWithAnalytics = exports.setColorWithAnalytics = exports.mergeCellsWithAnalytics = exports.insertRowWithAnalytics = exports.insertColumnWithAnalytics = exports.emptyMultipleCellsWithAnalytics = exports.distributeColumnsWidthsWithAnalytics = exports.deleteTableWithAnalytics = exports.deleteTableIfSelectedWithAnalytics = exports.deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = exports.deleteRowsWithAnalytics = exports.deleteColumnsWithAnalytics = exports.changeColumnWidthByStepWithAnalytics = exports.addRowAroundSelection = void 0;
7
+ exports.wrapTableInExpandWithAnalytics = exports.toggleNumberColumnWithAnalytics = exports.toggleHeaderRowWithAnalytics = exports.toggleHeaderColumnWithAnalytics = exports.toggleFixedColumnWidthsOptionAnalytics = exports.toggleActiveTableMenuWithAnalytics = exports.splitCellWithAnalytics = exports.sortColumnWithAnalytics = exports.setTableAlignmentWithTableContentWithPosWithAnalytics = exports.setTableAlignmentWithAnalytics = exports.setColorWithAnalytics = exports.mergeCellsWithAnalytics = exports.insertRowWithAnalytics = exports.insertColumnWithAnalytics = exports.emptyMultipleCellsWithAnalytics = exports.distributeColumnsWidthsWithAnalytics = exports.deleteTableWithAnalytics = exports.deleteTableIfSelectedWithAnalytics = exports.deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = exports.deleteRowsWithAnalytics = exports.deleteColumnsWithAnalytics = exports.changeColumnWidthByStepWithAnalytics = exports.addRowAroundSelection = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
10
  var _analytics = require("@atlaskit/editor-common/analytics");
@@ -18,6 +18,7 @@ var _deleteRows = require("../transforms/delete-rows");
18
18
  var _merge = require("../transforms/merge");
19
19
  var _analytics2 = require("../utils/analytics");
20
20
  var _nodes = require("../utils/nodes");
21
+ var _activeTableMenu = require("./active-table-menu");
21
22
  var _clear = require("./clear");
22
23
  var _collapse = require("./collapse");
23
24
  var _columnResize = require("./column-resize");
@@ -30,7 +31,38 @@ var _splitCell = require("./split-cell");
30
31
  var _toggle = require("./toggle");
31
32
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
32
33
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
33
- // #region Analytics wrappers
34
+ var toggleActiveTableMenuWithAnalytics = exports.toggleActiveTableMenuWithAnalytics = function toggleActiveTableMenuWithAnalytics(editorAnalyticsAPI) {
35
+ return function (direction, index) {
36
+ var trigger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'mouse';
37
+ return (0, _analytics2.withEditorAnalyticsAPI)(function (state) {
38
+ var _getPluginState = (0, _pluginFactory.getPluginState)(state),
39
+ previousActiveTableMenu = _getPluginState.activeTableMenu;
40
+ var isSameActiveMenu = (previousActiveTableMenu === null || previousActiveTableMenu === void 0 ? void 0 : previousActiveTableMenu.type) === direction && previousActiveTableMenu.index === index;
41
+ if (isSameActiveMenu) {
42
+ return undefined;
43
+ }
44
+ return {
45
+ action: _analytics.TABLE_ACTION.DRAG_MENU_OPENED,
46
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
47
+ actionSubjectId: null,
48
+ eventType: _analytics.EVENT_TYPE.TRACK,
49
+ attributes: {
50
+ inputMethod: trigger === 'keyboard' ? _analytics.INPUT_METHOD.KEYBOARD : _analytics.INPUT_METHOD.MOUSE,
51
+ direction: direction
52
+ }
53
+ };
54
+ })(editorAnalyticsAPI)(function (state, dispatch) {
55
+ if (dispatch) {
56
+ (0, _activeTableMenu.toggleActiveTableMenu)({
57
+ type: direction,
58
+ index: index,
59
+ openedBy: trigger
60
+ })(state, dispatch);
61
+ }
62
+ return true;
63
+ });
64
+ };
65
+ };
34
66
  var emptyMultipleCellsWithAnalytics = exports.emptyMultipleCellsWithAnalytics = function emptyMultipleCellsWithAnalytics(editorAnalyticsAPI) {
35
67
  return function (inputMethod, targetCellPosition) {
36
68
  return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref) {
@@ -195,8 +227,8 @@ var changeColumnWidthByStepWithAnalytics = exports.changeColumnWidthByStepWithAn
195
227
  table = _getSelectedTableInfo2.table,
196
228
  totalRowCount = _getSelectedTableInfo2.totalRowCount,
197
229
  totalColumnCount = _getSelectedTableInfo2.totalColumnCount;
198
- var _getPluginState = (0, _pluginFactory.getPluginState)(state),
199
- colIndex = _getPluginState.hoveredCell.colIndex;
230
+ var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
231
+ colIndex = _getPluginState2.hoveredCell.colIndex;
200
232
  return {
201
233
  action: _analytics.TABLE_ACTION.COLUMN_RESIZED,
202
234
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
@@ -316,8 +348,8 @@ var deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = exports.deleteSelected
316
348
  }
317
349
  var selectionType = (0, _misc.getTableSelectionType)(selection);
318
350
  if (selectionType === 'row') {
319
- var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
320
- pluginConfig = _getPluginState2.pluginConfig;
351
+ var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
352
+ pluginConfig = _getPluginState3.pluginConfig;
321
353
  var isHeaderRowRequired = pluginConfig.isHeaderRowRequired || false;
322
354
  return deleteRowsWithAnalytics(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT, rect, isHeaderRowRequired)(state, dispatch);
323
355
  } else if (selectionType === 'column') {
@@ -361,8 +393,8 @@ var toggleHeaderRowWithAnalytics = exports.toggleHeaderRowWithAnalytics = functi
361
393
  var _getSelectedTableInfo7 = (0, _analytics2.getSelectedTableInfo)(state.selection),
362
394
  totalRowCount = _getSelectedTableInfo7.totalRowCount,
363
395
  totalColumnCount = _getSelectedTableInfo7.totalColumnCount;
364
- var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
365
- isHeaderRowEnabled = _getPluginState3.isHeaderRowEnabled;
396
+ var _getPluginState4 = (0, _pluginFactory.getPluginState)(state),
397
+ isHeaderRowEnabled = _getPluginState4.isHeaderRowEnabled;
366
398
  return {
367
399
  action: _analytics.TABLE_ACTION.TOGGLED_HEADER_ROW,
368
400
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
@@ -381,8 +413,8 @@ var toggleHeaderColumnWithAnalytics = exports.toggleHeaderColumnWithAnalytics =
381
413
  var _getSelectedTableInfo8 = (0, _analytics2.getSelectedTableInfo)(state.selection),
382
414
  totalRowCount = _getSelectedTableInfo8.totalRowCount,
383
415
  totalColumnCount = _getSelectedTableInfo8.totalColumnCount;
384
- var _getPluginState4 = (0, _pluginFactory.getPluginState)(state),
385
- isHeaderColumnEnabled = _getPluginState4.isHeaderColumnEnabled;
416
+ var _getPluginState5 = (0, _pluginFactory.getPluginState)(state),
417
+ isHeaderColumnEnabled = _getPluginState5.isHeaderColumnEnabled;
386
418
  return {
387
419
  action: _analytics.TABLE_ACTION.TOGGLED_HEADER_COLUMN,
388
420
  actionSubject: _analytics.ACTION_SUBJECT.TABLE,
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "clearMultipleCells", {
33
33
  return _clear.clearMultipleCells;
34
34
  }
35
35
  });
36
+ Object.defineProperty(exports, "closeActiveTableMenu", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _activeTableMenu.closeActiveTableMenu;
40
+ }
41
+ });
36
42
  Object.defineProperty(exports, "convertFirstRowToHeader", {
37
43
  enumerable: true,
38
44
  get: function get() {
@@ -219,6 +225,12 @@ Object.defineProperty(exports, "sortByColumn", {
219
225
  return _sort.sortByColumn;
220
226
  }
221
227
  });
228
+ Object.defineProperty(exports, "toggleActiveTableMenu", {
229
+ enumerable: true,
230
+ get: function get() {
231
+ return _activeTableMenu.toggleActiveTableMenu;
232
+ }
233
+ });
222
234
  Object.defineProperty(exports, "toggleContextualMenu", {
223
235
  enumerable: true,
224
236
  get: function get() {
@@ -270,6 +282,7 @@ Object.defineProperty(exports, "updateWidthToWidest", {
270
282
  var _hover = require("./hover");
271
283
  var _insert = require("./insert");
272
284
  var _toggle = require("./toggle");
285
+ var _activeTableMenu = require("./active-table-menu");
273
286
  var _clear = require("./clear");
274
287
  var _misc = require("./misc");
275
288
  var _sort = require("./sort");
@@ -153,6 +153,8 @@ var cloneSourceWithAnalytics = exports.cloneSourceWithAnalytics = function clone
153
153
  });
154
154
  };
155
155
  };
156
+
157
+ // remove when 'platform_editor_table_menu_updates' is cleaned up
156
158
  var toggleDragMenuWithAnalytics = exports.toggleDragMenuWithAnalytics = function toggleDragMenuWithAnalytics(editorAnalyticsAPI) {
157
159
  return function (isDragMenuOpen, direction, index) {
158
160
  var trigger = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'mouse';
@@ -14,6 +14,7 @@ var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
14
14
  var _combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
15
15
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
16
16
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
17
+ var _activeTableMenu = require("../commands/active-table-menu");
17
18
  var _pluginFactory = require("../plugin-factory");
18
19
  var _pluginKey = require("../plugin-key");
19
20
  var _colgroup = require("../table-resizing/utils/colgroup");
@@ -93,6 +94,9 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI, isTableScalin
93
94
  (_insm$session3 = _insm.insm.session) === null || _insm$session3 === void 0 || _insm$session3.startFeature('tableDragAndDrop');
94
95
  }
95
96
  (0, _commands.toggleDragMenu)(false)(editorView.state, editorView.dispatch);
97
+ if ((0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true)) {
98
+ (0, _activeTableMenu.closeActiveTableMenu)()(editorView.state, editorView.dispatch);
99
+ }
96
100
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('dragging'));
97
101
  },
98
102
  onDrag: function onDrag(event) {
@@ -10,6 +10,7 @@ var _customSteps = require("@atlaskit/custom-steps");
10
10
  var _utils = require("@atlaskit/editor-common/utils");
11
11
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
12
12
  var _utils3 = require("@atlaskit/editor-tables/utils");
13
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
14
  var _defaultTableSelection = require("./default-table-selection");
14
15
  var _pluginKey = require("./table-resizing/plugin-key");
15
16
  var _collapse = require("./utils/collapse");
@@ -47,8 +48,14 @@ var updateTargetCellPosition = function updateTargetCellPosition(_ref) {
47
48
  if (pluginState.targetCellPosition === targetCellPosition) {
48
49
  return pluginState;
49
50
  }
51
+
52
+ // The updated table menu is anchored to the current target cell. When selection moves
53
+ // to another cell, close the active menu so render state cannot point at a stale anchor.
50
54
  return _objectSpread(_objectSpread({}, pluginState), {}, {
51
- targetCellPosition: targetCellPosition
55
+ targetCellPosition: targetCellPosition,
56
+ activeTableMenu: pluginState.activeTableMenu != null && pluginState.activeTableMenu.type !== 'none' && (0, _expValEquals.expValEquals)('platform_editor_table_menu_updates', 'isEnabled', true) ? {
57
+ type: 'none'
58
+ } : pluginState.activeTableMenu
52
59
  });
53
60
  };
54
61
  };
@@ -33,7 +33,8 @@ var _fixTables = require("./transforms/fix-tables");
33
33
  var _replaceTable = require("./transforms/replace-table");
34
34
  var _decoration = require("./utils/decoration");
35
35
  var _paste = require("./utils/paste");
36
- var _tableMode = require("./utils/tableMode");
36
+ var _applyMeasuredWidthToAllTables = require("./utils/tableMode/apply-measured-width-to-all-tables");
37
+ var _isContentModeSupported = require("./utils/tableMode/is-content-mode-supported");
37
38
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
38
39
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
39
40
  var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, nodeViewPortalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, fullWidthModeEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, allowFixedColumnWidthOption) {
@@ -140,7 +141,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
140
141
  editorViewRef = editorView;
141
142
  var contentModeSizeTableId = null;
142
143
  var focusListenerBinding = null;
143
- if ((pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 || (_pluginInjectionApi$e = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.mode) !== 'view' && (0, _tableMode.isContentModeSupported)({
144
+ if ((pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 || (_pluginInjectionApi$e = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.mode) !== 'view' && (0, _isContentModeSupported.isContentModeSupported)({
144
145
  allowColumnResizing: !!pluginConfig.allowColumnResizing,
145
146
  allowTableResizing: !!pluginConfig.allowTableResizing,
146
147
  isFullPageEditor: !isChromelessEditor && !isCommentEditor
@@ -155,7 +156,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
155
156
  if (!editorViewRef) {
156
157
  return;
157
158
  }
158
- (0, _tableMode.applyMeasuredWidthToAllTables)(editorViewRef, pluginInjectionApi);
159
+ (0, _applyMeasuredWidthToAllTables.applyMeasuredWidthToAllTables)(editorViewRef, pluginInjectionApi);
159
160
  });
160
161
  },
161
162
  options: {
@@ -33,6 +33,8 @@ var _default = exports.default = function _default(pluginState, action) {
33
33
  return _objectSpread(_objectSpread({}, pluginState), {}, {
34
34
  isContextualMenuOpen: !pluginState.isContextualMenuOpen
35
35
  });
36
+ case 'SET_ACTIVE_TABLE_MENU':
37
+ return _objectSpread(_objectSpread({}, pluginState), action.data);
36
38
  case 'SHOW_INSERT_ROW_BUTTON':
37
39
  if (action.data.insertRowButtonIndex === pluginState.insertRowButtonIndex) {
38
40
  return pluginState;
@@ -16,7 +16,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
16
16
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
17
17
  var _consts = require("./table-resizing/utils/consts");
18
18
  var _alignment = require("./utils/alignment");
19
- var _tableMode = require("./utils/tableMode");
19
+ var _isContentModeSupported = require("./utils/tableMode/is-content-mode-supported");
20
20
  var _excluded = ["width"];
21
21
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
22
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
@@ -72,7 +72,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
72
72
  newState.doc.forEach(function (node, offset) {
73
73
  if ((0, _table.isTableInContentMode)({
74
74
  tableNode: node,
75
- isSupported: (0, _tableMode.isContentModeSupported)({
75
+ isSupported: (0, _isContentModeSupported.isContentModeSupported)({
76
76
  allowColumnResizing: true,
77
77
  allowTableResizing: true,
78
78
  isFullPageEditor: true
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.getTableMeasurement = exports.applyTableMeasurement = void 0;
7
+ exports.getTableMeasurement = exports.clampToEditorMaxWidth = exports.applyTableMeasurement = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _styles = require("@atlaskit/editor-common/styles");
10
10
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
@@ -12,10 +12,11 @@ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
12
12
  var _tableTransformUtils = require("./table-transform-utils");
13
13
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
14
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
- var tableWidth = function tableWidth(contentWidth) {
15
+ var clampToEditorMaxWidth = exports.clampToEditorMaxWidth = function clampToEditorMaxWidth(contentWidth) {
16
16
  var maxEditorWidth = (0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true) ? _editorSharedStyles.akEditorMaxLayoutWidth : _editorSharedStyles.akEditorFullWidthLayoutWidth;
17
17
  return Math.min(maxEditorWidth, contentWidth);
18
18
  };
19
+ var tableWidth = clampToEditorMaxWidth;
19
20
  var getTableMeasurement = exports.getTableMeasurement = function getTableMeasurement(tableRef) {
20
21
  var colWidths = getRenderedColgroupColumnWidths(tableRef);
21
22
  var totalContentWidth = colWidths.reduce(function (acc, current) {
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.applyMeasuredWidthToAllTables = void 0;
7
+ var _analytics = require("@atlaskit/editor-common/analytics");
8
+ var _styles = require("@atlaskit/editor-common/styles");
9
+ var _table = require("@atlaskit/editor-common/table");
10
+ var _contentMode = require("../../transforms/content-mode");
11
+ /**
12
+ * Iterates all top-level tables in the document, and for those in content mode,
13
+ * measures rendered column widths and sets colwidth + table width attributes
14
+ * in a single batched transaction.
15
+ */
16
+ var applyMeasuredWidthToAllTables = exports.applyMeasuredWidthToAllTables = function applyMeasuredWidthToAllTables(view, pluginInjectionApi) {
17
+ var _view$state = view.state,
18
+ doc = _view$state.doc,
19
+ schema = _view$state.schema;
20
+ var tr = view.state.tr;
21
+ var table = schema.nodes.table;
22
+ var modified = false;
23
+ var measuredTables = [];
24
+
25
+ // modify only top-level tables
26
+ doc.forEach(function (node, offset) {
27
+ if (node.type !== table || (0, _table.hasTableBeenResized)(node) && node.attrs.layout !== 'align-start') {
28
+ return;
29
+ }
30
+ var domNode = view.domAtPos(offset + 1).node;
31
+ var tableWrapper = domNode instanceof HTMLElement ? domNode.closest(".".concat(_styles.TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP)) : null;
32
+ var tableRef = tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.querySelector('table');
33
+ if (!tableRef) {
34
+ return;
35
+ }
36
+ measuredTables.push({
37
+ node: node,
38
+ offset: offset,
39
+ measurement: (0, _contentMode.getTableMeasurement)(tableRef)
40
+ });
41
+ });
42
+ measuredTables.forEach(function (_ref) {
43
+ var node = _ref.node,
44
+ offset = _ref.offset,
45
+ measurement = _ref.measurement;
46
+ tr = (0, _contentMode.applyTableMeasurement)(tr, node, measurement, offset);
47
+ modified = true;
48
+ });
49
+ if (modified) {
50
+ var _pluginInjectionApi$a, _pluginInjectionApi$w, _pluginInjectionApi$w2;
51
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 || (_pluginInjectionApi$a = _pluginInjectionApi$a.actions) === null || _pluginInjectionApi$a === void 0 || _pluginInjectionApi$a.attachAnalyticsEvent({
52
+ action: _analytics.TABLE_ACTION.FIT_TO_CONTENT_AUTO_CONVERTED,
53
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
54
+ actionSubjectId: null,
55
+ eventType: _analytics.EVENT_TYPE.TRACK,
56
+ attributes: {
57
+ editorContainerWidth: (_pluginInjectionApi$w = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w2 = pluginInjectionApi.width) === null || _pluginInjectionApi$w2 === void 0 || (_pluginInjectionApi$w2 = _pluginInjectionApi$w2.sharedState.currentState()) === null || _pluginInjectionApi$w2 === void 0 ? void 0 : _pluginInjectionApi$w2.width) !== null && _pluginInjectionApi$w !== void 0 ? _pluginInjectionApi$w : 0,
58
+ totalTablesResized: measuredTables.length,
59
+ measurements: measuredTables.map(function (_ref2) {
60
+ var measurement = _ref2.measurement;
61
+ return {
62
+ tableWidth: measurement.tableWidth,
63
+ totalColumnCount: measurement.colWidths.length
64
+ };
65
+ })
66
+ }
67
+ })(tr);
68
+ view.dispatch(tr.setMeta('addToHistory', false));
69
+ }
70
+ };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.applyMeasuredWidthToSelectedTable = void 0;
7
+ var _analytics = require("@atlaskit/editor-common/analytics");
8
+ var _utils = require("@atlaskit/editor-tables/utils");
9
+ var _contentMode = require("../../transforms/content-mode");
10
+ var _measureTableWithAutoLayout = require("./measure-table-with-auto-layout");
11
+ /**
12
+ * Used to measure a selected table width with it's content being laid out natively by the browser
13
+ */
14
+ var applyMeasuredWidthToSelectedTable = exports.applyMeasuredWidthToSelectedTable = function applyMeasuredWidthToSelectedTable(view, api) {
15
+ var _api$width, _api$analytics, _api$width$sharedStat, _api$width2;
16
+ var tableObject = (0, _utils.findTable)(view.state.selection);
17
+ if (!tableObject) {
18
+ return;
19
+ }
20
+ var node = tableObject.node,
21
+ pos = tableObject.pos;
22
+ var tableState = api === null || api === void 0 ? void 0 : api.table.sharedState.currentState();
23
+ if (!(tableState !== null && tableState !== void 0 && tableState.tableRef)) {
24
+ return;
25
+ }
26
+ var editorContainerWidth = api === null || api === void 0 || (_api$width = api.width) === null || _api$width === void 0 || (_api$width = _api$width.sharedState.currentState()) === null || _api$width === void 0 ? void 0 : _api$width.width;
27
+ var measurement = (0, _measureTableWithAutoLayout.measureTableWithAutoLayout)(tableState.tableRef, editorContainerWidth);
28
+ var tr = (0, _contentMode.applyTableMeasurement)(view.state.tr, node, measurement, pos);
29
+ api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent({
30
+ action: _analytics.TABLE_ACTION.FIT_TO_CONTENT_ON_DEMAND,
31
+ actionSubject: _analytics.ACTION_SUBJECT.TABLE,
32
+ actionSubjectId: null,
33
+ eventType: _analytics.EVENT_TYPE.TRACK,
34
+ attributes: {
35
+ editorContainerWidth: (_api$width$sharedStat = api === null || api === void 0 || (_api$width2 = api.width) === null || _api$width2 === void 0 || (_api$width2 = _api$width2.sharedState.currentState()) === null || _api$width2 === void 0 ? void 0 : _api$width2.width) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : 0,
36
+ tableWidth: measurement.tableWidth,
37
+ totalColumnCount: measurement.colWidths.length
38
+ }
39
+ })(tr);
40
+ view.dispatch(tr);
41
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isContentModeSupported = void 0;
7
+ var isContentModeSupported = exports.isContentModeSupported = function isContentModeSupported(_ref) {
8
+ var allowColumnResizing = _ref.allowColumnResizing,
9
+ allowTableResizing = _ref.allowTableResizing,
10
+ isFullPageEditor = _ref.isFullPageEditor;
11
+ return allowColumnResizing && allowTableResizing && isFullPageEditor;
12
+ };