@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
168 lines • 5.34 kB
JavaScript
import React from 'react';
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
import { AddRowAboveItem } from './items/AddRowAboveItem';
import { AddRowBelowItem } from './items/AddRowBelowItem';
import { DeleteRowItem } from './items/DeleteRowItem';
import { HeaderRowToggleItem } from './items/HeaderRowToggleItem';
import { MoveRowDownItem } from './items/MoveRowDownItem';
import { MoveRowUpItem } from './items/MoveRowUpItem';
import { NumberedRowsToggleItem } from './items/NumberedRowsToggleItem';
import { ROW_MENU, ROW_TOGGLE_SECTION, ROW_BACKGROUND_SECTION, ROW_ADD_SECTION, ROW_DANGER_SECTION, ROW_MENU_SECTION_RANK, HEADER_ROW_TOGGLE_ITEM, NUMBERED_ROWS_TOGGLE_ITEM, ADD_ROW_ABOVE_ITEM, ADD_ROW_BELOW_ITEM, MOVE_ROW_UP_ITEM, MOVE_ROW_DOWN_ITEM, DELETE_ROW_ITEM, ROW_TOGGLE_SECTION_RANK, ROW_ADD_SECTION_RANK, ROW_DANGER_SECTION_RANK } from './keys';
export var getRowMenuComponents = function getRowMenuComponents(_ref) {
var api = _ref.api;
return [
// --- Menu surface ---
{
type: ROW_MENU.type,
key: ROW_MENU.key
},
// --- Toggle section (Header row, Numbered rows) ---
{
type: ROW_TOGGLE_SECTION.type,
key: ROW_TOGGLE_SECTION.key,
parents: [{
type: ROW_MENU.type,
key: ROW_MENU.key,
rank: ROW_MENU_SECTION_RANK[ROW_TOGGLE_SECTION.key]
}],
component: function component(props) {
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, props.children);
}
}, {
type: HEADER_ROW_TOGGLE_ITEM.type,
key: HEADER_ROW_TOGGLE_ITEM.key,
parents: [{
type: ROW_TOGGLE_SECTION.type,
key: ROW_TOGGLE_SECTION.key,
rank: ROW_TOGGLE_SECTION_RANK[HEADER_ROW_TOGGLE_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(HeaderRowToggleItem, {
api: api
});
}
}, {
type: NUMBERED_ROWS_TOGGLE_ITEM.type,
key: NUMBERED_ROWS_TOGGLE_ITEM.key,
parents: [{
type: ROW_TOGGLE_SECTION.type,
key: ROW_TOGGLE_SECTION.key,
rank: ROW_TOGGLE_SECTION_RANK[NUMBERED_ROWS_TOGGLE_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(NumberedRowsToggleItem, {
api: api
});
}
},
// --- Background color section ---
{
type: ROW_BACKGROUND_SECTION.type,
key: ROW_BACKGROUND_SECTION.key,
parents: [{
type: ROW_MENU.type,
key: ROW_MENU.key,
rank: ROW_MENU_SECTION_RANK[ROW_BACKGROUND_SECTION.key]
}],
component: function component(props) {
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
hasSeparator: true
}, props.children);
}
},
// --- Add / Move section ---
{
type: ROW_ADD_SECTION.type,
key: ROW_ADD_SECTION.key,
parents: [{
type: ROW_MENU.type,
key: ROW_MENU.key,
rank: ROW_MENU_SECTION_RANK[ROW_ADD_SECTION.key]
}],
component: function component(props) {
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
hasSeparator: true
}, props.children);
}
}, {
type: ADD_ROW_ABOVE_ITEM.type,
key: ADD_ROW_ABOVE_ITEM.key,
parents: [{
type: ROW_ADD_SECTION.type,
key: ROW_ADD_SECTION.key,
rank: ROW_ADD_SECTION_RANK[ADD_ROW_ABOVE_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(AddRowAboveItem, {
api: api
});
}
}, {
type: ADD_ROW_BELOW_ITEM.type,
key: ADD_ROW_BELOW_ITEM.key,
parents: [{
type: ROW_ADD_SECTION.type,
key: ROW_ADD_SECTION.key,
rank: ROW_ADD_SECTION_RANK[ADD_ROW_BELOW_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(AddRowBelowItem, {
api: api
});
}
}, {
type: MOVE_ROW_UP_ITEM.type,
key: MOVE_ROW_UP_ITEM.key,
parents: [{
type: ROW_ADD_SECTION.type,
key: ROW_ADD_SECTION.key,
rank: ROW_ADD_SECTION_RANK[MOVE_ROW_UP_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(MoveRowUpItem, {
api: api
});
}
}, {
type: MOVE_ROW_DOWN_ITEM.type,
key: MOVE_ROW_DOWN_ITEM.key,
parents: [{
type: ROW_ADD_SECTION.type,
key: ROW_ADD_SECTION.key,
rank: ROW_ADD_SECTION_RANK[MOVE_ROW_DOWN_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(MoveRowDownItem, {
api: api
});
}
},
// --- Danger section (Clear cells, Delete row) ---
{
type: ROW_DANGER_SECTION.type,
key: ROW_DANGER_SECTION.key,
parents: [{
type: ROW_MENU.type,
key: ROW_MENU.key,
rank: ROW_MENU_SECTION_RANK[ROW_DANGER_SECTION.key]
}],
component: function component(props) {
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
hasSeparator: true
}, props.children);
}
}, {
type: DELETE_ROW_ITEM.type,
key: DELETE_ROW_ITEM.key,
parents: [{
type: ROW_DANGER_SECTION.type,
key: ROW_DANGER_SECTION.key,
rank: ROW_DANGER_SECTION_RANK[DELETE_ROW_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(DeleteRowItem, {
api: api
});
}
}];
};