TypeCellOS / BlockNote

A React Rich Text Editor that's block-based (Notion style) and extensible. Built on top of Prosemirror and Tiptap.
https://www.blocknotejs.org/
Mozilla Public License 2.0
5.89k stars 381 forks source link

feat: Table cell/column widths in API #856

Open matthewlipski opened 1 week ago

matthewlipski commented 1 week ago

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

vercel[bot] commented 1 week ago

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
halimt92 commented 6 days ago

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 ?

matthewlipski commented 5 days ago

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 commented 5 days ago

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.