UNPKG

@atlaskit/editor-plugin-list

Version:

List plugin for @atlaskit/editor-core

38 lines (36 loc) 1.29 kB
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin'; import { createPlugin } from '@atlaskit/prosemirror-input-rules'; import { createRuleForListType } from './create-list-input-rule'; // Using UTF instead of • character // because of issue where product converted the // character into an escaped version. // Ignored via go/ees005 // eslint-disable-next-line require-unicode-regexp var BULLET_LIST_EXPRESSION = /^\s*([\*\-\u2022]) $/; // Ignored via go/ees005 // eslint-disable-next-line require-unicode-regexp var ORDERED_LIST_EXPRESSION = /((^[1-9]{1}[0-9]{0,2})|^(0))[\.\)] $/; export default function inputRulePlugin(schema, editorAnalyticsApi) { var _schema$nodes = schema.nodes, bulletList = _schema$nodes.bulletList, orderedList = _schema$nodes.orderedList; var rules = []; if (bulletList) { rules.push(createRuleForListType({ expression: BULLET_LIST_EXPRESSION, listType: bulletList, editorAnalyticsApi: editorAnalyticsApi })); } if (orderedList) { rules.push(createRuleForListType({ expression: ORDERED_LIST_EXPRESSION, listType: orderedList, editorAnalyticsApi: editorAnalyticsApi })); } if (rules.length !== 0) { return new SafePlugin(createPlugin('lists', rules)); } return; }