Skip to content

fix copy to clipboard#23966

Merged
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
kbhawkey:kb-fix-copy-clipboard
Sep 20, 2020
Merged

fix copy to clipboard#23966
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
kbhawkey:kb-fix-copy-clipboard

Conversation

@kbhawkey
Copy link
Copy Markdown
Contributor

@kbhawkey kbhawkey commented Sep 18, 2020

In the codenew shortcode, 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:

  • name of the file
  • file content

The rendered elements are not exactly as before but close. The filename/copy icon is left justified.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. sig/docs Categorizes an issue or PR as relevant to SIG Docs. labels Sep 18, 2020
@netlify
Copy link
Copy Markdown

netlify bot commented Sep 18, 2020

Deploy preview for kubernetes-io-master-staging ready!

Built with commit 245f989

https://deploy-preview-23966--kubernetes-io-master-staging.netlify.app

@kbhawkey
Copy link
Copy Markdown
Contributor Author

@kbhawkey kbhawkey changed the title fix copy clipboard fix copy to clipboard Sep 18, 2020
@tengqm
Copy link
Copy Markdown
Contributor

tengqm commented Sep 18, 2020

Thanks for the fix!
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 18, 2020
@sftim
Copy link
Copy Markdown
Contributor

sftim commented Sep 18, 2020

The text that is copied is:

  • name of the file
  • file content

I think readers would expect the copied text to be:

  • file content

can we implement this?

@sftim
Copy link
Copy Markdown
Contributor

sftim commented Sep 18, 2020

It's surprising to copy a file and have its filename appear in the paste; that's not what most readers will want.

@kbhawkey
Copy link
Copy Markdown
Contributor Author

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.

@kbhawkey
Copy link
Copy Markdown
Contributor Author

kbhawkey commented Sep 18, 2020

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)
about the copied content. The example text lacks a header.
Also ,there are three ways to get the content of the code block:
copy from directly from the page, click the link, click the copy-to-clipboard icon.

I am investigating another solution that will take a bit more work. The theme has recently added
prism.js and the copy-to-clipboard plugin. I think this would involve updating the submodule again,
turning on prism for the site, and updating the header. The site is currently using
Chroma Go highlighter in Hugo. For more information, see google/docsy#325 .

@sftim
Copy link
Copy Markdown
Contributor

sftim commented Sep 18, 2020

The quickest solution is to add the filename as a comment to the copied text.

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.

@kbhawkey
Copy link
Copy Markdown
Contributor Author

Right. Good spot. The filename + code has been a "feature" for some time.

@kbhawkey kbhawkey force-pushed the kb-fix-copy-clipboard branch from 30413ad to 245f989 Compare September 18, 2020 17:14
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 18, 2020
@kbhawkey
Copy link
Copy Markdown
Contributor Author

I move the text to a new div and out of the image element. There's still room for improvement, but I believe
the text copies correctly and omits the filename.

@tengqm
Copy link
Copy Markdown
Contributor

tengqm commented Sep 18, 2020

Great. This is more than a bug fix now. It is an improvement over our previous implementation.
Thanks.
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 18, 2020
@sftim
Copy link
Copy Markdown
Contributor

sftim commented Sep 20, 2020

Tech review: #23966 (comment)
Happy with the improvement described.
/area web-development
/approve

Many thanks @kbhawkey and @tengqm - it's a good think to fix.

@k8s-ci-robot k8s-ci-robot added the area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes label Sep 20, 2020
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 20, 2020
@k8s-ci-robot k8s-ci-robot merged commit c7ac126 into kubernetes:master Sep 20, 2020
@kbhawkey kbhawkey deleted the kb-fix-copy-clipboard branch September 22, 2020 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants