From 619e910f69e60f3648702d18f96b5c63337f8f48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 26 Apr 2023 17:41:02 -0400 Subject: [PATCH] fix: only add copy button to multiline codeblocks --- public/src/client/topic.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/src/client/topic.js b/public/src/client/topic.js index 4e68fd004d..37dec50e10 100644 --- a/public/src/client/topic.js +++ b/public/src/client/topic.js @@ -231,9 +231,10 @@ define('forum/topic', [ }); function addCopyCodeButton() { - const codeBlocks = $('[component="topic"] [component="post/content"] code:not([data-button-added])'); + let codeBlocks = $('[component="topic"] [component="post/content"] code:not([data-button-added])'); + codeBlocks = codeBlocks.filter((i, el) => $(el).text().includes('\n')); const container = $('
'); - const buttonDiv = $(''); + const buttonDiv = $(''); codeBlocks.parent().wrap(container).parent().append(buttonDiv); codeBlocks.parent().parent().find('[component="copy/code/btn"]').translateAttr('title', '[[topic:copy-code]]'); codeBlocks.attr('data-button-added', 1);