inputrule for horizonal-line

This commit is contained in:
Chrissi2812
2019-01-31 16:08:14 +01:00
parent 8d44a4c6fc
commit e27d65390b
3 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import { InputRule } from 'prosemirror-inputrules'
export default function (regexp, type, getAttrs) {
return new InputRule(regexp, (state, match, start, end) => {
const attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs
const { tr } = state
if (match[0]) {
tr.replaceWith(start - 1, end, type.create(attrs))
}
return tr
})
}