Home

# Class goog.editor.plugins.EnterHandler

Plugin to handle enter keys. This does all the crazy to normalize (as much as is reasonable) what happens when you hit enter. This also handles the special casing of hitting enter in a blockquote. In IE, Webkit, and Opera, the resulting HTML uses one DIV tag per line. In Firefox, the resulting HTML uses BR tags at the end of each line.

extends goog.editor.Plugin

Instance Method Summary

`deleteBrGecko(?goog.events.Event e)`

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.

| `deleteCursorSelectionIE_() ⇒ ?Node` Delete the selection at the current cursor position, then returns a temporary node at the current position.
| `deleteCursorSelectionW3C_() ⇒ ?goog.editor.range.Point` Delete the selection at the current cursor position, then returns the node at the current position.
| `deleteCursorSelection_() ⇒ (Node|Object|null)` Deletes the content at the current cursor position.
| `enable(?goog.editor.Field fieldObject)` Enables this plugin for the specified, registered field object. A field object should only be enabled when it is loaded.

`ensureBlockIeOpera(?goog.dom.TagName tag, boolean= opt_keyUp)`

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: "

## foo[cursor]

", 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.

| `handleBackspaceInternal(?goog.events.Event e, ?goog.dom.AbstractRange range)` Internal backspace handler.
| `handleDeleteGecko(?goog.events.Event e)` Internal delete key handler.
| `handleEnterAtCursorGeckoInternal(?goog.events.BrowserEvent e, boolean wasCollapsed, ?goog.dom.AbstractRange range)` 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.
| `handleEnterGecko_(?goog.events.BrowserEvent e)` Handles an enter keypress event on fields in Gecko.
| `handleEnterWebkitInternal(?goog.events.BrowserEvent e)` Handle an enter key press in WebKit.
| `handleKeyUpInternal(?goog.events.Event e)` Internal handler for keyup events.
| `prepareContentsHtml(string html) ⇒ 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.
| `processParagraphTagsInternal(?goog.events.Event e, boolean split)` Fix paragraphs to be the correct type of node.
| `releasePositionObject_((Node|Object|null) position)` Releases the object returned by deleteCursorSelection_.

Static Method Summary
| `deleteW3cRange_(?goog.dom.AbstractRange range)` Deletes the contents of the selection from the DOM.
| `isBrElem(?Node node) ⇒ boolean` Whether this is a node that contains a single BR tag and non-nbsp whitespace.
| `isDirectlyInBlockquote(?Node n) ⇒ boolean` Determines whether the lowest containing block node is a blockquote.
| `isInOneContainerW3c_(?goog.dom.AbstractRange range) ⇒ boolean` Checks whether the whole range is in a single block-level element.
| `isPartialEndW3c_(?goog.dom.AbstractRange range) ⇒ boolean` Checks whether the end of the range is not at the end of a block-level element.