fix(editor): don't convert text that's pasted into a code block to markdown

Resolves https://community.vikunja.io/t/pasting-into-code-block-renders-markdown/4181
This commit is contained in:
kolaente 2025-11-26 23:27:33 +01:00
parent f7bdb996ca
commit 34575e4eb7
1 changed files with 7 additions and 1 deletions

View File

@ -373,12 +373,18 @@ const PasteHandler = Extension.create({
}
}
}
const text = event.clipboardData?.getData('text/plain') || ''
if (!text) {
return false
}
// Don't convert markdown when pasting inside a code block
const $from = view.state.selection.$from
if ($from.parent.type.name === 'codeBlock') {
return false
}
const hasMarkdownSyntax = new RegExp('[*`_\\[\\]#-]').test(text)
if (!hasMarkdownSyntax) {
return false