Skip to main content
Participant
February 18, 2009
Answered

How to define LinkElement ID using IEditManager.applyLink

  • February 18, 2009
  • 1 reply
  • 555 views
I'm using code of the form:
IEditManager(_textFlow.interactionManager).applyLink(" http://www.cnn.com");
However, in my underlying markup, I'd like to have something like this:
<flow:a href=" http://www.cnn.com" id="myID">My Link here</flow:a>

Since in the latest releases of Gumbo SDK every FlowElement have IDs, we're using these IDs to track LinkElements which are later used to fire specific events based on their IDs, when the TextFlow is in non-editable mode. (we ignore the actual href).

The applyLink method of course takes only a url as string, but is there a way to add a general LinkElement using the IEditManager where we could specify the LinkElement ID ? We don't want to have to directly add LinkElements to the TextFlow because our current application uses an IEditManager.
This topic has been closed for replies.
Correct answer rdermer
I suggest you do it like this psuedo code and combine the applyLink operation with the ChangeElementIdOperation.

editManager.beginCompositeOperation()
editManager.applyLink(...);
// figure out where the linkElement is
var idOperation:ChangeElementIdOperation(editManager.selectionState, linkElement, IdYouWant);
editManager.doOperation(idOperation)
editManager.endCompositeOperation();

This lets you merge multiple operations into a single undoable unit.

Thanks,
Richard

1 reply

rdermerCorrect answer
Adobe Employee
February 18, 2009
I suggest you do it like this psuedo code and combine the applyLink operation with the ChangeElementIdOperation.

editManager.beginCompositeOperation()
editManager.applyLink(...);
// figure out where the linkElement is
var idOperation:ChangeElementIdOperation(editManager.selectionState, linkElement, IdYouWant);
editManager.doOperation(idOperation)
editManager.endCompositeOperation();

This lets you merge multiple operations into a single undoable unit.

Thanks,
Richard
bansalviAuthor
Participant
February 20, 2009
Thanks..yes that approach worked. I'm assuming that to get a handle on the LinkElement that I just created using the IEditManager, I have to give it a unique href that I can query later. So an approach like the attached code works. If there's a better way of doing this, let me know!