The goog.editor.Link Class

Wrap an editable link.

anchor {HTMLAnchorElement}
The anchor element.
isNew {boolean}
Whether this is a new link.

Initialize a new link.

anchor {HTMLAnchorElement}
The anchor element.
url {string}
The initial URL.
opt_target {string=}
The target.
opt_extraAnchors {Array.<HTMLAnchorElement>=}
Extra anchors created by the browser when parsing a selection.
returns {goog.editor.Link}
The link.

.finishLinkCreation(field)

After link creation, finish creating the link depending on the type of link being created.

field {goog.editor.Field}
The field where this link is being created.

.getAnchor()

returns {HTMLAnchorElement}
The anchor element.

.getCurrentText()

returns {string}
The inner text for the anchor.

.getExtraAnchors()

returns {!Array.<HTMLAnchorElement>}
The extra anchor elements, if any, created by the browser from a selection.

.initializeUrl(url)

Set the url without affecting the isNew() status of the link.

url {string}
A URL.

.isLikelyEmailAddress(str)

Returns true if str could be an email address, false otherwise Ex: goog.editor.Link.isLikelyEmailAddress_("some word") == false goog.editor.Link.isLikelyEmailAddress_("foo@foo.com") == true

str {string}
String to test for being email address.
returns {boolean}
Whether "str" looks like an email address.

.isLikelyUrl(str)

Returns true if str could be a URL, false otherwise Ex: TR_Util.isLikelyUrl_("http://www.google.com") == true TR_Util.isLikelyUrl_("www.google.com") == true

str {string}
String to check if it looks like a URL.
returns {boolean}
Whether str could be a URL.

.isMailto(url)

Determines whether or not a url is an email link.

url {string}
A url.
returns {boolean}
Whether the url is a mailto link.

.isNew()

returns {boolean}
Whether the link is new.

.placeCursorRightOf()

Places the cursor to the right of the anchor. Note that this is different from goog.editor.range's placeCursorNextTo in that it specifically handles the placement of a cursor in browsers that trap you in links, by adding a space when necessary and placing the cursor after that space.

Removes the link, leaving its contents in the document. Note that this object will no longer be usable/useful after this call.

.setTextAndUrl(newText, newUrl)

Change the link.

newText {string}
New text for the link. If the link contains all its text in one descendent, newText will only replace the text in that one node. Otherwise, we'll change the innerHTML of the whole link to newText.
newUrl {string}
A new URL.