Redactor is a minimalistic, lightweight WYSIWYG editor with great features and fantastic plugins.

We use osTicket for our help desk and it has Redactor version 9.2.4 integrated which is not the latest but it works fantastically.

Due to the nature of our business, we often need to name functions, files or even give quick code to customers in our help desk while offering support and it is essential to be able to highlight these with <code> tags for formatting purposes.

Redactor doesn’t have a code button plugin available which I could find so I quickly wrote one today for version 9.2.X. It’s just a little bit of Javascript using internal methods and objects of Redactor only. Below is also code for the latest version 10 of Redactor.

Please note that both instances below uses FontAwesome for a font icon for the button so you need to load FontAwesome in the <head> of your site:

Redactor 9 code button plugin

Redactor 10 code button plugin

That’s it, enjoy and feel free to comment if you have any questions or concerns!

Shares