GetmeUK / ContentTools

A JS library for building WYSIWYG editors for HTML content.
http://getcontenttools.com
MIT License
3.94k stars 393 forks source link

Making CT compatible with CSP style-src set to 'self' #567

Open jnnkB opened 4 years ago

jnnkB commented 4 years ago

When you set the value of style-src to 'self', ContentTools fails to apply some styles. This comes from using node.setAttribute("style", …) instead of node.style.attrubute = ... as you can read here.

I think it might not be that easy because you use code like this:

this._domElement.setAttribute('style', this._attributes['style']);

But it should be possible to store the styles as a map instead and to something like:

styles = {"background": "red"}
for (style in styles) {
    this._domElement.style[style] = styles[style]
}

I really would appreciate if you could implement this.