goog.editor.ContentEditableField
Provided By | |
---|---|
Extends | |
All Implemented Interfaces |
This class encapsulates an editable field that is just a contentEditable div.
To see events fired by this object, please see the base class.
new ContentEditableField( id, opt_doc )
Parameters |
|
---|
Instance Methods
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.addListener( type, listener, opt_capture, opt_handler ) → void
void
Registers a keyboard event listener on the field. This is necessary for Gecko since the fields are contained in an iFrame and there is no way to auto-propagate key events up to the main window.
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.attachIframe( iframe ) → void
void
Given the original field element, and the iframe that is destined to become the editable field, styles them appropriately and add the iframe to the dom.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.attachWrapper( wrapper ) → void
void
Attach an wrapper to this field, to be thrown out when the field is disposed.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.clearDelayedChange() → void
void
Don't wait for the timer and just fire the delayed change event if it's pending.
this.clearListeners() → void
void
Stops all listeners and timers.
this.debounceEvent( eventType ) → void
void
Block an event for a short amount of time. Intended for the situation where an event pair fires in quick succession (e.g., mousedown/mouseup, keydown/keyup, focus/blur), and we want the second event in the pair to get "debounced."
WARNING: This should never be used to solve race conditions or for mission-critical actions. It should only be used for UI improvements, where it's okay if the behavior is non-deterministic.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.dispatchBeforeChange() → void
void
This dispatches the beforechange event on the editable field
this.dispatchBlur() → void
void
Dispatches a blur event.
this.dispatchChange( opt_noDelay ) → void
void
Dispatches the appropriate set of change events. This only fires synchronous change events in blended-mode, iframe-using mozilla. It just starts the appropriate timer for goog.editor.Field.EventType.DELAYEDCHANGE. This also starts up change events again if they were stopped.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.dispatchCommandValueChange( opt_commands ) → void
void
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.dispatchSelectionChangeEvent( opt_e, opt_target ) → void
void
Dispatch a selection change event, optionally caused by the given browser event or selecting the given target.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
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.execCommand( command, ...var_args ) → *
*
Executes an editing command as per the registered plugins.
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.focus() → void
void
Gives the field focus.
this.focusAndPlaceCursorAtStart() → void
void
Gives the field focus and places the cursor at the start of the field.
this.getAppWindow() → Window
Window
Returns the "application" window, where dialogs and bubbles should be rendered.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getBaseZindex() → number
number
Returns the zindex of the base level of the field.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getCleanContents() → string
string
Retrieve the HTML contents of a field.
Do NOT just get the innerHTML of a field directly--there's a lot of processing that needs to happen.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getDisposed() → boolean
boolean
warning Deprecated | Use |
---|
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getEditableDomHelper() → (goog.dom.DomHelper|null)
(goog.dom.DomHelper|null)
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getEditableIframe() → (HTMLIFrameElement|null)
(HTMLIFrameElement|null)
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getElement() → (Element|null)
(Element|null)
Returns the editable DOM element or null if this field is not editable.
On IE or Safari this is the element with contentEditable=true (in whitebox mode, the iFrame body).
On Gecko this is the iFrame body TODO(user): How do we word this for subclass version?
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getFieldCopy() → Element
Element
Get the copy of the editable field element, which has the innerHTML set correctly.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getFieldFormatInfo( extraStyles ) → goog.editor.icontent.FieldFormatInfo
goog.editor.icontent.FieldFormatInfo
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.getHashCode() → string
string
Returns a string usable as a hash code for this field. For field's that were created with an id, the hash code is guaranteed to be the id. TODO(user): I think we can get rid of this. Seems only used from editor.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getIframeAttributes() → Object
Object
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getInjectableContents( contents, styles ) → string
string
Returns prepared contents that can be injected into the editable field.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
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.getOriginalElement() → (Element|null)
(Element|null)
Returns original DOM element that is being made editable by Trogedit or null if that element has not yet been found in the appropriate document.
Defined by | |||
---|---|---|---|
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.getPluginByClassId( classId ) → (goog.editor.PluginImpl|null)
(goog.editor.PluginImpl|null)
Returns the registered plugin with the given classId.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.getRange() → (goog.dom.AbstractRange|null)
(goog.dom.AbstractRange|null)
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.handleChange() → void
void
Handle a change in the Editable Field. Marks the field has modified, dispatches the change event on the editable field (moz only), starts the timer for the delayed change event. Note that these actions only occur if the proper events are not stopped.
this.handleDomAttrChange( handler, browserEvent ) → void
void
Fires a change event only if the attribute change effects the editiable field. We ignore events that are internal browser events (ie scrollbar state change)
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.handleFieldLoad() → void
void
Handle the loading of the field (e.g. once the field is ready to setup). TODO(user): this should probably just be moved into dispatchLoadEvent_.
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.iframeFieldLoadHandler( iframe, innerHtml, styles ) → void
void
this.inModalMode() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.injectContents( contents, field ) → void
void
Prepare the given contents, then inject them into the editable field.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.installStyles() → void
void
Installs styles if needed. Only writes styles when they can't be written inline directly into the field.
Overrides | |
---|---|
Parameters | None. |
this.isDisposed() → boolean
boolean
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.isEventStopped( eventType ) → boolean
boolean
Checks if the event of the given type has stopped being dispatched
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.isFixedHeight() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isLoaded() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isLoading() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isModified( opt_useIsEverModified ) → boolean
boolean
Checks the modified state of the field. Note: Changes that take place while the goog.editor.Field.EventType.CHANGE event is stopped do not effect the modified state.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.isSelectionEditable() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isUneditable() → boolean
boolean
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
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.makeEditable( opt_iframeSrc ) → void
void
Makes a field editable.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.makeEditableInternal( opt_iframeSrc ) → void
void
Handles actually making something editable - creating necessary nodes, injecting content, etc.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
|
this.makeUneditable( opt_skipRestore ) → void
void
Closes the field and cancels all pending change timers. Note that this means that if a change event has not fired yet, it will not fire. Clients should check fieldOj.isModified() if they depend on the final change event. Throws an error if the field is already uneditable.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.manipulateDom( func, opt_preventDelayedChange, opt_handler ) → void
void
Calls a function to manipulate the dom of this field. This method should be
used whenever Trogedit clients need to modify the dom of the field, so that
delayed change events are handled appropriately. Extra delayed change events
will cause undesired states to be added to the undo-redo stack. This method
will always fire at most one delayed change event, depending on the value of
opt_preventDelayedChange
.
Defined by | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.placeCursorAtEnd() → void
void
Place the cursor at the start of this field. It's recommended that you only use this method (and manipulate the selection in general) when there is not an existing selection in the field.
this.placeCursorAtStart() → void
void
Place the cursor at the start of this field. It's recommended that you only use this method (and manipulate the selection in general) when there is not an existing selection in the field.
this.queryCommandValue( commands ) → *
*
Gets the value of command(s).
Defined by | |||||
---|---|---|---|---|---|
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.registerPlugin( plugin ) → void
void
Registers the plugin with the editable field.
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.removeAllWrappers() → void
void
Removes all wrappers and destroys them.
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.resetOriginalElemProperties() → void
void
Reset the properties on the original field element to how it was before it was made editable.
this.restoreDom() → void
void
Restores the dom to how it was before being made editable.
Overrides | |
---|---|
Parameters | None. |
this.restoreSavedRange( opt_range ) → void
void
Restore a saved range, and set the focus on the field. If no range is specified, we simply set the focus.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setAppWindow( appWindow ) → void
void
Sets the application window.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setBaseZindex( zindex ) → void
void
Sets the zIndex that the field should be based off of. TODO(user): Get rid of this completely. Here for Sites. Should this be set directly on UI plugins?
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setFollowLinkInNewWindow( followLinkInNewWindow ) → void
void
Sets whether activating a hyperlink in this editable field will open a new window or not.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setInitialStyle( cssText ) → void
void
Sets the value that will replace the style attribute of this field's element when the field is made non-editable. This method is called with the current value of the style attribute when the field is made editable.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setModalMode( inModalMode ) → void
void
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.setSafeHtml( addParas, html, opt_dontFireDelayedChange, opt_applyLorem ) → void
void
Sets the contents of the field.
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.setUseWindowMouseUp( flag ) → void
void
Sets flag to control whether to use window mouse up after seeing a mouse down operation on the field.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setupFieldObject( field ) → void
void
Sets up the field object and window util of this field, and enables this editable field with all registered plugins. This is essential to the initialization of the field. It must be called when the field becomes fully loaded and editable.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setupMutationEventHandlersGecko() → void
void
Mutation events tell us when something has changed for mozilla.
this.shouldLoadAsynchronously() → boolean
boolean
Returns true if the field needs to be loaded asynchrnously.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.startChangeEvents( opt_fireChange, opt_fireDelayedChange ) → void
void
this.startEvent( eventType ) → void
void
Re-starts the event of the given type being dispatched, if it had previously been stopped with stopEvent().
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.stopChangeEvents( opt_stopChange, opt_stopDelayedChange, opt_cancelPendingDelayedChange ) → void
void
Temporarily ignore change events. If the time has already been set, it will fire immediately now. Further setting of the timer is stopped and dispatching of events is stopped until startChangeEvents is called.
Defined by | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.stopEvent( eventType ) → void
void
Stops the event of the given type from being dispatched.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.turnOnDesignModeGecko() → void
void
Attemps to turn on designMode for a document. This function can fail under certain circumstances related to the load event, and will throw an exception.
Overrides | |
---|---|
Parameters | None. |
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.unregisterPlugin( plugin ) → void
void
Unregisters the plugin with this field.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.usesIframe() → boolean
boolean
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.writeIframeContent( iframe, innerHtml, extraStyles ) → void
void
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.cssStyles → goog.html.SafeStyleSheet
goog.html.SafeStyleSheet
Additional styles to install for the editable field.
this.editableDomHelper → (goog.dom.DomHelper|null)
(goog.dom.DomHelper|null)
Dom helper for the editable node.
this.eventRegister → (goog.events.EventHandler<goog.editor.Field>|null)
(goog.events.EventHandler<goog.editor.Field>|null)
No information.
this.field → (Element|null)
(Element|null)
The editable dom node.
this.id → string
string
The id for this editable field, which must match the id of the element associated with this field.
this.logger → (goog.log.Logger|null)
(goog.log.Logger|null)
Logging object.
this.originalDomHelper → (goog.dom.DomHelper|null)
(goog.dom.DomHelper|null)
The dom helper for the node to be made editable.
this.originalElement → (Element|null)
(Element|null)
The original node that is being made editable, or null if it has not yet been found.