@atlaskit/editor-plugin-table 22.4.7 → 22.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/pm-plugins/commands/split-cell.js +18 -1
- package/dist/cjs/pm-plugins/transforms/merge.js +5 -2
- package/dist/cjs/ui/FloatingContextualButton/index.js +5 -0
- package/dist/cjs/ui/FloatingContextualMenu/CellMenuPopup.js +104 -0
- package/dist/cjs/ui/FloatingContextualMenu/index.js +13 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +7 -2
- package/dist/cjs/ui/TableMenu/cell/getCellMenuComponents.js +70 -0
- package/dist/cjs/ui/TableMenu/cell/items/MergeCellsItem.js +33 -0
- package/dist/cjs/ui/TableMenu/cell/items/SplitCellItem.js +33 -0
- package/dist/cjs/ui/TableMenu/cell/keys.js +40 -0
- package/dist/cjs/ui/TableMenu/column/getColumnMenuComponents.js +4 -11
- package/dist/cjs/ui/TableMenu/column/items/ColumnBackgroundSection.js +25 -0
- package/dist/cjs/ui/TableMenu/column/items/ColumnToggleSection.js +24 -0
- package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +10 -0
- package/dist/cjs/ui/TableMenu/column/items/HeaderColumnToggleItem.js +17 -1
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +2 -6
- package/dist/cjs/ui/TableMenu/column/items/SortDecreasingItem.js +3 -1
- package/dist/cjs/ui/TableMenu/column/items/SortIncreasingItem.js +3 -1
- package/dist/cjs/ui/TableMenu/row/getRowMenuComponents.js +0 -7
- package/dist/cjs/ui/TableMenu/row/items/HeaderRowToggleItem.js +9 -0
- package/dist/cjs/ui/TableMenu/row/items/MoveRowDownItem.js +10 -0
- package/dist/cjs/ui/TableMenu/row/items/MoveRowUpItem.js +10 -0
- package/dist/cjs/ui/TableMenu/shared/TableMenu.js +53 -3
- package/dist/cjs/ui/TableMenu/shared/TableMenuContext.js +13 -0
- package/dist/cjs/ui/TableMenu/shared/consts.js +3 -2
- package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +28 -19
- package/dist/cjs/ui/TableMenu/shared/getTableMenuComponents.js +2 -1
- package/dist/cjs/ui/event-handlers.js +6 -1
- package/dist/es2019/pm-plugins/commands/split-cell.js +17 -1
- package/dist/es2019/pm-plugins/transforms/merge.js +4 -4
- package/dist/es2019/ui/FloatingContextualButton/index.js +5 -0
- package/dist/es2019/ui/FloatingContextualMenu/CellMenuPopup.js +100 -0
- package/dist/es2019/ui/FloatingContextualMenu/index.js +13 -3
- package/dist/es2019/ui/FloatingDragMenu/index.js +7 -2
- package/dist/es2019/ui/TableMenu/cell/getCellMenuComponents.js +53 -0
- package/dist/es2019/ui/TableMenu/cell/items/MergeCellsItem.js +26 -0
- package/dist/es2019/ui/TableMenu/cell/items/SplitCellItem.js +26 -0
- package/dist/es2019/ui/TableMenu/cell/keys.js +42 -0
- package/dist/es2019/ui/TableMenu/column/getColumnMenuComponents.js +4 -12
- package/dist/es2019/ui/TableMenu/column/items/ColumnBackgroundSection.js +20 -0
- package/dist/es2019/ui/TableMenu/column/items/ColumnToggleSection.js +19 -0
- package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +11 -0
- package/dist/es2019/ui/TableMenu/column/items/HeaderColumnToggleItem.js +15 -0
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -5
- package/dist/es2019/ui/TableMenu/column/items/SortDecreasingItem.js +3 -1
- package/dist/es2019/ui/TableMenu/column/items/SortIncreasingItem.js +3 -1
- package/dist/es2019/ui/TableMenu/row/getRowMenuComponents.js +0 -8
- package/dist/es2019/ui/TableMenu/row/items/HeaderRowToggleItem.js +8 -0
- package/dist/es2019/ui/TableMenu/row/items/MoveRowDownItem.js +8 -0
- package/dist/es2019/ui/TableMenu/row/items/MoveRowUpItem.js +8 -0
- package/dist/es2019/ui/TableMenu/shared/TableMenu.js +51 -3
- package/dist/es2019/ui/TableMenu/shared/TableMenuContext.js +4 -0
- package/dist/es2019/ui/TableMenu/shared/consts.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/es2019/ui/event-handlers.js +4 -1
- package/dist/esm/pm-plugins/commands/split-cell.js +17 -1
- package/dist/esm/pm-plugins/transforms/merge.js +4 -2
- package/dist/esm/ui/FloatingContextualButton/index.js +5 -0
- package/dist/esm/ui/FloatingContextualMenu/CellMenuPopup.js +96 -0
- package/dist/esm/ui/FloatingContextualMenu/index.js +13 -3
- package/dist/esm/ui/FloatingDragMenu/index.js +7 -2
- package/dist/esm/ui/TableMenu/cell/getCellMenuComponents.js +63 -0
- package/dist/esm/ui/TableMenu/cell/items/MergeCellsItem.js +27 -0
- package/dist/esm/ui/TableMenu/cell/items/SplitCellItem.js +27 -0
- package/dist/esm/ui/TableMenu/cell/keys.js +34 -0
- package/dist/esm/ui/TableMenu/column/getColumnMenuComponents.js +4 -12
- package/dist/esm/ui/TableMenu/column/items/ColumnBackgroundSection.js +19 -0
- package/dist/esm/ui/TableMenu/column/items/ColumnToggleSection.js +18 -0
- package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +11 -0
- package/dist/esm/ui/TableMenu/column/items/HeaderColumnToggleItem.js +17 -0
- package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +3 -7
- package/dist/esm/ui/TableMenu/column/items/SortDecreasingItem.js +3 -1
- package/dist/esm/ui/TableMenu/column/items/SortIncreasingItem.js +3 -1
- package/dist/esm/ui/TableMenu/row/getRowMenuComponents.js +0 -8
- package/dist/esm/ui/TableMenu/row/items/HeaderRowToggleItem.js +10 -0
- package/dist/esm/ui/TableMenu/row/items/MoveRowDownItem.js +10 -0
- package/dist/esm/ui/TableMenu/row/items/MoveRowUpItem.js +10 -0
- package/dist/esm/ui/TableMenu/shared/TableMenu.js +52 -3
- package/dist/esm/ui/TableMenu/shared/TableMenuContext.js +6 -0
- package/dist/esm/ui/TableMenu/shared/consts.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/esm/ui/event-handlers.js +6 -1
- package/dist/types/pm-plugins/commands/split-cell.d.ts +2 -0
- package/dist/types/pm-plugins/transforms/merge.d.ts +2 -0
- package/dist/types/ui/FloatingContextualMenu/CellMenuPopup.d.ts +12 -0
- package/dist/types/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -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/ui/TableMenu/column/getColumnMenuComponents.d.ts +0 -7
- package/dist/types/ui/TableMenu/column/items/ColumnBackgroundSection.d.ts +10 -0
- package/dist/types/ui/TableMenu/column/items/ColumnToggleSection.d.ts +9 -0
- package/dist/types/ui/TableMenu/column/items/DistributeColumnsItem.d.ts +1 -1
- package/dist/types/ui/TableMenu/column/items/HeaderColumnToggleItem.d.ts +11 -1
- package/dist/types/ui/TableMenu/row/getRowMenuComponents.d.ts +0 -7
- package/dist/types/ui/TableMenu/row/items/HeaderRowToggleItem.d.ts +1 -1
- package/dist/types/ui/TableMenu/row/items/MoveRowDownItem.d.ts +1 -1
- package/dist/types/ui/TableMenu/row/items/MoveRowUpItem.d.ts +1 -1
- package/dist/types/ui/TableMenu/shared/TableMenu.d.ts +3 -1
- package/dist/types/ui/TableMenu/shared/TableMenuContext.d.ts +14 -0
- package/dist/types/ui/TableMenu/shared/consts.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/commands/split-cell.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/transforms/merge.d.ts +2 -0
- package/dist/types-ts4.5/ui/FloatingContextualMenu/CellMenuPopup.d.ts +12 -0
- package/dist/types-ts4.5/ui/TableMenu/cell/getCellMenuComponents.d.ts +2 -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/dist/types-ts4.5/ui/TableMenu/column/getColumnMenuComponents.d.ts +0 -7
- package/dist/types-ts4.5/ui/TableMenu/column/items/ColumnBackgroundSection.d.ts +10 -0
- package/dist/types-ts4.5/ui/TableMenu/column/items/ColumnToggleSection.d.ts +9 -0
- package/dist/types-ts4.5/ui/TableMenu/column/items/DistributeColumnsItem.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/HeaderColumnToggleItem.d.ts +11 -1
- package/dist/types-ts4.5/ui/TableMenu/row/getRowMenuComponents.d.ts +0 -7
- package/dist/types-ts4.5/ui/TableMenu/row/items/HeaderRowToggleItem.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/MoveRowDownItem.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/MoveRowUpItem.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/TableMenu.d.ts +3 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/TableMenuContext.d.ts +14 -0
- package/dist/types-ts4.5/ui/TableMenu/shared/consts.d.ts +1 -0
- package/package.json +5 -5
|
@@ -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
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
3
|
+
import { UserIntentPopupWrapper } from '@atlaskit/editor-common/user-intent';
|
|
3
4
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
4
5
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -65,10 +66,14 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
65
66
|
forcePlacement: true,
|
|
66
67
|
offset: expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? [TABLE_MENU_OFFSET, 0] : direction === 'row' ? [-9, 0] : [0, -7],
|
|
67
68
|
stick: true
|
|
68
|
-
}, expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? /*#__PURE__*/React.createElement(
|
|
69
|
+
}, expValEquals('platform_editor_table_menu_updates', 'isEnabled', true) ? /*#__PURE__*/React.createElement(UserIntentPopupWrapper, {
|
|
69
70
|
api: api,
|
|
71
|
+
userIntent: "tableDragMenuPopupOpen"
|
|
72
|
+
}, /*#__PURE__*/React.createElement(TableMenu, {
|
|
73
|
+
api: api,
|
|
74
|
+
editorView: editorView,
|
|
70
75
|
surface: direction === 'row' ? ROW_MENU : COLUMN_MENU
|
|
71
|
-
}) : /*#__PURE__*/React.createElement(DragMenu, {
|
|
76
|
+
})) : /*#__PURE__*/React.createElement(DragMenu, {
|
|
72
77
|
editorView: editorView,
|
|
73
78
|
isOpen: isOpen,
|
|
74
79
|
tableNode: tableNode,
|
|
@@ -0,0 +1,63 @@
|
|
|
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_RANK, MERGE_CELLS_ITEM, SPLIT_CELL_ITEM, CELL_ACTION_SECTION_RANK } from './keys';
|
|
6
|
+
export var getCellMenuComponents = function getCellMenuComponents() {
|
|
7
|
+
return [
|
|
8
|
+
// --- Menu surface ---
|
|
9
|
+
{
|
|
10
|
+
type: CELL_MENU.type,
|
|
11
|
+
key: CELL_MENU.key
|
|
12
|
+
},
|
|
13
|
+
// --- Main action section (Background color, Merge cells, Split cell) ---
|
|
14
|
+
{
|
|
15
|
+
type: CELL_ACTION_SECTION.type,
|
|
16
|
+
key: CELL_ACTION_SECTION.key,
|
|
17
|
+
parents: [{
|
|
18
|
+
type: CELL_MENU.type,
|
|
19
|
+
key: CELL_MENU.key,
|
|
20
|
+
rank: CELL_MENU_RANK[CELL_ACTION_SECTION.key]
|
|
21
|
+
}],
|
|
22
|
+
component: function component(props) {
|
|
23
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, props.children);
|
|
24
|
+
}
|
|
25
|
+
}, {
|
|
26
|
+
type: MERGE_CELLS_ITEM.type,
|
|
27
|
+
key: MERGE_CELLS_ITEM.key,
|
|
28
|
+
parents: [{
|
|
29
|
+
type: CELL_ACTION_SECTION.type,
|
|
30
|
+
key: CELL_ACTION_SECTION.key,
|
|
31
|
+
rank: CELL_ACTION_SECTION_RANK[MERGE_CELLS_ITEM.key]
|
|
32
|
+
}],
|
|
33
|
+
component: function component() {
|
|
34
|
+
return /*#__PURE__*/React.createElement(MergeCellsItem, null);
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
type: SPLIT_CELL_ITEM.type,
|
|
38
|
+
key: SPLIT_CELL_ITEM.key,
|
|
39
|
+
parents: [{
|
|
40
|
+
type: CELL_ACTION_SECTION.type,
|
|
41
|
+
key: CELL_ACTION_SECTION.key,
|
|
42
|
+
rank: CELL_ACTION_SECTION_RANK[SPLIT_CELL_ITEM.key]
|
|
43
|
+
}],
|
|
44
|
+
component: function component() {
|
|
45
|
+
return /*#__PURE__*/React.createElement(SplitCellItem, null);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
// --- Danger section (Clear cell) ---
|
|
49
|
+
{
|
|
50
|
+
type: CELL_DANGER_SECTION.type,
|
|
51
|
+
key: CELL_DANGER_SECTION.key,
|
|
52
|
+
parents: [{
|
|
53
|
+
type: CELL_MENU.type,
|
|
54
|
+
key: CELL_MENU.key,
|
|
55
|
+
rank: CELL_MENU_RANK[CELL_DANGER_SECTION.key]
|
|
56
|
+
}],
|
|
57
|
+
component: function component(props) {
|
|
58
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
59
|
+
hasSeparator: true
|
|
60
|
+
}, props.children);
|
|
61
|
+
}
|
|
62
|
+
}];
|
|
63
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Merge cells is only visible when the active selection can actually be merged
|
|
9
|
+
* (multi-cell, non-overlapping).
|
|
10
|
+
*/
|
|
11
|
+
var shouldShowMergeCells = function shouldShowMergeCells(tableMenuContext) {
|
|
12
|
+
return (tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.canMergeCells) === true;
|
|
13
|
+
};
|
|
14
|
+
export var MergeCellsItem = function MergeCellsItem() {
|
|
15
|
+
var tableMenuContext = useTableMenuContext();
|
|
16
|
+
var _useIntl = useIntl(),
|
|
17
|
+
formatMessage = _useIntl.formatMessage;
|
|
18
|
+
if (!shouldShowMergeCells(tableMenuContext)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
22
|
+
elemBefore: /*#__PURE__*/React.createElement(TableCellMergeIcon, {
|
|
23
|
+
label: "",
|
|
24
|
+
size: "small"
|
|
25
|
+
})
|
|
26
|
+
}, formatMessage(messages.mergeCells));
|
|
27
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Split cell is only visible when the active selection sits in a cell whose
|
|
9
|
+
* `rowspan` or `colspan` is greater than one.
|
|
10
|
+
*/
|
|
11
|
+
var shouldShowSplitCell = function shouldShowSplitCell(tableMenuContext) {
|
|
12
|
+
return (tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.canSplitCell) === true;
|
|
13
|
+
};
|
|
14
|
+
export var SplitCellItem = function SplitCellItem() {
|
|
15
|
+
var tableMenuContext = useTableMenuContext();
|
|
16
|
+
var _useIntl = useIntl(),
|
|
17
|
+
formatMessage = _useIntl.formatMessage;
|
|
18
|
+
if (!shouldShowSplitCell(tableMenuContext)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
22
|
+
elemBefore: /*#__PURE__*/React.createElement(TableCellSplitIcon, {
|
|
23
|
+
label: "",
|
|
24
|
+
size: "small"
|
|
25
|
+
})
|
|
26
|
+
}, formatMessage(messages.splitCell));
|
|
27
|
+
};
|
|
@@ -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_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);
|
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
3
3
|
import { AddColumnLeftItem } from './items/AddColumnLeftItem';
|
|
4
4
|
import { AddColumnRightItem } from './items/AddColumnRightItem';
|
|
5
|
+
import { ColumnBackgroundSection } from './items/ColumnBackgroundSection';
|
|
6
|
+
import { ColumnToggleSection } from './items/ColumnToggleSection';
|
|
5
7
|
import { DeleteColumnItem } from './items/DeleteColumnItem';
|
|
6
8
|
import { DistributeColumnsItem } from './items/DistributeColumnsItem';
|
|
7
9
|
import { HeaderColumnToggleItem } from './items/HeaderColumnToggleItem';
|
|
@@ -9,14 +11,6 @@ import { MoveColumnRightItem } from './items/MoveColumnRightItem';
|
|
|
9
11
|
import { SortDecreasingItem } from './items/SortDecreasingItem';
|
|
10
12
|
import { SortIncreasingItem } from './items/SortIncreasingItem';
|
|
11
13
|
import { COLUMN_MENU, COLUMN_TOGGLE_SECTION, COLUMN_BACKGROUND_SECTION, COLUMN_SORT_SECTION, COLUMN_ADD_SECTION, COLUMN_DANGER_SECTION, COLUMN_SECTION_RANK, HEADER_COLUMN_TOGGLE_ITEM, SORT_INCREASING_ITEM, SORT_DECREASING_ITEM, ADD_COLUMN_LEFT_ITEM, ADD_COLUMN_RIGHT_ITEM, MOVE_COLUMN_RIGHT_ITEM, DISTRIBUTE_COLUMNS_ITEM, DELETE_COLUMN_ITEM, COLUMN_TOGGLE_SECTION_RANK, COLUMN_SORT_SECTION_RANK, COLUMN_ADD_SECTION_RANK, COLUMN_DANGER_SECTION_RANK } from './keys';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Returns the RegisterComponent[] array defining the column menu surface.
|
|
15
|
-
*
|
|
16
|
-
* This is a **UI-only stub** — all items are always visible with no conditional
|
|
17
|
-
* logic and no wired actions. Functional behaviour (actions, conditional visibility)
|
|
18
|
-
* will be connected in follow-up tickets.
|
|
19
|
-
*/
|
|
20
14
|
export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
21
15
|
return [
|
|
22
16
|
// --- Menu surface ---
|
|
@@ -34,7 +28,7 @@ export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
|
34
28
|
rank: COLUMN_SECTION_RANK[COLUMN_TOGGLE_SECTION.key]
|
|
35
29
|
}],
|
|
36
30
|
component: function component(props) {
|
|
37
|
-
return /*#__PURE__*/React.createElement(
|
|
31
|
+
return /*#__PURE__*/React.createElement(ColumnToggleSection, null, props.children);
|
|
38
32
|
}
|
|
39
33
|
}, {
|
|
40
34
|
type: HEADER_COLUMN_TOGGLE_ITEM.type,
|
|
@@ -58,9 +52,7 @@ export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
|
58
52
|
rank: COLUMN_SECTION_RANK[COLUMN_BACKGROUND_SECTION.key]
|
|
59
53
|
}],
|
|
60
54
|
component: function component(props) {
|
|
61
|
-
return /*#__PURE__*/React.createElement(
|
|
62
|
-
hasSeparator: true
|
|
63
|
-
}, props.children);
|
|
55
|
+
return /*#__PURE__*/React.createElement(ColumnBackgroundSection, null, props.children);
|
|
64
56
|
}
|
|
65
57
|
},
|
|
66
58
|
// --- Sort section ---
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
3
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
4
|
+
import { shouldShowHeaderColumnToggle } from './HeaderColumnToggleItem';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Background section sits directly below `ColumnToggleSection`. Its separator
|
|
8
|
+
* exists only to divide it from the toggle section; when the toggle section
|
|
9
|
+
* is hidden, the separator must drop too so we don't render a stray rule at
|
|
10
|
+
* the very top of the menu.
|
|
11
|
+
*/
|
|
12
|
+
export var ColumnBackgroundSection = function ColumnBackgroundSection(_ref) {
|
|
13
|
+
var children = _ref.children;
|
|
14
|
+
var tableMenuContext = useTableMenuContext();
|
|
15
|
+
var hasSeparator = shouldShowHeaderColumnToggle(tableMenuContext);
|
|
16
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
17
|
+
hasSeparator: hasSeparator
|
|
18
|
+
}, children);
|
|
19
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
3
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
4
|
+
import { shouldShowHeaderColumnToggle } from './HeaderColumnToggleItem';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The toggle section currently contains only the Header column toggle. When
|
|
8
|
+
* that item is hidden, the whole section disappears so we don't render an
|
|
9
|
+
* empty wrapper (and so the section below can drop its leading separator).
|
|
10
|
+
*/
|
|
11
|
+
export var ColumnToggleSection = function ColumnToggleSection(_ref) {
|
|
12
|
+
var children = _ref.children;
|
|
13
|
+
var tableMenuContext = useTableMenuContext();
|
|
14
|
+
if (!shouldShowHeaderColumnToggle(tableMenuContext)) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, children);
|
|
18
|
+
};
|
|
@@ -2,9 +2,20 @@ import React from 'react';
|
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { TableColumnsDistributeIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
6
|
+
|
|
7
|
+
/** Distribute columns is only visible when more than one column is selected. */
|
|
8
|
+
var shouldShowDistributeColumns = function shouldShowDistributeColumns(tableMenuContext) {
|
|
9
|
+
var _tableMenuContext$sel;
|
|
10
|
+
return ((_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 0) > 1;
|
|
11
|
+
};
|
|
5
12
|
export var DistributeColumnsItem = function DistributeColumnsItem() {
|
|
13
|
+
var tableMenuContext = useTableMenuContext();
|
|
6
14
|
var _useIntl = useIntl(),
|
|
7
15
|
formatMessage = _useIntl.formatMessage;
|
|
16
|
+
if (!shouldShowDistributeColumns(tableMenuContext)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
8
19
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
9
20
|
elemBefore: /*#__PURE__*/React.createElement(TableColumnsDistributeIcon, {
|
|
10
21
|
color: "currentColor",
|
|
@@ -3,10 +3,27 @@ import { useIntl } from 'react-intl';
|
|
|
3
3
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
5
|
import Toggle from '@atlaskit/toggle';
|
|
6
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Header column toggle is only visible when the first column is the entire
|
|
10
|
+
* selection.
|
|
11
|
+
*
|
|
12
|
+
* Exported so `ColumnToggleSection` (which can become empty) and
|
|
13
|
+
* `ColumnBackgroundSection` (which drops its leading separator alongside)
|
|
14
|
+
* can stay in lockstep with this rule without redefining it.
|
|
15
|
+
*/
|
|
16
|
+
export var shouldShowHeaderColumnToggle = function shouldShowHeaderColumnToggle(tableMenuContext) {
|
|
17
|
+
return (tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstColumn) === true && tableMenuContext.selectedColumnCount === 1;
|
|
18
|
+
};
|
|
6
19
|
export var HeaderColumnToggleItem = function HeaderColumnToggleItem() {
|
|
20
|
+
var tableMenuContext = useTableMenuContext();
|
|
7
21
|
var _useIntl = useIntl(),
|
|
8
22
|
formatMessage = _useIntl.formatMessage;
|
|
9
23
|
var label = formatMessage(messages.headerColumn);
|
|
24
|
+
if (!shouldShowHeaderColumnToggle(tableMenuContext)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
10
27
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
11
28
|
elemAfter: /*#__PURE__*/React.createElement(Toggle, {
|
|
12
29
|
label: label,
|
|
@@ -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
|
|
@@ -2,11 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { ArrowDownIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
5
6
|
export var SortDecreasingItem = function SortDecreasingItem() {
|
|
7
|
+
var tableMenuContext = useTableMenuContext();
|
|
6
8
|
var _useIntl = useIntl(),
|
|
7
9
|
formatMessage = _useIntl.formatMessage;
|
|
8
10
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
9
|
-
isDisabled:
|
|
11
|
+
isDisabled: Boolean(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.hasMergedCellsInTable),
|
|
10
12
|
elemBefore: /*#__PURE__*/React.createElement(ArrowDownIcon, {
|
|
11
13
|
color: "currentColor",
|
|
12
14
|
label: "",
|
|
@@ -2,11 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { ArrowUpIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
5
6
|
export var SortIncreasingItem = function SortIncreasingItem() {
|
|
7
|
+
var tableMenuContext = useTableMenuContext();
|
|
6
8
|
var _useIntl = useIntl(),
|
|
7
9
|
formatMessage = _useIntl.formatMessage;
|
|
8
10
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
9
|
-
isDisabled:
|
|
11
|
+
isDisabled: Boolean(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.hasMergedCellsInTable),
|
|
10
12
|
elemBefore: /*#__PURE__*/React.createElement(ArrowUpIcon, {
|
|
11
13
|
color: "currentColor",
|
|
12
14
|
label: "",
|
|
@@ -8,14 +8,6 @@ import { MoveRowDownItem } from './items/MoveRowDownItem';
|
|
|
8
8
|
import { MoveRowUpItem } from './items/MoveRowUpItem';
|
|
9
9
|
import { NumberedRowsToggleItem } from './items/NumberedRowsToggleItem';
|
|
10
10
|
import { ROW_MENU, ROW_TOGGLE_SECTION, ROW_BACKGROUND_SECTION, ROW_ADD_SECTION, ROW_DANGER_SECTION, ROW_MENU_SECTION_RANK, HEADER_ROW_TOGGLE_ITEM, NUMBERED_ROWS_TOGGLE_ITEM, ADD_ROW_ABOVE_ITEM, ADD_ROW_BELOW_ITEM, MOVE_ROW_UP_ITEM, MOVE_ROW_DOWN_ITEM, DELETE_ROW_ITEM, ROW_TOGGLE_SECTION_RANK, ROW_ADD_SECTION_RANK, ROW_DANGER_SECTION_RANK } from './keys';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Returns the RegisterComponent[] array defining the row menu surface.
|
|
14
|
-
*
|
|
15
|
-
* This is a **UI-only stub** — all items are always visible with no conditional
|
|
16
|
-
* logic and no wired actions. Functional behaviour (actions, conditional visibility)
|
|
17
|
-
* will be connected in follow-up tickets.
|
|
18
|
-
*/
|
|
19
11
|
export var getRowMenuComponents = function getRowMenuComponents() {
|
|
20
12
|
return [
|
|
21
13
|
// --- Menu surface ---
|
|
@@ -3,10 +3,20 @@ import { useIntl } from 'react-intl';
|
|
|
3
3
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
5
|
import Toggle from '@atlaskit/toggle';
|
|
6
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
7
|
+
|
|
8
|
+
/** Header row toggle is only visible when the first row is the entire selection. */
|
|
9
|
+
var shouldShowHeaderRowToggle = function shouldShowHeaderRowToggle(tableMenuContext) {
|
|
10
|
+
return (tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstRow) === true && tableMenuContext.selectedRowCount === 1;
|
|
11
|
+
};
|
|
6
12
|
export var HeaderRowToggleItem = function HeaderRowToggleItem() {
|
|
13
|
+
var tableMenuContext = useTableMenuContext();
|
|
7
14
|
var _useIntl = useIntl(),
|
|
8
15
|
formatMessage = _useIntl.formatMessage;
|
|
9
16
|
var label = formatMessage(messages.headerRow);
|
|
17
|
+
if (!shouldShowHeaderRowToggle(tableMenuContext)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
10
20
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
11
21
|
elemAfter: /*#__PURE__*/React.createElement(Toggle, {
|
|
12
22
|
label: label,
|
|
@@ -4,13 +4,23 @@ import { moveRowDown, moveRowDownOld, tooltip } from '@atlaskit/editor-common/ke
|
|
|
4
4
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { TableRowMoveDownIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
6
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
7
8
|
var getMoveRowDownShortcut = function getMoveRowDownShortcut() {
|
|
8
9
|
return tooltip(expValEquals('editor-a11y-fy26-keyboard-move-row-column', 'isEnabled', true) ? moveRowDown : moveRowDownOld);
|
|
9
10
|
};
|
|
11
|
+
|
|
12
|
+
/** Move row down is hidden when the selection includes the last row (cannot move further down). */
|
|
13
|
+
var shouldShowMoveRowDown = function shouldShowMoveRowDown(tableMenuContext) {
|
|
14
|
+
return !(tableMenuContext !== null && tableMenuContext !== void 0 && tableMenuContext.isLastRow);
|
|
15
|
+
};
|
|
10
16
|
export var MoveRowDownItem = function MoveRowDownItem() {
|
|
11
17
|
var _getMoveRowDownShortc;
|
|
18
|
+
var tableMenuContext = useTableMenuContext();
|
|
12
19
|
var _useIntl = useIntl(),
|
|
13
20
|
formatMessage = _useIntl.formatMessage;
|
|
21
|
+
if (!shouldShowMoveRowDown(tableMenuContext)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
14
24
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
15
25
|
elemBefore: /*#__PURE__*/React.createElement(TableRowMoveDownIcon, {
|
|
16
26
|
color: "currentColor",
|
|
@@ -4,13 +4,23 @@ import { moveRowUp, moveRowUpOld, tooltip } from '@atlaskit/editor-common/keymap
|
|
|
4
4
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { TableRowMoveUpIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
6
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
7
8
|
var getMoveRowUpShortcut = function getMoveRowUpShortcut() {
|
|
8
9
|
return tooltip(expValEquals('editor-a11y-fy26-keyboard-move-row-column', 'isEnabled', true) ? moveRowUp : moveRowUpOld);
|
|
9
10
|
};
|
|
11
|
+
|
|
12
|
+
/** Move row up is hidden when the selection includes row 0 (cannot move further up). */
|
|
13
|
+
var shouldShowMoveRowUp = function shouldShowMoveRowUp(tableMenuContext) {
|
|
14
|
+
return !(tableMenuContext !== null && tableMenuContext !== void 0 && tableMenuContext.isFirstRow);
|
|
15
|
+
};
|
|
10
16
|
export var MoveRowUpItem = function MoveRowUpItem() {
|
|
11
17
|
var _getMoveRowUpShortcut;
|
|
18
|
+
var tableMenuContext = useTableMenuContext();
|
|
12
19
|
var _useIntl = useIntl(),
|
|
13
20
|
formatMessage = _useIntl.formatMessage;
|
|
21
|
+
if (!shouldShowMoveRowUp(tableMenuContext)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
14
24
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
15
25
|
elemBefore: /*#__PURE__*/React.createElement(TableRowMoveUpIcon, {
|
|
16
26
|
color: "currentColor",
|
|
@@ -1,27 +1,76 @@
|
|
|
1
1
|
/* TableMenu.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
import "./TableMenu.compiled.css";
|
|
3
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
7
|
import React, { memo, useMemo } from 'react';
|
|
8
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
9
|
+
import { EditorToolbarProvider } from '@atlaskit/editor-common/toolbar';
|
|
10
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
11
|
+
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
5
12
|
import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model';
|
|
6
13
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
14
|
+
import { canSplitCellSelection } from '../../../pm-plugins/commands/split-cell';
|
|
15
|
+
import { canMergeCellSelection } from '../../../pm-plugins/transforms/merge';
|
|
16
|
+
import { TableMenuProvider } from './TableMenuContext';
|
|
7
17
|
var tableMenuContainerStyles = {
|
|
8
18
|
container: "_2rko1qi0 _1reo15vq _18m915vq _1bsb1178 _16qs130s _bfhk1bhr"
|
|
9
19
|
};
|
|
20
|
+
var EMPTY_CONTEXT = {};
|
|
10
21
|
export var TableMenu = /*#__PURE__*/memo(function (_ref) {
|
|
11
22
|
var api = _ref.api,
|
|
23
|
+
editorView = _ref.editorView,
|
|
12
24
|
surface = _ref.surface;
|
|
13
25
|
var components = useMemo(function () {
|
|
14
26
|
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
15
27
|
return (_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(surface.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
16
28
|
}, [api, surface.key]);
|
|
29
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table', 'selection'], function (states) {
|
|
30
|
+
var _states$tableState, _states$selectionStat;
|
|
31
|
+
return {
|
|
32
|
+
tableNode: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.tableNode,
|
|
33
|
+
selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
|
|
34
|
+
};
|
|
35
|
+
}),
|
|
36
|
+
tableNode = _useSharedPluginState.tableNode,
|
|
37
|
+
selection = _useSharedPluginState.selection;
|
|
38
|
+
var tableMenuContext = useMemo(function () {
|
|
39
|
+
if (!selection || !tableNode) {
|
|
40
|
+
return EMPTY_CONTEXT;
|
|
41
|
+
}
|
|
42
|
+
var tableMap = TableMap.get(tableNode);
|
|
43
|
+
var selectionRect = getSelectionRect(selection);
|
|
44
|
+
var cellOps = {
|
|
45
|
+
canMergeCells: canMergeCellSelection(selection),
|
|
46
|
+
canSplitCell: canSplitCellSelection(selection),
|
|
47
|
+
hasMergedCellsInTable: tableMap.hasMergedCells()
|
|
48
|
+
};
|
|
49
|
+
if (!selectionRect) {
|
|
50
|
+
return cellOps;
|
|
51
|
+
}
|
|
52
|
+
return _objectSpread(_objectSpread({}, cellOps), {}, {
|
|
53
|
+
isFirstRow: selectionRect.top === 0,
|
|
54
|
+
isLastRow: selectionRect.bottom === tableMap.height,
|
|
55
|
+
selectedRowCount: selectionRect.bottom - selectionRect.top,
|
|
56
|
+
isFirstColumn: selectionRect.left === 0,
|
|
57
|
+
isLastColumn: selectionRect.right === tableMap.width,
|
|
58
|
+
selectedColumnCount: selectionRect.right - selectionRect.left
|
|
59
|
+
});
|
|
60
|
+
}, [selection, tableNode]);
|
|
17
61
|
if (components.length === 0) {
|
|
18
62
|
return null;
|
|
19
63
|
}
|
|
20
|
-
return /*#__PURE__*/React.createElement(
|
|
64
|
+
return /*#__PURE__*/React.createElement(EditorToolbarProvider, {
|
|
65
|
+
editorView: editorView !== null && editorView !== void 0 ? editorView : null
|
|
66
|
+
}, /*#__PURE__*/React.createElement(TableMenuProvider, {
|
|
67
|
+
value: tableMenuContext
|
|
68
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
21
69
|
xcss: tableMenuContainerStyles.container,
|
|
22
70
|
testId: surface.key
|
|
23
71
|
}, /*#__PURE__*/React.createElement(SurfaceRenderer, {
|
|
24
72
|
surface: surface,
|
|
25
73
|
components: components
|
|
26
|
-
}));
|
|
27
|
-
});
|
|
74
|
+
}))));
|
|
75
|
+
});
|
|
76
|
+
TableMenu.displayName = 'TableMenu';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
var TableMenuContext = /*#__PURE__*/React.createContext(undefined);
|
|
3
|
+
export var TableMenuProvider = TableMenuContext.Provider;
|
|
4
|
+
export var useTableMenuContext = function useTableMenuContext() {
|
|
5
|
+
return React.useContext(TableMenuContext);
|
|
6
|
+
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export var TABLE_MENU_WIDTH = 280;
|
|
1
|
+
export var TABLE_MENU_WIDTH = 280;
|
|
2
|
+
export var TABLE_MENU_SELECTOR = '[data-testid="column-handle-menu"], [data-testid="row-handle-menu"], [data-toolbar-nested-dropdown-menu]';
|
|
@@ -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
|
};
|