Jodit provides several ways to replace toolbar icons. You can replace one icon or all icons at once.
You can replace the icon for a specific button:
CopyJodit.make('#editor', { controls: { bold: { iconURL: 'https://xdsoft.net/favicon.png' } } });
Or through the module Icon
CopyJodit.modules.Icon.set( 'brush', `<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> <circle cx="50" cy="50" r="50" /> </svg>` ); Jodit.make('#editor');
Or replace all icons in Jodit.
For example, let's connect Jodit with Font Awesome icons
Include Jodit and and the CDN Font Awesome
Copy<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" /> <link rel="stylesheet" href="build/jodit.min.css" /> <script src="build/jodit.min.js"></script>
Create input element
Copy<textarea id="editor">Some text</textarea>
And define method getIcon
:
CopyJodit.make('#editor', { getIcon: function (name, clearName) { let code = name; // not all font awesome icons is matched to Jodit icons switch (clearName) { case 'redo': code = 'rotate-right'; break; } return ( '<i style="font-size:14px" class="fa fa-' + code + ' fa-xs"></i>' ); } });
For full replacing you can copy this code:
CopyJodit.make('#editor', { getIcon: function (name, clearName) { let code = clearName; switch (clearName) { case 'redo': code = 'rotate-right'; break; case 'video': code = 'video-camera'; break; case 'copyformat': code = 'clone'; break; case 'about': code = 'question'; break; case 'selectall': code = 'legal'; break; case 'symbol': return '<span style="text-align: center;font-size:14px;">Ω</span>'; case 'hr': code = 'minus'; break; case 'left': case 'right': case 'justify': case 'center': code = 'align-' + name; break; case 'brush': code = 'tint'; break; case 'fontsize': code = 'text-height'; break; case 'ul': case 'ol': code = 'list-' + name; break; case 'source': code = 'code'; break; } return ( '<i style="font-size:14px" class="fa fa-' + code + ' fa-xs"></i>' ); } });