mirror of
https://github.com/fmhy/edit.git
synced 2026-02-19 09:41:17 +11:00
Show Copied text on copy
This commit is contained in:
parent
8b2ae07c58
commit
3a71e8f164
1 changed files with 3 additions and 4 deletions
|
|
@ -17,10 +17,9 @@ export function copyableCodePlugin(md: MarkdownRenderer) {
|
|||
}
|
||||
const token = tokens[idx];
|
||||
const content = token.content;
|
||||
const buttonHTML = `<button class='base64' onclick="navigator.clipboard.writeText('${decode(
|
||||
content,
|
||||
)}')"><code>${content}</code></button>`;
|
||||
|
||||
return buttonHTML;
|
||||
return `<button class='base64' onclick="(function(btn){ const codeEl = btn.querySelector('code'); navigator.clipboard.writeText('${decode(
|
||||
content,
|
||||
)}').then(() => { const originalText = codeEl.textContent; codeEl.textContent = 'Copied'; setTimeout(() => codeEl.textContent = originalText, 3000); }).catch(console.error); })(this)"><code>${content}</code></button>`;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue