editor.plugins.LinkBubble Extends goog.editor.plugins.AbstractBubblePlugin
Property bubble plugin for links.

Inheritance

Constructor

goog.editor.plugins.LinkBubble(var_args)

Parameters

var_args : ...!goog.editor.plugins.LinkBubble.Action
List of extra actions supported by the bubble.

Instance Methods

Public Protected Private
createBubbleContents()
No description.
code »
deleteLink_()
Deletes the link associated with the bubble
code »
execCommandInternal()
No description.
code »
getBubbleTargetFromSelection()
No description.
code »
getBubbleTitle()
No description.
code »
getBubbleType()
No description.
code »
getLinkToTextObj_() !Object
Gets the text to display for a link, based on the type of link
Returns: !Object  Returns an object of the form: {linkText: displayTextForLinkTarget, valid: ifTheLinkIsValid}.
code »
getTargetUrl() string
Returns the target element url for the bubble.
Returns: string  The url href.
code »
getTestLinkAction_() string
Gets the url for the bubble test link. The test link is the link in the bubble the user can click on to make sure the link they entered is correct.
Returns: string  The url for the bubble link href.
code »
getTestLinkMessage() string
Returns the message to display for testing a link.
Returns: string  The message for testing a link.
code »
getTrogClassId()
No description.
code »
isInvalidUrl(url) boolean
Returns whether the URL should be considered invalid. This always returns false in the base class, and should be overridden by subclasses that wish to impose validity rules on URLs.
Arguments:
url : string
The url to check.
Returns: boolean  Whether the URL should be considered invalid.
code »
isSafeSchemeToOpen_(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.
Arguments:
url : string
A url.
Returns: boolean  Whether the url has a safe scheme.
code »
isSupportedCommand()
No description.
code »
onShow()
Sets the proper state for the action links.
code »
setBlockOpeningUnsafeSchemes(blockOpeningUnsafeSchemes)
Tells the plugin whether to block URLs with schemes not in the whitelist. If blocking is enabled, this plugin will not linkify the link in the bubble popup.
Arguments:
blockOpeningUnsafeSchemes : boolean
Whether to block non-whitelisted schemes.
code »
setSafeToOpenSchemes(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.
Arguments:
schemes : Array.<string>
String array of URL schemes to allow (http, https, etc.).
code »
setTestLinkUrlFn(func)
Set the optional function for getting the "test" link of a url.
Arguments:
func : function(string) : string
The function to use.
code »
shouldOpenUrl(url) boolean
Checks whether the plugin should open the given url in a new window.
Arguments:
url : string
The url to check.
Returns: boolean  If the plugin should open the given url in a new window.
code »
showLinkDialog_(e)
Shows the link dialog.
Arguments:
e : goog.events.BrowserEvent
The event.
code »
stopReferrerLeaks()
Tells the plugin to stop leaking the page's url via the referrer header when the link text 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.
code »
testLink()
Tests the link by opening it in a new tab/window. Should be used as the click event handler for the test pseudo-link.
code »
updateLink_()
Updates the href in the link bubble with a new link.
code »
bubbleFactory_()
Instance factory function that creates a bubble UI component. If set to a non-null value, this function will be used to create a bubble instead of the global factory function. It takes as parameters the bubble parent element and the z index to draw the bubble at.
code »
cleanOnBubbleClose()
Called when the bubble is closed or hidden. The default implementation does nothing.
code »
closeBubble()
Closes the bubble.
code »
createBubble(targetElement)
Creates and shows the property bubble.
Arguments:
targetElement : Element
The target element of the bubble.
code »
createBubbleContents(bubbleContainer)
Should be overriden by subclasses to add the type specific contents to the bubble.
Arguments:
bubbleContainer : Element
The container element of the bubble to which the contents should be added.
code »
createLink(linkIdlinkTextopt_onClickopt_container) Element
Helper method that creates a link with text set to linkText and optionaly wires up a listener for the CLICK event or the link.
Arguments:
linkId : string
The id of the link.
linkText : string
Text of the link.
opt_onClick : Function=
Optional function to call when the link is clicked.
opt_container : Element=
If specified, location to insert link. If no container is specified, the old link is removed and replaced.
Returns: Element  The link element.
code »
createLinkHelper(linkIdlinkTextisAnchoropt_container) Element
Helper method to create a link to insert into the bubble.
Arguments:
linkId : string
The id of the link.
linkText : string
Text of the link.
isAnchor : boolean
Set to true to create an actual anchor tag instead of a span. Actual links are right clickable (e.g. to open in a new window) and also update window status on hover.
opt_container : Element=
If specified, location to insert link. If no container is specified, the old link is removed and replaced.
Returns: Element  The link element.
code »
createLinkOption(id) Element
Helper method that creates option links (such as edit, test, remove)
Arguments:
id : string
String id for the span id.
Returns: Element  The option link element.
code »
disable()
No description.
code »
enableKeyboardNavigation(keyboardNavigationEnabled)
Sets whether the bubble should support tabbing through the link elements.
Arguments:
keyboardNavigationEnabled : boolean
Whether the bubble should support tabbing through the link elements.
code »
getBubbleDom() goog.dom.DomHelper
No description.
Returns: goog.dom.DomHelper  The dom helper for the bubble window.
code »
getBubbleMap() !Object.<goog.ui.editor.Bubble>
Returns the bubble map. Subclasses may override to use a separate map.
Returns: !Object.<goog.ui.editor.BubbleNo description.
code »
getBubbleTargetFromSelection(selectedElement) ?Element
Should be overriden by subclasses to return the bubble target element or null if an element of their required type isn't found.
Arguments:
selectedElement : Element
The target of the selection change event or the parent container of the current entire selection.
Returns: ?Element  The HTML bubble target element or null if no element of the required type is not found.
code »
getBubbleTitle() string
No description.
Returns: string  The title for bubble shown by this plugin. Defaults to no title. Should be overridden by subclasses.
code »
getBubbleType() string
No description.
Returns: string  The type of bubble shown by this plugin. Usually the tag name of the element this bubble targets.
code »
getSharedBubble_() !goog.ui.editor.Bubble
No description.
Returns: !goog.ui.editor.Bubble  The shared bubble object for the field this plugin is registered on. Creates it if necessary.
code »
getTargetElement() Element
Returns the element whose properties the bubble manipulates.
Returns: Element  The target element.
code »
handleKeyDown()
In case the keyboard navigation is enabled, this will focus to the first link element in the bubble when TAB is clicked. The user could still go through the rest of tabbable UI elements using shift + TAB.
code »
handleKeyUp()
No description.
code »
handlePanelClosed_()
Handles when the bubble panel is closed. Invoked when the entire bubble is hidden and also directly when the panel is closed manually.
code »
handleSelectionChange()
Pops up a property bubble for the given selection if appropriate and closes open property bubbles if no longer needed. This should not be overridden.
code »
handleSelectionChangeInternal(selectedElement) boolean
Pops up a property bubble for the given selection if appropriate and closes open property bubbles if no longer needed.
Arguments:
selectedElement : ?Element
The selected element.
Returns: boolean  Always false, allowing every bubble plugin to handle the event.
code »
isVisible() boolean
No description.
Returns: boolean  Whether the bubble is visible.
code »
onBubbleKey_(e)
Handles a key event on the bubble. This ensures that the focus loops through the link elements found in the bubble and then the focus is got by the field element.
Arguments:
e : goog.events.BrowserEvent
The event.
code »
onShow()
Called after the bubble is shown. The default implementation does nothing. Override it to provide your own one.
code »
registerActionHandler(targethandler)
Register the handler for the target's CLICK and ENTER key events.
Arguments:
target : Element
The event source element.
handler : Function
The event handler.
code »
registerClickHandler(targethandler)
Use goog.editor.plugins.AbstractBubblePlugin. registerActionHandler to register click and enter events. Register the handler for the target's CLICK event.
Arguments:
target : Element
The event source element.
handler : Function
The event handler.
code »
reposition()
Reposition the property bubble.
code »
setBubbleFactory(bubbleFactory)
Sets the instance bubble factory function. If set to a non-null value, this function will be used to create a bubble instead of the global factory function.
Arguments:
bubbleFactory : ?function(!Element, number): !goog.ui.editor.Bubble
Function that creates a bubble for the given bubble parent element and z index. Null to reset the factory function.
code »
setBubbleParent(bubbleParent)
Sets the bubble parent.
Arguments:
bubbleParent : Element
An element where the bubble will be anchored. If null, we will use the application document. This is useful when you have an editor embedded in a scrolling div.
code »
setupLink(linklinkIdopt_container)
Inserts a link in the given container if it is specified or removes the old link with this id and replaces it with the new link
Arguments:
link : Element
Html element to insert.
linkId : string
Id of the link.
opt_container : Element=
If specified, location to insert link.
code »
shouldPreferBubbleAboveElement() boolean
No description.
Returns: boolean  Whether the bubble should prefer placement above the target element.
code »
activeOnUneditableFields() boolean
No description.
Returns: boolean  If true, field will not disable the command when the field becomes uneditable.
code »
cleanContentsDom(fieldCopy)
Cleans the contents of the node passed to it. The node contents are modified directly, and the modifications will subsequently be used, for operations such as saving the innerHTML of the editor etc. Since the plugins act on the DOM directly, this method can be very expensive. This op is invoked even on disabled plugins.
Arguments:
fieldCopy : !Element
The copy of the editable field which needs to be cleaned up.
code »
cleanContentsHtml(originalHtml) string
Cleans the html contents of Trogedit. Both cleanContentsDom and and cleanContentsHtml will be called on contents extracted from Trogedit. The inverse of prepareContentsHtml. This op is invoked even on disabled plugins.
Arguments:
originalHtml : string
The trogedit HTML.
Returns: string  Cleaned-up HTML.
code »
disable(fieldObject)
Disables this plugin for the specified, registered field object.
Arguments:
fieldObject : goog.editor.Field
The field object.
code »
disposeInternal()
No description.
code »
enable(fieldObject)
Enables this plugin for the specified, registered field object. A field object should only be enabled when it is loaded.
Arguments:
fieldObject : goog.editor.Field
The field object.
code »
execCommand(commandvar_args) *
Handles execCommand. This default implementation handles dispatching BEFORECHANGE, CHANGE, and SELECTIONCHANGE events, and calls execCommandInternal to perform the actual command. Plugins that want to do their own event dispatching should override execCommand, otherwise it is preferred to only override execCommandInternal. This version of execCommand will only work for single field plugins. Multi-field plugins must override execCommand.
Arguments:
command : string
The command to execute.
var_args : ...*
Any additional parameters needed to execute the command.
Returns: *  The result of the execCommand, if any.
code »
execCommandInternal(commandvar_args) *
Handles execCommand. This default implementation does nothing, and is called by execCommand, which handles event dispatching. This method should be overriden by plugins that don't need to do their own event dispatching. If custom event dispatching is needed, execCommand shoul be overriden instead.
Arguments:
command : string
The command to execute.
var_args : ...*
Any additional parameters needed to execute the command.
Returns: *  The result of the execCommand, if any.
code »
getFieldDomHelper() ?goog.dom.DomHelper
No description.
Returns: ?goog.dom.DomHelper  The dom helper object associated with the currently active field.
code »
getFieldObject() goog.editor.Field
Sets the field object for use with this plugin.
Returns: goog.editor.Field  The editable field object.
code »
getTrogClassId() string
No description.
Returns: string  The ID unique to this plugin class. Note that different instances off the plugin share the same classId.
code »
handleKeyDown(e) boolean
Handles keydown. It is run before handleKeyboardShortcut and if it returns true handleKeyboardShortcut will not be called.
Arguments:
e : !goog.events.BrowserEvent
The browser event.
Returns: boolean  Whether the event was handled and thus should *not* be propagated to other plugins or handleKeyboardShortcut.
code »
handleKeyPress(e) boolean
Handles keypress. It is run before handleKeyboardShortcut and if it returns true handleKeyboardShortcut will not be called.
Arguments:
e : !goog.events.BrowserEvent
The browser event.
Returns: boolean  Whether the event was handled and thus should *not* be propagated to other plugins or handleKeyboardShortcut.
code »
handleKeyUp(e) boolean
Handles keyup.
Arguments:
e : !goog.events.BrowserEvent
The browser event.
Returns: boolean  Whether the event was handled and thus should *not* be propagated to other plugins.
code »
handleKeyboardShortcut(ekeyisModifierPressed) boolean
Handles keyboard shortcuts. Preferred to using handleKey* as it will use the proper event based on browser and will be more performant. If handleKeyPress/handleKeyDown returns true, this will not be called. If the plugin handles the shortcut, it is responsible for dispatching appropriate events (change, selection change at the time of this comment). If the plugin calls execCommand on the editable field, then execCommand already takes care of dispatching events. NOTE: For performance reasons this is only called when any key is pressed in conjunction with ctrl/meta keys OR when a small subset of keys (defined in goog.editor.Field.POTENTIAL_SHORTCUT_KEYCODES_) are pressed without ctrl/meta keys. We specifically don't invoke it when altKey is pressed since alt key is used in many i8n UIs to enter certain characters.
Arguments:
e : !goog.events.BrowserEvent
The browser event.
key : string
The key pressed.
isModifierPressed : boolean
Whether the ctrl/meta key was pressed or not.
Returns: boolean  Whether the event was handled and thus should *not* be propagated to other plugins. We also call preventDefault on the event if the return value is true.
code »
handleSelectionChange(opt_eopt_target) boolean
Handles selection change.
Arguments:
opt_e : !goog.events.BrowserEvent=
The browser event.
opt_target : !Node=
The node the selection changed to.
Returns: boolean  Whether the event was handled and thus should *not* be propagated to other plugins.
code »
isAutoDispose() boolean
No description.
Returns: boolean  Whether or not this plugin should automatically be disposed when it's registered field is disposed.
code »
isEnabled(fieldObject) boolean
Returns whether this plugin is enabled for the field object.
Arguments:
fieldObject : goog.editor.Field
The field object.
Returns: boolean  Whether this plugin is enabled for the field object.
code »
isSilentCommand(command) boolean
No description.
Arguments:
command : string
The command to check.
Returns: boolean  If true, field will not dispatch change events for commands of this type. This is useful for "seamless" plugins like dialogs and lorem ipsum.
code »
isSupportedCommand(command) boolean
Whether the string corresponds to a command this plugin handles.
Arguments:
command : string
Command string to check.
Returns: boolean  Whether the plugin handles this type of command.
code »
prepareContentsHtml(originalHtmlstyles) string
Prepares the given HTML for editing. Strips out content that should not appear in an editor, and normalizes content as appropriate. The inverse of cleanContentsHtml. This op is invoked even on disabled plugins.
Arguments:
originalHtml : string
The original HTML.
styles : Object
A map of strings. If the plugin wants to add any styles to the field element, it should add them as key-value pairs to this object.
Returns: string  New HTML that's ok for editing.
code »
queryCommandValue(command) *
Gets the state of this command if this plugin serves that command.
Arguments:
command : string
The command to check.
Returns: *  The value of the command.
code »
registerFieldObject(fieldObject)
Registers the field object for use with this plugin.
Arguments:
fieldObject : goog.editor.Field
The editable field object.
code »
setAutoDispose(autoDispose)
Set if this plugin should automatically be disposed when the registered field is disposed.
Arguments:
autoDispose : boolean
Whether to autoDispose.
code »
setFieldObject(fieldObject)
Sets the field object for use with this plugin.
Arguments:
fieldObject : goog.editor.Field
The editable field object.
code »
unregisterFieldObject(fieldObj)
Unregisters and disables this plugin for the current field object.
Arguments:
fieldObj : goog.editor.Field
The field object. For single-field plugins, this parameter is ignored.
code »
addEventListener(typeopt_captureopt_handlerScope)
Use #listen instead, when possible. Otherwise, use goog.events.listen if you are passing Object (instead of Function) as handler. Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched.
Arguments:
type : string
The type of the event to listen for.
: ?function():? | ?{handleEvent:function():?
No description.
opt_capture : boolean=
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope : Object=
Object in whose scope to call the listener.
code »
assertInitialized_()
Asserts that the event target instance is initialized properly.
code »
dispatchEvent()
No description.
code »
disposeInternal()
Removes 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.
code »
fireListeners()
No description.
code »
getListener()
No description.
code »
getListeners()
No description.
code »
getParentEventTarget() goog.events.EventTarget
Returns the parent of this event target to use for bubbling.
Returns: goog.events.EventTarget  The parent EventTarget or null if there is no parent.
code »
hasListener()
No description.
code »
listen()
No description.
code »
listenOnce()
No description.
code »
removeAllListeners()
No description.
code »
removeEventListener(typeopt_captureopt_handlerScope)
Use #unlisten instead, when possible. Otherwise, use goog.events.unlisten if you are passing Object (instead of Function) as handler. Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.
Arguments:
type : string
The type of the event to listen for.
: ?function():? | ?{handleEvent:function():?
No description.
opt_capture : boolean=
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope : Object=
Object in whose scope to call the listener.
code »
setParentEventTarget(parent)
Sets the parent of this event target to use for capture/bubble mechanism.
Arguments:
parent : goog.events.EventTarget
Parent listenable (null if none).
code »
setTargetForTesting(target)
Sets the target to be used for event.target when firing event. Mainly used for testing. For example, see goog.testing.events.mixinListenable.
Arguments:
target : !Object
The target.
code »
unlisten()
No description.
code »
unlistenByKey()
No description.
code »
addOnDisposeCallback(callbackopt_scope)
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
Arguments:
callback : function(this:T):?
The callback function.
opt_scope : T=
An optional scope to call the callback in.
code »
dispose() void
Disposes of the object. If the object hasn't already been disposed of, calls #disposeInternal. Classes that extend goog.Disposable should override #disposeInternal in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
Returns: void  Nothing.
code »
disposeInternal()
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend goog.Disposable should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' disposeInternal method. Everywhere else the public dispose method must be used. For example:
  mypackage.MyClass = function() {
    mypackage.MyClass.base(this, 'constructor');
    // Constructor logic specific to MyClass.
    ...
  };
  goog.inherits(mypackage.MyClass, goog.Disposable);

  mypackage.MyClass.prototype.disposeInternal = function() {
    // Dispose logic specific to MyClass.
    ...
    // Call superclass's disposeInternal at the end of the subclass's, like
    // in C++, to avoid hard-to-catch issues.
    mypackage.MyClass.base(this, 'disposeInternal');
  };
code »
getDisposed() boolean
Use #isDisposed instead. No description.
Returns: boolean  Whether the object has been disposed of.
code »
isDisposed() boolean
No description.
Returns: boolean  Whether the object has been disposed of.
code »
registerDisposable(disposable)
Associates a disposable object with this object so that they will be disposed together.
Arguments:
disposable : goog.disposable.IDisposable
that will be disposed when this object is disposed.
code »

Instance Properties

actionSpans_ :
List of spans corresponding to the extra actions.
Code »
blockOpeningUnsafeSchemes_ :
Whether to block opening links with a non-whitelisted URL scheme.
Code »
constructor :
No description.
Code »
extraActions_ :
List of extra actions supported by the bubble.
Code »
safeToOpenSchemes_ :
A list of whitelisted URL schemes which are safe to open.
Code »
stopReferrerLeaks_ :
Whether to stop leaking the page's url via the referrer header when the link text link is clicked.
Code »
bubbleParent_ :
The optional parent of the bubble. If null or not set, we will use the application document. This is useful when you have an editor embedded in a scrolling DIV.
Code »
constructor :
No description.
Code »
eventRegister : goog.events.EventHandler
Place to register events the plugin listens to.
Code »
keyboardNavigationEnabled_ :
Whether this bubble should support tabbing through the link elements. False by default.
Code »
panelId_ :
The id of the panel this plugin added to the shared bubble. Null when this plugin doesn't currently have a panel in a bubble.
Code »
autoDispose_ :
Indicates if this plugin should be automatically disposed when the registered field is disposed. This should be changed to false for plugins used as multi-field plugins.
Code »
constructor :
No description.
Code »
enabled_ :
Whether this plugin is enabled for the registered field object.
Code »
fieldObject : goog.editor.Field
The field object this plugin is attached to.
Code »
The logger for this plugin.
Code »
actualEventTarget_ : goog.events.EventTarget
The object to use for event.target. Useful when mixing in an EventTarget to another object.
Code »
constructor :
No description.
Code »
eventTargetListeners_ : goog.events.ListenerMap
Maps of event type to an array of listeners.
Code »
parentEventTarget_ : goog.events.EventTarget
Parent event target, used during event bubbling. TODO(user): Change this to goog.events.Listenable. This currently breaks people who expect getParentEventTarget to return goog.events.EventTarget.
Code »
creationStack :
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
Code »
disposed_ :
Whether the object has been disposed of.
Code »
onDisposeCallbacks_ :
Callbacks to invoke when this object is disposed.
Code »

Static Properties

goog.editor.plugins.LinkBubble.CHANGE_LINK_ID_ :
Element id for the link. type {string}
Code »
goog.editor.plugins.LinkBubble.CHANGE_LINK_SPAN_ID_ :
Element id for the change link span. type {string}
Code »
goog.editor.plugins.LinkBubble.DELETE_LINK_ID_ :
Element id for the delete link. type {string}
Code »
goog.editor.plugins.LinkBubble.DELETE_LINK_SPAN_ID_ :
Element id for the delete link span. type {string}
Code »
goog.editor.plugins.LinkBubble.LINK_DIV_ID_ :
Element id for the link bubble wrapper div. type {string}
Code »
goog.editor.plugins.LinkBubble.LINK_TEXT_ID_ :
Element id for the link text. type {string}
Code »
goog.editor.plugins.LinkBubble.TEST_LINK_ID_ :
Element id for the test link. type {string}
Code »
goog.editor.plugins.LinkBubble.TEST_LINK_SPAN_ID_ :
Element id for the test link span. type {string}
Code »
goog.editor.plugins.LinkBubble.superClass_ :
No description.
Code »

Package editor.plugins

Package Reference