@atlaskit/editor-plugin-table 7.4.7 → 7.4.9

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 (58) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/commands/insert.js +5 -12
  3. package/dist/cjs/plugin.js +17 -11
  4. package/dist/cjs/pm-plugins/table-width.js +53 -34
  5. package/dist/cjs/ui/FloatingContextualMenu/index.js +1 -1
  6. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +13 -3
  7. package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +53 -8
  8. package/dist/cjs/ui/FloatingDragMenu/index.js +9 -5
  9. package/dist/cjs/ui/consts.js +2 -1
  10. package/dist/cjs/utils/create.js +28 -0
  11. package/dist/cjs/utils/index.js +8 -1
  12. package/dist/es2019/commands/insert.js +7 -14
  13. package/dist/es2019/plugin.js +16 -10
  14. package/dist/es2019/pm-plugins/table-width.js +133 -114
  15. package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -2
  16. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +13 -3
  17. package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +42 -8
  18. package/dist/es2019/ui/FloatingDragMenu/index.js +10 -6
  19. package/dist/es2019/ui/consts.js +1 -0
  20. package/dist/es2019/utils/create.js +18 -0
  21. package/dist/es2019/utils/index.js +2 -1
  22. package/dist/esm/commands/insert.js +7 -14
  23. package/dist/esm/plugin.js +16 -10
  24. package/dist/esm/pm-plugins/table-width.js +53 -34
  25. package/dist/esm/ui/FloatingContextualMenu/index.js +2 -2
  26. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +13 -3
  27. package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +50 -9
  28. package/dist/esm/ui/FloatingDragMenu/index.js +10 -6
  29. package/dist/esm/ui/consts.js +1 -0
  30. package/dist/esm/utils/create.js +21 -0
  31. package/dist/esm/utils/index.js +2 -1
  32. package/dist/types/commands/insert.d.ts +3 -3
  33. package/dist/types/plugin.d.ts +4 -0
  34. package/dist/types/pm-plugins/table-width.d.ts +2 -1
  35. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +6 -1
  36. package/dist/types/ui/FloatingDragMenu/DropdownMenu.d.ts +8 -2
  37. package/dist/types/ui/consts.d.ts +1 -0
  38. package/dist/types/utils/create.d.ts +6 -0
  39. package/dist/types/utils/index.d.ts +1 -0
  40. package/dist/types-ts4.5/commands/insert.d.ts +3 -3
  41. package/dist/types-ts4.5/plugin.d.ts +4 -0
  42. package/dist/types-ts4.5/pm-plugins/table-width.d.ts +2 -1
  43. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +6 -1
  44. package/dist/types-ts4.5/ui/FloatingDragMenu/DropdownMenu.d.ts +8 -2
  45. package/dist/types-ts4.5/ui/consts.d.ts +1 -0
  46. package/dist/types-ts4.5/utils/create.d.ts +6 -0
  47. package/dist/types-ts4.5/utils/index.d.ts +1 -0
  48. package/package.json +2 -2
  49. package/src/commands/insert.ts +35 -19
  50. package/src/plugin.tsx +32 -9
  51. package/src/pm-plugins/table-width.ts +71 -38
  52. package/src/ui/FloatingContextualMenu/index.tsx +2 -1
  53. package/src/ui/FloatingDragMenu/DragMenu.tsx +16 -1
  54. package/src/ui/FloatingDragMenu/DropdownMenu.tsx +94 -50
  55. package/src/ui/FloatingDragMenu/index.tsx +8 -3
  56. package/src/ui/consts.ts +1 -0
  57. package/src/utils/create.ts +32 -0
  58. package/src/utils/index.ts +1 -0
@@ -13,7 +13,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
13
13
 
14
14
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
15
15
  import type { PluginConfig, TableDirection } from '../../types';
16
- import { dragMenuDropdownWidth } from '../consts';
16
+ import { dragMenuDropdownWidth, tablePopupMenuFitHeight } from '../consts';
17
17
 
18
18
  import DragMenu from './DragMenu';
19
19
 
@@ -63,7 +63,7 @@ const FloatingDragMenu = ({
63
63
  ? document.querySelector('#drag-handle-button-row')
64
64
  : document.querySelector('#drag-handle-button-column');
65
65
 
66
- const offset = direction === 'row' ? [-9, 6] : [0, -7];
66
+ const offset = direction === 'row' ? [-9, 0] : [0, -7];
67
67
 
68
68
  if (
69
69
  !targetHandleRef ||
@@ -72,7 +72,6 @@ const FloatingDragMenu = ({
72
72
  return null;
73
73
  }
74
74
 
75
- // TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
76
75
  return (
77
76
  <Popup
78
77
  alignX={direction === 'row' ? 'right' : undefined}
@@ -82,6 +81,7 @@ const FloatingDragMenu = ({
82
81
  boundariesElement={boundariesElement}
83
82
  scrollableElement={scrollableElement}
84
83
  fitWidth={dragMenuDropdownWidth}
84
+ fitHeight={tablePopupMenuFitHeight}
85
85
  // z-index value below is to ensure that this menu is above other floating menu
86
86
  // in table, but below floating dialogs like typeaheads, pickers, etc.
87
87
  // In sticky mode, we want to show the menu above the sticky header
@@ -105,6 +105,11 @@ const FloatingDragMenu = ({
105
105
  getEditorContainerWidth={getEditorContainerWidth}
106
106
  editorAnalyticsAPI={editorAnalyticsAPI}
107
107
  pluginConfig={pluginConfig}
108
+ fitWidth={dragMenuDropdownWidth}
109
+ fitHeight={tablePopupMenuFitHeight}
110
+ mountPoint={mountPoint}
111
+ boundariesElement={boundariesElement}
112
+ scrollableElement={scrollableElement}
108
113
  />
109
114
  </Popup>
110
115
  );
package/src/ui/consts.ts CHANGED
@@ -125,6 +125,7 @@ export const stickyRowOffsetTop = 8;
125
125
  export const stickyHeaderBorderBottomWidth = 1;
126
126
  export const tableOverflowShadowWidth = 8;
127
127
  export const tableOverflowShadowWidthWide = 32;
128
+ export const tablePopupMenuFitHeight = 188;
128
129
 
129
130
  export const dropTargetsZIndex = 14;
130
131
 
@@ -0,0 +1,32 @@
1
+ import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
2
+ import type { Schema } from '@atlaskit/editor-prosemirror/model';
3
+ import { createTable } from '@atlaskit/editor-tables/utils';
4
+
5
+ import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
6
+
7
+ export const createTableWithWidth =
8
+ (
9
+ isFullWidthModeEnabled?: boolean,
10
+ getEditorFeatureFlags?: GetEditorFeatureFlags,
11
+ createTableProps?: {
12
+ rowsCount?: number;
13
+ colsCount?: number;
14
+ },
15
+ ) =>
16
+ (schema: Schema) => {
17
+ const { tablePreserveWidth = false } = getEditorFeatureFlags
18
+ ? getEditorFeatureFlags()
19
+ : {};
20
+
21
+ if (tablePreserveWidth && isFullWidthModeEnabled) {
22
+ return createTable({
23
+ schema,
24
+ tableWidth: TABLE_MAX_WIDTH,
25
+ ...createTableProps,
26
+ });
27
+ }
28
+ return createTable({
29
+ schema,
30
+ ...createTableProps,
31
+ });
32
+ };
@@ -86,3 +86,4 @@ export {
86
86
  findDuplicatePosition,
87
87
  checkEdgeHasMergedCells,
88
88
  } from './merged-cells';
89
+ export { createTableWithWidth } from './create';