Skip to content

Commit

Permalink
fix(extension-link): 🐛 fix auto link validation not working on paste
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbch committed May 16, 2022
1 parent ec41540 commit 3a3eb53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/extension-link/src/helpers/pasteHandler.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
7 changes: 7 additions & 0 deletions packages/extension-link/src/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3a3eb53

Please sign in to comment.