mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-24 10:44:32 -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 {
|
||||
const el = elMarkup.querySelector('.code-wrapper'); // .markup .code-block code
|
||||
if (!el || !el.textContent) return;
|
||||
const els = elMarkup.querySelectorAll('.code-wrapper'); // .markup .code-block code
|
||||
|
||||
const btn = makeCodeCopyButton();
|
||||
// remove final trailing newline introduced during HTML rendering
|
||||
btn.setAttribute('data-clipboard-text', el.textContent.replace(/\r?\n$/, ''));
|
||||
el.append(btn);
|
||||
for (const el of els) {
|
||||
if (!el || !el.textContent) return;
|
||||
const btn = makeCodeCopyButton();
|
||||
// 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