When the user marks a text, he can define a backgroundcolor with the colorpicker (textcolor.plugin).
Once saved he can change the background-color but not get rid of it.
background-color:white is no solution as the bodycolor can be RGB or even a picture.
How is the colorpicker to configure to remove the style-tag or at least insert a background-color:none?

有帮助吗?

解决方案

Found a solution changing the plugin (textcolor). If there is a better way please be free to post it.

I added additional colors to the colorpicker. The Color #FFFFFe (near White) i marked as NO COLOR and changed the plugin as shown.

function onPanelClick(e) {
    var buttonCtrl = this.parent(), value;

    if ((value = e.target.getAttribute('data-mce-color'))) {
        buttonCtrl.hidePanel();
        value = '#' + value;
        buttonCtrl.color(value);
        if (value == '#FFFFFe') {  //Changing the value to -1 causes deletion :-)
            value = -1;
        }
        editor.execCommand(buttonCtrl.settings.selectcmd, false, value);
    }
}

其他提示

Researched a bit more since the given answer did not work in my version 4.5.0 of tinymce.

The textcolor plugin uses 'editor.formatter.remove(...)' to remove text color or background color upon selecting 'x' in the last option of the color palette for 'no color'. While that function is used elsewhere successfully in tinymce (e.g. when removing italics from text), in the context of the textcolor plugin it does not remove color formatting.


Solution:

Replace the following in the textcolor's plugin.js:

editor.formatter.remove(format, {value: null}, null, true);

with:

editor.dom.removeAllAttribs(editor.selection.getNode());



...or in the minified version plugin.min.js:

a.formatter.remove(b,{value:null},null,!0),

with:

a.dom.removeAllAttribs(a.selection.getNode()),



...and things start working as intended.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top