Skip to main content
December 24, 2010
Answered

TLF textFlow query

  • December 24, 2010
  • 1 reply
  • 1482 views

Hi everyone,

I have an issue regarding TLF which I have got stuck with. Actually my requirement is regarding the TextFlow.

I am working on an app which should load an XML and display it on a TextArea, and I was interested in using the TLF for the same.

Now the problem is that I have an XML which has tags such as <ParagraphStyle>,<CharacterStyle>. So now I saw some exapmles and was wondering that how can we use textFlow for the same as the TextFlow syntax supports tags like <p>, <div>, <span>, etc.

So what should I follow for the same ?

This topic has been closed for replies.
Correct answer robin_briggs

Ok, thanks for the help Robin.

But now I have another problem. When I press Enter key in my document, on export it gives me <p><span><span/><p/> .

I read the same issue in these forums, but still couldn't find a suitable way to implement the same. I tried overriding the keyDownHandler, and tried some way to prevent the extra  <p><span><span/><p/> values, but nothing helped.Also I was unable to prevent it from going to its parent. I used event.preventDefault() but still it crearted a new paragraph. So how to stop it from calling the parent. The max I could get from the code was:

<p><span>Some text.</span></p>

<p><span><br/><span/><span>The text after I pressed Enter key<span/><p/>.

I actually want is that instead of creating a new paragraph and a span, I get a <br /> element. So that when I press the Enter key, I get <br/> attached to the text on export.


So can you please guide me on how can I handle this issue.

Thanks.


Here are some ideas, I'm not sure what will work best for you - it depends on the details of what you want.

If all you want is for the enter key to insert <br/>, you can just tell TLF not to handle the enter key, and then you can handle it yourself by inserting a break.

To turn off the automatic handling of the enter key, you turn it off in the Configuration object before you create the TextFlow. There is a single default Configuration used for creating TextFlows when the Configuration is not specified, or it can be overridden when you construct each TextFlow. So if you want to handle the enter key for ALL TextFlows in the application, change the TextFlow.defaultConfiguration.manageEnterKey=false. Otherwise create a new Configuration instance, set manageEnterKey=false, and use that instance when creating TextFlows.

Then create a class that inherits from EditManager, and overrides the keyDownHandler function. In the case where the event.charCode is Keyboard.ENTER, call editManager.insert('\u2028'). This will end the line, but extend the paragraph, and is identical to a <br/>.

Note that  growing a huge paragraph (e.g., multiple page's worth of printed text) is likely to cause performance degradation.

Hope this helps,

- robin

1 reply

Known Participant
December 31, 2010

Eshaan

Don't know if it will help you but yes you can, just remember that TFL requires a special Namespace, but as long as you add this namespace to the XML file you should be able to use TFL tags to format text in a RichText Component.

Buabco

Adobe Employee
January 4, 2011

There's a description of the TLF XML format on our blog, see:

http://blogs.adobe.com/tlf/2010/12/tlf-1-0-markup-specification.html

You'll have to translate from the XML format you have coming in with CharacterStyle and ParagraphStyle to TLF format, but once you've done that, Flex will do the rest for you.

Can you tell me what format you're translating from? Is it InDesign, or something else?

Thanks,

- robin

January 5, 2011

Hi Robin,

Thanks for the reply, I was also following this approach, to first translate my XML to TLF format and then Flex can automatically render the content.

Ya I am trying to convert from a InCopy/InDesign file.

I am thinking of using XSLT for conversion. Would that be useful, or is there any better approach for the same ?

Thanks.