Copy link to clipboard
Copied
It seems to me that a very powerful aspect of TLF is the ability to loop through an XML tree and apply custom styling based on your own logic (via IFormatResolver). What I find disappointing is TextConverter's inflexibility and lack of direct TextField-style HTML/StyleSheet support. The docs say that TLF supports the same HTML tags as TextField via TextConverter.HTML_FORMAT. This may be true but it does not support them in the same manner. For example, TextField allows me to create a tag called <whatever> and have a corresponding style in a stylesheet. TextField also allows me to have an <a> be a child of a <span>. TLF is very anal about what tags can be where and what attributes they can have. In order for me to fully leverage IFormatResolver, I should be able to apply styles based on my own tag names and tag attributes.
When calling ITextImporter.importToFlow, where is the validation occuring? Is there an XSD? Can I override this validation? The strictness causes much pain when dealing with user-input as the source.
I wish TLF was more lenient when importing and would let me decide what to do with "bad" tags and attributes.
Copy link to clipboard
Copied
Hello all - Is there no hope here? Do I need to rip apart TLF and invent my own importer?
Copy link to clipboard
Copied
Its not clear which importer you are trying to use. Work is underway in the HTML importer to support custom tags. Note that because the HTML importer supports the TextField flavor of HTML which is non-standard we are now calling it "textFieldHTMLFormat".
The TEXT_LAYOUT_FORMAT markup importer doesn't support custom tags - you can accomplish the same thing by preprocessing the markup and making the elements a span with a styleName. TLF spans are not the same as HTML spans. In HTML a span is a grouping element. TLF spans are more akin to HTML text nodes. We have logged a request for a grouping element similar to an HTML span but are not implementing it at this stage of the development cycle. Implementing the grouping behavior of span (and links as children of spans) is going to be difficult without that grouping element and will require more work.
If you need to build a custom importer for your particular markup definition go for it. You should be able to write your own importer - other folks are. Hopefully the TLF importers can be of some help. I'd recommend not calling it "textLayoutFormat" but giving it some name of your own choice. This can be done without modyfing TLF itself so you can still continue to use the public RSLs etc.
Hope that helps,
Richard
Copy link to clipboard
Copied
I am using the HTML_FORMAT importer.
Work is underway in the HTML importer to support custom tags
Is this work available in SVN yet?
Implementing the grouping behavior of span (and links as children of spans) is going to be difficult without that grouping element and will require more work.
That's too bad - this is the main thing I find very restricting. Looks like I'm going to give a stab at a customer importer.
Thanks for your help Richard,
Matt
Copy link to clipboard
Copied
If you need to build a custom importer for your particular markup definition go for it. You should be able to write your own importer - other folks are
This is proving to be hard because of extensive internal namespacing in TLF. Do you have any recommendations?
Copy link to clipboard
Copied
Hi,
I'm dealing with this same issue ATM as well. The problem is I have a ton of content in HTML format. If any of it contains an error it breaks the whole project.
For example, I get this error on one of the records,
TypeError: Error #1085: The element type "div" must be terminated by the matching end-tag "</div>".
I know it should be closed off but this code was generated by an HTML Rich Text Editor. There could be tons of these.
I know too that there is a HTML_Formatter but it lacks link support plus many other features. If I have to use that I can't benefit from the TLF framework.
What I need is a loose mode to fall back on in case errors are encountered or a method to "close up unterminated element tags" and remove or replace non supported tags. I should have just said, I need something to make my code HTML markup valid to the TLF in as much as it can.
Randomly thoughts, a property I can enable for loose mode, a method that returns a valid textflow tree from xml or string markup, a method that imports loose markup into a textflow.
Copy link to clipboard
Copied
thx1138,
Are you converting the String containing HTML markup to an XML object? That's where you'd encounter errors like the one below.
I'd recommend passing the String directly to the HTML importer. While the current implementation of the HTML importer is quite strict, it will at least handle cases like missing end tags.
A more tolerant implementation of the HTML importer is in the works. It is intended to be compatible with the HTML fomat used by TextField.htmlText. Stay tuned.
Abhishek
(Adobe Systems Inc.)
Copy link to clipboard
Copied
I'll be eagerly awaiting!
I'm importing from a string into a TextFlow markup from HTML content:
<s:RichEditableText width="100%" y="52" styleName="postDescription" text="Description area"
editable="false" lineBreak="toFit"
textFlow="{TextFlowUtil.importFromString(TLFFormatter.format(XML(postsRepeater.currentItem).content))}"/>
The TLFFormatter class removes tags that TLF format doesn't support. Using import from string allows me to import HTML markup without the namespace, for example, "<p>" works.
Copy link to clipboard
Copied
Hi Abhishek,
I just read new documentation on mx and spark Text controls and I misunderstood the HTML importer. If that class will import HTML markup and convert HTML tags like "<p>" to TLF class elements like "<s:p>" is it possible for it to remove or ignore tags it doesn't understand? For example, if it encounters a "<em>" tag can the importer have settings to remove or ignore this tag? And can we have it fix or ignore our code so it follows the rules of TLF and mercifully ignore without error if for example, <div> accidentally happens to be a child of a <p> tag?
If I understand it correctly will we be able to have our own components in a TLF text flow? For example, if we have this markup, "<p>My music player<br/><local:MusicPlayerComponent width='100%' height='200'/></p>"
Will we be able to embed our own components like that?
Sorry, lots of questions.
Copy link to clipboard
Copied
Hi,
The revised implemenation of the HTML importer that I had mentioned in the previous post is more tolerant is that it allows missing end tags, unknown elements, unknown attributes, invalid attribute values etc.
However, it won't allow violations of TLF object model constraints, such as a <p/> inside an <a/>.
As for unknown tags like <em>, they are ignored. I am not sure what you mean by having your own components in a TLF text flow. In your example,<local:MusicPlayerComponent> will get the same treatment as <em>; it too will be ignored.
Abhishek
Copy link to clipboard
Copied
TLF supports the following tags:
At the same time, each node has an ActionScript class implementation: TextFlow, DivElement, ParagraphElement, LinkElement, TCYElement, SpanElement, InlineGraphicElement, TabElement, and BreakElement. All these classes inherit directly or indirectly from the class FlowElement.
Can we create our own class implementations inherited directly or indirectly from FlowElement? For example, if I wanted to create a TableElement, a
ChartElement, a SyntaxHighlightElement, VideoElement, a MusicElement, etc
My original question pertained to embedding a regular MXML Component, like mx:List, mx:DataGrid, mx:Button, etc.