fix link paste rule

This commit is contained in:
Philipp Kühn
2020-09-24 23:42:04 +02:00
parent 7a1c33242d
commit 40b0467650
2 changed files with 9 additions and 8 deletions

View File

@@ -16,7 +16,7 @@ declare module '@tiptap/core/src/Editor' {
}
}
export const pasteRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/gi
export const pasteRegex = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%_+.~#?&//=]*)/gi
export default new Mark<LinkOptions>()
.name('link')
@@ -55,7 +55,7 @@ export default new Mark<LinkOptions>()
},
}))
.pasteRules(({ type }) => [
markPasteRule(pasteRegex, type),
markPasteRule(pasteRegex, type, (url: string) => ({ href: url })),
])
.plugins(({ options }) => {
if (!options.openOnClick) {