move commands again

This commit is contained in:
Philipp Kühn
2020-11-04 22:38:52 +01:00
parent ca0c3188f3
commit 6f3db0970f
59 changed files with 761 additions and 1066 deletions

View File

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