Inline Tools API
In this article will be explained all available options for Inline Tools creation.
render
|
Required | create UI of button |
surround
|
Required | works with selected range |
checkState
|
Required | get Tool's activated state by selected range |
renderActions
|
Optional | create additional element below the buttons |
clear
|
Optional | clear Tool's stuff on opening/closing of Inline Toolbar |
isInline
|
Required | specifies Tool as Inline Toolbar Tool |
sanitize
|
Optional | sanitizer rules |
title
|
Optional | Allows to define Tool's title that can be used in Helper Tooltip appearing on hover |
shortcut
|
Optional | Allows to define a shortcut for tool |
Create Tool`s button for Inline Toolbar. Can either return MenuConfig or single HTML element with a button.
This method has no arguments.
MenuConfig
|
Configuration of the tune's appearance inside Inline Toolbar menu. |
Button
|
Advanced. HTML Element with button for Inline Toolbar. |
This method is called when Tool button is pressed and accepts Range
object with selected fragment as an argument.
Range
|
Range object with selected fragment |
Void
This method is called when Inline Toolbar is opened to update button`s state.
Selection
|
Selected fragment |
Void
Returns additional elements to interact with the user.
This method has no arguments
Element
|
HTML Element with additional interface |
This method is called when Inline Toolbar is closed. You can use it to reset some internal Tool`s states.
This method has no parameters
Void
To mark Tool as inline this static getter should return true
.
true
To avoid your Inline Tool to be sanitized you need to provide sanitize configuration for it. It will be merged with Block Tool configuration where your Tool is allowed to use.
Object
|
Sanitizer configuration rules. |
You can pass your Tool's title via
static getter. It can be used, for example, in the Tooltip with icon description that appears by hover.
title
(The example above is written on TypeScript. You can use native JS as well)
Provides keyboard shortcut for your Tool
String
|
Shortcut for Tool. Format described here. |