A. Wilson
A. Wilson

Reputation: 8840

Detect Plugin or Command Existence in TinyMCE

Does TinyMCE's API support a method for finding whether or not a plugin is active, or better, whether a given command is registered? Specifically, I am creating a plugin that would like to call the mceAutoResize command at periods, but in order to do so I would prefer to detect whether the command exists or not. I know I can do this by searching the plugins parameter, but I wanted to know specifically if there is an API-supported way (to limit the chances that this plugin will break on a TinyMCE update).

Upvotes: 3

Views: 906

Answers (1)

Thariama
Thariama

Reputation: 50840

To see if a plugin or command is active there seems to be no real API functionality. What you can do to see if a plugin is loaded use

var plugin_is_usable = tinymce.get(editor_id).plugins.pluginname;

To check if a given command (in this case mceAutoResize) is available you may use

var mceAutoResize_is_usable = tinymce.get(editor_id).execCommands.mceAutoResize;

It is not likely that this will ever change in tinymce.

Upvotes: 1

Related Questions