UNPKG

@mkljczk/lexical-remark

Version:

This package contains Markdown helpers and functionality for Lexical using remark-parse.

19 lines (15 loc) 490 B
import type { ListNode } from '@lexical/list'; import { List, ListItem } from 'mdast'; import { Handler } from './index.js'; export const list: Handler<ListNode> = (node, { rootHandler }) => { const remarkNode: List = { children: node .getChildren() .map((child) => rootHandler(child, { rootHandler })) .filter((child): child is ListItem => !!child), ordered: node.getListType() === 'number', spread: false, type: 'list', }; return remarkNode; };