Feedback on RichTextBox (Html) (2011_2_11_712)

2 posts, 0 answers
  1. Arthur Colman
    Arthur Colman avatar
    5 posts
    Member since:
    Dec 2006

    Posted 14 Sep 2011 Link to this post

    I really want to use the RichTextBox in an application I'm finalizing but I have been stymied by the issues I've enumerated below. Firts of all let me provide some background on my particular use so that you can determine if the scenario applies broadly.

    Scenario: RichTextBox is used to create Html fragments that are integrated into a finished document where formatting (headings and indents) are adjusted by where the fragment appears in the documents outline hierarchy. Fragments are created as if they are at level 1 (one) and the indent level is programmatically adjusted by where in the outline the fragment appears.

    To the best of my knowledge...
    1. HtmlFormatter translates Hn tags to <p> tags presents a challengs.
    2. Import process defines classes using some sort of internal naming approach. (I'd like associated classes and their name to be retained.)
    3. Providing an embedded stylesheet within an imported html document is not used.
    4. StyleDefinition(s) do not provide an ability to "name" the definition so that they can be programmatically assigned to a paragraph or span. (There may be a StyleProperty that supports this but I could not determine it.)
    5. I was pursueing the approach of wrapping the existing HtmlFormatter object and extending its utilty but many of the underlying classes are exposed at the Friend level versus Public level which prevents this approach

    My application is very concerned with **structure** while the RichTextBox is very concerned with retaining **style**. Whle addressing my point 1 above solves all my concerns points 2 - 5 I believe would be of value to other implementers.

    I'm going to have to fall back to using the web based Editor (which presents its own set of restrictions) but I will anxiously be watching developments in the RichTextBox as I believe that once finalized it will be an excellent product.

  2. Svett
    Admin
    Svett avatar
    728 posts

    Posted 20 Sep 2011 Link to this post

    Hi Arthur,

    Please see below the answers to your questions as you have listed them.
    1. HtmlFormatter translates Hn tags to <p> tags presents a challengs.

      At this point, predefined styles are not supported. Therefore, the Hn tags are imported as paragraphs with the respective font settings and are exported as <p> elements. We plan to introduce support for predefined styles in one of the next releases.

    2. Import process defines classes using some sort of internal naming approach. (I'd like associated classes and their name to be retained.)

      In order to make the current behavior clearer, let me elaborate a bit on the import and export. 

      The internal format of the document in RichTextBox consists of a RadDocument, Sections, Paragraphs, Spans, etc. It is quite different from HTML and therefore the control cannot be used as an HTML editor of sorts. At the time of import of a document of some format, the input is used to create a RadDocument taking into consideration the elements and properties that have corresponding ones in the document model. Therefore, there is no direct parallel between the imported HTML and the HTML that is being exported. In that notion, the RichTextBox differs greatly from RadEditor for ASP.NET AJAX, which can use the browser to render the HTML and show a preview of the document.

      As for the names of the classes, they are actually set on export, as the StyleDefinitions do not have a “Name” property. Persisting information about the HTML input like the names of the classes and the styles is not supported and will not be possible because paragraphs and span are split and merged dynamically and there will be no way for determining if the style should be changed, or the paragraphs and spans should be associated with new styles.

    3. Providing an embedded stylesheet within an imported html document is not used.

      If the stylesheet is included in the HTML document at the time of the import, we would appreciate a sample document illustrating the wrong import. In case you want to import a document and apply a style declared as a stylesheet afterwards, this is not possible due to the reasons specified above. Namely, after the import of the document, a RadDocument is created out of it with the current formatting defined, and it knows nothing about stylesheets and HTML formatting.

    4. StyleDefinition(s) do not provide an ability to "name" the definition so that they can be programmatically assigned to a paragraph or span. (There may be a StyleProperty that supports this but I could not determine it.)

      StyleDefinition does not have a Name property, but you can programmatically set the style of a Span or Paragraph like this:
    5. StyleDefinition style = new StyleDefinition();
      style.SetPropertyValue(Paragraph.BackgroundProperty, Color.Red);
      paragraph.Style = style;
    6. I was pursueing the approach of wrapping the existing HtmlFormatter object and extending its utilty but many of the underlying classes are exposed at the Friend level versus Public level which prevents this approach

      As a license holder of our Ultimate collection, you can download the source of the control and apply the changes you see fit there. However, you should have in mind that we do not support the source code and any changes that you apply to it.

    Best wishes,
    Svett
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top