@atlaskit/editor-plugin-table 22.4.11 → 22.4.13
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/tablePlugin.js +7 -1
- package/dist/cjs/ui/TableMenu/column/getColumnMenuComponents.js +46 -11
- package/dist/cjs/ui/TableMenu/column/items/AddColumnLeftItem.js +34 -1
- package/dist/cjs/ui/TableMenu/column/items/AddColumnRightItem.js +34 -1
- package/dist/cjs/ui/TableMenu/column/items/ColumnBackgroundSection.js +15 -2
- package/dist/cjs/ui/TableMenu/column/items/ColumnToggleSection.js +15 -2
- package/dist/cjs/ui/TableMenu/column/items/DeleteColumnItem.js +60 -3
- package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +43 -5
- package/dist/cjs/ui/TableMenu/column/items/HeaderColumnToggleItem.js +36 -5
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnLeftItem.js +69 -0
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +42 -3
- package/dist/cjs/ui/TableMenu/column/items/SortDecreasingItem.js +22 -1
- package/dist/cjs/ui/TableMenu/column/items/SortIncreasingItem.js +22 -1
- package/dist/cjs/ui/TableMenu/column/keys.js +6 -2
- 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 +7 -1
- package/dist/es2019/ui/TableMenu/column/getColumnMenuComponents.js +46 -12
- package/dist/es2019/ui/TableMenu/column/items/AddColumnLeftItem.js +37 -1
- package/dist/es2019/ui/TableMenu/column/items/AddColumnRightItem.js +37 -1
- package/dist/es2019/ui/TableMenu/column/items/ColumnBackgroundSection.js +15 -1
- package/dist/es2019/ui/TableMenu/column/items/ColumnToggleSection.js +15 -1
- package/dist/es2019/ui/TableMenu/column/items/DeleteColumnItem.js +63 -3
- package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +43 -7
- package/dist/es2019/ui/TableMenu/column/items/HeaderColumnToggleItem.js +40 -5
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnLeftItem.js +65 -0
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +44 -3
- package/dist/es2019/ui/TableMenu/column/items/SortDecreasingItem.js +24 -1
- package/dist/es2019/ui/TableMenu/column/items/SortIncreasingItem.js +24 -1
- package/dist/es2019/ui/TableMenu/column/keys.js +7 -2
- 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 +7 -1
- package/dist/esm/ui/TableMenu/column/getColumnMenuComponents.js +47 -12
- package/dist/esm/ui/TableMenu/column/items/AddColumnLeftItem.js +34 -1
- package/dist/esm/ui/TableMenu/column/items/AddColumnRightItem.js +34 -1
- package/dist/esm/ui/TableMenu/column/items/ColumnBackgroundSection.js +15 -2
- package/dist/esm/ui/TableMenu/column/items/ColumnToggleSection.js +15 -2
- package/dist/esm/ui/TableMenu/column/items/DeleteColumnItem.js +60 -3
- package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +43 -6
- package/dist/esm/ui/TableMenu/column/items/HeaderColumnToggleItem.js +36 -6
- package/dist/esm/ui/TableMenu/column/items/MoveColumnLeftItem.js +62 -0
- package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +42 -3
- package/dist/esm/ui/TableMenu/column/items/SortDecreasingItem.js +22 -1
- package/dist/esm/ui/TableMenu/column/items/SortIncreasingItem.js +22 -1
- package/dist/esm/ui/TableMenu/column/keys.js +5 -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 +2 -1
- package/dist/types/ui/TableMenu/column/getColumnMenuComponents.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/AddColumnLeftItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/AddColumnRightItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/ColumnBackgroundSection.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/ColumnToggleSection.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/DeleteColumnItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/DistributeColumnsItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/HeaderColumnToggleItem.d.ts +7 -3
- package/dist/types/ui/TableMenu/column/items/MoveColumnLeftItem.d.ts +3 -0
- package/dist/types/ui/TableMenu/column/items/MoveColumnRightItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/SortDecreasingItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/SortIncreasingItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/keys.d.ts +1 -0
- 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 +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/getColumnMenuComponents.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/AddColumnLeftItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/AddColumnRightItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/ColumnBackgroundSection.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/ColumnToggleSection.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/DeleteColumnItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/DistributeColumnsItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/HeaderColumnToggleItem.d.ts +7 -3
- package/dist/types-ts4.5/ui/TableMenu/column/items/MoveColumnLeftItem.d.ts +3 -0
- package/dist/types-ts4.5/ui/TableMenu/column/items/MoveColumnRightItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/SortDecreasingItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/SortIncreasingItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/keys.d.ts +1 -0
- 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 +4 -4
|
@@ -1,13 +1,70 @@
|
|
|
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 { deleteColumn, 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, hoverColumns } from '../../../../pm-plugins/commands';
|
|
11
|
+
import { deleteColumnsWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
12
|
+
import { getSelectedColumnIndexes } from '../../../../pm-plugins/utils/selection';
|
|
13
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
14
|
+
export var DeleteColumnItem = function DeleteColumnItem(_ref) {
|
|
15
|
+
var _tableMenuContext$sel, _tooltip;
|
|
16
|
+
var api = _ref.api;
|
|
17
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
18
|
+
editorView = _useEditorToolbar.editorView;
|
|
19
|
+
var tableMenuContext = useTableMenuContext();
|
|
20
|
+
var selectedColumnCount = (_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1;
|
|
8
21
|
var _useIntl = useIntl(),
|
|
9
22
|
formatMessage = _useIntl.formatMessage;
|
|
23
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
24
|
+
var tableState = states.tableState;
|
|
25
|
+
return {
|
|
26
|
+
isCommentEditor: tableState === null || tableState === void 0 ? void 0 : tableState.isCommentEditor,
|
|
27
|
+
isTableFixedColumnWidthsOptionEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableFixedColumnWidthsOptionEnabled,
|
|
28
|
+
isTableScalingEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableScalingEnabled
|
|
29
|
+
};
|
|
30
|
+
}),
|
|
31
|
+
isCommentEditor = _useSharedPluginState.isCommentEditor,
|
|
32
|
+
isTableFixedColumnWidthsOptionEnabled = _useSharedPluginState.isTableFixedColumnWidthsOptionEnabled,
|
|
33
|
+
isTableScalingEnabled = _useSharedPluginState.isTableScalingEnabled;
|
|
34
|
+
var handleMouseEnter = function handleMouseEnter() {
|
|
35
|
+
if (!editorView) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
39
|
+
if (!selectionRect) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
hoverColumns(getSelectedColumnIndexes(selectionRect), true)(editorView.state, editorView.dispatch);
|
|
43
|
+
};
|
|
44
|
+
var handleMouseLeave = function handleMouseLeave() {
|
|
45
|
+
if (!editorView) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
clearHoverSelection()(editorView.state, editorView.dispatch);
|
|
49
|
+
};
|
|
50
|
+
var handleClick = function handleClick() {
|
|
51
|
+
var _api$analytics;
|
|
52
|
+
if (!editorView) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
56
|
+
if (!selectionRect) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
var shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
|
|
60
|
+
deleteColumnsWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(INPUT_METHOD.TABLE_CONTEXT_MENU, selectionRect)(editorView.state, editorView.dispatch, editorView);
|
|
61
|
+
};
|
|
10
62
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
63
|
+
onClick: handleClick,
|
|
64
|
+
onFocus: handleMouseEnter,
|
|
65
|
+
onMouseEnter: handleMouseEnter,
|
|
66
|
+
onBlur: handleMouseLeave,
|
|
67
|
+
onMouseLeave: handleMouseLeave,
|
|
11
68
|
elemBefore: /*#__PURE__*/React.createElement(DeleteIcon, {
|
|
12
69
|
color: "currentColor",
|
|
13
70
|
label: "",
|
|
@@ -17,6 +74,6 @@ export var DeleteColumnItem = function DeleteColumnItem() {
|
|
|
17
74
|
shortcut: (_tooltip = tooltip(deleteColumn)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
18
75
|
})
|
|
19
76
|
}, formatMessage(messages.removeColumns, {
|
|
20
|
-
0:
|
|
77
|
+
0: selectedColumnCount
|
|
21
78
|
}));
|
|
22
79
|
};
|
|
@@ -1,22 +1,59 @@
|
|
|
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 { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
7
|
+
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
4
8
|
import { TableColumnsDistributeIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
9
|
+
import { distributeColumnsWidthsWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
10
|
+
import { getNewResizeStateFromSelectedColumns } from '../../../../pm-plugins/table-resizing/utils/resize-state';
|
|
5
11
|
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
6
|
-
|
|
7
12
|
/** Distribute columns is only visible when more than one column is selected. */
|
|
8
|
-
var shouldShowDistributeColumns = function shouldShowDistributeColumns(
|
|
9
|
-
|
|
10
|
-
return ((_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 0) > 1;
|
|
13
|
+
var shouldShowDistributeColumns = function shouldShowDistributeColumns(selectedColumnCount) {
|
|
14
|
+
return (selectedColumnCount !== null && selectedColumnCount !== void 0 ? selectedColumnCount : 0) > 1;
|
|
11
15
|
};
|
|
12
|
-
export var DistributeColumnsItem = function DistributeColumnsItem() {
|
|
16
|
+
export var DistributeColumnsItem = function DistributeColumnsItem(_ref) {
|
|
17
|
+
var api = _ref.api;
|
|
18
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
19
|
+
editorView = _useEditorToolbar.editorView;
|
|
13
20
|
var tableMenuContext = useTableMenuContext();
|
|
14
21
|
var _useIntl = useIntl(),
|
|
15
22
|
formatMessage = _useIntl.formatMessage;
|
|
16
|
-
|
|
23
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
24
|
+
var tableState = states.tableState;
|
|
25
|
+
return {
|
|
26
|
+
isCommentEditor: tableState === null || tableState === void 0 ? void 0 : tableState.isCommentEditor,
|
|
27
|
+
isTableFixedColumnWidthsOptionEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableFixedColumnWidthsOptionEnabled,
|
|
28
|
+
isTableScalingEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableScalingEnabled
|
|
29
|
+
};
|
|
30
|
+
}),
|
|
31
|
+
isCommentEditor = _useSharedPluginState.isCommentEditor,
|
|
32
|
+
isTableFixedColumnWidthsOptionEnabled = _useSharedPluginState.isTableFixedColumnWidthsOptionEnabled,
|
|
33
|
+
isTableScalingEnabled = _useSharedPluginState.isTableScalingEnabled;
|
|
34
|
+
var handleClick = function handleClick() {
|
|
35
|
+
var _api$width, _api$analytics;
|
|
36
|
+
if (!editorView) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
40
|
+
var editorContainerWidth = api === null || api === void 0 || (_api$width = api.width) === null || _api$width === void 0 ? void 0 : _api$width.sharedState.currentState();
|
|
41
|
+
if (!selectionRect || !editorContainerWidth) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
var newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), function () {
|
|
45
|
+
return editorContainerWidth;
|
|
46
|
+
}, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, isCommentEditor);
|
|
47
|
+
if (!newResizeState) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
distributeColumnsWidthsWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api)(INPUT_METHOD.TABLE_CONTEXT_MENU, newResizeState)(editorView.state, editorView.dispatch);
|
|
51
|
+
};
|
|
52
|
+
if (!shouldShowDistributeColumns(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount)) {
|
|
17
53
|
return null;
|
|
18
54
|
}
|
|
19
55
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
56
|
+
onClick: handleClick,
|
|
20
57
|
elemBefore: /*#__PURE__*/React.createElement(TableColumnsDistributeIcon, {
|
|
21
58
|
color: "currentColor",
|
|
22
59
|
label: "",
|
|
@@ -1,10 +1,12 @@
|
|
|
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 { toggleHeaderColumnWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
6
9
|
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
7
|
-
|
|
8
10
|
/**
|
|
9
11
|
* Header column toggle is only visible when the first column is the entire
|
|
10
12
|
* selection.
|
|
@@ -13,21 +15,49 @@ import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
|
13
15
|
* `ColumnBackgroundSection` (which drops its leading separator alongside)
|
|
14
16
|
* can stay in lockstep with this rule without redefining it.
|
|
15
17
|
*/
|
|
16
|
-
export var shouldShowHeaderColumnToggle = function shouldShowHeaderColumnToggle(
|
|
17
|
-
|
|
18
|
+
export var shouldShowHeaderColumnToggle = function shouldShowHeaderColumnToggle(_ref) {
|
|
19
|
+
var isFirstColumn = _ref.isFirstColumn,
|
|
20
|
+
isHeaderColumnAllowed = _ref.isHeaderColumnAllowed,
|
|
21
|
+
selectedColumnCount = _ref.selectedColumnCount;
|
|
22
|
+
return isHeaderColumnAllowed === true && isFirstColumn === true && selectedColumnCount === 1;
|
|
18
23
|
};
|
|
19
|
-
export var HeaderColumnToggleItem = function HeaderColumnToggleItem() {
|
|
24
|
+
export var HeaderColumnToggleItem = function HeaderColumnToggleItem(props) {
|
|
25
|
+
var api = props.api;
|
|
26
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
27
|
+
editorView = _useEditorToolbar.editorView;
|
|
20
28
|
var tableMenuContext = useTableMenuContext();
|
|
29
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
30
|
+
var _states$tableState, _states$tableState2;
|
|
31
|
+
return {
|
|
32
|
+
isHeaderColumnAllowed: (_states$tableState = states.tableState) === null || _states$tableState === void 0 || (_states$tableState = _states$tableState.pluginConfig) === null || _states$tableState === void 0 ? void 0 : _states$tableState.allowHeaderColumn,
|
|
33
|
+
isHeaderColumnEnabled: (_states$tableState2 = states.tableState) === null || _states$tableState2 === void 0 ? void 0 : _states$tableState2.isHeaderColumnEnabled
|
|
34
|
+
};
|
|
35
|
+
}),
|
|
36
|
+
isHeaderColumnAllowed = _useSharedPluginState.isHeaderColumnAllowed,
|
|
37
|
+
isHeaderColumnEnabled = _useSharedPluginState.isHeaderColumnEnabled;
|
|
21
38
|
var _useIntl = useIntl(),
|
|
22
39
|
formatMessage = _useIntl.formatMessage;
|
|
23
40
|
var label = formatMessage(messages.headerColumn);
|
|
24
|
-
|
|
41
|
+
var handleClick = function handleClick() {
|
|
42
|
+
var _api$analytics;
|
|
43
|
+
if (!editorView) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
toggleHeaderColumnWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(editorView.state, editorView.dispatch);
|
|
47
|
+
};
|
|
48
|
+
if (!shouldShowHeaderColumnToggle({
|
|
49
|
+
isFirstColumn: tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstColumn,
|
|
50
|
+
isHeaderColumnAllowed: isHeaderColumnAllowed,
|
|
51
|
+
selectedColumnCount: tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount
|
|
52
|
+
})) {
|
|
25
53
|
return null;
|
|
26
54
|
}
|
|
27
55
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
56
|
+
onClick: handleClick,
|
|
28
57
|
elemAfter: /*#__PURE__*/React.createElement(Toggle, {
|
|
29
58
|
label: label,
|
|
30
|
-
isChecked:
|
|
59
|
+
isChecked: !!isHeaderColumnEnabled,
|
|
60
|
+
onChange: handleClick
|
|
31
61
|
})
|
|
32
62
|
}, label);
|
|
33
63
|
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { moveColumnLeft, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
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';
|
|
9
|
+
import { ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
10
|
+
import TableColumnMoveLeftIcon from '@atlaskit/icon/core/table-column-move-left';
|
|
11
|
+
import { moveSourceWithAnalytics } from '../../../../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
12
|
+
import { getPluginState } from '../../../../pm-plugins/plugin-factory';
|
|
13
|
+
import { getSelectedColumnIndexes } from '../../../../pm-plugins/utils/selection';
|
|
14
|
+
import { TABLE_COLUMN } from '../../shared/consts';
|
|
15
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
16
|
+
var shouldShowMoveColumnLeft = function shouldShowMoveColumnLeft(isFirstColumn) {
|
|
17
|
+
return !isFirstColumn;
|
|
18
|
+
};
|
|
19
|
+
export var MoveColumnLeftItem = function MoveColumnLeftItem(props) {
|
|
20
|
+
var _tableMenuContext$sel, _tooltip;
|
|
21
|
+
var api = props.api;
|
|
22
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
23
|
+
editorView = _useEditorToolbar.editorView;
|
|
24
|
+
var tableMenuContext = useTableMenuContext();
|
|
25
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
26
|
+
var _states$tableState;
|
|
27
|
+
return {
|
|
28
|
+
tableNode: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.tableNode
|
|
29
|
+
};
|
|
30
|
+
}),
|
|
31
|
+
tableNode = _useSharedPluginState.tableNode;
|
|
32
|
+
var selectedColumnCount = (_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1;
|
|
33
|
+
var _useIntl = useIntl(),
|
|
34
|
+
formatMessage = _useIntl.formatMessage;
|
|
35
|
+
var handleClick = function handleClick() {
|
|
36
|
+
var _api$analytics, _api$accessibilityUti;
|
|
37
|
+
if (!editorView) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
41
|
+
if (!selectionRect) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
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_COLUMN, getSelectedColumnIndexes(selectionRect), selectionRect.left - 1)(editorView.state, editorView.dispatch);
|
|
45
|
+
};
|
|
46
|
+
if (!tableNode || !shouldShowMoveColumnLeft(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstColumn)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
50
|
+
onClick: handleClick,
|
|
51
|
+
elemBefore: /*#__PURE__*/React.createElement(TableColumnMoveLeftIcon, {
|
|
52
|
+
color: "currentColor",
|
|
53
|
+
label: "",
|
|
54
|
+
size: "small"
|
|
55
|
+
}),
|
|
56
|
+
elemAfter: /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
|
|
57
|
+
shortcut: (_tooltip = tooltip(moveColumnLeft)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
58
|
+
})
|
|
59
|
+
}, formatMessage(messages.moveColumnLeft, {
|
|
60
|
+
0: selectedColumnCount
|
|
61
|
+
}));
|
|
62
|
+
};
|
|
@@ -1,13 +1,52 @@
|
|
|
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 { moveColumnRight, 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 { TableColumnMoveRightIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
import { moveSourceWithAnalytics } from '../../../../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
11
|
+
import { getPluginState } from '../../../../pm-plugins/plugin-factory';
|
|
12
|
+
import { getSelectedColumnIndexes } from '../../../../pm-plugins/utils/selection';
|
|
13
|
+
import { TABLE_COLUMN } from '../../shared/consts';
|
|
14
|
+
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
15
|
+
var shouldShowMoveColumnRight = function shouldShowMoveColumnRight(isLastColumn) {
|
|
16
|
+
return !isLastColumn;
|
|
17
|
+
};
|
|
18
|
+
export var MoveColumnRightItem = function MoveColumnRightItem(props) {
|
|
19
|
+
var _tableMenuContext$sel, _tooltip;
|
|
20
|
+
var api = props.api;
|
|
21
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
22
|
+
editorView = _useEditorToolbar.editorView;
|
|
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 selectedColumnCount = (_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1;
|
|
8
32
|
var _useIntl = useIntl(),
|
|
9
33
|
formatMessage = _useIntl.formatMessage;
|
|
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_COLUMN, getSelectedColumnIndexes(selectionRect), selectionRect.right)(editorView.state, editorView.dispatch);
|
|
44
|
+
};
|
|
45
|
+
if (!tableNode || !shouldShowMoveColumnRight(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isLastColumn)) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
10
48
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
49
|
+
onClick: handleClick,
|
|
11
50
|
elemBefore: /*#__PURE__*/React.createElement(TableColumnMoveRightIcon, {
|
|
12
51
|
color: "currentColor",
|
|
13
52
|
label: "",
|
|
@@ -17,6 +56,6 @@ export var MoveColumnRightItem = function MoveColumnRightItem() {
|
|
|
17
56
|
shortcut: (_tooltip = tooltip(moveColumnRight)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
18
57
|
})
|
|
19
58
|
}, formatMessage(messages.moveColumnRight, {
|
|
20
|
-
0:
|
|
59
|
+
0: selectedColumnCount
|
|
21
60
|
}));
|
|
22
61
|
};
|
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
+
import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
4
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
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';
|
|
4
8
|
import { ArrowDownIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
9
|
+
import { sortColumnWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
5
10
|
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
6
|
-
export var SortDecreasingItem = function SortDecreasingItem() {
|
|
11
|
+
export var SortDecreasingItem = function SortDecreasingItem(_ref) {
|
|
12
|
+
var api = _ref.api;
|
|
13
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
14
|
+
editorView = _useEditorToolbar.editorView;
|
|
7
15
|
var tableMenuContext = useTableMenuContext();
|
|
8
16
|
var _useIntl = useIntl(),
|
|
9
17
|
formatMessage = _useIntl.formatMessage;
|
|
18
|
+
var handleClick = function handleClick() {
|
|
19
|
+
var _api$analytics;
|
|
20
|
+
if (!editorView) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
24
|
+
var columnIndex = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.left;
|
|
25
|
+
if (columnIndex === undefined) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
sortColumnWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.TABLE_CONTEXT_MENU, columnIndex, SortOrder.DESC)(editorView.state, editorView.dispatch);
|
|
29
|
+
};
|
|
10
30
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
31
|
+
onClick: handleClick,
|
|
11
32
|
isDisabled: Boolean(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.hasMergedCellsInTable),
|
|
12
33
|
elemBefore: /*#__PURE__*/React.createElement(ArrowDownIcon, {
|
|
13
34
|
color: "currentColor",
|
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
+
import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
4
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
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';
|
|
4
8
|
import { ArrowUpIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
9
|
+
import { sortColumnWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
5
10
|
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
6
|
-
export var SortIncreasingItem = function SortIncreasingItem() {
|
|
11
|
+
export var SortIncreasingItem = function SortIncreasingItem(_ref) {
|
|
12
|
+
var api = _ref.api;
|
|
13
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
14
|
+
editorView = _useEditorToolbar.editorView;
|
|
7
15
|
var tableMenuContext = useTableMenuContext();
|
|
8
16
|
var _useIntl = useIntl(),
|
|
9
17
|
formatMessage = _useIntl.formatMessage;
|
|
18
|
+
var handleClick = function handleClick() {
|
|
19
|
+
var _api$analytics;
|
|
20
|
+
if (!editorView) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
24
|
+
var columnIndex = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.left;
|
|
25
|
+
if (columnIndex === undefined) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
sortColumnWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.TABLE_CONTEXT_MENU, columnIndex, SortOrder.ASC)(editorView.state, editorView.dispatch);
|
|
29
|
+
};
|
|
10
30
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
31
|
+
onClick: handleClick,
|
|
11
32
|
isDisabled: Boolean(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.hasMergedCellsInTable),
|
|
12
33
|
elemBefore: /*#__PURE__*/React.createElement(ArrowUpIcon, {
|
|
13
34
|
color: "currentColor",
|
|
@@ -51,6 +51,10 @@ export var ADD_COLUMN_RIGHT_ITEM = {
|
|
|
51
51
|
type: 'menu-item',
|
|
52
52
|
key: 'add-column-right'
|
|
53
53
|
};
|
|
54
|
+
export var MOVE_COLUMN_LEFT_ITEM = {
|
|
55
|
+
type: 'menu-item',
|
|
56
|
+
key: 'move-column-left'
|
|
57
|
+
};
|
|
54
58
|
export var MOVE_COLUMN_RIGHT_ITEM = {
|
|
55
59
|
type: 'menu-item',
|
|
56
60
|
key: 'move-column-right'
|
|
@@ -69,5 +73,5 @@ export var DELETE_COLUMN_ITEM = {
|
|
|
69
73
|
export var COLUMN_TOGGLE_SECTION_RANK = _defineProperty({}, HEADER_COLUMN_TOGGLE_ITEM.key, 100);
|
|
70
74
|
export var COLUMN_BACKGROUND_SECTION_RANK = _defineProperty({}, BACKGROUND_COLOR_ITEM.key, 100);
|
|
71
75
|
export var COLUMN_SORT_SECTION_RANK = _defineProperty(_defineProperty({}, SORT_INCREASING_ITEM.key, 100), SORT_DECREASING_ITEM.key, 200);
|
|
72
|
-
export var COLUMN_ADD_SECTION_RANK = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ADD_COLUMN_LEFT_ITEM.key, 100), ADD_COLUMN_RIGHT_ITEM.key, 200),
|
|
76
|
+
export var COLUMN_ADD_SECTION_RANK = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ADD_COLUMN_LEFT_ITEM.key, 100), ADD_COLUMN_RIGHT_ITEM.key, 200), MOVE_COLUMN_LEFT_ITEM.key, 300), MOVE_COLUMN_RIGHT_ITEM.key, 400), DISTRIBUTE_COLUMNS_ITEM.key, 500);
|
|
73
77
|
export var COLUMN_DANGER_SECTION_RANK = _defineProperty(_defineProperty({}, CLEAR_CELLS_ITEM.key, 100), DELETE_COLUMN_ITEM.key, 200);
|
|
@@ -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: "",
|