What is @lexical/list?
@lexical/list is a package designed to provide list functionalities within the Lexical framework, a modern web text editor. It allows developers to create, manage, and manipulate ordered and unordered lists in a rich text editor environment.
What are @lexical/list's main functionalities?
Creating Ordered Lists
This feature allows you to create an ordered list (numbered list) within the Lexical editor. The code sample demonstrates how to create a new ordered list node and append it to the editor's root.
import { $createListNode, ListNode } from '@lexical/list';
const orderedListNode = $createListNode('number');
editor.update(() => {
const root = $getRoot();
root.append(orderedListNode);
});
Creating Unordered Lists
This feature allows you to create an unordered list (bulleted list) within the Lexical editor. The code sample shows how to create a new unordered list node and append it to the editor's root.
import { $createListNode, ListNode } from '@lexical/list';
const unorderedListNode = $createListNode('bullet');
editor.update(() => {
const root = $getRoot();
root.append(unorderedListNode);
});
Converting List Types
This feature allows you to convert an existing list from one type to another (e.g., from ordered to unordered). The code sample demonstrates how to find a list node in the current selection and change its type.
import { $createListNode, ListNode } from '@lexical/list';
editor.update(() => {
const selection = $getSelection();
if (selection !== null) {
const listNode = selection.getNodes().find(node => node instanceof ListNode);
if (listNode !== null) {
listNode.setListType('bullet'); // Convert to unordered list
}
}
});
Other packages similar to @lexical/list
draft-js
Draft.js is a rich text editor framework for React. It provides extensive support for creating and managing lists, including ordered and unordered lists. Compared to @lexical/list, Draft.js offers a more comprehensive set of features for building rich text editors but may have a steeper learning curve.
slate
Slate is another popular framework for building rich text editors in React. It offers robust support for lists and other rich text features. Slate is highly customizable and flexible, making it a strong alternative to @lexical/list for developers needing more control over their editor's behavior.
prosemirror
ProseMirror is a toolkit for building rich text editors with a focus on extensibility and performance. It includes built-in support for lists and other rich text elements. ProseMirror is known for its modular architecture, which allows developers to create highly customized editing experiences.
v0.8.0 (2023-02-09)
This release includes some breaking changes, including:
- Remove of indentList
and outdentList
from @lexical/list
.
- Refactor of the LexicalContentEditable
types from @lexical/react
to make them more accurate with HTMLDivElement
attributes.
This release adds functionality to apply node transforms to node replacements, it allows users to specify tab indentation sizes, and improved support for tracking the origin of YJS updates for collaborative editing.
- Ensure deletions capture existing formatting (#3867) Dominic Gannaway
- Add style properties to RangeSelection (#3863) Dominic Gannaway
- List indentation simplified (#3809) EgonBolton
- Update ContentEditable types (#3580) John Flockton
- Allow the format property to be omitted (#3812) Karibash
- Allow users to customise the indentation of tabs (#3802) John Flockton
- Apply node transform not only to the original node but also to the overriding node (#3639) mizuno
- feat: set the update tag from yjs based on the origin (#3608) El-Hussein Abdelraouf