remove verbal expressions

This commit is contained in:
Philipp Kühn
2020-09-09 18:47:47 +02:00
parent fab2fce671
commit ba744cf6d8
6 changed files with 38 additions and 110 deletions

View File

@@ -1,6 +1,4 @@
import { Node, CommandSpec } from '@tiptap/core'
import { NodeSpec } from 'prosemirror-model'
import VerEx from 'verbal-expressions'
import { Node } from '@tiptap/core'
import { textblockTypeInputRule } from 'prosemirror-inputrules'
type Level = 1 | 2 | 3 | 4 | 5 | 6
@@ -45,14 +43,7 @@ export default new Node<HeadingOptions>()
}))
.inputRules(({ options, type }) => {
return options.levels.map((level: Level) => {
const regex = VerEx()
.startOfLine()
.find('#')
.repeatPrevious(level)
.whitespace()
.endOfLine()
return textblockTypeInputRule(regex, type, { level })
return textblockTypeInputRule(new RegExp(`^(?:#){${level}}\s$/gm`), type, { level })
})
})
.create()