What is @tiptap/extension-task-list?
@tiptap/extension-task-list is an extension for the Tiptap editor that allows you to add and manage task lists within your rich text editor. It provides functionality to create, edit, and manage task lists, making it easier to handle to-do lists and similar content within your editor.
What are @tiptap/extension-task-list's main functionalities?
Create Task List
This code demonstrates how to create a task list using the @tiptap/extension-task-list package. It initializes the Tiptap editor with the TaskList and TaskItem extensions and sets the initial content to a task list with two items.
import TaskList from '@tiptap/extension-task-list';
import TaskItem from '@tiptap/extension-task-item';
import { Editor } from '@tiptap/core';
const editor = new Editor({
extensions: [
TaskList,
TaskItem,
],
content: '<ul data-type="taskList"><li data-checked="false">Task 1</li><li data-checked="true">Task 2</li></ul>',
});
Toggle Task Completion
This code demonstrates how to toggle the completion status of a task item within a task list. The `toggleTaskItem` method is used to change the checked state of a task item.
editor.chain().focus().toggleTaskItem({ id: 'task-item-id' }).run();
Add New Task Item
This code demonstrates how to add a new task item to an existing task list. The `insertContent` method is used to insert a new task item with the specified content.
editor.chain().focus().insertContent('<li data-type="taskItem" data-checked="false">New Task</li>').run();
0
@tiptap/extension-task-list
Introduction
Tiptap is a headless wrapper around ProseMirror – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as New York Times, The Guardian or Atlassian.
Official Documentation
Documentation can be found on the Tiptap website.
License
Tiptap is open sourced software licensed under the MIT license.