|
<SfRichTextEditor Placeholder="Enter Some Content">
<RichTextEditorToolbarSettings Items="@Tools" />
<RichTextEditorFontFamily Items="@FontFamilyItems" Default="Verdana" />
<RichTextEditorFontSize Items="@FontSizeItems" Default="16pt"></RichTextEditorFontSize>
</SfRichTextEditor>
<style>
.e-richtexteditor .e-rte-content .e-content,
.e-richtexteditor .e-source-content .e-content {
font-size: 16pt;
font-family: Verdana;
}
</style>
@code {
private List<DropDownItemModel> FontSizeItems = new List<DropDownItemModel>()
{
//Newly added font size.
new DropDownItemModel() { Command = "Font", SubCommand = "FontSize", Text = "16 pt", Value = "16pt" },
//Default Font Size in Rich Text Editor.
new DropDownItemModel() { Command = "Font", SubCommand = "FontSize", Text = "8 pt", Value = "8pt" },
new DropDownItemModel() { Command = "Font", SubCommand = "FontSize", Text = "10 pt", Value = "10pt" },
new DropDownItemModel() { Command = "Font", SubCommand = "FontSize", Text = "12 pt", Value = "12pt" },
new DropDownItemModel() { Command = "Font", SubCommand = "FontSize", Text = "14 pt", Value = "14pt" },
new DropDownItemModel() { Command = "Font", SubCommand = "FontSize", Text = "18 pt", Value = "18pt" },
new DropDownItemModel() { Command = "Font", SubCommand = "FontSize", Text = "24 pt", Value = "24pt" },
new DropDownItemModel() { Command = "Font", SubCommand = "FontSize", Text = "36 pt", Value = "36pt" }
};
private List<DropDownItemModel> FontFamilyItems = new List<DropDownItemModel>()
{
//Newly added font family.
new DropDownItemModel() { CssClass = "e-roboto-ui", Command = "Font", SubCommand = "FontName", Text = "Roboto", Value = "Roboto" },
//Default Font family in Rich Text Editor.
new DropDownItemModel() { CssClass = "e-segoe-ui", Command = "Font", SubCommand = "FontName", Text = "Segoe UI", Value = "Segoe UI" },
new DropDownItemModel() { CssClass = "e-arial", Command = "Font", SubCommand = "FontName", Text = "Arial", Value = "Arial,Helvetica,sans-serif" },
new DropDownItemModel() { CssClass = "e-georgia", Command = "Font", SubCommand = "FontName", Text = "Georgia", Value = "Georgia,serif" },
new DropDownItemModel() { CssClass = "e-impact", Command = "Font", SubCommand = "FontName", Text = "Impact", Value = "Impact,Charcoal,sans-serif" },
new DropDownItemModel() { CssClass = "e-tahoma", Command = "Font", SubCommand = "FontName", Text = "Tahoma", Value = "Tahoma,Geneva,sans-serif" },
new DropDownItemModel() { CssClass = "e-times-new-roman", Command = "Font", SubCommand = "FontName", Text = "Times New Roman", Value = "Times New Roman,Times,serif" },
new DropDownItemModel() { CssClass = "e-verdana", Command = "Font", SubCommand = "FontName", Text = "Verdana", Value = "Verdana,Geneva,sans-serif" }
};
. . .
} |
|
<head>
. . .
</head> |
Hi,
I'm experiencing also a initial value problem.
The inital p tag doesn't contain the default font size and font family.
can be seen in my demo app.
https://github.com/alisio92/TextEditorDemo
video showcase in attachment.
thanks
Attachment: demo_61603df3.zip
Hi, please note this doesn't quite match what is stated in the documentation:
https://blazor.syncfusion.com/documentation/rich-text-editor/how-to/default-font
The sample listed above works. What's stated in the documentation does not.
Thanks.
Dear Vinitha Jeyakumar
Continuing on the question from Alisio Putman, I have edited your sample to reconstruct the issue.
Following the documentation as stated on
https://blazor.syncfusion.com/documentation/rich-text-editor/how-to/default-font, to set the default font, you have to configure the RTE and add a style tag to the page to set the context class
<RichTextEditorFontFamily Default="Impact" Items="@FontFamilyItems" />
<RichTextEditorFontSize Default="36 pt" />
<style>
.customClass .e-rte-content .e-content {
/* to get the desired font on intially*/
font-family: Impact,Charcoal,sans-serif;
font-size: 36pt;
}
</style>
When typing new text in an empty RTE with a default font, the typed text will correctly be shown in the default font. However, when retrieving the value of the RTE, with two-way binding for example, you will get html and text without the default font styling.
Using this value on a different page, a dynamic html component, in an email, in a RTE with a different class... will result in plain text without the set default font as styling.
I assume this:
This is an issue when you save the value to the database and reload it in a RTE with a different default font. The result will be a styling with that RTE's default font, instead of the default font you saved the text in originally, as the styling is not passed with the value of the RTE
Attachment: RTE_Server1169589029_edit_b275d99a.zip
| <SfRichTextEditor CssClass="customClass" @bind-Value="@_myTextFromRTE"> <RichTextEditorToolbarSettings Items="@Tools" /> <RichTextEditorFontFamily Default="Impact" Items="@FontFamilyItems" /> <RichTextEditorFontSize Default="36 pt" /> </SfRichTextEditor> <p> <button type="button" @onclick="@RenderComponent"> Render above text as actual html </button> </p> <SfRichTextEditor CssClass="classWithoutDefaults" @bind-Value="@dynamicContent" Readonly="true"> <RichTextEditorToolbarSettings Items="@Tools" /> <RichTextEditorFontFamily Default="Impact" Items="@FontFamilyItems" /> <RichTextEditorFontSize Default="36 pt" /> </SfRichTextEditor> <style> .customClass .e-rte-content .e-content { /* to get the desired font on intially*/ font-family: Impact,Charcoal,sans-serif; font-size: 36pt; } .classWithoutDefaults .e-rte-content .e-content { /* to get the desired font on intially*/ font-family: initial; font-size: initial; } </style> @code{ public string RTEContent { get; set; } private string dynamicContent = ""; private string _myTextFromRTE = ""; private async Task RenderComponent() { RTEContent = "<div style='font-family: Impact; font-size:36pt;'>" + _myTextFromRTE + "</div>"; dynamicContent = RTEContent; } |
Hi,
I have exactly the same issue with the latest version of components.
I want to have the HTML-Content to be initilized with a font without any user interaction.
The hack above does not work (any more). Whats the best approach for this in 2025?
If I use the documented approach and set
<RichTextEditorFontFamily Items="FontFamilyItems" Width="70px" Default="Arial" />
This does only preset the dropdown, but the user must select it to be applied to the editor which is weird.
Hi,
I have exactly the same issue with the latest version of components.
I want to have the HTML-Content to be initilized with a font without any user interaction.
The hack above does not work (any more). Whats the best approach for this in 2025?
If I use the documented approach and set
<RichTextEditorFontFamily Items="FontFamilyItems" Width="70px" Default="Arial" />
This does only preset the dropdown, but the user must select it to be applied to the editor which is weird.
@Johannes Steurer
I was on the same project with@Gregory Braekevelt and @Alisio Putman, what we did:
we dropped syncfusion, also because they forces us into paying a much higher license fee. We went for Radzen controls, we ported the whole application to Radzen (what wasn't that obvious), and couldn't be more satisfied about this transition. Sorry Syncfusion, maybe we wanted to much customization from your components, but that is the step we did to make it work.
Regards Ben
Default property within the RichTextEditorFontFamily configuration. Once set, the selected font is seamlessly applied across the editor experience:Hi,
thanks for the project it perfectly demonstrates the issue that in fact it does not set the font:
You see in the snipping that the HTML-Tag does not have any style applied which it should have if you look at the editor. It's supposed to be a WYSIWYG editor which in this case is just not true IMO.
Thanks
Hi Ben Croughs,
We cannot see that you had any unresolved technical issues while you previously evaluated our controls, but please let us know if you had any, and we will do our best to assist. We also offer free community license to qualified customers that offers access to all of our products and free support as well. For more details, please check this at your convenience: Download Community Edition | Syncfusion
Regards,
Padmini
@using Syncfusion.Blazor.RichTextEditor @using Syncfusion.Blazor.Buttons <SfRichTextEditor @ref="rteObj" @bind-Value="RteValue"> <RichTextEditorFontFamily Default="@defFont" Items="@FontFamilyItems" /> <RichTextEditorToolbarSettings Items="@Tools" /> </SfRichTextEditor> <div>@dynamicContent</div> <button class="e-btn" @onclick="@RenderComponent">Get</button> @code { SfRichTextEditor rteObj; public string defFont { get; set; } = "Impact"; public string dynamicContent { get; set; } public string RteValue { get; set; } = "Type Something.."; private async Task RenderComponent() { var RTEContent = "<div style='font-family: " + defFont+ ";'>" + RteValue + "</div>"; dynamicContent = RTEContent; } private List<ToolbarItemModel> Tools = new List<ToolbarItemModel>() { new ToolbarItemModel() { Command = ToolbarCommand.FontName } }; private List<DropDownItemModel> FontFamilyItems = new List<DropDownItemModel>() { new DropDownItemModel() { Text = "Arial", Value = "Arial,Helvetica,sans-serif" }, new DropDownItemModel() { Text = "Roboto", Value = "Roboto" }, new DropDownItemModel() { Text = "Georgia", Value = "Georgia,serif" }, new DropDownItemModel() { Text = "Impact", Value = "Impact,Charcoal,sans-serif" }, new DropDownItemModel() { Text = "Tahoma", Value = "Tahoma,Geneva,sans-serif" } }; } |
Hi,
thanks for the answer, but I am not convinced about this workaround. You just add a div around the whole text.
What's the point in providing a way to select the default font (RichTextEditorFontFamily) if it's just not selected in the background and I need a hack to save it? From my point of view this pre-selection is even worse than no selection because it suggests to the user that the font is applied which in reality it's not.
Hope you can provide a workaround that works properly.
Thanks
Hi,
was anybody able to review, what I was pointing out above?
Thanks
Hi,
could you please provide us an update here?
Thanks
Hi,
I get your point but it's still not clear how to solve the issue.
We
need to be able to save the exact content the user produces
(independent of the user changing the font or not). If the styles are
not applied to the HTML it's not storing what the user sees and the HTML
will look different in a different environment.
IMO: If i set the
default-font in code it should be applied to the HTML content the same
way as if the user would select this font.
What do you think?