Text Layout Framework Follow Up and Request

UPDATE: I’ve posted a solution to this PureMVC + Text Layout Framework integration here (this applies not just to PureMVC, but anywhere you want to use your own “undo” stack in an MVC application).I’m having a bit of a tricky time with integratin…

UPDATE: I’ve posted a solution to this PureMVC + Text Layout Framework integration here (this applies not just to PureMVC, but anywhere you want to use your own “undo” stack in an MVC application).


I’m having a bit of a tricky time with integrating the TLF into an application which already has an “undo” system. The TLF has itself an UndoManager, but more on that later…

The public demo’s are all quite concise, showing the functionality of the TLF in a small amount of code, but I wonder if it’s possible for someone at Adobe to take a look at how people might be using the Text Layout Framework when they have implemented their own application-wide Undo stack which I believe is quite common for RIAs now.

The reason for this request is that the built in UndoManager for the TLF is great but it appears to lack extension points, so getting out of the View tier in order to maintain this “stack” becomes a bit of a nightmare…

Take for example PureMVC’s Undo utility (CommandHistoryProxy). I’m using this for every user action, from moving/scaling things on stage, to picking files for image components, to adding/deleting things from stage, and hopefully, editing text; every operation aims to be undo-able.

The way the TextFlow class works makes it very hard to get it to work within this setup. I’ve got a work-around now, but not exactly elegant as I now pollute my model (which previously stored just the XML markup) with things like a TextFlow instance and its associated interaction manager, FlowManager, container references etc coming along with it.

I’m thinking one reason for this is the way the model is not replaceable, you need to act on the TextFlow directly using DOM-like operations. This works fine if the user is editing the TextFlow directly with the keyboard. But say for example I have a formatting panel floating around with bold/italic buttons inside… I begin editing my TextFlow and make a selection, and as my TextFlow is stored in the application model, my formatting panel is able to apply the bold formatting via textFlow.applyFormat(boldFormat). But now that change has been applied directly to the TextFlow instance, I also need a way to send an application-wide message to add an operation to the Undo/Redo Stack that I already have so that the user can continue to use this Undo button for text as well as every other operation.

My current work-around prevents having to re-create the TextFlow after each change by reading the TextFlow.generation property to work out whether the change was a user initiated one, or an Undo one.

If anyone has any ideas on how this might be used within the context of a global/application-wide Undo stack outside of the TLF please feel free to drop suggestions in the comments. I know it’s early days for the TLF so I wanted to post this now just incase.

3 thoughts on “Text Layout Framework Follow Up and Request”

  1. You need to use the edit manager to get a proper undo/redo stack.

    So if you apply a character format like bold you would do so through the edit manager to assure it can be “undone” by the edit manager.

    So apply a format:
    var cf:CharacterFormat = new CharacterFormat();
    cf.fontWeight =’bold’;
    IEditManager(_textFlow.interactionManager).applyCharacterFormat(cf);

    Then Undo the last change (won’t matter if it is a format):
    EditManager(_textFlow.interactionManager).undo();

    Hope that helps,

    -Ken

  2. Hi Ken thanks for the post. I’ve used the TLF UndoManager as you show above, but the post relates to using a seperate application-wide undo stack that every other operation in the app is using (so some-how hooking it up to use the TextFlow/EditManager), the disparity between the two is the conundrum, I can’t use two seperate UndoManager because I only have one Undo button/menu option, so hooking the two up is required, bearing in mind I also have to select or re-instantiate (if deleted) the correct TextFlow and so on (but that’s already in place).

    I’m thinking the cleanest solution may just be to add another undo operation that contains a TLF Operation instance (via begin/endCompositeOperation(), but still tying this up to PureMVC’s Undo extension is the tricky bit and I’m keen to see if anyone at Adobe is using PureMVC (or similar), or anyone else in the community is using TLF with it.

    In short, the problem with using the built in TLF undo-manager is its integration with other undo operations in your application, which won’t manifest itself in the demos but will in a full scale application?

Comments are closed.