UNPKG

@atlaskit/editor-plugin-list

Version:

List plugin for @atlaskit/editor-core

45 lines • 1.88 kB
import React from 'react'; import { toggleBulletList, toggleOrderedList, tooltip } from '@atlaskit/editor-common/keymaps'; import { listMessages as messages } from '@atlaskit/editor-common/messages'; import { createQuickInsertMatcher } from '@atlaskit/editor-common/quick-insert/create-quick-insert-matcher'; import { ORDERED_LIST_MENU_ITEM, TEXT_FORMATTING_SECTION, UNORDERED_LIST_MENU_ITEM } from '@atlaskit/editor-common/quick-insert/keys'; import { TEXT_FORMATTING_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank'; import { ListQuickInsertMenuItem } from './ListQuickInsertMenuItem'; export var getListQuickInsertComponents = function getListQuickInsertComponents(_ref) { var api = _ref.api; return [{ item: UNORDERED_LIST_MENU_ITEM, type: 'unordered' }, { item: ORDERED_LIST_MENU_ITEM, type: 'ordered' }].map(function (_ref2) { var item = _ref2.item, type = _ref2.type; var isOrdered = type === 'ordered'; return { key: item.key, type: item.type, parents: [{ key: TEXT_FORMATTING_SECTION.key, type: TEXT_FORMATTING_SECTION.type, rank: TEXT_FORMATTING_SECTION_RANK[item.key] }], match: createQuickInsertMatcher(function (_ref3) { var formatMessage = _ref3.formatMessage; return { description: formatMessage(isOrdered ? messages.orderedListDescription : messages.unorderedListDescription), keywords: isOrdered ? ['ol', 'ordered'] : ['ul', 'unordered'], shortcut: tooltip(isOrdered ? toggleOrderedList : toggleBulletList), title: formatMessage(isOrdered ? messages.orderedList : messages.unorderedList) }; }), component: function component() { return /*#__PURE__*/React.createElement(ListQuickInsertMenuItem, { api: api, type: type }); } }; }); };