fix copy to clipboard#23966
Conversation
|
Deploy preview for kubernetes-io-master-staging ready! Built with commit 245f989 https://deploy-preview-23966--kubernetes-io-master-staging.netlify.app |
|
Check any page with code to copy. Here's one: |
|
Thanks for the fix! |
I think readers would expect the copied text to be:
can we implement this? |
|
It's surprising to copy a file and have its filename appear in the paste; that's not what most readers will want. |
I agree and was surprised to find the file name inserted into the file. Let me see if I can fix it. |
|
Hi. The quickest solution is to add the filename as a comment to the copied text. This is an easy change with the added benefit of providing information (the filename) I am investigating another solution that will take a bit more work. The theme has recently added |
I'm afraid I can see a shortcoming: some of the samples are in formats that don't support comments (JSON), and we might have samples where commenting is available but we don't know the syntax. It's not a regression so marking the filename as a YAML comment could be a useful interim step. |
|
Right. Good spot. The filename + code has been a "feature" for some time. |
30413ad to
245f989
Compare
|
I move the text to a new div and out of the image element. There's still room for improvement, but I believe |
|
Great. This is more than a bug fix now. It is an improvement over our previous implementation. |
|
Tech review: #23966 (comment) Many thanks @kbhawkey and @tengqm - it's a good think to fix. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sftim The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
In the
codenewshortcode, I previously replaced the table element with a div.However, the innerText was no longer copied to clipboard. This resolves issue #23817 .
The body of the code block is the innerText.
The text that is copied is:
The rendered elements are not exactly as before but close. The filename/copy icon is left justified.