简体   繁体   中英

jodit add button to insert html in editor

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?

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');
            }
        }
    ]
 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM