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