Skip to main content
Participating Frequently
January 28, 2010
Question

Extending flow leaf elements

  • January 28, 2010
  • 1 reply
  • 976 views

Hi I was wondering if anybody has any links to resources about extending the TextLayout Components?
Specifically I have a need to add new flow elements to the the text flow. I need to add new HTML elements not included in the current spefication or at the very least extend text flow to ignore instances of these elements in XML I convert via the text converter.
At the moment the following fragment of XML would break the XML to TextFlow conversion

<XML >

<blockquote>

<p><span>HELLO WORLD</span></p>

</blockquote>

</XML>

simply because of the block quote.
Basically I want a simple HTML editor
but I would settle for an editor that I can pass in elements that do not break the tet flow. I have a copy of the open source Text layout framework for reference and I am competant enough to extend classes etc.

All help greatly appreciated

This topic has been closed for replies.

1 reply

Adobe Employee
January 28, 2010

There are two basic ways to implement what you're looking for. First, you can change the XML import code to create the correct text layout. In this case, it would mean adding the <blockquote> element to the converter for TLF markup (TextConverter.TEXT_LAYOUT_MARKUP). Second, you could extend the FlowElement hierarchy to include additional elements, which would also require extending all the rest of TLF to understand what to do with the new elements. The second is much more work than the first, and in fact the FlowElement hierarchy was not designed with this kind of extension in mind (many classes are marked as final). The main feature you would get from doing the second that you don't get from the first would be round-tripping. There may be an easier to get that, if you require it.

What I would suggest is that you start by updating the TextLayoutImporter to understand <blockquote> and create a <div> with the required formatting attributes attached to get the correct look. If roundtrippping is critical, you can attach to the <div> some private style data that identifies it as a blockquote. Then update the TextLayoutExport to convert export of a <div> with a blockquote style data attached to a blockquote. Then you don't need to do anything special to the editing or composition code to deal with blockquotes.

Would this approach work for you?

- robin

wtf2009Author
Participating Frequently
January 29, 2010

Fantastic answer and very much along the lines I was looking for.If you've got the time could you answer this question; Would it be possible to use a custom flowmanager ( or interaction manager ) to rend the appearance of divs with special style data in a different way. What I'm thinking is that you could have divs render elements in the editor differently to create pseudo - html. Ie under the hood it would be achieved with DIV tags but to the user it would appear like standard html and of course as you say the exported output would be correct html / XML

Adobe Employee
January 30, 2010

It's possible, of course. But it is a ton of work, because you'd have to have you own custom flowComposer, with its own ComposeState. That's a lot of work. It's several orders of magnitude easier to use the formatting attributes already defined to  (indents, etc.) to get the look the way you want. Maybe if someone on the forum has successfully done it themselves they could advise you better on how hard it is.

Hope this helps,

- robin