From ac6305943444102a209f0f3bf4e48e111bf805b3 Mon Sep 17 00:00:00 2001 From: Petyo Ivanov Date: Sat, 14 Sep 2024 09:18:06 +0300 Subject: [PATCH] fix: deeply nested lists don't throw an error Fixes #583 --- src/examples/nested-lists.tsx | 32 +++++++++++++++++++++ src/plugins/lists/LexicalListItemVisitor.ts | 11 +++++-- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/examples/nested-lists.tsx diff --git a/src/examples/nested-lists.tsx b/src/examples/nested-lists.tsx new file mode 100644 index 0000000..fde570e --- /dev/null +++ b/src/examples/nested-lists.tsx @@ -0,0 +1,32 @@ +import React from 'react' +import { MDXEditor, listsPlugin, diffSourcePlugin, toolbarPlugin, DiffSourceToggleWrapper, UndoRedo } from '..' + +const listsMarkdown = ` +* hello +* world + * indented + * more +* back +` + +export function NestedLists() { + return ( + { + console.log(md) + }} + plugins={[ + listsPlugin(), + diffSourcePlugin(), + toolbarPlugin({ + toolbarContents: () => ( + + + + ) + }) + ]} + /> + ) +} diff --git a/src/plugins/lists/LexicalListItemVisitor.ts b/src/plugins/lists/LexicalListItemVisitor.ts index 601f653..d82c6e4 100644 --- a/src/plugins/lists/LexicalListItemVisitor.ts +++ b/src/plugins/lists/LexicalListItemVisitor.ts @@ -10,8 +10,15 @@ export const LexicalListItemVisitor: LexicalExportVisitor