---
title: "tinymce"
description: "TinyMCE core class."
canonical_url: "https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.root/"
md_url: "https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.root/index.md"
version: "latest"
last_updated: "2025-08-14T03:11:33Z"
tokens: 3908
---
# tinymce

TinyMCE core class.

## Summary

### Properties

| Name | Type | Summary | Defined by |
| --- | --- | --- | --- |
| DOM | `DOMUtils` | Global DOM instance. | `tinymce` |
| PluginManager | `AddOnManager` | Global PluginManager instance. Instance of AddOnManager. | `tinymce` |
| ScriptLoader | `ScriptLoader` | Global ScriptLoader instance. | `tinymce` |
| ThemeManager | `AddOnManager` |  | `tinymce` |
| activeEditor | `Editor` | Currently active editor instance. | `tinymce` |
| baseURI | `URI` | Absolute baseURI for the installation path of TinyMCE. | `tinymce` |
| baseURL | `String` | Base URL where the root directory if TinyMCE is located. | `tinymce` |
| defaultOptions | `Object` | Object containing the options that will be passed by default to the `init` method upon each initialization of an editor. These defaults will be shallow merged with other options passed to `init`. | `tinymce` |
| documentBaseURL | `String` | Document base URL where the current document is located. | `tinymce` |
| i18n | `Object` | Collection of language pack data. | `tinymce` |
| majorVersion | `String` | Major version of TinyMCE build. | `tinymce` |
| minorVersion | `String` | Minor version of TinyMCE build. | `tinymce` |
| pageUid | `String` | A uuid string to anonymously identify the page tinymce is loaded in | `tinymce` |
| releaseDate | `String` | Release date of TinyMCE build. | `tinymce` |
| suffix | `String` | Current suffix to add to each plugin/theme that gets loaded for example ".min". | `tinymce` |

### Methods

| Name | Summary | Defined by |
| --- | --- | --- |
| [add()](#add) | Adds an editor instance to the editor collection. This will also set it as the active editor. | `tinymce` |
| [addI18n()](#addI18n) | Adds a language pack, this gets called by the loaded language files like en.js. | `tinymce` |
| [createEditor()](#createEditor) | Creates an editor instance and adds it to the EditorManager collection. | `tinymce` |
| [each()](#each) | Performs an iteration of all items in a collection such as an object or array. This method will execute 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)`. | `tinymce` |
| [execCommand()](#execCommand) | Executes a specific command on the currently active editor. | `tinymce` |
| [explode()](#explode) | Splits a string but removes the whitespace before and after each value. | `tinymce` |
| [get()](#get) | Returns an editor instance for a given id. | `tinymce` |
| [grep()](#grep) | 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. | `tinymce` |
| [hasOwnProperty()](#hasOwnProperty) | JavaScript does not protect hasOwnProperty method, so it is possible to overwrite it. This is
an object independent version.
Checks if the input object `obj` has the property `prop`. | `tinymce` |
| [inArray()](#inArray) | Returns an index of the item or -1 if item is not present in the array. | `tinymce` |
| [init()](#init) | Initializes a set of editors. This method will create editors based on various settings.

For information on basic usage of `init`, see: [Basic setup](/docs/tinymce/8/basic-setup/). | `tinymce` |
| [is()](#is) | Checks if a object is of a specific type for example an array. | `tinymce` |
| [isArray()](#isArray) | Returns true/false if the object is an array or not. | `tinymce` |
| [makeMap()](#makeMap) | Makes a name/object map out of an array with names. | `tinymce` |
| [map()](#map) | Creates a new array by the return value of each iteration function call. This enables you to convert
one array list into another. | `tinymce` |
| [overrideDefaults()](#overrideDefaults) | Overrides the default options for editor instances. The `overrideDefaults` method replaces the `defaultOptions`, including any set by a previous call to the `overrideDefaults` method.

When using the Tiny Cloud, some of these defaults are required for the cloud-based editor to function.

Therefore, when using `overrideDefaults` with the cloud-based editor, any newly integrated options must be combined with the options in `tinymce.defaultOptions`. | `tinymce` |
| [remove()](#remove) | Removes a editor or editors form page. | `tinymce` |
| [resolve()](#resolve) | Resolves a string and returns the object from a specific structure. | `tinymce` |
| [setActive()](#setActive) | Sets the active editor instance and fires the deactivate/activate events. | `tinymce` |
| [toArray()](#toArray) | Converts the specified object into a real JavaScript array. | `tinymce` |
| [translate()](#translate) | Translates the specified string using the language pack items. | `tinymce` |
| [triggerSave()](#triggerSave) | Calls the save method on all editor instances in the collection. This can be useful when a form is to be submitted. | `tinymce` |
| [trim()](#trim) | Removes whitespace from the beginning and end of a string. | `tinymce` |
| [walk()](#walk) | Executed the specified function for each item in a object tree. | `tinymce` |

## Methods

### add()

```javascript
add(editor: tinymce.Editor): tinymce.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.

#### Return value

- `Editor` - The same instance that got passed in.

### addI18n()

```javascript
addI18n(code: String, items: Object)
```
Adds a language pack, this gets called by the loaded language files like en.js.

#### Parameters

- `code (String)` - Optional language code.
- `items (Object)` - Name/value object with translations.

### createEditor()

```javascript
createEditor(id: String, options: Object): tinymce.Editor
```
Creates an editor instance and adds it to the EditorManager collection.

#### Parameters

- `id (String)` - Instance id to use for editor.
- `options (Object)` - Editor instance options.

#### Return value

- `Editor` - Editor instance that got created.

### each()

```javascript
each(o: Object, cb: Function, s: Object)
```
Performs an iteration of all items in a collection such as an object or array. This method will execute 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)`.

#### Examples

```javascript
// Iterate an array
tinymce.each([ 1,2,3 ], (v, i) => {
  console.debug("Value: " + v + ", Index: " + i);
});

// Iterate an object
tinymce.each({ a: 1, b: 2, c: 3 }, (v, k) => {
  console.debug("Value: " + v + ", Key: " + k);
});
```

#### Parameters

- `o (Object)` - Collection to iterate.
- `cb (Function)` - Callback function to execute for each item.
- `s (Object)` - Optional scope to execute the callback in.

### execCommand()

```javascript
execCommand(cmd: String, ui: Boolean, value: Object | String | Number | Boolean): Boolean
```
Executes a specific command on the currently active editor.

#### Parameters

- `cmd (String)` - Command to perform for example Bold.
- `ui (Boolean)` - Optional boolean state if a UI should be presented for the command or not.
- `value (Object | String | Number | Boolean)` - Optional value parameter like for example an URL to a link.

#### Return value

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

### explode()

```javascript
explode(s: String, d: String)
```
Splits a string but removes the whitespace before and after each value.

#### Examples

```javascript
// Split a string into an array with a,b,c
const arr = tinymce.explode('a, b,   c');
```

#### Parameters

- `s (String)` - String to split.
- `d (String)` - Delimiter to split by.

### get()

```javascript
get(id: String | Number): tinymce.Editor | Array
```
Returns an editor instance for a given id.

#### Examples

```javascript
// Adds an onclick event to an editor by id
tinymce.get('mytextbox').on('click', (e) => {
  ed.windowManager.alert('Hello world!');
});

// Adds an onclick event to an editor by index
tinymce.get(0).on('click', (e) => {
  ed.windowManager.alert('Hello world!');
});

// Adds an onclick event to an editor by id (longer version)
tinymce.EditorManager.get('mytextbox').on('click', (e) => {
  ed.windowManager.alert('Hello world!');
});
```

#### Parameters

- `id (String | Number)` - The id or index of the editor instance to return.

#### Return value

- `Editor` - Editor instance or an array of editor instances.
- `Array` - Editor instance or an array of editor instances.

### grep()

```javascript
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.

#### Examples

```javascript
// Filter out some items, this will return an array with 4 and 5
const items = tinymce.grep([ 1,2,3,4,5 ], (v) => v > 3);
```

#### 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.

#### Return value

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

### hasOwnProperty()

```javascript
hasOwnProperty(obj: Object, prop: String): Boolean
```
JavaScript does not protect hasOwnProperty method, so it is possible to overwrite it. This is
an object independent version.
Checks if the input object `obj` has the property `prop`.

#### Parameters

- `obj (Object)` - Object to check if the property exists.
- `prop (String)` - Name of a property on the object.

#### Return value

- `Boolean` - true if the object has the specified property.

### inArray()

```javascript
inArray(item: any, arr: Array): Number
```
Returns an index of the item or -1 if item is not present in the array.

#### Parameters

- `item (any)` - Item to search for.
- `arr (Array)` - Array to search in.

#### Return value

- `Number` - index of the item or -1 if item was not found.

### init()

```javascript
init(options: Object): Promise
```
Initializes a set of editors. This method will create editors based on various settings.

For information on basic usage of `init`, see: [Basic setup](/docs/tinymce/8/basic-setup/).

#### Examples

```javascript
// Initializes a editor using the longer method
tinymce.EditorManager.init({
   some_settings : 'some value'
});

// Initializes a editor instance using the shorter version and with a promise
tinymce.init({
  some_settings : 'some value'
}).then((editors) => {
  ...
});
```

#### Parameters

- `options (Object)` - Options object to be passed to each editor instance.

#### Return value

- `Promise` - Promise that gets resolved with an array of editors when all editor instances are initialized.

### is()

```javascript
is(obj: Object, type: String): Boolean
```
Checks if a object is of a specific type for example an array.

#### Parameters

- `obj (Object)` - Object to check type of.
- `type (String)` - Optional type to check for.

#### Return value

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

### isArray()

```javascript
isArray(obj: Object): Boolean
```
Returns true/false if the object is an array or not.

#### Parameters

- `obj (Object)` - Object to check.

#### Return value

- `Boolean` - true/false state if the object is an array or not.

### makeMap()

```javascript
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.

#### Return value

- `Object` - Name/value map of items.

### map()

```javascript
map(array: Array, callback: 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

- `array (Array)` - Array of items to iterate.
- `callback (Function)` - Function to call for each item. It’s return value will be the new value.

#### Return value

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

### overrideDefaults()

```javascript
overrideDefaults(defaultOptions: Object)
```
Overrides the default options for editor instances. The `overrideDefaults` method replaces the `defaultOptions`, including any set by a previous call to the `overrideDefaults` method.

When using the Tiny Cloud, some of these defaults are required for the cloud-based editor to function.

Therefore, when using `overrideDefaults` with the cloud-based editor, any newly integrated options must be combined with the options in `tinymce.defaultOptions`.

#### Examples

```javascript
const customOptions = {
  toolbar_sticky: true
};

tinymce.overrideDefaults({
  ...tinymce.defaultOptions,
  ...customOptions
});
```

#### Parameters

- `defaultOptions (Object)` - Default options object.

### remove()

```javascript
remove(selector: tinymce.Editor | String | Object): tinymce.Editor
```
Removes a editor or editors form page.

#### Examples

```javascript
// Remove all editors bound to divs
tinymce.remove('div');

// Remove all editors bound to textareas
tinymce.remove('textarea');

// Remove all editors
tinymce.remove();

// Remove specific instance by id
tinymce.remove('#id');
```

#### Parameters

- `selector (Editor | String | Object)` - CSS selector or editor instance to remove.

#### Return value

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

### resolve()

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

#### Examples

```javascript
// Resolve a path into an object reference
const obj = tinymce.resolve('a.b.c.d');
```

#### Parameters

- `n (String)` - Path to resolve for example a.b.c.d.
- `o (Object)` - Optional object to search though, defaults to window.

#### Return value

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

### setActive()

```javascript
setActive(editor: tinymce.Editor)
```
Sets the active editor instance and fires the deactivate/activate events.

#### Parameters

- `editor (Editor)` - Editor instance to set as the active instance.

### toArray()

```javascript
toArray(obj: Object): Array
```
Converts the specified object into a real JavaScript array.

#### Parameters

- `obj (Object)` - Object to convert into array.

#### Return value

- `Array` - Array object based in input.

### translate()

```javascript
translate(text: String | Array | Object): String
```
Translates the specified string using the language pack items.

#### Parameters

- `text (String | Array | Object)` - String to translate

#### Return value

- `String` - Translated string.

### triggerSave()

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

#### Examples

```javascript
// Saves all contents
tinyMCE.triggerSave();
```

### trim()

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

#### Parameters

- `s (String)` - String to remove whitespace from.

#### Return value

- `String` - New string with removed whitespace.

### walk()

```javascript
walk(o: Object, f: Function, n: String, s: String)
```
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.
