webgui/www/extras/tinymce/docs/themes.htm
2004-12-16 17:34:32 +00:00

505 lines
23 KiB
HTML
Executable file

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Creating themes</TITLE>
<link href="style.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY>
<table width="100%" border="0" cellpadding="1" cellspacing="3" class="pageheader">
<tr>
<td class="title">Creating themes and plugins</td>
<td align="right"><a href="index.htm">TOC</a></td>
</tr>
</table>
<hr noshade>
<br>
<span class="subtitle">Creating your own Themes and plugins</span><br>
<br>
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;.<br>
<br>
The example below has three functions, these are explained in greater detail below.<br>
<br>
<table border="0" cellspacing="3" cellpadding="2" class="sample">
<tr>
<td class="samplecontent">function TinyMCE_<font color="#CC0000">default</font>_getEditorTemplate(settings)
{<br>
&nbsp;&nbsp;&nbsp;var template = new Array();<br>
<br> &nbsp;&nbsp;&nbsp;template['html'] = '&lt;Some HTML&gt;';<br>
&nbsp;&nbsp;&nbsp;template['delta_width'] = 0;<br>
&nbsp;&nbsp;&nbsp;template['delta_height'] = -40;<br>
<br>
&nbsp;&nbsp;&nbsp;return template;<br>
}
<p>function TinyMCE_<font color="#CC0000">default</font>_getInsertLinkTemplate(settings)
{<br>
&nbsp;&nbsp;&nbsp;var template = new Array();<br>
<br>
&nbsp;&nbsp;&nbsp;template['file'] = 'link.htm';<br>
&nbsp;&nbsp;&nbsp;template['width'] = 320;<br>
&nbsp;&nbsp;&nbsp;template['height'] = 130;<br>
<br>
&nbsp;&nbsp;&nbsp;return template;<br>
}<br>
<br>
function TinyMCE_<font color="#CC0000">default</font>_getInsertImageTemplate(settings)
{<br>
&nbsp;&nbsp;&nbsp;var template = new Array();<br>
<br>
&nbsp;&nbsp;&nbsp;template['file'] = 'image.htm';<br>
&nbsp;&nbsp;&nbsp;template['width'] = 320;<br>
&nbsp;&nbsp;&nbsp;template['height'] = 130;<br>
<br>
&nbsp;&nbsp;&nbsp;return template;<br>
}<br>
<br>
function TinyMCE_<font color="#CC0000">default</font>_handleNodeChange(editor_id,
node) {<br>
&nbsp;&nbsp;&nbsp;// Check what happend<br>
}<br>
<br>
function TinyMCE_<font color="#CC0000">default</font>_execCommand(editor_id, element, command, user_interface, value)
{<br>
&nbsp;&nbsp;&nbsp;//
Your custom command logic<br>
&nbsp;&nbsp;&nbsp;return false; <br>
}
<br>
</p>
</td>
</tr>
</table>
<br>
<hr noshade>
<p class="subtitle">Using external template files</p>
<p>When using external template files, with the argument called &quot;file&quot; desribed below, you need to include the &quot;tiny_mce_popup.js&quot;. This file is needed inorder to communicate with TinyMCE, all variables and language definitions gets replaced as in the &quot;html&quot; attribute.
</p>
Example of external template file:
<br>
<br>
<table border="0" cellspacing="3" cellpadding="2" class="sample">
<tr>
<td class="samplecontent">&lt;html&gt;<br>
&lt;head&gt;<br>
&lt;title&gt;<span class="failed">{$lang_theme_sample_title}</span>&lt;/title&gt;<br>
&lt;script language=&quot;javascript&quot; src=&quot;<span class="failed">../../tiny_mce_popup.js</span>&quot;&gt;&lt;/script&gt;<br>
&lt;script language=&quot;javascript&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(<span class="failed">tinyMCE.getWindowArg('some_arg')</span>);<br>
&lt;/script&gt;
<br>
&lt;body&gt;<br>
<span class="failed">{$lang_theme_sample_desc}</span><br>
&lt;/body&gt;
</td>
</tr>
</table>
<hr noshade>
<br>
<span class="subtitle">The TinyMCE_<font color="#CC0000">&lt;<font color="#CC0000">theme or plugin</font>&gt;</font>_getEditorTemplate(settings)
function</span></p>
<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>
<strong>Template data:<br>
<br>
</strong>
<table border="1" cellspacing="0">
<tr>
<td width="150"><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 width="150"><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 width="150"><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>
</table>
<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. <br>
<br>
<strong>Variables:</strong></p>
<table border="1" cellspacing="0">
<tr>
<td width="150"><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 width="150"><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>
</table>
<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 <a href="http://www.mozilla.org/editor/midas-spec.html" target="_blank">midas specification</a> and the <a href="using.htm#execcommand">TinyMCE specific commands</a>. <br>
</p>
<hr noshade>
<br>
<span class="subtitle">The TinyMCE_<font color="#CC0000">&lt;<font color="#CC0000">theme or plugin</font>&gt;</font>_getInsertLinkTemplate(settings)
function</span>
<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>
<strong>Template data:<br>
<br>
</strong>
<table border="1" cellspacing="0">
<tr>
<td width="150"><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 width="150"><strong>[width]</strong></td>
<td>Width of popup window in pixels. Default is 320.</td>
</tr>
<tr>
<td width="150"><strong>[height]</strong></td>
<td>Height of popup window in pixels. Default is 200.</td>
</tr>
</table>
<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. <br>
<br>
<strong>Variables/Window arguments:</strong></p>
<table border="1" cellspacing="0">
<tr>
<td width="150"><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 width="150"><strong>[css]</strong></td>
<td>Theme popup css location.</td>
</tr>
</table>
<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>
<hr noshade>
<br>
<span class="subtitle">The TinyMCE_<font color="#CC0000">&lt;<font color="#CC0000">theme or plugin</font>&gt;</font>_getInsertImageTemplate(settings)
function</span>
<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>
<strong>Template data:<br>
<br>
</strong>
<table border="1" cellspacing="0">
<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>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 width="150"><strong>[width]</strong></td>
<td>Width of popup window in pixels. Default is 320.</td>
</tr>
<tr>
<td width="150"><strong>[height]</strong></td>
<td>Height of popup window in pixels. Default is 200.</td>
</tr>
</table>
<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. <br>
<br>
<strong>Variables/Window arguments:</strong></p>
<table border="1" cellspacing="0">
<tr>
<td width="150"><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>
</table>
<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>
<hr noshade>
<br>
<span class="subtitle">The TinyMCE_<font color="#CC0000">&lt;<font color="#CC0000">theme or plugin</font>&gt;</font>_getInsertTableTemplate(settings) function</span>
<span class="subtitle">(Optional)</span>
<p>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. </p>
<strong>Template data:<br>
<br>
</strong>
<table border="1" cellspacing="0">
<tr>
<td><strong>html</strong></td>
<td>HTML template data, this value should contain all the HTML code needed to render the table 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 width="150"><strong>[width]</strong></td>
<td>Width of popup window in pixels.</td>
</tr>
<tr>
<td width="150"><strong>[height]</strong></td>
<td>Height of popup window in pixels.</td>
</tr>
</table>
<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. <br>
<br>
<strong>Variables/Window arguments:</strong></p>
<table border="1" cellspacing="0">
<tr>
<td width="150"><strong>[cols]</strong></td>
<td>This variable gets replaced with the number of columns in the table.</td>
</tr>
<tr>
<td><strong>[rows]</strong></td>
<td>This variable gets replaced with the number of rows in the table.</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>[cellpadding]</strong></td>
<td>This variable gets replaced with the &quot;cellpadding&quot; attribute value of the selected table if one is selected.</td>
</tr>
<tr>
<td><strong>[cellspacing]</strong></td>
<td>This variable gets replaced with the &quot;cellspacing&quot; attribute value of the selected table 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 table 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 table 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 table if one is selected.</td>
</tr>
<tr>
<td><strong>[action]</strong></td>
<td>Action type &quot;update&quot; or &quot;insert&quot; depending on if the user selected a table or want's to create a new one.</td>
</tr>
</table>
<br>
<hr noshade>
<span class="subtitle">The TinyMCE_<font color="#CC0000">&lt;<font color="#CC0000">theme or plugin</font>&gt;</font>_handleNodeChange
function (Optional)</span>
<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>
<strong>Parameters:<br>
<br>
</strong>
<table border="1" cellspacing="0">
<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 width="150"><strong>any_selection</strong></td>
<td>Is any text or image selected.</td>
</tr>
</table>
<br>
<hr noshade>
<span class="subtitle">The TinyMCE_<font color="#CC0000">&lt;<font color="#CC0000">theme or plugin</font>&gt;</font>_execCommand function (Optional)</span>
<p>This function is called when a command is executed for example &quot;bold&quot; or &quot;createlink&quot; 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. </p>
<strong>Parameters:<br>
<br>
</strong>
<table border="1" cellspacing="0">
<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 width="150"><strong>value</strong></td>
<td>Custom data value passed with command, may be any data type.</td>
</tr>
</table>
<br>
<strong>Returns:</strong> true - Command intercepted and handled do not continue with command handling. false - Continue with execCommand handling, bubble. <br>
<hr noshade>
<span class="subtitle">The TinyMCE_<font color="#CC0000">&lt;theme or plugin&gt;</font>_getControlHTML(control_name) function (Optional)</span>
<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>
<strong>Parameters:<br>
<br>
</strong>
<table border="1" cellspacing="0">
<tr>
<td width="150"><span class="subtitle">control_name</span></td>
<td>Control name to match agains for example &quot;iespell&quot; for the iespell plugin.</td>
</tr>
</table>
<br>
<strong>Returns:</strong> return the HTML template of that control or a empty string if the control_name wasn't recognized.
<hr noshade>
<span class="subtitle"><a name="cleanup"></a>The TinyMCE_<font color="#CC0000">&lt;plugin&gt;</font>_cleanup(type, content) function (Optional)</span>
<p>This function is called when a editor does cleanup of contents.</p>
<strong>Parameters:<br>
<br>
</strong>
<table border="1" cellspacing="0">
<tr>
<td><span class="subtitle">type</span></td>
<td>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. </td>
</tr>
<tr>
<td width="150"><strong>content</strong></td>
<td>HTML contents to be cleaned up, this string contains the HTML code. </td>
</tr>
</table>
<br>
<strong>Returns:</strong> return the cleaned up HTML code.<br>
<hr noshade>
<table width="100%" border="0" cellpadding="1" cellspacing="3" class="pagefooter">
<tr>
<td>Go to: <a href="index.htm">Table of contents</a></td>
<td align="right"><a href="#">Top</a></td>
</tr>
</table>
<br>
</BODY>
</HTML>