jpuri / draftjs-utils

An collection of useful utility functions for DraftJS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Background color toggle

Vladislao opened this issue · comments

Hello @jpuri, thank you for such a great tool.

It looks like background color toggle doesn't work properly. You can specify background color, but can't toggle it back by clicking on the same color (the way it works with text color).

It might be caused by this line: https://github.com/jpuri/draftjs-utils/blob/master/js/inline.js#L211

    const styleKey = styleType === 'bgcolor' ? 'backgroundColor' : styleType;
    if (!currentStyle.has(`${styleKey}-${style}`)) {

currentStyle contains bgcolor-rgb(...), but not the backgroundColor-rgb(...), might be a typo?

Reproducible on https://jpuri.github.io/react-draft-wysiwyg/#/
https://youtu.be/WJDcKKTH89E

I've personnally solved that by adding a "transparent color" to the list displayed to the user :)