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.
0.3.8 (July 20, 2022)
Lots of bug fixes.
Introduces TypeaheadPlugin and associated primitives, which consolidate the implementation of all such functionality (mentions and component picker) and create a base to build similar typeahead functionality from.
Introduces TableOfContents plugin for easier navigation of long-form documents. Available in the playground in the settings menu (bottom-left corner).
Introduces a "clipboard viewer" functionality in the local dev environment. When active, it shows the clipboard content the last time the paste event was fired with the editor focused.
- Remove default styling imports on HTML paste (#2663) Acy Watson
- fix(lexical-playground): code lang display (#2658) 子瞻 Luci
- chore(lexical-playground): remove files that should not be submitted (#2662) 子瞻 Luci
- Selection.extract fix (#2620) Acy Watson
- Specify the return type of getNearestNodeOfType. (#2651) hiraoka
- Autolink default protocol (#2654) Gerard Rovira
- fix(doc): RichTextPlugin placeholder (#2655) unvalley
- fix(lexical): calculate range selection formatting (#2643) 子瞻 Luci
- Add TableOfContentsPlugin (#2634) Karam Qaoud
- Port ASCII State Tree to Browser Extension (#2625) Will
- Fix markdown text matchers during md import (#2644) Maksim Horbachevsky
- fix(lexical): Japanese IME issue (#2623) 子瞻 Luci
- Remove comment box from footer (#2639) John Flockton
- Delete doc from ydocMap on unmount. Fixes init on re-mount (#2637) Maksim Horbachevsky
- feat: new way to delete comments and threads (#2570) Adithya Vardhan
- Lexical Typeaheads (#2534) Tyler Bainbridge
- Add $insertBlockNode (#2633) Gerard Rovira
- Add seperate flag for if script had loaded (#2628) John Flockton
- Fix Chrome types in Lexical DevTools (#2627) John Flockton
- Capture the expected payload type in commands (#2537) Patrik Åkerstrand
- fix unit test warning (#2618) Acy Watson
- fix(lexical-playground): fix toolbar-item button style bug in safari (#2621) 子瞻 Luci
- add docs (#2611) Acy Watson
- Add default value for undefined case in markdown transformers (#2453) Noah Cook
- Add PasteLog Plugin (#2609) Acy Watson
- Fix pasting inline code blocks (#2607) Maksim Horbachevsky