Skip to content

Commit

Permalink
Set type="button" attribute for copy to clipboard plugin. (#2593)
Browse files Browse the repository at this point in the history
When using Prism + copy to clipboard inside a HTML form, the form is submitted when copying.
It's because by default the button is seen as a submit button.
Adding the `type="button"` attribute prevents this.
  • Loading branch information
alexsegura committed Oct 15, 2020
1 parent b04cbaf commit f59a85f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/copy-to-clipboard/prism-copy-to-clipboard.js
Expand Up @@ -38,6 +38,7 @@
Prism.plugins.toolbar.registerButton('copy-to-clipboard', function (env) {
var linkCopy = document.createElement('button');
linkCopy.textContent = 'Copy';
linkCopy.setAttribute('type', 'button');

var element = env.element;

Expand Down
2 changes: 1 addition & 1 deletion plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js

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

0 comments on commit f59a85f

Please sign in to comment.