jodit add button to insert html in editor

2.3k Views Asked by At

There has been a few posts on a similar subject. However none of the solutions are working in my case.

I have managed to add a new button with the code below but when I click on it nothing happens.

<script>
var editor = new Jodit('#editor', {
    buttons: [
        'bold',
        {
            iconURL: './icons/icon.png',
            exec: function (editor) {
                return editor.create.fromHTML('text to insert');
            }
        }
    ]
});

What am I doing wrong?

Next step will be to add a new button with a dropdown of several insert options, each of these to insert a different html text in the editor.

Anybody has done that?

1

There are 1 best solutions below

3
Antonio Esposito On

Just look jodit documentation

Corrections of your code:

var editor = new Jodit('#editor', {
    buttons: [
        {   
            name: 'bold',
            tooltip: 'Bold'
            iconURL: './icons/icon.png',
            exec: function (editor) {
                editor.selection.insertHTML('text to insert');
            }
        }
    ]
 });