Open flaki opened 3 years ago
Have you tried adding styles to ul[data-tight=true] li
that remove the margins?
Appreciate the swift response, yes making the <p>
inside display: contents
is how I'm currently working around this, but I suspected that perhaps it was worthy to have a more clean solution of not rendering the paragraph elements in the first place?
The schema puts a block node there, which makes sense (you can have nested lists and such in tight list items), and the editor view expects nodes in the document to have a DOM node equivalent, so I don't think not rendering the paragraph is a very practical approach.
I see! Thanks for elaborating! Maybe then including the above CSS snippet by default and documenting this behavior would be a better recourse?
Have you tried adding styles to ul[data-tight=true] li that remove the margins?
I've corrected the display with these lines of css:
.ProseMirror ul li p:first-child {
margin-top: 0;
}
.ProseMirror ul li p:last-child {
margin-bottom: 0;
}
See in my POC project: https://github.com/stephane-klein/poc-svelte-prosemirror-markdown/blob/6a27f64eb7bd23663021a945d180b29c88d073d6/src/routes/editor.css#L336
I ran into a list-rendering-related inconsistency in ProseMirror. After digging around, I found #51 (TIL about "list tightness" in Markdown!), and the fix does seem to correctly detect the "hidden" attributes in Markdown-it's tokens and correctly attaches them on lists, but the then the (default) list rendering does not take these into account:
In the above screenshot, the left-hand side is plain Markdown-it, the right-hand side is ProseMirror. As evidenced by the
data-tight="true"
in the list DOM, the tightness is correctly detected but ignored on render.This behavior can also be reproduced by the Friendly Markdown example on the website.
I tried looking into where this gets rendered (is it prosemirror-schema-list?) but arguably I'm still a bit new to ProseMirror's internals and couldn't quite get to it, would be happy to help to have this fixed.