fix: click triggering other events

This commit is contained in:
Michal Vavra 2023-08-27 01:42:44 +02:00
parent e3cca040c7
commit 8e9ef31e4f
No known key found for this signature in database
GPG key ID: 0EEADE8EAA583DDC

View file

@ -16,8 +16,9 @@ export default class CopyInlineCodePlugin extends Plugin {
const icon = createSpan({cls: "copy-to-clipboard-icon", text: "\xa0📋"})
const textToCopy = code.textContent
icon.onclick = () => {
icon.onclick = (event) => {
if(textToCopy) {
event.stopPropagation();
navigator.clipboard.writeText(textToCopy)
new Notice(`Copied '${textToCopy}' to clipboard!`);
}