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 - }, - } - }, -})