I have this issue about the rich text editor that I hope someone can
help with. Basically, I want to be able to insert the string
'<!--pagebreak-->' at a certain caret index. This works fine when I
use the textarea.text property but when I use textarea.htmlText, it
inserts the '<!--pagebreak--> 7 characters before the caret. This is
because it counted the format '<B></B>' as indices. To
illustrate what I meant. Take a look:

TEXT INSERTING:
The <B>United States</B> is acting in step with Europe, where
governments often take a more interventionist stance in economies and
the financial systems are in the hands of a comparatively small number
of banks.
[CURSOR GOES HERE]
Britain took the lead last week, declaring its intention to take
equity stakes in banks to steady them. In the last two days, France,
Italy and Spain have announced rescue packages for their banks that
include state shareholdings.

RESULT:
The <B>United States</B> is acting in step with Europe, where
governments often take a more interventionist stance in economies and
the financial systems are in the hands of a comparatively small number
of <!--pagebreak-->banks.

Britain took the lead last week, declaring its intention to take
equity stakes in banks to steady them. In the last two days, France,
Italy and Spain have announced rescue packages for their banks that
include state shareholdings.

CODE:
var carIndex:int = textArea.getTextField().caretIndex;
var beginText:String = this.htmlText.substring(0, carIndex);
var endText:String = this.htmlText.substr(carIndex,this.htmlText.length);
var text:String = beginText + "\n &lt;!--pagebreak--&gt; \n" + endText;
this.htmlText = text;

I can use the 'text' property but then I will lose all my formatting. 

Can anyone think of a solution?

Thanks

Reply via email to