Home

# Class goog.editor.plugins.LinkDialogPlugin

A plugin that opens the link dialog.

extends goog.editor.plugins.AbstractDialogPlugin

Instance Method Summary
| `createDialog(!goog.dom.DomHelper dialogDomHelper, <Any Type> opt_arg) ⇒ ?goog.ui.editor.AbstractDialog` Creates a new instance of the dialog and registers for the relevant events.

`disposeInternal()`

Unattach listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners, it should be something like this:

    MyClass.prototype.disposeInternal = function() {
    MyClass.superClass_.disposeInternal.call(this);
    // Dispose logic for MyClass
    };

| `getCurrentLink() ⇒ ?goog.editor.Link`
| `getEventHandler() ⇒ ?goog.events.EventHandler`
| `getOpenLinkInNewWindowCheckedState() ⇒ boolean` Returns whether the"open link in new window" checkbox was checked last time the dialog was closed.
| `handleAfterHide(?goog.events.Event e)` Handles when the dialog closes.
| `handleBeforeTestLink(?goog.ui.editor.LinkDialog.BeforeTestLinkEvent e)` Handles the BeforeTestLink event fired when the 'test' link is clicked.
| `handleCancel_(?goog.events.Event e)` Handles the CANCEL event from the dialog by clearing the anchor if needed.
| `handleOk_(?goog.ui.editor.LinkDialog.OkEvent e)` Handles the OK event from the dialog by updating the link in the field.
| `isSafeSchemeToOpen_(string url) ⇒ boolean` Determines whether or not a url has a scheme which is safe to open. Schemes like javascript are unsafe due to the possibility of XSS.
| `setBlockOpeningUnsafeSchemes(boolean blockOpeningUnsafeSchemes)` Tells the plugin whether to block URLs with schemes not in the whitelist. If blocking is enabled, this plugin will stop the 'Test Link' popup window from being created. Blocking doesn't affect link creation--if the user clicks the 'OK' button with an unsafe URL, the link will still be created as normal.
| `setEmailWarning(string emailWarning)` Sets the warning message to show to users about including email addresses on public web pages.
| `setSafeToOpenSchemes(?Array.<(String|null)> schemes)` Sets a whitelist of allowed URL schemes that are safe to open. Schemes should all be in lowercase. If the plugin is set to block opening unsafe schemes, user-entered URLs will be converted to lowercase and checked against this list. The whitelist has no effect if blocking is not enabled.
| `shouldOpenUrl(string url) ⇒ boolean` Checks whether the plugin should open the given url in a new window.
| `showOpenLinkInNewWindow(boolean startChecked)` Tells the dialog to show a checkbox where the user can choose to have the link open in a new window.

`stopReferrerLeaks()`

Tells the plugin to stop leaking the page's url via the referrer header when the "test this link" link is clicked. When the user clicks on a link, the browser makes a request for the link url, passing the url of the current page in the request headers. If the user wants the current url to be kept secret (e.g. an unpublished document), the owner of the url that was clicked will see the secret url in the request headers, and it will no longer be a secret. Calling this method will not send a referrer header in the request, just as if the user had opened a blank window and typed the url in themselves.