Actually, if you create a BreakElement at the right place, it isn't substituted
for a line break character "\n", and it isn't stripped out when you convert to
TLF or HTML code.

As fortune would have it, I am dealing with exactly that TLF issue right now in
my project. I can't share the actual source, but I can tell you how I did it:

1) Create a break element <br /> manually:
        - ideas for solving it were in "I wanted to contribute some code...":
http://stackoverflow.com/questions/9937419/how-do-i-insert-a-spanelement-in-a-textflow
        - but splitting the TextFlow and re-assembling really wasn't cutting it 
for
complex structures like lists
        SOLUTION:
        1. find the LeafElement for the cursor position (which is a SpanElement)
        --> textflow.findLeaf(interactionManager.activePosition) as SpanElement
        2. find the relative position of the cursor within that SpanElement
        --> since there is no way to get the absolute cursor position relative 
to a
LeafElement, for this you need a hack comparing strings indexed from
cursorPos+pxAfter and cursorPos-pxBefore with SpanElement.getText();
        3. find the parent ParagraphElement for that LeafElement
        --> targetPara = leafElement.getParagraph();
        4. find the index for that SpanElement within the ParagraphElement (b/c 
you
might have several SpanElements within a ParagraphElement
        --> leafElement.getParagraph().getChildIndex(leafElement);
        5. split the SpanElement
        --> leafElement.splitAtPosition(relPos);
        6. insert BreakElement after the 1st part of the original SpanElement
        --> targetPara.addChildAt(leafIndex+1,flowElement);

2) Allow for creation of break element <br/> with Shift-Enter (not natively
supported):
        1. detect the shift-key pressed
        2. disable the default Enter key behaviour [it's read-only, so you have 
to use
your own]
        --> config = editor.textFlow.configuration as Configuration;
        config.manageEnterKey = false/true;
        3. if the Enter key is pressed right after, then create a line break at 
the
cursor (see above)
        4. on Mouseup on the Shift key, restore default Enter key behaviour (so 
new
<li> or <p> work)


_______________________________________________________________________

Joseph Balderson, Flex & Flash Platform Developer :: http://joeflash.ca
Author, Professional Flex 3 :: http://tinyurl.com/proflex3book

Scott Matheson wrote:
> Hi
>    I am trying to build a Paragraph from sentences,
> 
> this builds the Paragraph (from am XML file and itemRender)
> 
> the build function looks like
> 
> 
> var linkWrapper:LinkElement = new LinkElement();
> 
> var sentence:SpanElement = new SpanElement();
> 
> sentence.styleName = 'linkStyle';
> 
> sentence.textDecoration = TextDecoration.NONE;
> 
> sentence.text = model.text + " ";
> 
> linkWrapper.addChild(sentence);
> 
> paragraphArea.addChild(linkWrapper);
> 
> 
> 
> Layout
> 
> 
> 
> <s:TextArea id="ta" minHeight="0"  width="100%" editable="false"
> 
> <s:p id="paragraphArea" paragraphSpaceBefore="0">
> 
> </s:p>
> 
> </s:TextArea>
> 
> 
> 
> I get
> 
> 
> sentence1
> 
> sentence2
> 
> sentence3
> 
> 
> 
> my problem is how to i add a <br> in to the Paragraph and end up with
> 
> 
> sentence1
> 
> 
> sentence2
> 
> 
> sentence3
> 
> 
> 
> it would be good if the  input text  model.text  could be 
> "sentence1<br>sentence2<br>sentence3"
> 
> 
> 
> 
> 
> ________________________________
> 
> Disclaimer: This electronic mail and any attachments are confidential and may 
> be privileged. If you are not the intended recipient, please notify the 
> sender immediately by replying to this email, and destroy all copies of this 
> email and any attachments. Thank you.
> 

Reply via email to