michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: #include "domstubs.idl" michael@0: michael@0: interface nsIAtom; michael@0: interface nsIContent; michael@0: interface nsISupportsArray; michael@0: interface nsISelection; michael@0: interface nsIContentFilter; michael@0: michael@0: %{C++ michael@0: namespace mozilla { michael@0: namespace dom { michael@0: class Element; michael@0: } michael@0: } michael@0: %} michael@0: michael@0: [ptr] native Element (mozilla::dom::Element); michael@0: michael@0: [scriptable, uuid(833f30de-94c7-4630-a852-2300ef329d7b)] michael@0: michael@0: interface nsIHTMLEditor : nsISupports michael@0: { michael@0: %{C++ michael@0: typedef short EAlignment; michael@0: %} michael@0: michael@0: // used by GetAlignment() michael@0: const short eLeft = 0; michael@0: const short eCenter = 1; michael@0: const short eRight = 2; michael@0: const short eJustify = 3; michael@0: michael@0: michael@0: /* ------------ Inline property methods -------------- */ michael@0: michael@0: michael@0: /** michael@0: * AddDefaultProperty() registers a default style property with the editor michael@0: * michael@0: * @param aProperty the property to set by default michael@0: * @param aAttribute the attribute of the property, if applicable. michael@0: * May be null. michael@0: * Example: aProperty="font", aAttribute="color" michael@0: * @param aValue if aAttribute is not null, the value of the attribute. michael@0: * Example: aProperty="font", aAttribute="color", michael@0: * aValue="0x00FFFF" michael@0: */ michael@0: void addDefaultProperty(in nsIAtom aProperty, michael@0: in AString aAttribute, michael@0: in AString aValue); michael@0: michael@0: /** michael@0: * RemoveDefaultProperty() unregisters a default style property with the editor michael@0: * michael@0: * @param aProperty the property to remove from defaults michael@0: * @param aAttribute the attribute of the property, if applicable. michael@0: * May be null. michael@0: * Example: aProperty="font", aAttribute="color" michael@0: * @param aValue if aAttribute is not null, the value of the attribute. michael@0: * Example: aProperty="font", aAttribute="color", michael@0: * aValue="0x00FFFF" michael@0: */ michael@0: void removeDefaultProperty(in nsIAtom aProperty, michael@0: in AString aAttribute, michael@0: in AString aValue); michael@0: michael@0: /** michael@0: * RemoveAllDefaultProperties() unregisters all default style properties with the editor michael@0: * michael@0: */ michael@0: void removeAllDefaultProperties(); michael@0: michael@0: /** michael@0: * SetInlineProperty() sets the aggregate properties on the current selection michael@0: * michael@0: * @param aProperty the property to set on the selection michael@0: * @param aAttribute the attribute of the property, if applicable. michael@0: * May be null. michael@0: * Example: aProperty="font", aAttribute="color" michael@0: * @param aValue if aAttribute is not null, the value of the attribute. michael@0: * May be null. michael@0: * Example: aProperty="font", aAttribute="color", michael@0: * aValue="0x00FFFF" michael@0: */ michael@0: void setInlineProperty(in nsIAtom aProperty, michael@0: in AString aAttribute, michael@0: in AString aValue); michael@0: michael@0: /** michael@0: * getInlineProperty() gets aggregate properties of the current selection. michael@0: * All object in the current selection are scanned and their attributes are michael@0: * represented in a list of Property object. michael@0: * michael@0: * @param aProperty the property to get on the selection michael@0: * @param aAttribute the attribute of the property, if applicable. michael@0: * May be null. michael@0: * Example: aProperty="font", aAttribute="color" michael@0: * @param aValue if aAttribute is not null, the value of the attribute. michael@0: * May be null. michael@0: * Example: aProperty="font", aAttribute="color", michael@0: * aValue="0x00FFFF" michael@0: * @param aFirst [OUT] PR_TRUE if the first text node in the michael@0: * selection has the property michael@0: * @param aAny [OUT] PR_TRUE if any of the text nodes in the michael@0: * selection have the property michael@0: * @param aAll [OUT] PR_TRUE if all of the text nodes in the michael@0: * selection have the property michael@0: */ michael@0: void getInlineProperty(in nsIAtom aProperty, michael@0: in AString aAttribute, michael@0: in AString aValue, michael@0: out boolean aFirst, michael@0: out boolean aAny, michael@0: out boolean aAll); michael@0: michael@0: AString getInlinePropertyWithAttrValue(in nsIAtom aProperty, michael@0: in AString aAttribute, michael@0: in AString aValue, michael@0: out boolean aFirst, michael@0: out boolean aAny, michael@0: out boolean aAll); michael@0: michael@0: /** michael@0: * removeAllInlineProperties() deletes all the inline properties from all michael@0: * text in the current selection. michael@0: */ michael@0: void removeAllInlineProperties(); michael@0: michael@0: michael@0: /** michael@0: * removeInlineProperty() deletes the properties from all text in the current michael@0: * selection. If aProperty is not set on the selection, nothing is done. michael@0: * michael@0: * @param aProperty the property to remove from the selection michael@0: * All atoms are for normal HTML tags (e.g.: michael@0: * nsIEditorProperty::font) except when you want to michael@0: * remove just links and not named anchors. michael@0: * For that, use nsIEditorProperty::href michael@0: * @param aAttribute the attribute of the property, if applicable. michael@0: * May be null. michael@0: * Example: aProperty=nsIEditorProptery::font, michael@0: * aAttribute="color" michael@0: * nsIEditProperty::allAttributes is special. michael@0: * It indicates that all content-based text properties michael@0: * are to be removed from the selection. michael@0: */ michael@0: void removeInlineProperty(in nsIAtom aProperty, in AString aAttribute); michael@0: michael@0: /** michael@0: * Increase font size for text in selection by 1 HTML unit michael@0: * All existing text is scanned for existing attributes michael@0: * so they will be incremented instead of inserting new tag michael@0: */ michael@0: void increaseFontSize(); michael@0: michael@0: /** michael@0: * Decrease font size for text in selection by 1 HTML unit michael@0: * All existing text is scanned for existing attributes michael@0: * so they will be decreased instead of inserting new tag michael@0: */ michael@0: void decreaseFontSize(); michael@0: michael@0: /* ------------ HTML content methods -------------- */ michael@0: michael@0: /** michael@0: * Tests if a node is a BLOCK element according the the HTML 4.0 DTD. michael@0: * This does NOT consider CSS effect on display type michael@0: * michael@0: * @param aNode the node to test michael@0: */ michael@0: boolean nodeIsBlock(in nsIDOMNode node); michael@0: michael@0: /** michael@0: * Insert some HTML source at the current location michael@0: * michael@0: * @param aInputString the string to be inserted michael@0: */ michael@0: void insertHTML(in AString aInputString); michael@0: michael@0: michael@0: /** michael@0: * Paste the text in the OS clipboard at the cursor position, replacing michael@0: * the selected text (if any), but strip out any HTML styles and formatting michael@0: */ michael@0: void pasteNoFormatting(in long aSelectionType); michael@0: michael@0: /** michael@0: * Rebuild the entire document from source HTML michael@0: * Needed to be able to edit HEAD and other outside-of-BODY content michael@0: * michael@0: * @param aSourceString HTML source string of the entire new document michael@0: */ michael@0: void rebuildDocumentFromSource(in AString aSourceString); michael@0: michael@0: /** michael@0: * Insert some HTML source, interpreting michael@0: * the string argument according to the given context. michael@0: * michael@0: * @param aInputString the string to be inserted michael@0: * @param aContextStr Context of insertion michael@0: * @param aInfoStr Related info to aInputString michael@0: * @param aFlavor Transferable flavor, can be "" michael@0: * @param aSourceDoc document where input was dragged from (may be null) michael@0: * @param aDestinationNode location for insertion (such as when dropped) michael@0: * @param aDestinationOffset used with aDestNode to determine insert location michael@0: * @param aDeleteSelection used with aDestNode during drag&drop michael@0: * @param aCollapseSelection used with aDestNode during drag&drop michael@0: */ michael@0: void insertHTMLWithContext(in AString aInputString, michael@0: in AString aContextStr, michael@0: in AString aInfoStr, michael@0: in AString aFlavor, michael@0: in nsIDOMDocument aSourceDoc, michael@0: in nsIDOMNode aDestinationNode, michael@0: in long aDestinationOffset, michael@0: in boolean aDeleteSelection); michael@0: michael@0: michael@0: /** michael@0: * Insert an element, which may have child nodes, at the selection michael@0: * Used primarily to insert a new element for various insert element dialogs, michael@0: * but it enforces the HTML 4.0 DTD "CanContain" rules, so it should michael@0: * be useful for other elements. michael@0: * michael@0: * @param aElement The element to insert michael@0: * @param aDeleteSelection Delete the selection before inserting michael@0: * If aDeleteSelection is PR_FALSE, then the element is inserted michael@0: * after the end of the selection for all element except michael@0: * Named Anchors, which insert before the selection michael@0: */ michael@0: void insertElementAtSelection(in nsIDOMElement aElement, michael@0: in boolean aDeleteSelection); michael@0: michael@0: /** michael@0: * Set the documents title. michael@0: */ michael@0: void setDocumentTitle(in AString aTitle); michael@0: michael@0: /** michael@0: * Set the BaseURL for the document to the current URL michael@0: * but only if the page doesn't have a tag michael@0: * This should be done after the document URL has changed, michael@0: * such as after saving a file michael@0: * This is used as base for relativizing link and image urls michael@0: */ michael@0: void updateBaseURL(); michael@0: michael@0: michael@0: /* ------------ Selection manipulation -------------- */ michael@0: /* Should these be moved to nsISelection? */ michael@0: michael@0: /** michael@0: * Set the selection at the suppled element michael@0: * michael@0: * @param aElement An element in the document michael@0: */ michael@0: void selectElement(in nsIDOMElement aElement); michael@0: michael@0: /** michael@0: * Create a collapsed selection just after aElement michael@0: * michael@0: * XXX could we parameterize SelectElement(before/select/after>? michael@0: * michael@0: * The selection is set to parent-of-aElement with an michael@0: * offset 1 greater than aElement's offset michael@0: * but it enforces the HTML 4.0 DTD "CanContain" rules, so it should michael@0: * be useful for other elements. michael@0: * michael@0: * @param aElement An element in the document michael@0: */ michael@0: void setCaretAfterElement(in nsIDOMElement aElement); michael@0: michael@0: /** michael@0: * SetParagraphFormat Insert a block paragraph tag around selection michael@0: * @param aParagraphFormat "p", "h1" to "h6", "address", "pre", or "blockquote" michael@0: */ michael@0: void setParagraphFormat(in AString aParagraphFormat); michael@0: michael@0: /** michael@0: * getParagraphState returns what block tag paragraph format is in michael@0: * the selection. michael@0: * @param aMixed True if there is more than one format michael@0: * @return Name of block tag. "" is returned for none. michael@0: */ michael@0: AString getParagraphState(out boolean aMixed); michael@0: michael@0: /** michael@0: * getFontFaceState returns what font face is in the selection. michael@0: * @param aMixed True if there is more than one font face michael@0: * @return Name of face. Note: "tt" is returned for michael@0: * tt tag. "" is returned for none. michael@0: */ michael@0: AString getFontFaceState(out boolean aMixed); michael@0: michael@0: /** michael@0: * getFontColorState returns what font face is in the selection. michael@0: * @param aMixed True if there is more than one font color michael@0: * @return Color string. "" is returned for none. michael@0: */ michael@0: AString getFontColorState(out boolean aMixed); michael@0: michael@0: /** michael@0: * getFontColorState returns what font face is in the selection. michael@0: * @param aMixed True if there is more than one font color michael@0: * @return Color string. "" is returned for none. michael@0: */ michael@0: AString getBackgroundColorState(out boolean aMixed); michael@0: michael@0: /** michael@0: * getHighlightColorState returns what the highlight color of the selection. michael@0: * @param aMixed True if there is more than one font color michael@0: * @return Color string. "" is returned for none. michael@0: */ michael@0: AString getHighlightColorState(out boolean aMixed); michael@0: michael@0: /** michael@0: * getListState returns what list type is in the selection. michael@0: * @param aMixed True if there is more than one type of list, or michael@0: * if there is some list and non-list michael@0: * @param aOL The company that employs me. No, really, it's michael@0: * true if an "ol" list is selected. michael@0: * @param aUL true if an "ul" list is selected. michael@0: * @param aDL true if a "dl" list is selected. michael@0: */ michael@0: void getListState(out boolean aMixed, out boolean aOL, out boolean aUL, michael@0: out boolean aDL); michael@0: michael@0: /** michael@0: * getListItemState returns what list item type is in the selection. michael@0: * @param aMixed True if there is more than one type of list item, or michael@0: * if there is some list and non-list michael@0: * @param aLI true if "li" list items are selected. michael@0: * @param aDT true if "dt" list items are selected. michael@0: * @param aDD true if "dd" list items are selected. michael@0: */ michael@0: void getListItemState(out boolean aMixed, out boolean aLI, michael@0: out boolean aDT, out boolean aDD); michael@0: michael@0: /** michael@0: * getAlignment returns what alignment is in the selection. michael@0: * @param aMixed True if there is more than one type of list item, or michael@0: * if there is some list and non-list michael@0: * @param aAlign enum value for first encountered alignment michael@0: * (left/center/right) michael@0: */ michael@0: void getAlignment(out boolean aMixed, out short aAlign); michael@0: michael@0: /** michael@0: * Document me! michael@0: * michael@0: */ michael@0: void getIndentState(out boolean aCanIndent, out boolean aCanOutdent); michael@0: michael@0: /** michael@0: * Document me! michael@0: * michael@0: */ michael@0: void makeOrChangeList(in AString aListType, in boolean entireList, michael@0: in AString aBulletType); michael@0: michael@0: /** michael@0: * Document me! michael@0: * michael@0: */ michael@0: void removeList(in AString aListType); michael@0: michael@0: /** michael@0: * Document me! michael@0: * michael@0: */ michael@0: void indent(in AString aIndent); michael@0: michael@0: /** michael@0: * Document me! michael@0: * michael@0: */ michael@0: void align(in AString aAlign); michael@0: michael@0: /** michael@0: * Return the input node or a parent matching the given aTagName, michael@0: * starting the search at the supplied node. michael@0: * An example of use is for testing if a node is in a table cell michael@0: * given a selection anchor node. michael@0: * michael@0: * @param aTagName The HTML tagname michael@0: * Special input values: michael@0: * Use "href" to get a link node michael@0: * (an "A" tag with the "href" attribute set) michael@0: * Use "anchor" or "namedanchor" to get a named anchor node michael@0: * (an "A" tag with the "name" attribute set) michael@0: * Use "list" to get an OL, UL, or DL list node michael@0: * Use "td" to get either a TD or TH cell node michael@0: * michael@0: * @param aNode The node in the document to start the search. michael@0: * If it is null, the anchor node of the current selection is used. michael@0: * @return NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found michael@0: * (passes NS_SUCCEEDED macro) michael@0: */ michael@0: nsIDOMElement getElementOrParentByTagName(in AString aTagName, michael@0: in nsIDOMNode aNode); michael@0: michael@0: /** michael@0: * Return an element only if it is the only node selected, michael@0: * such as an image, horizontal rule, etc. michael@0: * The exception is a link, which is more like a text attribute: michael@0: * The Anchor tag is returned if the selection is within the textnode(s) michael@0: * that are children of the "A" node. michael@0: * This could be a collapsed selection, i.e., a caret michael@0: * within the link text. michael@0: * michael@0: * @param aTagName The HTML tagname or and empty string michael@0: * to get any element (but only if it is the only element selected) michael@0: * Special input values for Links and Named anchors: michael@0: * Use "href" to get a link node michael@0: * (an "A" tag with the "href" attribute set) michael@0: * Use "anchor" or "namedanchor" to get a named anchor node michael@0: * (an "A" tag with the "name" attribute set) michael@0: * @return NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found michael@0: * (passes NS_SUCCEEDED macro) michael@0: */ michael@0: nsIDOMElement getSelectedElement(in AString aTagName); michael@0: michael@0: /** michael@0: * Output the contents of the section as text/HTML format michael@0: */ michael@0: AString getHeadContentsAsHTML(); michael@0: michael@0: /** michael@0: * Replace all children of with string of HTML source michael@0: */ michael@0: void replaceHeadContentsWithHTML(in AString aSourceToInsert); michael@0: michael@0: /** michael@0: * Return a new element with default attribute values michael@0: * michael@0: * This does not rely on the selection, and is not sensitive to context. michael@0: * michael@0: * Used primarily to supply new element for various insert element dialogs michael@0: * (Image, Link, NamedAnchor, Table, and HorizontalRule michael@0: * are the only returned elements as of 7/25/99) michael@0: * michael@0: * @param aTagName The HTML tagname michael@0: * Special input values for Links and Named anchors: michael@0: * Use "href" to get a link node michael@0: * (an "A" tag with the "href" attribute set) michael@0: * Use "anchor" or "namedanchor" to get a named anchor node michael@0: * (an "A" tag with the "name" attribute set) michael@0: * @return The new element created. michael@0: */ michael@0: nsIDOMElement createElementWithDefaults(in AString aTagName); michael@0: michael@0: /** michael@0: * Insert an link element as the parent of the current selection michael@0: * michael@0: * @param aElement An "A" element with a non-empty "href" attribute michael@0: */ michael@0: void insertLinkAroundSelection(in nsIDOMElement aAnchorElement); michael@0: michael@0: /** michael@0: * Set the value of the "bgcolor" attribute on the document's element michael@0: * michael@0: * @param aColor The HTML color string, such as "#ffccff" or "yellow" michael@0: */ michael@0: void setBackgroundColor(in AString aColor); michael@0: michael@0: michael@0: /** michael@0: * Set an attribute on the document's element michael@0: * such as text, link, background colors michael@0: * michael@0: * 8/31/00 THIS ISN'T BEING USED? SHOULD WE DROP IT? michael@0: * michael@0: * @param aAttr The attribute to be set michael@0: * @param aValue The value of the attribute michael@0: */ michael@0: void setBodyAttribute(in AString aAttr, in AString aValue); michael@0: michael@0: /** michael@0: * Find all the nodes in the document which contain references michael@0: * to outside URIs (e.g. a href, img src, script src, etc.) michael@0: * The objects in the array will be type nsIURIRefObject. michael@0: * michael@0: * @return aNodeList the linked nodes found michael@0: */ michael@0: nsISupportsArray getLinkedObjects(); michael@0: michael@0: /** michael@0: * A boolean which is true is the HTMLEditor has been instantiated michael@0: * with CSS knowledge and if the CSS pref is currently checked michael@0: * michael@0: * @return true if CSS handled and enabled michael@0: */ michael@0: attribute boolean isCSSEnabled; michael@0: michael@0: /** michael@0: * Add listener for insertion override michael@0: * @param inFilter function which callers want called during insertion michael@0: */ michael@0: void addInsertionListener(in nsIContentFilter inFilter); michael@0: michael@0: /** michael@0: * Remove listener for insertion override michael@0: * @param inFilter function which callers do not want called during insertion michael@0: */ michael@0: void removeInsertionListener(in nsIContentFilter inFilter); michael@0: michael@0: /** michael@0: * Returns an anonymous nsDOMElement of type aTag, michael@0: * child of aParentNode. If aIsCreatedHidden is true, the class michael@0: * "hidden" is added to the created element. If aAnonClass is not michael@0: * the empty string, it becomes the value of the attribute "_moz_anonclass" michael@0: * @return a DOM Element michael@0: * @param aTag [IN] a string representing the desired type of michael@0: * the element to create michael@0: * @param aParentNode [IN] the parent node of the created anonymous michael@0: * element michael@0: * @param aAnonClass [IN] contents of the _moz_anonclass attribute michael@0: * @param aIsCreatedHidden [IN] a boolean specifying if the class "hidden" michael@0: * is to be added to the created anonymous michael@0: * element michael@0: */ michael@0: nsIDOMElement createAnonymousElement(in AString aTag, in nsIDOMNode aParentNode, michael@0: in AString aAnonClass, in boolean aIsCreatedHidden); michael@0: michael@0: /** michael@0: * returns the deepest container of the selection michael@0: * @return a DOM Element michael@0: */ michael@0: nsIDOMElement getSelectionContainer(); michael@0: michael@0: /** michael@0: * Checks if the anonymous nodes created by the HTML editor have to be michael@0: * refreshed or hidden depending on a possible new state of the selection michael@0: * @param aSelection [IN] a selection michael@0: */ michael@0: void checkSelectionStateForAnonymousButtons(in nsISelection aSelection); michael@0: michael@0: boolean isAnonymousElement(in nsIDOMElement aElement); michael@0: michael@0: /** michael@0: * A boolean indicating if a return key pressed in a paragraph creates michael@0: * another paragraph or just inserts a
at the caret michael@0: * michael@0: * @return true if CR in a paragraph creates a new paragraph michael@0: */ michael@0: attribute boolean returnInParagraphCreatesNewParagraph; michael@0: michael@0: /** michael@0: * Checks whether a BR node is visible to the user. michael@0: */ michael@0: boolean breakIsVisible(in nsIDOMNode aNode); michael@0: michael@0: /** michael@0: * Get an active editor's editing host in DOM window. If this editor isn't michael@0: * active in the DOM window, this returns NULL. michael@0: */ michael@0: [noscript, notxpcom] Element GetActiveEditingHost(); michael@0: }; michael@0: