add paste rules

This commit is contained in:
Philipp Kühn
2018-11-26 11:11:39 +01:00
parent df402a66ad
commit d27b0deb6a
6 changed files with 97 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
import { Mark, Plugin, TextSelection } from 'tiptap'
import { updateMark, removeMark } from 'tiptap-commands'
import { updateMark, removeMark, wrappingPasteRule } from 'tiptap-commands'
import { getMarkRange } from 'tiptap-utils'
export default class Link extends Mark {
@@ -41,6 +41,16 @@ export default class Link extends Mark {
}
}
pasteRules({ type }) {
return [
wrappingPasteRule(
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g,
type,
url => ({ href: url }),
),
]
}
get plugins() {
return [
new Plugin({