• createlink

last modified November 15, 2010 by egj

See http://trac.xinha.org/ticket/1553

 

To trigger a link-creation action from Javascript code, use

editor.execCommand("createlink")

(where editor is a Xinha editor object)

This will trigger the link-creation action.  The actual experience of the action depends on your configuration -- if CreateLink is installed, it will be one thing, and if it isn't it will be another (defined by modules/Linker).

 

You can also trigger an "edit this link" action, if you have a reference to an anchor el:

 editor.execCommand("createlink", false, anchor)

If you use the short form, the current cursor selection will be used to determine what happens -- if the selection is within an existing link, it will be edited; otherwise, a new hyperlink will be created out of the current selection.

If you use the long form with an explicit anchor el, you can trigger the action independent of the cursor position/selection.

 

Note that there must be some text selected, or an existing anchor specified, to make a link.