From 25a8c7ea80497d98c3555df3abec17c8b62a6ffc Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 12 Aug 2024 11:42:43 +0200 Subject: [PATCH] feat(editor): support custom protocol for links Resolves https://github.com/go-vikunja/vikunja/issues/306 (cherry picked from commit e2a87036e070305291fd7ac1cfc9fe02c847b697) --- frontend/src/components/input/editor/TipTap.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/input/editor/TipTap.vue b/frontend/src/components/input/editor/TipTap.vue index 360c9028d..d5ef4e181 100644 --- a/frontend/src/components/input/editor/TipTap.vue +++ b/frontend/src/components/input/editor/TipTap.vue @@ -325,6 +325,13 @@ watch( }, ) +const additionalLinkProtocols = [ + 'ftp', + 'git', + 'obsidian', + 'notion', +] + const extensions : Extensions = [ // Starterkit: Blockquote, @@ -379,7 +386,11 @@ const extensions : Extensions = [ Underline, Link.configure({ openOnClick: false, - validate: (href: string) => /^https?:\/\//.test(href), + validate: (href: string) => (new RegExp( + `^(https?|${additionalLinkProtocols.join('|')}):\\/\\/`, + 'i', + )).test(href), + protocols: additionalLinkProtocols, }), Table.configure({ resizable: true,