Hello,
I'm importing simple HTML and the bullets are showing up as all disc types. They should be square, disc, then circle. Is this a bug or do I need to do something else to make this display correctly? Loading the html into Chrome or IE will show the correct display.
Thanks,
Scott
HtmlFormatProvider htmlFormatProvider = new HtmlFormatProvider();
string htmlString = "<!DOCTYPE html><html><head></head><body><ul><li type='square'>This is a square</li><li type='disc'>This is a disc</li><li type='circle'>This is a circle</li></ul></body></html>";
radRichTextBox.Document = htmlFormatProvider.Import(htmlString);
8 Answers, 1 is accepted
The type attribute is not supported by HtmlFormatProvider. We have this feature request already logged and you could vote for its implementation and track our progress on it through the related item in our feedback portal.
Regards,
Tanya
Telerik
Thanks for the reply Tanya. Hopefully you will get that implemented in the not too distant future. I'm trying to import and export to and from the Telerik WPF control and the Telerik ASP.NET Editor. The WPF control does not support the HTML and the ASP.NET Editor does not support the exported XAML from the WPF control, so I'm having a hard time having the two communicate with each other.
One other question. Can you tell me how to set the default bullet styles in the WPF RadRichTextBox? And is there a way to check each line to see if there it is a bullet?
Maybe I can force the bullet styles without depending on the HTML.
Thanks,
Scott
I found how to change the default bullet styles.
DefaultListStyles.Bulleted.Levels[0].LevelText = "-";
DefaultListStyles.Bulleted.Levels[1].LevelText = "+";
DefaultListStyles.Bulleted.Levels[2].LevelText = "O";
Now I just need to loop through the text. I'm doing the following:
DocumentPosition position = new DocumentPosition(this.radRichTextBox.Document);
position.MoveToFirstPositionInDocument();
position.MoveToCurrentLineStart();
But I don't know how to loop through the document checking for bullets. Something like the following pseudocode is what I am thinking.
foreach(Line L in radRichTextBox.Document)
{
if( L is a bullet)
{
radRichTextBox.ActiveDocumentEditor.ChangeParagraphListStyle(DefaultListStyles.Bulleted);
}
}
Thanks,
Scott
To work with both editors, you could check the supported formats by each control and choose one, which could fit your needs and it is supported by each editor. At this point, RadEditor for ASP.NET AJAX supports import/export to RTF and DOCX. The mentioned formats are supported in RadRichTextBox as well.
For more information you could check our documentation about the controls:
- RadRichTextBox for WPF
- RadEditor for ASP.NET AJAX
Regarding the lists, they are a property of the Paragraph and you could check if there is an associated list style through the IsInList property:
IEnumerable<Paragraph> paragraphs =
this
.radRichTextBox.Document.EnumerateChildrenOfType<Paragraph>();
foreach
(var paragraph
in
paragraphs)
{
if
(paragraph.IsInList)
{
radRichTextBox.Document.CaretPosition.MoveToStartOfDocumentElement(paragraph);
radRichTextBox.ActiveDocumentEditor.ChangeParagraphListStyle(DefaultListStyles.Bulleted);
}
}
Note that the ChangeParagraphListStyle() method will apply the new list style to the paragraph, where the caret position is, and you will need to move the caret in order to change the style of the currently iterated paragraph as illustrated in the snippet.
Hope this helps.
Regards,
Tanya
Telerik
Thanks Tanya,
I tried out your code and it does exactly what I need!!! This is a big help.
Thanks again,
Scott
How to generate html without any inline style in HTMLDataProvider for RadRichTextBox control in wpf.
My Output is : <ol><li value=\"2\" style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;text-indent: 0px;line-height: 1.15;font-family: 'Verdana';font-size: 16px;color: #000000;\"><span style=\"font-family: 'Segoe UI';font-size: 13.33px;color: #000000;\">Procedure to Clean Oil tank</span></li></ol>
Required Output is : <ol><li value=\"2\"><span style=\"font-family: 'Segoe UI';font-size: 13.33px;color: #000000;\">Procedure to Clean Oil tank</span></li></ol>
Hello Jayesh,
I can see that there is a discussion on the matter in the other thread you have opened. Let's keep the conversation there to avoid any miscommunication between the different threads.
Regards,
Tanya
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.