fix(extension-link): 🐛 fix auto link validation not working on paste

This commit is contained in:
Dominik Biedebach
2022-05-16 11:01:37 +02:00
committed by Dominik
parent ec4154000d
commit 3a3eb5311c
2 changed files with 11 additions and 3 deletions

View File

@@ -1,7 +1,8 @@
import { Editor } from '@tiptap/core'
import { Plugin, PluginKey } from 'prosemirror-state'
import { MarkType } from 'prosemirror-model'
import { find } from 'linkifyjs'
import { MarkType } from 'prosemirror-model'
import { Plugin, PluginKey } from 'prosemirror-state'
import { Editor } from '@tiptap/core'
type PasteHandlerOptions = {
editor: Editor,

View File

@@ -132,6 +132,13 @@ export const Link = Mark.create<LinkOptions>({
return [
markPasteRule({
find: text => find(text)
.filter(link => {
if (this.options.validate) {
return this.options.validate(link.value)
}
return true
})
.filter(link => link.isLink)
.map(link => ({
text: link.value,