Project

General

Profile

Actions

Patch #42697

closed

Restrict copy button scope to .wiki pre tags

Added by Mizuki ISHIKAWA 23 days ago. Updated 21 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
UI
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Currently, the copy button for code blocks shows up not only for pre tags written in commonmark and Textile, but also in unexpected places like the information screen.
To avoid this in the future, I will limit the copy button to pre tags under the .wiki section.

diff --git a/app/assets/javascripts/application-legacy.js b/app/assets/javascripts/application-legacy.js
index 286e3e2e6..deaaa66b6 100644
--- a/app/assets/javascripts/application-legacy.js
+++ b/app/assets/javascripts/application-legacy.js
@@ -679,7 +679,7 @@ function copyDataClipboardTextToClipboard(target) {
 }

 function setupCopyButtonsToPreElements() {
-  document.querySelectorAll('pre:not(.pre-wrapper pre)').forEach((pre) => {
+  document.querySelectorAll('.wiki pre:not(.pre-wrapper pre)').forEach((pre) => {
     // Wrap the <pre> element with a container and add a copy button
     const wrapper = document.createElement("div");
     wrapper.classList.add("pre-wrapper");

</code>

Related issues

Related to Redmine - Feature #29214: Button to copy `pre` code block content to the clipboardClosedGo MAEDA

Actions
Actions

Also available in: Atom PDF