Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving copy to clipboard feature- Removing extra lines #34736

Closed
wants to merge 1 commit into from

Conversation

ayushtamra
Copy link

@ayushtamra ayushtamra commented Jun 30, 2022

Fix: #34447

Hello, this solves the issue of addition of extra lines, on "copy to clipboard". Implemented by making changes in the JavaScript, using JavaScript replace and trim function.

Deploy preview example yaml files which are now without extra lines:

  1. https://deploy-preview-34736--kubernetes-io-main-staging.netlify.app/docs/concepts/services-networking/network-policies/#networkpolicy-resource
  2. https://deploy-preview-34736--kubernetes-io-main-staging.netlify.app/docs/tasks/configure-pod-container/configure-runasusername/#set-the-username-for-a-pod

Signed-off-by: ayushtamra <tamraayush@gmail.com>
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 30, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: ayushtamra / name: Ayush Tamra (3d5f75e)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jun 30, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @ayushtamra!

It looks like this is your first PR to kubernetes/website 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/website has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 30, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign celestehorgan after the PR has been reviewed.
You can assign the PR to them by writing /assign @celestehorgan in a comment when ready.

The full list of commands accepted by this bot can be found here.

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 sig/docs Categorizes an issue or PR as relevant to SIG Docs. label Jun 30, 2022
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jun 30, 2022
@netlify
Copy link

netlify bot commented Jun 30, 2022

Pull request preview available for checking

Built without sensitive environment variables

Name Link
🔨 Latest commit 3d5f75e
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-io-main-staging/deploys/62bdc0e578fc6d0008a544f4
😎 Deploy Preview https://deploy-preview-34736--kubernetes-io-main-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@@ -23,6 +23,7 @@
document.body.appendChild(target);
}
target.value = document.getElementById(elem).innerText;
target.value = target.value.replace(/\n\n/gm,"\n").trim();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ayushtamra

I think this may be the wrong fix. If the original bug / behavior changes within Hugo then what gets copied could be different from what you get when you download the example.

At a minimum, this needs a clear comment that explains why the replace() happens.

Copy link
Author

@ayushtamra ayushtamra Jun 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @sftim I would like to mention that maybe its related to the execCommand() which is doing the copy here.
Also I have seen an question posted on StackOverflow(don't know if it makes sense): https://stackoverflow.com/questions/34477425/javascript-execcommandcopy-copies-text-but-adds-extra-white-space-to-value
But I am sure to look into and learn if there is any issues related with hugo

@Sea-n
Copy link
Member

Sea-n commented Aug 29, 2022

Hey @ayushtamra,

Any updates on this PR? Seems the fix is stuck here.

@ayushtamra
Copy link
Author

ayushtamra commented Aug 29, 2022

Hello @Sea-n I am actually able to solve this particular issue, by fixing the extra lines on a frontend level(a probable quick fix), but as mentioned I am not able to fix it at the root level, and will need help to solve it

@tengqm
Copy link
Contributor

tengqm commented Aug 29, 2022

I gave this a quick research.

Based on the HTML source code we get from the browser, my understanding is that something is wrong with Hugo when parsing a YAML file. The extra empty lines are added by the builtin shortcodes invoked here. We need to investigate why the contents of different files under the same directory are processed differently.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 27, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Dec 27, 2022
@divya-mohan0209
Copy link
Contributor

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Dec 28, 2022
@divya-mohan0209
Copy link
Contributor

Hello @ayushtamra , are you interested in continuing to work on this PR and investigate per suggestion by @tengqm ? Please confirm in either case since if you aren't, we can open this up to contributors who'd be able to pick this up from here.

@divya-mohan0209
Copy link
Contributor

Hey @ayushtamra , since there has been no response to the feedback provided I will be closing the PR. If you wish to continue work, please consider reopening it by issuing a /reopen command.

/close

@k8s-ci-robot
Copy link
Contributor

@divya-mohan0209: Closed this PR.

In response to this:

Hey @ayushtamra , since there has been no response to the feedback provided I will be closing the PR. If you wish to continue work, please consider reopening it by issuing a /reopen command.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

“Copy to clipboard” button adds extra lines into the copied text
7 participants