Table and row attributes

Hi all,

I am looking into using the prosemirror-tables module for table support. It looks very well thought out, so thanks for that!

In my use case we need to support extra attributes both on the table and the row level. We need this for things like the table width, special table styles, highlighted rows, etc.

As far as I can tell, right now only cells have support for extra attributes. Would it make sense for me to submit a PR to add the same support for rows and tables?

Or should I rather be making my own schema that is compatible with the schema created by tableNodes, by means of using tableRole and having attributes width and col|rowspan on cells?

I guess the question is: how much of the prosemirror-tables code relies on using the exact schema created by tableNodes?

Thanks Chris

Answer after just trying it out: it doesn’t :slight_smile:

So it’s totally possible to use the things like the cell/column/row-selection, the column resizing, etc, with a custom table schema, if that schema is compatible with the default table schema. The constraints here seem to be:

  • Table (tableRole = 'table') contains (only?) rows (tableRole = 'row') as direct children
  • Rows contain (only?) cells (tableRole = 'cell' or tableRole = 'header_cell') as direct children
  • Cells have attributes colspan (default: 1), rowspan (default: 1), and colwidth (default null).

My table schema doesn’t have header cells, and instead introduces extra table and row attributes, that seems to work well.

One issue that does come to mind is that commands like addRowAfter will create rows with the default set of attributes, which might or might not be a problem.

Works well so far, but the defaults work in our case.

By the way, I noticed that the columnResizing plugin is still undocumented (and thus considered private from a DefinitelyTyped perspective). It the feature still considered experimental?

That’s being used by multiple people, and I’d consider it stable. It’s just that no one has bothered to document it yet.