You can write your own module for Jodit. For example create Dummy module, which will insert some code in editor Create file Dummy.js with this content
CopyJodit.modules.Dummy = function (editor) { this.insertDummyImage = function (w, h, textcolor, bgcolor) { const image = editor.createInside.element('img'); image.setAttribute( 'src', 'http://dummyimage.com/' + w + 'x' + h + '/' + (textcolor || '000') + '/' + (bgcolor || 'fff') ); editor.selection.insertNode(image); editor.setEditorValue(); // for syncronize value between source textarea and editor }; };
You need include this file after include jodit.min.js
Copy<link type="text/css" rel="stylesheet" href="build/jodit.min.css" /> <script type="text/javascript" src="build/jodit.min.js"></script> <script type="text/javascript" src="Dummy.js"></script>
Now you can use this module. For example will append button in toolbar
CopyJodit.make('#editor', { buttons: [ 'bold', 'italic', { iconURL: 'images/dummy.png', tooltip: 'insert Dummy Image', exec: function (editor) { editor.dummy.insertDummyImage(100, 100, 'f00', '000'); } } ], events: { afterInit: function (editor) { editor.dummy = new Jodit.modules.Dummy(editor); } } });
Or you can use your mode like this:
Copyvar editor = new Jodit('#textareaid'); editor.getInstance('Dummy').insertDummyImage(100, 100, 'f00', '000');
That's all. You can try this example here