7 Answers, 1 is accepted
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
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
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
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
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
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
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