Skip to main content
March 3, 2011
Answered

How to get changes made to TLF text

  • March 3, 2011
  • 2 replies
  • 1017 views

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 has been closed for replies.
Correct answer robin_briggs

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

2 replies

March 9, 2011

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

robin_briggsCorrect answer
Adobe Employee
March 9, 2011

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

March 10, 2011

Ya now it is working fine.

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

Adobe Employee
March 5, 2011

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

March 7, 2011

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