@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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.MoveColumnLeftItem = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactIntl = require("react-intl");
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
|
+
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
13
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
15
|
+
var _utils = require("@atlaskit/editor-tables/utils");
|
|
16
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
17
|
+
var _tableColumnMoveLeft = _interopRequireDefault(require("@atlaskit/icon/core/table-column-move-left"));
|
|
18
|
+
var _commandsWithAnalytics = require("../../../../pm-plugins/drag-and-drop/commands-with-analytics");
|
|
19
|
+
var _pluginFactory = require("../../../../pm-plugins/plugin-factory");
|
|
20
|
+
var _selection = require("../../../../pm-plugins/utils/selection");
|
|
21
|
+
var _consts = require("../../shared/consts");
|
|
22
|
+
var _TableMenuContext = require("../../shared/TableMenuContext");
|
|
23
|
+
var shouldShowMoveColumnLeft = function shouldShowMoveColumnLeft(isFirstColumn) {
|
|
24
|
+
return !isFirstColumn;
|
|
25
|
+
};
|
|
26
|
+
var MoveColumnLeftItem = exports.MoveColumnLeftItem = function MoveColumnLeftItem(props) {
|
|
27
|
+
var _tableMenuContext$sel, _tooltip;
|
|
28
|
+
var api = props.api;
|
|
29
|
+
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
30
|
+
editorView = _useEditorToolbar.editorView;
|
|
31
|
+
var tableMenuContext = (0, _TableMenuContext.useTableMenuContext)();
|
|
32
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
33
|
+
var _states$tableState;
|
|
34
|
+
return {
|
|
35
|
+
tableNode: (_states$tableState = states.tableState) === null || _states$tableState === void 0 ? void 0 : _states$tableState.tableNode
|
|
36
|
+
};
|
|
37
|
+
}),
|
|
38
|
+
tableNode = _useSharedPluginState.tableNode;
|
|
39
|
+
var selectedColumnCount = (_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1;
|
|
40
|
+
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
41
|
+
formatMessage = _useIntl.formatMessage;
|
|
42
|
+
var handleClick = function handleClick() {
|
|
43
|
+
var _api$analytics, _api$accessibilityUti;
|
|
44
|
+
if (!editorView) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
var selectionRect = (0, _utils.getSelectionRect)(editorView.state.selection);
|
|
48
|
+
if (!selectionRect) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
(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.left - 1)(editorView.state, editorView.dispatch);
|
|
52
|
+
};
|
|
53
|
+
if (!tableNode || !shouldShowMoveColumnLeft(tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.isFirstColumn)) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
57
|
+
onClick: handleClick,
|
|
58
|
+
elemBefore: /*#__PURE__*/_react.default.createElement(_tableColumnMoveLeft.default, {
|
|
59
|
+
color: "currentColor",
|
|
60
|
+
label: "",
|
|
61
|
+
size: "small"
|
|
62
|
+
}),
|
|
63
|
+
elemAfter: /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarKeyboardShortcutHint, {
|
|
64
|
+
shortcut: (_tooltip = (0, _keymaps.tooltip)(_keymaps.moveColumnLeft)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
65
|
+
})
|
|
66
|
+
}, formatMessage(_messages.tableMessages.moveColumnLeft, {
|
|
67
|
+
0: selectedColumnCount
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
@@ -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
|
};
|
|
@@ -8,6 +8,7 @@ import { tintDirtyTransaction } from '@atlaskit/editor-common/collab';
|
|
|
8
8
|
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
9
9
|
import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
10
10
|
import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
11
|
+
import { NodeViewContentHole } from '@atlaskit/editor-common/react-node-view';
|
|
11
12
|
import { isTableInContentMode } from '@atlaskit/editor-common/table';
|
|
12
13
|
import { isValidPosition } from '@atlaskit/editor-common/utils';
|
|
13
14
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
@@ -19,7 +20,7 @@ import { autoSizeTable, clearHoverSelection, setTableRef } from '../pm-plugins/c
|
|
|
19
20
|
import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils/autoscrollers';
|
|
20
21
|
import { pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers/plugin-key';
|
|
21
22
|
import { findStickyHeaderForTable } from '../pm-plugins/sticky-headers/util';
|
|
22
|
-
import {
|
|
23
|
+
import { hasTableBeenResized, insertColgroupFromNode } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
23
24
|
import { COLUMN_MIN_WIDTH, TABLE_EDITOR_MARGIN, TABLE_OFFSET_IN_COMMENT_EDITOR } from '../pm-plugins/table-resizing/utils/consts';
|
|
24
25
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
25
26
|
import { getLayoutSize, getScalingPercentForTableWithoutWidth, getTableScalingPercent } from '../pm-plugins/table-resizing/utils/misc';
|
|
@@ -71,6 +72,21 @@ class TableComponent extends React.Component {
|
|
|
71
72
|
this.props.view.dispatch(tr);
|
|
72
73
|
});
|
|
73
74
|
_defineProperty(this, "lastSetTableRef", null);
|
|
75
|
+
_defineProperty(this, "setWrapperRef", elem => {
|
|
76
|
+
this.wrapper = elem;
|
|
77
|
+
if (!elem) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this.props.contentDOM(elem);
|
|
81
|
+
const tableElement = elem.querySelector('table');
|
|
82
|
+
if (tableElement !== this.table) {
|
|
83
|
+
this.table = tableElement;
|
|
84
|
+
this.observeTable(this.table);
|
|
85
|
+
if (this.table && (!expValEquals('platform_editor_table_ref_optimisation', 'isEnabled', true) || this.props.tableActive) && this.props.view && !expValEquals('platform_editor_fix_editor_unhandled_type_errors', 'isEnabled', true) && (expValEquals('platform_editor_table_update_table_ref', 'isEnabled', true) || fg('platform_editor_enable_table_update_ref_atlas'))) {
|
|
86
|
+
setTableRef(this.table)(this.props.view.state, this.props.view.dispatch);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
74
90
|
_defineProperty(this, "onStickyState", state => {
|
|
75
91
|
const pos = this.props.getPos();
|
|
76
92
|
if (!isValidPosition(pos, this.props.view.state)) {
|
|
@@ -919,26 +935,12 @@ class TableComponent extends React.Component {
|
|
|
919
935
|
var _this$wrapper4;
|
|
920
936
|
return ((_this$wrapper4 = this.wrapper) === null || _this$wrapper4 === void 0 ? void 0 : _this$wrapper4.clientWidth) || 760;
|
|
921
937
|
}
|
|
922
|
-
}), /*#__PURE__*/React.createElement(
|
|
923
|
-
|
|
938
|
+
}), /*#__PURE__*/React.createElement(NodeViewContentHole
|
|
939
|
+
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides -- existing table wrapper class required for legacy styling hooks
|
|
940
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
941
|
+
, {
|
|
924
942
|
className: classnames(ClassName.TABLE_NODE_WRAPPER),
|
|
925
|
-
ref:
|
|
926
|
-
this.wrapper = elem;
|
|
927
|
-
if (elem) {
|
|
928
|
-
this.props.contentDOM(elem);
|
|
929
|
-
const tableElement = elem.querySelector('table');
|
|
930
|
-
if (tableElement !== this.table) {
|
|
931
|
-
this.table = tableElement;
|
|
932
|
-
this.observeTable(this.table);
|
|
933
|
-
|
|
934
|
-
// // Update tableRef in plugin state when table is properly mounted
|
|
935
|
-
// // At this point, both table and wrapper are in DOM with correct parent-child relationship
|
|
936
|
-
if (this.table && (!expValEquals('platform_editor_table_ref_optimisation', 'isEnabled', true) || this.props.tableActive) && this.props.view && !expValEquals('platform_editor_fix_editor_unhandled_type_errors', 'isEnabled', true) && (expValEquals('platform_editor_table_update_table_ref', 'isEnabled', true) || fg('platform_editor_enable_table_update_ref_atlas'))) {
|
|
937
|
-
setTableRef(this.table)(this.props.view.state, this.props.view.dispatch);
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
}
|
|
943
|
+
ref: this.setWrapperRef
|
|
942
944
|
}, allowControls && colControls), !this.isNestedInTable ? /*#__PURE__*/React.createElement("div", {
|
|
943
945
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
944
946
|
className: ClassName.TABLE_STICKY_SCROLLBAR_CONTAINER,
|
|
@@ -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);
|