You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

codecopy.js 463B

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