This is a migrated thread and some comments may be shown as answers.

Importing HTML has issues with bullet styles

8 Answers 253 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Scott Michetti
Top achievements
Rank 1
Scott Michetti asked on 20 Oct 2015, 06:57 PM

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

Sort by
0
Scott Michetti
Top achievements
Rank 1
answered on 22 Oct 2015, 02:52 PM
Any thoughts on this one?
0
Tanya
Telerik team
answered on 23 Oct 2015, 01:48 PM
Hi Scott,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Scott Michetti
Top achievements
Rank 1
answered on 26 Oct 2015, 08:40 PM

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

0
Scott Michetti
Top achievements
Rank 1
answered on 27 Oct 2015, 03:40 PM

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

0
Tanya
Telerik team
answered on 29 Oct 2015, 11:08 AM
Hello 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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Scott Michetti
Top achievements
Rank 1
answered on 29 Oct 2015, 05:04 PM

Thanks Tanya,

I tried out your code and it does exactly what I need!!! This is a big help.

 

Thanks again,

Scott

0
Jayesh
Top achievements
Rank 1
Veteran
answered on 09 Nov 2020, 11:40 AM

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>

 

0
Tanya
Telerik team
answered on 11 Nov 2020, 01:32 PM

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/.

Tags
RichTextBox
Asked by
Scott Michetti
Top achievements
Rank 1
Answers by
Scott Michetti
Top achievements
Rank 1
Tanya
Telerik team
Jayesh
Top achievements
Rank 1
Veteran
Share this question
or