blob: 2aa7070c72ded5c4b95473229de108651590e285 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import {svg} from '../svg.js';
export function renderCodeCopy() {
const els = document.querySelectorAll('.markup .code-block code');
if (!els.length) return;
const button = document.createElement('button');
button.classList.add('code-copy', 'ui', 'button');
button.innerHTML = svg('octicon-copy');
for (const el of els) {
const btn = button.cloneNode(true);
btn.setAttribute('data-clipboard-text', el.textContent);
el.after(btn);
}
}
|