Node.js based forum software built for the modern web
fix: closes #11806, fix code blocks
Barış Soner Uşaklı165b0f856581
diff --git a/install/package.json b/install/package.jsonindex 534e854001..bd53f322ca 100644--- a/install/package.json+++ b/install/package.json@@ -96,12 +96,12 @@"nodebb-plugin-dbsearch": "6.1.0","nodebb-plugin-emoji": "5.1.3","nodebb-plugin-emoji-android": "4.0.0",- "nodebb-plugin-markdown": "12.1.5",+ "nodebb-plugin-markdown": "12.1.6","nodebb-plugin-mentions": "4.3.0","nodebb-plugin-ntfy": "1.0.16","nodebb-plugin-spam-be-gone": "2.1.1","nodebb-rewards-essentials": "0.2.3",- "nodebb-theme-harmony": "1.1.4",+ "nodebb-theme-harmony": "1.1.5","nodebb-theme-lavender": "7.1.1","nodebb-theme-peace": "2.1.2","nodebb-theme-persona": "13.2.4",diff --git a/public/src/client/topic.js b/public/src/client/topic.jsindex 7a0b228efd..79235656dd 100644--- a/public/src/client/topic.js+++ b/public/src/client/topic.js@@ -242,6 +242,15 @@ define('forum/topic', [function scrollbarVisible(element) {return element.scrollHeight > element.clientHeight;}+ function offsetCodeBtn(codeEl) {+ if (!codeEl.length) { return; }+ if (!codeEl[0].scrollHeight) {+ return setTimeout(offsetCodeBtn, 100, codeEl);+ }+ if (scrollbarVisible(codeEl.get(0))) {+ codeEl.parent().parent().find('[component="copy/code/btn"]').css({ margin: '0.5rem 1.5rem 0 0' });+ }+ }let codeBlocks = $('[component="topic"] [component="post/content"] code:not([data-button-added])');codeBlocks = codeBlocks.filter((i, el) => $(el).text().includes('\n'));const container = $('<div class="hover-parent position-relative"></div>');@@ -250,9 +259,7 @@ define('forum/topic', [preEls.wrap(container).parent().append(buttonDiv);preEls.parent().find('[component="copy/code/btn"]').translateAttr('title', '[[topic:copy-code]]');preEls.each((index, el) => {- if (scrollbarVisible(el)) {- $(el).parent().find('[component="copy/code/btn"]').css({ margin: '0.5rem 1.5rem 0 0' });- }+ offsetCodeBtn($(el).find('code'));});codeBlocks.attr('data-button-added', 1);}