Importing HTML has issues with bullet styles

7 posts, 0 answers
  1. Scott Michetti
    Scott Michetti avatar
    92 posts
    Member since:
    Feb 2010

    Posted 20 Oct 2015 Link to this post

    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);​

  2. Scott Michetti
    Scott Michetti avatar
    92 posts
    Member since:
    Feb 2010

    Posted 22 Oct 2015 Link to this post

    Any thoughts on this one?
  3. UI for WPF is Visual Studio 2017 Ready
  4. Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 23 Oct 2015 Link to this post

    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
  5. Scott Michetti
    Scott Michetti avatar
    92 posts
    Member since:
    Feb 2010

    Posted 26 Oct 2015 in reply to Tanya Link to this post

    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

  6. Scott Michetti
    Scott Michetti avatar
    92 posts
    Member since:
    Feb 2010

    Posted 27 Oct 2015 Link to this post

    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

  7. Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 29 Oct 2015 Link to this post

    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
  8. Scott Michetti
    Scott Michetti avatar
    92 posts
    Member since:
    Feb 2010

    Posted 29 Oct 2015 in reply to Tanya Link to this post

    Thanks Tanya,

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

     

    Thanks again,

    Scott

Back to Top
UI for WPF is Visual Studio 2017 Ready