obsidian-code-block-copy
obsidian-code-block-copy copied to clipboard
Unintended content has 'Copy' button
Love the plugin, just noticed this though:
not inside a code fence, just indented with a tab and it is being treated as code, is the intended behavior?
Ah yes, this is because tabbing a paragraph in markdown treats it as a code block.
But I can make the copy button NOT show for blocks without a language. Will do that soon
I have some code blocks without a language (eg. AdBlock filters). Is there no other distinction between the two types of code blocks?
Thats right, a tabbed code block and a fenced code block are indistinguishable in the rendered view.
However, you can always add a language -> you could use adblock
for those blocks. Since it is an unrecognized language it doesnt effect the highlighting anyways.
So my plan is: add a settings toggle, to optionally hide copy on blocks without a language also, I am looking into an option to put the copy button above, instead of inside the block - this way it wont overlap with text.
A bit too late, but maybe this will help someone. If you just want to remove that "Copy" button, add the following to the main.js
plugin file right after var pre = codeBlock.parentNode;
:
// Remove "Copy" button
if (pre.children.length > 1 && pre.children[1].tagName === 'BUTTON') {
pre.children[1].remove();
}
Also, you can add the toast notification on copy, like the original button does, just add this inside the clipboard.writeText
event:
new Notice('copied to your clipboard');