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"
16 [scriptable
, builtinclass
, uuid(87ee993e
-985f
-4a43
-a974
-0d9512da2fb0
)]
17 interface nsIHTMLEditor
: nsISupports
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 -------------- */
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.
38 * Example: aProperty="font", aAttribute="color"
39 * @param aValue if aAttribute is not null, the value of the attribute.
41 * Example: aProperty="font", aAttribute="color",
45 void setInlineProperty
(in AString aProperty
,
46 in AString aAttribute
,
50 * getInlineProperty() gets aggregate properties of the current selection.
51 * All object in the current selection are scanned and their attributes are
52 * 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.
57 * Example: aProperty="font", aAttribute="color"
58 * @param aValue if aAttribute is not null, the value of the attribute.
60 * Example: aProperty="font", aAttribute="color",
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 void getInlineProperty
(in AString aProperty
,
70 in AString aAttribute
,
76 AString getInlinePropertyWithAttrValue
(in AString aProperty
,
77 in AString aAttribute
,
84 * removeAllInlineProperties() deletes all the inline properties from all
85 * text in the current selection.
88 void removeAllInlineProperties
();
92 * removeInlineProperty() removes a property which changes inline style of
93 * text. E.g., bold, italic, super and sub.
95 * @param aProperty Tag name whcih represents the inline style you want to
96 * remove. E.g., "strong", "b", etc.
97 * If "href", <a> element which has href attribute will be
99 * If "name", <a> element which has non-empty name
100 * attribute will be removed.
101 * @param aAttribute If aProperty is "font", aAttribute should be "face",
102 * "size", "color" or "bgcolor".
105 void removeInlineProperty
(in AString aProperty
, in AString aAttribute
);
108 * Increase font size for text in selection by 1 HTML unit
109 * All existing text is scanned for existing <FONT SIZE> attributes
110 * so they will be incremented instead of inserting new <FONT> tag
113 void increaseFontSize
();
116 * Decrease font size for text in selection by 1 HTML unit
117 * All existing text is scanned for existing <FONT SIZE> attributes
118 * so they will be decreased instead of inserting new <FONT> tag
121 void decreaseFontSize
();
123 /* ------------ HTML content methods -------------- */
126 * Tests if a node is a BLOCK element according the the HTML 4.0 DTD.
127 * This does NOT consider CSS effect on display type
129 * @param aNode the node to test
131 boolean nodeIsBlock
(in Node node
);
134 * Insert some HTML source at the current location
136 * @param aInputString the string to be inserted
139 void insertHTML
(in AString aInputString
);
143 * Paste the text in the OS clipboard at the cursor position, replacing
144 * the selected text (if any), but strip out any HTML styles and formatting
147 void pasteNoFormatting
(in long aSelectionType
);
150 * Rebuild the entire document from source HTML
151 * Needed to be able to edit HEAD and other outside-of-BODY content
153 * @param aSourceString HTML source string of the entire new document
156 void rebuildDocumentFromSource
(in AString aSourceString
);
159 * Insert an element, which may have child nodes, at the selection
160 * Used primarily to insert a new element for various insert element dialogs,
161 * but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
162 * be useful for other elements.
164 * @param aElement The element to insert
165 * @param aDeleteSelection Delete the selection before inserting
166 * If aDeleteSelection is PR_FALSE, then the element is inserted
167 * after the end of the selection for all element except
168 * Named Anchors, which insert before the selection
171 void insertElementAtSelection
(in Element aElement
,
172 in boolean aDeleteSelection
);
175 * Set the BaseURL for the document to the current URL
176 * but only if the page doesn't have a <base> tag
177 * This should be done after the document URL has changed,
178 * such as after saving a file
179 * This is used as base for relativizing link and image urls
181 void updateBaseURL
();
184 /* ------------ Selection manipulation -------------- */
185 /* Should these be moved to Selection? */
188 * Set the selection at the suppled element
190 * @param aElement An element in the document
193 void selectElement
(in Element aElement
);
196 * Create a collapsed selection just after aElement
198 * XXX could we parameterize SelectElement(before/select/after>?
200 * The selection is set to parent-of-aElement with an
201 * offset 1 greater than aElement's offset
202 * but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
203 * be useful for other elements.
205 * @param aElement An element in the document
207 void setCaretAfterElement
(in Element aElement
);
210 * SetParagraphFormat Insert a block paragraph tag around selection
211 * @param aParagraphFormat "p", "h1" to "h6", "address", "pre", or "blockquote"
214 void setParagraphFormat
(in AString aParagraphFormat
);
217 * getParagraphState returns what block tag paragraph format is in
219 * @param aMixed True if there is more than one format
220 * @return Name of block tag. "" is returned for none.
222 AString getParagraphState
(out boolean aMixed
);
225 * getFontFaceState returns what font face is in the selection.
226 * @param aMixed True if there is more than one font face
227 * @return Name of face. Note: "tt" is returned for
228 * tt tag. "" is returned for none.
230 AString getFontFaceState
(out boolean aMixed
);
233 * getBackgroundColorState returns what the background color of the selection.
234 * @param aMixed True if there is more than one font color
235 * @return Color string. "" is returned for none.
237 AString getBackgroundColorState
(out boolean aMixed
);
240 * getHighlightColorState returns what the highlight color of the selection.
241 * @param aMixed True if there is more than one font color
242 * @return Color string. "" is returned for none.
244 AString getHighlightColorState
(out boolean aMixed
);
247 * getListState returns what list type is in the selection.
248 * @param aMixed True if there is more than one type of list, or
249 * if there is some list and non-list
250 * @param aOL The company that employs me. No, really, it's
251 * true if an "ol" list is selected.
252 * @param aUL true if an "ul" list is selected.
253 * @param aDL true if a "dl" list is selected.
255 void getListState
(out boolean aMixed
, out boolean aOL
, out boolean aUL
,
259 * getListItemState returns what list item type is in the selection.
260 * @param aMixed True if there is more than one type of list item, or
261 * if there is some list and non-list
262 * XXX This ignores `<li>` element selected state.
263 * For example, even if `<li>` and `<dt>` are selected,
264 * this is set to false.
265 * @param aLI true if "li" list items are selected.
266 * @param aDT true if "dt" list items are selected.
267 * @param aDD true if "dd" list items are selected.
269 void getListItemState
(out boolean aMixed
, out boolean aLI
,
270 out boolean aDT
, out boolean aDD
);
273 * getAlignment returns what alignment is in the selection.
274 * @param aMixed Always returns false.
275 * @param aAlign enum value for first encountered alignment
276 * (left/center/right)
278 void getAlignment
(out boolean aMixed
, out short aAlign
);
285 void makeOrChangeList
(in AString aListType
, in boolean entireList
,
286 in AString aBulletType
);
289 * removeList removes list items (<li>, <dd>, and <dt>) and list structures
290 * (<ul>, <ol>, and <dl>).
292 * @param aListType Unused.
295 void removeList
(in AString aListType
);
302 void indent
(in AString aIndent
);
309 void align
(in AString aAlign
);
312 * GetElementOrParentByTagName() looks for an element node whose name matches
313 * aTagName from aNode or anchor node of Selection to <body> element.
315 * @param aTagName The tag name which you want to look for.
316 * Must not be empty string.
317 * If "list", the result may be <ul>, <ol> or <dl>
319 * If "td", the result may be <td> or <th>.
320 * If "href", the result may be <a> element
321 * which has "href" attribute with non-empty value.
322 * If "anchor", the result may be <a> which has
323 * "name" attribute with non-empty value.
324 * @param aNode If non-null, this starts to look for the result
325 * from it. Otherwise, i.e., null, starts from
326 * anchor node of Selection.
327 * @return If an element which matches aTagName, returns
328 * an Element. Otherwise, nullptr.
330 Element getElementOrParentByTagName
(in AString aTagName
,
334 * getSelectedElement() returns a "selected" element node. "selected" means:
335 * - there is only one selection range
336 * - the range starts from an element node or in an element
337 * - the range ends at immediately after same element
338 * - and the range does not include any other element nodes.
339 * Additionally, only when aTagName is "href", this thinks that an <a>
340 * element which has non-empty "href" attribute includes the range, the
341 * <a> element is selected.
343 * @param aTagName Case-insensitive element name.
344 * If empty string, this returns any element node or null.
345 * If "href", this returns an <a> element which has
346 * non-empty "href" attribute or null.
347 * If "anchor", this returns an <a> element which has
348 * non-empty "name" attribute or null.
349 * Otherwise, returns an element node whose name is
350 * same as aTagName or null.
351 * @return A "selected" element.
353 nsISupports getSelectedElement
(in AString aTagName
);
356 * Return a new element with default attribute values
358 * This does not rely on the selection, and is not sensitive to context.
360 * Used primarily to supply new element for various insert element dialogs
361 * (Image, Link, NamedAnchor, Table, and HorizontalRule
362 * are the only returned elements as of 7/25/99)
364 * @param aTagName The HTML tagname
365 * Special input values for Links and Named anchors:
366 * Use "href" to get a link node
367 * (an "A" tag with the "href" attribute set)
368 * Use "anchor" or "namedanchor" to get a named anchor node
369 * (an "A" tag with the "name" attribute set)
370 * @return The new element created.
373 Element createElementWithDefaults
(in AString aTagName
);
376 * Insert an link element as the parent of the current selection
378 * @param aElement An "A" element with a non-empty "href" attribute
381 void insertLinkAroundSelection
(in Element aAnchorElement
);
384 * Set the value of the "bgcolor" attribute on the document's <body> element
386 * @param aColor The HTML color string, such as "#ffccff" or "yellow"
389 void setBackgroundColor
(in AString aColor
);
392 * A boolean which is true is the HTMLEditor has been instantiated
393 * with CSS knowledge and if the CSS pref is currently checked
395 * @return true if CSS handled and enabled
397 attribute
boolean isCSSEnabled
;
400 * checkSelectionStateForAnonymousButtons() may refresh editing UI such as
401 * resizers, inline-table-editing UI, absolute positioning UI for current
402 * Selection and focus state. When this method shows or hides UI, the
403 * editor (and/or its document/window) could be broken by mutation observers.
404 * FYI: Current user in script is only BlueGriffon.
407 void checkSelectionStateForAnonymousButtons
();
409 boolean isAnonymousElement
(in Element aElement
);
412 * A boolean indicating if a return key pressed in a paragraph creates
413 * another paragraph or just inserts a <br> at the caret
415 * @return true if CR in a paragraph creates a new paragraph
417 attribute
boolean returnInParagraphCreatesNewParagraph
;