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?
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?
It would be really helpful if commands like ‘addRowBefore’, ‘addRowAfter’ could accept optional parameters for table row and cell attributes which in turn can be used in ‘addRow’ command to create table rows and cells. This would allow us to customize table rows and cells (eg: cell borders, and other cell related stylings) more easily while keeping things clean and maintainable.
If such an extension is possible, it would be greatly appreciated! Otherwise, we may need to copy and modify these functions along with their dependencies to accommodate our custom attributes. Let us know if this is something that can be considered. Thanks!