@atlaskit/editor-plugin-table 22.4.11 → 22.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/tablePlugin.js +7 -1
- package/dist/cjs/ui/TableMenu/column/getColumnMenuComponents.js +46 -11
- package/dist/cjs/ui/TableMenu/column/items/AddColumnLeftItem.js +34 -1
- package/dist/cjs/ui/TableMenu/column/items/AddColumnRightItem.js +34 -1
- package/dist/cjs/ui/TableMenu/column/items/ColumnBackgroundSection.js +15 -2
- package/dist/cjs/ui/TableMenu/column/items/ColumnToggleSection.js +15 -2
- package/dist/cjs/ui/TableMenu/column/items/DeleteColumnItem.js +60 -3
- package/dist/cjs/ui/TableMenu/column/items/DistributeColumnsItem.js +43 -5
- package/dist/cjs/ui/TableMenu/column/items/HeaderColumnToggleItem.js +36 -5
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnLeftItem.js +69 -0
- package/dist/cjs/ui/TableMenu/column/items/MoveColumnRightItem.js +42 -3
- package/dist/cjs/ui/TableMenu/column/items/SortDecreasingItem.js +22 -1
- package/dist/cjs/ui/TableMenu/column/items/SortIncreasingItem.js +22 -1
- package/dist/cjs/ui/TableMenu/column/keys.js +6 -2
- package/dist/cjs/ui/TableMenu/row/getRowMenuComponents.js +23 -8
- package/dist/cjs/ui/TableMenu/row/items/AddRowAboveItem.js +24 -1
- package/dist/cjs/ui/TableMenu/row/items/AddRowBelowItem.js +24 -1
- package/dist/cjs/ui/TableMenu/row/items/DeleteRowItem.js +55 -3
- package/dist/cjs/ui/TableMenu/row/items/HeaderRowToggleItem.js +38 -5
- package/dist/cjs/ui/TableMenu/row/items/MoveRowDownItem.js +38 -13
- package/dist/cjs/ui/TableMenu/row/items/MoveRowUpItem.js +38 -13
- package/dist/cjs/ui/TableMenu/row/items/NumberedRowsToggleItem.js +29 -2
- package/dist/cjs/ui/TableMenu/shared/consts.js +4 -2
- package/dist/cjs/ui/TableMenu/shared/getSharedItems.js +5 -2
- package/dist/cjs/ui/TableMenu/shared/getTableMenuComponents.js +2 -2
- package/dist/cjs/ui/TableMenu/shared/items/ClearCellsItem.js +23 -3
- package/dist/cjs/ui/TableMenu/shared/types.js +5 -0
- package/dist/es2019/tablePlugin.js +7 -1
- package/dist/es2019/ui/TableMenu/column/getColumnMenuComponents.js +46 -12
- package/dist/es2019/ui/TableMenu/column/items/AddColumnLeftItem.js +37 -1
- package/dist/es2019/ui/TableMenu/column/items/AddColumnRightItem.js +37 -1
- package/dist/es2019/ui/TableMenu/column/items/ColumnBackgroundSection.js +15 -1
- package/dist/es2019/ui/TableMenu/column/items/ColumnToggleSection.js +15 -1
- package/dist/es2019/ui/TableMenu/column/items/DeleteColumnItem.js +63 -3
- package/dist/es2019/ui/TableMenu/column/items/DistributeColumnsItem.js +43 -7
- package/dist/es2019/ui/TableMenu/column/items/HeaderColumnToggleItem.js +40 -5
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnLeftItem.js +65 -0
- package/dist/es2019/ui/TableMenu/column/items/MoveColumnRightItem.js +44 -3
- package/dist/es2019/ui/TableMenu/column/items/SortDecreasingItem.js +24 -1
- package/dist/es2019/ui/TableMenu/column/items/SortIncreasingItem.js +24 -1
- package/dist/es2019/ui/TableMenu/column/keys.js +7 -2
- package/dist/es2019/ui/TableMenu/row/getRowMenuComponents.js +24 -8
- package/dist/es2019/ui/TableMenu/row/items/AddRowAboveItem.js +27 -1
- package/dist/es2019/ui/TableMenu/row/items/AddRowBelowItem.js +27 -1
- package/dist/es2019/ui/TableMenu/row/items/DeleteRowItem.js +59 -3
- package/dist/es2019/ui/TableMenu/row/items/HeaderRowToggleItem.js +42 -5
- package/dist/es2019/ui/TableMenu/row/items/MoveRowDownItem.js +42 -11
- package/dist/es2019/ui/TableMenu/row/items/MoveRowUpItem.js +42 -11
- package/dist/es2019/ui/TableMenu/row/items/NumberedRowsToggleItem.js +33 -2
- package/dist/es2019/ui/TableMenu/shared/consts.js +3 -1
- package/dist/es2019/ui/TableMenu/shared/getSharedItems.js +6 -2
- package/dist/es2019/ui/TableMenu/shared/getTableMenuComponents.js +1 -1
- package/dist/es2019/ui/TableMenu/shared/items/ClearCellsItem.js +26 -3
- package/dist/es2019/ui/TableMenu/shared/types.js +1 -0
- package/dist/esm/tablePlugin.js +7 -1
- package/dist/esm/ui/TableMenu/column/getColumnMenuComponents.js +47 -12
- package/dist/esm/ui/TableMenu/column/items/AddColumnLeftItem.js +34 -1
- package/dist/esm/ui/TableMenu/column/items/AddColumnRightItem.js +34 -1
- package/dist/esm/ui/TableMenu/column/items/ColumnBackgroundSection.js +15 -2
- package/dist/esm/ui/TableMenu/column/items/ColumnToggleSection.js +15 -2
- package/dist/esm/ui/TableMenu/column/items/DeleteColumnItem.js +60 -3
- package/dist/esm/ui/TableMenu/column/items/DistributeColumnsItem.js +43 -6
- package/dist/esm/ui/TableMenu/column/items/HeaderColumnToggleItem.js +36 -6
- package/dist/esm/ui/TableMenu/column/items/MoveColumnLeftItem.js +62 -0
- package/dist/esm/ui/TableMenu/column/items/MoveColumnRightItem.js +42 -3
- package/dist/esm/ui/TableMenu/column/items/SortDecreasingItem.js +22 -1
- package/dist/esm/ui/TableMenu/column/items/SortIncreasingItem.js +22 -1
- package/dist/esm/ui/TableMenu/column/keys.js +5 -1
- package/dist/esm/ui/TableMenu/row/getRowMenuComponents.js +23 -8
- package/dist/esm/ui/TableMenu/row/items/AddRowAboveItem.js +24 -1
- package/dist/esm/ui/TableMenu/row/items/AddRowBelowItem.js +24 -1
- package/dist/esm/ui/TableMenu/row/items/DeleteRowItem.js +55 -3
- package/dist/esm/ui/TableMenu/row/items/HeaderRowToggleItem.js +38 -6
- package/dist/esm/ui/TableMenu/row/items/MoveRowDownItem.js +39 -14
- package/dist/esm/ui/TableMenu/row/items/MoveRowUpItem.js +39 -14
- package/dist/esm/ui/TableMenu/row/items/NumberedRowsToggleItem.js +29 -2
- package/dist/esm/ui/TableMenu/shared/consts.js +3 -1
- package/dist/esm/ui/TableMenu/shared/getSharedItems.js +5 -2
- package/dist/esm/ui/TableMenu/shared/getTableMenuComponents.js +2 -2
- package/dist/esm/ui/TableMenu/shared/items/ClearCellsItem.js +23 -3
- package/dist/esm/ui/TableMenu/shared/types.js +1 -0
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/getColumnMenuComponents.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/AddColumnLeftItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/AddColumnRightItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/ColumnBackgroundSection.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/ColumnToggleSection.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/DeleteColumnItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/DistributeColumnsItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/HeaderColumnToggleItem.d.ts +7 -3
- package/dist/types/ui/TableMenu/column/items/MoveColumnLeftItem.d.ts +3 -0
- package/dist/types/ui/TableMenu/column/items/MoveColumnRightItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/SortDecreasingItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/items/SortIncreasingItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/column/keys.d.ts +1 -0
- package/dist/types/ui/TableMenu/row/getRowMenuComponents.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/AddRowAboveItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/AddRowBelowItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/DeleteRowItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/HeaderRowToggleItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/MoveRowDownItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/MoveRowUpItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/row/items/NumberedRowsToggleItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/shared/consts.d.ts +2 -0
- package/dist/types/ui/TableMenu/shared/getSharedItems.d.ts +2 -1
- package/dist/types/ui/TableMenu/shared/getTableMenuComponents.d.ts +2 -1
- package/dist/types/ui/TableMenu/shared/items/ClearCellsItem.d.ts +2 -1
- package/dist/types/ui/TableMenu/shared/types.d.ts +4 -0
- package/dist/types-ts4.5/types/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/getColumnMenuComponents.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/AddColumnLeftItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/AddColumnRightItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/ColumnBackgroundSection.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/ColumnToggleSection.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/DeleteColumnItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/DistributeColumnsItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/HeaderColumnToggleItem.d.ts +7 -3
- package/dist/types-ts4.5/ui/TableMenu/column/items/MoveColumnLeftItem.d.ts +3 -0
- package/dist/types-ts4.5/ui/TableMenu/column/items/MoveColumnRightItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/SortDecreasingItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/items/SortIncreasingItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/column/keys.d.ts +1 -0
- package/dist/types-ts4.5/ui/TableMenu/row/getRowMenuComponents.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/AddRowAboveItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/AddRowBelowItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/DeleteRowItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/HeaderRowToggleItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/MoveRowDownItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/MoveRowUpItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/row/items/NumberedRowsToggleItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/consts.d.ts +2 -0
- package/dist/types-ts4.5/ui/TableMenu/shared/getSharedItems.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/getTableMenuComponents.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/items/ClearCellsItem.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableMenu/shared/types.d.ts +4 -0
- package/package.json +4 -4
|
@@ -7,17 +7,44 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.NumberedRowsToggleItem = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactIntl = require("react-intl");
|
|
10
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
11
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
11
13
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
12
14
|
var _toggle = _interopRequireDefault(require("@atlaskit/toggle"));
|
|
13
|
-
var
|
|
15
|
+
var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
|
|
16
|
+
var NumberedRowsToggleItem = exports.NumberedRowsToggleItem = function NumberedRowsToggleItem(props) {
|
|
17
|
+
var api = props.api;
|
|
18
|
+
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
19
|
+
editorView = _useEditorToolbar.editorView;
|
|
20
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api !== null && api !== void 0 ? api : undefined, ['table'], function (states) {
|
|
21
|
+
var _states$tableState, _states$tableState2;
|
|
22
|
+
return {
|
|
23
|
+
isNumberColumnAllowed: (_states$tableState = states.tableState) === null || _states$tableState === void 0 || (_states$tableState = _states$tableState.pluginConfig) === null || _states$tableState === void 0 ? void 0 : _states$tableState.allowNumberColumn,
|
|
24
|
+
isNumberColumnEnabled: (_states$tableState2 = states.tableState) === null || _states$tableState2 === void 0 ? void 0 : _states$tableState2.isNumberColumnEnabled
|
|
25
|
+
};
|
|
26
|
+
}),
|
|
27
|
+
isNumberColumnAllowed = _useSharedPluginState.isNumberColumnAllowed,
|
|
28
|
+
isNumberColumnEnabled = _useSharedPluginState.isNumberColumnEnabled;
|
|
14
29
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
15
30
|
formatMessage = _useIntl.formatMessage;
|
|
16
31
|
var label = formatMessage(_messages.tableMessages.numberedRows);
|
|
32
|
+
var handleClick = function handleClick() {
|
|
33
|
+
var _api$analytics;
|
|
34
|
+
if (!editorView) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
(0, _commandsWithAnalytics.toggleNumberColumnWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(editorView.state, editorView.dispatch);
|
|
38
|
+
};
|
|
39
|
+
if (!isNumberColumnAllowed) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
17
42
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
43
|
+
onClick: handleClick,
|
|
18
44
|
elemAfter: /*#__PURE__*/_react.default.createElement(_toggle.default, {
|
|
19
45
|
label: label,
|
|
20
|
-
isChecked:
|
|
46
|
+
isChecked: !!isNumberColumnEnabled,
|
|
47
|
+
onChange: handleClick
|
|
21
48
|
})
|
|
22
49
|
}, label);
|
|
23
50
|
};
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TABLE_MENU_WIDTH = exports.TABLE_MENU_SELECTOR = void 0;
|
|
6
|
+
exports.TABLE_ROW = exports.TABLE_MENU_WIDTH = exports.TABLE_MENU_SELECTOR = exports.TABLE_COLUMN = void 0;
|
|
7
7
|
var TABLE_MENU_WIDTH = exports.TABLE_MENU_WIDTH = 280;
|
|
8
|
-
var TABLE_MENU_SELECTOR = exports.TABLE_MENU_SELECTOR = '[data-testid="column-handle-menu"], [data-testid="row-handle-menu"], [data-toolbar-nested-dropdown-menu]';
|
|
8
|
+
var TABLE_MENU_SELECTOR = exports.TABLE_MENU_SELECTOR = '[data-testid="column-handle-menu"], [data-testid="row-handle-menu"], [data-toolbar-nested-dropdown-menu]';
|
|
9
|
+
var TABLE_ROW = exports.TABLE_ROW = 'table-row';
|
|
10
|
+
var TABLE_COLUMN = exports.TABLE_COLUMN = 'table-column';
|
|
@@ -12,7 +12,8 @@ var _keys3 = require("../row/keys");
|
|
|
12
12
|
var _BackgroundColorItem = require("./items/BackgroundColorItem");
|
|
13
13
|
var _ClearCellsItem = require("./items/ClearCellsItem");
|
|
14
14
|
var _keys4 = require("./keys");
|
|
15
|
-
var getSharedItems = exports.getSharedItems = function getSharedItems() {
|
|
15
|
+
var getSharedItems = exports.getSharedItems = function getSharedItems(_ref) {
|
|
16
|
+
var api = _ref.api;
|
|
16
17
|
return [{
|
|
17
18
|
type: _keys4.BACKGROUND_COLOR_ITEM.type,
|
|
18
19
|
key: _keys4.BACKGROUND_COLOR_ITEM.key,
|
|
@@ -49,7 +50,9 @@ var getSharedItems = exports.getSharedItems = function getSharedItems() {
|
|
|
49
50
|
rank: _keys.CELL_DANGER_SECTION_RANK[_keys4.CLEAR_CELLS_ITEM.key]
|
|
50
51
|
}],
|
|
51
52
|
component: function component() {
|
|
52
|
-
return /*#__PURE__*/_react.default.createElement(_ClearCellsItem.ClearCellsItem,
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(_ClearCellsItem.ClearCellsItem, {
|
|
54
|
+
api: api
|
|
55
|
+
});
|
|
53
56
|
}
|
|
54
57
|
}];
|
|
55
58
|
};
|
|
@@ -10,6 +10,6 @@ var _getCellMenuComponents = require("../cell/getCellMenuComponents");
|
|
|
10
10
|
var _getColumnMenuComponents = require("../column/getColumnMenuComponents");
|
|
11
11
|
var _getRowMenuComponents = require("../row/getRowMenuComponents");
|
|
12
12
|
var _getSharedItems = require("./getSharedItems");
|
|
13
|
-
var getTableMenuComponents = exports.getTableMenuComponents = function getTableMenuComponents() {
|
|
14
|
-
return [].concat((0, _toConsumableArray2.default)((0, _getRowMenuComponents.getRowMenuComponents)()), (0, _toConsumableArray2.default)((0, _getColumnMenuComponents.getColumnMenuComponents)()), (0, _toConsumableArray2.default)((0, _getCellMenuComponents.getCellMenuComponents)()), (0, _toConsumableArray2.default)((0, _getSharedItems.getSharedItems)()));
|
|
13
|
+
var getTableMenuComponents = exports.getTableMenuComponents = function getTableMenuComponents(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
|
};
|
|
@@ -7,14 +7,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.ClearCellsItem = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactIntl = require("react-intl");
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
11
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
11
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
12
14
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
+
var _commandsWithAnalytics = require("../../../../pm-plugins/commands/commands-with-analytics");
|
|
16
|
+
var _pluginFactory = require("../../../../pm-plugins/plugin-factory");
|
|
17
|
+
var _TableMenuContext = require("../TableMenuContext");
|
|
18
|
+
var ClearCellsItem = exports.ClearCellsItem = function ClearCellsItem(_ref) {
|
|
19
|
+
var _tableMenuContext$sel, _tableMenuContext$sel2, _tooltip;
|
|
20
|
+
var api = _ref.api;
|
|
21
|
+
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
22
|
+
editorView = _useEditorToolbar.editorView;
|
|
23
|
+
var tableMenuContext = (0, _TableMenuContext.useTableMenuContext)();
|
|
15
24
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
16
25
|
formatMessage = _useIntl.formatMessage;
|
|
26
|
+
var selectedCellCount = Math.max((_tableMenuContext$sel = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedColumnCount) !== null && _tableMenuContext$sel !== void 0 ? _tableMenuContext$sel : 1, (_tableMenuContext$sel2 = tableMenuContext === null || tableMenuContext === void 0 ? void 0 : tableMenuContext.selectedRowCount) !== null && _tableMenuContext$sel2 !== void 0 ? _tableMenuContext$sel2 : 1);
|
|
27
|
+
var handleClick = function handleClick() {
|
|
28
|
+
var _api$analytics;
|
|
29
|
+
if (!editorView) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
33
|
+
targetCellPosition = _getPluginState.targetCellPosition;
|
|
34
|
+
(0, _commandsWithAnalytics.emptyMultipleCellsWithAnalytics)(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, targetCellPosition)(editorView.state, editorView.dispatch);
|
|
35
|
+
};
|
|
17
36
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
37
|
+
onClick: handleClick,
|
|
18
38
|
elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.CrossIcon, {
|
|
19
39
|
color: "currentColor",
|
|
20
40
|
label: "",
|
|
@@ -24,6 +44,6 @@ var ClearCellsItem = exports.ClearCellsItem = function ClearCellsItem() {
|
|
|
24
44
|
shortcut: (_tooltip = (0, _keymaps.tooltip)(_keymaps.backspace)) !== null && _tooltip !== void 0 ? _tooltip : ''
|
|
25
45
|
})
|
|
26
46
|
}, formatMessage(_messages.tableMessages.clearCells, {
|
|
27
|
-
0:
|
|
47
|
+
0: selectedCellCount
|
|
28
48
|
}));
|
|
29
49
|
};
|
|
@@ -82,7 +82,9 @@ const tablePlugin = ({
|
|
|
82
82
|
!(options !== null && options !== void 0 && options.isChromelessEditor) && !(options !== null && options !== void 0 && options.isCommentEditor) && (options === null || options === void 0 ? void 0 : (_options$getEditorFea2 = options.getEditorFeatureFlags) === null || _options$getEditorFea2 === void 0 ? void 0 : _options$getEditorFea2.call(options).tableSelector) && editorExperiment('platform_editor_controls', 'variant1');
|
|
83
83
|
if (expValEquals('platform_editor_table_menu_updates', 'isEnabled', true)) {
|
|
84
84
|
var _api$uiControlRegistr;
|
|
85
|
-
api === null || api === void 0 ? void 0 : (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.register(getTableMenuComponents(
|
|
85
|
+
api === null || api === void 0 ? void 0 : (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.register(getTableMenuComponents({
|
|
86
|
+
api
|
|
87
|
+
}));
|
|
86
88
|
}
|
|
87
89
|
return {
|
|
88
90
|
name: 'table',
|
|
@@ -110,6 +112,10 @@ const tablePlugin = ({
|
|
|
110
112
|
wasMaxWidthModeEnabled: !!(options !== null && options !== void 0 && options.wasMaxWidthEnabled),
|
|
111
113
|
isHeaderRowEnabled: tablePluginState.isHeaderRowEnabled,
|
|
112
114
|
isHeaderColumnEnabled: tablePluginState.isHeaderColumnEnabled,
|
|
115
|
+
isNumberColumnEnabled: tablePluginState.isNumberColumnEnabled,
|
|
116
|
+
isCommentEditor: tablePluginState.isCommentEditor,
|
|
117
|
+
isTableScalingEnabled: tablePluginState.isTableScalingEnabled,
|
|
118
|
+
isTableFixedColumnWidthsOptionEnabled,
|
|
113
119
|
ordering: tablePluginState.ordering,
|
|
114
120
|
isResizing: !!(tableResizingPluginState !== null && tableResizingPluginState !== void 0 && tableResizingPluginState.dragging || tableWidthResizingPluginState !== null && tableWidthResizingPluginState !== void 0 && tableWidthResizingPluginState.resizing),
|
|
115
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: "",
|