Editor

A frame which is expected to contain an editable document. Set the value of the editortype attribute to 'html' to create an editor document. Mozilla provides two types of editors, the HTML editor and the plaintext editor. The editor does not provide any editing user interface; you would supply that yourself. However, text editing, image resizing, and table row and cell editing capabilities are provided. If you do not set the editortype attribute on an editor, you must enable editing using the makeEditable method.

To specify the document to load in the editor use the src attribute. However, an issue is that if you specify the src attribute initially on the editor tag in the XUL file, the document does not become editable by default. To enable editing on an editor, do one of two things:

  1. Set the src attribute on the editor after the outer window has loaded, for example, in the onload handler. You might also set the src attribute based on what the user selects from a file dialog. In this case, set the editortype attribute on the editor.
  2. Call the makeEditable function to make the document loaded in the editor editable.

To edit a new document, set the src attribute to 'about:blank'.

Example:

    <editor src="http://www.xulplanet.com"/>
    <button label="Edit" oncommand="this.previousSibling.makeEditable('html',false);"/>

The editor element implements the following interfaces:

nsIAccessibleProvider  

Attributes:

editortype src type

Properties and Methods:

accessible commandManager contentDocument contentWindow docShell
editingSession editortype getEditor getHTMLEditor makeEditable
webBrowserFind webNavigation

Attributes:

Inherited from XUL Element:

align
allowevents
allownegativeassertions
class
coalesceduplicatearcs
collapsed
container
containment
context
contextmenu
datasources
dir
empty
equalsize
flags
flex
height
hidden
id
insertafter
insertbefore
left
maxheight
maxwidth
menu
minheight
minwidth
mousethrough
observes
ordinal
orient
pack
persist
popup
position
preference-editable
ref
removeelement
sortDirection
sortResource
sortResource2
statustext
style
template
tooltip
tooltiptext
top
uri
wait-cursor
width

editortype

Type: one of the values below

The type of editor to use. This value will be overriden depending on the content type of the document in the editor.

src

Type: document URL

The URL of the file to load into the editor.

type

Type: string

If set to the string 'content-primary', this editor becomes the primary content for the page. The window for the primary content can be retrieved more conveniently using 'window.content'.


Properties and Methods:

Inherited from XUL Element:

align
allowEvents
blur
boxObject
boxObject.element
boxObject.getLookAndFeelMetric
boxObject.height
boxObject.screenX
boxObject.screenY
boxObject.width
boxObject.x
boxObject.y
builder
className
click
collapsed
contextMenu
controllers
database
datasources
dir
doCommand
flex
focus
getElementsByAttribute
height
hidden
id
left
maxHeight
maxWidth
menu
minHeight
minWidth
observes
ordinal
orient
pack
persist
ref
resource
statusText
style
tooltip
tooltipText
top
width

Inherited from Element:

addEventListener
appendChild
attributes
childNodes
cloneNode
dispatchEvent
firstChild
getAttribute
getAttributeNS
getAttributeNode
getAttributeNodeNS
getElementsByTagName
getElementsByTagNameNS
hasAttribute
hasAttributeNS
hasAttributes
hasChildNodes
insertBefore
isSupported
lastChild
localName
namespaceURI
nextSibling
nodeName
nodeType
nodeValue
normalize
ownerDocument
parentNode
prefix
previousSibling
removeAttribute
removeAttributeNS
removeAttributeNode
removeChild
removeEventListener
replaceChild
setAttribute
setAttributeNS
setAttributeNode
setAttributeNodeNS
tagName

accessible

Type: nsIAccessible

Returns the accessibility object for the editor.

commandManager

Type: nsICommandManager

The command manager handles operations on the editor.

contentDocument

Type: document

This read-only property contains the document object in the editor.

contentWindow

Type: window

This read-only property contains the window object in the editor.

docShell

Type: nsIDocShell

This read-only property contains the nsIDocShell object for the document.

editingSession

Type: nsIEditingSession

The editing session for the editor which is used to initialize the editor. You would not normally need to use this.

editortype

Type: one of the values below

The type of editor to use. This value will be overriden depending on the content type of the document in the editor.

getEditor ( window )

Return Type: nsIEditor

Returns the editing interface for the editor which contains numerous methods for manipulating the document. Pass the editor's contentWindow as the argument.

getHTMLEditor ( window )

Return Type: nsIHTMLEditor

Returns the HTML editing interface for the editor which contains methods for manipulating an HTML document. Pass the editor's contentWindow as the argument.

makeEditable ( editortype , waitForLoad )

Return Type: no return value

This function enables editing for an editor. Specify 'text' or 'html' as the editortype.

webBrowserFind

Type: nsIWebBrowserFind

This read-only property contains an nsIWebBrowserFind object which can be used to search for text in the document.

webNavigation

Type: nsIWebNavigation

This read-only property contains the nsIWebNavigation object for the document. Most of its methods are callable directly on the editor itself, such as goBack and goForward. It also contains the load constants used by reloadWithFlags and loadURIWithFlags.


Copyright (C) 1999 - 2004 XulPlanet.com