Skip to content
This repository has been archived by the owner on Nov 20, 2022. It is now read-only.

Unintended content has 'Copy' button #1

Open
tallguyjenks opened this issue Nov 9, 2020 · 4 comments
Open

Unintended content has 'Copy' button #1

tallguyjenks opened this issue Nov 9, 2020 · 4 comments

Comments

@tallguyjenks
Copy link

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?

image
image

@jdbrice
Copy link
Owner

jdbrice commented Nov 14, 2020

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

@NomarCub
Copy link

I have some code blocks without a language (eg. AdBlock filters). Is there no other distinction between the two types of code blocks?

@jdbrice
Copy link
Owner

jdbrice commented Nov 17, 2020

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.

tdharris pushed a commit to tdharris/obsidian-code-block-copy that referenced this issue Aug 11, 2021
Make the copy button nicer using an SVG icon
@Teraskull
Copy link

Teraskull commented Aug 17, 2022

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');

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants