From 495633d1128a5422f96931c9ee33b286f1b8fdff Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni <6173598+dpschen@users.noreply.github.com> Date: Wed, 2 Jul 2025 17:50:40 +0200 Subject: [PATCH] fix(editor): prevent links from extending after space (#1059) --- frontend/src/components/input/editor/TipTap.vue | 11 ++++++++--- .../components/input/editor/stopLinkOnSpace.ts | 16 ---------------- 2 files changed, 8 insertions(+), 19 deletions(-) delete mode 100644 frontend/src/components/input/editor/stopLinkOnSpace.ts diff --git a/frontend/src/components/input/editor/TipTap.vue b/frontend/src/components/input/editor/TipTap.vue index a8e6a4acd..c1b0e1040 100644 --- a/frontend/src/components/input/editor/TipTap.vue +++ b/frontend/src/components/input/editor/TipTap.vue @@ -182,7 +182,6 @@ import XButton from '@/components/input/Button.vue' import {isEditorContentEmpty} from '@/helpers/editorContentEmpty' import inputPrompt from '@/helpers/inputPrompt' import {setLinkInEditor} from '@/components/input/editor/setLinkInEditor' -import StopLinkOnSpace from './stopLinkOnSpace' const props = withDefaults(defineProps<{ modelValue: string, @@ -296,6 +295,13 @@ const CustomImage = Image.extend({ }, }) +// prevent links from extending after space +const NonInclusiveLink = Link.extend({ + inclusive() { + return false + }, +}) + type Mode = 'edit' | 'preview' const internalMode = ref('preview') @@ -421,7 +427,7 @@ const extensions : Extensions = [ }), Typography, Underline, - Link.configure({ + NonInclusiveLink.configure({ openOnClick: false, validate: (href: string) => (new RegExp( `^(https?|${additionalLinkProtocols.join('|')}):\\/\\/`, @@ -473,7 +479,6 @@ const extensions : Extensions = [ }), PasteHandler, - StopLinkOnSpace, ] // Add a custom extension for the Escape key diff --git a/frontend/src/components/input/editor/stopLinkOnSpace.ts b/frontend/src/components/input/editor/stopLinkOnSpace.ts deleted file mode 100644 index 12c4e9bfa..000000000 --- a/frontend/src/components/input/editor/stopLinkOnSpace.ts +++ /dev/null @@ -1,16 +0,0 @@ -import {Extension} from '@tiptap/core' - -export default Extension.create({ - name: 'stopLinkOnSpace', - - addKeyboardShortcuts() { - return { - Space: ({editor}) => { - if (editor.isActive('link')) { - editor.commands.unsetLink() - } - return false - }, - } - }, -})