Closed sugihjamin closed 2 years ago
This is a nice idea! One question in my mind: This makes sense for code blocks with a single line, but how do we deal with multi-line console blocks (which might also contain console output)?
Alternatively, maybe the global “copy” button should exclude the prompts when the console block has only one line. What do you think?
I did consider suggesting it only for one-liner, but found that to be too limiting. If you have a multi-line console block, copy-and-pasting all the multiple lines of commands to the console actually does run them serially, so it could work as intended.
If one assumes a console prompt in front of each command, maybe copy only the commands so recognized, skipping potential console outputs or comments?
That makes sense, I hadn't realized that there's value in copying all the commands alone. How about this: Only for console
code blocks, we display two buttons. One is the regular "copy entire block" button, but the other copies just the commands.
I'll prototype it tomorrow/over the weekend, and put up a PR + demo :)
It would be interesting to see what icons you come up with to distinguish the two cases.
Assuming you have control over mouse functions on the browser, an alternative could be that drag-to-select on console
select only the commands, leaving out the prompts, outputs, and comments. The clipboard-copy button can be left as is, to copy everything, and you don't need to add another button.
It would be interesting to see what icons you come up with to distinguish the two cases.
I just realized I don't have a good icon for this yet 😅
Another alternative: Is there ever a use-case for copying an entire console
block along with its outputs? What if we changed the "copy" button only for console
blocks into a "Copy all commands" button?
An alternative could be that drag-to-select on
console
select only the commands, leaving out the prompts, outputs, and comments.
~^ This is a nice idea too!~
An alternative could be that drag-to-select on console select only the commands, leaving out the prompts, outputs, and comments.
^ This is a nice idea too!
Actually, this isn't possible in any browser except Firefox — only Firefox support selecting multiple disjoint text ranges. From (MDN)
There are ways to work around the browser limitations, but would likely involve a lot more work (which I think may be overkill for Primer Spec 😞 )
The 'copy all commands' button video demo looks good! Thanks!
This feature will be released with v.1.7.0 later this month. Closing this issue for now, let me know if you have questions :)
Is your feature request related to a problem? Please describe. When clicking on copy to clipboard on a (multi-line)
console
code block, the console prompts are also copied.Describe the solution you'd like Would be nice if copy to clipboard on a (multi-line)
console
code block behaves similarly to per-line copy, i.e., the console prompt is not copied. It is not immediately obvious that one can click on the line number to copy a line.