@atlaskit/editor-plugin-table 7.4.8 → 7.5.0

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 (192) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/commands/column-resize.js +4 -2
  3. package/dist/cjs/commands/delete.js +2 -1
  4. package/dist/cjs/commands/insert.js +6 -3
  5. package/dist/cjs/commands-with-analytics.js +4 -2
  6. package/dist/cjs/event-handlers.js +2 -1
  7. package/dist/cjs/nodeviews/TableComponent.js +116 -47
  8. package/dist/cjs/nodeviews/TableContainer.js +8 -4
  9. package/dist/cjs/nodeviews/TableResizer.js +6 -5
  10. package/dist/cjs/nodeviews/table.js +12 -4
  11. package/dist/cjs/plugin.js +50 -47
  12. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +9 -6
  13. package/dist/cjs/pm-plugins/keymap.js +6 -3
  14. package/dist/cjs/pm-plugins/main.js +4 -1
  15. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +7 -3
  16. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +32 -11
  17. package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
  18. package/dist/cjs/pm-plugins/table-resizing/utils/index.js +24 -0
  19. package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +20 -1
  20. package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +2 -1
  21. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +52 -11
  22. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +19 -8
  23. package/dist/cjs/toolbar.js +17 -10
  24. package/dist/cjs/transforms/column-width.js +22 -7
  25. package/dist/cjs/transforms/delete-columns.js +2 -1
  26. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +45 -38
  27. package/dist/cjs/ui/FloatingContextualMenu/index.js +5 -3
  28. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +15 -4
  29. package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +53 -8
  30. package/dist/cjs/ui/FloatingDragMenu/index.js +15 -6
  31. package/dist/cjs/ui/FloatingInsertButton/index.js +5 -1
  32. package/dist/cjs/ui/consts.js +2 -1
  33. package/dist/cjs/utils/create.js +1 -1
  34. package/dist/cjs/utils/drag-menu.js +4 -3
  35. package/dist/es2019/commands/column-resize.js +4 -3
  36. package/dist/es2019/commands/delete.js +2 -2
  37. package/dist/es2019/commands/insert.js +6 -6
  38. package/dist/es2019/commands-with-analytics.js +4 -4
  39. package/dist/es2019/event-handlers.js +2 -2
  40. package/dist/es2019/nodeviews/TableComponent.js +77 -8
  41. package/dist/es2019/nodeviews/TableContainer.js +8 -4
  42. package/dist/es2019/nodeviews/TableResizer.js +6 -5
  43. package/dist/es2019/nodeviews/table.js +12 -4
  44. package/dist/es2019/plugin.js +14 -8
  45. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +7 -4
  46. package/dist/es2019/pm-plugins/keymap.js +6 -3
  47. package/dist/es2019/pm-plugins/main.js +4 -1
  48. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +7 -3
  49. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +31 -12
  50. package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
  51. package/dist/es2019/pm-plugins/table-resizing/utils/index.js +2 -2
  52. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +20 -2
  53. package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +2 -2
  54. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +47 -10
  55. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +19 -12
  56. package/dist/es2019/toolbar.js +15 -12
  57. package/dist/es2019/transforms/column-width.js +24 -10
  58. package/dist/es2019/transforms/delete-columns.js +2 -2
  59. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +12 -5
  60. package/dist/es2019/ui/FloatingContextualMenu/index.js +6 -4
  61. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +15 -4
  62. package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +42 -8
  63. package/dist/es2019/ui/FloatingDragMenu/index.js +16 -7
  64. package/dist/es2019/ui/FloatingInsertButton/index.js +5 -1
  65. package/dist/es2019/ui/consts.js +1 -0
  66. package/dist/es2019/utils/create.js +1 -1
  67. package/dist/es2019/utils/drag-menu.js +4 -4
  68. package/dist/esm/commands/column-resize.js +4 -2
  69. package/dist/esm/commands/delete.js +2 -1
  70. package/dist/esm/commands/insert.js +6 -3
  71. package/dist/esm/commands-with-analytics.js +4 -2
  72. package/dist/esm/event-handlers.js +2 -1
  73. package/dist/esm/nodeviews/TableComponent.js +118 -49
  74. package/dist/esm/nodeviews/TableContainer.js +8 -4
  75. package/dist/esm/nodeviews/TableResizer.js +6 -5
  76. package/dist/esm/nodeviews/table.js +12 -4
  77. package/dist/esm/plugin.js +50 -47
  78. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +9 -6
  79. package/dist/esm/pm-plugins/keymap.js +6 -3
  80. package/dist/esm/pm-plugins/main.js +4 -1
  81. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +7 -3
  82. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +32 -11
  83. package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
  84. package/dist/esm/pm-plugins/table-resizing/utils/index.js +2 -2
  85. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +22 -2
  86. package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +2 -1
  87. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +52 -11
  88. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +19 -8
  89. package/dist/esm/toolbar.js +17 -10
  90. package/dist/esm/transforms/column-width.js +23 -8
  91. package/dist/esm/transforms/delete-columns.js +2 -1
  92. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +45 -38
  93. package/dist/esm/ui/FloatingContextualMenu/index.js +6 -4
  94. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +15 -4
  95. package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +50 -9
  96. package/dist/esm/ui/FloatingDragMenu/index.js +16 -7
  97. package/dist/esm/ui/FloatingInsertButton/index.js +5 -1
  98. package/dist/esm/ui/consts.js +1 -0
  99. package/dist/esm/utils/create.js +1 -1
  100. package/dist/esm/utils/drag-menu.js +4 -3
  101. package/dist/types/commands/column-resize.d.ts +1 -1
  102. package/dist/types/commands/delete.d.ts +1 -1
  103. package/dist/types/commands/insert.d.ts +3 -3
  104. package/dist/types/commands-with-analytics.d.ts +2 -2
  105. package/dist/types/event-handlers.d.ts +1 -1
  106. package/dist/types/nodeviews/TableComponent.d.ts +3 -0
  107. package/dist/types/nodeviews/TableContainer.d.ts +4 -2
  108. package/dist/types/nodeviews/TableResizer.d.ts +2 -1
  109. package/dist/types/nodeviews/table.d.ts +1 -0
  110. package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +3 -2
  111. package/dist/types/pm-plugins/keymap.d.ts +2 -2
  112. package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
  113. package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
  114. package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +2 -2
  115. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +7 -0
  116. package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
  117. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -3
  118. package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
  119. package/dist/types/toolbar.d.ts +2 -2
  120. package/dist/types/transforms/column-width.d.ts +1 -1
  121. package/dist/types/transforms/delete-columns.d.ts +1 -1
  122. package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
  123. package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
  124. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +7 -1
  125. package/dist/types/ui/FloatingDragMenu/DropdownMenu.d.ts +8 -2
  126. package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -2
  127. package/dist/types/ui/FloatingInsertButton/index.d.ts +2 -1
  128. package/dist/types/ui/consts.d.ts +1 -0
  129. package/dist/types/utils/drag-menu.d.ts +1 -1
  130. package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
  131. package/dist/types-ts4.5/commands/delete.d.ts +1 -1
  132. package/dist/types-ts4.5/commands/insert.d.ts +3 -3
  133. package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -2
  134. package/dist/types-ts4.5/event-handlers.d.ts +1 -1
  135. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +3 -0
  136. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
  137. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
  138. package/dist/types-ts4.5/nodeviews/table.d.ts +1 -0
  139. package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +3 -2
  140. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
  141. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
  142. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
  143. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +2 -2
  144. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +7 -0
  145. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
  146. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -3
  147. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
  148. package/dist/types-ts4.5/toolbar.d.ts +2 -2
  149. package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
  150. package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
  151. package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
  152. package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
  153. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +7 -1
  154. package/dist/types-ts4.5/ui/FloatingDragMenu/DropdownMenu.d.ts +8 -2
  155. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -2
  156. package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +2 -1
  157. package/dist/types-ts4.5/ui/consts.d.ts +1 -0
  158. package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
  159. package/package.json +3 -3
  160. package/src/commands/column-resize.ts +3 -0
  161. package/src/commands/delete.ts +2 -1
  162. package/src/commands/insert.ts +15 -6
  163. package/src/commands-with-analytics.ts +9 -3
  164. package/src/event-handlers.ts +2 -0
  165. package/src/nodeviews/TableComponent.tsx +91 -5
  166. package/src/nodeviews/TableContainer.tsx +6 -0
  167. package/src/nodeviews/TableResizer.tsx +6 -0
  168. package/src/nodeviews/table.tsx +15 -10
  169. package/src/plugin.tsx +17 -5
  170. package/src/pm-plugins/drag-and-drop/plugin.ts +16 -8
  171. package/src/pm-plugins/keymap.ts +11 -3
  172. package/src/pm-plugins/main.ts +3 -0
  173. package/src/pm-plugins/table-resizing/event-handlers.ts +11 -1
  174. package/src/pm-plugins/table-resizing/utils/colgroup.ts +49 -17
  175. package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
  176. package/src/pm-plugins/table-resizing/utils/index.ts +8 -1
  177. package/src/pm-plugins/table-resizing/utils/misc.ts +25 -1
  178. package/src/pm-plugins/table-resizing/utils/resize-column.ts +2 -1
  179. package/src/pm-plugins/table-resizing/utils/resize-state.ts +56 -11
  180. package/src/pm-plugins/table-resizing/utils/scale-table.ts +24 -6
  181. package/src/toolbar.tsx +18 -5
  182. package/src/transforms/column-width.ts +33 -11
  183. package/src/transforms/delete-columns.ts +7 -2
  184. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +20 -5
  185. package/src/ui/FloatingContextualMenu/index.tsx +4 -1
  186. package/src/ui/FloatingDragMenu/DragMenu.tsx +19 -1
  187. package/src/ui/FloatingDragMenu/DropdownMenu.tsx +94 -50
  188. package/src/ui/FloatingDragMenu/index.tsx +17 -4
  189. package/src/ui/FloatingInsertButton/index.tsx +17 -5
  190. package/src/ui/consts.ts +1 -0
  191. package/src/utils/create.ts +1 -3
  192. package/src/utils/drag-menu.ts +4 -1
@@ -302,8 +302,11 @@ export class ContextualMenu extends Component {
302
302
  }
303
303
  } = getPluginState(editorView.state);
304
304
  if (allowDistributeColumns && (!isDragAndDropEnabled || !getBooleanFF('platform.editor.table.new-cell-context-menu-styling'))) {
305
- var _newResizeState$chang;
306
- const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
305
+ var _this$props$getEditor, _this$props, _newResizeState$chang;
306
+ const {
307
+ tablePreserveWidth = false
308
+ } = ((_this$props$getEditor = (_this$props = this.props).getEditorFeatureFlags) === null || _this$props$getEditor === void 0 ? void 0 : _this$props$getEditor.call(_this$props)) || {};
309
+ const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, tablePreserveWidth);
307
310
  const wouldChange = (_newResizeState$chang = newResizeState === null || newResizeState === void 0 ? void 0 : newResizeState.changed) !== null && _newResizeState$chang !== void 0 ? _newResizeState$chang : false;
308
311
  return {
309
312
  content: formatMessage(messages.distributeColumns),
@@ -397,7 +400,8 @@ export class ContextualMenu extends Component {
397
400
  editorView,
398
401
  selectionRect,
399
402
  editorAnalyticsAPI,
400
- getEditorContainerWidth
403
+ getEditorContainerWidth,
404
+ getEditorFeatureFlags
401
405
  } = this.props;
402
406
  // TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
403
407
  const {
@@ -407,6 +411,9 @@ export class ContextualMenu extends Component {
407
411
  const {
408
412
  targetCellPosition
409
413
  } = getPluginState(state);
414
+ const {
415
+ tablePreserveWidth = false
416
+ } = (getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags()) || {};
410
417
  switch (item.value.name) {
411
418
  case 'sort_column_desc':
412
419
  sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect.left, SortOrder.DESC)(state, dispatch);
@@ -425,7 +432,7 @@ export class ContextualMenu extends Component {
425
432
  this.toggleOpen();
426
433
  break;
427
434
  case 'distribute_columns':
428
- const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
435
+ const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, tablePreserveWidth);
429
436
  if (newResizeStateWithAnalytics) {
430
437
  distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, newResizeStateWithAnalytics)(state, dispatch);
431
438
  this.toggleOpen();
@@ -436,7 +443,7 @@ export class ContextualMenu extends Component {
436
443
  this.toggleOpen();
437
444
  break;
438
445
  case 'insert_column':
439
- insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
446
+ insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI, tablePreserveWidth)(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
440
447
  this.toggleOpen();
441
448
  break;
442
449
  case 'insert_row':
@@ -5,7 +5,7 @@ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
6
6
  import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
7
7
  import { getPluginState } from '../../pm-plugins/plugin-factory';
8
- import { contextualMenuDropdownWidth, contextualMenuDropdownWidthDnD, contextualMenuTriggerSize } from '../consts';
8
+ import { contextualMenuDropdownWidth, contextualMenuDropdownWidthDnD, contextualMenuTriggerSize, tablePopupMenuFitHeight } from '../consts';
9
9
  import ContextualMenu from './ContextualMenu';
10
10
  import { tablePopupStyles } from './styles';
11
11
  const FloatingContextualMenu = ({
@@ -16,7 +16,8 @@ const FloatingContextualMenu = ({
16
16
  isOpen,
17
17
  pluginConfig,
18
18
  editorAnalyticsAPI,
19
- getEditorContainerWidth
19
+ getEditorContainerWidth,
20
+ getEditorFeatureFlags
20
21
  }) => {
21
22
  // TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
22
23
  const {
@@ -46,7 +47,7 @@ const FloatingContextualMenu = ({
46
47
  mountTo: mountPoint,
47
48
  boundariesElement: boundariesElement,
48
49
  scrollableElement: scrollableElement,
49
- fitHeight: 188,
50
+ fitHeight: tablePopupMenuFitHeight,
50
51
  fitWidth: isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth
51
52
  // z-index value below is to ensure that this menu is above other floating menu
52
53
  // in table, but below floating dialogs like typeaheads, pickers, etc.
@@ -68,7 +69,8 @@ const FloatingContextualMenu = ({
68
69
  selectionRect: selectionRect,
69
70
  boundariesElement: boundariesElement,
70
71
  editorAnalyticsAPI: editorAnalyticsAPI,
71
- getEditorContainerWidth: getEditorContainerWidth
72
+ getEditorContainerWidth: getEditorContainerWidth,
73
+ getEditorFeatureFlags: getEditorFeatureFlags
72
74
  })));
73
75
  };
74
76
  FloatingContextualMenu.displayName = 'FloatingContextualMenu';
@@ -170,7 +170,13 @@ export const DragMenu = /*#__PURE__*/React.memo(({
170
170
  pluginConfig,
171
171
  intl: {
172
172
  formatMessage
173
- }
173
+ },
174
+ fitHeight,
175
+ fitWidth,
176
+ mountPoint,
177
+ scrollableElement,
178
+ boundariesElement,
179
+ tablePreserveWidth
174
180
  }) => {
175
181
  var _pluginConfig$allowBa;
176
182
  const {
@@ -190,7 +196,7 @@ export const DragMenu = /*#__PURE__*/React.memo(({
190
196
  const shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
191
197
  const hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
192
198
  const allowBackgroundColor = (_pluginConfig$allowBa = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.allowBackgroundColor) !== null && _pluginConfig$allowBa !== void 0 ? _pluginConfig$allowBa : false;
193
- const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired);
199
+ const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.isHeaderRowRequired, tablePreserveWidth);
194
200
  const {
195
201
  menuItems,
196
202
  menuCallback
@@ -457,12 +463,17 @@ export const DragMenu = /*#__PURE__*/React.memo(({
457
463
  section: {
458
464
  hasSeparator: true
459
465
  },
460
- target: target,
461
466
  items: menuItems,
462
467
  onItemActivated: handleMenuItemActivated,
463
468
  onMouseEnter: handleItemMouseEnter,
464
469
  onMouseLeave: handleItemMouseLeave,
465
- handleClose: closeMenu
470
+ handleClose: closeMenu,
471
+ fitHeight: fitHeight,
472
+ fitWidth: fitWidth,
473
+ direction: direction,
474
+ mountPoint: mountPoint,
475
+ boundariesElement: boundariesElement,
476
+ scrollableElement: scrollableElement
466
477
  });
467
478
  });
468
479
  export default injectIntl(DragMenu);
@@ -1,26 +1,38 @@
1
- import React from 'react';
2
- import { DropList } from '@atlaskit/editor-common/ui';
1
+ /* eslint-disable @atlaskit/design-system/prefer-primitives */
2
+ import React, { useState } from 'react';
3
+ import { DropList, Popup } from '@atlaskit/editor-common/ui';
3
4
  import { ArrowKeyNavigationProvider, ArrowKeyNavigationType, DropdownMenuItem } from '@atlaskit/editor-common/ui-menu';
4
5
  import { withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
6
+ import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
5
7
  import { MenuGroup, Section } from '@atlaskit/menu';
6
8
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
9
  import { dragMenuDropdownWidth } from '../consts';
8
10
  const DropListWithOutsideListeners = withReactEditorViewOuterListeners(DropList);
9
11
  export const DropdownMenu = ({
10
- target,
11
12
  items,
12
13
  section,
13
14
  disableKeyboardHandling,
14
15
  onItemActivated,
15
16
  handleClose,
16
17
  onMouseEnter,
17
- onMouseLeave
18
+ onMouseLeave,
19
+ fitWidth,
20
+ fitHeight,
21
+ direction,
22
+ mountPoint,
23
+ boundariesElement,
24
+ scrollableElement
18
25
  }) => {
26
+ const [popupPlacement, setPopupPlacement] = useState(['bottom', 'left']);
27
+ const [targetRefDiv, setTargetRefDiv] = useState(null);
28
+ const handleRef = ref => {
29
+ setTargetRefDiv(ref);
30
+ };
19
31
  const innerMenu = () => {
20
32
  return /*#__PURE__*/React.createElement(DropListWithOutsideListeners, {
21
33
  isOpen: true,
22
34
  shouldFitContainer: true,
23
- position: ['bottom', 'left'].join(' '),
35
+ position: popupPlacement.join(' '),
24
36
  handleClickOutside: () => handleClose('editor'),
25
37
  handleEscapeKeydown: () => {
26
38
  if (!disableKeyboardHandling) {
@@ -33,7 +45,7 @@ export const DropdownMenu = ({
33
45
  e.stopPropagation();
34
46
  }
35
47
  },
36
- targetRef: target
48
+ targetRef: targetRefDiv
37
49
  }, /*#__PURE__*/React.createElement("div", {
38
50
  style: {
39
51
  height: 0,
@@ -60,7 +72,29 @@ export const DropdownMenu = ({
60
72
  if (disableKeyboardHandling) {
61
73
  return innerMenu();
62
74
  }
63
- return /*#__PURE__*/React.createElement(ArrowKeyNavigationProvider, {
75
+
76
+ // more offsets calculation as offsets depend on the direction and updated placement here
77
+ let offsetY = direction === 'row' ? popupPlacement[0] === 'bottom' ? -8 : -34 : 0;
78
+ let offsetX = direction === 'column' ? popupPlacement[1] === 'left' ? 0 : -7 : 0;
79
+ return /*#__PURE__*/React.createElement("div", {
80
+ className: "drag-dropdown-menu-wrapper"
81
+ }, /*#__PURE__*/React.createElement("div", {
82
+ className: "drag-dropdown-menu-popup-ref",
83
+ ref: handleRef
84
+ }), /*#__PURE__*/React.createElement(Popup, {
85
+ target: targetRefDiv,
86
+ mountTo: mountPoint,
87
+ boundariesElement: boundariesElement,
88
+ scrollableElement: scrollableElement,
89
+ onPlacementChanged: placement => {
90
+ setPopupPlacement(placement);
91
+ },
92
+ fitHeight: fitHeight,
93
+ fitWidth: fitWidth,
94
+ zIndex: akEditorFloatingPanelZIndex,
95
+ offset: [offsetX, offsetY],
96
+ allowOutOfBounds: true // required as this popup is child of a parent popup, should be allowed to be out of bound of the parent popup, otherwise horizontal offset is not right
97
+ }, /*#__PURE__*/React.createElement(ArrowKeyNavigationProvider, {
64
98
  closeOnTab: true,
65
99
  type: ArrowKeyNavigationType.MENU,
66
100
  onSelection: index => {
@@ -105,5 +139,5 @@ export const DropdownMenu = ({
105
139
  });
106
140
  }
107
141
  }
108
- }, innerMenu());
142
+ }, innerMenu())));
109
143
  };
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Popup } from '@atlaskit/editor-common/ui';
3
3
  import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
4
4
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
5
- import { dragMenuDropdownWidth } from '../consts';
5
+ import { dragMenuDropdownWidth, tablePopupMenuFitHeight } from '../consts';
6
6
  import DragMenu from './DragMenu';
7
7
  const FloatingDragMenu = ({
8
8
  mountPoint,
@@ -17,19 +17,21 @@ const FloatingDragMenu = ({
17
17
  getEditorContainerWidth,
18
18
  editorAnalyticsAPI,
19
19
  stickyHeaders,
20
- pluginConfig
20
+ pluginConfig,
21
+ getEditorFeatureFlags
21
22
  }) => {
22
23
  if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
23
24
  return null;
24
25
  }
25
26
  const inStickyMode = stickyHeaders === null || stickyHeaders === void 0 ? void 0 : stickyHeaders.sticky;
26
27
  const targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
27
- const offset = direction === 'row' ? [-9, 6] : [0, -7];
28
+ const offset = direction === 'row' ? [-9, 0] : [0, -7];
28
29
  if (!targetHandleRef || !(editorView.state.selection instanceof CellSelection)) {
29
30
  return null;
30
31
  }
31
-
32
- // TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
32
+ const {
33
+ tablePreserveWidth = false
34
+ } = getEditorFeatureFlags();
33
35
  return /*#__PURE__*/React.createElement(Popup, {
34
36
  alignX: direction === 'row' ? 'right' : undefined,
35
37
  alignY: direction === 'row' ? 'start' : undefined,
@@ -37,7 +39,8 @@ const FloatingDragMenu = ({
37
39
  mountTo: mountPoint,
38
40
  boundariesElement: boundariesElement,
39
41
  scrollableElement: scrollableElement,
40
- fitWidth: dragMenuDropdownWidth
42
+ fitWidth: dragMenuDropdownWidth,
43
+ fitHeight: tablePopupMenuFitHeight
41
44
  // z-index value below is to ensure that this menu is above other floating menu
42
45
  // in table, but below floating dialogs like typeaheads, pickers, etc.
43
46
  // In sticky mode, we want to show the menu above the sticky header
@@ -56,7 +59,13 @@ const FloatingDragMenu = ({
56
59
  targetCellPosition: targetCellPosition,
57
60
  getEditorContainerWidth: getEditorContainerWidth,
58
61
  editorAnalyticsAPI: editorAnalyticsAPI,
59
- pluginConfig: pluginConfig
62
+ pluginConfig: pluginConfig,
63
+ fitWidth: dragMenuDropdownWidth,
64
+ fitHeight: tablePopupMenuFitHeight,
65
+ mountPoint: mountPoint,
66
+ boundariesElement: boundariesElement,
67
+ scrollableElement: scrollableElement,
68
+ tablePreserveWidth: tablePreserveWidth
60
69
  }));
61
70
  };
62
71
  FloatingDragMenu.displayName = 'FloatingDragMenu';
@@ -177,12 +177,16 @@ export class FloatingInsertButton extends React.Component {
177
177
  getEditorContainerWidth
178
178
  } = this.props;
179
179
  if (typeof insertColumnButtonIndex !== 'undefined') {
180
+ var _this$props$getEditor, _this$props;
180
181
  event.preventDefault();
182
+ const {
183
+ tablePreserveWidth = false
184
+ } = ((_this$props$getEditor = (_this$props = this.props).getEditorFeatureFlags) === null || _this$props$getEditor === void 0 ? void 0 : _this$props$getEditor.call(_this$props)) || {};
181
185
  const {
182
186
  state,
183
187
  dispatch
184
188
  } = editorView;
185
- insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
189
+ insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI, tablePreserveWidth)(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
186
190
  }
187
191
  }
188
192
  }
@@ -56,6 +56,7 @@ export const stickyRowOffsetTop = 8;
56
56
  export const stickyHeaderBorderBottomWidth = 1;
57
57
  export const tableOverflowShadowWidth = 8;
58
58
  export const tableOverflowShadowWidthWide = 32;
59
+ export const tablePopupMenuFitHeight = 188;
59
60
  export const dropTargetsZIndex = 14;
60
61
  export const TABLE_SNAP_GAP = 9;
61
62
  export const TABLE_HIGHLIGHT_GAP = 10;
@@ -3,7 +3,7 @@ import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
3
3
  export const createTableWithWidth = (isFullWidthModeEnabled, getEditorFeatureFlags, createTableProps) => schema => {
4
4
  const {
5
5
  tablePreserveWidth = false
6
- } = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
6
+ } = (getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags()) || {};
7
7
  if (tablePreserveWidth && isFullWidthModeEnabled) {
8
8
  return createTable({
9
9
  schema,
@@ -58,7 +58,7 @@ const defaultSelectionRect = {
58
58
  right: 0,
59
59
  bottom: 0
60
60
  };
61
- export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired) => {
61
+ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired, tablePreserveWidth = false) => {
62
62
  var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
63
63
  const addOptions = direction === 'row' ? [{
64
64
  label: 'above',
@@ -138,7 +138,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
138
138
  moveCursorToInsertedRow: true
139
139
  })(state, dispatch);
140
140
  } else {
141
- insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
141
+ insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI, tablePreserveWidth)(INPUT_METHOD.TABLE_CONTEXT_MENU, (index !== null && index !== void 0 ? index : 0) + offset)(state, dispatch, editorView);
142
142
  }
143
143
  return true;
144
144
  },
@@ -150,7 +150,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
150
150
  onClick: (state, dispatch) => {
151
151
  const selectionRect = getClosestSelectionRect(state);
152
152
  if (selectionRect) {
153
- const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth);
153
+ const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, state, editorView.domAtPos.bind(editorView), getEditorContainerWidth, tablePreserveWidth);
154
154
  if (newResizeState) {
155
155
  distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, newResizeState)(state, dispatch);
156
156
  return true;
@@ -176,7 +176,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
176
176
  if (direction === 'row') {
177
177
  deleteRowsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect, !!isHeaderRowRequired)(state, dispatch);
178
178
  } else {
179
- deleteColumnsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect)(state, dispatch, editorView);
179
+ deleteColumnsWithAnalytics(editorAnalyticsAPI, tablePreserveWidth)(INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect !== null && selectionRect !== void 0 ? selectionRect : defaultSelectionRect)(state, dispatch, editorView);
180
180
  }
181
181
  return true;
182
182
  },
@@ -122,6 +122,7 @@ export var activateNextResizeArea = function activateNextResizeArea(direction) {
122
122
  };
123
123
  };
124
124
  export var changeColumnWidthByStep = function changeColumnWidthByStep(stepSize, getEditorContainerWidth) {
125
+ var tablePreserveWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
125
126
  return function (state, dispatch, view) {
126
127
  var customTr = state.tr;
127
128
  var fakeDispatch = function fakeDispatch(tr) {
@@ -170,14 +171,15 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(stepSize,
170
171
  table: originalTable,
171
172
  tableRef: dom,
172
173
  start: tableStartPosition,
173
- domAtPos: domAtPos
174
+ domAtPos: domAtPos,
175
+ tablePreserveWidth: tablePreserveWidth
174
176
  });
175
177
  updateControls()(state);
176
178
  var selectionRect = getSelectionRect(state.selection);
177
179
  var selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
178
180
  // only selected (or selected - 1) columns should be distributed
179
181
  var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
180
- var newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, resizingSelectedColumns ? selectedColumns : undefined);
182
+ var newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, resizingSelectedColumns ? selectedColumns : undefined, tablePreserveWidth);
181
183
  customTr = updateColumnWidths(newResizeState, originalTable, tableStartPosition)(customTr);
182
184
  if (dispatch) {
183
185
  dispatch(customTr);
@@ -1,8 +1,9 @@
1
1
  import { deleteColumns } from '../transforms/delete-columns';
2
2
  import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
3
3
  export var deleteColumnsCommand = function deleteColumnsCommand(rect) {
4
+ var tablePreserveWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4
5
  return function (state, dispatch, view) {
5
- var tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view)(state.tr);
6
+ var tr = deleteColumns(rect, getAllowAddColumnCustomStep(state), view, tablePreserveWidth)(state.tr);
6
7
  if (dispatch) {
7
8
  dispatch(tr);
8
9
  return true;
@@ -21,6 +21,7 @@ function addColumnAtCustomStep(column) {
21
21
  };
22
22
  }
23
23
  export function addColumnAt(getEditorContainerWidth) {
24
+ var tablePreserveWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
24
25
  return function (column) {
25
26
  var allowAddColumnCustomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
26
27
  var view = arguments.length > 2 ? arguments[2] : undefined;
@@ -34,7 +35,7 @@ export function addColumnAt(getEditorContainerWidth) {
34
35
  var table = findTable(updatedTr.selection);
35
36
  if (table) {
36
37
  // [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
37
- updatedTr = rescaleColumns()(table, view)(updatedTr);
38
+ updatedTr = rescaleColumns(tablePreserveWidth)(table, view)(updatedTr);
38
39
  }
39
40
  if (getBooleanFF('platform.editor.table.analytics-plugin-moved-event') && view) {
40
41
  updatedTr = updateRowOrColumnMovedTransform({
@@ -52,6 +53,7 @@ export function addColumnAt(getEditorContainerWidth) {
52
53
  // :: (EditorState, dispatch: ?(tr: Transaction)) → bool
53
54
  // Command to add a column before the column with the selection.
54
55
  export var addColumnBefore = function addColumnBefore(getEditorContainerWidth) {
56
+ var tablePreserveWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
55
57
  return function (state, dispatch, view) {
56
58
  var table = findTable(state.selection);
57
59
  if (!table) {
@@ -59,7 +61,7 @@ export var addColumnBefore = function addColumnBefore(getEditorContainerWidth) {
59
61
  }
60
62
  if (dispatch) {
61
63
  var rect = selectedRect(state);
62
- dispatch(addColumnAt(getEditorContainerWidth)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
64
+ dispatch(addColumnAt(getEditorContainerWidth, tablePreserveWidth)(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
63
65
  }
64
66
  return true;
65
67
  };
@@ -81,9 +83,10 @@ export var addColumnAfter = function addColumnAfter(getEditorContainerWidth) {
81
83
  };
82
84
  };
83
85
  export var insertColumn = function insertColumn(getEditorContainerWidth) {
86
+ var tablePreserveWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
84
87
  return function (column) {
85
88
  return function (state, dispatch, view) {
86
- var tr = addColumnAt(getEditorContainerWidth)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
89
+ var tr = addColumnAt(getEditorContainerWidth, tablePreserveWidth)(column, getAllowAddColumnCustomStep(state), view)(state.tr);
87
90
  var table = findTable(tr.selection);
88
91
  if (!table) {
89
92
  return false;
@@ -183,6 +183,7 @@ export var insertRowWithAnalytics = function insertRowWithAnalytics(editorAnalyt
183
183
  };
184
184
  };
185
185
  export var insertColumnWithAnalytics = function insertColumnWithAnalytics(getEditorContainerWidth, editorAnalyticsAPI) {
186
+ var tablePreserveWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
186
187
  return function (inputMethod, position) {
187
188
  return withEditorAnalyticsAPI(function (state) {
188
189
  var _getSelectedTableInfo2 = getSelectedTableInfo(state.selection),
@@ -200,7 +201,7 @@ export var insertColumnWithAnalytics = function insertColumnWithAnalytics(getEdi
200
201
  },
201
202
  eventType: EVENT_TYPE.TRACK
202
203
  };
203
- })(editorAnalyticsAPI)(insertColumn(getEditorContainerWidth)(position));
204
+ })(editorAnalyticsAPI)(insertColumn(getEditorContainerWidth, tablePreserveWidth)(position));
204
205
  };
205
206
  };
206
207
  export var deleteRowsWithAnalytics = function deleteRowsWithAnalytics(editorAnalyticsAPI) {
@@ -232,6 +233,7 @@ export var deleteRowsWithAnalytics = function deleteRowsWithAnalytics(editorAnal
232
233
  };
233
234
  };
234
235
  export var deleteColumnsWithAnalytics = function deleteColumnsWithAnalytics(editorAnalyticsAPI) {
236
+ var tablePreserveWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
235
237
  return function (inputMethod, rect) {
236
238
  return withEditorAnalyticsAPI(function (_ref6) {
237
239
  var selection = _ref6.selection;
@@ -251,7 +253,7 @@ export var deleteColumnsWithAnalytics = function deleteColumnsWithAnalytics(edit
251
253
  },
252
254
  eventType: EVENT_TYPE.TRACK
253
255
  };
254
- })(editorAnalyticsAPI)(deleteColumnsCommand(rect));
256
+ })(editorAnalyticsAPI)(deleteColumnsCommand(rect, tablePreserveWidth));
255
257
  };
256
258
  };
257
259
  export var deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = function deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI) {
@@ -328,6 +328,7 @@ export function handleTripleClick(view, pos) {
328
328
  return false;
329
329
  }
330
330
  export var handleCut = function handleCut(oldTr, oldState, newState, editorAnalyticsAPI, editorView) {
331
+ var tablePreserveWidth = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
331
332
  var oldSelection = oldState.tr.selection;
332
333
  var tr = newState.tr;
333
334
  if (oldSelection instanceof CellSelection) {
@@ -370,7 +371,7 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
370
371
  isHeaderRowRequired = _getPluginState9.pluginConfig.isHeaderRowRequired;
371
372
  tr = deleteRows(rect, isHeaderRowRequired)(tr);
372
373
  } else if (tr.selection.isColSelection()) {
373
- tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView)(tr);
374
+ tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView, tablePreserveWidth)(tr);
374
375
  }
375
376
  }
376
377
  }