@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,33 +1,64 @@
|
|
|
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
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
const shouldShowMoveRowDown = isLastRow => !isLastRow;
|
|
16
|
+
export const MoveRowDownItem = props => {
|
|
17
|
+
var _tableMenuContext$sel, _tooltip;
|
|
18
|
+
const {
|
|
19
|
+
api
|
|
20
|
+
} = props;
|
|
21
|
+
const {
|
|
22
|
+
editorView
|
|
23
|
+
} = useEditorToolbar();
|
|
14
24
|
const tableMenuContext = useTableMenuContext();
|
|
25
|
+
const {
|
|
26
|
+
tableNode
|
|
27
|
+
} = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], states => {
|
|
28
|
+
var _states$tableState;
|
|
29
|
+
return {
|
|
30
|
+
tableNode: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.tableNode
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
const selectedRowCount = (_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedRowCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1;
|
|
15
34
|
const {
|
|
16
35
|
formatMessage
|
|
17
36
|
} = useIntl();
|
|
18
|
-
|
|
37
|
+
const handleClick = () => {
|
|
38
|
+
var _api$analytics, _api$accessibilityUti;
|
|
39
|
+
if (!editorView) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const selectionRect = getSelectionRect(editorView.state.selection);
|
|
43
|
+
if (!selectionRect) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
moveSourceWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api === null || api === void 0 ? 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);
|
|
47
|
+
};
|
|
48
|
+
if (!tableNode || !shouldShowMoveRowDown(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isLastRow)) {
|
|
19
49
|
return null;
|
|
20
50
|
}
|
|
21
51
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
52
|
+
onClick: handleClick,
|
|
22
53
|
elemBefore: /*#__PURE__*/React.createElement(TableRowMoveDownIcon, {
|
|
23
54
|
color: "currentColor",
|
|
24
55
|
label: "",
|
|
25
56
|
size: "small"
|
|
26
57
|
}),
|
|
27
58
|
elemAfter: /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
|
|
28
|
-
shortcut: (
|
|
59
|
+
shortcut: (_tooltip = tooltip(moveRowDown)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
29
60
|
})
|
|
30
61
|
}, formatMessage(messages.moveRowDown, {
|
|
31
|
-
0:
|
|
62
|
+
0: selectedRowCount
|
|
32
63
|
}));
|
|
33
64
|
};
|
|
@@ -1,33 +1,64 @@
|
|
|
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
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
const shouldShowMoveRowUp = isFirstRow => !isFirstRow;
|
|
16
|
+
export const MoveRowUpItem = props => {
|
|
17
|
+
var _tableMenuContext$sel, _tooltip;
|
|
18
|
+
const {
|
|
19
|
+
api
|
|
20
|
+
} = props;
|
|
21
|
+
const {
|
|
22
|
+
editorView
|
|
23
|
+
} = useEditorToolbar();
|
|
14
24
|
const tableMenuContext = useTableMenuContext();
|
|
25
|
+
const {
|
|
26
|
+
tableNode
|
|
27
|
+
} = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], states => {
|
|
28
|
+
var _states$tableState;
|
|
29
|
+
return {
|
|
30
|
+
tableNode: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.tableNode
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
const selectedRowCount = (_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedRowCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1;
|
|
15
34
|
const {
|
|
16
35
|
formatMessage
|
|
17
36
|
} = useIntl();
|
|
18
|
-
|
|
37
|
+
const handleClick = () => {
|
|
38
|
+
var _api$analytics, _api$accessibilityUti;
|
|
39
|
+
if (!editorView) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const selectionRect = getSelectionRect(editorView.state.selection);
|
|
43
|
+
if (!selectionRect) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
moveSourceWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api === null || api === void 0 ? 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);
|
|
47
|
+
};
|
|
48
|
+
if (!tableNode || !shouldShowMoveRowUp(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstRow)) {
|
|
19
49
|
return null;
|
|
20
50
|
}
|
|
21
51
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
52
|
+
onClick: handleClick,
|
|
22
53
|
elemBefore: /*#__PURE__*/React.createElement(TableRowMoveUpIcon, {
|
|
23
54
|
color: "currentColor",
|
|
24
55
|
label: "",
|
|
25
56
|
size: "small"
|
|
26
57
|
}),
|
|
27
58
|
elemAfter: /*#__PURE__*/React.createElement(ToolbarKeyboardShortcutHint, {
|
|
28
|
-
shortcut: (
|
|
59
|
+
shortcut: (_tooltip = tooltip(moveRowUp)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
29
60
|
})
|
|
30
61
|
}, formatMessage(messages.moveRowUp, {
|
|
31
|
-
0:
|
|
62
|
+
0: selectedRowCount
|
|
32
63
|
}));
|
|
33
64
|
};
|
|
@@ -1,17 +1,48 @@
|
|
|
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 const NumberedRowsToggleItem = props => {
|
|
10
|
+
const {
|
|
11
|
+
api
|
|
12
|
+
} = props;
|
|
13
|
+
const {
|
|
14
|
+
editorView
|
|
15
|
+
} = useEditorToolbar();
|
|
16
|
+
const {
|
|
17
|
+
isNumberColumnAllowed,
|
|
18
|
+
isNumberColumnEnabled
|
|
19
|
+
} = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], states => {
|
|
20
|
+
var _states$tableState, _states$tableState$pl, _states$tableState2;
|
|
21
|
+
return {
|
|
22
|
+
isNumberColumnAllowed: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : (_states$tableState$pl = _states$tableState.pluginConfig) === null || _states$tableState$pl === void 0 ? void 0 : _states$tableState$pl.allowNumberColumn,
|
|
23
|
+
isNumberColumnEnabled: (_states$tableState2 = states.tableState) === null || _states$tableState2 === void 0 ? void 0 : _states$tableState2.isNumberColumnEnabled
|
|
24
|
+
};
|
|
25
|
+
});
|
|
7
26
|
const {
|
|
8
27
|
formatMessage
|
|
9
28
|
} = useIntl();
|
|
10
29
|
const label = formatMessage(messages.numberedRows);
|
|
30
|
+
const handleClick = () => {
|
|
31
|
+
var _api$analytics;
|
|
32
|
+
if (!editorView) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
toggleNumberColumnWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(editorView.state, editorView.dispatch);
|
|
36
|
+
};
|
|
37
|
+
if (!isNumberColumnAllowed) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
11
40
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
41
|
+
onClick: handleClick,
|
|
12
42
|
elemAfter: /*#__PURE__*/React.createElement(Toggle, {
|
|
13
43
|
label: label,
|
|
14
|
-
isChecked:
|
|
44
|
+
isChecked: !!isNumberColumnEnabled,
|
|
45
|
+
onChange: handleClick
|
|
15
46
|
})
|
|
16
47
|
}, label);
|
|
17
48
|
};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export const TABLE_MENU_WIDTH = 280;
|
|
2
|
-
export const TABLE_MENU_SELECTOR = '[data-testid="column-handle-menu"], [data-testid="row-handle-menu"], [data-toolbar-nested-dropdown-menu]';
|
|
2
|
+
export const TABLE_MENU_SELECTOR = '[data-testid="column-handle-menu"], [data-testid="row-handle-menu"], [data-toolbar-nested-dropdown-menu]';
|
|
3
|
+
export const TABLE_ROW = 'table-row';
|
|
4
|
+
export const TABLE_COLUMN = 'table-column';
|
|
@@ -5,7 +5,9 @@ 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 const getSharedItems = (
|
|
8
|
+
export const getSharedItems = ({
|
|
9
|
+
api
|
|
10
|
+
}) => [{
|
|
9
11
|
type: BACKGROUND_COLOR_ITEM.type,
|
|
10
12
|
key: BACKGROUND_COLOR_ITEM.key,
|
|
11
13
|
parents: [{
|
|
@@ -38,5 +40,7 @@ export const getSharedItems = () => [{
|
|
|
38
40
|
key: CELL_DANGER_SECTION.key,
|
|
39
41
|
rank: CELL_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
|
|
40
42
|
}],
|
|
41
|
-
component: () => /*#__PURE__*/React.createElement(ClearCellsItem,
|
|
43
|
+
component: () => /*#__PURE__*/React.createElement(ClearCellsItem, {
|
|
44
|
+
api: api
|
|
45
|
+
})
|
|
42
46
|
}];
|
|
@@ -2,4 +2,4 @@ import { getCellMenuComponents } from '../cell/getCellMenuComponents';
|
|
|
2
2
|
import { getColumnMenuComponents } from '../column/getColumnMenuComponents';
|
|
3
3
|
import { getRowMenuComponents } from '../row/getRowMenuComponents';
|
|
4
4
|
import { getSharedItems } from './getSharedItems';
|
|
5
|
-
export const getTableMenuComponents =
|
|
5
|
+
export const getTableMenuComponents = params => [...getRowMenuComponents(params), ...getColumnMenuComponents(params), ...getCellMenuComponents(), ...getSharedItems(params)];
|
|
@@ -1,14 +1,37 @@
|
|
|
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 const ClearCellsItem = ({
|
|
12
|
+
api
|
|
13
|
+
}) => {
|
|
14
|
+
var _tableMenuContext$sel, _tableMenuContext$sel2, _tooltip;
|
|
15
|
+
const {
|
|
16
|
+
editorView
|
|
17
|
+
} = useEditorToolbar();
|
|
18
|
+
const tableMenuContext = useTableMenuContext();
|
|
8
19
|
const {
|
|
9
20
|
formatMessage
|
|
10
21
|
} = useIntl();
|
|
22
|
+
const 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);
|
|
23
|
+
const handleClick = () => {
|
|
24
|
+
var _api$analytics;
|
|
25
|
+
if (!editorView) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const {
|
|
29
|
+
targetCellPosition
|
|
30
|
+
} = getPluginState(editorView.state);
|
|
31
|
+
emptyMultipleCellsWithAnalytics(api === null || api === void 0 ? 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);
|
|
32
|
+
};
|
|
11
33
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
34
|
+
onClick: handleClick,
|
|
12
35
|
elemBefore: /*#__PURE__*/React.createElement(CrossIcon, {
|
|
13
36
|
color: "currentColor",
|
|
14
37
|
label: "",
|
|
@@ -18,6 +41,6 @@ export const ClearCellsItem = () => {
|
|
|
18
41
|
shortcut: (_tooltip = tooltip(backspace)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
19
42
|
})
|
|
20
43
|
}, formatMessage(messages.clearCells, {
|
|
21
|
-
0:
|
|
44
|
+
0: selectedCellCount
|
|
22
45
|
}));
|
|
23
46
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
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,10 @@ 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,
|
|
119
|
+
isCommentEditor: tablePluginState.isCommentEditor,
|
|
120
|
+
isTableScalingEnabled: tablePluginState.isTableScalingEnabled,
|
|
121
|
+
isTableFixedColumnWidthsOptionEnabled: isTableFixedColumnWidthsOptionEnabled,
|
|
116
122
|
ordering: tablePluginState.ordering,
|
|
117
123
|
isResizing: !!(tableResizingPluginState !== null && tableResizingPluginState !== void 0 && tableResizingPluginState.dragging || tableWidthResizingPluginState !== null && tableWidthResizingPluginState !== void 0 && tableWidthResizingPluginState.resizing),
|
|
118
124
|
isTableResizing: tableWidthResizingPluginState === null || tableWidthResizingPluginState === void 0 ? void 0 : tableWidthResizingPluginState.resizing,
|
|
@@ -7,11 +7,13 @@ import { ColumnToggleSection } from './items/ColumnToggleSection';
|
|
|
7
7
|
import { DeleteColumnItem } from './items/DeleteColumnItem';
|
|
8
8
|
import { DistributeColumnsItem } from './items/DistributeColumnsItem';
|
|
9
9
|
import { HeaderColumnToggleItem } from './items/HeaderColumnToggleItem';
|
|
10
|
+
import { MoveColumnLeftItem } from './items/MoveColumnLeftItem';
|
|
10
11
|
import { MoveColumnRightItem } from './items/MoveColumnRightItem';
|
|
11
12
|
import { SortDecreasingItem } from './items/SortDecreasingItem';
|
|
12
13
|
import { SortIncreasingItem } from './items/SortIncreasingItem';
|
|
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';
|
|
14
|
-
export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
14
|
+
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_LEFT_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';
|
|
15
|
+
export var getColumnMenuComponents = function getColumnMenuComponents(_ref) {
|
|
16
|
+
var api = _ref.api;
|
|
15
17
|
return [
|
|
16
18
|
// --- Menu surface ---
|
|
17
19
|
{
|
|
@@ -28,7 +30,9 @@ export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
|
28
30
|
rank: COLUMN_SECTION_RANK[COLUMN_TOGGLE_SECTION.key]
|
|
29
31
|
}],
|
|
30
32
|
component: function component(props) {
|
|
31
|
-
return /*#__PURE__*/React.createElement(ColumnToggleSection,
|
|
33
|
+
return /*#__PURE__*/React.createElement(ColumnToggleSection, {
|
|
34
|
+
api: api
|
|
35
|
+
}, props.children);
|
|
32
36
|
}
|
|
33
37
|
}, {
|
|
34
38
|
type: HEADER_COLUMN_TOGGLE_ITEM.type,
|
|
@@ -39,7 +43,9 @@ export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
|
39
43
|
rank: COLUMN_TOGGLE_SECTION_RANK[HEADER_COLUMN_TOGGLE_ITEM.key]
|
|
40
44
|
}],
|
|
41
45
|
component: function component() {
|
|
42
|
-
return /*#__PURE__*/React.createElement(HeaderColumnToggleItem,
|
|
46
|
+
return /*#__PURE__*/React.createElement(HeaderColumnToggleItem, {
|
|
47
|
+
api: api
|
|
48
|
+
});
|
|
43
49
|
}
|
|
44
50
|
},
|
|
45
51
|
// --- Background color section ---
|
|
@@ -52,7 +58,9 @@ export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
|
52
58
|
rank: COLUMN_SECTION_RANK[COLUMN_BACKGROUND_SECTION.key]
|
|
53
59
|
}],
|
|
54
60
|
component: function component(props) {
|
|
55
|
-
return /*#__PURE__*/React.createElement(ColumnBackgroundSection,
|
|
61
|
+
return /*#__PURE__*/React.createElement(ColumnBackgroundSection, {
|
|
62
|
+
api: api
|
|
63
|
+
}, props.children);
|
|
56
64
|
}
|
|
57
65
|
},
|
|
58
66
|
// --- Sort section ---
|
|
@@ -78,7 +86,9 @@ export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
|
78
86
|
rank: COLUMN_SORT_SECTION_RANK[SORT_INCREASING_ITEM.key]
|
|
79
87
|
}],
|
|
80
88
|
component: function component() {
|
|
81
|
-
return /*#__PURE__*/React.createElement(SortIncreasingItem,
|
|
89
|
+
return /*#__PURE__*/React.createElement(SortIncreasingItem, {
|
|
90
|
+
api: api
|
|
91
|
+
});
|
|
82
92
|
}
|
|
83
93
|
}, {
|
|
84
94
|
type: SORT_DECREASING_ITEM.type,
|
|
@@ -89,7 +99,9 @@ export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
|
89
99
|
rank: COLUMN_SORT_SECTION_RANK[SORT_DECREASING_ITEM.key]
|
|
90
100
|
}],
|
|
91
101
|
component: function component() {
|
|
92
|
-
return /*#__PURE__*/React.createElement(SortDecreasingItem,
|
|
102
|
+
return /*#__PURE__*/React.createElement(SortDecreasingItem, {
|
|
103
|
+
api: api
|
|
104
|
+
});
|
|
93
105
|
}
|
|
94
106
|
},
|
|
95
107
|
// --- Add / Move section ---
|
|
@@ -115,7 +127,9 @@ export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
|
115
127
|
rank: COLUMN_ADD_SECTION_RANK[ADD_COLUMN_LEFT_ITEM.key]
|
|
116
128
|
}],
|
|
117
129
|
component: function component() {
|
|
118
|
-
return /*#__PURE__*/React.createElement(AddColumnLeftItem,
|
|
130
|
+
return /*#__PURE__*/React.createElement(AddColumnLeftItem, {
|
|
131
|
+
api: api
|
|
132
|
+
});
|
|
119
133
|
}
|
|
120
134
|
}, {
|
|
121
135
|
type: ADD_COLUMN_RIGHT_ITEM.type,
|
|
@@ -126,7 +140,22 @@ export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
|
126
140
|
rank: COLUMN_ADD_SECTION_RANK[ADD_COLUMN_RIGHT_ITEM.key]
|
|
127
141
|
}],
|
|
128
142
|
component: function component() {
|
|
129
|
-
return /*#__PURE__*/React.createElement(AddColumnRightItem,
|
|
143
|
+
return /*#__PURE__*/React.createElement(AddColumnRightItem, {
|
|
144
|
+
api: api
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
type: MOVE_COLUMN_LEFT_ITEM.type,
|
|
149
|
+
key: MOVE_COLUMN_LEFT_ITEM.key,
|
|
150
|
+
parents: [{
|
|
151
|
+
type: COLUMN_ADD_SECTION.type,
|
|
152
|
+
key: COLUMN_ADD_SECTION.key,
|
|
153
|
+
rank: COLUMN_ADD_SECTION_RANK[MOVE_COLUMN_LEFT_ITEM.key]
|
|
154
|
+
}],
|
|
155
|
+
component: function component() {
|
|
156
|
+
return /*#__PURE__*/React.createElement(MoveColumnLeftItem, {
|
|
157
|
+
api: api
|
|
158
|
+
});
|
|
130
159
|
}
|
|
131
160
|
}, {
|
|
132
161
|
type: MOVE_COLUMN_RIGHT_ITEM.type,
|
|
@@ -137,7 +166,9 @@ export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
|
137
166
|
rank: COLUMN_ADD_SECTION_RANK[MOVE_COLUMN_RIGHT_ITEM.key]
|
|
138
167
|
}],
|
|
139
168
|
component: function component() {
|
|
140
|
-
return /*#__PURE__*/React.createElement(MoveColumnRightItem,
|
|
169
|
+
return /*#__PURE__*/React.createElement(MoveColumnRightItem, {
|
|
170
|
+
api: api
|
|
171
|
+
});
|
|
141
172
|
}
|
|
142
173
|
}, {
|
|
143
174
|
type: DISTRIBUTE_COLUMNS_ITEM.type,
|
|
@@ -148,7 +179,9 @@ export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
|
148
179
|
rank: COLUMN_ADD_SECTION_RANK[DISTRIBUTE_COLUMNS_ITEM.key]
|
|
149
180
|
}],
|
|
150
181
|
component: function component() {
|
|
151
|
-
return /*#__PURE__*/React.createElement(DistributeColumnsItem,
|
|
182
|
+
return /*#__PURE__*/React.createElement(DistributeColumnsItem, {
|
|
183
|
+
api: api
|
|
184
|
+
});
|
|
152
185
|
}
|
|
153
186
|
},
|
|
154
187
|
// --- Danger section (Clear cells, Delete column) ---
|
|
@@ -174,7 +207,9 @@ export var getColumnMenuComponents = function getColumnMenuComponents() {
|
|
|
174
207
|
rank: COLUMN_DANGER_SECTION_RANK[DELETE_COLUMN_ITEM.key]
|
|
175
208
|
}],
|
|
176
209
|
component: function component() {
|
|
177
|
-
return /*#__PURE__*/React.createElement(DeleteColumnItem,
|
|
210
|
+
return /*#__PURE__*/React.createElement(DeleteColumnItem, {
|
|
211
|
+
api: api
|
|
212
|
+
});
|
|
178
213
|
}
|
|
179
214
|
}];
|
|
180
215
|
};
|
|
@@ -1,13 +1,46 @@
|
|
|
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 { addColumnBefore, 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 { TableColumnAddLeftIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
6
|
-
|
|
10
|
+
import { insertColumnWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
11
|
+
export var AddColumnLeftItem = function AddColumnLeftItem(_ref) {
|
|
7
12
|
var _tooltip;
|
|
13
|
+
var api = _ref.api;
|
|
14
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
15
|
+
editorView = _useEditorToolbar.editorView;
|
|
8
16
|
var _useIntl = useIntl(),
|
|
9
17
|
formatMessage = _useIntl.formatMessage;
|
|
18
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
19
|
+
var tableState = states.tableState;
|
|
20
|
+
return {
|
|
21
|
+
isCommentEditor: tableState === null || tableState === void 0 ? void 0 : tableState.isCommentEditor,
|
|
22
|
+
isTableFixedColumnWidthsOptionEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableFixedColumnWidthsOptionEnabled,
|
|
23
|
+
isTableScalingEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableScalingEnabled
|
|
24
|
+
};
|
|
25
|
+
}),
|
|
26
|
+
isCommentEditor = _useSharedPluginState.isCommentEditor,
|
|
27
|
+
isTableFixedColumnWidthsOptionEnabled = _useSharedPluginState.isTableFixedColumnWidthsOptionEnabled,
|
|
28
|
+
isTableScalingEnabled = _useSharedPluginState.isTableScalingEnabled;
|
|
29
|
+
var handleClick = function handleClick() {
|
|
30
|
+
var _api$analytics;
|
|
31
|
+
if (!editorView) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
35
|
+
var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.left;
|
|
36
|
+
if (index === undefined) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
|
|
40
|
+
insertColumnWithAnalytics(api, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(INPUT_METHOD.TABLE_CONTEXT_MENU, index)(editorView.state, editorView.dispatch, editorView);
|
|
41
|
+
};
|
|
10
42
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
43
|
+
onClick: handleClick,
|
|
11
44
|
elemBefore: /*#__PURE__*/React.createElement(TableColumnAddLeftIcon, {
|
|
12
45
|
color: "currentColor",
|
|
13
46
|
label: "",
|
|
@@ -1,13 +1,46 @@
|
|
|
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 { addColumnAfter, 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 { TableColumnAddRightIcon, ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
6
|
-
|
|
10
|
+
import { insertColumnWithAnalytics } from '../../../../pm-plugins/commands/commands-with-analytics';
|
|
11
|
+
export var AddColumnRightItem = function AddColumnRightItem(_ref) {
|
|
7
12
|
var _tooltip;
|
|
13
|
+
var api = _ref.api;
|
|
14
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
15
|
+
editorView = _useEditorToolbar.editorView;
|
|
8
16
|
var _useIntl = useIntl(),
|
|
9
17
|
formatMessage = _useIntl.formatMessage;
|
|
18
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
19
|
+
var tableState = states.tableState;
|
|
20
|
+
return {
|
|
21
|
+
isCommentEditor: tableState === null || tableState === void 0 ? void 0 : tableState.isCommentEditor,
|
|
22
|
+
isTableFixedColumnWidthsOptionEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableFixedColumnWidthsOptionEnabled,
|
|
23
|
+
isTableScalingEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableScalingEnabled
|
|
24
|
+
};
|
|
25
|
+
}),
|
|
26
|
+
isCommentEditor = _useSharedPluginState.isCommentEditor,
|
|
27
|
+
isTableFixedColumnWidthsOptionEnabled = _useSharedPluginState.isTableFixedColumnWidthsOptionEnabled,
|
|
28
|
+
isTableScalingEnabled = _useSharedPluginState.isTableScalingEnabled;
|
|
29
|
+
var handleClick = function handleClick() {
|
|
30
|
+
var _api$analytics;
|
|
31
|
+
if (!editorView) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
var selectionRect = getSelectionRect(editorView.state.selection);
|
|
35
|
+
var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
|
|
36
|
+
if (index === undefined) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
|
|
40
|
+
insertColumnWithAnalytics(api, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent, isCommentEditor)(INPUT_METHOD.TABLE_CONTEXT_MENU, index)(editorView.state, editorView.dispatch, editorView);
|
|
41
|
+
};
|
|
10
42
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
43
|
+
onClick: handleClick,
|
|
11
44
|
elemBefore: /*#__PURE__*/React.createElement(TableColumnAddRightIcon, {
|
|
12
45
|
color: "currentColor",
|
|
13
46
|
label: "",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
2
3
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
3
4
|
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
4
5
|
import { shouldShowHeaderColumnToggle } from './HeaderColumnToggleItem';
|
|
@@ -10,9 +11,21 @@ import { shouldShowHeaderColumnToggle } from './HeaderColumnToggleItem';
|
|
|
10
11
|
* the very top of the menu.
|
|
11
12
|
*/
|
|
12
13
|
export var ColumnBackgroundSection = function ColumnBackgroundSection(_ref) {
|
|
13
|
-
var
|
|
14
|
+
var api = _ref.api,
|
|
15
|
+
children = _ref.children;
|
|
14
16
|
var tableMenuContext = useTableMenuContext();
|
|
15
|
-
var
|
|
17
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
18
|
+
var _states$tableState;
|
|
19
|
+
return {
|
|
20
|
+
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
|
|
21
|
+
};
|
|
22
|
+
}),
|
|
23
|
+
isHeaderColumnAllowed = _useSharedPluginState.isHeaderColumnAllowed;
|
|
24
|
+
var hasSeparator = shouldShowHeaderColumnToggle({
|
|
25
|
+
isFirstColumn: tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstColumn,
|
|
26
|
+
isHeaderColumnAllowed: isHeaderColumnAllowed,
|
|
27
|
+
selectedColumnCount: tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount
|
|
28
|
+
});
|
|
16
29
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
17
30
|
hasSeparator: hasSeparator
|
|
18
31
|
}, children);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
2
3
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
3
4
|
import { useTableMenuContext } from '../../shared/TableMenuContext';
|
|
4
5
|
import { shouldShowHeaderColumnToggle } from './HeaderColumnToggleItem';
|
|
@@ -9,9 +10,21 @@ import { shouldShowHeaderColumnToggle } from './HeaderColumnToggleItem';
|
|
|
9
10
|
* empty wrapper (and so the section below can drop its leading separator).
|
|
10
11
|
*/
|
|
11
12
|
export var ColumnToggleSection = function ColumnToggleSection(_ref) {
|
|
12
|
-
var
|
|
13
|
+
var api = _ref.api,
|
|
14
|
+
children = _ref.children;
|
|
13
15
|
var tableMenuContext = useTableMenuContext();
|
|
14
|
-
|
|
16
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
17
|
+
var _states$tableState;
|
|
18
|
+
return {
|
|
19
|
+
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
|
|
20
|
+
};
|
|
21
|
+
}),
|
|
22
|
+
isHeaderColumnAllowed = _useSharedPluginState.isHeaderColumnAllowed;
|
|
23
|
+
if (!shouldShowHeaderColumnToggle({
|
|
24
|
+
isFirstColumn: tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstColumn,
|
|
25
|
+
isHeaderColumnAllowed: isHeaderColumnAllowed,
|
|
26
|
+
selectedColumnCount: tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount
|
|
27
|
+
})) {
|
|
15
28
|
return null;
|
|
16
29
|
}
|
|
17
30
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, children);
|