TinyMCE:API/tinymce.Editor/addCommand
From Moxiecode Documentation Wiki
Contents |
[edit]
Method: addCommand
[edit]
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.
[edit]
Syntax
<void> addCommand(<String> n, <function> f, <Object> s)
[edit]
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.
[edit]
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'}));
});
}
});
