TinyMCE

Object
TinyMCE_Control

Class TinyMCE_Control

Field Summary
TinyMCE_Cleanupcleanup
Cleanup engine reference, handles all XHTML serialization and cleanup.
TinyMCE_Selectionselection
Contains methods for handling the current instance selection.
Arraysettings
Name/Value array containing all instance settings.
Constructor Summary
TinyMCE_Control(<Array> settings)
This is the TinyMCE editor control instance class.
Method Summary
voidaddPlugin(<string> n, <TinyMCE_Plugin> n)
Adds a plugin to the editor instance.
booleanaddShortcut(<string> m, <Object> k, <string> d, <string> cmd, <boolean> ui, <Object> va)
Adds a keyboard shortcut to a specific command.
voidautoResetDesignMode()
Auto resets the design mode of the document if it gets lost.
voidexecCommand(<string> command, <boolean> user_interface, <mixed> value)
Executes a command on the current instance.
HTMLElementgetBody()
Returns the body element of a editor instance.
DOMDocumentgetContainerWin()
Returns the container window of a editor instance.
ObjectgetData(<String> na)
Get custom data storage object by name.
DOMDocumentgetDoc()
Returns the DOM document of a editor instance.
HTMLElementgetFocusElement()
Returns the currently selected element.
stringgetHTML(<bool> r)
Returns the cleaned HTML of the editor control instance.
HTMLElementgetParentBlockElement(<HTMLNode> n)
Returns the first block element parent of the specified node.
HTMLElementgetParentElement(<HTMLNode> node, <string> na, <function> f)
Returns the parent element of the specified node based on the search criteria.
DOMNodegetParentNode(<DOMNode> n, <function> f)
Returns a node by the specified selector function.
DOMRangegetRng()
Returns the browsers selections first range instance.
DOMSelectiongetSel()
Returns the browsers selection instance.
ObjectgetViewPort()
Returns the viewport of the editor instance.
WindowgetWin()
Returns the window of a editor instance.
booleanhandleShortcut(<DOMEvent> e)
Executes shortcuts based on the event information.
booleanhasPlugin(<string> n)
Returns true/false if the instance has the current plugin available.
booleanisDirty()
Returns true/false if the editor instance is dirty or not.
booleanisHidden()
Returns if the instance is hidden or not.
booleanqueryCommandState(<string> c)
Returns a command specific state, for example if bold is enabled or not.
mixedqueryCommandValue(<string> c)
Returns a command specific value, for example the current font size.
voidrepaint()
Repaints the editarea in Gecko browsers.
voidresizeToContent()
Auto resizes the current editor instance to match the inner document size.
voidselect()
Selects this instance as the currently selected instance.
voidsetBaseHREF(<string> u)
Sets the base href url of the current document instance.
voidsetHTML(<string> h)
Sets the HTML contents of the instance.
voidswitchSettings()
Switches the global TinyMCE settings to the current instance settings.
voidtriggerSave(<boolean> skip_cleanup, <boolean> skip_callback)
Moves the contents from the TinyMCE editor control instance to the hidden textarea that got replaced with TinyMCE.

Field Detail

cleanup

TinyMCE_Cleanup cleanup
Cleanup engine reference, handles all XHTML serialization and cleanup.

selection

TinyMCE_Selection selection
Contains methods for handling the current instance selection.

settings

Array settings
Name/Value array containing all instance settings.

Constructor Detail

TinyMCE_Control

TinyMCE_Control(<Array> settings)
This is the TinyMCE editor control instance class. A instance of this class will is made for each converted text area.

Parameters

settings - Name/Value array of instance specific configuration settings.

Method Detail

addPlugin

void addPlugin(<string> n, <TinyMCE_Plugin> n)
Adds a plugin to the editor instance. This will also add it globaly.

Parameters

n - Plugin name to check for.
n - TinyMCE plugin instance.

addShortcut

boolean addShortcut(<string> m, <Object> k, <string> d, <string> cmd, <boolean> ui, <Object> va)
Adds a keyboard shortcut to a specific command. These shortcuts can for example be added at the initInstance callback of a plugin. The shortcut description can be a language variable name or a string describing the function. If you don't specify a command, the shortcut will simply be a blocker shortcut. This enables you to remove built in shortcuts or remove theme specific shortcuts from a plugin.
Example shortcut inst.addShortcut('ctrl,alt', 'k', 'mceSomeCommand', false, 'somevalue'); Example blocker inst.addShortcut('ctrl,alt', 'k');

Parameters

m - List of shortcut modifiers keys, for example "ctrl,alt".
k - Shortcut key char for example "s" or a keycode value "13".
d - Optional Shortcut description, this will be presented in the about dialog.
cmd - Optional Command name to execute, for example mceLink or Bold.
ui - Optional True/false state if a UI (dialog) should be presented or not.
va - Optional command value, this can be anything.

Returns

true/false if the shortcut was added or not

autoResetDesignMode

void autoResetDesignMode()
Auto resets the design mode of the document if it gets lost. This is a Gecko specific function since it's a workaround for a bug where Gecko browsers loose the designMode state if the editor is hidden and shown in a tab or div.

execCommand

void execCommand(<string> command, <boolean> user_interface, <mixed> value)
Executes a command on the current instance. These commands can be TinyMCE internal commands prefixed with "mce" or they can be build in browser commands such as "Bold". A compleate list of browser commands is available on MSDN or Mozilla.org. This function will dispatch the execCommand function on each plugin, theme or the execcommand_callback option if none of these return true it will handle the command as a internal browser command.

Parameters

command - Command name to execute, for example mceLink or Bold.
user_interface - True/false state if a UI (dialog) should be presented or not.
value - Optional command value, this can be anything.

getBody

HTMLElement getBody()
Returns the body element of a editor instance.

Returns

Body element of a editor instance.

getContainerWin

DOMDocument getContainerWin()
Returns the container window of a editor instance. The container window is the window where the current instance lives in.

Returns

container window of a editor instance.

getData

Object getData(<String> na)
Get custom data storage object by name. The name should be for example the theme name or plugin name. The custom data storage can be used to store plugin/theme specific information on a editor instance. A empty object will be created automaticly the first time called.

Parameters

na - Name of data storate to retrive.

Returns

Data storage object

getDoc

DOMDocument getDoc()
Returns the DOM document of a editor instance.

Returns

DOM document of a editor instance.

getFocusElement

HTMLElement getFocusElement()
Returns the currently selected element. This is was added for compatiblity and is deprecated. Please use inst.selection.getFocusElement instead.

Returns

Currently selected element.

getHTML

string getHTML(<bool> r)
Returns the cleaned HTML of the editor control instance.

Parameters

r - Optional raw parameter, if set to true. Cleanup will be skipped.

Returns

Cleaned HTML content string.

getParentBlockElement

HTMLElement getParentBlockElement(<HTMLNode> n)
Returns the first block element parent of the specified node. This method will not go below the point of the instance body.

Parameters

n - Node get parent block element for.

Returns

First block element parent of the specified node or null if it wasn't found.

getParentElement

HTMLElement getParentElement(<HTMLNode> node, <string> na, <function> f)
Returns the parent element of the specified node based on the search criteria. This method will not go below the point of the instance body.

Parameters

node - Node to get parent element of.
na - Comma separated list of element names to get.
f - Optional function to call for each node, if it returns true the node is valid.

Returns

HTMLElement or null based on search criteras.

getParentNode

DOMNode getParentNode(<DOMNode> n, <function> f)
Returns a node by the specified selector function. This function will loop through all parent nodes and call the specified function for each node. If the function then returns true it will stop the execution and return that node. This function will not go below the instance body element.

Parameters

n - HTML node to search parents on.
f - Selection function to execute on each node.

Returns

DOMNode or null if it wasn't found.

getRng

DOMRange getRng()
Returns the browsers selections first range instance. This is was added for compatiblity and is deprecated. Please use inst.selection.getRng instead.

Returns

Browsers selections first range instance.

getSel

DOMSelection getSel()
Returns the browsers selection instance. This is was added for compatiblity and is deprecated. Please use inst.selection.getSel instead.

Returns

Browser selection instance.

getViewPort

Object getViewPort()
Returns the viewport of the editor instance.

Returns

Viewport object with fields top, left, width and height.

getWin

Window getWin()
Returns the window of a editor instance.

Returns

Window of a editor instance.

handleShortcut

boolean handleShortcut(<DOMEvent> e)
Executes shortcuts based on the event information.

Parameters

e - Keyboard event to handle.

Returns

true/false if the shortcut was found and executed or not.

hasPlugin

boolean hasPlugin(<string> n)
Returns true/false if the instance has the current plugin available.

Parameters

n - Plugin name to check for.

Returns

true/false if the instance has the current plugin available.

isDirty

boolean isDirty()
Returns true/false if the editor instance is dirty or not. In other words if it has been modified or not.

Returns

Editor instance dirty state.

isHidden

boolean isHidden()
Returns if the instance is hidden or not. This is a Gecko specific function other browsers will always return false. This function is used to workaround the lost designMode bug in Gecko browsers.

Returns

Returns if the instance is hidden or not.

queryCommandState

boolean queryCommandState(<string> c)
Returns a command specific state, for example if bold is enabled or not.

Parameters

c - Command to query state from.

Returns

Command specific state, for example if bold is enabled or not.

queryCommandValue

mixed queryCommandValue(<string> c)
Returns a command specific value, for example the current font size.

Parameters

c - Command to query value from.

Returns

Command specific value, for example the current font size.

repaint

void repaint()
Repaints the editarea in Gecko browsers. This method removes ghost resize handlers and other trailing graphics.

resizeToContent

void resizeToContent()
Auto resizes the current editor instance to match the inner document size.

select

void select()
Selects this instance as the currently selected instance. This will also dispatch a selectInstance call to all themes, plugins and other listeners.

setBaseHREF

void setBaseHREF(<string> u)
Sets the base href url of the current document instance. This method is used to temporarly remove the base url during copy/paste and drag/drop operations of relative links from external sites into TinyMCE. MSIE has a bug and converts relative links from external sites to absolute links incorrectly.

Parameters

u - URL to set as base URL or null to remove it.

setHTML

void setHTML(<string> h)
Sets the HTML contents of the instance.

Parameters

h - HTML content string to replace body with.

switchSettings

void switchSettings()
Switches the global TinyMCE settings to the current instance settings. This method is used to handle multiple configurations.

triggerSave

void triggerSave(<boolean> skip_cleanup, <boolean> skip_callback)
Moves the contents from the TinyMCE editor control instance to the hidden textarea that got replaced with TinyMCE. This is executed automaticly on for example form submit unless you configure otherwice.

Parameters

skip_cleanup - Optional Skip cleanup, simply move the contents as fast as possible.
skip_callback - Optional Skip callback, don't call the save_callback function.