Project

General

Profile

Actions

Patch #42697

open

Restrict copy button scope to .wiki pre tags

Added by Mizuki ISHIKAWA about 13 hours ago. Updated about 8 hours ago.

Status:
New
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>

No data to display

Actions

Also available in: Atom PDF