fix(extension-link): 🐛 fix auto link validation not working on paste
This commit is contained in:
committed by
Dominik
parent
ec4154000d
commit
3a3eb5311c
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user