tinymce
TinyMCE core class.
Summary
Properties
Name | Type | Summary | Defined by |
---|---|---|---|
DOM |
Global DOM instance. |
||
PluginManager |
Global PluginManager instance. Instance of AddOnManager. |
||
ScriptLoader |
Global ScriptLoader instance. |
||
ThemeManager |
|||
activeEditor |
Currently active editor instance. |
||
baseURI |
Absolute baseURI for the installation path of TinyMCE. |
||
baseURL |
|
Base URL where the root directory if TinyMCE is located. |
|
defaultOptions |
|
Object containing the options that will be passed by default to the |
|
documentBaseURL |
|
Document base URL where the current document is located. |
|
i18n |
|
Collection of language pack data. |
|
majorVersion |
|
Major version of TinyMCE build. |
|
minorVersion |
|
Minor version of TinyMCE build. |
|
releaseDate |
|
Release date of TinyMCE build. |
|
suffix |
|
Current suffix to add to each plugin/theme that gets loaded for example ".min". |
Methods
Name | Summary | Defined by |
---|---|---|
Adds an editor instance to the editor collection. This will also set it as the active editor. |
||
Adds a language pack, this gets called by the loaded language files like en.js. |
||
Creates an editor instance and adds it to the EditorManager collection. |
||
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: |
||
Executes a specific command on the currently active editor. |
||
Splits a string but removes the whitespace before and after each value. |
||
Returns an editor instance for a given id. |
||
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. |
||
JavaScript does not protect hasOwnProperty method, so it is possible to overwrite it. This is
an object independent version.
Checks if the input object |
||
Returns an index of the item or -1 if item is not present in the array. |
||
Initializes a set of editors. This method will create editors based on various settings. For information on basic usage of |
||
Checks if a object is of a specific type for example an array. |
||
Returns true/false if the object is an array or not. |
||
Makes a name/object map out of an array with names. |
||
Creates a new array by the return value of each iteration function call. This enables you to convert one array list into another. |
||
Overrides the default options for editor instances. The When using the Tiny Cloud, some of these defaults are required for the cloud-based editor to function. Therefore, when using |
||
Removes a editor or editors form page. |
||
Resolves a string and returns the object from a specific structure. |
||
Sets the active editor instance and fires the deactivate/activate events. |
||
Converts the specified object into a real JavaScript array. |
||
Translates the specified string using the language pack items. |
||
Calls the save method on all editor instances in the collection. This can be useful when a form is to be submitted. |
||
Removes whitespace from the beginning and end of a string. |
||
Executed the specified function for each item in a object tree. |
Methods
add()
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.
addI18n()
addI18n(code: String, items: Object)
Adds a language pack, this gets called by the loaded language files like en.js.
createEditor()
createEditor(id: String, options: Object): tinymce.Editor
Creates an editor instance and adds it to the EditorManager collection.
each()
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)
.
execCommand()
execCommand(cmd: String, ui: Boolean, value: Object | String | Number | Boolean): Boolean
Executes a specific command on the currently active editor.
explode()
explode(s: String, d: String)
Splits a string but removes the whitespace before and after each value.
get()
get(id: String | Number): tinymce.Editor | Array
Returns an editor instance for a given id.
Examples
// 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!');
});
Return value
-
Editor
- Editor instance or an array of editor instances. -
Array
- Editor instance or an array of editor instances.
grep()
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
// 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);
hasOwnProperty()
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
.
inArray()
inArray(item: any, arr: Array): Number
Returns an index of the item or -1 if item is not present in the array.
init()
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.
is()
is(obj: Object, type: String): Boolean
Checks if a object is of a specific type for example an array.
makeMap()
makeMap(items: Array | String, delim: String, map: Object): Object
Makes a name/object map out of an array with names.
map()
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.
overrideDefaults()
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
.
remove()
remove(selector: tinymce.Editor | String | Object): tinymce.Editor
Removes a editor or editors form page.
Examples
// 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.
resolve()
resolve(n: String, o: Object): Object
Resolves a string and returns the object from a specific structure.
setActive()
setActive(editor: tinymce.Editor)
Sets the active editor instance and fires the deactivate/activate events.
translate()
translate(text: String | Array | Object): String
Translates the specified string using the language pack items.
triggerSave()
triggerSave()
Calls the save method on all editor instances in the collection. This can be useful when a form is to be submitted.