Hello,
I’ve been using tiptap for the past few weeks in order to develop a custom rich-text editor. While learning to use tiptap, inevitably I learned to use ProseMirror to some extent.
There is an issue I’m trying to solve that by default, li
's content is wrapped inside a p
tag. What I want is to get rid of that p
tag and let the content sit right underneath the li
tag:
// Instead of this:
<ul>
<li><p>Some content</p></li>
</ul>
// I want this:
<ul>
<li>Some content</li>
</ul>
I tried looking around and see if someone has solved it before, but was unable.
One of my attempts was to modify the list_item
spec:
{
content: 'inline*',
defining: true,
draggable: false,
parseDOM: [{tag: 'li'}],
toDOM: () => ['li', 0],
}
This new spec does work when I “read” data (initial HTML content or paste) but does not work when I try to add a new list.
Feeding the editor
with the following HTML as its initial data works just fine (after the schema change):
<ul><li>abc</li></ul>
ProseMirror does not wrap the li
's content in a p
tag. However, when I try to add a new list, nothing happens. Also if I try to wrap some content in a list, it does not work.
Ideally, when I attempt to create a new empty list, I would like Prosemirror to create a list with a single empty li
:
<ul><li>[CURSOR]</li></ul>
I would also like to be able to wrap selected text in a list item.
If there any way I can achieve this result?