nsIHTMLEditor

IID:afc36593-5787-4420-93d9-b2c0ccbf0cad
Inherits From:nsISupports

This interface is implemented by the following components:


Constants

PRInt16 eLeft = 0
PRInt16 eCenter = 1
PRInt16 eRight = 2
PRInt16 eJustify = 3

Properties

PRBool isCSSEnabled

A boolean which is true is the HTMLEditor has been instantiated with CSS knowledge and if the CSS pref is currently checked

PRBool returnInParagraphCreatesNewParagraph

A boolean indicating if a return key pressed in a paragraph creates another paragraph or just inserts a
at the caret


Methods

void addDefaultProperty ( nsIAtom property , AString attribute , AString value ) void addInsertionListener ( nsIContentFilter inFilter ) void align ( AString align ) PRBool canDrag ( nsIDOMEvent event ) void checkSelectionStateForAnonymousButtons ( nsISelection selection ) nsIDOMElement createAnonymousElement ( AString tag , nsIDOMNode parentNode , AString anonClass , PRBool isCreatedHidden ) nsIDOMElement createElementWithDefaults ( AString tagName ) void decreaseFontSize ( ) void doDrag ( nsIDOMEvent event ) void getAlignment ( out PRBool mixed , out PRInt16 align ) AString getBackgroundColorState ( out PRBool mixed ) nsIDOMElement getElementOrParentByTagName ( AString tagName , nsIDOMNode node ) AString getFontColorState ( out PRBool mixed ) AString getFontFaceState ( out PRBool mixed ) AString getHeadContentsAsHTML ( ) AString getHighlightColorState ( out PRBool mixed ) void getIndentState ( out PRBool canIndent , out PRBool canOutdent ) void getInlineProperty ( nsIAtom property , AString attribute , AString value , out PRBool first , out PRBool any , out PRBool all ) AString getInlinePropertyWithAttrValue ( nsIAtom property , AString attribute , AString value , out PRBool first , out PRBool any , out PRBool all ) nsISupportsArray getLinkedObjects ( ) void getListItemState ( out PRBool mixed , out PRBool LI , out PRBool DT , out PRBool DD ) void getListState ( out PRBool mixed , out PRBool OL , out PRBool UL , out PRBool DL ) AString getParagraphState ( out PRBool mixed ) nsIDOMElement getSelectedElement ( AString tagName ) nsIDOMElement getSelectionContainer ( ) void ignoreSpuriousDragEvent ( PRBool ignoreSpuriousDragEvent ) void increaseFontSize ( ) void indent ( AString indent ) void insertElementAtSelection ( nsIDOMElement element , PRBool deleteSelection ) void insertFromDrop ( nsIDOMEvent event ) void insertHTML ( AString inputString ) void insertHTMLWithContext ( AString inputString , AString contextStr , AString infoStr , AString flavor , nsIDOMDocument sourceDoc , nsIDOMNode destinationNode , PRInt32 destinationOffset , PRBool deleteSelection ) void insertLinkAroundSelection ( nsIDOMElement anchorElement ) PRBool isAnonymousElement ( nsIDOMElement element ) void makeOrChangeList ( AString listType , PRBool entireList , AString bulletType ) PRBool nodeIsBlock ( nsIDOMNode node ) void pasteNoFormatting ( PRInt32 selectionType ) void rebuildDocumentFromSource ( AString sourceString ) void removeAllDefaultProperties ( ) void removeAllInlineProperties ( ) void removeDefaultProperty ( nsIAtom property , AString attribute , AString value ) void removeInlineProperty ( nsIAtom property , AString attribute ) void removeInsertionListener ( nsIContentFilter inFilter ) void removeList ( AString listType ) void replaceHeadContentsWithHTML ( AString sourceToInsert ) void selectElement ( nsIDOMElement element ) void setBackgroundColor ( AString color ) void setBodyAttribute ( AString attr , AString value ) void setCaretAfterElement ( nsIDOMElement element ) void setCSSInlineProperty ( nsIAtom property , AString attribute , AString value ) void setDocumentTitle ( AString title ) void setInlineProperty ( nsIAtom property , AString attribute , AString value ) void setParagraphFormat ( AString paragraphFormat ) void updateBaseURL ( )

void addDefaultProperty ( nsIAtom property , AString attribute , AString value )

AddDefaultProperty() registers a default style property with the editor

Arguments:
property: the property to set by default
attribute: the attribute of the property, if applicable. May be null. Example: property="font", attribute="color"
value: if attribute is not null, the value of the attribute. Example: property="font", attribute="color", value="0x00FFFF"

void addInsertionListener ( nsIContentFilter inFilter )

Add listener for insertion override

Arguments:
inFilter: function which callers want called during insertion

void align ( AString align )

Document me!

Arguments:
align

PRBool canDrag ( nsIDOMEvent event )

CanDrag decides if a drag should be started (for example, based on the current selection and mousepoint).

Arguments:
event

void checkSelectionStateForAnonymousButtons ( nsISelection selection )

Checks if the anonymous nodes created by the HTML editor have to be refreshed or hidden depending on a possible new state of the selection

Arguments:
selection: [IN] a selection

nsIDOMElement createAnonymousElement ( AString tag , nsIDOMNode parentNode , AString anonClass , PRBool isCreatedHidden )

Returns an anonymous nsDOMElement of type tag, child of parentNode. If isCreatedHidden is true, the class "hidden" is added to the created element. If anonClass is not the empty string, it becomes the value of the attribute "_moz_anonclass"

Arguments:
tag: [IN] a string representing the desired type of the element to create
parentNode: [IN] the parent node of the created anonymous element
anonClass: [IN] contents of the _moz_anonclass attribute
isCreatedHidden: [IN] a boolean specifying if the class "hidden" is to be added to the created anonymous element
Returns:
a DOM Element

nsIDOMElement createElementWithDefaults ( AString tagName )

Return a new element with default attribute values

This does not rely on the selection, and is not sensitive to context.

Used primarily to supply new element for various insert element dialogs (Image, Link, NamedAnchor, Table, and HorizontalRule are the only returned elements as of 7/25/99)

Arguments:
tagName: The HTML tagname Special input values for Links and Named anchors: Use "href" to get a link node (an "A" tag with the "href" attribute set) Use "anchor" or "namedanchor" to get a named anchor node (an "A" tag with the "name" attribute set)
Returns:
The new element created.

void decreaseFontSize ( )

Decrease font size for text in selection by 1 HTML unit All existing text is scanned for existing attributes so they will be decreased instead of inserting new tag


void doDrag ( nsIDOMEvent event )

DoDrag transfers the relevant data (as appropriate) to a transferable so it can later be dropped.

Arguments:
event

void getAlignment ( out PRBool mixed , out PRInt16 align )

GetAlignment returns what alignment is in the selection.

Arguments:
mixed: True if there is more than one type of list item, or if there is some list and non-list
align: enum value for first encountered alignment (left/center/right)

AString getBackgroundColorState ( out PRBool mixed )

GetFontColorState returns what font face is in the selection.

Arguments:
mixed: True if there is more than one font color
Returns:
Color string. "" is returned for none.

nsIDOMElement getElementOrParentByTagName ( AString tagName , nsIDOMNode node )

Return the input node or a parent matching the given tagName, starting the search at the supplied node. An example of use is for testing if a node is in a table cell given a selection anchor node.

Arguments:
tagName: The HTML tagname Special input values: Use "href" to get a link node (an "A" tag with the "href" attribute set) Use "anchor" or "namedanchor" to get a named anchor node (an "A" tag with the "name" attribute set) Use "list" to get an OL, UL, or DL list node Use "td" to get either a TD or TH cell node
node: The node in the document to start the search. If it is null, the anchor node of the current selection is used.
Returns:
NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)

AString getFontColorState ( out PRBool mixed )

GetFontColorState returns what font face is in the selection.

Arguments:
mixed: True if there is more than one font color
Returns:
Color string. "" is returned for none.

AString getFontFaceState ( out PRBool mixed )

GetFontFaceState returns what font face is in the selection.

Arguments:
mixed: True if there is more than one font face
Returns:
Name of face. Note: "tt" is returned for tt tag. "" is returned for none.

AString getHeadContentsAsHTML ( )

Output the contents of the section as text/HTML format


AString getHighlightColorState ( out PRBool mixed )

GetHighlightColorState returns what the highlight color of the selection.

Arguments:
mixed: True if there is more than one font color
Returns:
Color string. "" is returned for none.

void getIndentState ( out PRBool canIndent , out PRBool canOutdent )

Document me!

Arguments:
canIndent
canOutdent

void getInlineProperty ( nsIAtom property , AString attribute , AString value , out PRBool first , out PRBool any , out PRBool all )

GetInlineProperty() gets aggregate properties of the current selection. All object in the current selection are scanned and their attributes are represented in a list of Property object.

Arguments:
property: the property to get on the selection
attribute: the attribute of the property, if applicable. May be null. Example: property="font", attribute="color"
value: if attribute is not null, the value of the attribute. May be null. Example: property="font", attribute="color", value="0x00FFFF"
first: [OUT] PR_TRUE if the first text node in the selection has the property
any: [OUT] PR_TRUE if any of the text nodes in the selection have the property
all: [OUT] PR_TRUE if all of the text nodes in the selection have the property

AString getInlinePropertyWithAttrValue ( nsIAtom property , AString attribute , AString value , out PRBool first , out PRBool any , out PRBool all )

Arguments:
property
attribute
value
first
any
all

nsISupportsArray getLinkedObjects ( )

Find all the nodes in the document which contain references to outside URIs (e.g. a href, img src, script src, etc.) The objects in the array will be type nsIURIRefObject.

Returns:
aNodeList the linked nodes found

void getListItemState ( out PRBool mixed , out PRBool LI , out PRBool DT , out PRBool DD )

GetListItemState returns what list item type is in the selection.

Arguments:
mixed: True if there is more than one type of list item, or if there is some list and non-list
LI: true if "li" list items are selected.
DT: true if "dt" list items are selected.
DD: true if "dd" list items are selected.

void getListState ( out PRBool mixed , out PRBool OL , out PRBool UL , out PRBool DL )

GetListState returns what list type is in the selection.

Arguments:
mixed: True if there is more than one type of list, or if there is some list and non-list
OL: The company that employs me. No, really, it's true if an "ol" list is selected.
UL: true if an "ul" list is selected.
DL: true if a "dl" list is selected.

AString getParagraphState ( out PRBool mixed )

GetParagraphState returns what block tag paragraph format is in the selection.

Arguments:
mixed: True if there is more than one format
Returns:
Name of block tag. "" is returned for none.

nsIDOMElement getSelectedElement ( AString tagName )

Return an element only if it is the only node selected, such as an image, horizontal rule, etc. The exception is a link, which is more like a text attribute: The Anchor tag is returned if the selection is within the textnode(s) that are children of the "A" node. This could be a collapsed selection, i.e., a caret within the link text.

Arguments:
tagName: The HTML tagname or and empty string to get any element (but only if it is the only element selected) Special input values for Links and Named anchors: Use "href" to get a link node (an "A" tag with the "href" attribute set) Use "anchor" or "namedanchor" to get a named anchor node (an "A" tag with the "name" attribute set)
Returns:
NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found (passes NS_SUCCEEDED macro)

nsIDOMElement getSelectionContainer ( )

Returns the deepest container of the selection

Returns:
a DOM Element

void ignoreSpuriousDragEvent ( PRBool ignoreSpuriousDragEvent )

XXX Used to suppress spurious drag/drop events to workaround bug 50703 Don't use this method! It will go away after first release!

Arguments:
ignoreSpuriousDragEvent

void increaseFontSize ( )

Increase font size for text in selection by 1 HTML unit All existing text is scanned for existing attributes so they will be incremented instead of inserting new tag


void indent ( AString indent )

Document me!

Arguments:
indent

void insertElementAtSelection ( nsIDOMElement element , PRBool deleteSelection )

Insert an element, which may have child nodes, at the selection Used primarily to insert a new element for various insert element dialogs, but it enforces the HTML 4.0 DTD "CanContain" rules, so it should be useful for other elements.

Arguments:
element: The element to insert
deleteSelection: Delete the selection before inserting If deleteSelection is PR_FALSE, then the element is inserted after the end of the selection for all element except Named Anchors, which insert before the selection

void insertFromDrop ( nsIDOMEvent event )

InsertFromDrop looks for a dragsession and inserts the relevant data in response to a drop.

Arguments:
event

void insertHTML ( AString inputString )

Insert some HTML source at the current location

Arguments:
inputString: the string to be inserted

void insertHTMLWithContext ( AString inputString , AString contextStr , AString infoStr , AString flavor , nsIDOMDocument sourceDoc , nsIDOMNode destinationNode , PRInt32 destinationOffset , PRBool deleteSelection )

Insert some HTML source, interpreting the string argument according to the given context.

Arguments:
inputString: the string to be inserted
contextStr: Context of insertion
infoStr: Related info to inputString
flavor: Transferable flavor, can be ""
sourceDoc: document where input was dragged from (may be null)
destinationNode: location for insertion (such as when dropped)
destinationOffset: used with destNode to determine insert location
deleteSelection: used with destNode during drag&drop;

void insertLinkAroundSelection ( nsIDOMElement anchorElement )

Insert an link element as the parent of the current selection

Arguments:
anchorElement

PRBool isAnonymousElement ( nsIDOMElement element )

Arguments:
element

void makeOrChangeList ( AString listType , PRBool entireList , AString bulletType )

Document me!

Arguments:
listType
entireList
bulletType

PRBool nodeIsBlock ( nsIDOMNode node )

Tests if a node is a BLOCK element according the the HTML 4.0 DTD. This does NOT consider CSS effect on display type

Arguments:
node: the node to test

void pasteNoFormatting ( PRInt32 selectionType )

Paste the text in the OS clipboard at the cursor position, replacing the selected text (if any), but strip out any HTML styles and formatting

Arguments:
selectionType

void rebuildDocumentFromSource ( AString sourceString )

Rebuild the entire document from source HTML Needed to be able to edit HEAD and other outside-of-BODY content

Arguments:
sourceString: HTML source string of the entire new document

void removeAllDefaultProperties ( )

RemoveAllDefaultProperties() unregisters all default style properties with the editor


void removeAllInlineProperties ( )

RemoveAllInlineProperties() deletes all the inline properties from all text in the current selection.


void removeDefaultProperty ( nsIAtom property , AString attribute , AString value )

RemoveDefaultProperty() unregisters a default style property with the editor

Arguments:
property: the property to remove from defaults
attribute: the attribute of the property, if applicable. May be null. Example: property="font", attribute="color"
value: if attribute is not null, the value of the attribute. Example: property="font", attribute="color", value="0x00FFFF"

void removeInlineProperty ( nsIAtom property , AString attribute )

RemoveInlineProperty() deletes the properties from all text in the current selection. If property is not set on the selection, nothing is done.

Arguments:
property: the property to remove from the selection All atoms are for normal HTML tags (e.g.: nsIEditorProperty::font) except when you want to remove just links and not named anchors. For that, use nsIEditorProperty::href
attribute: the attribute of the property, if applicable. May be null. Example: property=nsIEditorProptery::font, attribute="color" nsIEditProperty::allAttributes is special. It indicates that all content-based text properties are to be removed from the selection.

void removeInsertionListener ( nsIContentFilter inFilter )

Remove listener for insertion override

Arguments:
inFilter: function which callers do not want called during insertion

void removeList ( AString listType )

Document me!

Arguments:
listType

void replaceHeadContentsWithHTML ( AString sourceToInsert )

Replace all children of with string of HTML source

Arguments:
sourceToInsert

void selectElement ( nsIDOMElement element )

Set the selection at the suppled element

Arguments:
element: An element in the document

void setBackgroundColor ( AString color )

Set the value of the "bgcolor" attribute on the document's element

Arguments:
color: The HTML color string, such as "#ffccff" or "yellow"

void setBodyAttribute ( AString attr , AString value )

Set an attribute on the document's element such as text, link, background colors

8/31/00 THIS ISN'T BEING USED? SHOULD WE DROP IT?

Arguments:
attr: The attribute to be set
value: The value of the attribute

void setCaretAfterElement ( nsIDOMElement element )

Create a collapsed selection just after element

XXX could we parameterize SelectElement(before/select/after>?

The selection is set to parent-of-aElement with an offset 1 greater than element's offset but it enforces the HTML 4.0 DTD "CanContain" rules, so it should be useful for other elements.

Arguments:
element: An element in the document

void setCSSInlineProperty ( nsIAtom property , AString attribute , AString value )

SetInlineProperty() sets the aggregate properties on the current selection

Arguments:
property: the property to set on the selection
attribute: the attribute of the property, if applicable. May be null. Example: property="font", attribute="color"
value: if attribute is not null, the value of the attribute. May be null. Example: property="font", attribute="color", value="0x00FFFF"

void setDocumentTitle ( AString title )

Set the documents title.

Arguments:
title

void setInlineProperty ( nsIAtom property , AString attribute , AString value )

Arguments:
property
attribute
value

void setParagraphFormat ( AString paragraphFormat )

SetParagraphFormat Insert a block paragraph tag around selection

Arguments:
paragraphFormat: "p", "h1" to "h6", "address", "pre", or "blockquote"

void updateBaseURL ( )

Set the BaseURL for the document to the current URL but only if the page doesn't have a tag This should be done after the document URL has changed, such as after saving a file This is used as base for relativizing link and image urls

Reference documentation is generated from Mozilla's source.

Add a note User Contributed Notes
No comments available

Copyright © 1999 - 2005 XULPlanet.com