Skip to content

Commit

Permalink
fix: correct export of check lists
Browse files Browse the repository at this point in the history
Fixes #255
  • Loading branch information
petyosi committed Jan 5, 2024
1 parent 658beb8 commit 9573753
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/plugins/lists/LexicalListItemVisitor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $isListItemNode, $isListNode, ListItemNode } from '@lexical/list'
import { $isListItemNode, $isListNode, ListItemNode, ListNode } from '@lexical/list'
import * as Mdast from 'mdast'
import { LexicalExportVisitor } from '../../exportMarkdownFromLexical'

Expand All @@ -13,10 +13,11 @@ export const LexicalListItemVisitor: LexicalExportVisitor<ListItemNode, Mdast.Li
const prevListItemNode = mdastParent.children.at(-1) as Mdast.ListItem
actions.visitChildren(lexicalNode, prevListItemNode)
} else {
const parentList = lexicalNode.getParent() as ListNode
// nest the children in a paragraph for MDAST compatibility
const listItem = actions.appendToParent(mdastParent, {
type: 'listItem' as const,
checked: lexicalNode.getChecked(),
checked: parentList.getListType() === 'check' ? Boolean(lexicalNode.getChecked()) : undefined,
spread: false,
children: [{ type: 'paragraph' as const, children: [] }]
}) as Mdast.ListItem
Expand Down

0 comments on commit 9573753

Please sign in to comment.