• Jodit
  • PRO
  • Builder
  • Getting Started
  • Playground
  • Examples
  • Documentation
  • Download
  • Overview
  • Issue tracker
  • Docs
  • Plugins
  • Demo
  • Pricing
  • File Browser Pro
  • Sign in
Get connected wth us on social networks!

Footer

Jodit Core

  • Jodit Home page
  • Documentation
  • Playground
  • Examples
  • Github
  • Issues

Integration

  • Jodit React
  • Jodit Angular
  • Jodit Vue
  • Jodit Yii2
  • Jodit Joomla

PRO/OEM plugins

  • AutoComplete
  • Backup Plugin
  • Button Generator
  • Change case
  • Custom Color Picker
  • Emoji
  • Finder
  • Google Search
  • Paste code
  • Show Blocks
  • Virtual Keyboard
  • Tune block
  • Highlight signature
  • Google Maps Editor
  • Export in PDF
  • Page Break
  • Iframe Editor
  • Paste from Word PRO
  • Mobile View
  • ToDo List
  • Translate

Links

  • Demo PRO/OEM
  • Demo FileBrowser PRO
  • Price
  • License
  • Support
  • For resellers

Versions

  • site v.0.1.810
  • Jodit PRO v.4.6.4
  • Jodit v.4.6.2
  • All versions
2025 © Copyright: XDSoft.net <support@xdsoft.net>
  • Getting started

    • Installation
    • Usage
    • Support
    • FAQs
    • Cloud
    • Examples
  • How to

    • Create plugin
    • Add custom button
    • Add custom font in the font list
    • How to create module
    • How to generate license key
    • How to make a backend finder
    • How to set up document view
  • Modes

    • Source mode
  • Customisation

    • Theme
    • Keyboard
  • API

    • License Rest API
    • JS API
  • Changelog

  • Plugins

    • AutoComplete
    • Backup Plugin
    • Button Generator
    • Change case
    • Custom Color Picker
    • Emoji
    • Finder
    • Google Search
    • Paste code
    • Show Blocks
    • Virtual Keyboard
    • Tune block
    • Highlight signature
    • Google Maps Editor
    • Export in PDF
    • Page Break
    • Iframe Editor
    • Paste from Word PRO
    • Mobile View
    • ToDo List
    • Translate

How to add custom button to Jodit toolbar

In the simplest case, you can add a button right when you initialize the editor.:

const editor = Jodit.make('#editor', { buttons: [ ...Jodit.defaultOptions.buttons, { name: 'insertDate', tooltip: 'Insert current Date', exec: (editor) => { editor.s.insertHTML(new Date().toDateString()); } } ] });
Copy

Also, the button can be described in the dictionary Jodit.defaultOptions.controls.

Jodit.defaultOptions.controls.selectAll = { tooltip: 'Select all content', command: 'selectall' }; const editor = Jodit.make('#editor', { buttons: [...Jodit.defaultOptions.buttons, 'selectAll'] });
Copy

The Button interface is quite extensive, and we will not describe it here.

In this tutorial, we will only describe a few examples for different types of buttons.

Drop-down list

Jodit.defaultOptions.controls.wrapInTag = { tooltip: 'Wrap selection in tag', list: ['h1', 'h2', 'h3'], childTemplate: (editor, key, value) => `<span class="${key}">${editor.i18n(value)}</span>`, isChildActive: (editor, control) => { const current = editor.s.current(); if (current) { const currentBox = Dom.closest( current, (node) => Dom.isTag(node, control.list), // check if parent node is one of list editor.editor ); return Boolean( currentBox && currentBox !== editor.editor && control.args !== undefined && currentBox.nodeName.toLowerCase() === control.args[0] ); } return false; }, exec(editor, _, { control }) { let value = control.args && control.args[0]; // h1, h2 ... editor.s.applyStyle(undefined, { element: value }); editor.setEditorValue(); // Synchronizing the state of the WYSIWYG editor and the source textarea return false; } };
Copy

The list of items can also be a dictionary

Jodit.defaultOptions.controls.wrapInTag = { // ... list: { h1: 'Heading 1', h2: 'Heading 2', h3: 'Heading 3' } // ... };
Copy

Button with a drop-down popup

Often you need not a list, but a full-fledged popup, which will contain your interface or form.

Jodit.defaultOptions.controls.addWord = { tooltip: 'Enter text and insert', icon: 'pencil', popup: (editor, current, self, close) => { const form = editor.create.fromHTML( `<form> <input type="text"/> <button type="submit">Insert</button> </form>` ); editor.e.on(form, 'submit', (e) => { e.preventDefault(); editor.s.insertHTML(form.querySelector('input').value); close(); }); return form; } };
Copy

The popup method must return an HTMLElement or string.