Results 1 to 2 of 2

Thread: HtmlEditor replace <br> with <br/>

  1. #1
    Ext JS Premium Member
    Join Date
    Jan 2011
    Posts
    52
    Answers
    1

    Default HtmlEditor replace <br> with <br/>

    When a newline is created in the HtmlEditor field, it is done by wrapping a <br> inside a div block. Due to a backend component requirement, I need to ensure the <br> is closed (i.e. insert <br/> instead). Unfortunately I can't post-process the field on the server to achieve this.

    Is there any way I can override the HtmlEditor field's behaviour to insert a <br/> instead of a <br>? Is this even something that HtmlEditor does? Perhaps it's default browser behaviour ... if so, how would I go about handling that? Check for the browser type and capture <enter> events, ... then? :-)

    Thanks in advance!

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    We actually don't control the line breaks (unless it's IE). The html that is inserted into the textarea actually comes from a body.innerHTML call which comes directly from the browser. You can see this in the syncValue method of the HtmlEditor.

    To do this yourself, you can override the cleanHtml method and return the new html so you can replace <br> with <br />
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •