Skip to content

Commit 22807f5

Browse files
authored
fix: docs/copy-code: exclude button text from clipboard (#9138)
1 parent d475bad commit 22807f5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

docs/src/code.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ function addCodeCopyButtons() {
117117

118118
function copyCodeFor(codeElement) {
119119
return () => {
120-
navigator.clipboard.writeText(codeElement.textContent);
120+
const clone = codeElement.cloneNode(true);
121+
clone.querySelectorAll('.btnCopyCode').forEach(btn => btn.remove());
122+
navigator.clipboard.writeText(clone.textContent);
121123

122124
const success = addButton('✅', codeElement);
123125
success.disabled = true;
@@ -135,6 +137,7 @@ function addCodeCopyButtons() {
135137
btn.style.top = '11.5px';
136138
btn.style.right = '15px';
137139
btn.textContent = txt;
140+
btn.classList.add('btnCopyCode');
138141

139142
parent.appendChild(btn);
140143

0 commit comments

Comments
 (0)