5 Feb 2013 5:12 AM #1
Unanswered: 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!
7 Feb 2013 8:06 AM #2
- Join Date
- Mar 2007
- Gainesville, FL
- Vote Rating
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 @SenchaMitch
Sencha Inc, Senior Software Engineer
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services email@example.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!
When posting code, please use BBCode's CODE tags.