tinymce
TinyMCE core class.
Summary
Properties
Name | Type | Summary | Defined by |
---|---|---|---|
$ |
Dom query instance. Deprecated in TinyMCE 5.10 and has been marked for removal in TinyMCE 6.0. |
||
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. |
|
documentBaseURL |
|
Document base URL where the current document is located. |
|
editors |
|
Collection of editor instances. Deprecated in TinyMCE 4.7 and has been marked for removal in TinyMCE 6.0 - Use tinymce.get() instead. |
|
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 a class, subclass or static singleton. Deprecated in TinyMCE 5.10 and has been marked for removal in TinyMCE 6.0. |
||
Creates an editor instance and adds it to the EditorManager collection. |
||
Creates a namespace on a specific object. Deprecated in TinyMCE 5.10 and has been marked for removal in TinyMCE 6.0. |
||
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). |
||
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 settings for editor instances. |
||
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.
create()
create(s: String, p: Object, root: Object)
Creates a class, subclass or static singleton.
Deprecated in TinyMCE 5.10 and has been marked for removal in TinyMCE 6.0.
Examples
// Creates a basic class
tinymce.create('tinymce.somepackage.SomeClass', {
SomeClass: function() {
// Class constructor
},
method: function() {
// Some method
}
});
// Creates a basic subclass class
tinymce.create('tinymce.somepackage.SomeSubClass:tinymce.somepackage.SomeClass', {
SomeSubClass: function() {
// Class constructor
this.parent(); // Call parent constructor
},
method: function() {
// Some method
this.parent(); // Call parent method
},
'static': {
staticMethod: function() {
// Static method
}
}
});
// Creates a singleton/static class
tinymce.create('static tinymce.somepackage.SomeSingletonClass', {
method: function() {
// Some method
}
});
createEditor()
createEditor(id: String, settings: Object): tinymce.Editor
Creates an editor instance and adds it to the EditorManager collection.
createNS()
createNS(n: String, o: Object): Object
Creates a namespace on a specific object.
Deprecated in TinyMCE 5.10 and has been marked for removal in TinyMCE 6.0.
Examples
// Create some namespace
tinymce.createNS('tinymce.somepackage.subpackage');
// Add a singleton
var tinymce.somepackage.subpackage.SomeSingleton = {
method: function() {
// Some method
}
};
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 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).
execCommand()
execCommand(cmd: String, ui: Boolean, value: String): 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', function(e) {
ed.windowManager.alert('Hello world!');
});
// Adds an onclick event to an editor by index
tinymce.get(0).on('click', function(e) {
ed.windowManager.alert('Hello world!');
});
// Adds an onclick event to an editor by id (longer version)
tinymce.EditorManager.get('mytextbox').on('click', function(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
var items = tinymce.grep([1,2,3,4,5], function(v) {return 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(settings: 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(defaultSettings: Object)
Overrides the default settings for editor instances.
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.