@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
146 lines • 5.37 kB
JavaScript
import React from 'react';
import { CELL_ACTION_SECTION, CELL_ADD_SECTION, CELL_DANGER_SECTION, CELL_ACTION_SECTION_RANK, CELL_ADD_SECTION_RANK, CELL_DANGER_SECTION_RANK } from '../cell/keys';
import { AddColumnRightItem } from '../column/items/AddColumnRightItem';
import { DeleteColumnItem } from '../column/items/DeleteColumnItem';
import { DistributeColumnsItem } from '../column/items/DistributeColumnsItem';
import { ADD_COLUMN_RIGHT_ITEM, COLUMN_ADD_SECTION, COLUMN_BACKGROUND_SECTION, COLUMN_DANGER_SECTION, COLUMN_ADD_SECTION_RANK, COLUMN_BACKGROUND_SECTION_RANK, COLUMN_DANGER_SECTION_RANK, DELETE_COLUMN_ITEM, DISTRIBUTE_COLUMNS_ITEM } from '../column/keys';
import { AddRowBelowItem } from '../row/items/AddRowBelowItem';
import { DeleteRowItem } from '../row/items/DeleteRowItem';
import { ADD_ROW_BELOW_ITEM, DELETE_ROW_ITEM, ROW_ADD_SECTION, ROW_BACKGROUND_SECTION, ROW_DANGER_SECTION, ROW_ADD_SECTION_RANK, ROW_BACKGROUND_SECTION_RANK, ROW_DANGER_SECTION_RANK } from '../row/keys';
import { BackgroundColorItem } from './items/BackgroundColorItem';
import { ClearCellsItem } from './items/ClearCellsItem';
import { BACKGROUND_COLOR_ITEM, CLEAR_CELLS_ITEM } from './keys';
export var getSharedItems = function getSharedItems(_ref) {
var api = _ref.api;
return [
// The add/delete items are registered here rather than in the row/column menu files,
// once with an additional cell parent, so they render inside the cell menu too.
{
type: BACKGROUND_COLOR_ITEM.type,
key: BACKGROUND_COLOR_ITEM.key,
parents: [{
type: ROW_BACKGROUND_SECTION.type,
key: ROW_BACKGROUND_SECTION.key,
rank: ROW_BACKGROUND_SECTION_RANK[BACKGROUND_COLOR_ITEM.key]
}, {
type: COLUMN_BACKGROUND_SECTION.type,
key: COLUMN_BACKGROUND_SECTION.key,
rank: COLUMN_BACKGROUND_SECTION_RANK[BACKGROUND_COLOR_ITEM.key]
}, {
type: CELL_ACTION_SECTION.type,
key: CELL_ACTION_SECTION.key,
rank: CELL_ACTION_SECTION_RANK[BACKGROUND_COLOR_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(BackgroundColorItem, {
api: api
});
}
}, {
type: ADD_COLUMN_RIGHT_ITEM.type,
key: ADD_COLUMN_RIGHT_ITEM.key,
parents: [{
type: COLUMN_ADD_SECTION.type,
key: COLUMN_ADD_SECTION.key,
rank: COLUMN_ADD_SECTION_RANK[ADD_COLUMN_RIGHT_ITEM.key]
}, {
type: CELL_ADD_SECTION.type,
key: CELL_ADD_SECTION.key,
rank: CELL_ADD_SECTION_RANK[ADD_COLUMN_RIGHT_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(AddColumnRightItem, {
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]
}, {
type: CELL_ADD_SECTION.type,
key: CELL_ADD_SECTION.key,
rank: CELL_ADD_SECTION_RANK[ADD_ROW_BELOW_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(AddRowBelowItem, {
api: api
});
}
}, {
type: DISTRIBUTE_COLUMNS_ITEM.type,
key: DISTRIBUTE_COLUMNS_ITEM.key,
parents: [{
type: COLUMN_ADD_SECTION.type,
key: COLUMN_ADD_SECTION.key,
rank: COLUMN_ADD_SECTION_RANK[DISTRIBUTE_COLUMNS_ITEM.key]
}, {
type: CELL_ADD_SECTION.type,
key: CELL_ADD_SECTION.key,
rank: CELL_ADD_SECTION_RANK[DISTRIBUTE_COLUMNS_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(DistributeColumnsItem, {
api: api
});
}
}, {
type: CLEAR_CELLS_ITEM.type,
key: CLEAR_CELLS_ITEM.key,
parents: [{
type: ROW_DANGER_SECTION.type,
key: ROW_DANGER_SECTION.key,
rank: ROW_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
}, {
type: COLUMN_DANGER_SECTION.type,
key: COLUMN_DANGER_SECTION.key,
rank: COLUMN_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
}, {
type: CELL_DANGER_SECTION.type,
key: CELL_DANGER_SECTION.key,
rank: CELL_DANGER_SECTION_RANK[CLEAR_CELLS_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(ClearCellsItem, {
api: api
});
}
}, {
type: DELETE_COLUMN_ITEM.type,
key: DELETE_COLUMN_ITEM.key,
parents: [{
type: COLUMN_DANGER_SECTION.type,
key: COLUMN_DANGER_SECTION.key,
rank: COLUMN_DANGER_SECTION_RANK[DELETE_COLUMN_ITEM.key]
}, {
type: CELL_DANGER_SECTION.type,
key: CELL_DANGER_SECTION.key,
rank: CELL_DANGER_SECTION_RANK[DELETE_COLUMN_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(DeleteColumnItem, {
api: api
});
}
}, {
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]
}, {
type: CELL_DANGER_SECTION.type,
key: CELL_DANGER_SECTION.key,
rank: CELL_DANGER_SECTION_RANK[DELETE_ROW_ITEM.key]
}],
component: function component() {
return /*#__PURE__*/React.createElement(DeleteRowItem, {
api: api
});
}
}];
};