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

In-browser snippet copying #27

Merged
merged 1 commit into from Aug 22, 2016
Merged

Conversation

@ramiabraham
Copy link
Contributor

@ramiabraham ramiabraham commented Aug 21, 2016

Adds copy functionality using execCommand(‘copy’) to directly copy the code snippet to the clipboard.

  • Will fallback to cpt.openSnippetCopy() on failure.
  • Uses cpt.browserCopyStyles() to set styles because I couldn’t immediately locate an effective means to manipulate styles via the scss/css alone.
  • wp.a11y.speak is commented out in two cases in frontend.js, as the eslintrc config returns an undef error on wp. A custom global/environment handler for wp - or a line-level eslint rule is required (or suppression of the error itself).
  • Needs a grunt build ( I opted for the courtesy of me not compiling in the PR).

Appearance:

snippet copy example

Adds copy functionality using `execCommand(‘copy’)` to directly copy the code snippet to the clipboard.

- Will fallback to `cpt.openSnippetCopy()` on failure.
- Uses `cpt.browserCopyStyles()` to set styles because I couldn’t immediately locate an effective means to manipulate styles via the scss/css alone.
- wp.a11y.speak is commented out, as the eslintrc config returns an undef error on `wp`. A custom environment, or a line-level eslint rule is required (or suppression of the error itself).
- Needs a grunt build for min assets etc.
@jtsternberg
Copy link
Owner

@jtsternberg jtsternberg commented Aug 22, 2016

Hey @ramiabraham, tried testing this, but it never copies to the clipboard. Which browser are you using where this works?

@ramiabraham
Copy link
Contributor Author

@ramiabraham ramiabraham commented Aug 22, 2016

@jtsternberg did you compile grunt first?

@jtsternberg
Copy link
Owner

@jtsternberg jtsternberg commented Aug 22, 2016

Yah. I think I got it now. Thanks

@jtsternberg jtsternberg merged commit a13f96f into jtsternberg:master Aug 22, 2016
@jtsternberg
Copy link
Owner

@jtsternberg jtsternberg commented Aug 22, 2016

💥 Thank you sir 👑 @ramiabraham

@ramiabraham
Copy link
Contributor Author

@ramiabraham ramiabraham commented Aug 22, 2016

@jtsternberg Woot!

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

Successfully merging this pull request may close these issues.

None yet

2 participants