clipboard-copy-element
clipboard-copy-element copied to clipboard
Feature Request - Not Copying the "$" or "#" in the beginning
Is there a way to copy element text content or input values to the clipboard, without the leading dollar sign "$" but still keep it displayed in the README preview?
For example, in README.md, copying the first command copies the "$" in the beginning, i.e. $ npm install --save @github/clipboard-copy-element. However, that can cause some issues:
$ $ npm install --save @github/clipboard-copy-element
-bash: $: command not found
One solution is to have the command not include the "$". But its inclusion is conventional for "run as non-root" as opposed to prepending the command with "#" which indicates running the command as root.
I had a similar use case to exclude prompt characters (such as $). The way I solved this is to wrap those characters in a span with aria-hidden=true and exclude them from the copied text.
Here's the patch which tackles this: https://github.com/naiyerasif/site/blob/fc48785799bc40a061ca95aee77a8a8d5b2e81b0/src/modules/clipboard-copy/clipboard.js#L12