Bug 443880. Comment-only change to IDL. r=me, b=443880
[wine-gecko.git] / editor / idl / nsIHTMLEditor.idl
blob6550065e63794f487ce7187fce2afa6cd0947327
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Daniel Glazman <glazman@netscape.com>
24 * Akkana Peck <akkana@netscape.com>
25 * Kathleen Brade <brade@netscape.com>
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
41 #include "nsISupports.idl"
42 #include "domstubs.idl"
44 interface nsIAtom;
45 interface nsISupportsArray;
46 interface nsISelection;
47 interface nsIContentFilter;
49 %{C++
50 #define NS_EDITOR_ELEMENT_NOT_FOUND \
51 NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_EDITOR, 1)
54 [scriptable, uuid(afc36593-5787-4420-93d9-b2c0ccbf0cad)]
56 interface nsIHTMLEditor : nsISupports
58 %{C++
59 typedef short EAlignment;
62 // used by GetAlignment()
63 const short eLeft = 0;
64 const short eCenter = 1;
65 const short eRight = 2;
66 const short eJustify = 3;
69 /* ------------ Inline property methods -------------- */
72 /**
73 * AddDefaultProperty() registers a default style property with the editor
75 * @param aProperty the property to set by default
76 * @param aAttribute the attribute of the property, if applicable.
77 * May be null.
78 * Example: aProperty="font", aAttribute="color"
79 * @param aValue if aAttribute is not null, the value of the attribute.
80 * Example: aProperty="font", aAttribute="color",
81 * aValue="0x00FFFF"
83 void addDefaultProperty(in nsIAtom aProperty,
84 in AString aAttribute,
85 in AString aValue);
87 /**
88 * RemoveDefaultProperty() unregisters a default style property with the editor
90 * @param aProperty the property to remove from defaults
91 * @param aAttribute the attribute of the property, if applicable.
92 * May be null.
93 * Example: aProperty="font", aAttribute="color"
94 * @param aValue if aAttribute is not null, the value of the attribute.
95 * Example: aProperty="font", aAttribute="color",
96 * aValue="0x00FFFF"
98 void removeDefaultProperty(in nsIAtom aProperty,
99 in AString aAttribute,
100 in AString aValue);
103 * RemoveAllDefaultProperties() unregisters all default style properties with the editor
106 void removeAllDefaultProperties();
109 * SetInlineProperty() sets the aggregate properties on the current selection
111 * @param aProperty the property to set on the selection
112 * @param aAttribute the attribute of the property, if applicable.
113 * May be null.
114 * Example: aProperty="font", aAttribute="color"
115 * @param aValue if aAttribute is not null, the value of the attribute.
116 * May be null.
117 * Example: aProperty="font", aAttribute="color",
118 * aValue="0x00FFFF"
120 void setCSSInlineProperty(in nsIAtom aProperty,
121 in AString aAttribute,
122 in AString aValue);
123 void setInlineProperty(in nsIAtom aProperty,
124 in AString aAttribute,
125 in AString aValue);
128 * getInlineProperty() gets aggregate properties of the current selection.
129 * All object in the current selection are scanned and their attributes are
130 * represented in a list of Property object.
132 * @param aProperty the property to get on the selection
133 * @param aAttribute the attribute of the property, if applicable.
134 * May be null.
135 * Example: aProperty="font", aAttribute="color"
136 * @param aValue if aAttribute is not null, the value of the attribute.
137 * May be null.
138 * Example: aProperty="font", aAttribute="color",
139 * aValue="0x00FFFF"
140 * @param aFirst [OUT] PR_TRUE if the first text node in the
141 * selection has the property
142 * @param aAny [OUT] PR_TRUE if any of the text nodes in the
143 * selection have the property
144 * @param aAll [OUT] PR_TRUE if all of the text nodes in the
145 * selection have the property
147 void getInlineProperty(in nsIAtom aProperty,
148 in AString aAttribute,
149 in AString aValue,
150 out boolean aFirst,
151 out boolean aAny,
152 out boolean aAll);
154 AString getInlinePropertyWithAttrValue(in nsIAtom aProperty,
155 in AString aAttribute,
156 in AString aValue,
157 out boolean aFirst,
158 out boolean aAny,
159 out boolean aAll);
162 * removeAllInlineProperties() deletes all the inline properties from all
163 * text in the current selection.
165 void removeAllInlineProperties();
169 * removeInlineProperty() deletes the properties from all text in the current
170 * selection. If aProperty is not set on the selection, nothing is done.
172 * @param aProperty the property to remove from the selection
173 * All atoms are for normal HTML tags (e.g.:
174 * nsIEditorProperty::font) except when you want to
175 * remove just links and not named anchors.
176 * For that, use nsIEditorProperty::href
177 * @param aAttribute the attribute of the property, if applicable.
178 * May be null.
179 * Example: aProperty=nsIEditorProptery::font,
180 * aAttribute="color"
181 * nsIEditProperty::allAttributes is special.
182 * It indicates that all content-based text properties
183 * are to be removed from the selection.
185 void removeInlineProperty(in nsIAtom aProperty, in AString aAttribute);
188 * Increase font size for text in selection by 1 HTML unit
189 * All existing text is scanned for existing <FONT SIZE> attributes
190 * so they will be incremented instead of inserting new <FONT> tag
192 void increaseFontSize();
195 * Decrease font size for text in selection by 1 HTML unit
196 * All existing text is scanned for existing <FONT SIZE> attributes
197 * so they will be decreased instead of inserting new <FONT> tag
199 void decreaseFontSize();
201 /* ------------ Drag/Drop methods -------------- */
203 /**
204 * canDrag decides if a drag should be started
205 * (for example, based on the current selection and mousepoint).
207 boolean canDrag(in nsIDOMEvent aEvent);
209 /**
210 * doDrag transfers the relevant data (as appropriate)
211 * to a transferable so it can later be dropped.
213 void doDrag(in nsIDOMEvent aEvent);
215 /**
216 * insertFromDrop looks for a dragsession and inserts the
217 * relevant data in response to a drop.
219 void insertFromDrop(in nsIDOMEvent aEvent);
221 /* ------------ HTML content methods -------------- */
224 * Tests if a node is a BLOCK element according the the HTML 4.0 DTD.
225 * This does NOT consider CSS effect on display type
227 * @param aNode the node to test
229 boolean nodeIsBlock(in nsIDOMNode node);
232 * Insert some HTML source at the current location
234 * @param aInputString the string to be inserted
236 void insertHTML(in AString aInputString);
239 /**
240 * Paste the text in the OS clipboard at the cursor position, replacing
241 * the selected text (if any), but strip out any HTML styles and formatting
243 void pasteNoFormatting(in long aSelectionType);
245 /**
246 * Rebuild the entire document from source HTML
247 * Needed to be able to edit HEAD and other outside-of-BODY content
249 * @param aSourceString HTML source string of the entire new document
251 void rebuildDocumentFromSource(in AString aSourceString);
254 * Insert some HTML source, interpreting
255 * the string argument according to the given context.
257 * @param aInputString the string to be inserted
258 * @param aContextStr Context of insertion
259 * @param aInfoStr Related info to aInputString
260 * @param aFlavor Transferable flavor, can be ""
261 * @param aSourceDoc document where input was dragged from (may be null)
262 * @param aDestinationNode location for insertion (such as when dropped)
263 * @param aDestinationOffset used with aDestNode to determine insert location
264 * @param aDeleteSelection used with aDestNode during drag&drop
265 * @param aCollapseSelection used with aDestNode during drag&drop
267 void insertHTMLWithContext(in AString aInputString,
268 in AString aContextStr,
269 in AString aInfoStr,
270 in AString aFlavor,
271 in nsIDOMDocument aSourceDoc,
272 in nsIDOMNode aDestinationNode,
273 in long aDestinationOffset,
274 in boolean aDeleteSelection);
277 /**
278 * Insert an element, which may have child nodes, at the selection
279 * Used primarily to insert a new element for various insert element dialogs,
280 * but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
281 * be useful for other elements.
283 * @param aElement The element to insert
284 * @param aDeleteSelection Delete the selection before inserting
285 * If aDeleteSelection is PR_FALSE, then the element is inserted
286 * after the end of the selection for all element except
287 * Named Anchors, which insert before the selection
289 void insertElementAtSelection(in nsIDOMElement aElement,
290 in boolean aDeleteSelection);
292 /**
293 * Set the documents title.
295 void setDocumentTitle(in AString aTitle);
297 /**
298 * Set the BaseURL for the document to the current URL
299 * but only if the page doesn't have a <base> tag
300 * This should be done after the document URL has changed,
301 * such as after saving a file
302 * This is used as base for relativizing link and image urls
304 void updateBaseURL();
307 /* ------------ Selection manipulation -------------- */
308 /* Should these be moved to nsISelection? */
310 /**
311 * Set the selection at the suppled element
313 * @param aElement An element in the document
315 void selectElement(in nsIDOMElement aElement);
317 /**
318 * Create a collapsed selection just after aElement
320 * XXX could we parameterize SelectElement(before/select/after>?
322 * The selection is set to parent-of-aElement with an
323 * offset 1 greater than aElement's offset
324 * but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
325 * be useful for other elements.
327 * @param aElement An element in the document
329 void setCaretAfterElement(in nsIDOMElement aElement);
332 * SetParagraphFormat Insert a block paragraph tag around selection
333 * @param aParagraphFormat "p", "h1" to "h6", "address", "pre", or "blockquote"
335 void setParagraphFormat(in AString aParagraphFormat);
338 * getParagraphState returns what block tag paragraph format is in
339 * the selection.
340 * @param aMixed True if there is more than one format
341 * @return Name of block tag. "" is returned for none.
343 AString getParagraphState(out boolean aMixed);
345 /**
346 * getFontFaceState returns what font face is in the selection.
347 * @param aMixed True if there is more than one font face
348 * @return Name of face. Note: "tt" is returned for
349 * tt tag. "" is returned for none.
351 AString getFontFaceState(out boolean aMixed);
353 /**
354 * getFontColorState returns what font face is in the selection.
355 * @param aMixed True if there is more than one font color
356 * @return Color string. "" is returned for none.
358 AString getFontColorState(out boolean aMixed);
360 /**
361 * getFontColorState returns what font face is in the selection.
362 * @param aMixed True if there is more than one font color
363 * @return Color string. "" is returned for none.
365 AString getBackgroundColorState(out boolean aMixed);
367 /**
368 * getHighlightColorState returns what the highlight color of the selection.
369 * @param aMixed True if there is more than one font color
370 * @return Color string. "" is returned for none.
372 AString getHighlightColorState(out boolean aMixed);
374 /**
375 * getListState returns what list type is in the selection.
376 * @param aMixed True if there is more than one type of list, or
377 * if there is some list and non-list
378 * @param aOL The company that employs me. No, really, it's
379 * true if an "ol" list is selected.
380 * @param aUL true if an "ul" list is selected.
381 * @param aDL true if a "dl" list is selected.
383 void getListState(out boolean aMixed, out boolean aOL, out boolean aUL,
384 out boolean aDL);
386 /**
387 * getListItemState returns what list item type is in the selection.
388 * @param aMixed True if there is more than one type of list item, or
389 * if there is some list and non-list
390 * @param aLI true if "li" list items are selected.
391 * @param aDT true if "dt" list items are selected.
392 * @param aDD true if "dd" list items are selected.
394 void getListItemState(out boolean aMixed, out boolean aLI,
395 out boolean aDT, out boolean aDD);
397 /**
398 * getAlignment returns what alignment is in the selection.
399 * @param aMixed True if there is more than one type of list item, or
400 * if there is some list and non-list
401 * @param aAlign enum value for first encountered alignment
402 * (left/center/right)
404 void getAlignment(out boolean aMixed, out short aAlign);
407 * Document me!
410 void getIndentState(out boolean aCanIndent, out boolean aCanOutdent);
413 * Document me!
416 void makeOrChangeList(in AString aListType, in boolean entireList,
417 in AString aBulletType);
420 * Document me!
423 void removeList(in AString aListType);
426 * Document me!
429 void indent(in AString aIndent);
432 * Document me!
435 void align(in AString aAlign);
437 /**
438 * Return the input node or a parent matching the given aTagName,
439 * starting the search at the supplied node.
440 * An example of use is for testing if a node is in a table cell
441 * given a selection anchor node.
443 * @param aTagName The HTML tagname
444 * Special input values:
445 * Use "href" to get a link node
446 * (an "A" tag with the "href" attribute set)
447 * Use "anchor" or "namedanchor" to get a named anchor node
448 * (an "A" tag with the "name" attribute set)
449 * Use "list" to get an OL, UL, or DL list node
450 * Use "td" to get either a TD or TH cell node
452 * @param aNode The node in the document to start the search.
453 * If it is null, the anchor node of the current selection is used.
454 * @return NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
455 * (passes NS_SUCCEEDED macro)
457 nsIDOMElement getElementOrParentByTagName(in AString aTagName,
458 in nsIDOMNode aNode);
460 /**
461 * Return an element only if it is the only node selected,
462 * such as an image, horizontal rule, etc.
463 * The exception is a link, which is more like a text attribute:
464 * The Anchor tag is returned if the selection is within the textnode(s)
465 * that are children of the "A" node.
466 * This could be a collapsed selection, i.e., a caret
467 * within the link text.
469 * @param aTagName The HTML tagname or and empty string
470 * to get any element (but only if it is the only element selected)
471 * Special input values for Links and Named anchors:
472 * Use "href" to get a link node
473 * (an "A" tag with the "href" attribute set)
474 * Use "anchor" or "namedanchor" to get a named anchor node
475 * (an "A" tag with the "name" attribute set)
476 * @return NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
477 * (passes NS_SUCCEEDED macro)
479 nsIDOMElement getSelectedElement(in AString aTagName);
481 /**
482 * Output the contents of the <HEAD> section as text/HTML format
484 AString getHeadContentsAsHTML();
486 /**
487 * Replace all children of <HEAD> with string of HTML source
489 void replaceHeadContentsWithHTML(in AString aSourceToInsert);
491 /**
492 * Return a new element with default attribute values
494 * This does not rely on the selection, and is not sensitive to context.
496 * Used primarily to supply new element for various insert element dialogs
497 * (Image, Link, NamedAnchor, Table, and HorizontalRule
498 * are the only returned elements as of 7/25/99)
500 * @param aTagName The HTML tagname
501 * Special input values for Links and Named anchors:
502 * Use "href" to get a link node
503 * (an "A" tag with the "href" attribute set)
504 * Use "anchor" or "namedanchor" to get a named anchor node
505 * (an "A" tag with the "name" attribute set)
506 * @return The new element created.
508 nsIDOMElement createElementWithDefaults(in AString aTagName);
510 /**
511 * Insert an link element as the parent of the current selection
513 * @param aElement An "A" element with a non-empty "href" attribute
515 void insertLinkAroundSelection(in nsIDOMElement aAnchorElement);
517 /**
518 * Set the value of the "bgcolor" attribute on the document's <body> element
520 * @param aColor The HTML color string, such as "#ffccff" or "yellow"
522 void setBackgroundColor(in AString aColor);
525 /**
526 * Set an attribute on the document's <body> element
527 * such as text, link, background colors
529 * 8/31/00 THIS ISN'T BEING USED? SHOULD WE DROP IT?
531 * @param aAttr The attribute to be set
532 * @param aValue The value of the attribute
534 void setBodyAttribute(in AString aAttr, in AString aValue);
536 /**
537 * XXX Used to suppress spurious drag/drop events to workaround bug 50703
538 * Don't use this method! It will go away after first release!
540 void ignoreSpuriousDragEvent(in boolean aIgnoreSpuriousDragEvent);
543 * Find all the nodes in the document which contain references
544 * to outside URIs (e.g. a href, img src, script src, etc.)
545 * The objects in the array will be type nsIURIRefObject.
547 * @return aNodeList the linked nodes found
549 nsISupportsArray getLinkedObjects();
551 /**
552 * A boolean which is true is the HTMLEditor has been instantiated
553 * with CSS knowledge and if the CSS pref is currently checked
555 * @return true if CSS handled and enabled
557 attribute boolean isCSSEnabled;
560 * Add listener for insertion override
561 * @param inFilter function which callers want called during insertion
563 void addInsertionListener(in nsIContentFilter inFilter);
566 * Remove listener for insertion override
567 * @param inFilter function which callers do not want called during insertion
569 void removeInsertionListener(in nsIContentFilter inFilter);
572 * Returns an anonymous nsDOMElement of type aTag,
573 * child of aParentNode. If aIsCreatedHidden is true, the class
574 * "hidden" is added to the created element. If aAnonClass is not
575 * the empty string, it becomes the value of the attribute "_moz_anonclass"
576 * @return a DOM Element
577 * @param aTag [IN] a string representing the desired type of
578 * the element to create
579 * @param aParentNode [IN] the parent node of the created anonymous
580 * element
581 * @param aAnonClass [IN] contents of the _moz_anonclass attribute
582 * @param aIsCreatedHidden [IN] a boolean specifying if the class "hidden"
583 * is to be added to the created anonymous
584 * element
586 nsIDOMElement createAnonymousElement(in AString aTag, in nsIDOMNode aParentNode,
587 in AString aAnonClass, in boolean aIsCreatedHidden);
590 * returns the deepest container of the selection
591 * @return a DOM Element
593 nsIDOMElement getSelectionContainer();
596 * Checks if the anonymous nodes created by the HTML editor have to be
597 * refreshed or hidden depending on a possible new state of the selection
598 * @param aSelection [IN] a selection
600 void checkSelectionStateForAnonymousButtons(in nsISelection aSelection);
602 boolean isAnonymousElement(in nsIDOMElement aElement);
605 * A boolean indicating if a return key pressed in a paragraph creates
606 * another paragraph or just inserts a <br> at the caret
608 * @return true if CR in a paragraph creates a new paragraph
610 attribute boolean returnInParagraphCreatesNewParagraph;