add basic inputrules and pasterules

This commit is contained in:
Philipp Kühn
2020-04-02 08:53:59 +02:00
parent b85df2b4c1
commit 28d5ae094b
10 changed files with 209 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
import { Mark } from '@tiptap/core'
import { Mark, markInputRule, markPasteRule } from '@tiptap/core'
import { toggleMark } from 'prosemirror-commands'
import { MarkSpec } from 'prosemirror-model'
@@ -36,4 +36,18 @@ export default class Italic extends Mark {
}
}
inputRules() {
return [
markInputRule(/(?:^|[^_])(_([^_]+)_)$/, this.schemaType),
// markInputRule(/(?:^|[^*])(\*([^*]+)\*)$/, this.schemaType),
]
}
pasteRules() {
return [
markPasteRule(/_([^_]+)_/g, this.schemaType),
// markPasteRule(/\*([^*]+)\*/g, this.schemaType),
]
}
}