Skip to content

Commit

Permalink
Add className option for toolbar items (#1951)
Browse files Browse the repository at this point in the history
Allows for passing in a className when registering a toolbar button to allow to target via CSS.

An example:
```js
   Prism.plugins.toolbar.registerButton( 'my-button', {
        text: 'My Button',
        className: 'my-button',
    });
```
This will add the span element `<span class="my-button">My Button</span>` .
  • Loading branch information
mkaz authored and mAAdhaTTah committed Jun 25, 2019
1 parent 5d191b9 commit 5ab28bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions plugins/toolbar/prism-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @property {string} text The text displayed.
* @property {string} [url] The URL of the link which will be created.
* @property {Function} [onClick] The event listener for the `click` event of the created button.
* @property {string} [className] The class attribute to include with element.
*/

/**
Expand Down Expand Up @@ -44,6 +45,10 @@
element = document.createElement('span');
}

if (opts.className) {
element.classList.add(opts.className);
}

element.textContent = opts.text;

return element;
Expand Down
2 changes: 1 addition & 1 deletion plugins/toolbar/prism-toolbar.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5ab28bb

Please sign in to comment.