BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

feat: Table cell/column widths in API

Open matthewlipski opened this issue 1 year ago • 4 comments

You can already resize table cells in BlockNote, but these use premade TipTap nodes and so their widths are not really accessible to get/set via the BlockNote API. This PR modifies the typing of TableContent so that you can now read and update table cell widths. Additionally, it fixes a small bug that was preventing the cell widths from being parsed correctly.

The changes I made are based on #846, but I don't have push rights to that remote repo so this PR replaces that one.

Closes #655

matthewlipski avatar Jun 20 '24 21:06 matthewlipski

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

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Jun 20, 2024 9:34pm
blocknote-website ✅ Ready (Inspect) Visit Preview Jun 20, 2024 9:34pm

vercel[bot] avatar Jun 20 '24 21:06 vercel[bot]

Hmm, downside is that this would break all existing documents stored right? Let's think a bit more about backwards compatibility before merging this

If you guys use a minWidth of 100px and change the minWidth of the paragraphs instead of the width, it would not affect the existing tables right @YousefED ?

halimt92 avatar Jun 26 '24 15:06 halimt92

Hmm, downside is that this would break all existing documents stored right? Let's think a bit more about backwards compatibility before merging this

If you guys use a minWidth of 100px and change the minWidth of the paragraphs instead of the width, it would not affect the existing tables right @YousefED ?

It's not quite that simple - the width of the table cells was/is already stored within TipTap's TableCell node, this PR is more about exposing that to the BlockNote API so the widths are preserved when saving and loading the doc. But because we're adding a width to table cells in the API, the type definition of CellContent needs to be changed and so existing documents with the previous CellContent type definition will break.

matthewlipski avatar Jun 26 '24 22:06 matthewlipski

Also just to add, it is a good point that cells should have a minimum width (should be able to extend the TableCell node with addAttributes to do that), and we should make sure to do that before merging because right now it makes the UX pretty janky.

matthewlipski avatar Jun 26 '24 22:06 matthewlipski