Creating custom toolbar commands
Textbox.io’s toolbar can be customized to suit the needs of your application. Buttons on the toolbar are referred to as commands. Custom commands can be created at initialization time as part of the editor configuration.
When using custom commands, you’ll need to explicitly define the rest of your toolbar configuration (i.e. stipulate all items to appear). See Changing the Toolbar for more information.
A typical custom command can be defined appear as the following:
|id||String||A unique, user-defined key to identify the custom command. This enables the command to be uniquely identified at runtime|
|text||String||The text to display as a tooltip when a user hovers over the command|
|icon||String||a URL path (relative or absolute) to a 13*13px image for the command's icon.|
|action||function||A function defining the action to occur when the user clicks on the button.|
Including custom commands in your toolbar
Including the custom command in your toolbar requires specifying where you'd like it in your toolbar:
This example shows how to create a basic custom item and add it to the toolbar.
Accessing the editor from action functions
Often when writing action functions for custom commands, you'll want to do something meaningful with the editor content. To do this, use
textboxio.getActiveEditor() to obtain a reference to the editor where the cursor is currently located.
See the API reference for more information.