This is for advanced users, TinyMCE has a global instance with some public functions that can be called from the page.
tinyMCE.triggerSave([skip_cleanup], [skip_callback]);
Makes a cleanup and moves the contents from the editor to the form field. This method is automaticly called by tinyMCE by adding a trigger on the forms submit method.
Parameters | |
[skip_cleanup] | Disables the cleanup process of trigger save. Defaults to false. (Optional) |
[skip_callback] | Disables the execution of the save_callback function. Defaults to false. (Optional) |
Returns: Nothing
tinyMCE.updateContent(form_element_name);
Moves the contents from the form element to the editor, this does the opposite of triggerSave(). This method can be used when you want to change the contents of the editor dynamicly.
Parameters | |
form_element_name | The name of the form element to get contents from. |
Returns: Nothing
tinyMCE.execInstanceCommand(editor_id, command, [user_interface], [value]);
This method executes a command by name on the editor instance specified by the editor_id parameter.
Parameters | |
editor_id | ID of editor instance or element id/name of the replaced element. |
command | Command to execute check the execCommand function for details. |
[user_interface] | Is a user interface to be used or not. |
[value] | Value to pass with command for example a URL.. |
Returns: Nothing
tinyMCE.execCommand(command, [user_interface], [value]);
This method executes a command by name on the selected editor instance.
Parameters | |||||||||||||||||||||||||||||||||||||
command | Command to execute for example "Bold" or "Italic". These are defined by Mozilla Midas specification or Microsoft specification. But there are a some TinyMCE specific commands many other commands are available within plugins and themes.
|
||||||||||||||||||||||||||||||||||||
[user_interface] | Tells if the command is to display a user interface or not. True/False option. | ||||||||||||||||||||||||||||||||||||
[value] | Value to pass for the command for example to insertLink it's the URL of the link. |
Returns: Nothing
Example:
<a href="javascript:tinymce.execCommand('Bold');">[Do bold]</a>
(Deprecated) tinyMCE.insertLink(href, target);
This method is deprecated and removed as of 2.0.3. Use tinyMCE.execCommand('mceInsertContent',false,'custom html'); instead and tinyMCE.getInstanceById('<inst>').selection.getFocusElement() to retrive/update the selected element.
But if you realy need the old function it's marked internal but is available in the advanced theme and you can call it by using tinyMCE.themes['advanced']._insertLink(href, target);. But the recommended way is to modify your code to use the logic above.
This method inserts a link a the cursor position of the selected editor instance or updates the selected link with new data. This method should be called upon "ok" in the insertLink popup when you create custom themes.
Parameters | |
href | HREF/URL of the link. |
target | Target of the link. |
Returns: Nothing
(Deprecated) tinyMCE.insertImage(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout);
This method is deprecated and removed as of 2.0.3. Use tinyMCE.execCommand('mceInsertContent',false,'custom html'); instead or if you realy need the old function it's marked internal but is available in the advanced theme and you can call it by using tinyMCE.themes['advanced']._insertImage(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout);. But the recommended way is to modify your code to use the logic above.
This method inserts a image a the cursor position of the selected editor instance or updates the selected image with new data. This method should be called upon "ok" in the insertImage popup when you create custom themes.
Parameters | |
src | Image src url. |
alt | Alternative text of img element. |
border | Border of image element. |
hspace | Horizontal spacing of image element. |
vspace | Vertical spacing of image element. |
width | Width of image element. |
height | Height of image element. |
align | Alignment of image element. |
title | Link title of image element. |
onmouseover | On mouse over event handler of image element. |
onmouseout | On mouse out event handler of image element. |
Returns: Nothing
tinyMCE.triggerNodeChange();
This method is to be called when external changes is made to the editor. This method will then call the "handleNodeChangeCallback" callback in the theme.
Parameters:
None
Returns: Nothing
tinyMCE.getContent();
This method returns the HTML contents of the currently selected editor or null if no editor was selected.
Parameters:
None
Returns: HTML contents of the currently selected editor or null.
Syntax: tinyMCE.setContent(html);
This method sets the HTML contents of the currently selected editor.
Parameters | |
html | HTML Source code to set. |
Returns: None.
tinyMCE.getInstanceById(editor_id);
This method returns a editor instance by editor id.
Parameters | |
editor_id | Editor instance to retrive. |
Returns: TinyMCE Editor instance (TinyMCE_Control).
tinyMCE.importThemeLanguagePack([theme]);
This method imports/loads theme specific language packs. This may be called from custom themes.
Parameters | |
[theme] | Name of the current theme. This is a optional parameter it defaults to the global "theme" setting. This parameter is useful within theme plugins. |
Returns: None.
tinyMCE.importPluginLanguagePack(plugin, valid_languages);
This method imports/loads plugin specific language packs. This may be called from custom plugins.
Parameters | |
plugin | Name of the current plugin. |
valid_languages | Comma separated list of supported languagepacks. |
Returns: None.
tinyMCE.applyTemplate(html);
This method replaces settings and lang variables in the theme.
Parameters | |
html | HTML code to apply theme variable substitution on. |
Returns: New converted, HTML code.
tinyMCE.openWindow(template, [args]);
This method opens a new window by the template data assigned, it will get the width, height and html data from template parameters. The args array contains variable names to be substituted.
There are some custom window arguments:
Parameters | |
mce_replacevariables | Enables/Disables the language/variable replacement of the document HTML. Enabled by default. |
mce_windowresize | Enables/Disables the auto resize feature of popupwindows. Enabled by default. |
Parameters | |
template | Name/Value array with width, height, html and file keys in it. |
[args] | Name/Value array with variable names to replace. Variables in the template file key value (URL) gets replaced with the argument list. |
Returns: None.
tinyMCE.getWindowArg(name, [default_value]);
This method returns a window argument defined by name. This function is to be used in theme popup windows to retrive dialog parameters.
Parameters | |
name | Name of window argument to get. |
[default_value] | Default value to be returned if window argument is missing. |
Returns: Window argument value.
tinyMCE.setWindowArg(name, value);
This method sets a window argument by name. This can for example be useful if plugin are to call other plugins.
Parameters | |
name | Name of window argument to set. |
value | Value to set in window argument. |
Returns: Window argument value.
tinyMCE.getParam(name, [default_value], [strip_whitespace]);
This method returns a TinyMCE configuration parameter.
Parameters: | |
name | Name of window argument to get. |
[default_value] | Default value to be returned if window argument is missing. |
[strip_whitespace] | If true all whitespace will be removed from return value, default: false. |
Returns: TinyMCE configuration parameter.