Don't unnecessarily markdown-ify links pasted into markdown editor (#3958)

This commit is contained in:
Prospector 2025-07-09 16:11:17 -07:00 committed by GitHub
parent cff3c72f94
commit 5d17663040
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -397,10 +397,11 @@ onMounted(() => {
const selection = view.state.selection.main const selection = view.state.selection.main
const selectionText = view.state.doc.sliceString(selection.from, selection.to) const selectionText = view.state.doc.sliceString(selection.from, selection.to)
const linkText = selectionText ? selectionText : url if (selectionText) {
const linkMarkdown = `[${linkText}](${url})` const linkMarkdown = `[${selectionText}](${url})`
return markdownCommands.replaceSelection(view, linkMarkdown) return markdownCommands.replaceSelection(view, linkMarkdown)
} }
}
// Check if the length of the document is greater than the max length. If it is, prevent the paste. // Check if the length of the document is greater than the max length. If it is, prevent the paste.
if (props.maxLength && view.state.doc.length > props.maxLength) { if (props.maxLength && view.state.doc.length > props.maxLength) {