Skip to main content
Mar 3, 2011 12:54 PM UTC
Answered

How to get changes made to TLF text

Hi,

Is there a way in TLF to get the number of changes made to the TLF text ? Like if I have applied underline to some text, or changed the font size, etc.

Can I get these changes made to the text ?

Like whenever I do an operation, can I store the operation each time an operation gets completed.

This topic is closed to new replies. Start a new post to keep the conversation going.
robin_briggsCorrect answer
Adobe Employee
Mar 9, 2011 5:32 PM UTC

The UndoManager can undo changes that are made through the EditManager, but not changes that are made directly to the TextFlow. Likewise we do operations and send operation messages only for things that go through the EditManager. I would suggest that if you want to remove the leaf node, you can remove it by getting its text range, and deleting it through the EditManager. Then the change would be undoable. Try something like this:

     editManager.deleteText(new SelectionState(textFlow, leaf.getAbsoluteStart(), leaf.getAbsoluteStart() + leaf.textLength));

- robin

5 replies

Mar 9, 2011 11:06 AM UTC

Hi Robin,

The peoblem I am facing now is I got the styles and other tlf features to undo using undo manager, but now I have a scenario where I search through some tlf childs i.e. ParagrapghElements, SpanElements, etc. and search a specific span having an id assigned. And then delete that leaf having any id.

I use this for the same: flowLeafElement.getParagraph().removeChild(flowLeafElement);

where my :

          flowLeafElement : is the current leaf node.

I get this leaf element's paragrapgh and then remove that specific leaf.

But now the problem is that my required text gets removed, but it is not reverted on doing an Undo.

I have already assigned an UndoManger to my textflow's interaction manager.

I also attached a FlowOperationEvent.FLOW_OPERATION_COMPLETE event to my text flow, but it isn't called when I remove the child leaf from the text flow.

So please help me figure out a way to track these changes so that I get the changes to revert on an Undo?

Thanks

Translate
robin_briggsCorrect answer
Adobe Employee
Mar 9, 2011 5:32 PM UTC

The UndoManager can undo changes that are made through the EditManager, but not changes that are made directly to the TextFlow. Likewise we do operations and send operation messages only for things that go through the EditManager. I would suggest that if you want to remove the leaf node, you can remove it by getting its text range, and deleting it through the EditManager. Then the change would be undoable. Try something like this:

     editManager.deleteText(new SelectionState(textFlow, leaf.getAbsoluteStart(), leaf.getAbsoluteStart() + leaf.textLength));

- robin

Translate
Mar 10, 2011 5:25 AM UTC

Ya now it is working fine.

Thanks for the prompt reply Robin. You really saved me a lot of time.

Translate
Adobe Employee
Mar 5, 2011 6:38 AM UTC

If you give the EditManager an UndoManager when you construct it, then the UndoManager will get handed every operation after it is executed. You could create your own UndoManager and track the operations with it if you want to. BTW, there is also a generation number on the TextFlow that is incremented for every model change, but there are usually multiple model changes for an individual operation, so that may not work for you.

- robin

Translate
Mar 7, 2011 5:18 AM UTC

Thanks Robin for the help. I got it to work by this way.

Translate