From f487f81f523c54fd17d235752161ce70fba80591 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 10 Jun 2025 21:09:14 +0200 Subject: [PATCH] fix(editor): pasted link capturing trailing text (#912) --- frontend/src/components/input/editor/TipTap.vue | 12 +++++++----- .../components/input/editor/stopLinkOnSpace.ts | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) create 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 7f36fb75b..b343a1be6 100644 --- a/frontend/src/components/input/editor/TipTap.vue +++ b/frontend/src/components/input/editor/TipTap.vue @@ -182,6 +182,7 @@ 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, @@ -464,11 +465,12 @@ const extensions : Extensions = [ }, }), - Commands.configure({ - suggestion: suggestionSetup(t), - }), - - PasteHandler, + Commands.configure({ + suggestion: suggestionSetup(t), + }), + + 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 new file mode 100644 index 000000000..ea2608511 --- /dev/null +++ b/frontend/src/components/input/editor/stopLinkOnSpace.ts @@ -0,0 +1,16 @@ +import {Extension} from '@tiptap/core' + +export default Extension.create({ + name: 'stopLinkOnSpace', + + addKeyboardShortcuts() { + return { + Space: ({editor}) => { + if (editor.isActive('link')) { + editor.commands.unsetLink() + } + return false + }, + } + }, +})