goog.editor.plugins.TagOnEnterHandler
Provided By | |
---|---|
Extends | |
All Implemented Interfaces |
Plugin to handle enter keys. This subclass normalizes all browsers to use the given block tag on enter.
new TagOnEnterHandler( tag )
Parameters |
|
---|
Instance Methods
this.activeOnUneditableFields() → boolean
boolean
This plugin is active on uneditable fields so it can provide a value for queryCommandValue calls asking for goog.editor.Command.BLOCKQUOTE.
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.addEventListener( type, handler, opt_capture, opt_handlerScope ) → void
void
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.
warning Deprecated | Use |
---|
Defined by | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.addOnDisposeCallback<T>( callback, opt_scope ) → void
void
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added. If a callback is added to an already disposed Disposable, it will be called immediately.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.cleanContentsDom( fieldCopy ) → void
void
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.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.cleanContentsHtml( originalHtml ) → string
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.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.deleteBrGecko( e ) → void
void
Deletes the element at the cursor if it is a BR node, and if it does, calls e.preventDefault to stop the browser from deleting. Only necessary in Gecko as a workaround for mozilla bug 205350 where deleting a BR that is followed by a block element doesn't work (the BR gets immediately replaced). We also need to account for an ill-formed cursor which occurs from us trying to stop the browser from deleting.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.disable( fieldObject ) → void
void
Disables this plugin for the specified, registered field object.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.dispatchEvent( e ) → boolean
boolean
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.
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
this.dispose() → ?
?
Disposes of the object and its resources.
Overrides | ||
---|---|---|
Specified by | ||
Parameters | None. | |
Returns |
|
this.disposeInternal() → void
void
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.
Defined by | |
---|---|
Overrides | |
Parameters | None. |
this.enable( fieldObject ) → void
void
Enables this plugin for the specified, registered field object. A field object should only be enabled when it is loaded.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
|
this.ensureBlockIeOpera( tag, opt_keyUp ) → void
void
Ensures all text in IE and Opera to be in the given tag in order to control Enter spacing. Call this when Enter is pressed if desired.
We want to make sure the user is always inside of a block (or other nodes
listed in goog.editor.plugins.EnterHandler.IGNORE_ENSURE_BLOCK_NODES_). We
listen to keypress to force nodes that the user is leaving to turn into
blocks, but we also need to listen to keyup to force nodes that the user is
entering to turn into blocks.
Example: html is: <h2>foo[cursor]</h2>
, and the user hits enter. We
don't want to format the h2, but we do want to format the P that is
created on enter. The P node is not available until keyup.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.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.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
this.execCommandInternal( command, ...var_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.
TODO(user): This pattern makes accurate typing impossible.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
this.fireListeners<EVENTOBJ>( type, capture, eventObject ) → boolean
boolean
Fires all registered listeners in this listenable for the given type and capture mode, passing them the given eventObject. This does not perform actual capture/bubble. Only implementors of the interface should be using this.
Overrides | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||
Parameters |
| ||||||||||||
Returns |
|
this.getDisposed() → boolean
boolean
warning Deprecated | Use |
---|
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getFieldDomHelper() → (goog.dom.DomHelper|null)
(goog.dom.DomHelper|null)
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getFieldObject() → (goog.editor.Field|null)
(goog.editor.Field|null)
Sets the field object for use with this plugin.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getListener<SCOPE, EVENTOBJ>( type, listener, capture, opt_listenerScope ) → (goog.events.ListenableKey|null)
(goog.events.ListenableKey|null)
Gets the goog.events.ListenableKey for the event or null if no such listener is in use.
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.getListeners<EVENTOBJ>( type, capture ) → Array<goog.events.ListenableKey>
Array<goog.events.ListenableKey>
Gets all listeners in this listenable for the given type and capture mode.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||
Parameters |
| ||||||||
Returns |
|
this.getNonCollapsingBlankHtml() → string
string
Gets HTML with no contents that won't collapse, for browsers that collapse the empty string.
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getParentEventTarget() → (goog.events.Listenable|null)
(goog.events.Listenable|null)
Returns the parent of this event target to use for capture/bubble mechanism.
NOTE(chrishenry): The name reflects the original implementation of
custom event target (goog.events.EventTarget
). We decided
that changing the name is not worth it.
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.getTrogClassId() → string
string
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.handleBackspaceInternal( e, range ) → void
void
Internal backspace handler.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.handleDeleteGecko( e ) → void
void
Internal delete key handler.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleEnterAtCursorGeckoInternal( e, wasCollapsed, range ) → void
void
Handle an enter key press on collapsed selection. handleEnterGecko_ ensures the selection is collapsed by deleting its contents if it is not. The default implementation does nothing.
Overrides | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.handleEnterWebkitInternal( e ) → void
void
Handle an enter key press in WebKit.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleKeyDown( e ) → boolean
boolean
Handles keydown. It is run before handleKeyboardShortcut and if it returns true handleKeyboardShortcut will not be called.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
| ||||
Returns |
|
this.handleKeyPress( e ) → boolean
boolean
Handles keypress. It is run before handleKeyboardShortcut and if it returns true handleKeyboardShortcut will not be called.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
| ||||
Returns |
|
this.handleKeyUp( e ) → boolean
boolean
Handles keyup.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
| ||||
Returns |
|
this.handleKeyUpInternal( e ) → void
void
Internal handler for keyup events.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.handleKeyboardShortcut( e, key, isModifierPressed ) → boolean
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 i18n UIs to enter certain characters.
Defined by | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||||||
Returns |
|
this.handleSelectionChange( opt_e, opt_target ) → boolean
boolean
Handles selection change.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
this.hasListener<EVENTOBJ>( opt_type, opt_capture ) → boolean
boolean
Whether there is any active listeners matching the specified signature. If either the type or capture parameters are unspecified, the function will match on the remaining criteria.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||
Parameters |
| ||||||||
Returns |
|
this.isAutoDispose() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isDisposed() → boolean
boolean
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.isEnabled( fieldObject ) → boolean
boolean
Returns whether this plugin is enabled for the field object.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.isSilentCommand( command ) → boolean
boolean
this.isSupportedCommand( command ) → boolean
boolean
this.listen<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → goog.events.ListenableKey
goog.events.ListenableKey
Adds an event listener. A listener can only be added once to an object and if it is added again the key for the listener is returned. Note that if the existing listener is a one-off listener (registered via listenOnce), it will no longer be a one-off listener after a call to listen().
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.listenOnce<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → goog.events.ListenableKey
goog.events.ListenableKey
Adds an event listener that is removed automatically after the listener fired once.
If an existing listener already exists, listenOnce will do nothing. In particular, if the listener was previously registered via listen(), listenOnce() will not turn the listener into a one-off listener. Similarly, if there is already an existing one-off listener, listenOnce does not modify the listeners (it is still a once listener).
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.prepareContentsHtml( html ) → string
string
If the contents are empty, return the 'default' html for the field. The 'default' contents depend on the enter handling mode, so it makes the most sense in this plugin.
Defined by | |||||
---|---|---|---|---|---|
Overrides | |||||
Parameters |
| ||||
Returns |
|
this.processParagraphTagsInternal( e, split ) → void
void
Fix paragraphs to be the correct type of node.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.queryCommandValue( command ) → *
*
Gets the state of this command if this plugin serves that command.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.registerDisposable( disposable ) → void
void
Associates a disposable object with this object so that they will be disposed together.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.registerFieldObject( fieldObject ) → void
void
Registers the field object for use with this plugin.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.removeAllListeners( opt_type ) → number
number
Removes all listeners from this listenable. If type is specified, it will only remove listeners of the particular type. otherwise all registered listeners will be removed.
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
this.removeEventListener( type, handler, opt_capture, opt_handlerScope ) → void
void
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.
warning Deprecated | Use |
---|
Defined by | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.saveScrollPosition() → function(): ?
function(): ?
Saves the field's scroll position. See b/7279077 for context. Currently only does anything in Edge, since all other browsers already seem to work correctly.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.setAutoDispose( autoDispose ) → void
void
Set if this plugin should automatically be disposed when the registered field is disposed.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setFieldObject( fieldObject ) → void
void
Sets the field object for use with this plugin.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setParentEventTarget( parent ) → void
void
Sets the parent of this event target to use for capture/bubble mechanism.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setTargetForTesting( target ) → void
void
Sets the target to be used for event.target
when firing
event. Mainly used for testing. For example, see
goog.testing.events.mixinListenable
.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.unlisten<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → boolean
boolean
Removes an event listener which was added with listen() or listenOnce().
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.unlistenByKey( key ) → boolean
boolean
Removes an event listener which was added with listen() by the key returned by listen().
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
this.unregisterFieldObject( fieldObj ) → void
void
Unregisters and disables this plugin for the current field object.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
Instance Properties
this.creationStack → (string|undefined)
(string|undefined)
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
this.fieldObject → (goog.editor.Field|null)
(goog.editor.Field|null)
The field object this plugin is attached to.
warning Deprecated | Use goog.editor.PluginImpl.getFieldObject and goog.editor.PluginImpl.setFieldObject. |
---|
Defined by |
---|
this.logger → (goog.log.Logger|null)
(goog.log.Logger|null)
The logger for this plugin.
this.tag → goog.dom.TagName
goog.dom.TagName
The type of block level tag to add on enter, for browsers that support specifying the default block-level tag. Can be overriden by subclasses; must be either DIV or P.