kendo-uikendo-editor

How do I set the default selected color of the KendoEditor's foreColor tool?


I want to set the default color for the Kendo Editor's foreColor tool to "black". By default, the color is always "white".


Solution

  • DontVoteMeDown has a great answer! However as soon as you click the dropdown arrow on the colorPicker, you lose the currently selected color. You could save the current color to a variable and reload it each time the palette is opened. Then update the selected color on change:

        var curForeColor = "#000000";
    
        $("#editor").kendoEditor({
            tools: [{
                name: "foreColor",
            }]
        });
    
    
        var colorpicker = $("div.k-i-foreground-color").data("kendoColorPicker");
        colorpicker.value(curForeColor);
    
        colorpicker.bind("change", function(){
          curForeColor = colorpicker.value();
        });
    
    
        colorpicker.bind("open", function(){
          colorpicker.value(curForeColor);
        });
    

    DEMO