This is a migrated thread and some comments may be shown as answers.

Modifying schema on Editor not working on all tags

1 Answer 170 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 18 Nov 2019, 01:22 PM

Hi

It appears I cannot add schema attrs to 'table' 'table_row' or 'table_cell' tags

Docs shows adding attrs to p tag which works fine.

https://www.telerik.com/kendo-react-ui/components/editor/schema/ 

 

Here is an example of my issue forked from the example in docs adding attrs to table tag.

https://stackblitz.com/edit/react-paewaz-lapmmp?embed=1&file=app/main.jsx

 

Thanks

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 18 Nov 2019, 02:44 PM

Hello, James,

Thank you for the example.

This happens because we need to tell the table schema to read these new attributes when parsing from and to the DOM:

https://prosemirror.net/docs/ref/#model.NodeSpec.toDOM 

https://prosemirror.net/docs/ref/#model.MarkSpec.parseDOM

        table.toDOM = node => ['table', node.attrs, 0];
        table.parseDOM = [{ tag: 'table', getAttrs: getAttributes }]

This is the updated example:
https://stackblitz.com/edit/react-paewaz-xl3bxu?file=app/main.jsx

Additionally, please check another example showing an alternative approach:

https://stackblitz.com/edit/react-f4qb39-1wedpk?file=app%2Fmain.jsx

Also, we have a task to improve the table functionality including the table schema:

https://github.com/telerik/kendo-react/issues/366

I hope this is helpful.

Regards,
Stefan
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
James
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or