rangy icon indicating copy to clipboard operation
rangy copied to clipboard

class Applier: error adding more than 1 classes

Open dryaner opened this issue 10 years ago • 2 comments

I need to add 2 extra classes to the applier, I tried to use the next options elementProperties : { className : 'highlight rangy' }

but that give me the next error

failed to execute 'add' on 'DOMTokenList': The token provided ('highlight rangy') contains HTML space characters, which are not valid in tokens.

To solve that I had to modify the rangy-classapplier.js function addClass line 70

changing the first if to that

if (typeof el.classList == "object" && typeof className == "object") {

if that is correct, you can added to the code or I can do a commit with that.

dryaner avatar Oct 06 '15 09:10 dryaner

I don't believe this was ever implemented ... but it seems like it definitely should be! Is there a workaround to make this work with more than two classes?

ghost avatar Oct 10 '16 12:10 ghost

The answer from @dryaner should work for as many classes as you like, as long as they are space delimited.

My question is: how can we get the undoToSelection to work with multiple classes as well?

wyeack avatar Aug 25 '17 12:08 wyeack