inLine comes with the following callback functions.
onChange
The onChange callback is excecuted each time you make a change on the selector initialized with inLine. It must be specified on the main options as shown below and it returns the API object:
How to set
new inLine('#myEditor', {
onChange: function (res) {
document.querySelector('#myTextarea').value = res.content;
}
});
Returned value
{
"textarea": [textarea DOM element],
"content": "Ut lobortis maximus mi, sed interdum turpis finibus eget. Integer vulputate in quam sit amet placerat."
}
onToolbarOpen
The onToolbarOpen callback is excecuted when you select a text and the toolbar comes down.
How to set
new inLine('#myEditor', {
onToolbarOpen: function (res) {
res.textarea.classList.add('focus');
}
});
Returned value
{
"textarea": [textarea DOM element],
"content": "Ut <strong>lobortis maximus mi</strong>, sed interdum turpis <u>finibus eget</u>. Integer vulputate in <em>quam sit amet</em> placerat."
}
onToolbarClose
The onToolbarClose callback is excecuted when you release the selection and the toolbar is closed.
How to set
new inLine('#myEditor', {
onToolbarClose: function (res) {
res.textarea.classList.remove('focus');
}
});
Returned value
{
"textarea": [textarea DOM element],
"content": "Ut lobortis maximus mi, sed interdum turpis finibus eget. Integer vulputate in quam sit amet placerat."
}