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.