redFur
November 15, 2018, 9:12am
1
Hi, I want to create a parse rule for a mark based on a class. So my mark is called ‘highlight’, i’m applying a certain class by having
toDOM() { return [“span”,{class: “highlight”}, 0] }
for parsing I tried parseDOM: [‘span’, {class: “highlight”}, 0] but that doesn’t seem to work. My guess is that I need to use getAttrs to make it work? Is that right? Is there a better way?
Thanks,
Ivan
marijn
November 15, 2018, 10:00am
2
You can use a CSS selector "span.highlight"
(though your parseDOM
spec seems generally invalid—check the docs for how parse rule objects should look)
redFur
November 15, 2018, 2:53pm
3
Ah yes, I pasted the wrong thing, I was meant to write [{class: ‘highlight’}].
Anyway, [{tag: ‘span.highlight’}] works, missed the bit where it says it’s css selector and thought it’s just a tag.
Thanks!