Skip to main content
Inspiring
January 23, 2009
Answered

How to dynamically add new FlowElement to existing TextFlow via TLF markup

  • January 23, 2009
  • 3 replies
  • 1341 views
Is there a way to create a new FlowElement (such as a DivElement) from markup text without having to go through the TextFilter.importToFlow function?

What I am trying to accomplish is this:
I have a TextFlow already built.
I receive some text that I want to inject into the TextFlow as a new element somewhere in the existing TextFlow.

The method that I am using to accomplish this is, to create a second TextFlow from the markup via the importToFlow Function. Then I get the element from the second flow and make a deepCopy of it into a new "unowned" element. Lastly, I use this new "unowned" element in my main code by adding it as a child of the original TextFlow.
My function that does this is attached.
Thanks.
Tim
This topic has been closed for replies.
Correct answer joe.shankar
There isn't any way to do it today without using importToFlow.

Sounds like what you want is is similar to innerHTML and innerXHTML. Ideally TLF would provided implementations for getInnerTLFMarkup and setInnerTLFMarkup for use as described below. I also suspect that if TLF were to implement these functions today we would use importToFlow under the hood.

// read markup
var flowElement:FlowElement = getFlowElement();
var tlfMarkup:String = getInnerTLFMarkup(flowElement);

// write markup
var flowElement:FlowElement = getFlowElement();
var tlfMarkup:String = getTLFMarkup();
setInnerTLFMarkup(flowElement, tlfMarkup);

3 replies

tpf70Author
Inspiring
February 20, 2009
Yes Joe.
In essence this is what I am looking to do.

I have implemented a way to do this as I described above, I just feel this is really inefficient (if not a hack), and it seems like this sort of functionality would be something that more folks would want.
Tim
Adobe Employee
January 26, 2009
Are you trying to add plain text to an existing TextFlow, such that the plain text is put into a div? That's pretty straightforward. You can create a new DivElement, attach it the TextFlow, and then add the text in.

Or do you have a markup snippet, such as:
<div><p fontSize = "21">Hello There</p><div>
And you want to resolve that to a DivElement which you then insert into the TextFlow? This latter one is not supported. It is something we've considered doing though.

Which one are you looking for?
tpf70Author
Inspiring
January 26, 2009
I am looking to create flow elements that could be any arbitrary TLF supported markup and add the resulting created components as a child(children) to either the root text flow of some other child node of the root text flow.

In short terms... I am looking to inject arbitrary TLF markup into an existing TextFlow.
joe.shankarCorrect answer
Adobe Employee
February 19, 2009
There isn't any way to do it today without using importToFlow.

Sounds like what you want is is similar to innerHTML and innerXHTML. Ideally TLF would provided implementations for getInnerTLFMarkup and setInnerTLFMarkup for use as described below. I also suspect that if TLF were to implement these functions today we would use importToFlow under the hood.

// read markup
var flowElement:FlowElement = getFlowElement();
var tlfMarkup:String = getInnerTLFMarkup(flowElement);

// write markup
var flowElement:FlowElement = getFlowElement();
var tlfMarkup:String = getTLFMarkup();
setInnerTLFMarkup(flowElement, tlfMarkup);
Inspiring
January 26, 2009
Are you trying to add plain text to an existing TextFlow, such that the plain
text is put into a div? That's pretty straightforward. You can create a new
DivElement, attach it the TextFlow, and then add the text in.

Or do you have a markup snippet, such as:
<div><p fontSize = "21">Hello There</p><div>
And you want to resolve that to a DivElement which you then insert into the
TextFlow? This latter one is not supported.

Which one are you looking for?