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

feat: copy to clipboard code snippet #1060

Merged
merged 8 commits into from
Oct 13, 2020

Conversation

ngdevelop-tech
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Other... Please describe:

What is the current behavior?

Copy to clipboard button is not available for code snippets.

Issue Number: N/A

What is the new behavior?

Copy to clipboard feature is added for the code snippet. This feature is included in markdown plugin.

  • To use this feature follow the below steps :

The way we have enableSyntaxHighlighting: true flag for highlighting code, another flag is added enableCopyToClipboard, the default value of this flag is false.

If you want to enable copy to clipboard feature, set plugin config as below

setPluginConfig('md', { enableSyntaxHighlighting: true, enableCopyToClipboard: true });

When enableCopyToClipboard is true, it will add Copy button, it's script and style while transforming markdown to html.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@ngdevelop-tech
Copy link
Contributor Author

@SanderElias, while implementing this PR, I have also found one issue,
pre with position: relative will not work properly, currently in our code snippets when we do horizontal scroll, language heading move with it. generally, it should not move.
Also when I added a copy button on the right-top corner with an absolute position. it was also moving on the horizontal scroll.
So to fix such issue I have added one parent div.scully-code-snippet with position relative.

So it fixes both the issue. This behavior is inspired by the gatsby docs.

Please confirm if it is correct or not. If it is correct then I will update the test case snapshot in sample-blog app where it is getting failed now. If you have any suggestion and want me to update anything please let me know.

@ngdevelop-tech
Copy link
Contributor Author

Hi @SanderElias, I have created a separate plugin and committed the code. please review it.

@jorgeucano jorgeucano merged commit 70efac5 into scullyio:main Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants