mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-26 11:04:27 -04:00
첫번째 코드블럭에만 copy-button 추가되는 현상 수정
This commit is contained in:
parent
5ba3a881c0
commit
1be4b3e138
@ -8,11 +8,13 @@ export function makeCodeCopyButton(): HTMLButtonElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function initMarkupCodeCopy(elMarkup: HTMLElement): void {
|
export function initMarkupCodeCopy(elMarkup: HTMLElement): void {
|
||||||
const el = elMarkup.querySelector('.code-wrapper'); // .markup .code-block code
|
const els = elMarkup.querySelectorAll('.code-wrapper'); // .markup .code-block code
|
||||||
if (!el || !el.textContent) return;
|
|
||||||
|
|
||||||
const btn = makeCodeCopyButton();
|
for (const el of els) {
|
||||||
// remove final trailing newline introduced during HTML rendering
|
if (!el || !el.textContent) return;
|
||||||
btn.setAttribute('data-clipboard-text', el.textContent.replace(/\r?\n$/, ''));
|
const btn = makeCodeCopyButton();
|
||||||
el.append(btn);
|
// remove final trailing newline introduced during HTML rendering
|
||||||
|
btn.setAttribute('data-clipboard-text', el.textContent.replace(/\r?\n$/, ''));
|
||||||
|
el.append(btn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user