# tinymce

Class | tinymce
Type | Singleton

Core namespace with core functionality for the TinyMCE API all sub classes will be added to this namespace/object.

#### Example

## Public Properties

Property | Defined By
--- | ---
activeEditor : Editor Currently active editor instance. | tinymce
baseURI : URI Absolute baseURI for the installation path of TinyMCE. | tinymce
editors : Object Collection of editor instances. | tinymce
i18n : Object Collection of language pack data. | tinymce
isAir : Boolean [static] Constant that is true if the runtime is Adobe Air. | tinymce
isGecko : Boolean [static] Constant that is true if the browser is Gecko. | tinymce
isIDevice : Boolean [static] Constant that tells if the current browser is an iPhone or iPad. | tinymce
isIE : Boolean [static] Constant that is true if the browser is IE. | tinymce
isIE6 : Boolean [static] Constant that is true if the browser is IE 6 or older. | tinymce
isIE7 : Boolean [static] Constant that is true if the browser is IE 7. | tinymce
isIE8 : Boolean [static] Constant that is true if the browser is IE 8. | tinymce
isIE9 : Boolean [static] Constant that is true if the browser is IE 9. | tinymce
isIOS5 : Boolean [static] Constant that is true if the current browser is running on iOS 5 or greater. | tinymce
isMac : Boolean [static] Constant that is true if the os is Mac OS. | tinymce
isOpera : Boolean [static] Constant that is true if the browser is Opera. | tinymce
isWebKit : Boolean [static] Constant that is true if the browser is WebKit (Safari/Chrome). | tinymce
majorVersion : String [static] Major version of TinyMCE build. | tinymce
minorVersion : String [static] Major version of TinyMCE build. | tinymce
releaseDate : String [static] Release date of TinyMCE build. | tinymce

## Public Methods

Method | Defined By
--- | ---
add(editor:Editor):Editor Adds an editor instance to the editor collection. | tinymce
addI18n(p:String, o:Object):void Adds a language pack, this gets called by the loaded language files like en. | tinymce
addUnload(f:function, s:Object):function [static] Adds an unload handler to the document. | tinymce
create(s:String, p:Object, root:Object):void [static] Creates a class, subclass or static singleton. | tinymce
createNS(n:String, o:Object):Object [static] Creates a namespace on a specific object. | tinymce
each(o:Object, cb:function, s:Object):void [static] Performs an iteration of all items in a collection such as an object or array. | tinymce
execCommand(c:String, u:Boolean, v:String):Boolean Executes a specific command on the currently active editor. | tinymce
execInstanceCommand(id:String, c:String, u:Boolean, v:String):Boolean Deprecated: Use the execCommand method of a editor instance instead. | tinymce
explode(s:string, d:string):void [static] Splits a string but removes the whitespace before and after each value. | tinymce
extend(obj:Object, ext..n:Object):Object [static] Extends an object with the specified other object(s). | tinymce
get(id:String/Number):Editor Returns a editor instance by id. | tinymce
getInstanceById(id:String):Editor Deprecated: Use get method instead. | tinymce
grep(a:Array, f:function):Array [static] Filters out items from the input array by calling the specified function for each item. | tinymce
inArray(a:Array, v:Object):Number/String [static] Returns the index of a value in an array, this method will return -1 if the item wasn't found. | tinymce
init(s:Object):void Initializes a set of editors. | tinymce
is(o:Object, t:string):Boolean [static] Checks if a object is of a specific type for example an array. | tinymce
makeMap(items:Array/String, delim:String, map:Object):Object [static] Makes a name/object map out of an array with names. | tinymce
map(a:Array, f:function):Array [static] Creates a new array by the return value of each iteration function call. | tinymce
remove(e:Editor):Editor Removes a editor instance from the collection. | tinymce
removeUnload(f:function):function [static] Removes the specified function form the unload handler list. | tinymce
resolve(n:String, o:Object):Object [static] Resolves a string and returns the object from a specific structure. | tinymce
triggerSave():void Calls the save method on all editor instances in the collection. | tinymce
trim(s:String):String [static] Removes whitespace from the beginning and end of a string. | tinymce
walk(o:Object, f:function, n:String, s:String):void [static] Executed the specified function for each item in a object tree. | tinymce

## Public Events

Event | Defined By
--- | ---
onAddEditor(sender:tinymce, editor:Editor) Fires when a new editor instance is added to the tinymce collection. | tinymce
onRemoveEditor(sender:tinymce, editor:Editor) Fires when an editor instance is removed from the tinymce collection. | tinymce

## Property details

### activeEditorproperty

`public activeEditor : Editor`
Currently active editor instance.

#### Example

### baseURIproperty

`public baseURI : URI`
Absolute baseURI for the installation path of TinyMCE.

### editorsproperty

`public editors : Object`
Collection of editor instances.

#### Example

### i18nproperty

`public i18n : Object`
Collection of language pack data.

### isAirproperty

`public static isAir : Boolean`
Constant that is true if the runtime is Adobe Air.

### isGeckoproperty

`public static isGecko : Boolean`
Constant that is true if the browser is Gecko.

### isIDeviceproperty

`public static isIDevice : Boolean`
Constant that tells if the current browser is an iPhone or iPad.

### isIEproperty

`public static isIE : Boolean`
Constant that is true if the browser is IE.

### isIE6property

`public static isIE6 : Boolean`
Constant that is true if the browser is IE 6 or older.

### isIE7property

`public static isIE7 : Boolean`
Constant that is true if the browser is IE 7.

### isIE8property

`public static isIE8 : Boolean`
Constant that is true if the browser is IE 8.

### isIE9property

`public static isIE9 : Boolean`
Constant that is true if the browser is IE 9.

### isIOS5property

`public static isIOS5 : Boolean`
Constant that is true if the current browser is running on iOS 5 or greater.

### isMacproperty

`public static isMac : Boolean`
Constant that is true if the os is Mac OS.

### isOperaproperty

`public static isOpera : Boolean`
Constant that is true if the browser is Opera.

### isWebKitproperty

`public static isWebKit : Boolean`
Constant that is true if the browser is WebKit (Safari/Chrome).

### majorVersionproperty

`public static majorVersion : String`
Major version of TinyMCE build.

### minorVersionproperty

`public static minorVersion : String`
Major version of TinyMCE build.

### releaseDateproperty

`public static releaseDate : String`
Release date of TinyMCE build.

## Method details

### addmethod

`public function add(editor:Editor):Editor`
Adds an editor instance to the editor collection. This will also set it as the active editor.

#### Parameters

editor:Editor | Editor instance to add to the collection.

#### Returns

Editor - The same instance that got passed in.

### addI18nmethod

`public function addI18n(p:String, o:Object):void`
Adds a language pack, this gets called by the loaded language files like en.js.

#### Parameters

p:String | Prefix for the language items. For example en.myplugin
o:Object | Name/Value collection with items to add to the language group.

### addUnloadmethod

`public static function addUnload(f:function, s:Object):function`
Adds an unload handler to the document. This handler will be executed when the document gets unloaded. This method is useful for dealing with browser memory leaks where it might be vital to remove DOM references etc.

#### Parameters

f:function | Function to execute before the document gets unloaded.
s:Object | Optional scope to execute the function in.

#### Returns

function - Returns the specified unload handler function.

#### Example

### createmethod

`public static function create(s:String, p:Object, root:Object):void`
Creates a class, subclass or static singleton. More details on this method can be found in the Wiki.

#### Parameters

s:String | Class name, inheritage and prefix.
p:Object | Collection of methods to add to the class.
root:Object | Optional root object defaults to the global window object.

#### Example

### createNSmethod

`public static function createNS(n:String, o:Object):Object`
Creates a namespace on a specific object.

#### Parameters

n:String | Namespace to create for example a.b.c.d.
o:Object | Optional object to add namespace to, defaults to window.

#### Returns

Object - New namespace object the last item in path.

#### Example

### eachmethod

`public static function each(o:Object, cb:function, s:Object):void`
Performs an iteration of all items in a collection such as an object or array. This method will execure the callback function for each item in the collection, if the callback returns false the iteration will terminate. The callback has the following format: cb(value, key_or_index).

#### Parameters

o:Object | Collection to iterate.
cb:function | Callback function to execute for each item.
s:Object | Optional scope to execute the callback in.

#### Example

### execCommandmethod

`public function execCommand(c:String, u:Boolean, v:String):Boolean`
Executes a specific command on the currently active editor.

#### Parameters

c:String | Command to perform for example Bold.
u:Boolean | Optional boolean state if a UI should be presented for the command or not.
v:String | Optional value parameter like for example an URL to a link.

#### Returns

Boolean - true/false if the command was executed or not.

### execInstanceCommandmethod

`public function execInstanceCommand(id:String, c:String, u:Boolean, v:String):Boolean`
Deprecated: Use the execCommand method of a editor instance instead.
Executes a command on a specific editor by id. This method was added for compatibility with the 2.x branch.

#### Parameters

id:String | Editor id to perform the command on.
c:String | Command to perform for example Bold.
u:Boolean | Optional boolean state if a UI should be presented for the command or not.
v:String | Optional value parameter like for example an URL to a link.

#### Returns

Boolean - true/false if the command was executed or not.

### explodemethod

`public static function explode(s:string, d:string):void`
Splits a string but removes the whitespace before and after each value.

#### Parameters

s:string | String to split.
d:string | Delimiter to split by.

#### Example

### extendmethod

`public static function extend(obj:Object, ext..n:Object):Object`
Extends an object with the specified other object(s).

#### Parameters

obj:Object | Object to extend with new items.
ext..n:Object | Object(s) to extend the specified object with.

#### Returns

Object - o New extended object, same reference as the input object.

#### Example

### getmethod

`public function get(id:String/Number):Editor`
Returns a editor instance by id.

#### Parameters

id:String/Number | Editor instance id or index to return.

#### Returns

Editor - Editor instance to return.

#### Example

### getInstanceByIdmethod

`public function getInstanceById(id:String):Editor`
Deprecated: Use get method instead.
Returns a editor instance by id. This method was added for compatibility with the 2.x branch.

#### Parameters

id:String | Editor instance id to return.

#### Returns

Editor - Editor instance to return.

#### See Also

- get

### grepmethod

`public static function grep(a:Array, f:function):Array`
Filters out items from the input array by calling the specified function for each item. If the function returns false the item will be excluded if it returns true it will be included.

#### Parameters

a:Array | Array of items to loop though.
f:function | Function to call for each item. Include/exclude depends on it's return value.

#### Returns

Array - New array with values imported and filtered based in input.

#### Example

### inArraymethod

`public static function inArray(a:Array, v:Object):Number/String`
Returns the index of a value in an array, this method will return -1 if the item wasn't found.

#### Parameters

a:Array | Array/Object to search for value in.
v:Object | Value to check for inside the array.

#### Returns

Number/String - Index of item inside the array inside an object. Or -1 if it wasn't found.

#### Example

### initmethod

`public function init(s:Object):void`
Initializes a set of editors. This method will create a bunch of editors based in the input.

#### Parameters

s:Object | Settings object to be passed to each editor instance.

#### Example

### ismethod

`public static function is(o:Object, t:string):Boolean`
Checks if a object is of a specific type for example an array.

#### Parameters

o:Object | Object to check type of.
t:string | Optional type to check for.

#### Returns

Boolean - true/false if the object is of the specified type.

### makeMapmethod

`public static function makeMap(items:Array/String, delim:String, map:Object):Object`
Makes a name/object map out of an array with names.

#### Parameters

items:Array/String | Items to make map out of.
delim:String | Optional delimiter to split string by.
map:Object | Optional map to add items to.

#### Returns

Object - Name/value map of items.

### mapmethod

`public static function map(a:Array, f:function):Array`
Creates a new array by the return value of each iteration function call. This enables you to convert one array list into another.

#### Parameters

a:Array | Array of items to iterate.
f:function | Function to call for each item. It's return value will be the new value.

#### Returns

Array - Array with new values based on function return values.

### removemethod

`public function remove(e:Editor):Editor`
Removes a editor instance from the collection.

#### Parameters

e:Editor | Editor instance to remove.

#### Returns

Editor - The editor that got passed in will be return if it was found otherwise null.

### removeUnloadmethod

`public static function removeUnload(f:function):function`
Removes the specified function form the unload handler list.

#### Parameters

f:function | Function to remove from unload handler list.

#### Returns

function - Removed function name or null if it wasn't found.

### resolvemethod

`public static function resolve(n:String, o:Object):Object`
Resolves a string and returns the object from a specific structure.

#### Parameters

n:String | Path to resolve for example a.b.c.d.
o:Object | Optional object to search though, defaults to window.

#### Returns

Object - Last object in path or null if it couldn't be resolved.

#### Example

### triggerSavemethod

`public function triggerSave():void`
Calls the save method on all editor instances in the collection. This can be useful when a form is to be submitted.

#### Example

### trimmethod

`public static function trim(s:String):String`
Removes whitespace from the beginning and end of a string.

#### Parameters

s:String | String to remove whitespace from.

#### Returns

String - New string with removed whitespace.

### walkmethod

`public static function walk(o:Object, f:function, n:String, s:String):void`
Executed the specified function for each item in a object tree.

#### Parameters

o:Object | Object tree to walk though.
f:function | Function to call for each item.
n:String | Optional name of collection inside the objects to walk for example childNodes.
s:String | Optional scope to execute the function in.

## Event details

### onAddEditorevent

`public event onAddEditor(sender:tinymce, editor:Editor)`
Fires when a new editor instance is added to the tinymce collection.

#### Parameters

sender:tinymce | TinyMCE root class/namespace.
editor:Editor | Editor instance.

#### Example

### onRemoveEditorevent

`public event onRemoveEditor(sender:tinymce, editor:Editor)`
Fires when an editor instance is removed from the tinymce collection.

#### Parameters

sender:tinymce | TinyMCE root class/namespace.
editor:Editor | Editor instance.