Merge branch 'master' into markdown-paste
This commit is contained in:
14
packages/tiptap-commands/src/commands/nodeInputRule.js
Normal file
14
packages/tiptap-commands/src/commands/nodeInputRule.js
Normal 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
|
||||
})
|
||||
}
|
||||
@@ -40,6 +40,7 @@ import {
|
||||
|
||||
import insertText from './commands/insertText'
|
||||
import markInputRule from './commands/markInputRule'
|
||||
import nodeInputRule from './commands/nodeInputRule'
|
||||
import pasteRule from './commands/pasteRule'
|
||||
import markPasteRule from './commands/markPasteRule'
|
||||
import removeMark from './commands/removeMark'
|
||||
@@ -93,6 +94,7 @@ export {
|
||||
insertText,
|
||||
markInputRule,
|
||||
markPasteRule,
|
||||
nodeInputRule,
|
||||
pasteRule,
|
||||
removeMark,
|
||||
replaceText,
|
||||
|
||||
Reference in New Issue
Block a user