TinyMCE core class.
| 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. |
|
pageUid |
|
A uuid string to anonymously identify the page tinymce is loaded in |
|
releaseDate |
|
Release date of TinyMCE build. |
|
suffix |
|
Current suffix to add to each plugin/theme that gets loaded for example ".min". |
| 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. |
add(editor: tinymce.Editor): tinymce.EditorAdds an editor instance to the editor collection. This will also set it as the active editor.
-
editor (Editor)- Editor instance to add to the collection.
addI18n(code: String, items: Object)Adds a language pack, this gets called by the loaded language files like en.js.
createEditor(id: String, options: Object): tinymce.EditorCreates an editor instance and adds it to the EditorManager collection.
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).
// 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);
});execCommand(cmd: String, ui: Boolean, value: Object | String | Number | Boolean): BooleanExecutes a specific command on the currently active editor.
-
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.
explode(s: String, d: String)Splits a string but removes the whitespace before and after each value.
get(id: String | Number): tinymce.Editor | ArrayReturns an editor instance for a given id.
// 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!');
});-
Editor- Editor instance or an array of editor instances. -
Array- Editor instance or an array of editor instances.
grep(a: Array, f: Function): ArrayFilters 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.
// 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);-
a (Array)- Array of items to loop though. -
f (Function)- Function to call for each item. Include/exclude depends on it’s return value.
hasOwnProperty(obj: Object, prop: String): BooleanJavaScript 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.
-
obj (Object)- Object to check if the property exists. -
prop (String)- Name of a property on the object.
inArray(item: any, arr: Array): NumberReturns an index of the item or -1 if item is not present in the array.
init(options: Object): PromiseInitializes a set of editors. This method will create editors based on various settings.
For information on basic usage of init, see: Basic setup.
// 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) => {
...
});is(obj: Object, type: String): BooleanChecks if a object is of a specific type for example an array.
isArray(obj: Object): BooleanReturns true/false if the object is an array or not.
makeMap(items: Array | String, delim: String, map: Object): ObjectMakes a name/object map out of an array with names.
-
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.
map(array: Array, callback: Function): ArrayCreates a new array by the return value of each iteration function call. This enables you to convert one array list into another.
-
array (Array)- Array of items to iterate. -
callback (Function)- Function to call for each item. It’s return value will be the new value.
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.
const customOptions = {
toolbar_sticky: true
};
tinymce.overrideDefaults({
...tinymce.defaultOptions,
...customOptions
});remove(selector: tinymce.Editor | String | Object): tinymce.EditorRemoves a editor or editors form page.
// 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');-
selector (Editor | String | Object)- CSS selector or editor instance to remove.
resolve(n: String, o: Object): ObjectResolves a string and returns the object from a specific structure.
-
n (String)- Path to resolve for example a.b.c.d. -
o (Object)- Optional object to search though, defaults to window.
setActive(editor: tinymce.Editor)Sets the active editor instance and fires the deactivate/activate events.
toArray(obj: Object): ArrayConverts the specified object into a real JavaScript array.
translate(text: String | Array | Object): StringTranslates the specified string using the language pack items.
triggerSave()Calls the save method on all editor instances in the collection. This can be useful when a form is to be submitted.
trim(s: String): StringRemoves whitespace from the beginning and end of a string.
walk(o: Object, f: Function, n: String, s: String)Executed the specified function for each item in a object tree.