@atlaskit/editor-plugin-table 22.4.11 → 22.4.12
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 +9 -0
- package/dist/cjs/tablePlugin.js +4 -1
- package/dist/cjs/ui/TableMenu/row/getRowMenuComponents.js +23 -8
- package/dist/cjs/ui/TableMenu/row/items/AddRowAboveItem.js +24 -1
- package/dist/cjs/ui/TableMenu/row/items/AddRowBelowItem.js +24 -1
- package/dist/cjs/ui/TableMenu/row/items/DeleteRowItem.js +55 -3
- package/dist/cjs/ui/TableMenu/row/items/HeaderRowToggleItem.js +38 -5
- package/dist/cjs/ui/TableMenu/row/items/MoveRowDownItem.js +38 -13
- package/dist/cjs/ui/TableMenu/row/items/MoveRowUpItem.js +38 -13
- package/dist/cjs/ui/TableMenu/row/items/NumberedRowsToggleItem.js +29 -2
- package/dist/cjs/ui/TableMenu/shared/consts.js +4 -2
- package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +5 -2
- package/dist/cjs/ui/TableMenu/shared/getTableMenuComponents.js +2 -2
- package/dist/cjs/ui/TableMenu/shared/items/ClearCellsItem.js +23 -3
- package/dist/cjs/ui/TableMenu/shared/types.js +5 -0
- package/dist/es2019/tablePlugin.js +4 -1
- package/dist/es2019/ui/TableMenu/row/getRowMenuComponents.js +24 -8
- package/dist/es2019/ui/TableMenu/row/items/AddRowAboveItem.js +27 -1
- package/dist/es2019/ui/TableMenu/row/items/AddRowBelowItem.js +27 -1
- package/dist/es2019/ui/TableMenu/row/items/DeleteRowItem.js +59 -3
- package/dist/es2019/ui/TableMenu/row/items/HeaderRowToggleItem.js +42 -5
- package/dist/es2019/ui/TableMenu/row/items/MoveRowDownItem.js +42 -11
- package/dist/es2019/ui/TableMenu/row/items/MoveRowUpItem.js +42 -11
- package/dist/es2019/ui/TableMenu/row/items/NumberedRowsToggleItem.js +33 -2
- package/dist/es2019/ui/TableMenu/shared/consts.js +3 -1
- package/dist/es2019/ui/TableMenu/shared/getSharedItems.js +6 -2
- package/dist/es2019/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
- package/dist/es2019/ui/TableMenu/shared/items/ClearCellsItem.js +26 -3
- package/dist/es2019/ui/TableMenu/shared/types.js +1 -0
- package/dist/esm/tablePlugin.js +4 -1
- package/dist/esm/ui/TableMenu/row/getRowMenuComponents.js +23 -8
- package/dist/esm/ui/TableMenu/row/items/AddRowAboveItem.js +24 -1
- package/dist/esm/ui/TableMenu/row/items/AddRowBelowItem.js +24 -1
- package/dist/esm/ui/TableMenu/row/items/DeleteRowItem.js +55 -3
- package/dist/esm/ui/TableMenu/row/items/HeaderRowToggleItem.js +38 -6
- package/dist/esm/ui/TableMenu/row/items/MoveRowDownItem.js +39 -14
- package/dist/esm/ui/TableMenu/row/items/MoveRowUpItem.js +39 -14
- package/dist/esm/ui/TableMenu/row/items/NumberedRowsToggleItem.js +29 -2
- package/dist/esm/ui/TableMenu/shared/consts.js +3 -1
- package/dist/esm/ui/TableMenu/shared/getSharedItems.js +5 -2
- package/dist/esm/ui/TableMenu/shared/getTableMenuComponents.js +2 -2
- package/dist/esm/ui/TableMenu/shared/items/ClearCellsItem.js +23 -3
- package/dist/esm/ui/TableMenu/shared/types.js +1 -0
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/ui/TableMenu/row/getRowMenuComponents.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/AddRowAboveItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/AddRowBelowItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/DeleteRowItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/HeaderRowToggleItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/MoveRowDownItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/MoveRowUpItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/NumberedRowsToggleItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/shared/consts.d.ts +2 -0
- package/dist/types/ui/TableMenu/shared/getSharedItems.d.ts +2 -1
- package/dist/types/ui/TableMenu/shared/getTableMenuComponents.d.ts +2 -1
- package/dist/types/ui/TableMenu/shared/items/ClearCellsItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/shared/types.d.ts +4 -0
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableMenu/row/getRowMenuComponents.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/AddRowAboveItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/AddRowBelowItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/DeleteRowItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/HeaderRowToggleItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/MoveRowDownItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/MoveRowUpItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/NumberedRowsToggleItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/consts.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableMenu/shared/getSharedItems.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/getTableMenuComponents.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/items/ClearCellsItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/types.d.ts +4 -0
- package/package.json +3 -3
package/dist/esm/tablePlugin.js
CHANGED
|
@@ -85,7 +85,9 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
85
85
|
!(options !== null && options !== void 0 && options.isChromelessEditor) && !(options !== null && options !== void 0 && options.isCommentEditor) && (options === null || options === void 0 || (_options$getEditorFea2 = options.getEditorFeatureFlags) === null || _options$getEditorFea2 === void 0 ? void 0 : _options$getEditorFea2.call(options).tableSelector) && editorExperiment('platform_editor_controls', 'variant1');
|
|
86
86
|
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
87
87
|
var _api$uiControlRegistr;
|
|
88
|
-
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register(getTableMenuComponents(
|
|
88
|
+
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register(getTableMenuComponents({
|
|
89
|
+
api: api
|
|
90
|
+
}));
|
|
89
91
|
}
|
|
90
92
|
return {
|
|
91
93
|
name: 'table',
|
|
@@ -113,6 +115,7 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
113
115
|
wasMaxWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasMaxWidthEnabled),
|
|
114
116
|
isHeaderRowEnabled: tablePluginState.isHeaderRowEnabled,
|
|
115
117
|
isHeaderColumnEnabled: tablePluginState.isHeaderColumnEnabled,
|
|
118
|
+
isNumberColumnEnabled: tablePluginState.isNumberColumnEnabled,
|
|
116
119
|
ordering: tablePluginState.ordering,
|
|
117
120
|
isResizing: !!(tableResizingPluginState !== null && tableResizingPluginState !== void 0 && tableResizingPluginState.dragging || tableWidthResizingPluginState !== null && tableWidthResizingPluginState !== void 0 && tableWidthResizingPluginState.resizing),
|
|
118
121
|
isTableResizing: tableWidthResizingPluginState === null || tableWidthResizingPluginState === void 0 ? void 0 : tableWidthResizingPluginState.resizing,
|
|
@@ -8,7 +8,8 @@ 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
|
-
export var getRowMenuComponents = function getRowMenuComponents() {
|
|
11
|
+
export var getRowMenuComponents = function getRowMenuComponents(_ref) {
|
|
12
|
+
var api = _ref.api;
|
|
12
13
|
return [
|
|
13
14
|
// --- Menu surface ---
|
|
14
15
|
{
|
|
@@ -36,7 +37,9 @@ export var getRowMenuComponents = function getRowMenuComponents() {
|
|
|
36
37
|
rank: ROW_TOGGLE_SECTION_RANK[HEADER_ROW_TOGGLE_ITEM.key]
|
|
37
38
|
}],
|
|
38
39
|
component: function component() {
|
|
39
|
-
return /*#__PURE__*/React.createElement(HeaderRowToggleItem,
|
|
40
|
+
return /*#__PURE__*/React.createElement(HeaderRowToggleItem, {
|
|
41
|
+
api: api
|
|
42
|
+
});
|
|
40
43
|
}
|
|
41
44
|
}, {
|
|
42
45
|
type: NUMBERED_ROWS_TOGGLE_ITEM.type,
|
|
@@ -47,7 +50,9 @@ export var getRowMenuComponents = function getRowMenuComponents() {
|
|
|
47
50
|
rank: ROW_TOGGLE_SECTION_RANK[NUMBERED_ROWS_TOGGLE_ITEM.key]
|
|
48
51
|
}],
|
|
49
52
|
component: function component() {
|
|
50
|
-
return /*#__PURE__*/React.createElement(NumberedRowsToggleItem,
|
|
53
|
+
return /*#__PURE__*/React.createElement(NumberedRowsToggleItem, {
|
|
54
|
+
api: api
|
|
55
|
+
});
|
|
51
56
|
}
|
|
52
57
|
},
|
|
53
58
|
// --- Background color section ---
|
|
@@ -88,7 +93,9 @@ export var getRowMenuComponents = function getRowMenuComponents() {
|
|
|
88
93
|
rank: ROW_ADD_SECTION_RANK[ADD_ROW_ABOVE_ITEM.key]
|
|
89
94
|
}],
|
|
90
95
|
component: function component() {
|
|
91
|
-
return /*#__PURE__*/React.createElement(AddRowAboveItem,
|
|
96
|
+
return /*#__PURE__*/React.createElement(AddRowAboveItem, {
|
|
97
|
+
api: api
|
|
98
|
+
});
|
|
92
99
|
}
|
|
93
100
|
}, {
|
|
94
101
|
type: ADD_ROW_BELOW_ITEM.type,
|
|
@@ -99,7 +106,9 @@ export var getRowMenuComponents = function getRowMenuComponents() {
|
|
|
99
106
|
rank: ROW_ADD_SECTION_RANK[ADD_ROW_BELOW_ITEM.key]
|
|
100
107
|
}],
|
|
101
108
|
component: function component() {
|
|
102
|
-
return /*#__PURE__*/React.createElement(AddRowBelowItem,
|
|
109
|
+
return /*#__PURE__*/React.createElement(AddRowBelowItem, {
|
|
110
|
+
api: api
|
|
111
|
+
});
|
|
103
112
|
}
|
|
104
113
|
}, {
|
|
105
114
|
type: MOVE_ROW_UP_ITEM.type,
|
|
@@ -110,7 +119,9 @@ export var getRowMenuComponents = function getRowMenuComponents() {
|
|
|
110
119
|
rank: ROW_ADD_SECTION_RANK[MOVE_ROW_UP_ITEM.key]
|
|
111
120
|
}],
|
|
112
121
|
component: function component() {
|
|
113
|
-
return /*#__PURE__*/React.createElement(MoveRowUpItem,
|
|
122
|
+
return /*#__PURE__*/React.createElement(MoveRowUpItem, {
|
|
123
|
+
api: api
|
|
124
|
+
});
|
|
114
125
|
}
|
|
115
126
|
}, {
|
|
116
127
|
type: MOVE_ROW_DOWN_ITEM.type,
|
|
@@ -121,7 +132,9 @@ export var getRowMenuComponents = function getRowMenuComponents() {
|
|
|
121
132
|
rank: ROW_ADD_SECTION_RANK[MOVE_ROW_DOWN_ITEM.key]
|
|
122
133
|
}],
|
|
123
134
|
component: function component() {
|
|
124
|
-
return /*#__PURE__*/React.createElement(MoveRowDownItem,
|
|
135
|
+
return /*#__PURE__*/React.createElement(MoveRowDownItem, {
|
|
136
|
+
api: api
|
|
137
|
+
});
|
|
125
138
|
}
|
|
126
139
|
},
|
|
127
140
|
// --- Danger section (Clear cells, Delete row) ---
|
|
@@ -147,7 +160,9 @@ export var getRowMenuComponents = function getRowMenuComponents() {
|
|
|
147
160
|
rank: ROW_DANGER_SECTION_RANK[DELETE_ROW_ITEM.key]
|
|
148
161
|
}],
|
|
149
162
|
component: function component() {
|
|
150
|
-
return /*#__PURE__*/React.createElement(DeleteRowItem,
|
|
163
|
+
return /*#__PURE__*/React.createElement(DeleteRowItem, {
|
|
164
|
+
api: api
|
|
165
|
+
});
|
|
151
166
|
}
|
|
152
167
|
}];
|
|
153
168
|
};
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import { addRowBefore, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
4
5
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
7
|
+
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
5
8
|
import { TableRowAddAboveIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
6
|
-
|
|
9
|
+
import { insertRowWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
10
|
+
export var AddRowAboveItem = function AddRowAboveItem(props) {
|
|
7
11
|
var _tooltip;
|
|
12
|
+
var api = props.api;
|
|
13
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
14
|
+
editorView = _useEditorToolbar.editorView;
|
|
8
15
|
var _useIntl = useIntl(),
|
|
9
16
|
formatMessage = _useIntl.formatMessage;
|
|
17
|
+
var handleClick = function handleClick() {
|
|
18
|
+
var _api$analytics;
|
|
19
|
+
if (!editorView) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
23
|
+
var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.top;
|
|
24
|
+
if (index === undefined) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
insertRowWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.TABLE_CONTEXT_MENU, {
|
|
28
|
+
index: index,
|
|
29
|
+
moveCursorToInsertedRow: true
|
|
30
|
+
})(editorView.state, editorView.dispatch);
|
|
31
|
+
};
|
|
10
32
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
33
|
+
onClick: handleClick,
|
|
11
34
|
elemBefore: /*#__PURE__*/React.createElement(TableRowAddAboveIcon, {
|
|
12
35
|
color: "currentColor",
|
|
13
36
|
label: "",
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import { addRowAfter, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
4
5
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
7
|
+
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
5
8
|
import { TableRowAddBelowIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
6
|
-
|
|
9
|
+
import { insertRowWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
10
|
+
export var AddRowBelowItem = function AddRowBelowItem(props) {
|
|
7
11
|
var _tooltip;
|
|
12
|
+
var api = props.api;
|
|
13
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
14
|
+
editorView = _useEditorToolbar.editorView;
|
|
8
15
|
var _useIntl = useIntl(),
|
|
9
16
|
formatMessage = _useIntl.formatMessage;
|
|
17
|
+
var handleClick = function handleClick() {
|
|
18
|
+
var _api$analytics;
|
|
19
|
+
if (!editorView) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
23
|
+
var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.bottom;
|
|
24
|
+
if (index === undefined) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
insertRowWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.TABLE_CONTEXT_MENU, {
|
|
28
|
+
index: index,
|
|
29
|
+
moveCursorToInsertedRow: true
|
|
30
|
+
})(editorView.state, editorView.dispatch);
|
|
31
|
+
};
|
|
10
32
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
33
|
+
onClick: handleClick,
|
|
11
34
|
elemBefore: /*#__PURE__*/React.createElement(TableRowAddBelowIcon, {
|
|
12
35
|
color: "currentColor",
|
|
13
36
|
label: "",
|
|
@@ -1,13 +1,65 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
5
|
import { deleteRow, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
4
6
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
8
|
+
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
5
9
|
import { DeleteIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
import { clearHoverSelection, hoverRows } from '../../../../pm-plugins/commands';
|
|
11
|
+
import { deleteRowsWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
12
|
+
import { getSelectedRowIndexes } from '../../../../pm-plugins/utils/selection';
|
|
13
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
14
|
+
export var DeleteRowItem = function DeleteRowItem(props) {
|
|
15
|
+
var _tableMenuContext$sel, _tooltip;
|
|
16
|
+
var api = props.api;
|
|
17
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
18
|
+
editorView = _useEditorToolbar.editorView;
|
|
19
|
+
var tableMenuContext = useTableMenuContext();
|
|
20
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
21
|
+
var _states$tableState;
|
|
22
|
+
return {
|
|
23
|
+
isHeaderRowRequired: (_states$tableState = states.tableState) === null || _states$tableState === void 0 || (_states$tableState = _states$tableState.pluginConfig) === null || _states$tableState === void 0 ? void 0 : _states$tableState.isHeaderRowRequired
|
|
24
|
+
};
|
|
25
|
+
}),
|
|
26
|
+
isHeaderRowRequired = _useSharedPluginState.isHeaderRowRequired;
|
|
27
|
+
var selectedRowCount = (_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedRowCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1;
|
|
8
28
|
var _useIntl = useIntl(),
|
|
9
29
|
formatMessage = _useIntl.formatMessage;
|
|
30
|
+
var handleMouseEnter = function handleMouseEnter() {
|
|
31
|
+
if (!editorView) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
35
|
+
if (!selectionRect) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
hoverRows(getSelectedRowIndexes(selectionRect), true)(editorView.state, editorView.dispatch);
|
|
39
|
+
};
|
|
40
|
+
var handleMouseLeave = function handleMouseLeave() {
|
|
41
|
+
if (!editorView) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
clearHoverSelection()(editorView.state, editorView.dispatch);
|
|
45
|
+
};
|
|
46
|
+
var handleClick = function handleClick() {
|
|
47
|
+
var _api$analytics;
|
|
48
|
+
if (!editorView) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
52
|
+
if (!selectionRect) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
deleteRowsWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect, !!isHeaderRowRequired)(editorView.state, editorView.dispatch);
|
|
56
|
+
};
|
|
10
57
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
58
|
+
onClick: handleClick,
|
|
59
|
+
onFocus: handleMouseEnter,
|
|
60
|
+
onMouseEnter: handleMouseEnter,
|
|
61
|
+
onBlur: handleMouseLeave,
|
|
62
|
+
onMouseLeave: handleMouseLeave,
|
|
11
63
|
elemBefore: /*#__PURE__*/React.createElement(DeleteIcon, {
|
|
12
64
|
color: "currentColor",
|
|
13
65
|
label: "",
|
|
@@ -17,6 +69,6 @@ export var DeleteRowItem = function DeleteRowItem() {
|
|
|
17
69
|
shortcut: (_tooltip = tooltip(deleteRow)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
18
70
|
})
|
|
19
71
|
}, formatMessage(messages.removeRows, {
|
|
20
|
-
0:
|
|
72
|
+
0: selectedRowCount
|
|
21
73
|
}));
|
|
22
74
|
};
|
|
@@ -1,26 +1,58 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
4
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
4
6
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
7
|
import Toggle from '@atlaskit/toggle';
|
|
8
|
+
import { toggleHeaderRowWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
6
9
|
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
7
|
-
|
|
8
10
|
/** Header row toggle is only visible when the first row is the entire selection. */
|
|
9
|
-
var shouldShowHeaderRowToggle = function shouldShowHeaderRowToggle(
|
|
10
|
-
|
|
11
|
+
var shouldShowHeaderRowToggle = function shouldShowHeaderRowToggle(_ref) {
|
|
12
|
+
var isFirstRow = _ref.isFirstRow,
|
|
13
|
+
isHeaderRowAllowed = _ref.isHeaderRowAllowed,
|
|
14
|
+
selectedRowCount = _ref.selectedRowCount;
|
|
15
|
+
return isHeaderRowAllowed === true && isFirstRow && selectedRowCount === 1;
|
|
11
16
|
};
|
|
12
|
-
export var HeaderRowToggleItem = function HeaderRowToggleItem() {
|
|
17
|
+
export var HeaderRowToggleItem = function HeaderRowToggleItem(props) {
|
|
18
|
+
var _tableMenuContext$sel;
|
|
19
|
+
var api = props.api;
|
|
20
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
21
|
+
editorView = _useEditorToolbar.editorView;
|
|
13
22
|
var tableMenuContext = useTableMenuContext();
|
|
23
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
24
|
+
var _states$tableState, _states$tableState2;
|
|
25
|
+
return {
|
|
26
|
+
isHeaderRowAllowed: (_states$tableState = states.tableState) === null || _states$tableState === void 0 || (_states$tableState = _states$tableState.pluginConfig) === null || _states$tableState === void 0 ? void 0 : _states$tableState.allowHeaderRow,
|
|
27
|
+
isHeaderRowEnabled: (_states$tableState2 = states.tableState) === null || _states$tableState2 === void 0 ? void 0 : _states$tableState2.isHeaderRowEnabled
|
|
28
|
+
};
|
|
29
|
+
}),
|
|
30
|
+
isHeaderRowAllowed = _useSharedPluginState.isHeaderRowAllowed,
|
|
31
|
+
isHeaderRowEnabled = _useSharedPluginState.isHeaderRowEnabled;
|
|
32
|
+
var selectedRowCount = (_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedRowCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 0;
|
|
14
33
|
var _useIntl = useIntl(),
|
|
15
34
|
formatMessage = _useIntl.formatMessage;
|
|
16
35
|
var label = formatMessage(messages.headerRow);
|
|
17
|
-
|
|
36
|
+
var handleClick = function handleClick() {
|
|
37
|
+
var _api$analytics;
|
|
38
|
+
if (!editorView) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
toggleHeaderRowWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(editorView.state, editorView.dispatch);
|
|
42
|
+
};
|
|
43
|
+
if (!shouldShowHeaderRowToggle({
|
|
44
|
+
isFirstRow: (tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstRow) === true,
|
|
45
|
+
isHeaderRowAllowed: isHeaderRowAllowed,
|
|
46
|
+
selectedRowCount: selectedRowCount
|
|
47
|
+
})) {
|
|
18
48
|
return null;
|
|
19
49
|
}
|
|
20
50
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
51
|
+
onClick: handleClick,
|
|
21
52
|
elemAfter: /*#__PURE__*/React.createElement(Toggle, {
|
|
22
53
|
label: label,
|
|
23
|
-
isChecked:
|
|
54
|
+
isChecked: !!isHeaderRowEnabled,
|
|
55
|
+
onChange: handleClick
|
|
24
56
|
})
|
|
25
57
|
}, label);
|
|
26
58
|
};
|
|
@@ -1,36 +1,61 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
-
import {
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { moveRowDown, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
4
6
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
8
|
+
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
5
9
|
import { TableRowMoveDownIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
6
|
-
import {
|
|
10
|
+
import { moveSourceWithAnalytics } from '../../../../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
11
|
+
import { getPluginState } from '../../../../pm-plugins/plugin-factory';
|
|
12
|
+
import { getSelectedRowIndexes } from '../../../../pm-plugins/utils/selection';
|
|
13
|
+
import { TABLE_ROW } from '../../shared/consts';
|
|
7
14
|
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
8
|
-
var
|
|
9
|
-
return
|
|
15
|
+
var shouldShowMoveRowDown = function shouldShowMoveRowDown(isLastRow) {
|
|
16
|
+
return !isLastRow;
|
|
10
17
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export var MoveRowDownItem = function MoveRowDownItem() {
|
|
17
|
-
var _getMoveRowDownShortc;
|
|
18
|
+
export var MoveRowDownItem = function MoveRowDownItem(props) {
|
|
19
|
+
var _tableMenuContext$sel, _tooltip;
|
|
20
|
+
var api = props.api;
|
|
21
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
22
|
+
editorView = _useEditorToolbar.editorView;
|
|
18
23
|
var tableMenuContext = useTableMenuContext();
|
|
24
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
25
|
+
var _states$tableState;
|
|
26
|
+
return {
|
|
27
|
+
tableNode: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.tableNode
|
|
28
|
+
};
|
|
29
|
+
}),
|
|
30
|
+
tableNode = _useSharedPluginState.tableNode;
|
|
31
|
+
var selectedRowCount = (_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedRowCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1;
|
|
19
32
|
var _useIntl = useIntl(),
|
|
20
33
|
formatMessage = _useIntl.formatMessage;
|
|
21
|
-
|
|
34
|
+
var handleClick = function handleClick() {
|
|
35
|
+
var _api$analytics, _api$accessibilityUti;
|
|
36
|
+
if (!editorView) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
40
|
+
if (!selectionRect) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
moveSourceWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify, getPluginState(editorView.state).getIntl)(INPUT_METHOD.TABLE_CONTEXT_MENU, TABLE_ROW, getSelectedRowIndexes(selectionRect), selectionRect.bottom)(editorView.state, editorView.dispatch);
|
|
44
|
+
};
|
|
45
|
+
if (!tableNode || !shouldShowMoveRowDown(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isLastRow)) {
|
|
22
46
|
return null;
|
|
23
47
|
}
|
|
24
48
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
49
|
+
onClick: handleClick,
|
|
25
50
|
elemBefore: /*#__PURE__*/React.createElement(TableRowMoveDownIcon, {
|
|
26
51
|
color: "currentColor",
|
|
27
52
|
label: "",
|
|
28
53
|
size: "small"
|
|
29
54
|
}),
|
|
30
55
|
elemAfter: /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
|
|
31
|
-
shortcut: (
|
|
56
|
+
shortcut: (_tooltip = tooltip(moveRowDown)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
32
57
|
})
|
|
33
58
|
}, formatMessage(messages.moveRowDown, {
|
|
34
|
-
0:
|
|
59
|
+
0: selectedRowCount
|
|
35
60
|
}));
|
|
36
61
|
};
|
|
@@ -1,36 +1,61 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
-
import {
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { moveRowUp, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
4
6
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
8
|
+
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
5
9
|
import { TableRowMoveUpIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
6
|
-
import {
|
|
10
|
+
import { moveSourceWithAnalytics } from '../../../../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
11
|
+
import { getPluginState } from '../../../../pm-plugins/plugin-factory';
|
|
12
|
+
import { getSelectedRowIndexes } from '../../../../pm-plugins/utils/selection';
|
|
13
|
+
import { TABLE_ROW } from '../../shared/consts';
|
|
7
14
|
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
8
|
-
var
|
|
9
|
-
return
|
|
15
|
+
var shouldShowMoveRowUp = function shouldShowMoveRowUp(isFirstRow) {
|
|
16
|
+
return !isFirstRow;
|
|
10
17
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export var MoveRowUpItem = function MoveRowUpItem() {
|
|
17
|
-
var _getMoveRowUpShortcut;
|
|
18
|
+
export var MoveRowUpItem = function MoveRowUpItem(props) {
|
|
19
|
+
var _tableMenuContext$sel, _tooltip;
|
|
20
|
+
var api = props.api;
|
|
21
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
22
|
+
editorView = _useEditorToolbar.editorView;
|
|
18
23
|
var tableMenuContext = useTableMenuContext();
|
|
24
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
25
|
+
var _states$tableState;
|
|
26
|
+
return {
|
|
27
|
+
tableNode: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.tableNode
|
|
28
|
+
};
|
|
29
|
+
}),
|
|
30
|
+
tableNode = _useSharedPluginState.tableNode;
|
|
31
|
+
var selectedRowCount = (_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedRowCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1;
|
|
19
32
|
var _useIntl = useIntl(),
|
|
20
33
|
formatMessage = _useIntl.formatMessage;
|
|
21
|
-
|
|
34
|
+
var handleClick = function handleClick() {
|
|
35
|
+
var _api$analytics, _api$accessibilityUti;
|
|
36
|
+
if (!editorView) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
40
|
+
if (!selectionRect) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
moveSourceWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 ? void 0 : _api$accessibilityUti.actions.ariaNotify, getPluginState(editorView.state).getIntl)(INPUT_METHOD.TABLE_CONTEXT_MENU, TABLE_ROW, getSelectedRowIndexes(selectionRect), selectionRect.top - 1)(editorView.state, editorView.dispatch);
|
|
44
|
+
};
|
|
45
|
+
if (!tableNode || !shouldShowMoveRowUp(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstRow)) {
|
|
22
46
|
return null;
|
|
23
47
|
}
|
|
24
48
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
49
|
+
onClick: handleClick,
|
|
25
50
|
elemBefore: /*#__PURE__*/React.createElement(TableRowMoveUpIcon, {
|
|
26
51
|
color: "currentColor",
|
|
27
52
|
label: "",
|
|
28
53
|
size: "small"
|
|
29
54
|
}),
|
|
30
55
|
elemAfter: /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
|
|
31
|
-
shortcut: (
|
|
56
|
+
shortcut: (_tooltip = tooltip(moveRowUp)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
32
57
|
})
|
|
33
58
|
}, formatMessage(messages.moveRowUp, {
|
|
34
|
-
0:
|
|
59
|
+
0: selectedRowCount
|
|
35
60
|
}));
|
|
36
61
|
};
|
|
@@ -1,16 +1,43 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
4
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
4
6
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
5
7
|
import Toggle from '@atlaskit/toggle';
|
|
6
|
-
|
|
8
|
+
import { toggleNumberColumnWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
9
|
+
export var NumberedRowsToggleItem = function NumberedRowsToggleItem(props) {
|
|
10
|
+
var api = props.api;
|
|
11
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
12
|
+
editorView = _useEditorToolbar.editorView;
|
|
13
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
14
|
+
var _states$tableState, _states$tableState2;
|
|
15
|
+
return {
|
|
16
|
+
isNumberColumnAllowed: (_states$tableState = states.tableState) === null || _states$tableState === void 0 || (_states$tableState = _states$tableState.pluginConfig) === null || _states$tableState === void 0 ? void 0 : _states$tableState.allowNumberColumn,
|
|
17
|
+
isNumberColumnEnabled: (_states$tableState2 = states.tableState) === null || _states$tableState2 === void 0 ? void 0 : _states$tableState2.isNumberColumnEnabled
|
|
18
|
+
};
|
|
19
|
+
}),
|
|
20
|
+
isNumberColumnAllowed = _useSharedPluginState.isNumberColumnAllowed,
|
|
21
|
+
isNumberColumnEnabled = _useSharedPluginState.isNumberColumnEnabled;
|
|
7
22
|
var _useIntl = useIntl(),
|
|
8
23
|
formatMessage = _useIntl.formatMessage;
|
|
9
24
|
var label = formatMessage(messages.numberedRows);
|
|
25
|
+
var handleClick = function handleClick() {
|
|
26
|
+
var _api$analytics;
|
|
27
|
+
if (!editorView) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
toggleNumberColumnWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(editorView.state, editorView.dispatch);
|
|
31
|
+
};
|
|
32
|
+
if (!isNumberColumnAllowed) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
10
35
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
36
|
+
onClick: handleClick,
|
|
11
37
|
elemAfter: /*#__PURE__*/React.createElement(Toggle, {
|
|
12
38
|
label: label,
|
|
13
|
-
isChecked:
|
|
39
|
+
isChecked: !!isNumberColumnEnabled,
|
|
40
|
+
onChange: handleClick
|
|
14
41
|
})
|
|
15
42
|
}, label);
|
|
16
43
|
};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
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]';
|
|
2
|
+
export var TABLE_MENU_SELECTOR = '[data-testid="column-handle-menu"], [data-testid="row-handle-menu"], [data-toolbar-nested-dropdown-menu]';
|
|
3
|
+
export var TABLE_ROW = 'table-row';
|
|
4
|
+
export var TABLE_COLUMN = 'table-column';
|
|
@@ -5,7 +5,8 @@ import { ROW_BACKGROUND_SECTION, ROW_DANGER_SECTION, ROW_BACKGROUND_SECTION_RANK
|
|
|
5
5
|
import { BackgroundColorItem } from './items/BackgroundColorItem';
|
|
6
6
|
import { ClearCellsItem } from './items/ClearCellsItem';
|
|
7
7
|
import { BACKGROUND_COLOR_ITEM, CLEAR_CELLS_ITEM } from './keys';
|
|
8
|
-
export var getSharedItems = function getSharedItems() {
|
|
8
|
+
export var getSharedItems = function getSharedItems(_ref) {
|
|
9
|
+
var api = _ref.api;
|
|
9
10
|
return [{
|
|
10
11
|
type: BACKGROUND_COLOR_ITEM.type,
|
|
11
12
|
key: BACKGROUND_COLOR_ITEM.key,
|
|
@@ -42,7 +43,9 @@ export var getSharedItems = function getSharedItems() {
|
|
|
42
43
|
rank: CELL_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
|
|
43
44
|
}],
|
|
44
45
|
component: function component() {
|
|
45
|
-
return /*#__PURE__*/React.createElement(ClearCellsItem,
|
|
46
|
+
return /*#__PURE__*/React.createElement(ClearCellsItem, {
|
|
47
|
+
api: api
|
|
48
|
+
});
|
|
46
49
|
}
|
|
47
50
|
}];
|
|
48
51
|
};
|
|
@@ -3,6 +3,6 @@ import { getCellMenuComponents } from '../cell/getCellMenuComponents';
|
|
|
3
3
|
import { getColumnMenuComponents } from '../column/getColumnMenuComponents';
|
|
4
4
|
import { getRowMenuComponents } from '../row/getRowMenuComponents';
|
|
5
5
|
import { getSharedItems } from './getSharedItems';
|
|
6
|
-
export var getTableMenuComponents = function getTableMenuComponents() {
|
|
7
|
-
return [].concat(_toConsumableArray(getRowMenuComponents()), _toConsumableArray(getColumnMenuComponents()), _toConsumableArray(getCellMenuComponents()), _toConsumableArray(getSharedItems()));
|
|
6
|
+
export var getTableMenuComponents = function getTableMenuComponents(params) {
|
|
7
|
+
return [].concat(_toConsumableArray(getRowMenuComponents(params)), _toConsumableArray(getColumnMenuComponents()), _toConsumableArray(getCellMenuComponents()), _toConsumableArray(getSharedItems(params)));
|
|
8
8
|
};
|
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import { backspace, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
4
5
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
5
7
|
import { CrossIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
import { emptyMultipleCellsWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
9
|
+
import { getPluginState } from '../../../../pm-plugins/plugin-factory';
|
|
10
|
+
import { useTableMenuContext } from '../TableMenuContext';
|
|
11
|
+
export var ClearCellsItem = function ClearCellsItem(_ref) {
|
|
12
|
+
var _tableMenuContext$sel, _tableMenuContext$sel2, _tooltip;
|
|
13
|
+
var api = _ref.api;
|
|
14
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
15
|
+
editorView = _useEditorToolbar.editorView;
|
|
16
|
+
var tableMenuContext = useTableMenuContext();
|
|
8
17
|
var _useIntl = useIntl(),
|
|
9
18
|
formatMessage = _useIntl.formatMessage;
|
|
19
|
+
var selectedCellCount = Math.max((_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1, (_tableMenuContext$sel2 = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedRowCount) !== null && _tableMenuContext$sel2 !== void 0 ? _tableMenuContext$sel2 : 1);
|
|
20
|
+
var handleClick = function handleClick() {
|
|
21
|
+
var _api$analytics;
|
|
22
|
+
if (!editorView) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
var _getPluginState = getPluginState(editorView.state),
|
|
26
|
+
targetCellPosition = _getPluginState.targetCellPosition;
|
|
27
|
+
emptyMultipleCellsWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.TABLE_CONTEXT_MENU, targetCellPosition)(editorView.state, editorView.dispatch);
|
|
28
|
+
};
|
|
10
29
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
30
|
+
onClick: handleClick,
|
|
11
31
|
elemBefore: /*#__PURE__*/React.createElement(CrossIcon, {
|
|
12
32
|
color: "currentColor",
|
|
13
33
|
label: "",
|
|
@@ -17,6 +37,6 @@ export var ClearCellsItem = function ClearCellsItem() {
|
|
|
17
37
|
shortcut: (_tooltip = tooltip(backspace)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
18
38
|
})
|
|
19
39
|
}, formatMessage(messages.clearCells, {
|
|
20
|
-
0:
|
|
40
|
+
0: selectedCellCount
|
|
21
41
|
}));
|
|
22
42
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -34,7 +34,7 @@ export type PluginInjectionAPIWithA11y = ExtractInjectionAPI<TablePlugin> & {
|
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
-
export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'isMaxWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'wasMaxWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredColumns' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest' | 'tableRef' | 'tablePos' | 'targetCellPosition' | 'isContextualMenuOpen' | 'pluginConfig' | 'insertColumnButtonIndex' | 'insertRowButtonIndex' | 'tableWrapperTarget' | 'isCellMenuOpenByKeyboard'> & {
|
|
37
|
+
export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'isMaxWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'wasMaxWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'isNumberColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredColumns' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest' | 'tableRef' | 'tablePos' | 'targetCellPosition' | 'isContextualMenuOpen' | 'pluginConfig' | 'insertColumnButtonIndex' | 'insertRowButtonIndex' | 'tableWrapperTarget' | 'isCellMenuOpenByKeyboard'> & {
|
|
38
38
|
dragMenuDirection?: TableDirection;
|
|
39
39
|
dragMenuIndex?: number;
|
|
40
40
|
editorContentAreaHeight?: number;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { RegisterComponent } from '@atlaskit/editor-ui-control-model';
|
|
2
|
-
|
|
2
|
+
import type { TableMenuComponentsParams } from '../shared/types';
|
|
3
|
+
export declare const getRowMenuComponents: ({ api }: TableMenuComponentsParams) => RegisterComponent[];
|