Reputation: 19953
Using TinyMCE, is it possible to add toolbar buttons or shortcuts for <code>
and <pre>
formatting (so that they work in the same way as <b>
, <i>
etc)?
Having to go through 4 clicks to get to code
(Format -> Formats -> Inline -> Code) and another 4 clicks to get to pre
(Format -> Formats -> Blocks -> Pre) is a massive pain.
Adding the keyword code
to the list of toolbar buttons or even to the Format menu results in the source code button.
Upvotes: 2
Views: 636
Reputation: 2582
On the TinyMCE initialization:
tinymce.init({
selector: 'textarea',
height: 500,
toolbar: 'codeSC',
[...]
setup: function (editor) {
editor.addButton('codeSC', {
text: '<code>',
icon: false,
onclick: function () {
editor.insertContent('<code>Text inside code</code>');
}
});
}
});
codeSC = codeShortCut
Upvotes: 2