@atlaskit/editor-plugin-table 5.7.1 → 5.7.3

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 (77) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/nodeviews/TableComponent.js +4 -1
  3. package/dist/cjs/plugin.js +2 -1
  4. package/dist/cjs/pm-plugins/main.js +5 -16
  5. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +0 -4
  6. package/dist/cjs/toolbar.js +87 -14
  7. package/dist/cjs/types.js +0 -2
  8. package/dist/cjs/ui/FloatingDragMenu/index.js +5 -2
  9. package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +3 -3
  10. package/dist/cjs/ui/FloatingInsertButton/index.js +1 -1
  11. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +49 -18
  12. package/dist/cjs/ui/TableFloatingColumnControls/index.js +17 -8
  13. package/dist/cjs/ui/common-styles.js +1 -1
  14. package/dist/cjs/utils/decoration.js +48 -34
  15. package/dist/cjs/utils/dom.js +1 -19
  16. package/dist/cjs/utils/index.js +0 -6
  17. package/dist/es2019/nodeviews/TableComponent.js +5 -2
  18. package/dist/es2019/plugin.js +2 -1
  19. package/dist/es2019/pm-plugins/main.js +1 -12
  20. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +1 -5
  21. package/dist/es2019/toolbar.js +77 -9
  22. package/dist/es2019/types.js +0 -2
  23. package/dist/es2019/ui/FloatingDragMenu/index.js +6 -3
  24. package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +3 -3
  25. package/dist/es2019/ui/FloatingInsertButton/index.js +2 -2
  26. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +42 -12
  27. package/dist/es2019/ui/TableFloatingColumnControls/index.js +18 -9
  28. package/dist/es2019/ui/common-styles.js +6 -1
  29. package/dist/es2019/utils/decoration.js +47 -33
  30. package/dist/es2019/utils/dom.js +0 -18
  31. package/dist/es2019/utils/index.js +1 -1
  32. package/dist/esm/nodeviews/TableComponent.js +5 -2
  33. package/dist/esm/plugin.js +2 -1
  34. package/dist/esm/pm-plugins/main.js +1 -12
  35. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +1 -5
  36. package/dist/esm/toolbar.js +86 -13
  37. package/dist/esm/types.js +0 -2
  38. package/dist/esm/ui/FloatingDragMenu/index.js +6 -3
  39. package/dist/esm/ui/FloatingInsertButton/InsertButton.js +3 -3
  40. package/dist/esm/ui/FloatingInsertButton/index.js +2 -2
  41. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +45 -14
  42. package/dist/esm/ui/TableFloatingColumnControls/index.js +18 -9
  43. package/dist/esm/ui/common-styles.js +2 -2
  44. package/dist/esm/utils/decoration.js +48 -34
  45. package/dist/esm/utils/dom.js +0 -18
  46. package/dist/esm/utils/index.js +1 -1
  47. package/dist/types/toolbar.d.ts +3 -1
  48. package/dist/types/types.d.ts +1 -1
  49. package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -1
  50. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +3 -1
  51. package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -0
  52. package/dist/types/utils/dom.d.ts +0 -1
  53. package/dist/types/utils/index.d.ts +1 -1
  54. package/dist/types-ts4.5/toolbar.d.ts +3 -1
  55. package/dist/types-ts4.5/types.d.ts +1 -1
  56. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -1
  57. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +3 -1
  58. package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -0
  59. package/dist/types-ts4.5/utils/dom.d.ts +0 -1
  60. package/dist/types-ts4.5/utils/index.d.ts +1 -1
  61. package/package.json +8 -8
  62. package/src/nodeviews/TableComponent.tsx +7 -2
  63. package/src/plugin.tsx +1 -0
  64. package/src/pm-plugins/main.ts +0 -18
  65. package/src/pm-plugins/table-resizing/event-handlers.ts +1 -8
  66. package/src/toolbar.tsx +135 -9
  67. package/src/types.ts +1 -2
  68. package/src/ui/FloatingDragMenu/index.tsx +14 -2
  69. package/src/ui/FloatingInsertButton/InsertButton.tsx +6 -2
  70. package/src/ui/FloatingInsertButton/index.tsx +4 -2
  71. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +53 -19
  72. package/src/ui/TableFloatingColumnControls/index.tsx +23 -11
  73. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +0 -10
  74. package/src/ui/common-styles.ts +6 -0
  75. package/src/utils/decoration.ts +41 -28
  76. package/src/utils/dom.ts +0 -23
  77. package/src/utils/index.ts +0 -1
@@ -3,6 +3,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
4
4
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { RowStickyState } from '../../pm-plugins/sticky-headers';
6
7
  import type { TableDirection } from '../../types';
7
8
  export interface Props {
8
9
  editorView: EditorView;
@@ -18,9 +19,10 @@ export interface Props {
18
19
  getEditorContainerWidth: GetEditorContainerWidth;
19
20
  canDrag?: boolean;
20
21
  editorAnalyticsAPI?: EditorAnalyticsAPI;
22
+ stickyHeaders?: RowStickyState;
21
23
  }
22
24
  declare const FloatingDragMenu: {
23
- ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, editorAnalyticsAPI, }: Props): JSX.Element | null;
25
+ ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, editorAnalyticsAPI, stickyHeaders, }: Props): JSX.Element | null;
24
26
  displayName: string;
25
27
  };
26
28
  export default FloatingDragMenu;
@@ -15,6 +15,8 @@ export interface ColumnControlsProps {
15
15
  hasHeaderColumn?: boolean;
16
16
  isTableHovered?: boolean;
17
17
  canDrag?: boolean;
18
+ tableContainerWidth?: number;
19
+ isNumberColumnEnabled?: boolean;
18
20
  }
19
- export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, isResizing, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, canDrag, }: ColumnControlsProps) => JSX.Element;
21
+ export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, isResizing, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, canDrag, tableContainerWidth, isNumberColumnEnabled, }: ColumnControlsProps) => JSX.Element;
20
22
  export default ColumnControls;
@@ -23,6 +23,8 @@ export interface Props {
23
23
  stickyHeader?: RowStickyState;
24
24
  isTableHovered?: boolean;
25
25
  canDrag?: boolean;
26
+ tableContainerWidth?: number;
27
+ isNumberColumnEnabled?: boolean;
26
28
  }
27
29
  export declare const TableFloatingColumnControls: React.FC<Props>;
28
30
  export default TableFloatingColumnControls;
@@ -15,7 +15,6 @@ export declare const isDragColumnFloatingInsertDot: (node: HTMLElement | null) =
15
15
  export declare const isDragCornerButton: (node: HTMLElement | null) => boolean;
16
16
  export declare const getMousePositionHorizontalRelativeByElement: (mouseEvent: MouseEvent, elementContentRects?: ElementContentRects, gapInPixels?: number, isDragAndDropEnabled?: boolean) => 'left' | 'right' | null;
17
17
  export declare const getMousePositionVerticalRelativeByElement: (mouseEvent: MouseEvent) => 'top' | 'bottom' | null;
18
- export declare const updateResizeHandles: (tableRef?: HTMLElement) => void;
19
18
  export declare const hasResizeHandler: ({ columnEndIndexTarget, target, }: {
20
19
  columnEndIndexTarget: number;
21
20
  target: HTMLElement;
@@ -2,7 +2,7 @@ export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, is
2
2
  export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine, } from './decoration';
3
3
  export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow, } from './nodes';
4
4
  export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, } from './paste';
5
- export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint, } from './dom';
5
+ export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint, } from './dom';
6
6
  export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, getColumnIndexMappedToColumnIndexInFirstRow, } from './column-controls';
7
7
  export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow, } from './row-controls';
8
8
  export type { RowParams } from './row-controls';
@@ -2,9 +2,11 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { Command, FloatingToolbarDropdown, FloatingToolbarHandler, FloatingToolbarItem, GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
- import type { Rect } from '@atlaskit/editor-tables/table-map';
5
+ import { Rect } from '@atlaskit/editor-tables/table-map';
6
6
  import type { PluginConfig, ToolbarMenuConfig, ToolbarMenuContext, ToolbarMenuState } from './types';
7
7
  export declare const getToolbarMenuConfig: (config: ToolbarMenuConfig, state: ToolbarMenuState, { formatMessage }: ToolbarMenuContext, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => FloatingToolbarItem<Command>;
8
8
  export declare const getToolbarCellOptionsConfig: (editorState: EditorState, editorView: EditorView | undefined | null, initialSelectionRect: Rect, { formatMessage }: ToolbarMenuContext, getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => FloatingToolbarDropdown<Command>;
9
9
  export declare const getClosestSelectionRect: (state: EditorState) => Rect | undefined;
10
+ export declare const getClosestSelectionOrTableRect: (state: EditorState) => Rect | undefined;
10
11
  export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorFeatureFlags: GetEditorFeatureFlags, getEditorView: () => EditorView | null) => (config: PluginConfig) => FloatingToolbarHandler;
12
+ export declare const getDistributeConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
@@ -322,7 +322,6 @@ export declare const TableCssClassName: {
322
322
  RESIZING_PLUGIN: string;
323
323
  RESIZE_CURSOR: string;
324
324
  IS_RESIZING: string;
325
- RESIZE_HANDLE: string;
326
325
  RESIZE_HANDLE_DECORATION: string;
327
326
  CONTEXTUAL_SUBMENU: string;
328
327
  CONTEXTUAL_MENU_BUTTON_WRAP: string;
@@ -377,6 +376,7 @@ export interface ToolbarMenuState {
377
376
  isNumberColumnEnabled?: boolean;
378
377
  isTableCollapsed?: boolean;
379
378
  canCollapseTable?: boolean;
379
+ isDragAndDropEnabled?: boolean;
380
380
  }
381
381
  export interface ToolbarMenuContext {
382
382
  formatMessage: IntlShape['formatMessage'];
@@ -3,6 +3,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
4
4
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { RowStickyState } from '../../pm-plugins/sticky-headers';
6
7
  import type { TableDirection } from '../../types';
7
8
  export interface Props {
8
9
  editorView: EditorView;
@@ -18,9 +19,10 @@ export interface Props {
18
19
  getEditorContainerWidth: GetEditorContainerWidth;
19
20
  canDrag?: boolean;
20
21
  editorAnalyticsAPI?: EditorAnalyticsAPI;
22
+ stickyHeaders?: RowStickyState;
21
23
  }
22
24
  declare const FloatingDragMenu: {
23
- ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, editorAnalyticsAPI, }: Props): JSX.Element | null;
25
+ ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, editorAnalyticsAPI, stickyHeaders, }: Props): JSX.Element | null;
24
26
  displayName: string;
25
27
  };
26
28
  export default FloatingDragMenu;
@@ -15,6 +15,8 @@ export interface ColumnControlsProps {
15
15
  hasHeaderColumn?: boolean;
16
16
  isTableHovered?: boolean;
17
17
  canDrag?: boolean;
18
+ tableContainerWidth?: number;
19
+ isNumberColumnEnabled?: boolean;
18
20
  }
19
- export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, isResizing, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, canDrag, }: ColumnControlsProps) => JSX.Element;
21
+ export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, isResizing, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, canDrag, tableContainerWidth, isNumberColumnEnabled, }: ColumnControlsProps) => JSX.Element;
20
22
  export default ColumnControls;
@@ -23,6 +23,8 @@ export interface Props {
23
23
  stickyHeader?: RowStickyState;
24
24
  isTableHovered?: boolean;
25
25
  canDrag?: boolean;
26
+ tableContainerWidth?: number;
27
+ isNumberColumnEnabled?: boolean;
26
28
  }
27
29
  export declare const TableFloatingColumnControls: React.FC<Props>;
28
30
  export default TableFloatingColumnControls;
@@ -18,7 +18,6 @@ export declare const isDragColumnFloatingInsertDot: (node: HTMLElement | null) =
18
18
  export declare const isDragCornerButton: (node: HTMLElement | null) => boolean;
19
19
  export declare const getMousePositionHorizontalRelativeByElement: (mouseEvent: MouseEvent, elementContentRects?: ElementContentRects, gapInPixels?: number, isDragAndDropEnabled?: boolean) => 'left' | 'right' | null;
20
20
  export declare const getMousePositionVerticalRelativeByElement: (mouseEvent: MouseEvent) => 'top' | 'bottom' | null;
21
- export declare const updateResizeHandles: (tableRef?: HTMLElement) => void;
22
21
  export declare const hasResizeHandler: ({ columnEndIndexTarget, target, }: {
23
22
  columnEndIndexTarget: number;
24
23
  target: HTMLElement;
@@ -2,7 +2,7 @@ export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, is
2
2
  export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine, } from './decoration';
3
3
  export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow, } from './nodes';
4
4
  export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, } from './paste';
5
- export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint, } from './dom';
5
+ export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint, } from './dom';
6
6
  export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, getColumnIndexMappedToColumnIndexInFirstRow, } from './column-controls';
7
7
  export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow, } from './row-controls';
8
8
  export type { RowParams } from './row-controls';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "5.7.1",
3
+ "version": "5.7.3",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^35.2.0",
32
32
  "@atlaskit/custom-steps": "^0.0.10",
33
- "@atlaskit/editor-common": "^76.29.0",
33
+ "@atlaskit/editor-common": "^76.30.0",
34
34
  "@atlaskit/editor-palette": "1.5.2",
35
35
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
36
36
  "@atlaskit/editor-plugin-content-insertion": "^0.1.0",
@@ -119,9 +119,6 @@
119
119
  "platform.editor.resizing-table-height-improvement": {
120
120
  "type": "boolean"
121
121
  },
122
- "platform.editor.table-remove-update-resize-handles_djvab": {
123
- "type": "boolean"
124
- },
125
122
  "platform.editor.table.increase-shadow-visibility_lh89r": {
126
123
  "type": "boolean"
127
124
  },
@@ -140,14 +137,17 @@
140
137
  "platform.editor.a11y-table-resizing_uapcv": {
141
138
  "type": "boolean"
142
139
  },
143
- "platform.editor.a11y.table-selection_9uv33": {
140
+ "platform.editor.table.new-cell-context-menu-styling": {
144
141
  "type": "boolean"
145
142
  },
146
- "platform.editor.table.new-cell-context-menu-styling": {
143
+ "platform.editor.a11y.table-selection_9uv33": {
147
144
  "type": "boolean"
148
145
  },
149
146
  "platform.editor.menu.group-items": {
150
147
  "type": "boolean"
148
+ },
149
+ "platform.editor.table.in-danger-hover-merged-cells-fix": {
150
+ "type": "boolean"
151
151
  }
152
152
  }
153
- }
153
+ }
@@ -13,7 +13,10 @@ import {
13
13
  } from '@atlaskit/editor-common/analytics';
14
14
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
15
15
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
16
- import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
16
+ import {
17
+ getParentNodeWidth,
18
+ getTableContainerWidth,
19
+ } from '@atlaskit/editor-common/node-width';
17
20
  import { tableMarginSides } from '@atlaskit/editor-common/styles';
18
21
  import type {
19
22
  EditorContainerWidth,
@@ -510,7 +513,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
510
513
  stickyHeader={this.state.stickyHeader}
511
514
  />
512
515
  );
513
-
516
+ const tableContainerWidth = getTableContainerWidth(node);
514
517
  const colControls = isDragAndDropEnabled ? (
515
518
  <TableFloatingColumnControls
516
519
  editorView={view}
@@ -530,6 +533,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
530
533
  stickyHeader={this.state.stickyHeader}
531
534
  canDrag={canDrag}
532
535
  getEditorFeatureFlags={getEditorFeatureFlags}
536
+ tableContainerWidth={tableContainerWidth}
537
+ isNumberColumnEnabled={node.attrs.isNumberColumnEnabled}
533
538
  />
534
539
  ) : null;
535
540
 
package/src/plugin.tsx CHANGED
@@ -515,6 +515,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
515
515
  canDrag={dragAndDropState?.canDrag}
516
516
  getEditorContainerWidth={defaultGetEditorContainerWidth}
517
517
  editorAnalyticsAPI={editorAnalyticsAPI}
518
+ stickyHeaders={stickyHeader}
518
519
  />
519
520
  )}
520
521
  {allowControls && !isDragAndDropEnabled && !isResizing && (
@@ -37,8 +37,6 @@ import {
37
37
  findParentNodeOfType,
38
38
  } from '@atlaskit/editor-prosemirror/utils';
39
39
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
40
- import { findTable } from '@atlaskit/editor-tables/utils';
41
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
42
40
 
43
41
  import {
44
42
  addBoldInEmptyHeaderCells,
@@ -83,7 +81,6 @@ import {
83
81
  transformSliceToCorrectEmptyTableCells,
84
82
  transformSliceToFixHardBreakProblemOnCopyFromCell,
85
83
  transformSliceToRemoveOpenTable,
86
- updateResizeHandles,
87
84
  } from '../utils';
88
85
  import { isHeaderRowRequired } from '../utils/paste';
89
86
 
@@ -209,7 +206,6 @@ export const createPlugin = (
209
206
  const { selection } = state;
210
207
  const pluginState = getPluginState(state);
211
208
  let tableRef: HTMLTableElement | undefined;
212
- let tableNode;
213
209
  if (pluginState.editorHasFocus) {
214
210
  const parent = findParentDomRefOfType(
215
211
  state.schema.nodes.table,
@@ -221,26 +217,12 @@ export const createPlugin = (
221
217
  'table',
222
218
  ) || undefined;
223
219
  }
224
-
225
- tableNode = findTable(state.selection);
226
220
  }
227
221
 
228
222
  if (pluginState.tableRef !== tableRef) {
229
223
  setTableRef(tableRef)(state, dispatch);
230
224
  }
231
225
 
232
- // Removes updateResizeHandles
233
- if (
234
- getBooleanFF(
235
- 'platform.editor.table-remove-update-resize-handles_djvab',
236
- )
237
- ) {
238
- } else {
239
- if (pluginState.tableNode !== tableNode) {
240
- updateResizeHandles(tableRef);
241
- }
242
- }
243
-
244
226
  if (pluginState.editorHasFocus && pluginState.tableRef) {
245
227
  const { $cursor } = state.selection as TextSelection;
246
228
  if ($cursor) {
@@ -20,7 +20,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
20
20
 
21
21
  import { updateResizeHandleDecorations } from '../../commands/misc';
22
22
  import { updateColumnWidths } from '../../transforms';
23
- import { getSelectedColumnIndexes, updateResizeHandles } from '../../utils';
23
+ import { getSelectedColumnIndexes } from '../../utils';
24
24
  import { META_KEYS } from '../table-analytics';
25
25
 
26
26
  import { evenColumns, setDragging, stopResizing } from './commands';
@@ -228,13 +228,6 @@ export const handleMouseDown = (
228
228
  resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom);
229
229
 
230
230
  updateControls()(state);
231
- // Remove updateResizeHandles
232
- if (
233
- getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')
234
- ) {
235
- } else {
236
- updateResizeHandles(dom);
237
- }
238
231
  }
239
232
 
240
233
  window.addEventListener('mouseup', finish);
package/src/toolbar.tsx CHANGED
@@ -40,7 +40,7 @@ import { findParentDomRefOfType } from '@atlaskit/editor-prosemirror/utils';
40
40
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
41
41
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
42
42
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
43
- import type { Rect } from '@atlaskit/editor-tables/table-map';
43
+ import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
44
44
  import {
45
45
  findCellRectClosestToPos,
46
46
  findTable,
@@ -48,7 +48,10 @@ import {
48
48
  isSelectionType,
49
49
  splitCell,
50
50
  } from '@atlaskit/editor-tables/utils';
51
+ import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
51
52
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
53
+ import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
54
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
52
55
 
53
56
  import {
54
57
  clearHoverSelection,
@@ -131,14 +134,29 @@ export const getToolbarMenuConfig = (
131
134
  },
132
135
  ];
133
136
 
134
- return {
135
- id: 'editor.table.tableOptions',
136
- type: 'dropdown',
137
- testId: 'table_options',
138
- title: formatMessage(messages.tableOptions),
139
- hidden: options.every((option) => option.hidden),
140
- options,
141
- };
137
+ if (
138
+ state.isDragAndDropEnabled &&
139
+ getBooleanFF('platform.editor.table.new-cell-context-menu-styling')
140
+ ) {
141
+ return {
142
+ id: 'editor.table.tableOptions',
143
+ type: 'dropdown',
144
+ testId: 'table_options',
145
+ icon: TableOptionsIcon,
146
+ title: formatMessage(messages.tableOptions),
147
+ hidden: options.every((option) => option.hidden),
148
+ options,
149
+ };
150
+ } else {
151
+ return {
152
+ id: 'editor.table.tableOptions',
153
+ type: 'dropdown',
154
+ testId: 'table_options',
155
+ title: formatMessage(messages.tableOptions),
156
+ hidden: options.every((option) => option.hidden),
157
+ options,
158
+ };
159
+ }
142
160
  };
143
161
 
144
162
  // Added these options for mobile. Mobile bridge translates this menu and
@@ -399,6 +417,22 @@ export const getClosestSelectionRect = (
399
417
  : findCellRectClosestToPos(selection.$from);
400
418
  };
401
419
 
420
+ export const getClosestSelectionOrTableRect = (
421
+ state: EditorState,
422
+ ): Rect | undefined => {
423
+ const selection = state.selection;
424
+ const tableObject = findTable(state.selection);
425
+ if (!tableObject) {
426
+ return;
427
+ }
428
+ const map = TableMap.get(tableObject.node);
429
+ const tableRect = new Rect(0, 0, map.width, map.height);
430
+
431
+ return isSelectionType(selection, 'cell')
432
+ ? getSelectionRect(selection)!
433
+ : tableRect;
434
+ };
435
+
402
436
  export const getToolbarConfig =
403
437
  (
404
438
  getEditorContainerWidth: GetEditorContainerWidth,
@@ -436,6 +470,19 @@ export const getToolbarConfig =
436
470
  getEditorContainerWidth,
437
471
  editorAnalyticsAPI,
438
472
  );
473
+
474
+ let columnSettingsItems;
475
+ columnSettingsItems =
476
+ pluginState.isDragAndDropEnabled &&
477
+ getBooleanFF('platform.editor.table.new-cell-context-menu-styling')
478
+ ? getColumnSettingItems(
479
+ state,
480
+ getEditorView(),
481
+ intl,
482
+ getEditorContainerWidth,
483
+ editorAnalyticsAPI,
484
+ )
485
+ : [];
439
486
  const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
440
487
 
441
488
  // Check if we need to show confirm dialog for delete button
@@ -502,6 +549,7 @@ export const getToolbarConfig =
502
549
  menu,
503
550
  separator(menu.hidden),
504
551
  ...cellItems,
552
+ ...columnSettingsItems,
505
553
  ...colorPicker,
506
554
  {
507
555
  type: 'extensions-placeholder',
@@ -574,6 +622,84 @@ const getCellItems = (
574
622
  return [];
575
623
  };
576
624
 
625
+ export const getDistributeConfig =
626
+ (
627
+ getEditorContainerWidth: GetEditorContainerWidth,
628
+ editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
629
+ ): Command =>
630
+ (state, dispatch, editorView) => {
631
+ const selectionOrTableRect = getClosestSelectionOrTableRect(state);
632
+ if (!editorView || !selectionOrTableRect) {
633
+ return false;
634
+ }
635
+ const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(
636
+ selectionOrTableRect,
637
+ state,
638
+ editorView.domAtPos.bind(editorView),
639
+ getEditorContainerWidth,
640
+ );
641
+
642
+ if (newResizeStateWithAnalytics) {
643
+ distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(
644
+ INPUT_METHOD.FLOATING_TB,
645
+ newResizeStateWithAnalytics,
646
+ )(state, dispatch);
647
+ return true;
648
+ }
649
+ return false;
650
+ };
651
+
652
+ // this create the button group for distribute column and also fixed column width
653
+ // fixed column button should be in this function call in the future
654
+ const getColumnSettingItems = (
655
+ editorState: EditorState,
656
+ editorView: EditorView | undefined | null,
657
+ { formatMessage }: ToolbarMenuContext,
658
+ getEditorContainerWidth: GetEditorContainerWidth,
659
+ editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
660
+ ): Array<FloatingToolbarItem<Command>> => {
661
+ const pluginState = getPluginState(editorState);
662
+ const selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
663
+
664
+ if (!selectionOrTableRect || !editorView) {
665
+ return [];
666
+ }
667
+
668
+ const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(
669
+ selectionOrTableRect,
670
+ editorState,
671
+ editorView.domAtPos.bind(editorView),
672
+ getEditorContainerWidth,
673
+ );
674
+
675
+ const wouldChange = newResizeStateWithAnalytics?.changed ?? false;
676
+
677
+ if (
678
+ pluginState?.pluginConfig?.allowDistributeColumns &&
679
+ pluginState.isDragAndDropEnabled
680
+ ) {
681
+ return [
682
+ {
683
+ id: 'editor.table.distributeColumns',
684
+ type: 'button',
685
+ title: formatMessage(messages.distributeColumns),
686
+ icon: DistributeColumnIcon,
687
+ onClick: (state, dispatch, view) =>
688
+ getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI)(
689
+ state,
690
+ dispatch,
691
+ view,
692
+ ),
693
+ disabled: !wouldChange,
694
+ },
695
+ {
696
+ type: 'separator',
697
+ },
698
+ ];
699
+ }
700
+ return [];
701
+ };
702
+
577
703
  const getColorPicker = (
578
704
  state: EditorState,
579
705
  menu: FloatingToolbarItem<Command>,
package/src/types.ts CHANGED
@@ -359,8 +359,6 @@ export const TableCssClassName = {
359
359
  RESIZE_CURSOR: `${tablePrefixSelector}-resize-cursor`,
360
360
  IS_RESIZING: `${tablePrefixSelector}-is-resizing`,
361
361
 
362
- // Resize handle is going to be removed together with updateResizeHandles - table's utility function
363
- RESIZE_HANDLE: `${tablePrefixSelector}-resize-handle`,
364
362
  RESIZE_HANDLE_DECORATION: `${tablePrefixSelector}-resize-decoration`,
365
363
 
366
364
  CONTEXTUAL_SUBMENU: `${tablePrefixSelector}-contextual-submenu`,
@@ -408,6 +406,7 @@ export interface ToolbarMenuState {
408
406
  isNumberColumnEnabled?: boolean;
409
407
  isTableCollapsed?: boolean;
410
408
  canCollapseTable?: boolean;
409
+ isDragAndDropEnabled?: boolean;
411
410
  }
412
411
 
413
412
  export interface ToolbarMenuContext {
@@ -5,9 +5,13 @@ import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
5
5
  import { Popup } from '@atlaskit/editor-common/ui';
6
6
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
7
7
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
- import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
8
+ import {
9
+ akEditorFloatingDialogZIndex,
10
+ akEditorFloatingOverlapPanelZIndex,
11
+ } from '@atlaskit/editor-shared-styles';
9
12
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
10
13
 
14
+ import type { RowStickyState } from '../../pm-plugins/sticky-headers';
11
15
  import type { TableDirection } from '../../types';
12
16
  import { dragMenuDropdownWidth } from '../consts';
13
17
 
@@ -27,6 +31,7 @@ export interface Props {
27
31
  getEditorContainerWidth: GetEditorContainerWidth;
28
32
  canDrag?: boolean;
29
33
  editorAnalyticsAPI?: EditorAnalyticsAPI;
34
+ stickyHeaders?: RowStickyState;
30
35
  }
31
36
 
32
37
  const FloatingDragMenu = ({
@@ -42,6 +47,7 @@ const FloatingDragMenu = ({
42
47
  getEditorContainerWidth,
43
48
  canDrag,
44
49
  editorAnalyticsAPI,
50
+ stickyHeaders,
45
51
  }: Props) => {
46
52
  if (
47
53
  !isOpen ||
@@ -50,6 +56,7 @@ const FloatingDragMenu = ({
50
56
  ) {
51
57
  return null;
52
58
  }
59
+ const inStickyMode = stickyHeaders?.sticky;
53
60
 
54
61
  const targetHandleRef =
55
62
  direction === 'row'
@@ -77,7 +84,12 @@ const FloatingDragMenu = ({
77
84
  fitWidth={dragMenuDropdownWidth}
78
85
  // z-index value below is to ensure that this menu is above other floating menu
79
86
  // in table, but below floating dialogs like typeaheads, pickers, etc.
80
- zIndex={akEditorFloatingOverlapPanelZIndex}
87
+ // In sticky mode, we want to show the menu above the sticky header
88
+ zIndex={
89
+ inStickyMode
90
+ ? akEditorFloatingDialogZIndex
91
+ : akEditorFloatingOverlapPanelZIndex
92
+ }
81
93
  forcePlacement={true}
82
94
  offset={offset}
83
95
  stick={true}
@@ -32,6 +32,7 @@ export interface ButtonProps {
32
32
  const getInsertLineHeight = (
33
33
  tableRef: HTMLElement,
34
34
  hasStickyHeaders: boolean,
35
+ isDragAndDropEnabled?: boolean,
35
36
  ) => {
36
37
  // The line gets height 100% from the table,
37
38
  // but since we have an overflow on the left,
@@ -39,7 +40,9 @@ const getInsertLineHeight = (
39
40
  const LINE_OFFSET = 3;
40
41
 
41
42
  const ADDITIONAL_HEIGHT = hasStickyHeaders
42
- ? tableRef.getBoundingClientRect().top - tableMarginTop * 4 - LINE_OFFSET
43
+ ? tableRef.getBoundingClientRect().top -
44
+ tableMarginTop * (isDragAndDropEnabled ? 3 : 4) -
45
+ LINE_OFFSET
43
46
  : tableToolbarSize + LINE_OFFSET;
44
47
  return tableRef.offsetHeight + ADDITIONAL_HEIGHT;
45
48
  };
@@ -140,7 +143,8 @@ export const InsertButtonForDragAndDrop = ({
140
143
  left: token('space.150', '12px'),
141
144
  }
142
145
  : {
143
- height: getInsertLineHeight(tableRef, hasStickyHeaders) - 8,
146
+ height:
147
+ getInsertLineHeight(tableRef, hasStickyHeaders, true) - 8,
144
148
  top: '-3px',
145
149
  }
146
150
  }
@@ -21,7 +21,7 @@ import { closestElement } from '@atlaskit/editor-common/utils';
21
21
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
22
22
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
23
23
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
24
- import { akEditorTableCellOnStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
24
+ import { akEditorTableInsertButtonOnStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
25
25
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
26
26
  import { TableMap } from '@atlaskit/editor-tables/table-map';
27
27
  import { findTable } from '@atlaskit/editor-tables/utils';
@@ -192,7 +192,9 @@ export class FloatingInsertButton extends React.Component<
192
192
  // Only when inserting a column, otherwise set to undefined
193
193
  // Need to set z-index in the Popup, set z-index in the <InsertButton /> will not work
194
194
  const zIndex: number | undefined =
195
- type === 'column' ? akEditorTableCellOnStickyHeaderZIndex : undefined;
195
+ type === 'column'
196
+ ? akEditorTableInsertButtonOnStickyHeaderZIndex
197
+ : undefined;
196
198
 
197
199
  return (
198
200
  <Popup