0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-24 10:44:32 -04:00

Update web_src/js/markup/codecopy.ts

This commit is contained in:
wxiaoguang 2025-04-17 07:07:37 +08:00 committed by GitHub
parent 0a4a29a3c4
commit 4188181475
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,6 +15,7 @@ export function initMarkupCodeCopy(elMarkup: HTMLElement): void {
const btn = makeCodeCopyButton();
// remove final trailing newline introduced during HTML rendering
btn.setAttribute('data-clipboard-text', el.textContent.replace(/\r?\n$/, ''));
// we only want to use `.code-block-container` if it exists, no matter `.code-block` exists or not.
const btnContainer = el.closest('.code-block-container') ?? el.closest('.code-block');
btnContainer.append(btn);
});