mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-04 14:46:57 -05:00
5791a73e75
None of the frontend js/ts files was touched besides these two commands
(edit: no longer true, I touched one file in
61105d0618
because of a deprecation that was not showing before the rename).
`tsc` currently reports 778 errors, so I have disabled it in CI as
planned.
Everything appears to work fine.
22 lines
646 B
TypeScript
22 lines
646 B
TypeScript
import {svg} from '../svg.ts';
|
|
|
|
export function makeCodeCopyButton() {
|
|
const button = document.createElement('button');
|
|
button.classList.add('code-copy', 'ui', 'button');
|
|
button.innerHTML = svg('octicon-copy');
|
|
return button;
|
|
}
|
|
|
|
export function renderCodeCopy() {
|
|
const els = document.querySelectorAll('.markup .code-block code');
|
|
if (!els.length) return;
|
|
|
|
for (const el of els) {
|
|
if (!el.textContent) continue;
|
|
const btn = makeCodeCopyButton();
|
|
// remove final trailing newline introduced during HTML rendering
|
|
btn.setAttribute('data-clipboard-text', el.textContent.replace(/\r?\n$/, ''));
|
|
el.after(btn);
|
|
}
|
|
}
|