docs: fix copy to clipboard functionality for code blocks
This commit is contained in:
Vendored
+7
-4
@@ -513,11 +513,14 @@
|
|||||||
|
|
||||||
// Determine what to copy
|
// Determine what to copy
|
||||||
var text;
|
var text;
|
||||||
var pre = btn.closest("pre");
|
var preWrap = btn.closest(".pre-wrap");
|
||||||
if (pre) {
|
if (preWrap) {
|
||||||
// Code block: copy the code element text (excludes button)
|
// Code block: copy the code element text (excludes button)
|
||||||
var code = pre.querySelector("code");
|
var pre = preWrap.querySelector("pre");
|
||||||
text = (code || pre).textContent;
|
if (pre) {
|
||||||
|
var code = pre.querySelector("code");
|
||||||
|
text = (code || pre).textContent;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Input field: copy value of the preceding input
|
// Input field: copy value of the preceding input
|
||||||
var input = btn.previousElementSibling;
|
var input = btn.previousElementSibling;
|
||||||
|
|||||||
Reference in New Issue
Block a user