@atlaskit/editor-plugin-table 22.4.12 → 22.4.14
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 +16 -0
- package/dist/cjs/nodeviews/TableComponent.js +21 -19
- package/dist/cjs/tablePlugin.js +3 -0
- 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/shared/getTableMenuComponents.js +1 -1
- package/dist/es2019/nodeviews/TableComponent.js +22 -20
- package/dist/es2019/tablePlugin.js +3 -0
- 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/shared/getTableMenuComponents.js +1 -1
- package/dist/esm/nodeviews/TableComponent.js +22 -20
- package/dist/esm/tablePlugin.js +3 -0
- 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/shared/getTableMenuComponents.js +1 -1
- 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-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/package.json +5 -3
|
@@ -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);
|
|
@@ -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
|
};
|