fix(editor): pasted link capturing trailing text (#912)

This commit is contained in:
kolaente 2025-06-10 21:09:14 +02:00 committed by GitHub
parent b41665b6e4
commit f487f81f52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 5 deletions

View File

@ -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

View File

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