This plugin adds a button to the toolbar that allows you to insert and manage interactive task lists with checkboxes. Todo lists are perfect for creating checklists, task lists, or any content that requires user interaction.
If you are using a fat build of the editor, then the plugin is already included in it. If you are using the slim build, then you need to enable it manually:
CopyJodit.make('#editor', { extraPlugins: ['todo-list'] });
By default, the plugin generates the following HTML structure:
Copy<ul class="todo-list"> <li> <label class="todo-list__label" contenteditable="false"> <input tabindex="-1" type="checkbox" /> </label> Task item text </li> </ul>
string
'todo-list'
The CSS class name applied to the <ul>
element of the todo list.
CopyJodit.make('#editor', { todoList: { className: 'custom-todo-list' } });
string
'todo-list__label'
The CSS class name applied to the <label>
element that wraps the checkbox.
CopyJodit.make('#editor', { todoList: { labelClassName: 'custom-todo-list__checkbox-wrapper' } });
(jodit: IJodit) => HTMLElement
A function that creates the checkbox element. By default, it creates an <input type="checkbox" tabindex="-1">
element.
Default implementation:
Copyfunction inputFactory(jodit) { return jodit.createInside.element('input', { type: 'checkbox', tabindex: -1 }); }
You can customize this to create any element you want to use as a checkbox:
CopyJodit.make('#editor', { todoList: { inputFactory: (jodit) => { // Create a custom checkbox using a span with a custom class return jodit.createInside.element('span', { class: 'custom-checkbox', tabindex: -1 }); } } });
Copyconst editor = Jodit.make('#editor', { buttons: ['todoList'], extraPlugins: ['todo-list'] }); // You can also trigger the todo list programmatically editor.execCommand('todoList');
Copyconst editor = Jodit.make('#editor', { buttons: ['todoList'], todoList: { className: 'task-list', labelClassName: 'task-checkbox' } });
Copyconst editor = Jodit.make('#editor', { buttons: ['todoList'], todoList: { inputFactory: (jodit) => { const checkbox = jodit.createInside.element('div', { class: 'custom-checkbox', tabindex: -1 }); // Add a checkmark icon inside const icon = jodit.createInside.element('i', { class: 'checkmark-icon' }); checkbox.appendChild(icon); return checkbox; } } });
You can customize the appearance of todo lists using CSS variables:
Copy<style> :root { --jd-todo-color-checkbox-border: #333; --jd-todo-color-checkbox-border-checked: #25ab33; --jd-todo-color-checkbox-bg-checked: #25ab33; --jd-todo-color-checkbox-mark-checked: #fff; --jd-todo-size-checkbox: 18px; } </style>
These variables control:
--jd-todo-color-checkbox-border
: Border color of the unchecked checkbox--jd-todo-color-checkbox-border-checked
: Border color of the checked checkbox--jd-todo-color-checkbox-bg-checked
: Background color of the checked checkbox--jd-todo-color-checkbox-mark-checked
: Color of the checkmark--jd-todo-size-checkbox
: Size of the checkboxThis implementation ensures a smooth user experience when working with interactive task lists in the editor.