Creating themes and plugins | TOC |
function TinyMCE_default_getEditorTemplate(settings)
{ var template = new Array(); template['html'] = '<Some HTML>'; template['delta_width'] = 0; template['delta_height'] = -40; return template; } function TinyMCE_default_getInsertLinkTemplate(settings)
{ |
Using external template files
When using external template files, with the argument called "file" desribed below, you need to include the "tiny_mce_popup.js". This file is needed inorder to communicate with TinyMCE, all variables and language definitions gets replaced as in the "html" attribute.
Example of external template file:<html> <head> <title>{$lang_theme_sample_title}</title> <script language="javascript" src="../../tiny_mce_popup.js"></script> <script language="javascript"> alert(tinyMCE.getWindowArg('some_arg')); </script> <body> {$lang_theme_sample_desc} </body> |
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.
Template data:html | HTML template data, this value should contain all the HTML code needed to render the editor. Notice: {$<variable>} are replaces with values when used. More about these specific values later on. |
[delta_width] | 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. |
[delta_height] | 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. |
Variables within the "html" value above are replaced with internal
TinyMCE values. There are two types of variables one is the ones starting with
the "lang_" prefix, these are replaced with the matching names in
the language packs. So for example <b>{$lang_test}</b> gets replaces
with the "tinyMCELang['lang_test']" variable and the output is then
<b>Test</b>. The other variables are passed expicilty for the template
used and these are listed below. Notice: Variables within [] characters are
optional.
Variables:
editor_id | 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. |
[default_document] | 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. |
[area_width] | Width of IFRAME area in pixels. |
[area_height] | Height of IFRAME area in pixels. |
[width] | Width of the whole editor area in pixels. |
[height] | Height of the whole editor area in pixels. |
[themeurl] | URL to theme location |
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.
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.
Template data:html | HTML template data, this value should contain all the HTML code needed to render the link dialog. Notice: {$<variable>} are replaces with values when used. More about these specific values later on. This parameter is not needed if the "file" param is assigned. |
file | Name of external template file to use, this may even be logic pages like .php,.asp,.jsp etc. |
[width] | Width of popup window in pixels. Default is 320. |
[height] | Height of popup window in pixels. Default is 200. |
Variables within the "html" value above are replaced with internal
TinyMCE values. There are two types of variables one is the ones starting with
the "lang_" prefix, these are replaced with the matching names in
the language packs. So for example <b>{$lang_test}</b> gets replaces
with the "tinyMCELang['lang_test']" variable and the output is then
<b>Test</b>. The other variables are passed expicilty for the template
used and these are listed below. Notice: Variables within [] characters are
optional.
Variables/Window arguments:
[href] | This variable gets replaced with the "href" attribute value of the selected link if one is selected. |
[target] | This variable gets replaced with the "target" attribute value of the selected link if one is selected. |
[css] | Theme popup css location. |
Notice: There are a javascript function that can be called from this template "window.opener.tinyMCE.insertLink(href, target)" this inserts the link into the currently selected editor and should be called when for example a insert button is pressed.
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.
Template data:html | HTML template data, this value should contain all the HTML code needed to render the image dialog. Notice: {$<variable>} are replaces with values when used. More about these specific values later on. This parameter is not needed if the "file" param is assigned. |
file | Name of external template file to use, this may even be logic pages like .php,.asp,.jsp etc. |
[width] | Width of popup window in pixels. Default is 320. |
[height] | Height of popup window in pixels. Default is 200. |
Variables within the "html" value above are replaced with internal
TinyMCE values. There are two types of variables one is the ones starting with
the "lang_" prefix, these are replaced with the matchin names in the
language packs. So for example <b>{$lang_test}</b> gets replaces
with the "tinyMCELang['lang_test']" variable and the output is then
<b>Test</b>. The other variables are passed expicilty for the template
used and these are listed below. Notice: Variables within [] characters are
optional.
Variables/Window arguments:
[src] | This variable gets replaced with the "src" attribute value of the selected link if one is selected. |
[alt] | This variable gets replaced with the "alt" attribute value of the selected link if one is selected. |
[border] | This variable gets replaced with the "border" attribute value of the selected link if one is selected. |
[hspace] | This variable gets replaced with the "hspace" attribute value of the selected link if one is selected. |
[vspace] | This variable gets replaced with the "vspace" attribute value of the selected link if one is selected. |
[width] | This variable gets replaced with the "width" attribute value of the selected link if one is selected. |
[height] | This variable gets replaced with the "height" attribute value of the selected link if one is selected. |
[align] | This variable gets replaced with the "align" attribute value of the selected link if one is selected. |
[css] | Theme popup css location. |
Notice: There are a javascript function that can be called from this template "window.opener.tinyMCE.insertImage(src, alt, border, hspace, vspace, width, height, align)" this inserts the image into the currently selected editor and should be called when for example a insert button is pressed.
This function is responsible for the layout of the insert table 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.
Template data:html | HTML template data, this value should contain all the HTML code needed to render the table dialog. Notice: {$<variable>} are replaces with values when used. More about these specific values later on. This parameter is not needed if the "file" param is assigned. |
file | Name of external template file to use, this may even be logic pages like .php,.asp,.jsp etc. |
[width] | Width of popup window in pixels. |
[height] | Height of popup window in pixels. |
Variables within the "html" value above are replaced with internal TinyMCE values. There are two types of variables one is the ones starting with the "lang_" prefix, these are replaced with the matchin names in the language packs. So for example <b>{$lang_test}</b> gets replaces with the "tinyMCELang['lang_test']" variable and the output is then <b>Test</b>. The other variables are passed expicilty for the template used and these are listed below. Notice: Variables within [] characters are optional.
Variables/Window arguments:
[cols] | This variable gets replaced with the number of columns in the table. |
[rows] | This variable gets replaced with the number of rows in the table. |
[border] | This variable gets replaced with the "border" attribute value of the selected link if one is selected. |
[cellpadding] | This variable gets replaced with the "cellpadding" attribute value of the selected table if one is selected. |
[cellspacing] | This variable gets replaced with the "cellspacing" attribute value of the selected table if one is selected. |
[width] | This variable gets replaced with the "width" attribute value of the selected table if one is selected. |
[height] | This variable gets replaced with the "height" attribute value of the selected table if one is selected. |
[align] | This variable gets replaced with the "align" attribute value of the selected table if one is selected. |
[action] | Action type "update" or "insert" depending on if the user selected a table or want's to create a new one. |
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.
Parameters:editor_id | Unique editor id, this is the same as the $editor_id variable in getEditorTemplate. |
node | Reference to the Node element where the cursor is currenly located. |
undo_index | Current undo index, this value is -1 if the custom undo/redo support is disabled. |
undo_levels | Current number of undo levels, this value is -1 if the custom undo/redo support is disabled. |
visual_aid | True/false state of visual aid/guidelines mode. |
any_selection | Is any text or image selected. |
This function is called when a command is executed for example "bold" or "createlink" this callback/theme/plugin 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.
Parameters:editor_id | Unique editor id, this is the same as the $editor_id variable in getEditorTemplate. |
element | Reference to the document DOM root element of the editor instance. |
command | Command that is to be executed for example "myCommand". |
user_interface | true/false option if a user insterace is to be used or not. |
value | Custom data value passed with command, may be any data type. |
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.
Parameters:control_name | Control name to match agains for example "iespell" for the iespell plugin. |
This function is called when a editor does cleanup of contents.
Parameters:type | Type of cleanup, insert_to_editor or get_from_editor. Insert to editor is passed when new content is placed within the editor and get_from_editor is when content is passed out from the editor. |
content | HTML contents to be cleaned up, this string contains the HTML code. |
Go to: Table of contents | Top |