Hi Telerik Team,
I use your RichTextBox control.
I use the Import/Export HTML mode with HTMLProvider.
If i underline a word and I export in HTML the tag "text-decoration: underline;" is visible.
But when I import the same HTML, the word is not underlined.
I made a labs basic to prove this. If i can send this to you for helping It is with pleasure.
Téo
16 Answers, 1 is accepted
Thank you for reporting this bug.
We will make sure to fix it in the service pack or internal build before that.
Iva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
<UserControl.Resources> <telerikHtml:HtmlDataProvider x:Name="HtmlProvider" RichTextBox="{Binding ElementName=editor}" Html="{Binding MyBody, Mode=TwoWay}" FormatProvider="{Binding HtmlFormatProvider}"/> </UserControl.Resources>
<telerik:RadRichTextBox AllowScaling="False" Height="282" HorizontalScrollBarVisibility="Hidden" IsContextMenuEnabled="False" IsSelectionMiniToolBarEnabled="False" IsSpellCheckingEnabled="False" Name="editor" VerticalScrollBarVisibility="Hidden" Width="400" />
Thanks,
Kris
Thank you for reporting this bug. It is related to the newly introduced style system. We have updated your Telerik points in appreciation of your involvement.
As a workaround, you can use HtmlExportSettings and specify StyleRepositoryExportMode to DontExportStyles.
On a side note, when you use data-binding, you have to declare the data provider in the visual tree, as noted in this article. This ensures that the DataContext of the data provider will be properly updated if it is changed for some reason. Furthermore, you must not declare/bind the FormatProvider of the data provider. It is exposed in order to enable finer customization of the import/export through the settings.
In a nut-shell, your code should read:
<
Grid
>
<
telerikHtml:HtmlDataProvider
x:Name
=
"HtmlProvider"
RichTextBox
=
"{Binding ElementName=editor}"
Html
=
"{Binding MyBody, Mode=TwoWay}"
>
<
telerikHtml:HtmlDataProvider.FormatProvider
>
<
telerikHtml:HtmlFormatProvider
>
<
telerikHtml:HtmlFormatProvider.ExportSettings
>
<
telerikHtmlSettings:HtmlExportSettings
StyleRepositoryExportMode
=
"DontExportStyles"
/>
</
telerikHtml:HtmlFormatProvider.ExportSettings
>
</
telerikHtml:HtmlFormatProvider
>
</
telerikHtml:HtmlDataProvider.FormatProvider
>
</
telerikHtml:HtmlDataProvider
>
<
telerik:RadRichTextBox
AllowScaling
=
"False"
Height
=
"282"
HorizontalScrollBarVisibility
=
"Hidden"
IsContextMenuEnabled
=
"False"
IsSelectionMiniToolBarEnabled
=
"False"
IsSpellCheckingEnabled
=
"False"
Name
=
"editor"
VerticalScrollBarVisibility
=
"Hidden"
Width
=
"400"
/>
</
Grid
>
where telerikHtmlSettings namespace is:
xmlns:telerikHtmlSettings="clr-namespace:Telerik.Windows.Documents.FormatProviders.Html;assembly=Telerik.Windows.Documents"
Iva Toteva
the Telerik team
Use XmlDataProvider instead and convert the html to Xaml by doing the following:
<telerikXaml:XamlDataProvider x:Name="XamlProvider" RichTextBox="{Binding ElementName=editor}" Xaml="{Binding MyXaml, Mode=TwoWay}" />
string html = @"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <title>Untitled</title> <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <style type='text/css'> .p_CC664AAA { margin: 0px 0px 12px 0px;text-align: left;text-indent: 0pt;padding: 0px 0px 0px 0px; } .s_1681A555 { font-family: 'Times New Roman';font-style: Normal;font-weight: normal;font-size: 16px;color: #000000; } </style> </head> <body> <p class='p_CC664AAA'> <span class='s_1681A555'>This is <strong>bold</strong> text, this is <em>italic</em> text, and this is <span><u>underlined</u></span> text.</span> </p> </body> </html>"; //Workaround for a bug in the RadRichTextBox control XamlDataProvider provider = new XamlDataProvider(); provider.FormatProvider = new HtmlFormatProvider(); provider.Xaml = html; provider.RichTextBox = new RadRichTextBox(); MyXaml = new XamlFormatProvider().Export(provider.RichTextBox.Document);
Once the xaml is loaded you can extract the html from the radrichtext editor:RadDocument doc = new XamlFormatProvider().Import(MyXaml); string html = new HtmlFormatProvider().Export(doc);
1. FormatProviders are meant to be used when you import/export a document to one of the supported formats. For example, they are used in the OpenDocumentCommand and SaveCommand which open/save documents as files on the client machine through the OpenFileDialog and the SaveFileDialog.
2. DataProviders are built on top of FormatProviders in order to enable data-binding. They track when the document content is changed and update the property that they are bound to and vice versa - update the document when the property notifies that it has been changed. The data providers create an instance of the respective format provider internally (HTML, XAML, etc.) and use it to import/export the document.
Now, the code in your snippet that creates a XamlDataProvider, HtmlFormatProvider and RadRichTextBox in code-behind and exports the document to XAML is equivalent to:
RadDocument document =
new
HtmlFormatProvider().Import(html);
MyXaml =
new
XamlFormatProvider().Import(document);
Since there is no problem with the HTML import, as well as XAML import and export, "document" will be correct and will have all the formatting specified in the initial string. Due to the fact that you are using XamlDataProvider in XAML, the content of the RadRichTextBox will also be correct.
Proceeding with your code, importing MyXaml will just create the same document as the one kept in "document" ("doc" will be the same as "document", correctly preserving the formatting).
Then, when you export the document with the default HTML export, the underlines will be lost again. The value of html at the end will be as in the attached file. As you can see, the style for the underlined span (s_C676007D) does not include an underline.
So, basically, you have two options:
1. Use XamlDataProvider in XAML, just convert the initial input to XAML as in my first snippet.
2. Use HtmlDataProvider in XAML, setting StyleRepositoryExportMode to DontExportStyles, as in the snippet in my previous post.
I hope this helps.
All the best,
Iva Toteva
the Telerik team
Now when i use dashed,dotted or wave types underline then it showing on the selected text but when i save it and try to reaccess it from database then it will display as a normal underline not one which is selected i.e wave, dashed or dotted..
I was not able to set ExportFontStylesAsTags option of HtmlExportSettings to true.
please suggest some solution for it.
HtmlFormatProvider exports all underlines as Single underlines, i.e. using the text-decoration property and setting it to underline (text-decoration: underline;). We will consider implementing different export of the underlines, but it is not clear if and when it will be implemented.
When it comes to the ExportFontStylesAsTags property, it has been introduced in one of the latest versions, so the reason why you can't set it is probably that you are using an older version of the controls. However, when you set it to "True", the underlines will be exported as <u>[underlined text]</u> and again the style of the underlines will not be saved.
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thank you.
As Iva posted, in the current version the default HtmlFormatProvider doesn't preserve the underline style in the output HTML. We will, however, consider adding such feature in future releases.
Regards,
Boby
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thank you.
We are not aware of any issues with the XAML export and import of underlines. Overall it is recommended to use XAML to persist documents viewed in RadRichTextBox, because XAML is closest to our internal document format and ensures best serialization of all rich text features. In comparison, HTML format provider does not persist headers and footers and some other properties that have no analog in HTML.
Kind regards,Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Is there any progress for this case.
I'm dealing with exactly the same scenario.
Thanks in advance,
Salim
[quote]Boby said:Hello Chaitanya,
As Iva posted, in the current version the default HtmlFormatProvider doesn't preserve the underline style in the output HTML. We will, however, consider adding such feature in future releases.
Regards,
Boby
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
At the moment we don't plan on implementing import and export of the underline style for the HTMLFormatProvider. One of the main reasons for this is that the text-decoration-style property is not supported by most browsers.
Regards,
Anna
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Hi Anna,
How can I remove/hide Underline decorations on the font properties dialog ?
Thanks
I am attaching a solution which demonstrates an implementation of a custom font properties dialog with the Underline section removed.
I hope this helps.
Regards,
Anna
Telerik
See What's Next in App Development. Register for TelerikNEXT.