The goog.editor.Plugin Class

goog.editor.Plugin
> goog.events.EventTarget
> goog.Disposable

goog.editor.Plugin()

Abstract API for trogedit plugins.

.IRREPRESSIBLE_OPS

A set of op codes that run even on disabled plugins.

.OPCODE

A map from plugin operations to the names of the methods that invoke those operations.

The goog.editor.Plugin.Op Enum

An enum of operations that plugins may support. … more

.activeOnUneditableFields

returns {boolean}
If true, field will not disable the command when the field becomes uneditable.

.addEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

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. Supported for legacy but use goog.events.listen(src, type, handler) instead.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
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.

.addOnDisposeCallback(callback, opt_scope)

Inherited from goog.Disposable .

Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.

callback {!Function}
The callback function.
opt_scope {Object=}
An optional scope to call the callback in.

.cleanContentsDom

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.

fieldCopy {!Element}
The copy of the editable field which needs to be cleaned up.

.cleanContentsHtml

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.

originalHtml {string}
The trogedit HTML.
returns {string}
Cleaned-up HTML.

.creationStack {string}

Inherited from goog.Disposable .

If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.

.disable(fieldObject)

Disables this plugin for the specified, registered field object.

fieldObject {goog.editor.Field}
The field object.

.dispatchEvent(e)

Inherited from goog.events.EventTarget .

Dispatches an event (or event like object) and calls all listeners listening for events of this type. The type of the event is decided by the type property on the event object. If any of the listeners returns false OR calls preventDefault then this function will return false. If one of the capture listeners calls stopPropagation, then the bubble listeners won't fire.

e {string|Object|goog.events.Event}
Event object.
returns {boolean}
If anyone called preventDefault on the event object (or if any of the handlers returns false this will also return false.

.dispose()

Inherited from goog.Disposable .

Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.

returns {void}
Nothing.

.enable(fieldObject)

Enables this plugin for the specified, registered field object. A field object should only be enabled when it is loaded.

fieldObject {goog.editor.Field}
The field object.

.execCommand(command, var_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.

command {string}
The command to execute.
var_args {...*}
Any additional parameters needed to execute the command.
returns {*}
The result of the execCommand, if any.

.getFieldDomHelper()

returns {goog.dom.DomHelper?}
The dom helper object associated with the currently active field.

.getParentEventTarget()

Inherited from 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.

.getTrogClassId

returns {string}
The ID unique to this plugin class. Note that different instances off the plugin share the same classId.

.handleKeyDown

Handles keydown. It is run before handleKeyboardShortcut and if it returns true handleKeyboardShortcut will not be called.

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.

.handleKeyPress

Handles keypress. It is run before handleKeyboardShortcut and if it returns true handleKeyboardShortcut will not be called.

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.

.handleKeyUp

Handles keyup.

e {!goog.events.BrowserEvent}
The browser event.
returns {boolean}
Whether the event was handled and thus should *not* be propagated to other plugins.

.handleKeyboardShortcut

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.

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.

.handleSelectionChange

Handles selection change.

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.

.isAutoDispose()

returns {boolean}
Whether or not this plugin should automatically be disposed when it's registered field is disposed.

.isDisposed()

Inherited from goog.Disposable .

returns {boolean}
Whether the object has been disposed of.

.isEnabled(fieldObject)

Returns whether this plugin is enabled for the field object.

fieldObject {goog.editor.Field}
The field object.
returns {boolean}
Whether this plugin is enabled for the field object.

.isSilentCommand

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.

.isSupportedCommand(command)

Whether the string corresponds to a command this plugin handles.

command {string}
Command string to check.
returns {boolean}
Whether the plugin handles this type of command.

.prepareContentsHtml

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.

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.

.queryCommandValue

Gets the state of this command if this plugin serves that command.

command {string}
The command to check.
returns {*}
The value of the command.

.registerDisposable(disposable)

Inherited from goog.Disposable .

Associates a disposable object with this object so that they will be disposed together.

disposable {goog.disposable.IDisposable}
that will be disposed when this object is disposed.

.registerFieldObject(fieldObject)

Registers the field object for use with this plugin.

fieldObject {goog.editor.Field}
The editable field object.

.removeEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

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.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
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.

.setAutoDispose(autoDispose)

Set if this plugin should automatically be disposed when the registered field is disposed.

autoDispose {boolean}
Whether to autoDispose.

.setParentEventTarget(parent)

Inherited from goog.events.EventTarget .

Sets the parent of this event target to use for bubbling.

parent {goog.events.EventTarget?}
Parent EventTarget (null if none).

.unregisterFieldObject(fieldObj)

Unregisters and disables this plugin for the current field object.

fieldObj {goog.editor.Field}
The field object. For single-field plugins, this parameter is ignored.