TinyMCE:API/tinymce.Editor/addCommand

From Moxiecode Documentation Wiki

Jump to: navigation, search

Contents

Method: addCommand

Summary

Adds a custom command to the editor, you can also override existing commands with this method. The command that you add can be executed with execCommand.

Syntax

<void> addCommand(<String> n, <function> f, <Object> s)

Parameters

n
Command name to add/override.
f
Function to execute when the command occurs. The function may optionally return a true value to signal that the command should be passed further in the command chain. Any other value, or no returned value at all, means that the command has been successfully executed.
s
Optional scope to execute the function in.

Examples

// Adds a custom command that later can be executed using execCommand
tinyMCE.init({
   ...

   setup : function(ed) {
      // Register example command
      ed.addCommand('mycommand', function(ui, v) {
         ed.windowManager.alert('Hello world!! Selection: ' + ed.selection.getContent({format : 'text'}));
      });
   }
});
Personal tools