@atlaskit/editor-plugin-list
Version:
List plugin for @atlaskit/editor-core
36 lines (35 loc) • 1.24 kB
JavaScript
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
import { createPlugin } from '@atlaskit/prosemirror-input-rules';
import { createRuleForListType } from './create-list-input-rule';
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({
// 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
expression: /^\s*([\*\-\u2022]) $/,
listType: bulletList,
editorAnalyticsApi: editorAnalyticsApi
}));
}
// Ignored via go/ees005
// eslint-disable-next-line require-unicode-regexp
var expression = /((^[1-9]{1}[0-9]{0,2})|^(0))[\.\)] $/;
if (orderedList) {
rules.push(createRuleForListType({
expression: expression,
listType: orderedList,
editorAnalyticsApi: editorAnalyticsApi
}));
}
if (rules.length !== 0) {
return new SafePlugin(createPlugin('lists', rules));
}
return;
}