clipboard-copy-element icon indicating copy to clipboard operation
clipboard-copy-element copied to clipboard

Feature Request - Not Copying the "$" or "#" in the beginning

Open osalbahr opened this issue 2 years ago • 1 comments

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.

osalbahr avatar Mar 26 '23 21:03 osalbahr

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

naiyerasif avatar Jun 22 '24 16:06 naiyerasif