4 * Copyright 2009, Moxiecode Systems AB
5 * Released under LGPL License.
7 * License: http://tinymce.moxiecode.com/license
8 * Contributing: http://tinymce.moxiecode.com/contributing
12 // Load plugin specific language pack
13 tinymce
.PluginManager
.requireLangPack('example');
15 tinymce
.create('tinymce.plugins.ExamplePlugin', {
17 * Initializes the plugin, this will be executed after the plugin has been created.
18 * This call is done before the editor instance has finished it's initialization so use the onInit event
19 * of the editor instance to intercept that event.
21 * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
22 * @param {string} url Absolute URL to where the plugin is located.
24 init : function(ed
, url
) {
25 // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
26 ed
.addCommand('mceExample', function() {
27 ed
.windowManager
.open({
28 file
: url
+ '/dialog.htm',
29 width
: 320 + parseInt(ed
.getLang('example.delta_width', 0)),
30 height
: 120 + parseInt(ed
.getLang('example.delta_height', 0)),
33 plugin_url
: url
, // Plugin absolute URL
34 some_custom_arg
: 'custom arg' // Custom argument
38 // Register example button
39 ed
.addButton('example', {
40 title
: 'example.desc',
42 image
: url
+ '/img/example.gif'
45 // Add a node change handler, selects the button in the UI when a image is selected
46 ed
.onNodeChange
.add(function(ed
, cm
, n
) {
47 cm
.setActive('example', n
.nodeName
== 'IMG');
52 * Creates control instances based in the incomming name. This method is normally not
53 * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
54 * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
55 * method can be used to create those.
57 * @param {String} n Name of the control to create.
58 * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
59 * @return {tinymce.ui.Control} New control instance or null if no control was created.
61 createControl : function(n
, cm
) {
66 * Returns information about the plugin as a name/value array.
67 * The current keys are longname, author, authorurl, infourl and version.
69 * @return {Object} Name/value array containing information about the plugin.
71 getInfo : function() {
73 longname
: 'Example plugin',
74 author
: 'Some author',
75 authorurl
: 'http://tinymce.moxiecode.com',
76 infourl
: 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example',
83 tinymce
.PluginManager
.add('example', tinymce
.plugins
.ExamplePlugin
);