Depending on the Editor there are several ways to extend the editor in Joomla — I'm going to assume you're talking about
editors-xtd plugins. These are the buttons found below the main editor area.
There is a shortage of documentatoin on creating them so, as suggested, the best bet will be to look at existing editor extensions — I would start with the standard ones installed by default with Joomla. You can find the source code for them in the
/plugins/editors-xtd/ directory of your Joomla installation.
You can find currently available ones listed on the Joomla Extension Directory here.
editor-xtd plugins are like standard plugins so start with the Plugin Developer Overview article on Joomla Docs.
The main things to remember are:
- the plugin group is defined in the plugins XML file as
- the event triggered to display your custom button is
As it sounds the
onDisplay() method is where you return the do all the prep for the button (like assembling the HTML of the button). The
onDisplay() method should end with you return that html...
Obviously in that
// Get the current document
$doc = JFactory::getDocument();
$js = '...'
// Add it to the document as script block
// Or if you have a lot of JS, it's probably best in it's own file…
$jsFile = '/path/to/js/file.js';
// Add the link to the doc's head…
There are other methods Joomla provides to get and set the content of the editor, save it and to get the name of a method to insert text at the current cursor position in the editor.