UNPKG

@atlaskit/editor-plugin-list

Version:

List plugin for @atlaskit/editor-core

39 lines (38 loc) 1.15 kB
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) { const { nodes: { bulletList, orderedList } } = schema; const 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 })); } // Ignored via go/ees005 // eslint-disable-next-line require-unicode-regexp const expression = /((^[1-9]{1}[0-9]{0,2})|^(0))[\.\)] $/; if (orderedList) { rules.push(createRuleForListType({ expression, listType: orderedList, editorAnalyticsApi })); } if (rules.length !== 0) { return new SafePlugin(createPlugin('lists', rules)); } return; }