BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Fix for numbered list item when exporting to PDF, DOCX

Open mfanselmo opened this issue 1 year ago • 5 comments

This PR https://github.com/TypeCellOS/BlockNote/pull/1326 introduced the ability to start numbered lists from indices other than 1. I noticed on the demo to export to pdf/docx this was not taked into account.

I was not able to run playwright locally and update snapshots if that is needed, can you give me guidance here or do it?

mfanselmo avatar Jan 07 '25 13:01 mfanselmo

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Jan 8, 2025 7:39pm

vercel[bot] avatar Jan 07 '25 13:01 vercel[bot]

@mfanselmo is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jan 07 '25 13:01 vercel[bot]

Hey! I spent quite a bit of time on this but ran into some tricky edge cases I couldn’t get to work perfectly. Let me break them down:

For PDFs, numbering is straightforward since we can manually set the numbering. However, Word has a few quirks: To start a numbered list at a value other than 1, you have to define a specific configuration for that list type. It’s not as simple as just setting a start value. I handled this by maintaining a set of starting indices and manually referencing them via blocknote-numbered-list-{index}. Word automatically increments list numbers, so if you need to restart numbering manually, you have to use the instance parameter for adjacent lists. I came across a weird edge case where adjacent lists, nested under different parent blocks, don’t behave as expected—even though the instance parameter should fix it. For now, my code assigns a unique numeric ID to each list instance, but I believe this might be overkill and could be simplified. I left it in just in case someone wants to dig into it.

Here’s an example of content that doesn’t render correctly in Word. Based on how instance works, I would expect this to work fine: image

I’ve updated the snapshots for both PDF and DOCX to test these cases. The PDF output works perfectly, but DOCX still has this one issue. @YousefED I will leave this one to this point for now, but if I find time in the future I will give it another go

mfanselmo avatar Jan 08 '25 19:01 mfanselmo

Hi @mfanselmo are you still planning to work on this? Since you mentioned it's not ready to merge

matthewlipski avatar Feb 28 '25 15:02 matthewlipski

Hey, not planning on working on this for now. Still missing the DOCX fix.

mfanselmo avatar Mar 12 '25 12:03 mfanselmo