goog.editor.ContentEditableField
Classgoog.editor.ContentEditableField
> goog.editor.Field
> goog.events.EventTarget
> goog.Disposable
goog.editor.ContentEditableField(id, opt_doc)
This class encapsulates an editable field that is just a contentEditable div. To see events fired by this object, please see the base class.
id
{string
}
opt_doc
{Document
=}
.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
}
handler
{Function
|Object
}
opt_capture
{boolean
=}
opt_handlerScope
{Object
=}
.addListener(type, listener, opt_capture, opt_handler)
Inherited from goog.editor.Field
.
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.
type
{string
|Array
.<string
>}
listener
{Function
}
opt_capture
{boolean
=}
opt_handler
{Object
=}
.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
}
opt_scope
{Object
=}
.attachIframe(iframe)
[protected]Inherited from goog.editor.Field
.
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.
iframe
{HTMLIFrameElement
}
.attachWrapper(wrapper)
Inherited from goog.editor.Field
.
Attach an wrapper to this field, to be thrown out when the field is disposed.
wrapper
{goog.Disposable
}
.clearDelayedChange()
Inherited from goog.editor.Field
.
Don't wait for the timer and just fire the delayed change event if it's pending.
.creationStack
{string
}Inherited from goog.Disposable
.
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
.debounceEvent(eventType)
Inherited from goog.editor.Field
.
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.
eventType
{goog.editor.Field.EventType
}
.dispatchBeforeChange()
Inherited from goog.editor.Field
.
This dispatches the beforechange event on the editable field
.dispatchChange(opt_noDelay)
Inherited from goog.editor.Field
.
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.
opt_noDelay
{boolean
=}
.dispatchCommandValueChange(opt_commands)
Inherited from goog.editor.Field
.
Dispatches a command value change event.
opt_commands
{Array
.<string
>=}
.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
}
boolean
}
.dispatchSelectionChangeEvent(opt_e, opt_target)
Inherited from goog.editor.Field
.
Dispatch a selection change event, optionally caused by the given browser event or selecting the given target.
opt_e
{goog.events.BrowserEvent
=}
opt_target
{Node
=}
.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.
void
}
.disposeInternal()
[protected]Inherited from goog.editor.Field
.
Unattach 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, it should be something like this:
MyClass.prototype.disposeInternal = function() { MyClass.superClass_.disposeInternal.call(this); // Dispose logic for MyClass };
.execCommand(command, var_args)
Inherited from goog.editor.Field
.
Executes an editing command as per the registered plugins.
command
{string
}
var_args
{...*}
.field
{Element
}Inherited from goog.editor.Field
.
The editable dom node.
.focus()
Inherited from goog.editor.Field
.
Gives the field focus.
.focusAndPlaceCursorAtStart()
Inherited from goog.editor.Field
.
Gives the field focus and places the cursor at the start of the field.
.getAppWindow()
Inherited from goog.editor.Field
.
Returns the "application" window, where dialogs and bubbles should be rendered.
Window
}
.getBaseZindex()
Inherited from goog.editor.Field
.
Returns the zindex of the base level of the field.
number
}
.getCleanContents()
Inherited from goog.editor.Field
.
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.
string
}
.getDisposed
[deprecated]Deprecated. Use {@link #isDisposed} instead.
Inherited from goog.Disposable
.
boolean
}
.getEditableDomHelper()
Inherited from goog.editor.Field
.
goog.dom.DomHelper
?}
.getEditableIframe()
[protected]Inherited from goog.editor.Field
.
HTMLIFrameElement
}
.getElement()
Inherited from goog.editor.Field
.
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?
Element
}
.getFieldCopy()
[protected]Inherited from goog.editor.Field
.
Get the copy of the editable field element, which has the innerHTML set correctly.
Element
}
.getFieldFormatInfo(extraStyles)
[protected]Inherited from goog.editor.Field
.
extraStyles
{Object
}
goog.editor.icontent.FieldFormatInfo
}
.getHashCode()
Inherited from goog.editor.Field
.
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.
string
}
.getIframeAttributes()
[protected]Inherited from goog.editor.Field
.
Object
}
.getInjectableContents(contents, styles)
Inherited from goog.editor.Field
.
Returns prepared contents that can be injected into the editable field.
contents
{?string
}
styles
{Object
}
string
}
.getOriginalElement()
Inherited from goog.editor.Field
.
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.
Element
}
.getParentEventTarget()
Inherited from goog.events.EventTarget
.
Returns the parent of this event target to use for bubbling.
goog.events.EventTarget
}
.getPluginByClassId(classId)
Inherited from goog.editor.Field
.
Returns the registered plugin with the given classId.
classId
{string
}
goog.editor.Plugin
}
.getRange()
Inherited from goog.editor.Field
.
goog.dom.AbstractRange
?}
.handleChange()
Inherited from goog.editor.Field
.
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.
.handleDomAttrChange(handler, browserEvent)
[protected]Inherited from goog.editor.Field
.
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)
handler
{Function
}
browserEvent
{goog.events.BrowserEvent
}
.handleFieldLoad()
[protected]Inherited from goog.editor.Field
.
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_.
.iframeFieldLoadHandler(iframe, innerHtml, styles)
[protected]Inherited from goog.editor.Field
.
The function to call when the editable iframe loads.
iframe
{HTMLIFrameElement
}
innerHtml
{string
}
styles
{Object
}
.inModalMode()
Inherited from goog.editor.Field
.
boolean
}
.injectContents(contents, field)
[protected]Inherited from goog.editor.Field
.
Prepare the given contents, then inject them into the editable field.
contents
{?string
}
field
{Element
}
.installStyles()
[protected]Installs styles if needed. Only writes styles when they can't be written inline directly into the field.
.isDisposed()
Inherited from goog.Disposable
.
boolean
}
.isEventStopped(eventType)
[protected]Inherited from goog.editor.Field
.
Checks if the event of the given type has stopped being dispatched
eventType
{goog.editor.Field.EventType
}
boolean
}
.isFixedHeight
Inherited from goog.editor.Field
.
boolean
}
.isLoaded()
Inherited from goog.editor.Field
.
boolean
}
.isLoading()
Inherited from goog.editor.Field
.
boolean
}
.isModified(opt_useIsEverModified)
Inherited from goog.editor.Field
.
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.
opt_useIsEverModified
{boolean
=}
boolean
}
.isSelectionEditable()
Inherited from goog.editor.Field
.
boolean
}
.isUneditable()
Inherited from goog.editor.Field
.
boolean
}
.logger
[protected] {goog.debug.Logger
}Logging object.
.makeEditable(opt_iframeSrc)
Inherited from goog.editor.Field
.
Makes a field editable.
opt_iframeSrc
{string
=}
.makeEditableInternal(opt_iframeSrc)
[protected]Handles actually making something editable - creating necessary nodes, injecting content, etc.
opt_iframeSrc
{string
=}
.makeUneditable(opt_skipRestore)
Inherited from goog.editor.Field
.
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.
opt_skipRestore
{boolean
=}
.manipulateDom(func, opt_preventDelayedChange, opt_handler)
Inherited from goog.editor.Field
.
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 {@code opt_preventDelayedChange}.
func
{function
()}
opt_preventDelayedChange
{boolean
=}
opt_handler
{Object
=}
.placeCursorAtEnd()
Inherited from goog.editor.Field
.
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.
.placeCursorAtStart()
Inherited from goog.editor.Field
.
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.
.queryCommandValue(commands)
Inherited from goog.editor.Field
.
Gets the value of command(s).
commands
{string
|Array
.<string
>}
.registerDisposable(disposable)
Inherited from goog.Disposable
.
Associates a disposable object with this object so that they will be disposed together.
disposable
{goog.disposable.IDisposable
}
.registerPlugin(plugin)
Inherited from goog.editor.Field
.
Registers the plugin with the editable field.
plugin
{goog.editor.Plugin
}
.removeAllWrappers()
Inherited from goog.editor.Field
.
Removes all wrappers and destroys them.
.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
}
handler
{Function
|Object
}
opt_capture
{boolean
=}
opt_handlerScope
{Object
=}
.resetOriginalElemProperties()
Inherited from goog.editor.Field
.
Reset the properties on the original field element to how it was before it was made editable.
.restoreDom
[protected]Restores the dom to how it was before being made editable.
.setAppWindow(appWindow)
Inherited from goog.editor.Field
.
Sets the application window.
appWindow
{!Window
}
.setBaseZindex(zindex)
Inherited from goog.editor.Field
.
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?
zindex
{number
}
.setHtml(addParas, html, opt_dontFireDelayedChange, opt_applyLorem)
Inherited from goog.editor.Field
.
Sets the contents of the field.
addParas
{boolean
}
html
{?string
}
opt_dontFireDelayedChange
{boolean
=}
opt_applyLorem
{boolean
=}
.setInitialStyle(cssText)
Inherited from goog.editor.Field
.
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.
cssText
{string
}
.setModalMode(inModalMode)
Inherited from goog.editor.Field
.
inModalMode
{boolean
}
.setParentEventTarget(parent)
Inherited from goog.events.EventTarget
.
Sets the parent of this event target to use for bubbling.
parent
{goog.events.EventTarget
?}
.setupFieldObject(field)
[protected]Inherited from goog.editor.Field
.
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.
field
{Element
}
.setupMutationEventHandlersGecko()
[protected]Inherited from goog.editor.Field
.
Mutation events tell us when something has changed for mozilla.
.shouldLoadAsynchronously()
[protected]Inherited from goog.editor.Field
.
Returns true if the field needs to be loaded asynchrnously.
boolean
}
.shouldRefocusOnInputMobileSafari
Inherited from goog.editor.Field
.
boolean
}
.startChangeEvents(opt_fireChange, opt_fireDelayedChange)
Inherited from goog.editor.Field
.
Start change events again and fire once if desired.
opt_fireChange
{boolean
=}
opt_fireDelayedChange
{boolean
=}
.startEvent(eventType)
Inherited from goog.editor.Field
.
Re-starts the event of the given type being dispatched, if it had previously been stopped with stopEvent().
eventType
{goog.editor.Field.EventType
}
.stopChangeEvents(opt_stopChange, opt_stopDelayedChange)
Inherited from goog.editor.Field
.
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.
opt_stopChange
{boolean
=}
opt_stopDelayedChange
{boolean
=}
.stopEvent(eventType)
Inherited from goog.editor.Field
.
Stops the event of the given type from being dispatched.
eventType
{goog.editor.Field.EventType
}
.turnOnDesignModeGecko
[protected]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.
.unregisterPlugin(plugin)
Inherited from goog.editor.Field
.
Unregisters the plugin with this field.
plugin
{goog.editor.Plugin
}
.usesIframe()
boolean
}
.writeIframeContent(iframe, innerHtml, extraStyles)
[protected]Inherited from goog.editor.Field
.
Writes the html content into the iframe. Handles writing any aditional styling as well.
iframe
{HTMLIFrameElement
}
innerHtml
{string
}
extraStyles
{Object
}