@atlaskit/editor-plugin-table 9.1.3 → 9.2.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 (49) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/nodeviews/TableComponent.js +5 -5
  3. package/dist/cjs/nodeviews/TableComponentWithSharedState.js +6 -4
  4. package/dist/cjs/nodeviews/table.js +1 -2
  5. package/dist/cjs/tablePlugin.js +1 -0
  6. package/dist/cjs/ui/DragHandle/index.js +55 -6
  7. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +17 -2
  8. package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -2
  9. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +60 -7
  10. package/dist/cjs/ui/TableFloatingControls/index.js +24 -4
  11. package/dist/es2019/nodeviews/TableComponent.js +5 -5
  12. package/dist/es2019/nodeviews/TableComponentWithSharedState.js +6 -4
  13. package/dist/es2019/nodeviews/table.js +1 -2
  14. package/dist/es2019/tablePlugin.js +1 -0
  15. package/dist/es2019/ui/DragHandle/index.js +57 -6
  16. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +18 -3
  17. package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -2
  18. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +62 -7
  19. package/dist/es2019/ui/TableFloatingControls/index.js +25 -5
  20. package/dist/esm/nodeviews/TableComponent.js +5 -5
  21. package/dist/esm/nodeviews/TableComponentWithSharedState.js +6 -4
  22. package/dist/esm/nodeviews/table.js +1 -2
  23. package/dist/esm/tablePlugin.js +1 -0
  24. package/dist/esm/ui/DragHandle/index.js +54 -5
  25. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +18 -3
  26. package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -2
  27. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +60 -7
  28. package/dist/esm/ui/TableFloatingControls/index.js +25 -5
  29. package/dist/types/nodeviews/TableComponent.d.ts +3 -1
  30. package/dist/types/types/index.d.ts +1 -1
  31. package/dist/types/ui/DragHandle/index.d.ts +21 -0
  32. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -1
  33. package/dist/types/ui/TableFloatingControls/RowControls/DragControls.d.ts +8 -5
  34. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +3 -1
  35. package/dist/types-ts4.5/types/index.d.ts +1 -1
  36. package/dist/types-ts4.5/ui/DragHandle/index.d.ts +21 -0
  37. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -1
  38. package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/DragControls.d.ts +8 -5
  39. package/package.json +8 -5
  40. package/src/nodeviews/TableComponent.tsx +9 -7
  41. package/src/nodeviews/TableComponentWithSharedState.tsx +4 -2
  42. package/src/nodeviews/table.tsx +1 -2
  43. package/src/tablePlugin.tsx +1 -0
  44. package/src/types/index.ts +1 -0
  45. package/src/ui/DragHandle/index.tsx +67 -2
  46. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +38 -19
  47. package/src/ui/TableFloatingColumnControls/index.tsx +2 -5
  48. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +86 -25
  49. package/src/ui/TableFloatingControls/index.tsx +54 -27
@@ -2,6 +2,7 @@ import React, { useCallback } from 'react';
2
2
  import { browser } from '@atlaskit/editor-common/browser';
3
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
4
  import { findTable } from '@atlaskit/editor-tables/utils';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
7
  import { hoverCell, hoverRows, selectRow, selectRows } from '../../pm-plugins/commands';
7
8
  import { isTableNested } from '../../pm-plugins/utils/nodes';
@@ -11,7 +12,8 @@ import { DragCornerControls, DragCornerControlsWithSelection } from './CornerCon
11
12
  import { FloatingControlsWithSelection } from './FloatingControlsWithSelection';
12
13
  import NumberColumn from './NumberColumn';
13
14
  import { RowControls } from './RowControls/ClassicControls';
14
- import { DragControls } from './RowControls/DragControls';
15
+ import { DragControls, DragControlsWithSelection } from './RowControls/DragControls';
16
+ // Row controls
15
17
  export var TableFloatingControls = function TableFloatingControls(_ref) {
16
18
  var _findTable;
17
19
  var editorView = _ref.editorView,
@@ -106,18 +108,36 @@ export var TableFloatingControls = function TableFloatingControls(_ref) {
106
108
  updateCellHoverLocation: updateCellHoverLocation,
107
109
  stickyTop: stickyTop,
108
110
  isDragAndDropEnabled: isDragAndDropEnabled
109
- }) : null, tableActive && /*#__PURE__*/React.createElement(React.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/React.createElement(React.Fragment, null, shouldShowCornerControls && (editorExperiment('platform_editor_table_use_shared_state_hook', true) ? /*#__PURE__*/React.createElement(DragCornerControlsWithSelection, {
111
+ }) : null, tableActive && /*#__PURE__*/React.createElement(React.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/React.createElement(React.Fragment, null, fg('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/React.createElement(React.Fragment, null, shouldShowCornerControls && /*#__PURE__*/React.createElement(DragCornerControlsWithSelection, {
110
112
  editorView: editorView,
111
113
  tableRef: tableRef,
112
114
  isInDanger: isInDanger,
113
115
  isResizing: isResizing,
114
116
  api: api
115
- }) : /*#__PURE__*/React.createElement(DragCornerControls, {
117
+ }), /*#__PURE__*/React.createElement(DragControlsWithSelection, {
118
+ tableRef: tableRef,
119
+ tableNode: tableNode,
120
+ hoveredCell: hoveredCell,
121
+ isTableHovered: isTableHovered,
122
+ editorView: editorView,
123
+ tableActive: tableActive,
124
+ isInDanger: isInDanger,
125
+ isResizing: isResizing
126
+ // Ignored via go/ees005
127
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
128
+ ,
129
+ tableWidth: tableWrapperWidth,
130
+ hoverRows: _hoverRows,
131
+ selectRow: _selectRow,
132
+ selectRows: _selectRows,
133
+ updateCellHoverLocation: updateCellHoverLocation,
134
+ api: api
135
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, shouldShowCornerControls && /*#__PURE__*/React.createElement(DragCornerControls, {
116
136
  editorView: editorView,
117
137
  tableRef: tableRef,
118
138
  isInDanger: isInDanger,
119
139
  isResizing: isResizing
120
- })), /*#__PURE__*/React.createElement(DragControls, {
140
+ }), /*#__PURE__*/React.createElement(DragControls, {
121
141
  tableRef: tableRef,
122
142
  tableNode: tableNode,
123
143
  hoveredCell: hoveredCell,
@@ -134,7 +154,7 @@ export var TableFloatingControls = function TableFloatingControls(_ref) {
134
154
  selectRow: _selectRow,
135
155
  selectRows: _selectRows,
136
156
  updateCellHoverLocation: updateCellHoverLocation
137
- })) : editorExperiment('platform_editor_table_use_shared_state_hook', true) ? /*#__PURE__*/React.createElement(FloatingControlsWithSelection, {
157
+ }))) : fg('platform_editor_table_use_shared_state_hook_fg') ? /*#__PURE__*/React.createElement(FloatingControlsWithSelection, {
138
158
  editorView: editorView,
139
159
  tableRef: tableRef,
140
160
  isInDanger: isInDanger,
@@ -5,6 +5,7 @@ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
5
5
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
6
6
  import type { EditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
7
7
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
8
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
8
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
10
  import type { CellHoverMeta, PluginInjectionAPI } from '../types';
10
11
  import type { TableOptions } from './types';
@@ -17,7 +18,7 @@ interface ComponentProps {
17
18
  options?: TableOptions;
18
19
  contentDOM: (node: HTMLElement | null) => void;
19
20
  containerWidth: EditorContainerWidth;
20
- allowControls: boolean;
21
+ allowControls?: boolean;
21
22
  allowTableResizing?: boolean;
22
23
  allowTableAlignment?: boolean;
23
24
  isHeaderRowEnabled: boolean;
@@ -37,6 +38,7 @@ interface ComponentProps {
37
38
  hoveredCell?: CellHoverMeta;
38
39
  isTableHovered?: boolean;
39
40
  isWholeTableInDanger?: boolean;
41
+ selection?: Selection;
40
42
  }
41
43
  declare const _default: React.FC<import("react-intl-next").WithIntlProps<ComponentProps>> & {
42
44
  WrappedComponent: React.ComponentType<ComponentProps>;
@@ -33,7 +33,7 @@ export type PluginInjectionAPIWithA11y = ExtractInjectionAPI<TablePlugin> & {
33
33
  };
34
34
  };
35
35
  };
36
- export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
36
+ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredColumns' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
37
37
  isResizing: boolean;
38
38
  isTableResizing?: boolean;
39
39
  isWholeTableInDanger?: boolean;
@@ -20,8 +20,29 @@ type DragHandleProps = {
20
20
  toggleDragMenu?: (trigger: TriggerType, event?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
21
21
  editorView: EditorView;
22
22
  isDragMenuTarget: boolean;
23
+ hoveredColumns?: number[];
24
+ hoveredRows?: number[];
23
25
  };
24
26
  export declare const DragHandle: React.FC<import("react-intl-next").WithIntlProps<DragHandleProps & WrappedComponentProps>> & {
25
27
  WrappedComponent: React.ComponentType<DragHandleProps & WrappedComponentProps>;
26
28
  };
29
+ export declare const DragHandleWithSharedState: React.FC<import("react-intl-next").WithIntlProps<DragHandleProps & {
30
+ api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"table", {
31
+ pluginConfiguration: import("../../tablePluginType").TablePluginOptions | undefined;
32
+ actions: import("../../tablePluginType").TablePluginActions;
33
+ sharedState?: import("../../types").TableSharedState | undefined;
34
+ commands: import("../../tablePluginType").TablePluginCommands;
35
+ dependencies: import("../../tablePluginType").TablePluginDependencies;
36
+ }> | undefined;
37
+ } & WrappedComponentProps>> & {
38
+ WrappedComponent: React.ComponentType<DragHandleProps & {
39
+ api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"table", {
40
+ pluginConfiguration: import("../../tablePluginType").TablePluginOptions | undefined;
41
+ actions: import("../../tablePluginType").TablePluginActions;
42
+ sharedState?: import("../../types").TableSharedState | undefined;
43
+ commands: import("../../tablePluginType").TablePluginCommands;
44
+ dependencies: import("../../tablePluginType").TablePluginDependencies;
45
+ }> | undefined;
46
+ } & WrappedComponentProps>;
47
+ };
27
48
  export {};
@@ -20,7 +20,7 @@ interface ColumnControlsProps {
20
20
  isDragging?: boolean;
21
21
  getScrollOffset?: () => number;
22
22
  }
23
- export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, tableContainerWidth, isNumberColumnEnabled, isDragging, getScrollOffset, api, }: ColumnControlsProps & {
23
+ export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, stickyTop, localId, isInDanger, rowHeights, colWidths, isTableHovered, tableContainerWidth, isNumberColumnEnabled, isDragging, getScrollOffset, api, }: ColumnControlsProps & {
24
24
  api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"table", {
25
25
  pluginConfiguration: import("../../../tablePluginType").TablePluginOptions | undefined;
26
26
  actions: import("../../../tablePluginType").TablePluginActions;
@@ -1,7 +1,9 @@
1
- import React from 'react';
2
- import type { WrappedComponentProps } from 'react-intl-next';
1
+ /// <reference types="react" />
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
4
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { TablePlugin } from '../../../tablePluginType';
5
7
  import type { CellHoverMeta } from '../../../types';
6
8
  type DragControlsProps = {
7
9
  editorView: EditorView;
@@ -17,8 +19,9 @@ type DragControlsProps = {
17
19
  selectRow: (row: number, expand: boolean) => void;
18
20
  selectRows: (rowIndexes: number[]) => void;
19
21
  updateCellHoverLocation: (rowIndex: number) => void;
22
+ api?: ExtractInjectionAPI<TablePlugin>;
23
+ selection?: Selection;
20
24
  };
21
- export declare const DragControls: React.FC<import("react-intl-next").WithIntlProps<DragControlsProps & WrappedComponentProps>> & {
22
- WrappedComponent: React.ComponentType<DragControlsProps & WrappedComponentProps>;
23
- };
25
+ export declare const DragControls: ({ tableRef, tableNode, tableWidth, hoveredCell, tableActive, editorView, isInDanger, isResizing, isTableHovered, hoverRows, selectRow, selectRows, updateCellHoverLocation, api, selection, }: DragControlsProps) => JSX.Element | null;
26
+ export declare const DragControlsWithSelection: ({ editorView, tableRef, tableNode, tableWidth, tableActive, hoveredCell, isInDanger, isTableHovered, isResizing, hoverRows, selectRow, selectRows, updateCellHoverLocation, api, }: Exclude<DragControlsProps, 'selection'>) => JSX.Element;
24
27
  export {};
@@ -5,6 +5,7 @@ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
5
5
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
6
6
  import type { EditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
7
7
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
8
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
8
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
10
  import type { CellHoverMeta, PluginInjectionAPI } from '../types';
10
11
  import type { TableOptions } from './types';
@@ -17,7 +18,7 @@ interface ComponentProps {
17
18
  options?: TableOptions;
18
19
  contentDOM: (node: HTMLElement | null) => void;
19
20
  containerWidth: EditorContainerWidth;
20
- allowControls: boolean;
21
+ allowControls?: boolean;
21
22
  allowTableResizing?: boolean;
22
23
  allowTableAlignment?: boolean;
23
24
  isHeaderRowEnabled: boolean;
@@ -37,6 +38,7 @@ interface ComponentProps {
37
38
  hoveredCell?: CellHoverMeta;
38
39
  isTableHovered?: boolean;
39
40
  isWholeTableInDanger?: boolean;
41
+ selection?: Selection;
40
42
  }
41
43
  declare const _default: React.FC<import("react-intl-next").WithIntlProps<ComponentProps>> & {
42
44
  WrappedComponent: React.ComponentType<ComponentProps>;
@@ -33,7 +33,7 @@ export type PluginInjectionAPIWithA11y = ExtractInjectionAPI<TablePlugin> & {
33
33
  };
34
34
  };
35
35
  };
36
- export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
36
+ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredColumns' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
37
37
  isResizing: boolean;
38
38
  isTableResizing?: boolean;
39
39
  isWholeTableInDanger?: boolean;
@@ -20,8 +20,29 @@ type DragHandleProps = {
20
20
  toggleDragMenu?: (trigger: TriggerType, event?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
21
21
  editorView: EditorView;
22
22
  isDragMenuTarget: boolean;
23
+ hoveredColumns?: number[];
24
+ hoveredRows?: number[];
23
25
  };
24
26
  export declare const DragHandle: React.FC<import("react-intl-next").WithIntlProps<DragHandleProps & WrappedComponentProps>> & {
25
27
  WrappedComponent: React.ComponentType<DragHandleProps & WrappedComponentProps>;
26
28
  };
29
+ export declare const DragHandleWithSharedState: React.FC<import("react-intl-next").WithIntlProps<DragHandleProps & {
30
+ api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"table", {
31
+ pluginConfiguration: import("../../tablePluginType").TablePluginOptions | undefined;
32
+ actions: import("../../tablePluginType").TablePluginActions;
33
+ sharedState?: import("../../types").TableSharedState | undefined;
34
+ commands: import("../../tablePluginType").TablePluginCommands;
35
+ dependencies: import("../../tablePluginType").TablePluginDependencies;
36
+ }> | undefined;
37
+ } & WrappedComponentProps>> & {
38
+ WrappedComponent: React.ComponentType<DragHandleProps & {
39
+ api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"table", {
40
+ pluginConfiguration: import("../../tablePluginType").TablePluginOptions | undefined;
41
+ actions: import("../../tablePluginType").TablePluginActions;
42
+ sharedState?: import("../../types").TableSharedState | undefined;
43
+ commands: import("../../tablePluginType").TablePluginCommands;
44
+ dependencies: import("../../tablePluginType").TablePluginDependencies;
45
+ }> | undefined;
46
+ } & WrappedComponentProps>;
47
+ };
27
48
  export {};
@@ -20,7 +20,7 @@ interface ColumnControlsProps {
20
20
  isDragging?: boolean;
21
21
  getScrollOffset?: () => number;
22
22
  }
23
- export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, tableContainerWidth, isNumberColumnEnabled, isDragging, getScrollOffset, api, }: ColumnControlsProps & {
23
+ export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, stickyTop, localId, isInDanger, rowHeights, colWidths, isTableHovered, tableContainerWidth, isNumberColumnEnabled, isDragging, getScrollOffset, api, }: ColumnControlsProps & {
24
24
  api?: import("@atlaskit/editor-common/types").EditorInjectionAPI<"table", {
25
25
  pluginConfiguration: import("../../../tablePluginType").TablePluginOptions | undefined;
26
26
  actions: import("../../../tablePluginType").TablePluginActions;
@@ -1,7 +1,9 @@
1
- import React from 'react';
2
- import type { WrappedComponentProps } from 'react-intl-next';
1
+ /// <reference types="react" />
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
4
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { TablePlugin } from '../../../tablePluginType';
5
7
  import type { CellHoverMeta } from '../../../types';
6
8
  type DragControlsProps = {
7
9
  editorView: EditorView;
@@ -17,8 +19,9 @@ type DragControlsProps = {
17
19
  selectRow: (row: number, expand: boolean) => void;
18
20
  selectRows: (rowIndexes: number[]) => void;
19
21
  updateCellHoverLocation: (rowIndex: number) => void;
22
+ api?: ExtractInjectionAPI<TablePlugin>;
23
+ selection?: Selection;
20
24
  };
21
- export declare const DragControls: React.FC<import("react-intl-next").WithIntlProps<DragControlsProps & WrappedComponentProps>> & {
22
- WrappedComponent: React.ComponentType<DragControlsProps & WrappedComponentProps>;
23
- };
25
+ export declare const DragControls: ({ tableRef, tableNode, tableWidth, hoveredCell, tableActive, editorView, isInDanger, isResizing, isTableHovered, hoverRows, selectRow, selectRows, updateCellHoverLocation, api, selection, }: DragControlsProps) => JSX.Element | null;
26
+ export declare const DragControlsWithSelection: ({ editorView, tableRef, tableNode, tableWidth, tableActive, hoveredCell, isInDanger, isTableHovered, isResizing, hoverRows, selectRow, selectRows, updateCellHoverLocation, api, }: Exclude<DragControlsProps, 'selection'>) => JSX.Element;
24
27
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "9.1.3",
3
+ "version": "9.2.0",
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
  "@atlaskit/adf-schema": "^46.1.0",
31
31
  "@atlaskit/button": "^20.3.0",
32
32
  "@atlaskit/custom-steps": "^0.9.0",
33
- "@atlaskit/editor-common": "^99.1.0",
33
+ "@atlaskit/editor-common": "^99.3.0",
34
34
  "@atlaskit/editor-palette": "1.6.4",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
@@ -43,7 +43,7 @@
43
43
  "@atlaskit/editor-prosemirror": "6.2.1",
44
44
  "@atlaskit/editor-shared-styles": "^3.2.0",
45
45
  "@atlaskit/editor-tables": "^2.8.0",
46
- "@atlaskit/icon": "^23.3.0",
46
+ "@atlaskit/icon": "^23.4.0",
47
47
  "@atlaskit/menu": "^2.13.0",
48
48
  "@atlaskit/platform-feature-flags": "^0.3.0",
49
49
  "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
@@ -51,9 +51,9 @@
51
51
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
52
52
  "@atlaskit/primitives": "^13.3.0",
53
53
  "@atlaskit/theme": "^14.0.0",
54
- "@atlaskit/tmp-editor-statsig": "^2.34.0",
54
+ "@atlaskit/tmp-editor-statsig": "^2.36.0",
55
55
  "@atlaskit/toggle": "^14.0.0",
56
- "@atlaskit/tokens": "^3.0.0",
56
+ "@atlaskit/tokens": "^3.1.0",
57
57
  "@atlaskit/tooltip": "^19.0.0",
58
58
  "@babel/runtime": "^7.0.0",
59
59
  "@emotion/react": "^11.7.1",
@@ -134,6 +134,9 @@
134
134
  },
135
135
  "platform_editor_table_overflow_in_full_width_fix": {
136
136
  "type": "boolean"
137
+ },
138
+ "platform_editor_table_use_shared_state_hook_fg": {
139
+ "type": "boolean"
137
140
  }
138
141
  }
139
142
  }
@@ -17,6 +17,7 @@ import { tableMarginSides } from '@atlaskit/editor-common/styles';
17
17
  import type { EditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
18
18
  import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
19
19
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
20
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
20
21
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
21
22
  import {
22
23
  akEditorTableNumberColumnWidth,
@@ -26,7 +27,6 @@ import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
26
27
  import { fg } from '@atlaskit/platform-feature-flags';
27
28
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
28
29
  import type { CleanupFn } from '@atlaskit/pragmatic-drag-and-drop/types';
29
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
30
30
  import { token } from '@atlaskit/tokens';
31
31
 
32
32
  import { autoSizeTable, clearHoverSelection } from '../pm-plugins/commands';
@@ -107,7 +107,7 @@ interface ComponentProps {
107
107
 
108
108
  contentDOM: (node: HTMLElement | null) => void;
109
109
  containerWidth: EditorContainerWidth;
110
- allowControls: boolean;
110
+ allowControls?: boolean;
111
111
 
112
112
  allowTableResizing?: boolean;
113
113
  allowTableAlignment?: boolean;
@@ -125,12 +125,13 @@ interface ComponentProps {
125
125
  pluginInjectionApi?: PluginInjectionAPI;
126
126
  intl: IntlShape;
127
127
 
128
- // marking props as option to ensure backward compatibility when platform_editor_table_use_shared_state_hook disabled
128
+ // marking props as optional to ensure backward compatibility when platform_editor_table_use_shared_state_hook_fg disabled
129
129
  isInDanger?: boolean;
130
130
  hoveredRows?: number[];
131
131
  hoveredCell?: CellHoverMeta;
132
132
  isTableHovered?: boolean;
133
133
  isWholeTableInDanger?: boolean;
134
+ selection?: Selection;
134
135
  }
135
136
 
136
137
  interface TableState {
@@ -598,7 +599,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
598
599
 
599
600
  const table = findTable(view.state.selection);
600
601
 
601
- if (editorExperiment('platform_editor_table_use_shared_state_hook', false)) {
602
+ if (!fg('platform_editor_table_use_shared_state_hook_fg')) {
602
603
  const pluginState = getPluginState(view.state);
603
604
  isInDanger = pluginState.isInDanger;
604
605
  }
@@ -809,6 +810,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
809
810
  isTableScalingEnabled, // here we can use options.isTableScalingEnabled
810
811
  allowTableResizing,
811
812
  allowTableAlignment,
813
+ selection,
812
814
  } = this.props;
813
815
 
814
816
  let { isInDanger, hoveredRows, hoveredCell, isTableHovered, isWholeTableInDanger } = this.props;
@@ -816,7 +818,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
816
818
  const { showBeforeShadow, showAfterShadow } = this.state;
817
819
  const node = getNode();
818
820
 
819
- if (editorExperiment('platform_editor_table_use_shared_state_hook', false)) {
821
+ if (!fg('platform_editor_table_use_shared_state_hook_fg')) {
820
822
  const pluginState = getPluginState(view.state);
821
823
  isInDanger = pluginState.isInDanger;
822
824
  hoveredRows = pluginState.hoveredRows;
@@ -908,7 +910,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
908
910
  const topShadowPadding = isDragAndDropEnabled ? 0 : shadowPadding;
909
911
  const topOffset = fg('platform_editor_breakout_use_css')
910
912
  ? 0
911
- : this.state.stickyHeader?.top ?? 0;
913
+ : (this.state.stickyHeader?.top ?? 0);
912
914
 
913
915
  const topStickyShadowPosition =
914
916
  this.state.stickyHeader && topOffset + this.state.stickyHeader.padding + topShadowPadding + 2;
@@ -926,7 +928,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
926
928
  [ClassName.WITH_CONTROLS]: allowControls && tableActive,
927
929
  [ClassName.TABLE_STICKY]: this.state.stickyHeader && hasHeaderRow,
928
930
  [ClassName.HOVERED_DELETE_BUTTON]: isInDanger,
929
- [ClassName.TABLE_SELECTED]: isTableSelected(view.state.selection),
931
+ [ClassName.TABLE_SELECTED]: isTableSelected(selection ?? view.state.selection),
930
932
  })}
931
933
  editorView={view}
932
934
  getPos={getPos}
@@ -51,10 +51,11 @@ export const TableComponentWithSharedState = ({
51
51
  allowTableAlignment,
52
52
  allowTableResizing,
53
53
  }: TableComponentWithSharedStateProps) => {
54
- const { widthState, tableState, mediaState } = useSharedPluginState(api, [
54
+ const { widthState, tableState, mediaState, selectionState } = useSharedPluginState(api, [
55
55
  'width',
56
56
  'table',
57
57
  'media',
58
+ 'selection',
58
59
  ]);
59
60
 
60
61
  if (!tableState) {
@@ -104,7 +105,7 @@ export const TableComponentWithSharedState = ({
104
105
  getPos={getPos}
105
106
  isMediaFullscreen={mediaState?.isFullscreen}
106
107
  options={options}
107
- allowControls={!!allowControls}
108
+ allowControls={allowControls}
108
109
  isHeaderRowEnabled={isHeaderRowEnabled}
109
110
  isHeaderColumnEnabled={isHeaderColumnEnabled}
110
111
  isDragAndDropEnabled={options?.isDragAndDropEnabled}
@@ -127,6 +128,7 @@ export const TableComponentWithSharedState = ({
127
128
  hoveredCell={hoveredCell}
128
129
  isTableHovered={isTableHovered}
129
130
  isWholeTableInDanger={isWholeTableInDanger}
131
+ selection={selectionState?.selection}
130
132
  />
131
133
  );
132
134
  };
@@ -20,7 +20,6 @@ import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
20
20
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
21
21
  import { TableMap } from '@atlaskit/editor-tables/table-map';
22
22
  import { fg } from '@atlaskit/platform-feature-flags';
23
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
24
23
 
25
24
  import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-config';
26
25
  import { pluginKey as tableDragAndDropPluginKey } from '../pm-plugins/drag-and-drop/plugin-key';
@@ -190,7 +189,7 @@ export default class TableView extends ReactNodeView<Props> {
190
189
  };
191
190
 
192
191
  render(props: Props, forwardRef: ForwardRef) {
193
- if (editorExperiment('platform_editor_table_use_shared_state_hook', true)) {
192
+ if (fg('platform_editor_table_use_shared_state_hook_fg')) {
194
193
  return (
195
194
  <TableComponentWithSharedState
196
195
  forwardRef={forwardRef}
@@ -133,6 +133,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
133
133
  isTableResizing: tableWidthResizingPluginState?.resizing,
134
134
  isInDanger: tablePluginState.isInDanger,
135
135
  hoveredRows: tablePluginState.hoveredRows,
136
+ hoveredColumns: tablePluginState.hoveredColumns,
136
137
  hoveredCell: tablePluginState.hoveredCell,
137
138
  isTableHovered: tablePluginState.isTableHovered,
138
139
  isWholeTableInDanger: tablePluginState.isWholeTableInDanger,
@@ -53,6 +53,7 @@ export type TableSharedStateInternal = Pick<
53
53
  | 'ordering'
54
54
  | 'isInDanger'
55
55
  | 'hoveredRows'
56
+ | 'hoveredColumns'
56
57
  | 'hoveredCell'
57
58
  | 'isTableHovered'
58
59
  | 'tableNode'
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @atlaskit/design-system/no-html-button */
1
2
  import type { MouseEventHandler } from 'react';
2
3
  import React, { useEffect, useMemo, useRef, useState } from 'react';
3
4
 
@@ -7,7 +8,9 @@ import type { WrappedComponentProps } from 'react-intl-next';
7
8
  import { injectIntl } from 'react-intl-next';
8
9
 
9
10
  import { browser } from '@atlaskit/editor-common/browser';
11
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
10
12
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
13
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
11
14
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
12
15
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
13
16
  import { findTable, TableMap } from '@atlaskit/editor-tables';
@@ -22,8 +25,9 @@ import {
22
25
  findDuplicatePosition,
23
26
  hasMergedCellsInSelection,
24
27
  } from '../../pm-plugins/utils/merged-cells';
28
+ import type { TablePlugin } from '../../tablePluginType';
25
29
  import { TableCssClassName as ClassName } from '../../types';
26
- import type { CellHoverMeta, TableDirection } from '../../types';
30
+ import type { CellHoverMeta, TableDirection, TableSharedStateInternal } from '../../types';
27
31
  import { dragTableInsertColumnButtonSize } from '../consts';
28
32
  import { DragPreview } from '../DragPreview';
29
33
 
@@ -49,6 +53,12 @@ type DragHandleProps = {
49
53
  ) => void;
50
54
  editorView: EditorView;
51
55
  isDragMenuTarget: boolean; // this is identify which current handle component is
56
+ hoveredColumns?: number[];
57
+ hoveredRows?: number[];
58
+ };
59
+
60
+ type DragHandleWithSharedStateProps = Exclude<DragHandleProps, 'hoveredColumns' | 'hoveredRows'> & {
61
+ api?: ExtractInjectionAPI<TablePlugin>;
52
62
  };
53
63
 
54
64
  const DragHandleComponent = ({
@@ -67,6 +77,8 @@ const DragHandleComponent = ({
67
77
  onClick,
68
78
  editorView,
69
79
  intl: { formatMessage },
80
+ hoveredColumns,
81
+ hoveredRows,
70
82
  }: DragHandleProps & WrappedComponentProps) => {
71
83
  const dragHandleDivRef = useRef<HTMLButtonElement>(null);
72
84
  const [previewContainer, setPreviewContainer] = useState<HTMLElement | null>(null);
@@ -74,7 +86,13 @@ const DragHandleComponent = ({
74
86
  state,
75
87
  state: { selection },
76
88
  } = editorView;
77
- const { hoveredColumns, hoveredRows } = getPluginState(state);
89
+
90
+ if (hoveredColumns === undefined || hoveredRows === undefined) {
91
+ const { hoveredColumns: hoveredColumnsState, hoveredRows: hoveredRowsState } =
92
+ getPluginState(state);
93
+ hoveredColumns = hoveredColumnsState;
94
+ hoveredRows = hoveredRowsState;
95
+ }
78
96
  const { isDragMenuOpen = false } = getDnDPluginState(state);
79
97
 
80
98
  const isRow = direction === 'row';
@@ -291,4 +309,51 @@ const DragHandleComponent = ({
291
309
  );
292
310
  };
293
311
 
312
+ const DragHandleComponentWithSharedState = ({
313
+ isDragMenuTarget,
314
+ tableLocalId,
315
+ direction,
316
+ appearance,
317
+ indexes,
318
+ forceDefaultHandle,
319
+ previewHeight,
320
+ previewWidth,
321
+ onMouseOver,
322
+ onMouseOut,
323
+ toggleDragMenu,
324
+ hoveredCell,
325
+ onClick,
326
+ editorView,
327
+ intl,
328
+ api,
329
+ }: DragHandleWithSharedStateProps & WrappedComponentProps) => {
330
+ const { tableState } = useSharedPluginState(api, ['table']) as {
331
+ tableState?: TableSharedStateInternal;
332
+ };
333
+
334
+ return (
335
+ <DragHandleComponent
336
+ isDragMenuTarget={isDragMenuTarget}
337
+ tableLocalId={tableLocalId}
338
+ direction={direction}
339
+ appearance={appearance}
340
+ indexes={indexes}
341
+ forceDefaultHandle={forceDefaultHandle}
342
+ previewWidth={previewWidth}
343
+ previewHeight={previewHeight}
344
+ onMouseOver={onMouseOver}
345
+ onMouseOut={onMouseOut}
346
+ toggleDragMenu={toggleDragMenu}
347
+ hoveredCell={hoveredCell}
348
+ onClick={onClick}
349
+ editorView={editorView}
350
+ intl={intl}
351
+ hoveredColumns={tableState?.hoveredColumns}
352
+ hoveredRows={tableState?.hoveredRows}
353
+ />
354
+ );
355
+ };
356
+
294
357
  export const DragHandle = injectIntl(DragHandleComponent);
358
+
359
+ export const DragHandleWithSharedState = injectIntl(DragHandleComponentWithSharedState);