diff options
Diffstat (limited to 'web_src/js/markup/codecopy.js')
-rw-r--r-- | web_src/js/markup/codecopy.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/web_src/js/markup/codecopy.js b/web_src/js/markup/codecopy.js new file mode 100644 index 0000000000..2aa7070c72 --- /dev/null +++ b/web_src/js/markup/codecopy.js @@ -0,0 +1,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); + } +} |