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

docs: added copy to clipboard for each code block #2616

Merged
merged 12 commits into from Oct 31, 2022

Conversation

danangtomo
Copy link
Contributor

@danangtomo danangtomo commented Oct 20, 2022

Marked version:

Markdown flavor: Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a

Description

Expectation

Can do the copy process for each code block

Result

image

What was attempted

added copy to clipboard feature for each code block

Committer

In most cases, this should be a different person than the contributor.

@vercel
Copy link

vercel bot commented Oct 20, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
marked-website ✅ Ready (Inspect) Visit Preview Oct 31, 2022 at 8:11AM (UTC)

@danangtomo danangtomo changed the title 2611 copy clipboard 2611: added copy to clipboard for each code block Oct 20, 2022
@danangtomo
Copy link
Contributor Author

can you check it @UziTech

@UziTech
Copy link
Member

UziTech commented Oct 22, 2022

I'll take a closer look at this in the next few days. Is there a reason you went with execCommand instead of navigator.clipboard?

@danangtomo
Copy link
Contributor Author

I'll take a closer look at this in the next few days. Is there a reason you went with execCommand instead of navigator.clipboard?

Please check the latest changes

@UziTech
Copy link
Member

UziTech commented Oct 28, 2022

I think it would be better if the button would be on the top right instead of bottom right. That way it can be used without having to scroll to the bottom. Also it should be absolute positioned and show on hover like github.

code_copy

@danangtomo
Copy link
Contributor Author

I think it would be better if the button would be on the top right instead of bottom right. That way it can be used without having to scroll to the bottom. Also it should be absolute positioned and show on hover like github.

code_copy code_copy

Thanks for the input. changes have been made

@UziTech
Copy link
Member

UziTech commented Oct 29, 2022

It looks like the wrapper div is taking up space. Can we absolute position that instead?

image

@UziTech
Copy link
Member

UziTech commented Oct 31, 2022

I create a PR for this PR at danangtomo#1 If you merge that it will update this PR and I can approve it.

@danangtomo
Copy link
Contributor Author

I create a PR for this PR at danangtomo#1 If you merge that it will update this PR and I can approve it.

cool. sorry I've been busy lately

// New: https://marked.js.org/using_pro#renderer
var pageName = match[1].toLowerCase();
var sectionName = match[2];
window.location.href = '/' + pageName + sectionName;

Check warning

Code scanning / CodeQL

Client-side URL redirect

Untrusted URL redirection depends on [a user-provided value](1).
Copy link
Member

@UziTech UziTech left a comment

Choose a reason for hiding this comment

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

image

Thanks for working on this! 💯

@UziTech UziTech changed the title 2611: added copy to clipboard for each code block docs: added copy to clipboard for each code block Oct 31, 2022
@UziTech UziTech merged commit 1d7f039 into markedjs:master Oct 31, 2022
@danangtomo
Copy link
Contributor Author

image image

Thanks for working on this! 💯

my pleasure. happy to have contributed!

@khanrahim1616
Copy link

Is there any code example of how to add / use copy to clipboard button ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add copy to clipboard for each code block
3 participants