I need headings in my doc to have an id attribute.
The native node’s parseDOM is this (It allows detecting headings of all levels.):
parseDOM: [
{ tag: "h1", attrs: { level: 1 } },
{ tag: "h2", attrs: { level: 2 } },
{ tag: "h3", attrs: { level: 3 } },
{ tag: "h4", attrs: { level: 4 } },
{ tag: "h5", attrs: { level: 5 } },
{ tag: "h6", attrs: { level: 6 } },
],
i couldn’t figure it out when overriding the parseDOM . This is what i wrote:
schemaSpecNodes.get('heading').parseDOM = [
{
tag: 'h1 | h2 | h3 | h4 | h5 | h6',
getAttrs(dom) {
return { level: dom.getAttribute('level'), id:dom.getAttribute('id') };
},
},
];
But i got the error :
Uncaught DOMException: Failed to execute ‘matches’ on ‘Element’: ‘h1 | h2 | h3 | h4 | h5 | h6’ is not a valid selector.
How i can achieve ?