compose: Do not paste formatted markdown when inside a code block.

We usually default to pasting formatted markdown (unless the Shift key
is used to paste plainly instead), but when we're inside a code block,
we always want to paste plainly.
This commit is contained in:
N-Shar-ma 2023-11-10 02:09:23 +05:30 committed by Tim Abbott
parent f5bcf5d608
commit 602d1d7323
1 changed files with 7 additions and 1 deletions

View File

@ -543,10 +543,16 @@ export function paste_handler(event) {
return;
}
// We do not paste formatted markdoown when inside a code block.
// Unlike Chrome, Firefox doesn't automatically paste plainly on using Ctrl+Shift+V,
// hence we need to handle it ourselves, by checking if shift key is pressed, and only
// if not, we proceed with the default formatted paste.
if (paste_html && !compose_ui.shift_pressed && page_params.development_environment) {
if (
!compose_ui.cursor_inside_code_block($textarea) &&
paste_html &&
!compose_ui.shift_pressed &&
page_params.development_environment
) {
event.preventDefault();
event.stopPropagation();
const text = paste_handler_converter(paste_html);