upgrading tinymce to 2.0.5.1

This commit is contained in:
JT Smith 2006-04-15 20:03:31 +00:00
parent cb2a8d025e
commit 00d46f6148
342 changed files with 13043 additions and 11487 deletions

View file

@ -11,55 +11,221 @@
</div>
<div class="content">
<h2>Creating your own Themes</h2>
<p>
Creating you own themes for the TinyMCE application is fairly easy if you know the basics of HTML, CSS and Javascript. The most easy way is to copy the &quot;default&quot; or the &quot;advanced&quot; template and rename it as your own name to for example &quot;mytheme&quot;. After you copy the template you need to change the red sections marked below to &quot;mytheme&quot; this is needed so that themes don't overlap in other words it gives the theme a unique name. Then just alter the HTML code as you see fit but notice some elements needs to be there so check the docs below on each function also remember that your custom themes needs to be located in tiny_mce's &quot;themes&quot; directory. If you want you may add theme specific options/settings but remember to namespace them in the following format &quot;theme_&lt;your theme&gt;_&lt;option&gt;&quot;.
Creating you own themes for the TinyMCE application is fairly easy if you know the basics of HTML, CSS and Javascript. The most easy way is to copy the &quot;simple&quot; or the &quot;advanced&quot; template and rename it as your own name to for example &quot;mytheme&quot;. After you copy the template you need to change the red sections marked below to &quot;mytheme&quot; this is needed so that themes don't overlap in other words it gives the theme a unique name. Then just alter the HTML code as you see fit but notice some elements needs to be there so check the docs below on each function also remember that your custom themes needs to be located in tiny_mce's &quot;themes&quot; directory. If you want you may add theme specific options/settings but remember to namespace them in the following format &quot;theme_&lt;your theme&gt;_&lt;option&gt;&quot;.
</p>
<div class="separator"></div>
<h3>Theme directory structure</h3>
<p>
The example below has three functions, these are explained in greater detail below.
<table class="btable">
<thead>
<th>File/Directory</td>
<th>Description</td>
</thead>
<tbody>
<tr><td>css</td><td>Theme specific CSS files</td></tr>
<tr><td>docs</td><td>Theme specific documentation</td></tr>
<tr><td>images</td><td>Theme specific images</td></tr>
<tr><td>jscripts</td><td>Theme specific jscripts for HTML dialogs</td></tr>
<tr><td>langs</td><td>Theme specific language files</td></tr>
<tr><td>editor_template.js</td><td>Editor theme template file (compressed).</td></tr>
<tr><td>editor_template_src.js</td><td>Editor theme template file (source).</td></tr>
<tr><td>somedialog.htm</td><td>Theme specific dialog HTML file.</td></tr>
</table>
</p>
<div class="separator"></div>
<h3>Theme example source</h3>
<p>
The example below shows a simple empty theme and all possible callbacks.
</p>
<p>
<div class="example">
<pre>
function TinyMCE_<span class="marked">default</span>_getEditorTemplate(settings) {
var template = new Array();
var TinyMCE_<span class="marked">SomeName</span>Theme = {
/**
* Returns information about the theme as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @returns Name/value array containing information about the theme.
* @type Array
*/
getInfo : function() {
return {
longname : 'Your Theme',
author : 'Your name',
authorurl : 'http://www.yoursite.com',
infourl : 'http://www.yoursite.com/docs/template.html',
version : "1.0"
};
},
template['html'] = '&lt;Some HTML&gt;';
template['delta_width'] = 0;
template['delta_height'] = -40;
/**
* Gets executed when a TinyMCE editor instance is initialized.
*
* @param {TinyMCE_Control} Initialized TinyMCE editor control instance.
*/
initInstance : function(inst) {
// You can take out theme specific parameters
alert("Initialization parameter:" + tinyMCE.getParam("<span class="marked">somename</span>_someparam", false));
return template;
}
// Register custom keyboard shortcut
inst.addShortcut('ctrl', 't', 'lang_<span class="marked">somename</span>_desc', 'mceSomeCommand');
},
function TinyMCE_<span class="marked">default</span>_getInsertLinkTemplate(settings) {
var template = new Array();
/**
* Returns the HTML code for a specific control or empty string if this theme doesn't have that control.
* A control can be a button, select list or any other HTML item to present in the TinyMCE user interface.
* The variable {$editor_id} will be replaced with the current editor instance id and {$themeurl} will be replaced
* with the URL of the theme. Language variables such as {$lang_somekey} will also be replaced with contents from
* the language packs.
*
* @param {string} cn Editor control/button name to get HTML for.
* @return HTML code for a specific control or empty string.
* @type string
*/
getControlHTML : function(cn) {
switch (cn) {
case "<span class="marked">SomeControl</span>":
return tinyMCE.getButtonHTML(cn, 'lang_<span class="marked">sometheme</span>_<span class="marked">button</span>_desc', '{$themeurl}/images/<span class="marked">someimage</span>.gif', '<span class="marked">mceSomeCommand</span>');
}
template['file'] = 'link.htm';
template['width'] = 320;
template['height'] = 130;
return "";
},
return template;
}
/**
* Returns the HTML code that should be inserted for a specific editor instance.
* This function should return a name/value array with three items html, delta_width, delta_height.
* The html item should contain the HTML code to insert as a editor instance.
* The variable {$editor_id} will be replaced with the current editor instance id and {$themeurl} will be replaced
* with the URL of the theme. Language variables such as {$lang_somekey} will also be replaced with contents from
* the language packs. Any element with the id {$editor_id} will be replaced with the editor iframe element.
* The {$width} and {$height} variables will be replaced with the editors outside dimension values.
* The delta_width/height is the relative width/height in pixels to add or remove from the iframe dimensions.
*
* @param {Array} settings Name/Value array instance settings.
* @param {string} editor_id TinMYCE editor control instance id.
* @return Name/Value array of editor template data.
* @type Array
*/
getEditorTemplate : function(settings, editor_id) {
var html = "";
function TinyMCE_<span class="marked">default</span>_getInsertImageTemplate(settings) {
var template = new Array();
// Build toolbar and editor instance
html += "..";
template['file'] = 'image.htm';
template['width'] = 320;
template['height'] = 130;
return {
html : html,
delta_width : 0,
delta_height : 0
};
},
return template;
}
/**
* Executes a specific command, this function handles theme commands.
*
* @param {string} editor_id TinyMCE editor instance id that issued the command.
* @param {HTMLElement} element Body or root element for the editor instance.
* @param {string} command Command name to be executed.
* @param {string} user_interface True/false if a user interface should be presented.
* @param {mixed} value Custom value argument, can be anything.
* @return true/false if the command was executed by this theme or not.
* @type
*/
execCommand : function(editor_id, element, command, user_interface, value) {
// Handle commands
switch (command) {
// Remember to have the "mce" prefix for commands so they don't intersect with built in ones in the browser.
case "mce<span class="marked">SomeCommand</span>":
// Do your custom command logic here.
function TinyMCE_<span class="marked">default</span>_handleNodeChange(editor_id, node) {
// Check what happend
}
return true;
}
function TinyMCE_<span class="marked">default</span>_execCommand(editor_id, element, command, user_interface, value) {
// Your custom command logic
return false;
}
// Pass to next handler in chain
return false;
},
/**
* Gets called ones the cursor/selection in a TinyMCE instance changes. This is useful to enable/disable
* button controls depending on where the user are and what they have selected. This method gets executed
* alot and should be as performance tuned as possible.
*
* @param {string} editor_id TinyMCE editor instance id that was changed.
* @param {HTMLNode} node Current node location, where the cursor is in the DOM tree.
* @param {int} undo_index The current undo index, if this is -1 custom undo/redo is disabled.
* @param {int} undo_levels The current undo levels, if this is -1 custom undo/redo is disabled.
* @param {boolean} visual_aid Is visual aids enabled/disabled ex: dotted lines on tables.
* @param {boolean} any_selection Is there any selection at all or is there only a cursor.
*/
handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
},
/**
* Gets called when a TinyMCE editor instance gets filled with content on startup.
*
* @param {string} editor_id TinyMCE editor instance id that was filled with content.
* @param {HTMLElement} body HTML body element of editor instance.
* @param {HTMLDocument} doc HTML document instance.
*/
setupContent : function(editor_id, body, doc) {
},
/**
* Gets called when the contents of a TinyMCE area is modified, in other words when a undo level is
* added.
*
* @param {TinyMCE_Control} inst TinyMCE editor area control instance that got modified.
*/
onChange : function(inst) {
},
/**
* Gets called when TinyMCE handles events such as keydown, mousedown etc. TinyMCE
* doesn't listen on all types of events so custom event handling may be required for
* some purposes.
*
* @param {Event} e HTML editor event reference.
* @return true - pass to next handler in chain, false - stop chain execution
* @type boolean
*/
handleEvent : function(e) {
return true;
},
/**
* Gets called when HTML contents is inserted or retrived from a TinyMCE editor instance.
* The type parameter contains what type of event that was performed and what format the content is in.
* Possible valuses for type is get_from_editor, insert_to_editor, get_from_editor_dom, insert_to_editor_dom.
*
* @param {string} type Cleanup event type.
* @param {mixed} content Editor contents that gets inserted/extracted can be a string or DOM element.
* @param {TinyMCE_Control} inst TinyMCE editor instance control that performes the cleanup.
* @return New content or the input content depending on action.
* @type string
*/
cleanup : function(type, content, inst) {
return content;
},
// Private theme internal methods
/**
* This is just a internal theme method, prefix all internal methods with a _ character.
* The prefix is needed so they doesn't collide with future TinyMCE callback functions.
*
* @param {string} a Some arg1.
* @param {string} b Some arg2.
* @return Some return.
* @type string
*/
_someInternalFunction : function(a, b) {
return 1;
}
};
// Adds the theme class to the list of available TinyMCE themes
tinyMCE.addTheme("<span class="marked">sometheme</span>", TinyMCE_<span class="marked">SomeTheme</span>Theme);
</pre>
</div>
</p>
@ -74,348 +240,21 @@ When creating a popup you need to include the &quot;tiny_mce_popup.js&quot; this
<pre>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;{$lang_plugin_sample_title}&lt;/title&gt;
&lt;title&gt;{$lang_theme_sample_title}&lt;/title&gt;
&lt;script language=&quot;javascript&quot; src=&quot;../../tiny_mce_popup.js&quot;&gt;&lt;/script&gt;
&lt;script language=&quot;javascript&quot;&gt;
// getWindowArg returns any arguments passed to the window
alert(tinyMCE.getWindowArg('some_arg'));
&lt;/script&gt;
&lt;body&gt;
&lt;strong&gt;{$lang_plugin_sample_desc}&lt;/strong&gt;
&lt;strong&gt;{$lang_theme_sample_desc}&lt;/strong&gt;
&lt;/body&gt;
</pre>
</div>
<div class="separator"></div>
<h3>The TinyMCE_&lt;theme&gt;_getEditorTemplate(settings) function</h3>
<p>
This function is responsible for the layout of the editor instance within the page it should return a name/value based array with some specific names. These are explained below, notice names included in [] characters are optional. The settings parameter to this function is a name/value array containing tinyMCE:s settings/options.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Template data</td>
</tr>
</thead>
<tbody>
<tr>
<td><strong>html</strong></td>
<td>HTML template data, this value should contain all the HTML code needed to render the editor. Notice: {$&lt;variable&gt;} are replaces with values when used. More about these specific values later on.</td>
</tr>
<tr>
<td><strong>[delta_width]</strong></td>
<td>Delta width, this value should contain the relative width needed by the UI. For example if a toolbar takes 20 pixels this value should be -20. This is so the editor gets the same size as the element that are replaced.</td>
</tr>
<tr>
<td><strong>[delta_height]</strong></td>
<td>Delta height, this value should contain the relative width needed by the UI. For example if a toolbar takes 40 pixels this value should be -40. This is so the editor gets the same size as the element that are replaced.</td>
</tr>
</tbody>
</table>
</p>
<p>
Variables within the &quot;html&quot; value above are replaced with internal TinyMCE values. There are two types of variables one is the ones starting with the &quot;lang_&quot; prefix, these are replaced with the matching names in the language packs. So for example &lt;b&gt;{$lang_test}&lt;/b&gt; gets replaces with the &quot;tinyMCELang['lang_test']&quot; variable and the output is then &lt;b&gt;Test&lt;/b&gt;. The other variables are passed expicilty for the template used and these are listed below. Notice: Variables within [] characters are optional.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Variables</td>
</tr>
</thead>
<tbody>
<tr>
<td><strong>editor_id</strong></td>
<td>This is the editor instance id and it should be placed in ID attribute of the IFRAME element that must be included in the template.</td>
</tr>
<tr>
<td><strong>[default_document]</strong></td>
<td>This will be replaced with a blank html page, this is added for MSIE security issues and should be placed in the SRC attribute of the IFRAME within the template.</td>
</tr>
<tr>
<td><strong>[area_width]</strong></td>
<td>Width of IFRAME area in pixels.</td>
</tr>
<tr>
<td><strong>[area_height]</strong></td>
<td>Height of IFRAME area in pixels.</td>
</tr>
<tr>
<td><strong>[width]</strong></td>
<td>Width of the whole editor area in pixels.</td>
</tr>
<tr>
<td><strong>[height]</strong></td>
<td>Height of the whole editor area in pixels.</td>
</tr>
<tr>
<td><strong>[themeurl]</strong></td>
<td>URL to theme location.</td>
</tr>
</tbody>
</table>
</p>
<p>
Notice: There are two javascript function that can be called from this template these are tinyMCE.execCommand that executes commans on the currenly selected editor area and the tinyMCE.switchClass that switches the CSS class of the element specified. For more details of commands available by execCommand check the Mozilla midas specification and the TinyMCE specific commands.
</p>
<div class="separator"></div>
<h3>The TinyMCE_&lt;theme&gt;_getInsertLinkTemplate(settings) function</h3>
<p>
This function is responsible for the layout of the insert link popup window and it should return a name/value based array with some specific names. These are explained below, notice names included in [] characters are optional. The settings parameter to this function is a name/value array containing tinyMCE:s settings/options.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Template data</td>
</tr>
</thead>
<tbody>
<tr>
<td><strong>html</strong></td>
<td>HTML template data, this value should contain all the HTML code needed to render the link dialog. Notice: {$&lt;variable&gt;} are replaces with values when used. More about these specific values later on. This parameter is not needed if the &quot;file&quot; param is assigned.</td>
</tr>
<tr>
<td><strong>file</strong></td>
<td>Name of external template file to use, this may even be logic pages like .php,.asp,.jsp etc.</td>
</tr>
<tr>
<td><strong>[width]</strong></td>
<td>Width of popup window in pixels. Default is 320.</td>
</tr>
<tr>
<td><strong>[height]</strong></td>
<td>Height of popup window in pixels. Default is 200.</td>
</tr>
</tbody>
</table>
</p>
<p>
Variables within the &quot;html&quot; value above are replaced with internal TinyMCE values. There are two types of variables one is the ones starting with the &quot;lang_&quot; prefix, these are replaced with the matching names in the language packs. So for example &lt;b&gt;{$lang_test}&lt;/b&gt; gets replaces with the &quot;tinyMCELang['lang_test']&quot; variable and the output is then &lt;b&gt;Test&lt;/b&gt;. The other variables are passed expicilty for the template used and these are listed below. Notice: Variables within [] characters are optional.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Variables/Window arguments:</td>
</tr>
</thead>
<tbody>
<tr>
<td><strong>[href]</strong></td>
<td>This variable gets replaced with the &quot;href&quot; attribute value of the selected link if one is selected.</td>
</tr>
<tr>
<td><strong>[target]</strong></td>
<td>This variable gets replaced with the &quot;target&quot; attribute value of the selected link if one is selected.</td>
</tr>
<tr>
<td><strong>[css]</strong></td>
<td>Theme popup css location.</td>
</tr>
</tbody>
</table>
</p>
<p>
Notice: There are a javascript function that can be called from this template &quot;window.opener.tinyMCE.insertLink(href, target)&quot; this inserts the link into the currently selected editor and should be called when for example a insert button is pressed.
</p>
<div class="separator"></div>
<h3>The TinyMCE_&lt;theme&gt;_getInsertImageTemplate(settings) function</h3>
<p>
This function is responsible for the layout of the insert image dialog, it should return a name/value based array with some specific names. These are explained below, notice names included in [] characters are optional. The settings parameter to this function is a name/value array containing tinyMCE:s settings/options.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Template data</td>
</tr>
</thead>
<tbody>
<tr>
<td><strong>html</strong></td>
<td>HTML template data, this value should contain all the HTML code needed to render the image dialog. Notice: {$&lt;variable&gt;} are replaces with values when used. More about these specific values later on. This parameter is not needed if the &quot;file&quot; param is assigned.</td>
</tr>
<tr>
<td><strong>[width]</strong></td>
<td>Width of popup window in pixels. Default is 320.</td>
</tr>
<tr>
<td><strong>[height]</strong></td>
<td>Height of popup window in pixels. Default is 200.</td>
</tr>
</tbody>
</table>
</p>
<p>
Variables within the &quot;html&quot; value above are replaced with internal TinyMCE values. There are two types of variables one is the ones starting with the &quot;lang_&quot; prefix, these are replaced with the matchin names in the language packs. So for example &lt;b&gt;{$lang_test}&lt;/b&gt; gets replaces with the &quot;tinyMCELang['lang_test']&quot; variable and the output is then &lt;b&gt;Test&lt;/b&gt;. The other variables are passed expicilty for the template used and these are listed below. Notice: Variables within [] characters are optional.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Variables/Window arguments</td>
</tr>
</thead>
<tbody>
<tr>
<td><strong>[src]</strong></td>
<td>This variable gets replaced with the &quot;src&quot; attribute value of the selected link if one is selected.</td>
</tr>
<tr>
<td><strong>[alt]</strong></td>
<td>This variable gets replaced with the &quot;alt&quot; attribute value of the selected link if one is selected.</td>
</tr>
<tr>
<td><strong>[border]</strong></td>
<td>This variable gets replaced with the &quot;border&quot; attribute value of the selected link if one is selected.</td>
</tr>
<tr>
<td><strong>[hspace]</strong></td>
<td>This variable gets replaced with the &quot;hspace&quot; attribute value of the selected link if one is selected.</td>
</tr>
<tr>
<td><strong>[vspace]</strong></td>
<td>This variable gets replaced with the &quot;vspace&quot; attribute value of the selected link if one is selected.</td>
</tr>
<tr>
<td><strong>[width]</strong></td>
<td>This variable gets replaced with the &quot;width&quot; attribute value of the selected link if one is selected.</td>
</tr>
<tr>
<td><strong>[height]</strong></td>
<td>This variable gets replaced with the &quot;height&quot; attribute value of the selected link if one is selected.</td>
</tr>
<tr>
<td><strong>[align]</strong></td>
<td>This variable gets replaced with the &quot;align&quot; attribute value of the selected link if one is selected.</td>
</tr>
<tr>
<td><strong>[css]</strong></td>
<td>Theme popup css location.</td>
</tr>
</tbody>
</table>
</p>
<p>
Notice: There are a javascript function that can be called from this template &quot;window.opener.tinyMCE.insertImage(src, alt, border, hspace, vspace, width, height, align)&quot; this inserts the image into the currently selected editor and should be called when for example a insert button is pressed.
</p>
<div class="separator"></div>
<h3>The TinyMCE_&lt;theme&gt;_handleNodeChange function (Optional)</h3>
<p>
This function is called when the cursor/selection of a editor instance changes. Then the currenly selected/focused node is passed to this function. This can be useful when you want to change the UI depending on what the user has selected.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td><strong>editor_id</strong></td>
<td>Unique editor id, this is the same as the $editor_id variable in getEditorTemplate.</td>
</tr>
<tr>
<td><strong>node</strong></td>
<td>Reference to the Node element where the cursor is currenly located.</td>
</tr>
<tr>
<td><strong>undo_index</strong></td>
<td>Current undo index, this value is -1 if the custom undo/redo support is disabled.</td>
</tr>
<tr>
<td><strong>undo_levels</strong></td>
<td>Current number of undo levels, this value is -1 if the custom undo/redo support is disabled.</td>
</tr>
<tr>
<td><strong>visual_aid</strong></td>
<td>True/false state of visual aid/guidelines mode.</td>
</tr>
<tr>
<td><strong>any_selection</strong></td>
<td>Is any text or image selected.</td>
</tr>
</tbody>
</table>
</p>
<div class="separator"></div>
<h3>The TinyMCE_&lt;theme&gt;_execCommand function (Optional)</h3>
<p>
This function is called when a command is executed for example &quot;bold&quot; or &quot;createlink&quot; this callback/theme function may then intercept theme specific commands and do custom logic. If this command returns true the command handling is terminated and the default tinyMCE command handeling never gets executed.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td><strong>editor_id</strong></td>
<td>Unique editor id, this is the same as the $editor_id variable in getEditorTemplate.</td>
</tr>
<tr>
<td><strong>element</strong></td>
<td>Reference to the document DOM root element of the editor instance.</td>
</tr>
<tr>
<td><strong>command</strong></td>
<td>Command that is to be executed for example &quot;myCommand&quot;.</td>
</tr>
<tr>
<td><strong>user_interface</strong></td>
<td>true/false option if a user insterace is to be used or not.</td>
</tr>
<tr>
<td><strong>value</strong></td>
<td>Custom data value passed with command, may be any data type.</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: <br />
true - Command intercepted and handled do not continue with command handling.<br />
false - Continue with execCommand handling, bubble.<br />
</p>
<div class="separator"></div>
<h3>The TinyMCE_&lt;theme&gt;_getControlHTML(control_name) function (Optional)</h3>
<p>
This function is called when a editor needs to render a specific control/button. This function should return the HTML template of that control or a empty string if the control_name wasn't recognized. Notice the variable {$pluginurl} gets replaced with the URL prefix for the current plugin directory.
</p>
<p>
<table border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<td colspan="2">Parameters</td>
</tr>
</thead>
<tbody>
<tr>
<td><strong>control_name</strong></td>
<td>Control name to match against.</td>
</tr>
</tbody>
</table>
</p>
<p>
Returns: return the HTML template of that control or a empty string if the control_name wasn't recognized.
</p>
</div>
<div class="footer">
<div class="helpindexlink"><a href="index.html">Index</a></div>
<div class="copyright">Copyright &copy; 2005 Moxiecode Systems AB</div>
<div class="copyright">Copyright &copy; 2003-2006 <a href="http://www.moxiecode.com">Moxiecode Systems AB</a></div>
<br style="clear: both" />
</div>