This is a migrated thread and some comments may be shown as answers.

Default color - RadEditor

1 Answer 269 Views
Editor
This is a migrated thread and some comments may be shown as answers.
imad
Top achievements
Rank 1
imad asked on 20 Sep 2018, 03:34 PM

Hello,

I want to make a default color in toolbar for the color and background : when the user select a text, and click on the buton of color,that will make my dafault color

i do this

<telerik:EditorTool Name="ForeColor"     Value="red" />

but when i select the text and try to make my color by default ,that open the dialog color and not colorized my text

 

Thank you

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 25 Sep 2018, 08:02 AM
Hi Imad,

If you want to apply a default color to the content area check this article and demo: Set Editor Background and Color and Customize Content Area.

If you want to change the pallet colors see this article: Colors.

To programmatically execute the ForeColor or BackColor commands use the fire client-side method:

 editor.fire('ForeColor', { value: "orange" });

Here is an example how to set the forecolor to red when clicking on the ForeColor tool:

<script type="text/javascript">
    function OnClientLoad(editor, args) {
        var foreColor = editor.getToolByName("ForeColor");
        $telerik.$(foreColor.get_element()).click(function () {
            foreColor.set_value('red');
            editor.fire('ForeColor', { value: "red" });
        });
    }
     
</script>
<telerik:RadEditor runat="server" OnClientLoad="OnClientLoad" ID="RadEditor1">
    <Content>some test content</Content>
</telerik:RadEditor>

Here is another example how to set the default color when start typing in the content area:

<script type="text/javascript">
    function OnClientLoad(editor, args) {
        var element = document.all ? editor.get_document().body : editor.get_document();
        $telerik.addExternalHandler(element, "click", function (e) {
            editor.fire('ForeColor', { value: "red" });
        });
    }
</script>
<telerik:RadEditor runat="server" OnClientLoad="OnClientLoad" ID="RadEditor1">
    <Content>test content</Content>
</telerik:RadEditor>


Regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Editor
Asked by
imad
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or