@atlaskit/editor-plugin-table 7.5.4 → 7.5.6

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 (236) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/commands/column-resize.js +3 -3
  3. package/dist/cjs/commands/delete.js +2 -2
  4. package/dist/cjs/commands/insert.js +15 -15
  5. package/dist/cjs/commands-with-analytics.js +7 -7
  6. package/dist/cjs/event-handlers.js +27 -11
  7. package/dist/cjs/nodeviews/OverflowShadowsObserver.js +24 -15
  8. package/dist/cjs/nodeviews/TableCell.js +5 -30
  9. package/dist/cjs/nodeviews/TableComponent.js +120 -83
  10. package/dist/cjs/nodeviews/TableContainer.js +23 -21
  11. package/dist/cjs/nodeviews/TableResizer.js +13 -13
  12. package/dist/cjs/nodeviews/table.js +9 -9
  13. package/dist/cjs/plugin.js +60 -59
  14. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +13 -13
  15. package/dist/cjs/pm-plugins/keymap.js +6 -8
  16. package/dist/cjs/pm-plugins/main.js +7 -24
  17. package/dist/cjs/pm-plugins/sticky-headers/plugin.js +2 -3
  18. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -12
  19. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +2 -2
  20. package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
  21. package/dist/cjs/pm-plugins/table-resizing/utils/index.js +2 -2
  22. package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +3 -3
  23. package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +3 -3
  24. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +11 -12
  25. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +13 -13
  26. package/dist/cjs/pm-plugins/table-width.js +6 -2
  27. package/dist/cjs/toolbar.js +21 -21
  28. package/dist/cjs/transforms/column-width.js +4 -4
  29. package/dist/cjs/transforms/delete-columns.js +2 -2
  30. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
  31. package/dist/cjs/ui/FloatingContextualMenu/index.js +2 -4
  32. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -2
  33. package/dist/cjs/ui/FloatingDragMenu/index.js +6 -6
  34. package/dist/cjs/ui/FloatingInsertButton/index.js +6 -7
  35. package/dist/cjs/ui/TableFloatingColumnControls/index.js +8 -48
  36. package/dist/cjs/ui/TableFloatingControls/index.js +113 -223
  37. package/dist/cjs/utils/column-controls.js +5 -5
  38. package/dist/cjs/utils/create.js +2 -5
  39. package/dist/cjs/utils/dom.js +13 -15
  40. package/dist/cjs/utils/drag-menu.js +4 -4
  41. package/dist/es2019/commands/column-resize.js +3 -3
  42. package/dist/es2019/commands/delete.js +2 -2
  43. package/dist/es2019/commands/insert.js +12 -12
  44. package/dist/es2019/commands-with-analytics.js +6 -6
  45. package/dist/es2019/event-handlers.js +27 -11
  46. package/dist/es2019/nodeviews/OverflowShadowsObserver.js +24 -15
  47. package/dist/es2019/nodeviews/TableCell.js +1 -24
  48. package/dist/es2019/nodeviews/TableComponent.js +88 -63
  49. package/dist/es2019/nodeviews/TableContainer.js +20 -22
  50. package/dist/es2019/nodeviews/TableResizer.js +13 -13
  51. package/dist/es2019/nodeviews/table.js +9 -9
  52. package/dist/es2019/plugin.js +19 -20
  53. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +6 -6
  54. package/dist/es2019/pm-plugins/keymap.js +5 -8
  55. package/dist/es2019/pm-plugins/main.js +6 -23
  56. package/dist/es2019/pm-plugins/sticky-headers/plugin.js +1 -1
  57. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +5 -5
  58. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -2
  59. package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
  60. package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
  61. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
  62. package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +3 -2
  63. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +12 -13
  64. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +13 -13
  65. package/dist/es2019/pm-plugins/table-width.js +6 -2
  66. package/dist/es2019/toolbar.js +15 -15
  67. package/dist/es2019/transforms/column-width.js +5 -5
  68. package/dist/es2019/transforms/delete-columns.js +2 -2
  69. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +9 -12
  70. package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -4
  71. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +2 -2
  72. package/dist/es2019/ui/FloatingDragMenu/index.js +5 -5
  73. package/dist/es2019/ui/FloatingInsertButton/index.js +5 -6
  74. package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -27
  75. package/dist/es2019/ui/TableFloatingControls/index.js +119 -193
  76. package/dist/es2019/utils/column-controls.js +6 -6
  77. package/dist/es2019/utils/create.js +2 -5
  78. package/dist/es2019/utils/dom.js +13 -15
  79. package/dist/es2019/utils/drag-menu.js +4 -4
  80. package/dist/esm/commands/column-resize.js +3 -3
  81. package/dist/esm/commands/delete.js +2 -2
  82. package/dist/esm/commands/insert.js +15 -15
  83. package/dist/esm/commands-with-analytics.js +7 -7
  84. package/dist/esm/event-handlers.js +27 -11
  85. package/dist/esm/nodeviews/OverflowShadowsObserver.js +24 -15
  86. package/dist/esm/nodeviews/TableCell.js +5 -30
  87. package/dist/esm/nodeviews/TableComponent.js +119 -82
  88. package/dist/esm/nodeviews/TableContainer.js +24 -22
  89. package/dist/esm/nodeviews/TableResizer.js +13 -13
  90. package/dist/esm/nodeviews/table.js +9 -9
  91. package/dist/esm/plugin.js +60 -59
  92. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +13 -13
  93. package/dist/esm/pm-plugins/keymap.js +6 -8
  94. package/dist/esm/pm-plugins/main.js +7 -24
  95. package/dist/esm/pm-plugins/sticky-headers/plugin.js +2 -3
  96. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +12 -12
  97. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +2 -2
  98. package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
  99. package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
  100. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +2 -2
  101. package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +4 -3
  102. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +13 -14
  103. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +13 -13
  104. package/dist/esm/pm-plugins/table-width.js +6 -2
  105. package/dist/esm/toolbar.js +21 -21
  106. package/dist/esm/transforms/column-width.js +5 -5
  107. package/dist/esm/transforms/delete-columns.js +2 -2
  108. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
  109. package/dist/esm/ui/FloatingContextualMenu/index.js +2 -4
  110. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +2 -2
  111. package/dist/esm/ui/FloatingDragMenu/index.js +6 -6
  112. package/dist/esm/ui/FloatingInsertButton/index.js +6 -7
  113. package/dist/esm/ui/TableFloatingColumnControls/index.js +8 -48
  114. package/dist/esm/ui/TableFloatingControls/index.js +113 -224
  115. package/dist/esm/utils/column-controls.js +6 -6
  116. package/dist/esm/utils/create.js +2 -5
  117. package/dist/esm/utils/dom.js +13 -15
  118. package/dist/esm/utils/drag-menu.js +4 -4
  119. package/dist/types/commands/column-resize.d.ts +1 -1
  120. package/dist/types/commands/delete.d.ts +1 -1
  121. package/dist/types/commands/insert.d.ts +7 -7
  122. package/dist/types/commands-with-analytics.d.ts +3 -3
  123. package/dist/types/event-handlers.d.ts +4 -5
  124. package/dist/types/nodeviews/OverflowShadowsObserver.d.ts +3 -1
  125. package/dist/types/nodeviews/TableCell.d.ts +1 -5
  126. package/dist/types/nodeviews/TableComponent.d.ts +6 -3
  127. package/dist/types/nodeviews/TableContainer.d.ts +6 -4
  128. package/dist/types/nodeviews/TableResizer.d.ts +2 -2
  129. package/dist/types/nodeviews/table.d.ts +1 -1
  130. package/dist/types/nodeviews/types.d.ts +1 -0
  131. package/dist/types/plugin.d.ts +1 -0
  132. package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
  133. package/dist/types/pm-plugins/keymap.d.ts +2 -2
  134. package/dist/types/pm-plugins/main.d.ts +1 -1
  135. package/dist/types/pm-plugins/sticky-headers/plugin.d.ts +2 -3
  136. package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
  137. package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
  138. package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
  139. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
  140. package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
  141. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
  142. package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
  143. package/dist/types/pm-plugins/table-width.d.ts +1 -2
  144. package/dist/types/toolbar.d.ts +2 -2
  145. package/dist/types/transforms/column-width.d.ts +1 -1
  146. package/dist/types/transforms/delete-columns.d.ts +1 -1
  147. package/dist/types/types.d.ts +1 -3
  148. package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
  149. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
  150. package/dist/types/ui/FloatingDragMenu/index.d.ts +2 -3
  151. package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -2
  152. package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -1
  153. package/dist/types/ui/TableFloatingControls/index.d.ts +5 -22
  154. package/dist/types/utils/create.d.ts +1 -2
  155. package/dist/types/utils/dom.d.ts +10 -2
  156. package/dist/types/utils/drag-menu.d.ts +1 -1
  157. package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
  158. package/dist/types-ts4.5/commands/delete.d.ts +1 -1
  159. package/dist/types-ts4.5/commands/insert.d.ts +7 -7
  160. package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -3
  161. package/dist/types-ts4.5/event-handlers.d.ts +4 -5
  162. package/dist/types-ts4.5/nodeviews/OverflowShadowsObserver.d.ts +3 -1
  163. package/dist/types-ts4.5/nodeviews/TableCell.d.ts +1 -5
  164. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +6 -3
  165. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +6 -4
  166. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -2
  167. package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
  168. package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
  169. package/dist/types-ts4.5/plugin.d.ts +1 -0
  170. package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
  171. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
  172. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  173. package/dist/types-ts4.5/pm-plugins/sticky-headers/plugin.d.ts +2 -3
  174. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
  175. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
  176. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
  177. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
  178. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
  179. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
  180. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
  181. package/dist/types-ts4.5/pm-plugins/table-width.d.ts +1 -2
  182. package/dist/types-ts4.5/toolbar.d.ts +2 -2
  183. package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
  184. package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
  185. package/dist/types-ts4.5/types.d.ts +1 -3
  186. package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
  187. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
  188. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +2 -3
  189. package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -2
  190. package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -1
  191. package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +5 -22
  192. package/dist/types-ts4.5/utils/create.d.ts +1 -2
  193. package/dist/types-ts4.5/utils/dom.d.ts +10 -2
  194. package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
  195. package/package.json +3 -4
  196. package/src/commands/column-resize.ts +4 -3
  197. package/src/commands/delete.ts +2 -2
  198. package/src/commands/insert.ts +15 -27
  199. package/src/commands-with-analytics.ts +6 -9
  200. package/src/event-handlers.ts +107 -105
  201. package/src/nodeviews/OverflowShadowsObserver.ts +32 -21
  202. package/src/nodeviews/TableCell.ts +0 -26
  203. package/src/nodeviews/TableComponent.tsx +107 -78
  204. package/src/nodeviews/TableContainer.tsx +26 -32
  205. package/src/nodeviews/TableResizer.tsx +15 -18
  206. package/src/nodeviews/table.tsx +6 -5
  207. package/src/nodeviews/types.ts +1 -0
  208. package/src/plugin.tsx +17 -32
  209. package/src/pm-plugins/drag-and-drop/plugin.ts +10 -15
  210. package/src/pm-plugins/keymap.ts +6 -13
  211. package/src/pm-plugins/main.ts +6 -25
  212. package/src/pm-plugins/sticky-headers/plugin.ts +2 -11
  213. package/src/pm-plugins/table-resizing/event-handlers.ts +6 -4
  214. package/src/pm-plugins/table-resizing/utils/colgroup.ts +2 -2
  215. package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
  216. package/src/pm-plugins/table-resizing/utils/index.ts +1 -1
  217. package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
  218. package/src/pm-plugins/table-resizing/utils/resize-column.ts +5 -2
  219. package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -13
  220. package/src/pm-plugins/table-resizing/utils/scale-table.ts +14 -14
  221. package/src/pm-plugins/table-width.ts +4 -6
  222. package/src/toolbar.tsx +16 -19
  223. package/src/transforms/column-width.ts +7 -6
  224. package/src/transforms/delete-columns.ts +2 -2
  225. package/src/types.ts +1 -4
  226. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +11 -16
  227. package/src/ui/FloatingContextualMenu/index.tsx +0 -2
  228. package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -3
  229. package/src/ui/FloatingDragMenu/index.tsx +4 -8
  230. package/src/ui/FloatingInsertButton/index.tsx +11 -22
  231. package/src/ui/TableFloatingColumnControls/index.tsx +5 -29
  232. package/src/ui/TableFloatingControls/index.tsx +155 -241
  233. package/src/utils/column-controls.ts +5 -6
  234. package/src/utils/create.ts +2 -5
  235. package/src/utils/dom.ts +12 -19
  236. package/src/utils/drag-menu.ts +7 -12
@@ -9,6 +9,7 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _ui = require("@atlaskit/editor-common/ui");
10
10
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
11
11
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
12
+ var _pluginFactory = require("../../pm-plugins/plugin-factory");
12
13
  var _consts = require("../consts");
13
14
  var _DragMenu = _interopRequireDefault(require("./DragMenu"));
14
15
  var FloatingDragMenu = function FloatingDragMenu(_ref) {
@@ -24,8 +25,7 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
24
25
  getEditorContainerWidth = _ref.getEditorContainerWidth,
25
26
  editorAnalyticsAPI = _ref.editorAnalyticsAPI,
26
27
  stickyHeaders = _ref.stickyHeaders,
27
- pluginConfig = _ref.pluginConfig,
28
- getEditorFeatureFlags = _ref.getEditorFeatureFlags;
28
+ pluginConfig = _ref.pluginConfig;
29
29
  if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
30
30
  return null;
31
31
  }
@@ -35,9 +35,9 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
35
35
  if (!targetHandleRef || !(editorView.state.selection instanceof _cellSelection.CellSelection)) {
36
36
  return null;
37
37
  }
38
- var _getEditorFeatureFlag = getEditorFeatureFlags(),
39
- _getEditorFeatureFlag2 = _getEditorFeatureFlag.tablePreserveWidth,
40
- tablePreserveWidth = _getEditorFeatureFlag2 === void 0 ? false : _getEditorFeatureFlag2;
38
+ var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
39
+ _getPluginState$isTab = _getPluginState.isTableScalingEnabled,
40
+ isTableScalingEnabled = _getPluginState$isTab === void 0 ? false : _getPluginState$isTab;
41
41
  return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
42
42
  alignX: direction === 'row' ? 'right' : undefined,
43
43
  alignY: direction === 'row' ? 'start' : undefined,
@@ -71,7 +71,7 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
71
71
  mountPoint: mountPoint,
72
72
  boundariesElement: boundariesElement,
73
73
  scrollableElement: scrollableElement,
74
- tablePreserveWidth: tablePreserveWidth
74
+ isTableScalingEnabled: isTableScalingEnabled
75
75
  }));
76
76
  };
77
77
  FloatingDragMenu.displayName = 'FloatingDragMenu';
@@ -25,6 +25,7 @@ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
25
25
  var _tableMap = require("@atlaskit/editor-tables/table-map");
26
26
  var _utils3 = require("@atlaskit/editor-tables/utils");
27
27
  var _commandsWithAnalytics = require("../../commands-with-analytics");
28
+ var _pluginFactory = require("../../pm-plugins/plugin-factory");
28
29
  var _types = require("../../types");
29
30
  var _utils4 = require("../../utils");
30
31
  var _getPopupOptions = _interopRequireDefault(require("./getPopupOptions"));
@@ -195,17 +196,15 @@ var FloatingInsertButton = exports.FloatingInsertButton = /*#__PURE__*/function
195
196
  var _this$props4 = this.props,
196
197
  editorView = _this$props4.editorView,
197
198
  insertColumnButtonIndex = _this$props4.insertColumnButtonIndex,
198
- editorAnalyticsAPI = _this$props4.editorAnalyticsAPI,
199
- getEditorContainerWidth = _this$props4.getEditorContainerWidth;
199
+ editorAnalyticsAPI = _this$props4.editorAnalyticsAPI;
200
200
  if (typeof insertColumnButtonIndex !== 'undefined') {
201
- var _this$props$getEditor, _this$props5;
202
201
  event.preventDefault();
203
- var _ref = ((_this$props$getEditor = (_this$props5 = this.props).getEditorFeatureFlags) === null || _this$props$getEditor === void 0 ? void 0 : _this$props$getEditor.call(_this$props5)) || {},
204
- _ref$tablePreserveWid = _ref.tablePreserveWidth,
205
- tablePreserveWidth = _ref$tablePreserveWid === void 0 ? false : _ref$tablePreserveWid;
202
+ var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
203
+ _getPluginState$isTab = _getPluginState.isTableScalingEnabled,
204
+ isTableScalingEnabled = _getPluginState$isTab === void 0 ? false : _getPluginState$isTab;
206
205
  var state = editorView.state,
207
206
  dispatch = editorView.dispatch;
208
- (0, _commandsWithAnalytics.insertColumnWithAnalytics)(getEditorContainerWidth, editorAnalyticsAPI, tablePreserveWidth)(_analytics.INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
207
+ (0, _commandsWithAnalytics.insertColumnWithAnalytics)(editorAnalyticsAPI, isTableScalingEnabled)(_analytics.INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
209
208
  }
210
209
  }
211
210
  }]);
@@ -15,9 +15,6 @@ var _ColumnControls = require("./ColumnControls");
15
15
  var _ColumnDropTargets = require("./ColumnDropTargets");
16
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
19
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
20
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
21
18
  var TableFloatingColumnControls = exports.TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
22
19
  var editorView = _ref.editorView,
23
20
  tableRef = _ref.tableRef,
@@ -32,54 +29,17 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
32
29
  isTableHovered = _ref.isTableHovered,
33
30
  tableContainerWidth = _ref.tableContainerWidth,
34
31
  isNumberColumnEnabled = _ref.isNumberColumnEnabled,
35
- getScrollOffset = _ref.getScrollOffset;
36
- var _useState = (0, _react.useState)({
37
- width: 0,
38
- height: 0
39
- }),
32
+ getScrollOffset = _ref.getScrollOffset,
33
+ tableWrapperHeight = _ref.tableWrapperHeight;
34
+ var _useState = (0, _react.useState)(false),
40
35
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
41
- tableRect = _useState2[0],
42
- setTableRect = _useState2[1];
43
- var _useState3 = (0, _react.useState)(false),
44
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
45
- isDragging = _useState4[0],
46
- setIsDragging = _useState4[1];
36
+ isDragging = _useState2[0],
37
+ setIsDragging = _useState2[1];
47
38
  var containerRef = (0, _react.useRef)(null);
48
39
  var node = getNode();
49
40
  var currentNodeLocalId = node === null || node === void 0 ? void 0 : node.attrs.localId;
50
41
  var hasHeaderColumn = (0, _utils.containsHeaderColumn)(node);
51
42
  var stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
52
- (0, _react.useEffect)(function () {
53
- var _window;
54
- if (tableRef && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
55
- var resizeObserver = new ResizeObserver(function (entries) {
56
- var _iterator = _createForOfIteratorHelper(entries),
57
- _step;
58
- try {
59
- var _loop = function _loop() {
60
- var entry = _step.value;
61
- setTableRect(function (prev) {
62
- if (prev.width !== entry.contentRect.width || prev.height !== entry.contentRect.height) {
63
- return entry.contentRect;
64
- }
65
- return prev;
66
- });
67
- };
68
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
69
- _loop();
70
- }
71
- } catch (err) {
72
- _iterator.e(err);
73
- } finally {
74
- _iterator.f();
75
- }
76
- });
77
- resizeObserver.observe(tableRef);
78
- return function () {
79
- resizeObserver.disconnect();
80
- };
81
- }
82
- }, [tableRef]);
83
43
  (0, _react.useEffect)(function () {
84
44
  return (0, _adapter.monitorForElements)({
85
45
  canMonitor: function canMonitor(_ref2) {
@@ -100,11 +60,11 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
100
60
  }, [editorView, currentNodeLocalId]);
101
61
  var rowHeights = (0, _react.useMemo)(function () {
102
62
  // NOTE: we don't care so much as to what tableHeight is, we only care that it changed and is a sane value.
103
- if (tableRef && !!tableRect.height) {
63
+ if (tableRef && !!tableWrapperHeight) {
104
64
  return (0, _utils.getRowHeights)(tableRef);
105
65
  }
106
66
  return [0];
107
- }, [tableRef, tableRect.height]);
67
+ }, [tableRef, tableWrapperHeight]);
108
68
  if (!tableRef || !tableActive || isResizing) {
109
69
  return null;
110
70
  }
@@ -141,7 +101,7 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
141
101
  }), isDragging && /*#__PURE__*/_react.default.createElement(_ColumnDropTargets.ColumnDropTargets, {
142
102
  tableRef: tableRef,
143
103
  isHeaderSticky: (stickyHeader === null || stickyHeader === void 0 ? void 0 : stickyHeader.sticky) && hasHeaderRow,
144
- tableHeight: tableRect.height,
104
+ tableHeight: tableWrapperHeight,
145
105
  localId: currentNodeLocalId,
146
106
  colWidths: colWidths,
147
107
  getScrollOffset: getScrollOffset
@@ -5,240 +5,130 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
8
+ exports.default = exports.TableFloatingControls = void 0;
16
9
  var _react = _interopRequireWildcard(require("react"));
17
10
  var _utils = require("@atlaskit/editor-common/utils");
18
11
  var _commands = require("../../commands");
19
12
  var _types = require("../../types");
20
- var _utils2 = require("../../utils");
21
13
  var _CornerControls = require("./CornerControls");
22
14
  var _NumberColumn = _interopRequireDefault(require("./NumberColumn"));
23
15
  var _RowControls = require("./RowControls");
24
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
25
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
26
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
27
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
28
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
29
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
30
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
31
- var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component) {
32
- (0, _inherits2.default)(TableFloatingControls, _Component);
33
- var _super = _createSuper(TableFloatingControls);
34
- function TableFloatingControls(props) {
35
- var _this;
36
- (0, _classCallCheck2.default)(this, TableFloatingControls);
37
- _this = _super.call(this, props);
38
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectRow", function (row, expand) {
39
- var editorView = _this.props.editorView;
40
- var state = editorView.state,
41
- dispatch = editorView.dispatch;
42
- // fix for issue ED-4665
43
- if (_utils.browser.ie_version === 11) {
44
- editorView.dom.blur();
45
- }
46
- (0, _commands.selectRow)(row, expand)(state, dispatch);
47
- });
48
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectRows", function (rowIndexes) {
49
- var editorView = _this.props.editorView;
50
- var state = editorView.state,
51
- dispatch = editorView.dispatch;
52
- // fix for issue ED-4665
53
- if (_utils.browser.ie_version === 11) {
54
- editorView.dom.blur();
55
- }
56
- (0, _commands.selectRows)(rowIndexes)(state, dispatch);
57
- });
58
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hoverRows", function (rows, danger) {
59
- var _this$props$editorVie = _this.props.editorView,
60
- state = _this$props$editorVie.state,
61
- dispatch = _this$props$editorVie.dispatch;
62
- (0, _commands.hoverRows)(rows, danger)(state, dispatch);
63
- });
64
- // re-use across numbered columns and row controls
65
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateCellHoverLocation", function (rowIndex) {
66
- var _this$props = _this.props,
67
- editorView = _this$props.editorView,
68
- tableActive = _this$props.tableActive;
69
- var state = editorView.state,
70
- dispatch = editorView.dispatch;
71
- if (tableActive) {
72
- // For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
73
- // of the opposite dimension. For example; here when we mouse over the row drag handle then we're technically
74
- // also hovering over column 0 index. And vice-versa with columns. This means we don't need to worry about knowing the
75
- // current column index. We can just force it to 0.
76
- (0, _commands.hoverCell)(rowIndex, 0)(state, dispatch);
77
- }
78
- });
79
- _this.state = {
80
- tableWrapperWidth: 0,
81
- /** Height needs to be tracked to re-render decorations correctly, do not remove */
82
- tableWrapperHeight: 0
83
- };
84
- return _this;
85
- }
86
- (0, _createClass2.default)(TableFloatingControls, [{
87
- key: "componentDidMount",
88
- value: function componentDidMount() {
89
- this.tryInitResizeObserver();
18
+ var TableFloatingControls = exports.TableFloatingControls = function TableFloatingControls(_ref) {
19
+ var editorView = _ref.editorView,
20
+ tableRef = _ref.tableRef,
21
+ tableNode = _ref.tableNode,
22
+ isInDanger = _ref.isInDanger,
23
+ isResizing = _ref.isResizing,
24
+ isNumberColumnEnabled = _ref.isNumberColumnEnabled,
25
+ isHeaderRowEnabled = _ref.isHeaderRowEnabled,
26
+ isHeaderColumnEnabled = _ref.isHeaderColumnEnabled,
27
+ tableActive = _ref.tableActive,
28
+ hasHeaderRow = _ref.hasHeaderRow,
29
+ hoveredRows = _ref.hoveredRows,
30
+ stickyHeader = _ref.stickyHeader,
31
+ isDragAndDropEnabled = _ref.isDragAndDropEnabled,
32
+ hoveredCell = _ref.hoveredCell,
33
+ isTableHovered = _ref.isTableHovered,
34
+ tableWrapperWidth = _ref.tableWrapperWidth;
35
+ var _selectRow = (0, _react.useCallback)(function (row, expand) {
36
+ var state = editorView.state,
37
+ dispatch = editorView.dispatch;
38
+ // fix for issue ED-4665
39
+ if (_utils.browser.ie_version === 11) {
40
+ editorView.dom.blur();
90
41
  }
91
- }, {
92
- key: "componentDidUpdate",
93
- value: function componentDidUpdate() {
94
- // tableRef prop is not guaranteed to be defined after componentDidMount, so retry to init resize observer on update
95
- this.tryInitResizeObserver();
42
+ (0, _commands.selectRow)(row, expand)(state, dispatch);
43
+ }, [editorView]);
44
+ var _selectRows = (0, _react.useCallback)(function (rowIndexes) {
45
+ var state = editorView.state,
46
+ dispatch = editorView.dispatch;
47
+ // fix for issue ED-4665
48
+ if (_utils.browser.ie_version === 11) {
49
+ editorView.dom.blur();
96
50
  }
51
+ (0, _commands.selectRows)(rowIndexes)(state, dispatch);
52
+ }, [editorView]);
53
+ var _hoverRows = (0, _react.useCallback)(function (rows, danger) {
54
+ var state = editorView.state,
55
+ dispatch = editorView.dispatch;
56
+ (0, _commands.hoverRows)(rows, danger)(state, dispatch);
57
+ }, [editorView]);
97
58
 
98
- // tracking the table height changes to update floating controls
99
- }, {
100
- key: "tryInitResizeObserver",
101
- value: function tryInitResizeObserver() {
102
- var _window,
103
- _this2 = this;
104
- var tableRef = this.props.tableRef;
105
- if (tableRef && !this.resizeObserver && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
106
- var tableWrapper = tableRef.closest(".".concat(_types.TableCssClassName.TABLE_NODE_WRAPPER));
107
- this.resizeObserver = new ResizeObserver(function (entries) {
108
- var _iterator = _createForOfIteratorHelper(entries),
109
- _step;
110
- try {
111
- var _loop = function _loop() {
112
- var entry = _step.value;
113
- _this2.setState(function (prev) {
114
- return (prev === null || prev === void 0 ? void 0 : prev.tableWrapperWidth) === entry.contentRect.width && prev.tableWrapperHeight === entry.contentRect.height ? prev : {
115
- tableWrapperWidth: entry.contentRect.width,
116
- tableWrapperHeight: entry.contentRect.height
117
- };
118
- });
119
- };
120
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
121
- _loop();
122
- }
123
- } catch (err) {
124
- _iterator.e(err);
125
- } finally {
126
- _iterator.f();
127
- }
128
- });
129
- this.resizeObserver.observe(tableWrapper);
130
- }
131
- }
132
- }, {
133
- key: "shouldComponentUpdate",
134
- value: function shouldComponentUpdate(nextProps, nextState) {
135
- var _this$props2 = this.props,
136
- tableRef = _this$props2.tableRef,
137
- isInDanger = _this$props2.isInDanger,
138
- isResizing = _this$props2.isResizing,
139
- isHeaderRowEnabled = _this$props2.isHeaderRowEnabled,
140
- isNumberColumnEnabled = _this$props2.isNumberColumnEnabled,
141
- hoveredRows = _this$props2.hoveredRows,
142
- selection = _this$props2.selection,
143
- tableActive = _this$props2.tableActive,
144
- isHeaderColumnEnabled = _this$props2.isHeaderColumnEnabled,
145
- ordering = _this$props2.ordering,
146
- headerRowHeight = _this$props2.headerRowHeight,
147
- stickyHeader = _this$props2.stickyHeader,
148
- hoveredCell = _this$props2.hoveredCell,
149
- isTableHovered = _this$props2.isTableHovered;
150
- return this.state.tableWrapperWidth !== nextState.tableWrapperWidth || this.state.tableWrapperHeight !== nextState.tableWrapperHeight || ordering !== nextProps.ordering || tableRef !== nextProps.tableRef || tableActive !== nextProps.tableActive || isInDanger !== nextProps.isInDanger || isResizing !== nextProps.isResizing || hoveredRows !== nextProps.hoveredRows || isHeaderRowEnabled !== nextProps.isHeaderRowEnabled || isHeaderColumnEnabled !== nextProps.isHeaderColumnEnabled || isNumberColumnEnabled !== nextProps.isNumberColumnEnabled || (0, _utils2.isSelectionUpdated)(selection, nextProps.selection) || headerRowHeight !== nextProps.headerRowHeight || stickyHeader !== nextProps.stickyHeader || hoveredCell !== nextProps.hoveredCell || isTableHovered !== nextProps.isTableHovered;
59
+ // re-use across numbered columns and row controls
60
+ var updateCellHoverLocation = (0, _react.useCallback)(function (rowIndex) {
61
+ var state = editorView.state,
62
+ dispatch = editorView.dispatch;
63
+ if (tableActive) {
64
+ // For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
65
+ // of the opposite dimension. For example; here when we mouse over the row drag handle then we're technically
66
+ // also hovering over column 0 index. And vice-versa with columns. This means we don't need to worry about knowing the
67
+ // current column index. We can just force it to 0.
68
+ (0, _commands.hoverCell)(rowIndex, 0)(state, dispatch);
151
69
  }
152
- }, {
153
- key: "componentWillUnmount",
154
- value: function componentWillUnmount() {
155
- if (this.resizeObserver) {
156
- this.resizeObserver.disconnect();
157
- }
158
- }
159
- }, {
160
- key: "render",
161
- value: function render() {
162
- var _this$props3 = this.props,
163
- editorView = _this$props3.editorView,
164
- tableRef = _this$props3.tableRef,
165
- tableNode = _this$props3.tableNode,
166
- isInDanger = _this$props3.isInDanger,
167
- isResizing = _this$props3.isResizing,
168
- isNumberColumnEnabled = _this$props3.isNumberColumnEnabled,
169
- isHeaderRowEnabled = _this$props3.isHeaderRowEnabled,
170
- isHeaderColumnEnabled = _this$props3.isHeaderColumnEnabled,
171
- tableActive = _this$props3.tableActive,
172
- hasHeaderRow = _this$props3.hasHeaderRow,
173
- hoveredRows = _this$props3.hoveredRows,
174
- stickyHeader = _this$props3.stickyHeader,
175
- isDragAndDropEnabled = _this$props3.isDragAndDropEnabled,
176
- hoveredCell = _this$props3.hoveredCell,
177
- isTableHovered = _this$props3.isTableHovered;
178
- if (!tableRef) {
179
- return null;
180
- }
181
- var stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
182
- var wrapperClassName = isDragAndDropEnabled ? _types.TableCssClassName.DRAG_ROW_CONTROLS_WRAPPER : _types.TableCssClassName.ROW_CONTROLS_WRAPPER;
183
- return /*#__PURE__*/_react.default.createElement("div", {
184
- className: wrapperClassName
185
- }, /*#__PURE__*/_react.default.createElement("div", {
186
- onMouseDown: function onMouseDown(e) {
187
- return !isDragAndDropEnabled && e.preventDefault();
188
- }
189
- }, isNumberColumnEnabled ? /*#__PURE__*/_react.default.createElement(_NumberColumn.default, {
190
- editorView: editorView,
191
- hoverRows: this.hoverRows,
192
- tableRef: tableRef,
193
- tableActive: tableActive,
194
- hoveredRows: hoveredRows,
195
- hasHeaderRow: hasHeaderRow,
196
- isInDanger: isInDanger,
197
- isResizing: isResizing,
198
- selectRow: this.selectRow,
199
- updateCellHoverLocation: this.updateCellHoverLocation,
200
- stickyTop: stickyTop,
201
- isDragAndDropEnabled: isDragAndDropEnabled
202
- }) : null, tableActive && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.DragCornerControls, {
203
- editorView: editorView,
204
- tableRef: tableRef,
205
- isInDanger: isInDanger,
206
- isResizing: isResizing
207
- }), /*#__PURE__*/_react.default.createElement(_RowControls.DragControls, {
208
- tableRef: tableRef,
209
- tableNode: tableNode,
210
- hoveredCell: hoveredCell,
211
- isTableHovered: isTableHovered,
212
- editorView: editorView,
213
- tableActive: tableActive,
214
- isInDanger: isInDanger,
215
- isResizing: isResizing,
216
- tableWidth: this.state.tableWrapperWidth,
217
- hoverRows: this.hoverRows,
218
- selectRow: this.selectRow,
219
- selectRows: this.selectRows,
220
- updateCellHoverLocation: this.updateCellHoverLocation
221
- })) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.CornerControls, {
222
- editorView: editorView,
223
- tableRef: tableRef,
224
- isInDanger: isInDanger,
225
- isResizing: isResizing,
226
- isHeaderRowEnabled: isHeaderRowEnabled,
227
- isHeaderColumnEnabled: isHeaderColumnEnabled,
228
- hoveredRows: hoveredRows,
229
- stickyTop: tableActive ? stickyTop : undefined
230
- }), /*#__PURE__*/_react.default.createElement(_RowControls.RowControls, {
231
- editorView: editorView,
232
- tableRef: tableRef,
233
- hoverRows: this.hoverRows,
234
- hoveredRows: hoveredRows,
235
- isInDanger: isInDanger,
236
- isResizing: isResizing,
237
- selectRow: this.selectRow,
238
- stickyTop: tableActive ? stickyTop : undefined
239
- })))));
70
+ }, [editorView, tableActive]);
71
+ if (!tableRef) {
72
+ return null;
73
+ }
74
+ var stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
75
+ var wrapperClassName = isDragAndDropEnabled ? _types.TableCssClassName.DRAG_ROW_CONTROLS_WRAPPER : _types.TableCssClassName.ROW_CONTROLS_WRAPPER;
76
+ return /*#__PURE__*/_react.default.createElement("div", {
77
+ className: wrapperClassName
78
+ }, /*#__PURE__*/_react.default.createElement("div", {
79
+ onMouseDown: function onMouseDown(e) {
80
+ return !isDragAndDropEnabled && e.preventDefault();
240
81
  }
241
- }]);
242
- return TableFloatingControls;
243
- }(_react.Component);
244
- (0, _defineProperty2.default)(TableFloatingControls, "displayName", 'TableFloatingControls');
82
+ }, isNumberColumnEnabled ? /*#__PURE__*/_react.default.createElement(_NumberColumn.default, {
83
+ editorView: editorView,
84
+ hoverRows: _hoverRows,
85
+ tableRef: tableRef,
86
+ tableActive: tableActive,
87
+ hoveredRows: hoveredRows,
88
+ hasHeaderRow: hasHeaderRow,
89
+ isInDanger: isInDanger,
90
+ isResizing: isResizing,
91
+ selectRow: _selectRow,
92
+ updateCellHoverLocation: updateCellHoverLocation,
93
+ stickyTop: stickyTop,
94
+ isDragAndDropEnabled: isDragAndDropEnabled
95
+ }) : null, tableActive && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.DragCornerControls, {
96
+ editorView: editorView,
97
+ tableRef: tableRef,
98
+ isInDanger: isInDanger,
99
+ isResizing: isResizing
100
+ }), /*#__PURE__*/_react.default.createElement(_RowControls.DragControls, {
101
+ tableRef: tableRef,
102
+ tableNode: tableNode,
103
+ hoveredCell: hoveredCell,
104
+ isTableHovered: isTableHovered,
105
+ editorView: editorView,
106
+ tableActive: tableActive,
107
+ isInDanger: isInDanger,
108
+ isResizing: isResizing,
109
+ tableWidth: tableWrapperWidth,
110
+ hoverRows: _hoverRows,
111
+ selectRow: _selectRow,
112
+ selectRows: _selectRows,
113
+ updateCellHoverLocation: updateCellHoverLocation
114
+ })) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.CornerControls, {
115
+ editorView: editorView,
116
+ tableRef: tableRef,
117
+ isInDanger: isInDanger,
118
+ isResizing: isResizing,
119
+ isHeaderRowEnabled: isHeaderRowEnabled,
120
+ isHeaderColumnEnabled: isHeaderColumnEnabled,
121
+ hoveredRows: hoveredRows,
122
+ stickyTop: tableActive ? stickyTop : undefined
123
+ }), /*#__PURE__*/_react.default.createElement(_RowControls.RowControls, {
124
+ editorView: editorView,
125
+ tableRef: tableRef,
126
+ hoverRows: _hoverRows,
127
+ hoveredRows: hoveredRows,
128
+ isInDanger: isInDanger,
129
+ isResizing: isResizing,
130
+ selectRow: _selectRow,
131
+ stickyTop: tableActive ? stickyTop : undefined
132
+ })))));
133
+ };
134
+ var _default = exports.default = TableFloatingControls;
@@ -26,13 +26,13 @@ var getColumnsWidths = exports.getColumnsWidths = function getColumnsWidths(view
26
26
  length: map.width
27
27
  });
28
28
  for (var i = 0; i < map.width; i++) {
29
- var cells = (0, _utils3.getCellsInColumn)(i)(selection);
30
- var cell = cells[0];
31
- if (cell) {
32
- var cellRef = (0, _utils2.findDomRefAtPos)(cell.pos, domAtPos);
29
+ if (!map.isCellMergedTopLeft(0, i)) {
30
+ var node = table.node.nodeAt(map.map[i]);
31
+ var pos = map.map[i] + table.start;
32
+ var cellRef = (0, _utils2.findDomRefAtPos)(pos, domAtPos);
33
33
  var rect = cellRef.getBoundingClientRect();
34
34
  widths[i] = (rect ? rect.width : cellRef.offsetWidth) + 1;
35
- i += cell.node.attrs.colspan - 1;
35
+ i += node.attrs.colspan - 1;
36
36
  }
37
37
  }
38
38
  }
@@ -10,12 +10,9 @@ var _utils = require("@atlaskit/editor-tables/utils");
10
10
  var _utils2 = require("../pm-plugins/table-resizing/utils");
11
11
  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; }
12
12
  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; }
13
- var createTableWithWidth = exports.createTableWithWidth = function createTableWithWidth(isFullWidthModeEnabled, getEditorFeatureFlags, createTableProps) {
13
+ var createTableWithWidth = exports.createTableWithWidth = function createTableWithWidth(isTableScalingEnabled, isFullWidthModeEnabled, createTableProps) {
14
14
  return function (schema) {
15
- var _ref = (getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags()) || {},
16
- _ref$tablePreserveWid = _ref.tablePreserveWidth,
17
- tablePreserveWidth = _ref$tablePreserveWid === void 0 ? false : _ref$tablePreserveWid;
18
- if (tablePreserveWidth && isFullWidthModeEnabled) {
15
+ if (isTableScalingEnabled && isFullWidthModeEnabled) {
19
16
  return (0, _utils.createTable)(_objectSpread({
20
17
  schema: schema,
21
18
  tableWidth: _utils2.TABLE_MAX_WIDTH
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.isTableControlsButton = exports.isTableContainerOrWrapper = exports.isRowControlsButton = exports.isResizeHandleDecoration = exports.isInsertRowButton = exports.isDragRowFloatingInsertDot = exports.isDragRowControlsButton = exports.isDragCornerButton = exports.isDragColumnFloatingInsertDot = exports.isCornerButton = exports.isColumnControlsDecorations = exports.isCell = exports.hasResizeHandler = exports.getTree = exports.getTop = exports.getMousePositionVerticalRelativeByElement = exports.getMousePositionHorizontalRelativeByElement = exports.getColumnOrRowIndex = exports.findNearestCellIndexToPoint = void 0;
7
7
  var _utils = require("@atlaskit/editor-common/utils");
8
8
  var _types = require("../types");
9
- var SELECTOR_TABLE_LEAFS = ".".concat(_types.TableCssClassName.TABLE_CELL, ", .").concat(_types.TableCssClassName.TABLE_HEADER_CELL);
10
9
  var isCell = exports.isCell = function isCell(node) {
11
10
  return Boolean(node && (['TH', 'TD'].indexOf(node.tagName) > -1 || !!(0, _utils.closestElement)(node, ".".concat(_types.TableCssClassName.TABLE_HEADER_CELL)) || !!(0, _utils.closestElement)(node, ".".concat(_types.TableCssClassName.TABLE_CELL))));
12
11
  };
@@ -102,22 +101,21 @@ var isDragCornerButton = exports.isDragCornerButton = function isDragCornerButto
102
101
  *
103
102
  * the same is valid to the right side.
104
103
  */
105
-
106
- var getMousePositionHorizontalRelativeByElement = exports.getMousePositionHorizontalRelativeByElement = function getMousePositionHorizontalRelativeByElement(mouseEvent, elementContentRects, gapInPixels, isDragAndDropEnabled) {
104
+ /**
105
+ * This can be used with mouse events to determine the left/right side of the target the pointer is closest too.
106
+ *
107
+ * WARNING: This metod reads properties which can trigger a reflow; use this wisely.
108
+ *
109
+ * @param mouseEvent
110
+ * @param gapInPixels
111
+ * @returns
112
+ */
113
+ var getMousePositionHorizontalRelativeByElement = exports.getMousePositionHorizontalRelativeByElement = function getMousePositionHorizontalRelativeByElement(mouseEvent, offsetX, gapInPixels) {
107
114
  var element = mouseEvent.target;
108
115
  if (element instanceof HTMLElement) {
109
- var width, x;
110
- if (isDragAndDropEnabled) {
111
- // mouse event fires for new overlapping column controls, so the cell can not get detected. Get width
112
- // directly from element that will be .pm-table-drag-columns-floating-insert-dot-wrapper
113
- width = element.clientWidth;
114
- } else {
115
- var _closestCell$id, _elementContentRects$, _elementContentRects$2;
116
- var closestCell = element.closest(SELECTOR_TABLE_LEAFS);
117
- var id = (_closestCell$id = closestCell === null || closestCell === void 0 ? void 0 : closestCell.id) !== null && _closestCell$id !== void 0 ? _closestCell$id : '';
118
- width = (_elementContentRects$ = elementContentRects === null || elementContentRects === void 0 || (_elementContentRects$2 = elementContentRects[id]) === null || _elementContentRects$2 === void 0 ? void 0 : _elementContentRects$2.width) !== null && _elementContentRects$ !== void 0 ? _elementContentRects$ : 0;
119
- }
120
- x = mouseEvent.offsetX;
116
+ var width = element.clientWidth; // reflow
117
+ var x = !Number.isNaN(offsetX) ? offsetX : mouseEvent.offsetX; // reflow
118
+
121
119
  if (width <= 0) {
122
120
  return null;
123
121
  }