Interaction with the user
Our Marker Tool is ready to use. However, we can add some more features. For example, you want to choose a highlight color when you use Marker. For that we will use HTML input
element with type color
. To add input to the Inline Toolbar we need renderActions
method which returns some layout we want to add:
Now when marker button is pressed just show this input. When highlight is removed — hide it:
Unfortunately that wouldn't work as expected because mark.style.backgroundColor
returns the value of color in normalized rgb()
format. To handle it we need one more helping method to convert the rgb value to hex:
That's it! Now you can choose the color of marker. With renderActions
method you can insert into Inline Toolbar any inputs or hints for the user (e.g. input for the link).
Here the full code of Marker Tool with color picker:
In the next article you can learn about some advanced methods for Inline Tools.