Custom Plugins
Creating a Plugin
Plugins must be added as a property of the sceditor.plugins.*
object.
For example to create a plugin called myplugin
it would be:
// Created in sceditor.plugins.[name] object
sceditor.plugins.myplugin = function() {
// Place signal handlers and functions here
};
To then enable the plugin in the editor, add myplugin
to the plugins option when creating the editor.
Handling Signals
To create a signal handler, just create a function with the name of the signal and it will automatically be called whenever that signal is raised.
e.g.
sceditor.plugins.myplugin = function() {
base.signalKeydownEvent = function(e) {
// this will automatically be called when 'myplugin'
// is registered with an editor instance and there
// is a keydown event
};
};
All signals will have this
set to the editor instance that the plugin applies to.
init
Called when the plugin is registered to the editor.
destroy
Called when destroy()
is called on the editor or the plugin is removed from the editor.
This signal should be used to unbind any DOM events and to do any clean up so that any memory used can be freed by the browser.
signalKeydownEvent
Parameters:
- e event
Thekeydown
event object
Called whenever the keydown
event is triggered in either the WYSIWYG or Source Mode editors.
Use this.sourceMode()
to check which mode the editor is in.
signalKeyupEvent
Parameters:
- e event
Thekeyup
event object
Called whenever the keyup
event is triggered in either the WYSIWYG or Source Mode editors.
Use this.sourceMode()
to check which mode the editor is in.
signalKeypressEvent
Parameters:
- e event
Thekeypress
event object
Called whenever the keypress
event is triggered in either the WYSIWYG or Source Mode editors.
Use this.sourceMode()
to check which mode the editor is in.
signalFocusEvent
Parameters:
- e event
Thefocus
event object
Called whenever the focus
event is triggered in either the WYSIWYG or Source Mode editors.
Use this.sourceMode()
to check which mode the editor is in.
signalBlurEvent
Parameters:
- e event
Theblur
event object
Called whenever the blur
event is triggered in either the WYSIWYG or Source Mode editors.
Use this.sourceMode()
to check which mode the editor is in.
signalContextmenuEvent
Parameters:
- e event
Thecontextmenu
event object
Called whenever the contextmenu
event is triggered in either the WYSIWYG or Source Mode editors.
Use this.sourceMode()
to check which mode the editor is in.
signalSelectionchangedEvent
Parameters:
- e event
Theselectionchanged
event object
Called whenever the selection has changed in the WYSIWYG editor.
This event does not occur when in source mode.