Backed out changeset 5c8bf24bb247 (bug 1923942) for causing generate failures. CLOSED...
[gecko.git] / editor / nsIHTMLEditor.idl
blobb2e3bf54d41bff3c828baeec7b756122c76a6980
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsISupports.idl"
7 #include "domstubs.idl"
9 interface nsIContent;
11 webidl Document;
12 webidl Element;
13 webidl Node;
14 webidl Selection;
16 [scriptable, builtinclass, uuid(87ee993e-985f-4a43-a974-0d9512da2fb0)]
17 interface nsIHTMLEditor : nsISupports
19 %{C++
20 typedef short EAlignment;
23 // used by GetAlignment()
24 const short eLeft = 0;
25 const short eCenter = 1;
26 const short eRight = 2;
27 const short eJustify = 3;
30 /* ------------ Inline property methods -------------- */
32 /**
33 * SetInlineProperty() sets the aggregate properties on the current selection
35 * @param aProperty the property to set on the selection
36 * @param aAttribute the attribute of the property, if applicable.
37 * May be null.
38 * Example: aProperty="font", aAttribute="color"
39 * @param aValue if aAttribute is not null, the value of the attribute.
40 * May be null.
41 * Example: aProperty="font", aAttribute="color",
42 * aValue="0x00FFFF"
44 [can_run_script]
45 void setInlineProperty(in AString aProperty,
46 in AString aAttribute,
47 in AString aValue);
49 /**
50 * getInlinePropertyWithAttrValue() gets aggregate properties of the current
51 * selection. All object in the current selection are scanned and their
52 * attributes are represented in a list of Property object.
54 * @param aProperty the property to get on the selection
55 * @param aAttribute the attribute of the property, if applicable.
56 * May be null.
57 * Example: aProperty="font", aAttribute="color"
58 * @param aValue if aAttribute is not null, the value of the attribute.
59 * May be null.
60 * Example: aProperty="font", aAttribute="color",
61 * aValue="0x00FFFF"
62 * @param aFirst [OUT] PR_TRUE if the first text node in the
63 * selection has the property
64 * @param aAny [OUT] PR_TRUE if any of the text nodes in the
65 * selection have the property
66 * @param aAll [OUT] PR_TRUE if all of the text nodes in the
67 * selection have the property
69 [can_run_script]
70 AString getInlinePropertyWithAttrValue(in AString aProperty,
71 in AString aAttribute,
72 in AString aValue,
73 out boolean aFirst,
74 out boolean aAny,
75 out boolean aAll);
77 /**
78 * removeInlineProperty() removes a property which changes inline style of
79 * text. E.g., bold, italic, super and sub.
81 * @param aProperty Tag name whcih represents the inline style you want to
82 * remove. E.g., "strong", "b", etc.
83 * If "href", <a> element which has href attribute will be
84 * removed.
85 * If "name", <a> element which has non-empty name
86 * attribute will be removed.
87 * @param aAttribute If aProperty is "font", aAttribute should be "face",
88 * "size", "color" or "bgcolor".
90 [can_run_script]
91 void removeInlineProperty(in AString aProperty, in AString aAttribute);
93 /* ------------ HTML content methods -------------- */
95 /**
96 * Tests if a node is a BLOCK element. This checks whether the computed
97 * style of the element is block or not.
99 * @param aNode the node to test
101 [can_run_script]
102 boolean nodeIsBlock(in Node aNode);
105 * Insert some HTML source at the current location
107 * @param aInputString the string to be inserted
109 [can_run_script]
110 void insertHTML(in AString aInputString);
113 * Rebuild the entire document from source HTML
114 * Needed to be able to edit HEAD and other outside-of-BODY content
116 * @param aSourceString HTML source string of the entire new document
118 [can_run_script]
119 void rebuildDocumentFromSource(in AString aSourceString);
122 * Insert an element, which may have child nodes, at the selection
123 * Used primarily to insert a new element for various insert element dialogs,
124 * but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
125 * be useful for other elements.
127 * @param aElement The element to insert
128 * @param aDeleteSelection Delete the selection before inserting
129 * If aDeleteSelection is PR_FALSE, then the element is inserted
130 * after the end of the selection for all element except
131 * Named Anchors, which insert before the selection
133 [can_run_script]
134 void insertElementAtSelection(in Element aElement,
135 in boolean aDeleteSelection);
138 * Set the BaseURL for the document to the current URL
139 * but only if the page doesn't have a <base> tag
140 * This should be done after the document URL has changed,
141 * such as after saving a file
142 * This is used as base for relativizing link and image urls
144 void updateBaseURL();
147 /* ------------ Selection manipulation -------------- */
148 /* Should these be moved to Selection? */
151 * Set the selection at the suppled element
153 * @param aElement An element in the document
155 [can_run_script]
156 void selectElement(in Element aElement);
159 * getParagraphState returns what block tag paragraph format is in
160 * the selection.
161 * @param aMixed True if there is more than one format
162 * @return Name of block tag. "" is returned for none.
164 AString getParagraphState(out boolean aMixed);
167 * getFontFaceState returns what font face is in the selection.
168 * @param aMixed True if there is more than one font face
169 * @return Name of face. Note: "tt" is returned for
170 * tt tag. "" is returned for none.
172 [can_run_script]
173 AString getFontFaceState(out boolean aMixed);
176 * getHighlightColorState returns what the highlight color of the selection.
177 * @param aMixed True if there is more than one font color
178 * @return Color string. "" is returned for none.
180 [can_run_script]
181 AString getHighlightColorState(out boolean aMixed);
184 * getListState returns what list type is in the selection.
185 * @param aMixed True if there is more than one type of list, or
186 * if there is some list and non-list
187 * @param aOL The company that employs me. No, really, it's
188 * true if an "ol" list is selected.
189 * @param aUL true if an "ul" list is selected.
190 * @param aDL true if a "dl" list is selected.
192 void getListState(out boolean aMixed, out boolean aOL, out boolean aUL,
193 out boolean aDL);
196 * getListItemState returns what list item type is in the selection.
197 * @param aMixed True if there is more than one type of list item, or
198 * if there is some list and non-list
199 * XXX This ignores `<li>` element selected state.
200 * For example, even if `<li>` and `<dt>` are selected,
201 * this is set to false.
202 * @param aLI true if "li" list items are selected.
203 * @param aDT true if "dt" list items are selected.
204 * @param aDD true if "dd" list items are selected.
206 void getListItemState(out boolean aMixed, out boolean aLI,
207 out boolean aDT, out boolean aDD);
210 * getAlignment returns what alignment is in the selection.
211 * @param aMixed Always returns false.
212 * @param aAlign enum value for first encountered alignment
213 * (left/center/right)
215 [can_run_script]
216 void getAlignment(out boolean aMixed, out short aAlign);
219 * Document me!
222 [can_run_script]
223 void makeOrChangeList(in AString aListType, in boolean entireList,
224 in AString aBulletType);
227 * removeList removes list items (<li>, <dd>, and <dt>) and list structures
228 * (<ul>, <ol>, and <dl>).
230 * @param aListType Unused.
232 [can_run_script]
233 void removeList(in AString aListType);
236 * GetElementOrParentByTagName() returns an inclusive ancestor element whose
237 * name matches aTagName from aNode or anchor node of Selection to <body>
238 * element or null if there is no element matching with aTagName.
240 * @param aTagName The tag name which you want to look for.
241 * Must not be empty string.
242 * If "list", the result may be <ul>, <ol> or <dl>
243 * element.
244 * If "td", the result may be <td> or <th>.
245 * If "href", the result may be <a> element
246 * which has "href" attribute with non-empty value.
247 * If "anchor", the result may be <a> which has
248 * "name" attribute with non-empty value.
249 * @param aNode If non-null, this starts to look for the result
250 * from it. Otherwise, i.e., null, starts from
251 * anchor node of Selection.
252 * @return If an element which matches aTagName, returns
253 * an Element. Otherwise, nullptr.
255 Element getElementOrParentByTagName(in AString aTagName,
256 in Node aNode);
259 * getSelectedElement() returns a "selected" element node. "selected" means:
260 * - there is only one selection range
261 * - the range starts from an element node or in an element
262 * - the range ends at immediately after same element
263 * - and the range does not include any other element nodes.
264 * Additionally, only when aTagName is "href", this thinks that an <a>
265 * element which has non-empty "href" attribute includes the range, the
266 * <a> element is selected.
268 * @param aTagName Case-insensitive element name.
269 * If empty string, this returns any element node or null.
270 * If "href", this returns an <a> element which has
271 * non-empty "href" attribute or null.
272 * If "anchor", this returns an <a> element which has
273 * non-empty "name" attribute or null.
274 * Otherwise, returns an element node whose name is
275 * same as aTagName or null.
276 * @return A "selected" element.
278 nsISupports getSelectedElement(in AString aTagName);
281 * Return a new element with default attribute values
283 * This does not rely on the selection, and is not sensitive to context.
285 * Used primarily to supply new element for various insert element dialogs
286 * (Image, Link, NamedAnchor, Table, and HorizontalRule
287 * are the only returned elements as of 7/25/99)
289 * @param aTagName The HTML tagname
290 * Special input values for Links and Named anchors:
291 * Use "href" to get a link node
292 * (an "A" tag with the "href" attribute set)
293 * Use "anchor" or "namedanchor" to get a named anchor node
294 * (an "A" tag with the "name" attribute set)
295 * @return The new element created.
297 [can_run_script]
298 Element createElementWithDefaults(in AString aTagName);
301 * Insert an link element as the parent of the current selection
303 * @param aElement An "A" element with a non-empty "href" attribute
305 [can_run_script]
306 void insertLinkAroundSelection(in Element aAnchorElement);
309 * Set the value of the "bgcolor" attribute on the document's <body> element
311 * @param aColor The HTML color string, such as "#ffccff" or "yellow"
313 [can_run_script]
314 void setBackgroundColor(in AString aColor);
317 * A boolean which is true is the HTMLEditor has been instantiated
318 * with CSS knowledge and if the CSS pref is currently checked
320 * @return true if CSS handled and enabled
322 [setter_can_run_script] attribute boolean isCSSEnabled;
325 * checkSelectionStateForAnonymousButtons() may refresh editing UI such as
326 * resizers, inline-table-editing UI, absolute positioning UI for current
327 * Selection and focus state. When this method shows or hides UI, the
328 * editor (and/or its document/window) could be broken by mutation observers.
329 * FYI: Current user in script is only BlueGriffon.
331 [can_run_script]
332 void checkSelectionStateForAnonymousButtons();
334 boolean isAnonymousElement(in Element aElement);
337 * A boolean indicating if a return key pressed in a paragraph creates
338 * another paragraph or just inserts a <br> at the caret
340 * @return true if CR in a paragraph creates a new paragraph
342 attribute boolean returnInParagraphCreatesNewParagraph;