{"action":"created","issue":{"url":"https://api.github.com/repos/PrismJS/prism/issues/891","repository_url":"https://api.github.com/repos/PrismJS/prism","labels_url":"https://api.github.com/repos/PrismJS/prism/issues/891/labels{/name}","comments_url":"https://api.github.com/repos/PrismJS/prism/issues/891/comments","events_url":"https://api.github.com/repos/PrismJS/prism/issues/891/events","html_url":"https://github.com/PrismJS/prism/pull/891","id":133474413,"number":891,"title":"Plugins: Toolbar & Copy to Clipboard","user":{"login":"mAAdhaTTah","id":4371429,"avatar_url":"https://avatars.githubusercontent.com/u/4371429?v=3","gravatar_id":"","url":"https://api.github.com/users/mAAdhaTTah","html_url":"https://github.com/mAAdhaTTah","followers_url":"https://api.github.com/users/mAAdhaTTah/followers","following_url":"https://api.github.com/users/mAAdhaTTah/following{/other_user}","gists_url":"https://api.github.com/users/mAAdhaTTah/gists{/gist_id}","starred_url":"https://api.github.com/users/mAAdhaTTah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mAAdhaTTah/subscriptions","organizations_url":"https://api.github.com/users/mAAdhaTTah/orgs","repos_url":"https://api.github.com/users/mAAdhaTTah/repos","events_url":"https://api.github.com/users/mAAdhaTTah/events{/privacy}","received_events_url":"https://api.github.com/users/mAAdhaTTah/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":51,"created_at":"2016-02-13T21:23:15Z","updated_at":"2016-10-07T22:58:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/PrismJS/prism/pulls/891","html_url":"https://github.com/PrismJS/prism/pull/891","diff_url":"https://github.com/PrismJS/prism/pull/891.diff","patch_url":"https://github.com/PrismJS/prism/pull/891.patch"},"body":"I'm using Prism as the syntax highlighter for my WordPress plugin, [WP-Gistpen](https://github.com/mAAdhaTTah/WP-Gistpen). I've built a toolbar plugin that I'd like to contribute to Prism. I've got a first pass at extracting the plugin from its CommonJS origins,, but I need some feedback on how to change it to fit the Prism way of doing things, e.g. the HTML API. I also see some possible synergy with the [Parse Settings](https://github.com/PrismJS/prism/pull/851) plugin.\r\n\r\nThe Toolbar exposes two methods: a `hook` method, which is registered with Prism's `complete` hook, and a `registerButton` method, which takes a callback that creates the buttons. The callback will be passed the `env` and should return an `a` or `span` element, which other plugins can use to register themselves with the Toolbar to get their text or link to display.\r\n\r\nI've also created a [Clipboard](https://github.com/mAAdhaTTah/WP-Gistpen/blob/7b26f5027eba6d65fc54432401459811f98c0168/src/js/prism/clipboard.js) plugin is an example of this callback, which creates an anchor tag that, when clicked, copies the code to the clipboard. I plan to extract that into a Prism plugin as well, but I'm not sure how Prism wants to handle dependencies like [Clipboard.js](https://clipboardjs.com/), or how the download page will work with internal dependencies like this. In the interest of user friendliness, what's the best approach to take here?\r\n\r\nPrior art:\r\n\r\n* https://github.com/PrismJS/prism/issues/280\r\n* https://github.com/PrismJS/prism/issues/286\r\n* http://dev.misterphilip.com/prism/plugins/toolbar/\r\n* https://github.com/PrismJS/prism/pull/142/files\r\n\r\nOpen Questions:\r\n\r\n* [x] Should the `registerButton` method be polymorphic?\r\n* [x] How can the CSS styles be improved?\r\n* [x] How should we handle 3rd party dependencies, like [Clipboard.js](https://clipboardjs.com/)?\r\n* [ ] What should the HTML API be? (See: #910)\r\n* [x] How do we deal with this plugin & filename plugin conflicts? (See: #910, #914)"},"comment":{"url":"https://api.github.com/repos/PrismJS/prism/issues/comments/252380248","html_url":"https://github.com/PrismJS/prism/pull/891#issuecomment-252380248","issue_url":"https://api.github.com/repos/PrismJS/prism/issues/891","id":252380248,"user":{"login":"LeaVerou","id":175836,"avatar_url":"https://avatars.githubusercontent.com/u/175836?v=3","gravatar_id":"","url":"https://api.github.com/users/LeaVerou","html_url":"https://github.com/LeaVerou","followers_url":"https://api.github.com/users/LeaVerou/followers","following_url":"https://api.github.com/users/LeaVerou/following{/other_user}","gists_url":"https://api.github.com/users/LeaVerou/gists{/gist_id}","starred_url":"https://api.github.com/users/LeaVerou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LeaVerou/subscriptions","organizations_url":"https://api.github.com/users/LeaVerou/orgs","repos_url":"https://api.github.com/users/LeaVerou/repos","events_url":"https://api.github.com/users/LeaVerou/events{/privacy}","received_events_url":"https://api.github.com/users/LeaVerou/received_events","type":"User","site_admin":false},"created_at":"2016-10-07T22:58:30Z","updated_at":"2016-10-07T22:58:30Z","body":"If there are buttons etc that's not gonna work. `data-` attributes it is then!"}}
{"actor":{"display_login":"LeaVerou"}}