@atlaskit/editor-plugin-table 22.4.6 → 22.4.8
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.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/pm-plugins/utils/nodes.js +17 -2
- package/dist/cjs/ui/FloatingContextualButton/index.js +5 -0
- package/dist/cjs/ui/FloatingContextualMenu/CellMenuPopup.js +103 -0
- package/dist/cjs/ui/FloatingContextualMenu/index.js +13 -2
- package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +77 -0
- package/dist/cjs/ui/TableMenu/cell/items/MergeCellsItem.js +21 -0
- package/dist/cjs/ui/TableMenu/cell/items/SplitCellItem.js +21 -0
- package/dist/cjs/ui/TableMenu/cell/keys.js +40 -0
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -6
- package/dist/cjs/ui/TableMenu/shared/TableMenu.js +2 -1
- package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +28 -19
- package/dist/cjs/ui/TableMenu/shared/getTableMenuComponents.js +2 -1
- package/dist/es2019/pm-plugins/utils/nodes.js +11 -2
- package/dist/es2019/ui/FloatingContextualButton/index.js +5 -0
- package/dist/es2019/ui/FloatingContextualMenu/CellMenuPopup.js +99 -0
- package/dist/es2019/ui/FloatingContextualMenu/index.js +13 -3
- package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +61 -0
- package/dist/es2019/ui/TableMenu/cell/items/MergeCellsItem.js +15 -0
- package/dist/es2019/ui/TableMenu/cell/items/SplitCellItem.js +15 -0
- package/dist/es2019/ui/TableMenu/cell/keys.js +42 -0
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -5
- package/dist/es2019/ui/TableMenu/shared/TableMenu.js +2 -1
- package/dist/es2019/ui/TableMenu/shared/getSharedItems.js +9 -0
- package/dist/es2019/ui/TableMenu/shared/getTableMenuComponents.js +2 -1
- package/dist/esm/pm-plugins/utils/nodes.js +17 -2
- package/dist/esm/ui/FloatingContextualButton/index.js +5 -0
- package/dist/esm/ui/FloatingContextualMenu/CellMenuPopup.js +95 -0
- package/dist/esm/ui/FloatingContextualMenu/index.js +13 -3
- package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +71 -0
- package/dist/esm/ui/TableMenu/cell/items/MergeCellsItem.js +14 -0
- package/dist/esm/ui/TableMenu/cell/items/SplitCellItem.js +14 -0
- package/dist/esm/ui/TableMenu/cell/keys.js +34 -0
- package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -7
- package/dist/esm/ui/TableMenu/shared/TableMenu.js +2 -1
- package/dist/esm/ui/TableMenu/shared/getSharedItems.js +9 -0
- package/dist/esm/ui/TableMenu/shared/getTableMenuComponents.js +2 -1
- package/dist/types/pm-plugins/utils/nodes.d.ts +3 -1
- package/dist/types/ui/FloatingContextualMenu/CellMenuPopup.d.ts +12 -0
- package/dist/types/ui/TableMenu/cell/getCellMenuComponents.d.ts +9 -0
- package/dist/types/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -0
- package/dist/types/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -0
- package/dist/types/ui/TableMenu/cell/keys.d.ts +9 -0
- package/dist/types-ts4.5/pm-plugins/utils/nodes.d.ts +3 -1
- package/dist/types-ts4.5/ui/FloatingContextualMenu/CellMenuPopup.d.ts +12 -0
- package/dist/types-ts4.5/ui/TableMenu/cell/getCellMenuComponents.d.ts +9 -0
- package/dist/types-ts4.5/ui/TableMenu/cell/items/MergeCellsItem.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableMenu/cell/items/SplitCellItem.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableMenu/cell/keys.d.ts +9 -0
- package/package.json +7 -7
|
@@ -8,9 +8,11 @@ import { Popup } from '@atlaskit/editor-common/ui';
|
|
|
8
8
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
9
9
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
10
10
|
import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
11
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
12
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
12
13
|
import { contextualMenuDropdownWidthDnD, contextualMenuTriggerSize, tablePopupMenuFitHeight } from '../consts';
|
|
13
|
-
|
|
14
|
+
import { TABLE_MENU_WIDTH } from '../TableMenu/shared/consts';
|
|
15
|
+
import { CellMenuPopup } from './CellMenuPopup';
|
|
14
16
|
// Ignored via go/ees005
|
|
15
17
|
// eslint-disable-next-line import/no-named-as-default
|
|
16
18
|
import ContextualMenu from './ContextualMenu';
|
|
@@ -68,7 +70,7 @@ const FloatingContextualMenu = ({
|
|
|
68
70
|
boundariesElement: boundariesElement,
|
|
69
71
|
scrollableElement: scrollableElement,
|
|
70
72
|
fitHeight: tablePopupMenuFitHeight,
|
|
71
|
-
fitWidth: contextualMenuDropdownWidthDnD
|
|
73
|
+
fitWidth: expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? TABLE_MENU_WIDTH : contextualMenuDropdownWidthDnD
|
|
72
74
|
// z-index value below is to ensure that this menu is above other floating menu
|
|
73
75
|
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
74
76
|
,
|
|
@@ -78,7 +80,15 @@ const FloatingContextualMenu = ({
|
|
|
78
80
|
,
|
|
79
81
|
offset: [-7, 0],
|
|
80
82
|
stick: true
|
|
81
|
-
}, jsx(
|
|
83
|
+
}, expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? jsx(CellMenuPopup, {
|
|
84
|
+
api: api,
|
|
85
|
+
editorView: editorView,
|
|
86
|
+
isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
|
|
87
|
+
isOpen: isOpen,
|
|
88
|
+
targetCellRef: targetCellRef
|
|
89
|
+
}) :
|
|
90
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
91
|
+
jsx("div", {
|
|
82
92
|
css: tablePopupStyles()
|
|
83
93
|
}, jsx(ContextualMenu, {
|
|
84
94
|
editorView: editorView
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
3
|
+
import { MergeCellsItem } from './items/MergeCellsItem';
|
|
4
|
+
import { SplitCellItem } from './items/SplitCellItem';
|
|
5
|
+
import { CELL_MENU, CELL_ACTION_SECTION, CELL_DANGER_SECTION, CELL_MENU_SECTION_RANK, MERGE_CELLS_ITEM, SPLIT_CELL_ITEM, CELL_ACTION_SECTION_RANK } from './keys';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns the RegisterComponent[] array defining the cell contextual menu surface.
|
|
9
|
+
*
|
|
10
|
+
* This is a **UI-only stub** — all items are always visible with no conditional
|
|
11
|
+
* logic and no wired actions. Functional behaviour (actions, conditional visibility)
|
|
12
|
+
* will be connected in follow-up tickets.
|
|
13
|
+
*/
|
|
14
|
+
export const getCellMenuComponents = () => [
|
|
15
|
+
// --- Menu surface ---
|
|
16
|
+
{
|
|
17
|
+
type: CELL_MENU.type,
|
|
18
|
+
key: CELL_MENU.key
|
|
19
|
+
},
|
|
20
|
+
// --- Main action section (Background color, Merge cells, Split cell) ---
|
|
21
|
+
{
|
|
22
|
+
type: CELL_ACTION_SECTION.type,
|
|
23
|
+
key: CELL_ACTION_SECTION.key,
|
|
24
|
+
parents: [{
|
|
25
|
+
type: CELL_MENU.type,
|
|
26
|
+
key: CELL_MENU.key,
|
|
27
|
+
rank: CELL_MENU_SECTION_RANK[CELL_ACTION_SECTION.key]
|
|
28
|
+
}],
|
|
29
|
+
component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, props.children)
|
|
30
|
+
}, {
|
|
31
|
+
type: MERGE_CELLS_ITEM.type,
|
|
32
|
+
key: MERGE_CELLS_ITEM.key,
|
|
33
|
+
parents: [{
|
|
34
|
+
type: CELL_ACTION_SECTION.type,
|
|
35
|
+
key: CELL_ACTION_SECTION.key,
|
|
36
|
+
rank: CELL_ACTION_SECTION_RANK[MERGE_CELLS_ITEM.key]
|
|
37
|
+
}],
|
|
38
|
+
component: () => /*#__PURE__*/React.createElement(MergeCellsItem, null)
|
|
39
|
+
}, {
|
|
40
|
+
type: SPLIT_CELL_ITEM.type,
|
|
41
|
+
key: SPLIT_CELL_ITEM.key,
|
|
42
|
+
parents: [{
|
|
43
|
+
type: CELL_ACTION_SECTION.type,
|
|
44
|
+
key: CELL_ACTION_SECTION.key,
|
|
45
|
+
rank: CELL_ACTION_SECTION_RANK[SPLIT_CELL_ITEM.key]
|
|
46
|
+
}],
|
|
47
|
+
component: () => /*#__PURE__*/React.createElement(SplitCellItem, null)
|
|
48
|
+
},
|
|
49
|
+
// --- Danger section (Clear cell) ---
|
|
50
|
+
{
|
|
51
|
+
type: CELL_DANGER_SECTION.type,
|
|
52
|
+
key: CELL_DANGER_SECTION.key,
|
|
53
|
+
parents: [{
|
|
54
|
+
type: CELL_MENU.type,
|
|
55
|
+
key: CELL_MENU.key,
|
|
56
|
+
rank: CELL_MENU_SECTION_RANK[CELL_DANGER_SECTION.key]
|
|
57
|
+
}],
|
|
58
|
+
component: props => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
59
|
+
hasSeparator: true
|
|
60
|
+
}, props.children)
|
|
61
|
+
}];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { TableCellMergeIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
|
+
export const MergeCellsItem = () => {
|
|
6
|
+
const {
|
|
7
|
+
formatMessage
|
|
8
|
+
} = useIntl();
|
|
9
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
10
|
+
elemBefore: /*#__PURE__*/React.createElement(TableCellMergeIcon, {
|
|
11
|
+
label: "",
|
|
12
|
+
size: "small"
|
|
13
|
+
})
|
|
14
|
+
}, formatMessage(messages.mergeCells));
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { TableCellSplitIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
|
+
export const SplitCellItem = () => {
|
|
6
|
+
const {
|
|
7
|
+
formatMessage
|
|
8
|
+
} = useIntl();
|
|
9
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
10
|
+
elemBefore: /*#__PURE__*/React.createElement(TableCellSplitIcon, {
|
|
11
|
+
label: "",
|
|
12
|
+
size: "small"
|
|
13
|
+
})
|
|
14
|
+
}, formatMessage(messages.splitCell));
|
|
15
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { BACKGROUND_COLOR_ITEM, CLEAR_CELLS_ITEM } from '../shared/keys';
|
|
2
|
+
|
|
3
|
+
// --- Menu surface ---
|
|
4
|
+
|
|
5
|
+
export const CELL_MENU = {
|
|
6
|
+
type: 'menu',
|
|
7
|
+
key: 'cell-contextual-menu'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// --- Sections ---
|
|
11
|
+
|
|
12
|
+
export const CELL_ACTION_SECTION = {
|
|
13
|
+
type: 'menu-section',
|
|
14
|
+
key: 'cell-action-section'
|
|
15
|
+
};
|
|
16
|
+
export const CELL_DANGER_SECTION = {
|
|
17
|
+
type: 'menu-section',
|
|
18
|
+
key: 'cell-danger-section'
|
|
19
|
+
};
|
|
20
|
+
export const CELL_MENU_SECTION_RANK = {
|
|
21
|
+
[CELL_ACTION_SECTION.key]: 100,
|
|
22
|
+
[CELL_DANGER_SECTION.key]: 200
|
|
23
|
+
};
|
|
24
|
+
export const MERGE_CELLS_ITEM = {
|
|
25
|
+
type: 'menu-item',
|
|
26
|
+
key: 'merge-cells'
|
|
27
|
+
};
|
|
28
|
+
export const SPLIT_CELL_ITEM = {
|
|
29
|
+
type: 'menu-item',
|
|
30
|
+
key: 'split-cell'
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// --- Item ranks within their sections ---
|
|
34
|
+
|
|
35
|
+
export const CELL_ACTION_SECTION_RANK = {
|
|
36
|
+
[BACKGROUND_COLOR_ITEM.key]: 100,
|
|
37
|
+
[MERGE_CELLS_ITEM.key]: 200,
|
|
38
|
+
[SPLIT_CELL_ITEM.key]: 300
|
|
39
|
+
};
|
|
40
|
+
export const CELL_DANGER_SECTION_RANK = {
|
|
41
|
+
[CLEAR_CELLS_ITEM.key]: 100
|
|
42
|
+
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
-
import { moveColumnRight,
|
|
3
|
+
import { moveColumnRight, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
4
4
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { TableColumnMoveRightIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
6
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
-
const getMoveColumnRightShortcut = () => tooltip(expValEquals('editor-a11y-fy26-keyboard-move-row-column', 'isEnabled', true) ? moveColumnRight : moveColumnRightOld);
|
|
8
6
|
export const MoveColumnRightItem = () => {
|
|
9
|
-
var
|
|
7
|
+
var _tooltip;
|
|
10
8
|
const {
|
|
11
9
|
formatMessage
|
|
12
10
|
} = useIntl();
|
|
@@ -17,7 +15,7 @@ export const MoveColumnRightItem = () => {
|
|
|
17
15
|
size: "small"
|
|
18
16
|
}),
|
|
19
17
|
elemAfter: /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
|
|
20
|
-
shortcut: (
|
|
18
|
+
shortcut: (_tooltip = tooltip(moveColumnRight)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
21
19
|
})
|
|
22
20
|
}, formatMessage(messages.moveColumnRight, {
|
|
23
21
|
0: 1
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { CELL_ACTION_SECTION, CELL_DANGER_SECTION, CELL_ACTION_SECTION_RANK, CELL_DANGER_SECTION_RANK } from '../cell/keys';
|
|
2
3
|
import { COLUMN_BACKGROUND_SECTION, COLUMN_DANGER_SECTION, COLUMN_BACKGROUND_SECTION_RANK, COLUMN_DANGER_SECTION_RANK } from '../column/keys';
|
|
3
4
|
import { ROW_BACKGROUND_SECTION, ROW_DANGER_SECTION, ROW_BACKGROUND_SECTION_RANK, ROW_DANGER_SECTION_RANK } from '../row/keys';
|
|
4
5
|
import { BackgroundColorItem } from './items/BackgroundColorItem';
|
|
@@ -15,6 +16,10 @@ export const getSharedItems = () => [{
|
|
|
15
16
|
type: COLUMN_BACKGROUND_SECTION.type,
|
|
16
17
|
key: COLUMN_BACKGROUND_SECTION.key,
|
|
17
18
|
rank: COLUMN_BACKGROUND_SECTION_RANK[BACKGROUND_COLOR_ITEM.key]
|
|
19
|
+
}, {
|
|
20
|
+
type: CELL_ACTION_SECTION.type,
|
|
21
|
+
key: CELL_ACTION_SECTION.key,
|
|
22
|
+
rank: CELL_ACTION_SECTION_RANK[BACKGROUND_COLOR_ITEM.key]
|
|
18
23
|
}],
|
|
19
24
|
component: () => /*#__PURE__*/React.createElement(BackgroundColorItem, null)
|
|
20
25
|
}, {
|
|
@@ -28,6 +33,10 @@ export const getSharedItems = () => [{
|
|
|
28
33
|
type: COLUMN_DANGER_SECTION.type,
|
|
29
34
|
key: COLUMN_DANGER_SECTION.key,
|
|
30
35
|
rank: COLUMN_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
|
|
36
|
+
}, {
|
|
37
|
+
type: CELL_DANGER_SECTION.type,
|
|
38
|
+
key: CELL_DANGER_SECTION.key,
|
|
39
|
+
rank: CELL_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
|
|
31
40
|
}],
|
|
32
41
|
component: () => /*#__PURE__*/React.createElement(ClearCellsItem, null)
|
|
33
42
|
}];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { getCellMenuComponents } from '../cell/getCellMenuComponents';
|
|
1
2
|
import { getColumnMenuComponents } from '../column/getColumnMenuComponents';
|
|
2
3
|
import { getRowMenuComponents } from '../row/getRowMenuComponents';
|
|
3
4
|
import { getSharedItems } from './getSharedItems';
|
|
4
|
-
export const getTableMenuComponents = () => [...getRowMenuComponents(), ...getColumnMenuComponents(), ...getSharedItems()];
|
|
5
|
+
export const getTableMenuComponents = () => [...getRowMenuComponents(), ...getColumnMenuComponents(), ...getCellMenuComponents(), ...getSharedItems()];
|
|
@@ -2,6 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import { mapChildren } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
4
4
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
5
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
6
|
export var isIsolating = function isIsolating(node) {
|
|
6
7
|
return !!node.type.spec.isolating;
|
|
7
8
|
};
|
|
@@ -20,7 +21,7 @@ export var containsHeaderColumn = function containsHeaderColumn(table) {
|
|
|
20
21
|
if (cell && cell.type !== table.type.schema.nodes.tableHeader) {
|
|
21
22
|
return false;
|
|
22
23
|
}
|
|
23
|
-
} catch (
|
|
24
|
+
} catch (_unused) {
|
|
24
25
|
return false;
|
|
25
26
|
}
|
|
26
27
|
}
|
|
@@ -127,11 +128,20 @@ var anyChildCellMergedAcrossRow = function anyChildCellMergedAcrossRow(node) {
|
|
|
127
128
|
return rowspan > 1;
|
|
128
129
|
});
|
|
129
130
|
};
|
|
131
|
+
var anyChildCellMergedAcrossColumn = function anyChildCellMergedAcrossColumn(node) {
|
|
132
|
+
return mapChildren(node, function (child) {
|
|
133
|
+
return child.attrs.colspan || 0;
|
|
134
|
+
}).some(function (colspan) {
|
|
135
|
+
return colspan > 1;
|
|
136
|
+
});
|
|
137
|
+
};
|
|
130
138
|
|
|
131
139
|
/**
|
|
132
140
|
* Check if a given node is a header row with this definition:
|
|
133
141
|
* - all children are tableHeader cells
|
|
134
|
-
* - no table cells have been
|
|
142
|
+
* - no table cells have been merged with other table row cells (rowspan > 1)
|
|
143
|
+
* - no table cells have been merged with other table column cells (colspan > 1),
|
|
144
|
+
* (colspan check gated behind platform_editor_fix_sticky_header_malfunction)
|
|
135
145
|
*
|
|
136
146
|
* @param node ProseMirror node
|
|
137
147
|
* @returns boolean if it meets definition
|
|
@@ -140,6 +150,11 @@ export var supportedHeaderRow = function supportedHeaderRow(node) {
|
|
|
140
150
|
var allHeaders = mapChildren(node, function (child) {
|
|
141
151
|
return child.type.name === 'tableHeader';
|
|
142
152
|
}).every(Boolean);
|
|
153
|
+
if (expValEquals('platform_editor_fix_sticky_header_malfunction', 'isEnabled', true)) {
|
|
154
|
+
var someMergedAcrossRow = anyChildCellMergedAcrossRow(node);
|
|
155
|
+
var someMergedAcrossColumn = anyChildCellMergedAcrossColumn(node);
|
|
156
|
+
return allHeaders && !someMergedAcrossRow && !someMergedAcrossColumn;
|
|
157
|
+
}
|
|
143
158
|
var someMerged = anyChildCellMergedAcrossRow(node);
|
|
144
159
|
return allHeaders && !someMerged;
|
|
145
160
|
};
|
|
@@ -46,6 +46,11 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
46
46
|
var handleClick = function handleClick() {
|
|
47
47
|
var state = editorView.state,
|
|
48
48
|
dispatch = editorView.dispatch;
|
|
49
|
+
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
50
|
+
toggleContextualMenu()(state, dispatch);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
49
54
|
// Clicking outside the dropdown handles toggling the menu closed
|
|
50
55
|
// (otherwise these two toggles combat each other).
|
|
51
56
|
// In the event a user clicks the chevron button again
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { bind } from 'bind-event-listener';
|
|
3
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { UserIntentPopupWrapper } from '@atlaskit/editor-common/user-intent';
|
|
5
|
+
import { setFocusToCellMenu, toggleContextualMenu } from '../../pm-plugins/commands';
|
|
6
|
+
import { TableCssClassName as ClassName } from '../../types';
|
|
7
|
+
import { CELL_MENU } from '../TableMenu/cell/keys';
|
|
8
|
+
import { TableMenu } from '../TableMenu/shared/TableMenu';
|
|
9
|
+
export var CellMenuPopup = function CellMenuPopup(_ref) {
|
|
10
|
+
var api = _ref.api,
|
|
11
|
+
editorView = _ref.editorView,
|
|
12
|
+
isCellMenuOpenByKeyboard = _ref.isCellMenuOpenByKeyboard,
|
|
13
|
+
isOpen = _ref.isOpen,
|
|
14
|
+
targetCellRef = _ref.targetCellRef;
|
|
15
|
+
var tableMenuRef = useRef(null);
|
|
16
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['userIntent'], function (states) {
|
|
17
|
+
var _states$userIntentSta;
|
|
18
|
+
return {
|
|
19
|
+
currentUserIntent: (_states$userIntentSta = states.userIntentState) === null || _states$userIntentSta === void 0 ? void 0 : _states$userIntentSta.currentUserIntent
|
|
20
|
+
};
|
|
21
|
+
}),
|
|
22
|
+
currentUserIntent = _useSharedPluginState.currentUserIntent;
|
|
23
|
+
var closeCellMenu = useCallback(function () {
|
|
24
|
+
var state = editorView.state,
|
|
25
|
+
dispatch = editorView.dispatch,
|
|
26
|
+
dom = editorView.dom;
|
|
27
|
+
toggleContextualMenu()(state, dispatch);
|
|
28
|
+
if (isCellMenuOpenByKeyboard) {
|
|
29
|
+
setFocusToCellMenu(false)(state, dispatch);
|
|
30
|
+
dom.focus();
|
|
31
|
+
}
|
|
32
|
+
}, [editorView, isCellMenuOpenByKeyboard]);
|
|
33
|
+
useEffect(function () {
|
|
34
|
+
if (!isOpen || currentUserIntent !== 'tableDragMenuPopupOpen') {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
closeCellMenu();
|
|
38
|
+
}, [closeCellMenu, currentUserIntent, isOpen]);
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
if (!isOpen) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!(targetCellRef instanceof HTMLElement)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
var ownerDocument = targetCellRef.ownerDocument;
|
|
47
|
+
var handlePointerDown = function handlePointerDown(event) {
|
|
48
|
+
var _tableMenuRef$current;
|
|
49
|
+
var target = event.target;
|
|
50
|
+
if (!(target instanceof Node)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if ((_tableMenuRef$current = tableMenuRef.current) !== null && _tableMenuRef$current !== void 0 && _tableMenuRef$current.contains(target)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
var cellMenuButton = ownerDocument.querySelector(".".concat(ClassName.CONTEXTUAL_MENU_BUTTON));
|
|
57
|
+
if (cellMenuButton !== null && cellMenuButton !== void 0 && cellMenuButton.contains(target)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
closeCellMenu();
|
|
61
|
+
};
|
|
62
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
63
|
+
if (event.key === 'Escape') {
|
|
64
|
+
closeCellMenu();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var unbindPointerDown = bind(ownerDocument, {
|
|
68
|
+
type: 'pointerdown',
|
|
69
|
+
listener: handlePointerDown,
|
|
70
|
+
options: {
|
|
71
|
+
capture: true
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
var unbindKeyDown = bind(ownerDocument, {
|
|
75
|
+
type: 'keydown',
|
|
76
|
+
listener: handleKeyDown,
|
|
77
|
+
options: {
|
|
78
|
+
capture: true
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return function () {
|
|
82
|
+
unbindPointerDown();
|
|
83
|
+
unbindKeyDown();
|
|
84
|
+
};
|
|
85
|
+
}, [closeCellMenu, isOpen, targetCellRef]);
|
|
86
|
+
return /*#__PURE__*/React.createElement(UserIntentPopupWrapper, {
|
|
87
|
+
api: api,
|
|
88
|
+
userIntent: "tableContextualMenuPopupOpen"
|
|
89
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
ref: tableMenuRef
|
|
91
|
+
}, /*#__PURE__*/React.createElement(TableMenu, {
|
|
92
|
+
api: api,
|
|
93
|
+
surface: CELL_MENU
|
|
94
|
+
})));
|
|
95
|
+
};
|
|
@@ -8,9 +8,11 @@ import { Popup } from '@atlaskit/editor-common/ui';
|
|
|
8
8
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
9
9
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
10
10
|
import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
11
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
12
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
12
13
|
import { contextualMenuDropdownWidthDnD, contextualMenuTriggerSize, tablePopupMenuFitHeight } from '../consts';
|
|
13
|
-
|
|
14
|
+
import { TABLE_MENU_WIDTH } from '../TableMenu/shared/consts';
|
|
15
|
+
import { CellMenuPopup } from './CellMenuPopup';
|
|
14
16
|
// Ignored via go/ees005
|
|
15
17
|
// eslint-disable-next-line import/no-named-as-default
|
|
16
18
|
import ContextualMenu from './ContextualMenu';
|
|
@@ -64,7 +66,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
64
66
|
boundariesElement: boundariesElement,
|
|
65
67
|
scrollableElement: scrollableElement,
|
|
66
68
|
fitHeight: tablePopupMenuFitHeight,
|
|
67
|
-
fitWidth: contextualMenuDropdownWidthDnD
|
|
69
|
+
fitWidth: expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? TABLE_MENU_WIDTH : contextualMenuDropdownWidthDnD
|
|
68
70
|
// z-index value below is to ensure that this menu is above other floating menu
|
|
69
71
|
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
70
72
|
,
|
|
@@ -74,7 +76,15 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
74
76
|
,
|
|
75
77
|
offset: [-7, 0],
|
|
76
78
|
stick: true
|
|
77
|
-
}, jsx(
|
|
79
|
+
}, expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? jsx(CellMenuPopup, {
|
|
80
|
+
api: api,
|
|
81
|
+
editorView: editorView,
|
|
82
|
+
isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
|
|
83
|
+
isOpen: isOpen,
|
|
84
|
+
targetCellRef: targetCellRef
|
|
85
|
+
}) :
|
|
86
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
87
|
+
jsx("div", {
|
|
78
88
|
css: tablePopupStyles()
|
|
79
89
|
}, jsx(ContextualMenu, {
|
|
80
90
|
editorView: editorView
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
3
|
+
import { MergeCellsItem } from './items/MergeCellsItem';
|
|
4
|
+
import { SplitCellItem } from './items/SplitCellItem';
|
|
5
|
+
import { CELL_MENU, CELL_ACTION_SECTION, CELL_DANGER_SECTION, CELL_MENU_SECTION_RANK, MERGE_CELLS_ITEM, SPLIT_CELL_ITEM, CELL_ACTION_SECTION_RANK } from './keys';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns the RegisterComponent[] array defining the cell contextual menu surface.
|
|
9
|
+
*
|
|
10
|
+
* This is a **UI-only stub** — all items are always visible with no conditional
|
|
11
|
+
* logic and no wired actions. Functional behaviour (actions, conditional visibility)
|
|
12
|
+
* will be connected in follow-up tickets.
|
|
13
|
+
*/
|
|
14
|
+
export var getCellMenuComponents = function getCellMenuComponents() {
|
|
15
|
+
return [
|
|
16
|
+
// --- Menu surface ---
|
|
17
|
+
{
|
|
18
|
+
type: CELL_MENU.type,
|
|
19
|
+
key: CELL_MENU.key
|
|
20
|
+
},
|
|
21
|
+
// --- Main action section (Background color, Merge cells, Split cell) ---
|
|
22
|
+
{
|
|
23
|
+
type: CELL_ACTION_SECTION.type,
|
|
24
|
+
key: CELL_ACTION_SECTION.key,
|
|
25
|
+
parents: [{
|
|
26
|
+
type: CELL_MENU.type,
|
|
27
|
+
key: CELL_MENU.key,
|
|
28
|
+
rank: CELL_MENU_SECTION_RANK[CELL_ACTION_SECTION.key]
|
|
29
|
+
}],
|
|
30
|
+
component: function component(props) {
|
|
31
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, props.children);
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
type: MERGE_CELLS_ITEM.type,
|
|
35
|
+
key: MERGE_CELLS_ITEM.key,
|
|
36
|
+
parents: [{
|
|
37
|
+
type: CELL_ACTION_SECTION.type,
|
|
38
|
+
key: CELL_ACTION_SECTION.key,
|
|
39
|
+
rank: CELL_ACTION_SECTION_RANK[MERGE_CELLS_ITEM.key]
|
|
40
|
+
}],
|
|
41
|
+
component: function component() {
|
|
42
|
+
return /*#__PURE__*/React.createElement(MergeCellsItem, null);
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
type: SPLIT_CELL_ITEM.type,
|
|
46
|
+
key: SPLIT_CELL_ITEM.key,
|
|
47
|
+
parents: [{
|
|
48
|
+
type: CELL_ACTION_SECTION.type,
|
|
49
|
+
key: CELL_ACTION_SECTION.key,
|
|
50
|
+
rank: CELL_ACTION_SECTION_RANK[SPLIT_CELL_ITEM.key]
|
|
51
|
+
}],
|
|
52
|
+
component: function component() {
|
|
53
|
+
return /*#__PURE__*/React.createElement(SplitCellItem, null);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
// --- Danger section (Clear cell) ---
|
|
57
|
+
{
|
|
58
|
+
type: CELL_DANGER_SECTION.type,
|
|
59
|
+
key: CELL_DANGER_SECTION.key,
|
|
60
|
+
parents: [{
|
|
61
|
+
type: CELL_MENU.type,
|
|
62
|
+
key: CELL_MENU.key,
|
|
63
|
+
rank: CELL_MENU_SECTION_RANK[CELL_DANGER_SECTION.key]
|
|
64
|
+
}],
|
|
65
|
+
component: function component(props) {
|
|
66
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
67
|
+
hasSeparator: true
|
|
68
|
+
}, props.children);
|
|
69
|
+
}
|
|
70
|
+
}];
|
|
71
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { TableCellMergeIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
|
+
export var MergeCellsItem = function MergeCellsItem() {
|
|
6
|
+
var _useIntl = useIntl(),
|
|
7
|
+
formatMessage = _useIntl.formatMessage;
|
|
8
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
9
|
+
elemBefore: /*#__PURE__*/React.createElement(TableCellMergeIcon, {
|
|
10
|
+
label: "",
|
|
11
|
+
size: "small"
|
|
12
|
+
})
|
|
13
|
+
}, formatMessage(messages.mergeCells));
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { TableCellSplitIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
|
+
export var SplitCellItem = function SplitCellItem() {
|
|
6
|
+
var _useIntl = useIntl(),
|
|
7
|
+
formatMessage = _useIntl.formatMessage;
|
|
8
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
9
|
+
elemBefore: /*#__PURE__*/React.createElement(TableCellSplitIcon, {
|
|
10
|
+
label: "",
|
|
11
|
+
size: "small"
|
|
12
|
+
})
|
|
13
|
+
}, formatMessage(messages.splitCell));
|
|
14
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { BACKGROUND_COLOR_ITEM, CLEAR_CELLS_ITEM } from '../shared/keys';
|
|
3
|
+
|
|
4
|
+
// --- Menu surface ---
|
|
5
|
+
|
|
6
|
+
export var CELL_MENU = {
|
|
7
|
+
type: 'menu',
|
|
8
|
+
key: 'cell-contextual-menu'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// --- Sections ---
|
|
12
|
+
|
|
13
|
+
export var CELL_ACTION_SECTION = {
|
|
14
|
+
type: 'menu-section',
|
|
15
|
+
key: 'cell-action-section'
|
|
16
|
+
};
|
|
17
|
+
export var CELL_DANGER_SECTION = {
|
|
18
|
+
type: 'menu-section',
|
|
19
|
+
key: 'cell-danger-section'
|
|
20
|
+
};
|
|
21
|
+
export var CELL_MENU_SECTION_RANK = _defineProperty(_defineProperty({}, CELL_ACTION_SECTION.key, 100), CELL_DANGER_SECTION.key, 200);
|
|
22
|
+
export var MERGE_CELLS_ITEM = {
|
|
23
|
+
type: 'menu-item',
|
|
24
|
+
key: 'merge-cells'
|
|
25
|
+
};
|
|
26
|
+
export var SPLIT_CELL_ITEM = {
|
|
27
|
+
type: 'menu-item',
|
|
28
|
+
key: 'split-cell'
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// --- Item ranks within their sections ---
|
|
32
|
+
|
|
33
|
+
export var CELL_ACTION_SECTION_RANK = _defineProperty(_defineProperty(_defineProperty({}, BACKGROUND_COLOR_ITEM.key, 100), MERGE_CELLS_ITEM.key, 200), SPLIT_CELL_ITEM.key, 300);
|
|
34
|
+
export var CELL_DANGER_SECTION_RANK = _defineProperty({}, CLEAR_CELLS_ITEM.key, 100);
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
-
import { moveColumnRight,
|
|
3
|
+
import { moveColumnRight, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
4
4
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { TableColumnMoveRightIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
6
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
-
var getMoveColumnRightShortcut = function getMoveColumnRightShortcut() {
|
|
8
|
-
return tooltip(expValEquals('editor-a11y-fy26-keyboard-move-row-column', 'isEnabled', true) ? moveColumnRight : moveColumnRightOld);
|
|
9
|
-
};
|
|
10
6
|
export var MoveColumnRightItem = function MoveColumnRightItem() {
|
|
11
|
-
var
|
|
7
|
+
var _tooltip;
|
|
12
8
|
var _useIntl = useIntl(),
|
|
13
9
|
formatMessage = _useIntl.formatMessage;
|
|
14
10
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
@@ -18,7 +14,7 @@ export var MoveColumnRightItem = function MoveColumnRightItem() {
|
|
|
18
14
|
size: "small"
|
|
19
15
|
}),
|
|
20
16
|
elemAfter: /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
|
|
21
|
-
shortcut: (
|
|
17
|
+
shortcut: (_tooltip = tooltip(moveColumnRight)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
22
18
|
})
|
|
23
19
|
}, formatMessage(messages.moveColumnRight, {
|
|
24
20
|
0: 1
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { CELL_ACTION_SECTION, CELL_DANGER_SECTION, CELL_ACTION_SECTION_RANK, CELL_DANGER_SECTION_RANK } from '../cell/keys';
|
|
2
3
|
import { COLUMN_BACKGROUND_SECTION, COLUMN_DANGER_SECTION, COLUMN_BACKGROUND_SECTION_RANK, COLUMN_DANGER_SECTION_RANK } from '../column/keys';
|
|
3
4
|
import { ROW_BACKGROUND_SECTION, ROW_DANGER_SECTION, ROW_BACKGROUND_SECTION_RANK, ROW_DANGER_SECTION_RANK } from '../row/keys';
|
|
4
5
|
import { BackgroundColorItem } from './items/BackgroundColorItem';
|
|
@@ -16,6 +17,10 @@ export var getSharedItems = function getSharedItems() {
|
|
|
16
17
|
type: COLUMN_BACKGROUND_SECTION.type,
|
|
17
18
|
key: COLUMN_BACKGROUND_SECTION.key,
|
|
18
19
|
rank: COLUMN_BACKGROUND_SECTION_RANK[BACKGROUND_COLOR_ITEM.key]
|
|
20
|
+
}, {
|
|
21
|
+
type: CELL_ACTION_SECTION.type,
|
|
22
|
+
key: CELL_ACTION_SECTION.key,
|
|
23
|
+
rank: CELL_ACTION_SECTION_RANK[BACKGROUND_COLOR_ITEM.key]
|
|
19
24
|
}],
|
|
20
25
|
component: function component() {
|
|
21
26
|
return /*#__PURE__*/React.createElement(BackgroundColorItem, null);
|
|
@@ -31,6 +36,10 @@ export var getSharedItems = function getSharedItems() {
|
|
|
31
36
|
type: COLUMN_DANGER_SECTION.type,
|
|
32
37
|
key: COLUMN_DANGER_SECTION.key,
|
|
33
38
|
rank: COLUMN_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
|
|
39
|
+
}, {
|
|
40
|
+
type: CELL_DANGER_SECTION.type,
|
|
41
|
+
key: CELL_DANGER_SECTION.key,
|
|
42
|
+
rank: CELL_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
|
|
34
43
|
}],
|
|
35
44
|
component: function component() {
|
|
36
45
|
return /*#__PURE__*/React.createElement(ClearCellsItem, null);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { getCellMenuComponents } from '../cell/getCellMenuComponents';
|
|
2
3
|
import { getColumnMenuComponents } from '../column/getColumnMenuComponents';
|
|
3
4
|
import { getRowMenuComponents } from '../row/getRowMenuComponents';
|
|
4
5
|
import { getSharedItems } from './getSharedItems';
|
|
5
6
|
export var getTableMenuComponents = function getTableMenuComponents() {
|
|
6
|
-
return [].concat(_toConsumableArray(getRowMenuComponents()), _toConsumableArray(getColumnMenuComponents()), _toConsumableArray(getSharedItems()));
|
|
7
|
+
return [].concat(_toConsumableArray(getRowMenuComponents()), _toConsumableArray(getColumnMenuComponents()), _toConsumableArray(getCellMenuComponents()), _toConsumableArray(getSharedItems()));
|
|
7
8
|
};
|