TinyMCE:API/tinymce.Plugin/init
From Moxiecode Documentation Wiki
Contents |
[edit]
Method: init
[edit]
Summary
Initialization function for the plugin. This will be called when the plugin is created.
[edit]
Syntax
<void> init(<tinymce.Editor> e, <String> u)
[edit]
Parameters
- e
- Editor instance that created the plugin instance.
- u
- Absolute URL where the plugin is located.
[edit]
Examples
// Creates a new plugin class
tinymce.create('tinymce.plugins.ExamplePlugin', {
init : function(ed, url) {
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
ed.addCommand('mceExample', function() {
ed.windowManager.open({
file : url + '/dialog.htm',
width : 320 + ed.getLang('example.delta_width', 0),
height : 120 + ed.getLang('example.delta_height', 0),
inline : 1
}, {
plugin_url : url, // Plugin absolute URL
some_custom_arg : 'custom arg' // Custom argument
});
});
// Register example button
ed.addButton('example', {
title : 'example.desc',
cmd : 'mceExample',
image : url + '/img/example.gif'
});
// Add a node change handler, selects the button in the UI when a image is selected
ed.onNodeChange.add(function(ed, cm, n) {
cm.setActive('example', n.nodeName == 'IMG');
});
}
});
// Register plugin
tinymce.PluginManager.add('example', tinymce.plugins.ExamplePlugin);
