This is a migrated thread and some comments may be shown as answers.
RadEditor not saving the font style when the default font style is selected
7 Answers 19 Views
This is a migrated thread and some comments may be shown as answers.
Ruben
Top achievements
Rank 1
Ruben asked on 05 Mar 2018, 04:14 PM

Hi,

When I type any text in the editor without changing the default font style the text doesn't get saved with the font style.

Is there any solution to always save the font style?

Thanks

7 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 05 Mar 2018, 04:18 PM
Hello Ruben,

Please take a look at the following forum threads, which discussed the browser issue: https://www.telerik.com/forums/default-font-name-and-font-size-set-not-getting-in-radeditor-font-name-and-size and https://www.telerik.com/forums/radeditor-default-font-style-not-applied-upon-typing.

Regards,
Rumen
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Ruben
Top achievements
Rank 1
answered on 05 Mar 2018, 08:35 PM

Hi,

I need to save the font style to the database. And those solutions are for display the value in the browser.

Is there any way to always save the font style to the database?

Thanks

0
Rumen
Telerik team
answered on 06 Mar 2018, 08:54 AM
Hi Ruben,

It would be very helpful if you explain your scenario in more detail, because the content produced by RadEditor is a just string with HTML markup in it and the font information is part of this string.

If the RealFontSize, or FontSize tools or the HTML mode are enabled, the end user can apply multiple font sizes to different parts of the content.

On the other side, the content area can have a font size applied by a CSS style as shown in this demo: Customize Content Area or by JavaScript as shown here.

Best regards,
Rumen
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Ruben
Top achievements
Rank 1
answered on 06 Mar 2018, 03:24 PM

Hello,

What I need is that always the content produced by RadEditor contains the font information as part of the string with HTML markup in it. For example, this is the desired result: "<span style="font-family: Arial; font-size: 12px;">test</span>"

I can apply a font style to the content area through a CSS style or by JavaScript using the OnClientLoad event, but always when I type any text without modifying the default values that I chose, the string produced by RadEditor doesn't contain the span tag with the font style information. If I only modify the font-size the content produced will have this: "<span style="font-size:12px;">test</span>". But if I don't change any font format the content produced will be just this: "test".

Thanks for trying to help and hope this will make more sense now

0
Rumen
Telerik team
answered on 06 Mar 2018, 04:02 PM
Hi there,

In such case, it is better to wrap the initial content in a span tag with applied font-size setting:

<script>
function OnClientLoad(editor, args)
{
    setTimeout(function()
    {
         //fire the FontName and FontSize commands
         editor.fire('FontName', { value: 'Arial' });
         editor.fire('RealFontSize', { value: '9pt' });
    }, 0);
}
</script>
<telerik:RadEditor id="RadEditor1" runat="server" OnClientLoad="OnClientLoad" />


Best regards,
Rumen
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Ruben
Top achievements
Rank 1
answered on 06 Mar 2018, 09:56 PM

Hello,

That solution works, but it's not always consistent if the editor is loaded with a default value. I found a solution for this using the OnClientSubmit event, I wrapped the editor content in a span tag with the font style attribute. 

Now, I would like to know if in this event I can get the default and  of the editor when it was loaded, to apply it to the span that I'm going to create, this is because we create editors dynamically in the server with different font styles.

Thanks,

Ruben

0
Rumen
Telerik team
answered on 07 Mar 2018, 04:01 PM
Hi,

The body and the iframe element of RadEditor does not have a default font applied and they are inherited by the page. If the font is applied programmatically as below to the body element of RadEditor you can obtain it with editor.get_contentArea().style.fontSize and editor.get_contentArea().style.fontFamily

<script>
    function OnClientLoad(editor, args) {
        var style = editor.get_contentArea().style;
        style.backgroundImage = "none";
        style.backgroundColor = "black";
        style.color = "red";
        style.fontFamily = "Arial";
        style.fontSize = 15 + "px";
        alert(" Font size" + editor.get_contentArea().style.fontSize + "\r\n Font name: " + editor.get_contentArea().style.fontFamily);
    }
</script>
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientLoad="OnClientLoad">
    <Content>test</Content>
</telerik:RadEditor>



Best regards,
Rumen
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Asked by
Ruben
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Ruben
Top achievements
Rank 1
Share this question
or