wiki:Developers/WritingPlugins

Writing plugins

Writing a plugin for WYMeditor is quite easy, if you have a basic knowledge of jQuery and Object Oriented Programming in Javascript.

Example plugin

//Extend WYMeditor
Wymeditor.prototype.hovertools = function() {
  
  var wym = this;
  
  //bind events on buttons
  $j(this._box).find(this._options.toolSelector).hover(
    function() {
      wym.status($j(this).html());
    },
    function() {
      wym.status(' ');
    }
  );
};

This example extends WYMeditor with a new method 'hovertools', and uses jQuery to execute a function while the mouse hovers over WYMeditor tools.

this._box is the WYMeditor container, this._options.toolSelector is the jQuery selector, wym.status() displays a message in the status bar.

(work in progress)