hanford/remark-slate

Lists not serializing properly

Closed this issue · 3 comments

It looks like when serializing list types (ol, ul then li's) it looks to be placing them in a single string which doesn't render them properly in markdown:

- item 1- item 2- item 3

https://github.com/hanford/remark-slate/blob/master/src/serialize.ts#L183
I would think this would be a \n instead. Seems like there might be a trim happening somewhere that is removing that double space or that I'm doing something wrong (the more likely scenario :P)

Thank you again for this wonderful library.

I'm going to fork the repo and see if I can get a test running with it failing then see if I can submit a PR.. in the time being here's the condition i'm seeing.

Additional details:

[
    {
        "type": "paragraph",
        "children": [
            {
                "text": "This is a test"
            }
        ]
    },
    {
        "type": "paragraph",
        "children": [
            {
                "text": ""
            }
        ]
    },
    {
        "type": "paragraph",
        "children": [
            {
                "text": "I want to eat."
            }
        ]
    },
    {
        "type": "paragraph",
        "children": [
            {
                "text": ""
            }
        ]
    },
    {
        "type": "ul",
        "children": [
            {
                "type": "li",
                "children": [
                    {
                        "type": "p",
                        "children": [
                            {
                                "text": "I want to eat 1 pepper,"
                            }
                        ]
                    }
                ]
            },
            {
                "type": "li",
                "children": [
                    {
                        "type": "p",
                        "children": [
                            {
                                "text": "a strawberry "
                            }
                        ]
                    }
                ]
            },
            {
                "type": "li",
                "children": [
                    {
                        "type": "p",
                        "children": [
                            {
                                "text": "a raspberry"
                            }
                        ]
                    }
                ]
            }
        ]
    },
    {
        "type": "p",
        "children": [
            {
                "text": ""
            }
        ]
    },
    {
        "type": "p",
        "children": [
            {
                "text": "and that's it!"
            }
        ]
    }
]

produces the following markdown:

This is a test
<br>

I want to eat.
<br>


- I want to eat 1 pepper,- a strawberry - a raspberry
and that&amp;#39;s it!

And in the slate editor:
Screen Shot 2020-07-30 at 12 03 41 PM

Awesome, I'd definitely merge a fix .. but this specific issue isn't happening for me in my editors 🤔

Looks like, for some reason, some of my content coming out of lists is resolving as p's vs paragraph's. I pulled down the project and started logging through when I noticed that.

I'm using a few plugins from @udecode/slate-plugins that I'm guessing might be making those adjustments. I'll see if I can configure properly. Sorry for the potential alarm!

Thanks again for the library!

EDIT:
Configuration for ListPlugin was needed (incase others hit similar issues):

ListPlugin({
	p: {
		type: 'paragraph'
	}
})