fix(editor): prevent links from extending after space (#1059)

This commit is contained in:
Dominik Pschenitschni 2025-07-02 17:50:40 +02:00 committed by GitHub
parent ef80fa77b4
commit 495633d112
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 19 deletions

View File

@ -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<Mode>('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

View File

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