@atlaskit/editor-plugin-table 22.4.12 → 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 +8 -0
- 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/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/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 +3 -3
|
@@ -7,14 +7,53 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.MoveColumnRightItem = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactIntl = require("react-intl");
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
12
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
11
13
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
15
|
+
var _utils = require("@atlaskit/editor-tables/utils");
|
|
12
16
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
13
|
-
var
|
|
14
|
-
|
|
17
|
+
var _commandsWithAnalytics = require("../../../../pm-plugins/drag-and-drop/commands-with-analytics");
|
|
18
|
+
var _pluginFactory = require("../../../../pm-plugins/plugin-factory");
|
|
19
|
+
var _selection = require("../../../../pm-plugins/utils/selection");
|
|
20
|
+
var _consts = require("../../shared/consts");
|
|
21
|
+
var _TableMenuContext = require("../../shared/TableMenuContext");
|
|
22
|
+
var shouldShowMoveColumnRight = function shouldShowMoveColumnRight(isLastColumn) {
|
|
23
|
+
return !isLastColumn;
|
|
24
|
+
};
|
|
25
|
+
var MoveColumnRightItem = exports.MoveColumnRightItem = function MoveColumnRightItem(props) {
|
|
26
|
+
var _tableMenuContext$sel, _tooltip;
|
|
27
|
+
var api = props.api;
|
|
28
|
+
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
29
|
+
editorView = _useEditorToolbar.editorView;
|
|
30
|
+
var tableMenuContext = (0, _TableMenuContext.useTableMenuContext)();
|
|
31
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
32
|
+
var _states$tableState;
|
|
33
|
+
return {
|
|
34
|
+
tableNode: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.tableNode
|
|
35
|
+
};
|
|
36
|
+
}),
|
|
37
|
+
tableNode = _useSharedPluginState.tableNode;
|
|
38
|
+
var selectedColumnCount = (_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1;
|
|
15
39
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
16
40
|
formatMessage = _useIntl.formatMessage;
|
|
41
|
+
var handleClick = function handleClick() {
|
|
42
|
+
var _api$analytics, _api$accessibilityUti;
|
|
43
|
+
if (!editorView) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
var selectionRect = (0, _utils.getSelectionRect)(editorView.state.selection);
|
|
47
|
+
if (!selectionRect) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
(0, _commandsWithAnalytics.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, (0, _pluginFactory.getPluginState)(editorView.state).getIntl)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, _consts.TABLE_COLUMN, (0, _selection.getSelectedColumnIndexes)(selectionRect), selectionRect.right)(editorView.state, editorView.dispatch);
|
|
51
|
+
};
|
|
52
|
+
if (!tableNode || !shouldShowMoveColumnRight(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isLastColumn)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
17
55
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
56
|
+
onClick: handleClick,
|
|
18
57
|
elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.TableColumnMoveRightIcon, {
|
|
19
58
|
color: "currentColor",
|
|
20
59
|
label: "",
|
|
@@ -24,6 +63,6 @@ var MoveColumnRightItem = exports.MoveColumnRightItem = function MoveColumnRight
|
|
|
24
63
|
shortcut: (_tooltip = (0, _keymaps.tooltip)(_keymaps.moveColumnRight)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
25
64
|
})
|
|
26
65
|
}, formatMessage(_messages.tableMessages.moveColumnRight, {
|
|
27
|
-
0:
|
|
66
|
+
0: selectedColumnCount
|
|
28
67
|
}));
|
|
29
68
|
};
|
|
@@ -7,14 +7,35 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.SortDecreasingItem = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactIntl = require("react-intl");
|
|
10
|
+
var _customSteps = require("@atlaskit/custom-steps");
|
|
11
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
14
|
+
var _utils = require("@atlaskit/editor-tables/utils");
|
|
11
15
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
16
|
+
var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
|
|
12
17
|
var _TableMenuContext = require("../../shared/TableMenuContext");
|
|
13
|
-
var SortDecreasingItem = exports.SortDecreasingItem = function SortDecreasingItem() {
|
|
18
|
+
var SortDecreasingItem = exports.SortDecreasingItem = function SortDecreasingItem(_ref) {
|
|
19
|
+
var api = _ref.api;
|
|
20
|
+
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
21
|
+
editorView = _useEditorToolbar.editorView;
|
|
14
22
|
var tableMenuContext = (0, _TableMenuContext.useTableMenuContext)();
|
|
15
23
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
16
24
|
formatMessage = _useIntl.formatMessage;
|
|
25
|
+
var handleClick = function handleClick() {
|
|
26
|
+
var _api$analytics;
|
|
27
|
+
if (!editorView) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
var selectionRect = (0, _utils.getSelectionRect)(editorView.state.selection);
|
|
31
|
+
var columnIndex = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.left;
|
|
32
|
+
if (columnIndex === undefined) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
(0, _commandsWithAnalytics.sortColumnWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, columnIndex, _customSteps.TableSortOrder.DESC)(editorView.state, editorView.dispatch);
|
|
36
|
+
};
|
|
17
37
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
38
|
+
onClick: handleClick,
|
|
18
39
|
isDisabled: Boolean(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.hasMergedCellsInTable),
|
|
19
40
|
elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.ArrowDownIcon, {
|
|
20
41
|
color: "currentColor",
|
|
@@ -7,14 +7,35 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.SortIncreasingItem = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactIntl = require("react-intl");
|
|
10
|
+
var _customSteps = require("@atlaskit/custom-steps");
|
|
11
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
14
|
+
var _utils = require("@atlaskit/editor-tables/utils");
|
|
11
15
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
16
|
+
var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
|
|
12
17
|
var _TableMenuContext = require("../../shared/TableMenuContext");
|
|
13
|
-
var SortIncreasingItem = exports.SortIncreasingItem = function SortIncreasingItem() {
|
|
18
|
+
var SortIncreasingItem = exports.SortIncreasingItem = function SortIncreasingItem(_ref) {
|
|
19
|
+
var api = _ref.api;
|
|
20
|
+
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
21
|
+
editorView = _useEditorToolbar.editorView;
|
|
14
22
|
var tableMenuContext = (0, _TableMenuContext.useTableMenuContext)();
|
|
15
23
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
16
24
|
formatMessage = _useIntl.formatMessage;
|
|
25
|
+
var handleClick = function handleClick() {
|
|
26
|
+
var _api$analytics;
|
|
27
|
+
if (!editorView) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
var selectionRect = (0, _utils.getSelectionRect)(editorView.state.selection);
|
|
31
|
+
var columnIndex = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.left;
|
|
32
|
+
if (columnIndex === undefined) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
(0, _commandsWithAnalytics.sortColumnWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, columnIndex, _customSteps.TableSortOrder.ASC)(editorView.state, editorView.dispatch);
|
|
36
|
+
};
|
|
17
37
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
38
|
+
onClick: handleClick,
|
|
18
39
|
isDisabled: Boolean(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.hasMergedCellsInTable),
|
|
19
40
|
elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.ArrowUpIcon, {
|
|
20
41
|
color: "currentColor",
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.SORT_INCREASING_ITEM = exports.SORT_DECREASING_ITEM = exports.MOVE_COLUMN_RIGHT_ITEM = exports.HEADER_COLUMN_TOGGLE_ITEM = exports.DISTRIBUTE_COLUMNS_ITEM = exports.DELETE_COLUMN_ITEM = exports.COLUMN_TOGGLE_SECTION_RANK = exports.COLUMN_TOGGLE_SECTION = exports.COLUMN_SORT_SECTION_RANK = exports.COLUMN_SORT_SECTION = exports.COLUMN_SECTION_RANK = exports.COLUMN_MENU = exports.COLUMN_DANGER_SECTION_RANK = exports.COLUMN_DANGER_SECTION = exports.COLUMN_BACKGROUND_SECTION_RANK = exports.COLUMN_BACKGROUND_SECTION = exports.COLUMN_ADD_SECTION_RANK = exports.COLUMN_ADD_SECTION = exports.ADD_COLUMN_RIGHT_ITEM = exports.ADD_COLUMN_LEFT_ITEM = void 0;
|
|
7
|
+
exports.SORT_INCREASING_ITEM = exports.SORT_DECREASING_ITEM = exports.MOVE_COLUMN_RIGHT_ITEM = exports.MOVE_COLUMN_LEFT_ITEM = exports.HEADER_COLUMN_TOGGLE_ITEM = exports.DISTRIBUTE_COLUMNS_ITEM = exports.DELETE_COLUMN_ITEM = exports.COLUMN_TOGGLE_SECTION_RANK = exports.COLUMN_TOGGLE_SECTION = exports.COLUMN_SORT_SECTION_RANK = exports.COLUMN_SORT_SECTION = exports.COLUMN_SECTION_RANK = exports.COLUMN_MENU = exports.COLUMN_DANGER_SECTION_RANK = exports.COLUMN_DANGER_SECTION = exports.COLUMN_BACKGROUND_SECTION_RANK = exports.COLUMN_BACKGROUND_SECTION = exports.COLUMN_ADD_SECTION_RANK = exports.COLUMN_ADD_SECTION = exports.ADD_COLUMN_RIGHT_ITEM = exports.ADD_COLUMN_LEFT_ITEM = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _keys = require("../shared/keys");
|
|
10
10
|
// --- Menu surface ---
|
|
@@ -57,6 +57,10 @@ var ADD_COLUMN_RIGHT_ITEM = exports.ADD_COLUMN_RIGHT_ITEM = {
|
|
|
57
57
|
type: 'menu-item',
|
|
58
58
|
key: 'add-column-right'
|
|
59
59
|
};
|
|
60
|
+
var MOVE_COLUMN_LEFT_ITEM = exports.MOVE_COLUMN_LEFT_ITEM = {
|
|
61
|
+
type: 'menu-item',
|
|
62
|
+
key: 'move-column-left'
|
|
63
|
+
};
|
|
60
64
|
var MOVE_COLUMN_RIGHT_ITEM = exports.MOVE_COLUMN_RIGHT_ITEM = {
|
|
61
65
|
type: 'menu-item',
|
|
62
66
|
key: 'move-column-right'
|
|
@@ -75,5 +79,5 @@ var DELETE_COLUMN_ITEM = exports.DELETE_COLUMN_ITEM = {
|
|
|
75
79
|
var COLUMN_TOGGLE_SECTION_RANK = exports.COLUMN_TOGGLE_SECTION_RANK = (0, _defineProperty2.default)({}, HEADER_COLUMN_TOGGLE_ITEM.key, 100);
|
|
76
80
|
var COLUMN_BACKGROUND_SECTION_RANK = exports.COLUMN_BACKGROUND_SECTION_RANK = (0, _defineProperty2.default)({}, _keys.BACKGROUND_COLOR_ITEM.key, 100);
|
|
77
81
|
var COLUMN_SORT_SECTION_RANK = exports.COLUMN_SORT_SECTION_RANK = (0, _defineProperty2.default)((0, _defineProperty2.default)({}, SORT_INCREASING_ITEM.key, 100), SORT_DECREASING_ITEM.key, 200);
|
|
78
|
-
var COLUMN_ADD_SECTION_RANK = exports.COLUMN_ADD_SECTION_RANK = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, ADD_COLUMN_LEFT_ITEM.key, 100), ADD_COLUMN_RIGHT_ITEM.key, 200),
|
|
82
|
+
var COLUMN_ADD_SECTION_RANK = exports.COLUMN_ADD_SECTION_RANK = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, 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);
|
|
79
83
|
var COLUMN_DANGER_SECTION_RANK = exports.COLUMN_DANGER_SECTION_RANK = (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _keys.CLEAR_CELLS_ITEM.key, 100), DELETE_COLUMN_ITEM.key, 200);
|
|
@@ -11,5 +11,5 @@ var _getColumnMenuComponents = require("../column/getColumnMenuComponents");
|
|
|
11
11
|
var _getRowMenuComponents = require("../row/getRowMenuComponents");
|
|
12
12
|
var _getSharedItems = require("./getSharedItems");
|
|
13
13
|
var getTableMenuComponents = exports.getTableMenuComponents = function getTableMenuComponents(params) {
|
|
14
|
-
return [].concat((0, _toConsumableArray2.default)((0, _getRowMenuComponents.getRowMenuComponents)(params)), (0, _toConsumableArray2.default)((0, _getColumnMenuComponents.getColumnMenuComponents)()), (0, _toConsumableArray2.default)((0, _getCellMenuComponents.getCellMenuComponents)()), (0, _toConsumableArray2.default)((0, _getSharedItems.getSharedItems)(params)));
|
|
14
|
+
return [].concat((0, _toConsumableArray2.default)((0, _getRowMenuComponents.getRowMenuComponents)(params)), (0, _toConsumableArray2.default)((0, _getColumnMenuComponents.getColumnMenuComponents)(params)), (0, _toConsumableArray2.default)((0, _getCellMenuComponents.getCellMenuComponents)()), (0, _toConsumableArray2.default)((0, _getSharedItems.getSharedItems)(params)));
|
|
15
15
|
};
|
|
@@ -113,6 +113,9 @@ const tablePlugin = ({
|
|
|
113
113
|
isHeaderRowEnabled: tablePluginState.isHeaderRowEnabled,
|
|
114
114
|
isHeaderColumnEnabled: tablePluginState.isHeaderColumnEnabled,
|
|
115
115
|
isNumberColumnEnabled: tablePluginState.isNumberColumnEnabled,
|
|
116
|
+
isCommentEditor: tablePluginState.isCommentEditor,
|
|
117
|
+
isTableScalingEnabled: tablePluginState.isTableScalingEnabled,
|
|
118
|
+
isTableFixedColumnWidthsOptionEnabled,
|
|
116
119
|
ordering: tablePluginState.ordering,
|
|
117
120
|
isResizing: !!(tableResizingPluginState !== null && tableResizingPluginState !== void 0 && tableResizingPluginState.dragging || tableWidthResizingPluginState !== null && tableWidthResizingPluginState !== void 0 && tableWidthResizingPluginState.resizing),
|
|
118
121
|
isTableResizing: tableWidthResizingPluginState === null || tableWidthResizingPluginState === void 0 ? void 0 : tableWidthResizingPluginState.resizing,
|
|
@@ -7,11 +7,14 @@ 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 const 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 const getColumnMenuComponents = ({
|
|
16
|
+
api
|
|
17
|
+
}) => [
|
|
15
18
|
// --- Menu surface ---
|
|
16
19
|
{
|
|
17
20
|
type: COLUMN_MENU.type,
|
|
@@ -26,7 +29,9 @@ export const getColumnMenuComponents = () => [
|
|
|
26
29
|
key: COLUMN_MENU.key,
|
|
27
30
|
rank: COLUMN_SECTION_RANK[COLUMN_TOGGLE_SECTION.key]
|
|
28
31
|
}],
|
|
29
|
-
component: props => /*#__PURE__*/React.createElement(ColumnToggleSection,
|
|
32
|
+
component: props => /*#__PURE__*/React.createElement(ColumnToggleSection, {
|
|
33
|
+
api: api
|
|
34
|
+
}, props.children)
|
|
30
35
|
}, {
|
|
31
36
|
type: HEADER_COLUMN_TOGGLE_ITEM.type,
|
|
32
37
|
key: HEADER_COLUMN_TOGGLE_ITEM.key,
|
|
@@ -35,7 +40,9 @@ export const getColumnMenuComponents = () => [
|
|
|
35
40
|
key: COLUMN_TOGGLE_SECTION.key,
|
|
36
41
|
rank: COLUMN_TOGGLE_SECTION_RANK[HEADER_COLUMN_TOGGLE_ITEM.key]
|
|
37
42
|
}],
|
|
38
|
-
component: () => /*#__PURE__*/React.createElement(HeaderColumnToggleItem,
|
|
43
|
+
component: () => /*#__PURE__*/React.createElement(HeaderColumnToggleItem, {
|
|
44
|
+
api: api
|
|
45
|
+
})
|
|
39
46
|
},
|
|
40
47
|
// --- Background color section ---
|
|
41
48
|
{
|
|
@@ -46,7 +53,9 @@ export const getColumnMenuComponents = () => [
|
|
|
46
53
|
key: COLUMN_MENU.key,
|
|
47
54
|
rank: COLUMN_SECTION_RANK[COLUMN_BACKGROUND_SECTION.key]
|
|
48
55
|
}],
|
|
49
|
-
component: props => /*#__PURE__*/React.createElement(ColumnBackgroundSection,
|
|
56
|
+
component: props => /*#__PURE__*/React.createElement(ColumnBackgroundSection, {
|
|
57
|
+
api: api
|
|
58
|
+
}, props.children)
|
|
50
59
|
},
|
|
51
60
|
// --- Sort section ---
|
|
52
61
|
{
|
|
@@ -68,7 +77,9 @@ export const getColumnMenuComponents = () => [
|
|
|
68
77
|
key: COLUMN_SORT_SECTION.key,
|
|
69
78
|
rank: COLUMN_SORT_SECTION_RANK[SORT_INCREASING_ITEM.key]
|
|
70
79
|
}],
|
|
71
|
-
component: () => /*#__PURE__*/React.createElement(SortIncreasingItem,
|
|
80
|
+
component: () => /*#__PURE__*/React.createElement(SortIncreasingItem, {
|
|
81
|
+
api: api
|
|
82
|
+
})
|
|
72
83
|
}, {
|
|
73
84
|
type: SORT_DECREASING_ITEM.type,
|
|
74
85
|
key: SORT_DECREASING_ITEM.key,
|
|
@@ -77,7 +88,9 @@ export const getColumnMenuComponents = () => [
|
|
|
77
88
|
key: COLUMN_SORT_SECTION.key,
|
|
78
89
|
rank: COLUMN_SORT_SECTION_RANK[SORT_DECREASING_ITEM.key]
|
|
79
90
|
}],
|
|
80
|
-
component: () => /*#__PURE__*/React.createElement(SortDecreasingItem,
|
|
91
|
+
component: () => /*#__PURE__*/React.createElement(SortDecreasingItem, {
|
|
92
|
+
api: api
|
|
93
|
+
})
|
|
81
94
|
},
|
|
82
95
|
// --- Add / Move section ---
|
|
83
96
|
{
|
|
@@ -99,7 +112,9 @@ export const getColumnMenuComponents = () => [
|
|
|
99
112
|
key: COLUMN_ADD_SECTION.key,
|
|
100
113
|
rank: COLUMN_ADD_SECTION_RANK[ADD_COLUMN_LEFT_ITEM.key]
|
|
101
114
|
}],
|
|
102
|
-
component: () => /*#__PURE__*/React.createElement(AddColumnLeftItem,
|
|
115
|
+
component: () => /*#__PURE__*/React.createElement(AddColumnLeftItem, {
|
|
116
|
+
api: api
|
|
117
|
+
})
|
|
103
118
|
}, {
|
|
104
119
|
type: ADD_COLUMN_RIGHT_ITEM.type,
|
|
105
120
|
key: ADD_COLUMN_RIGHT_ITEM.key,
|
|
@@ -108,7 +123,20 @@ export const getColumnMenuComponents = () => [
|
|
|
108
123
|
key: COLUMN_ADD_SECTION.key,
|
|
109
124
|
rank: COLUMN_ADD_SECTION_RANK[ADD_COLUMN_RIGHT_ITEM.key]
|
|
110
125
|
}],
|
|
111
|
-
component: () => /*#__PURE__*/React.createElement(AddColumnRightItem,
|
|
126
|
+
component: () => /*#__PURE__*/React.createElement(AddColumnRightItem, {
|
|
127
|
+
api: api
|
|
128
|
+
})
|
|
129
|
+
}, {
|
|
130
|
+
type: MOVE_COLUMN_LEFT_ITEM.type,
|
|
131
|
+
key: MOVE_COLUMN_LEFT_ITEM.key,
|
|
132
|
+
parents: [{
|
|
133
|
+
type: COLUMN_ADD_SECTION.type,
|
|
134
|
+
key: COLUMN_ADD_SECTION.key,
|
|
135
|
+
rank: COLUMN_ADD_SECTION_RANK[MOVE_COLUMN_LEFT_ITEM.key]
|
|
136
|
+
}],
|
|
137
|
+
component: () => /*#__PURE__*/React.createElement(MoveColumnLeftItem, {
|
|
138
|
+
api: api
|
|
139
|
+
})
|
|
112
140
|
}, {
|
|
113
141
|
type: MOVE_COLUMN_RIGHT_ITEM.type,
|
|
114
142
|
key: MOVE_COLUMN_RIGHT_ITEM.key,
|
|
@@ -117,7 +145,9 @@ export const getColumnMenuComponents = () => [
|
|
|
117
145
|
key: COLUMN_ADD_SECTION.key,
|
|
118
146
|
rank: COLUMN_ADD_SECTION_RANK[MOVE_COLUMN_RIGHT_ITEM.key]
|
|
119
147
|
}],
|
|
120
|
-
component: () => /*#__PURE__*/React.createElement(MoveColumnRightItem,
|
|
148
|
+
component: () => /*#__PURE__*/React.createElement(MoveColumnRightItem, {
|
|
149
|
+
api: api
|
|
150
|
+
})
|
|
121
151
|
}, {
|
|
122
152
|
type: DISTRIBUTE_COLUMNS_ITEM.type,
|
|
123
153
|
key: DISTRIBUTE_COLUMNS_ITEM.key,
|
|
@@ -126,7 +156,9 @@ export const getColumnMenuComponents = () => [
|
|
|
126
156
|
key: COLUMN_ADD_SECTION.key,
|
|
127
157
|
rank: COLUMN_ADD_SECTION_RANK[DISTRIBUTE_COLUMNS_ITEM.key]
|
|
128
158
|
}],
|
|
129
|
-
component: () => /*#__PURE__*/React.createElement(DistributeColumnsItem,
|
|
159
|
+
component: () => /*#__PURE__*/React.createElement(DistributeColumnsItem, {
|
|
160
|
+
api: api
|
|
161
|
+
})
|
|
130
162
|
},
|
|
131
163
|
// --- Danger section (Clear cells, Delete column) ---
|
|
132
164
|
{
|
|
@@ -148,5 +180,7 @@ export const getColumnMenuComponents = () => [
|
|
|
148
180
|
key: COLUMN_DANGER_SECTION.key,
|
|
149
181
|
rank: COLUMN_DANGER_SECTION_RANK[DELETE_COLUMN_ITEM.key]
|
|
150
182
|
}],
|
|
151
|
-
component: () => /*#__PURE__*/React.createElement(DeleteColumnItem,
|
|
183
|
+
component: () => /*#__PURE__*/React.createElement(DeleteColumnItem, {
|
|
184
|
+
api: api
|
|
185
|
+
})
|
|
152
186
|
}];
|
|
@@ -1,14 +1,50 @@
|
|
|
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 const AddColumnLeftItem = ({
|
|
12
|
+
api
|
|
13
|
+
}) => {
|
|
7
14
|
var _tooltip;
|
|
15
|
+
const {
|
|
16
|
+
editorView
|
|
17
|
+
} = useEditorToolbar();
|
|
8
18
|
const {
|
|
9
19
|
formatMessage
|
|
10
20
|
} = useIntl();
|
|
21
|
+
const {
|
|
22
|
+
isCommentEditor,
|
|
23
|
+
isTableFixedColumnWidthsOptionEnabled,
|
|
24
|
+
isTableScalingEnabled
|
|
25
|
+
} = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], states => {
|
|
26
|
+
const tableState = states.tableState;
|
|
27
|
+
return {
|
|
28
|
+
isCommentEditor: tableState === null || tableState === void 0 ? void 0 : tableState.isCommentEditor,
|
|
29
|
+
isTableFixedColumnWidthsOptionEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableFixedColumnWidthsOptionEnabled,
|
|
30
|
+
isTableScalingEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableScalingEnabled
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
const handleClick = () => {
|
|
34
|
+
var _api$analytics;
|
|
35
|
+
if (!editorView) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const selectionRect = getSelectionRect(editorView.state.selection);
|
|
39
|
+
const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.left;
|
|
40
|
+
if (index === undefined) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
|
|
44
|
+
insertColumnWithAnalytics(api, api === null || api === void 0 ? 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);
|
|
45
|
+
};
|
|
11
46
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
47
|
+
onClick: handleClick,
|
|
12
48
|
elemBefore: /*#__PURE__*/React.createElement(TableColumnAddLeftIcon, {
|
|
13
49
|
color: "currentColor",
|
|
14
50
|
label: "",
|
|
@@ -1,14 +1,50 @@
|
|
|
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 const AddColumnRightItem = ({
|
|
12
|
+
api
|
|
13
|
+
}) => {
|
|
7
14
|
var _tooltip;
|
|
15
|
+
const {
|
|
16
|
+
editorView
|
|
17
|
+
} = useEditorToolbar();
|
|
8
18
|
const {
|
|
9
19
|
formatMessage
|
|
10
20
|
} = useIntl();
|
|
21
|
+
const {
|
|
22
|
+
isCommentEditor,
|
|
23
|
+
isTableFixedColumnWidthsOptionEnabled,
|
|
24
|
+
isTableScalingEnabled
|
|
25
|
+
} = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], states => {
|
|
26
|
+
const tableState = states.tableState;
|
|
27
|
+
return {
|
|
28
|
+
isCommentEditor: tableState === null || tableState === void 0 ? void 0 : tableState.isCommentEditor,
|
|
29
|
+
isTableFixedColumnWidthsOptionEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableFixedColumnWidthsOptionEnabled,
|
|
30
|
+
isTableScalingEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableScalingEnabled
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
const handleClick = () => {
|
|
34
|
+
var _api$analytics;
|
|
35
|
+
if (!editorView) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const selectionRect = getSelectionRect(editorView.state.selection);
|
|
39
|
+
const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
|
|
40
|
+
if (index === undefined) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
|
|
44
|
+
insertColumnWithAnalytics(api, api === null || api === void 0 ? 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);
|
|
45
|
+
};
|
|
11
46
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
47
|
+
onClick: handleClick,
|
|
12
48
|
elemBefore: /*#__PURE__*/React.createElement(TableColumnAddRightIcon, {
|
|
13
49
|
color: "currentColor",
|
|
14
50
|
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,10 +11,23 @@ import { shouldShowHeaderColumnToggle } from './HeaderColumnToggleItem';
|
|
|
10
11
|
* the very top of the menu.
|
|
11
12
|
*/
|
|
12
13
|
export const ColumnBackgroundSection = ({
|
|
14
|
+
api,
|
|
13
15
|
children
|
|
14
16
|
}) => {
|
|
15
17
|
const tableMenuContext = useTableMenuContext();
|
|
16
|
-
const
|
|
18
|
+
const {
|
|
19
|
+
isHeaderColumnAllowed
|
|
20
|
+
} = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], states => {
|
|
21
|
+
var _states$tableState, _states$tableState$pl;
|
|
22
|
+
return {
|
|
23
|
+
isHeaderColumnAllowed: (_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.allowHeaderColumn
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
const hasSeparator = shouldShowHeaderColumnToggle({
|
|
27
|
+
isFirstColumn: tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstColumn,
|
|
28
|
+
isHeaderColumnAllowed,
|
|
29
|
+
selectedColumnCount: tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount
|
|
30
|
+
});
|
|
17
31
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
18
32
|
hasSeparator: hasSeparator
|
|
19
33
|
}, 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,10 +10,23 @@ import { shouldShowHeaderColumnToggle } from './HeaderColumnToggleItem';
|
|
|
9
10
|
* empty wrapper (and so the section below can drop its leading separator).
|
|
10
11
|
*/
|
|
11
12
|
export const ColumnToggleSection = ({
|
|
13
|
+
api,
|
|
12
14
|
children
|
|
13
15
|
}) => {
|
|
14
16
|
const tableMenuContext = useTableMenuContext();
|
|
15
|
-
|
|
17
|
+
const {
|
|
18
|
+
isHeaderColumnAllowed
|
|
19
|
+
} = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], states => {
|
|
20
|
+
var _states$tableState, _states$tableState$pl;
|
|
21
|
+
return {
|
|
22
|
+
isHeaderColumnAllowed: (_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.allowHeaderColumn
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
if (!shouldShowHeaderColumnToggle({
|
|
26
|
+
isFirstColumn: tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstColumn,
|
|
27
|
+
isHeaderColumnAllowed,
|
|
28
|
+
selectedColumnCount: tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount
|
|
29
|
+
})) {
|
|
16
30
|
return null;
|
|
17
31
|
}
|
|
18
32
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, children);
|
|
@@ -1,14 +1,74 @@
|
|
|
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 const DeleteColumnItem = ({
|
|
15
|
+
api
|
|
16
|
+
}) => {
|
|
17
|
+
var _tableMenuContext$sel, _tooltip;
|
|
18
|
+
const {
|
|
19
|
+
editorView
|
|
20
|
+
} = useEditorToolbar();
|
|
21
|
+
const tableMenuContext = useTableMenuContext();
|
|
22
|
+
const selectedColumnCount = (_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1;
|
|
8
23
|
const {
|
|
9
24
|
formatMessage
|
|
10
25
|
} = useIntl();
|
|
26
|
+
const {
|
|
27
|
+
isCommentEditor,
|
|
28
|
+
isTableFixedColumnWidthsOptionEnabled,
|
|
29
|
+
isTableScalingEnabled
|
|
30
|
+
} = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], states => {
|
|
31
|
+
const tableState = states.tableState;
|
|
32
|
+
return {
|
|
33
|
+
isCommentEditor: tableState === null || tableState === void 0 ? void 0 : tableState.isCommentEditor,
|
|
34
|
+
isTableFixedColumnWidthsOptionEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableFixedColumnWidthsOptionEnabled,
|
|
35
|
+
isTableScalingEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableScalingEnabled
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
const handleMouseEnter = () => {
|
|
39
|
+
if (!editorView) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const selectionRect = getSelectionRect(editorView.state.selection);
|
|
43
|
+
if (!selectionRect) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
hoverColumns(getSelectedColumnIndexes(selectionRect), true)(editorView.state, editorView.dispatch);
|
|
47
|
+
};
|
|
48
|
+
const handleMouseLeave = () => {
|
|
49
|
+
if (!editorView) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
clearHoverSelection()(editorView.state, editorView.dispatch);
|
|
53
|
+
};
|
|
54
|
+
const handleClick = () => {
|
|
55
|
+
var _api$analytics;
|
|
56
|
+
if (!editorView) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const selectionRect = getSelectionRect(editorView.state.selection);
|
|
60
|
+
if (!selectionRect) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
|
|
64
|
+
deleteColumnsWithAnalytics(api === null || api === void 0 ? 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);
|
|
65
|
+
};
|
|
11
66
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
67
|
+
onClick: handleClick,
|
|
68
|
+
onFocus: handleMouseEnter,
|
|
69
|
+
onMouseEnter: handleMouseEnter,
|
|
70
|
+
onBlur: handleMouseLeave,
|
|
71
|
+
onMouseLeave: handleMouseLeave,
|
|
12
72
|
elemBefore: /*#__PURE__*/React.createElement(DeleteIcon, {
|
|
13
73
|
color: "currentColor",
|
|
14
74
|
label: "",
|
|
@@ -18,6 +78,6 @@ export const DeleteColumnItem = () => {
|
|
|
18
78
|
shortcut: (_tooltip = tooltip(deleteColumn)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
19
79
|
})
|
|
20
80
|
}, formatMessage(messages.removeColumns, {
|
|
21
|
-
0:
|
|
81
|
+
0: selectedColumnCount
|
|
22
82
|
}));
|
|
23
83
|
};
|
|
@@ -1,23 +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
|
-
const shouldShowDistributeColumns =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
+
const shouldShowDistributeColumns = selectedColumnCount => (selectedColumnCount !== null && selectedColumnCount !== void 0 ? selectedColumnCount : 0) > 1;
|
|
14
|
+
export const DistributeColumnsItem = ({
|
|
15
|
+
api
|
|
16
|
+
}) => {
|
|
17
|
+
const {
|
|
18
|
+
editorView
|
|
19
|
+
} = useEditorToolbar();
|
|
13
20
|
const tableMenuContext = useTableMenuContext();
|
|
14
21
|
const {
|
|
15
22
|
formatMessage
|
|
16
23
|
} = useIntl();
|
|
17
|
-
|
|
24
|
+
const {
|
|
25
|
+
isCommentEditor,
|
|
26
|
+
isTableFixedColumnWidthsOptionEnabled,
|
|
27
|
+
isTableScalingEnabled
|
|
28
|
+
} = useSharedPluginStateWithSelector(api !== null && api !== void 0 ? api : undefined, ['table'], states => {
|
|
29
|
+
const tableState = states.tableState;
|
|
30
|
+
return {
|
|
31
|
+
isCommentEditor: tableState === null || tableState === void 0 ? void 0 : tableState.isCommentEditor,
|
|
32
|
+
isTableFixedColumnWidthsOptionEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableFixedColumnWidthsOptionEnabled,
|
|
33
|
+
isTableScalingEnabled: tableState === null || tableState === void 0 ? void 0 : tableState.isTableScalingEnabled
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
const handleClick = () => {
|
|
37
|
+
var _api$width, _api$analytics;
|
|
38
|
+
if (!editorView) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const selectionRect = getSelectionRect(editorView.state.selection);
|
|
42
|
+
const editorContainerWidth = api === null || api === void 0 ? void 0 : (_api$width = api.width) === null || _api$width === void 0 ? void 0 : _api$width.sharedState.currentState();
|
|
43
|
+
if (!selectionRect || !editorContainerWidth) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const newResizeState = getNewResizeStateFromSelectedColumns(selectionRect, editorView.state, editorView.domAtPos.bind(editorView), () => editorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, isCommentEditor);
|
|
47
|
+
if (!newResizeState) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
distributeColumnsWidthsWithAnalytics(api === null || api === void 0 ? 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)) {
|
|
18
53
|
return null;
|
|
19
54
|
}
|
|
20
55
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
56
|
+
onClick: handleClick,
|
|
21
57
|
elemBefore: /*#__PURE__*/React.createElement(TableColumnsDistributeIcon, {
|
|
22
58
|
color: "currentColor",
|
|
23
59
|
label: "",
|