Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsISupports.idl" |
michael@0 | 7 | #include "domstubs.idl" |
michael@0 | 8 | |
michael@0 | 9 | interface nsIAtom; |
michael@0 | 10 | interface nsIContent; |
michael@0 | 11 | interface nsISupportsArray; |
michael@0 | 12 | interface nsISelection; |
michael@0 | 13 | interface nsIContentFilter; |
michael@0 | 14 | |
michael@0 | 15 | %{C++ |
michael@0 | 16 | namespace mozilla { |
michael@0 | 17 | namespace dom { |
michael@0 | 18 | class Element; |
michael@0 | 19 | } |
michael@0 | 20 | } |
michael@0 | 21 | %} |
michael@0 | 22 | |
michael@0 | 23 | [ptr] native Element (mozilla::dom::Element); |
michael@0 | 24 | |
michael@0 | 25 | [scriptable, uuid(833f30de-94c7-4630-a852-2300ef329d7b)] |
michael@0 | 26 | |
michael@0 | 27 | interface nsIHTMLEditor : nsISupports |
michael@0 | 28 | { |
michael@0 | 29 | %{C++ |
michael@0 | 30 | typedef short EAlignment; |
michael@0 | 31 | %} |
michael@0 | 32 | |
michael@0 | 33 | // used by GetAlignment() |
michael@0 | 34 | const short eLeft = 0; |
michael@0 | 35 | const short eCenter = 1; |
michael@0 | 36 | const short eRight = 2; |
michael@0 | 37 | const short eJustify = 3; |
michael@0 | 38 | |
michael@0 | 39 | |
michael@0 | 40 | /* ------------ Inline property methods -------------- */ |
michael@0 | 41 | |
michael@0 | 42 | |
michael@0 | 43 | /** |
michael@0 | 44 | * AddDefaultProperty() registers a default style property with the editor |
michael@0 | 45 | * |
michael@0 | 46 | * @param aProperty the property to set by default |
michael@0 | 47 | * @param aAttribute the attribute of the property, if applicable. |
michael@0 | 48 | * May be null. |
michael@0 | 49 | * Example: aProperty="font", aAttribute="color" |
michael@0 | 50 | * @param aValue if aAttribute is not null, the value of the attribute. |
michael@0 | 51 | * Example: aProperty="font", aAttribute="color", |
michael@0 | 52 | * aValue="0x00FFFF" |
michael@0 | 53 | */ |
michael@0 | 54 | void addDefaultProperty(in nsIAtom aProperty, |
michael@0 | 55 | in AString aAttribute, |
michael@0 | 56 | in AString aValue); |
michael@0 | 57 | |
michael@0 | 58 | /** |
michael@0 | 59 | * RemoveDefaultProperty() unregisters a default style property with the editor |
michael@0 | 60 | * |
michael@0 | 61 | * @param aProperty the property to remove from defaults |
michael@0 | 62 | * @param aAttribute the attribute of the property, if applicable. |
michael@0 | 63 | * May be null. |
michael@0 | 64 | * Example: aProperty="font", aAttribute="color" |
michael@0 | 65 | * @param aValue if aAttribute is not null, the value of the attribute. |
michael@0 | 66 | * Example: aProperty="font", aAttribute="color", |
michael@0 | 67 | * aValue="0x00FFFF" |
michael@0 | 68 | */ |
michael@0 | 69 | void removeDefaultProperty(in nsIAtom aProperty, |
michael@0 | 70 | in AString aAttribute, |
michael@0 | 71 | in AString aValue); |
michael@0 | 72 | |
michael@0 | 73 | /** |
michael@0 | 74 | * RemoveAllDefaultProperties() unregisters all default style properties with the editor |
michael@0 | 75 | * |
michael@0 | 76 | */ |
michael@0 | 77 | void removeAllDefaultProperties(); |
michael@0 | 78 | |
michael@0 | 79 | /** |
michael@0 | 80 | * SetInlineProperty() sets the aggregate properties on the current selection |
michael@0 | 81 | * |
michael@0 | 82 | * @param aProperty the property to set on the selection |
michael@0 | 83 | * @param aAttribute the attribute of the property, if applicable. |
michael@0 | 84 | * May be null. |
michael@0 | 85 | * Example: aProperty="font", aAttribute="color" |
michael@0 | 86 | * @param aValue if aAttribute is not null, the value of the attribute. |
michael@0 | 87 | * May be null. |
michael@0 | 88 | * Example: aProperty="font", aAttribute="color", |
michael@0 | 89 | * aValue="0x00FFFF" |
michael@0 | 90 | */ |
michael@0 | 91 | void setInlineProperty(in nsIAtom aProperty, |
michael@0 | 92 | in AString aAttribute, |
michael@0 | 93 | in AString aValue); |
michael@0 | 94 | |
michael@0 | 95 | /** |
michael@0 | 96 | * getInlineProperty() gets aggregate properties of the current selection. |
michael@0 | 97 | * All object in the current selection are scanned and their attributes are |
michael@0 | 98 | * represented in a list of Property object. |
michael@0 | 99 | * |
michael@0 | 100 | * @param aProperty the property to get on the selection |
michael@0 | 101 | * @param aAttribute the attribute of the property, if applicable. |
michael@0 | 102 | * May be null. |
michael@0 | 103 | * Example: aProperty="font", aAttribute="color" |
michael@0 | 104 | * @param aValue if aAttribute is not null, the value of the attribute. |
michael@0 | 105 | * May be null. |
michael@0 | 106 | * Example: aProperty="font", aAttribute="color", |
michael@0 | 107 | * aValue="0x00FFFF" |
michael@0 | 108 | * @param aFirst [OUT] PR_TRUE if the first text node in the |
michael@0 | 109 | * selection has the property |
michael@0 | 110 | * @param aAny [OUT] PR_TRUE if any of the text nodes in the |
michael@0 | 111 | * selection have the property |
michael@0 | 112 | * @param aAll [OUT] PR_TRUE if all of the text nodes in the |
michael@0 | 113 | * selection have the property |
michael@0 | 114 | */ |
michael@0 | 115 | void getInlineProperty(in nsIAtom aProperty, |
michael@0 | 116 | in AString aAttribute, |
michael@0 | 117 | in AString aValue, |
michael@0 | 118 | out boolean aFirst, |
michael@0 | 119 | out boolean aAny, |
michael@0 | 120 | out boolean aAll); |
michael@0 | 121 | |
michael@0 | 122 | AString getInlinePropertyWithAttrValue(in nsIAtom aProperty, |
michael@0 | 123 | in AString aAttribute, |
michael@0 | 124 | in AString aValue, |
michael@0 | 125 | out boolean aFirst, |
michael@0 | 126 | out boolean aAny, |
michael@0 | 127 | out boolean aAll); |
michael@0 | 128 | |
michael@0 | 129 | /** |
michael@0 | 130 | * removeAllInlineProperties() deletes all the inline properties from all |
michael@0 | 131 | * text in the current selection. |
michael@0 | 132 | */ |
michael@0 | 133 | void removeAllInlineProperties(); |
michael@0 | 134 | |
michael@0 | 135 | |
michael@0 | 136 | /** |
michael@0 | 137 | * removeInlineProperty() deletes the properties from all text in the current |
michael@0 | 138 | * selection. If aProperty is not set on the selection, nothing is done. |
michael@0 | 139 | * |
michael@0 | 140 | * @param aProperty the property to remove from the selection |
michael@0 | 141 | * All atoms are for normal HTML tags (e.g.: |
michael@0 | 142 | * nsIEditorProperty::font) except when you want to |
michael@0 | 143 | * remove just links and not named anchors. |
michael@0 | 144 | * For that, use nsIEditorProperty::href |
michael@0 | 145 | * @param aAttribute the attribute of the property, if applicable. |
michael@0 | 146 | * May be null. |
michael@0 | 147 | * Example: aProperty=nsIEditorProptery::font, |
michael@0 | 148 | * aAttribute="color" |
michael@0 | 149 | * nsIEditProperty::allAttributes is special. |
michael@0 | 150 | * It indicates that all content-based text properties |
michael@0 | 151 | * are to be removed from the selection. |
michael@0 | 152 | */ |
michael@0 | 153 | void removeInlineProperty(in nsIAtom aProperty, in AString aAttribute); |
michael@0 | 154 | |
michael@0 | 155 | /** |
michael@0 | 156 | * Increase font size for text in selection by 1 HTML unit |
michael@0 | 157 | * All existing text is scanned for existing <FONT SIZE> attributes |
michael@0 | 158 | * so they will be incremented instead of inserting new <FONT> tag |
michael@0 | 159 | */ |
michael@0 | 160 | void increaseFontSize(); |
michael@0 | 161 | |
michael@0 | 162 | /** |
michael@0 | 163 | * Decrease font size for text in selection by 1 HTML unit |
michael@0 | 164 | * All existing text is scanned for existing <FONT SIZE> attributes |
michael@0 | 165 | * so they will be decreased instead of inserting new <FONT> tag |
michael@0 | 166 | */ |
michael@0 | 167 | void decreaseFontSize(); |
michael@0 | 168 | |
michael@0 | 169 | /* ------------ HTML content methods -------------- */ |
michael@0 | 170 | |
michael@0 | 171 | /** |
michael@0 | 172 | * Tests if a node is a BLOCK element according the the HTML 4.0 DTD. |
michael@0 | 173 | * This does NOT consider CSS effect on display type |
michael@0 | 174 | * |
michael@0 | 175 | * @param aNode the node to test |
michael@0 | 176 | */ |
michael@0 | 177 | boolean nodeIsBlock(in nsIDOMNode node); |
michael@0 | 178 | |
michael@0 | 179 | /** |
michael@0 | 180 | * Insert some HTML source at the current location |
michael@0 | 181 | * |
michael@0 | 182 | * @param aInputString the string to be inserted |
michael@0 | 183 | */ |
michael@0 | 184 | void insertHTML(in AString aInputString); |
michael@0 | 185 | |
michael@0 | 186 | |
michael@0 | 187 | /** |
michael@0 | 188 | * Paste the text in the OS clipboard at the cursor position, replacing |
michael@0 | 189 | * the selected text (if any), but strip out any HTML styles and formatting |
michael@0 | 190 | */ |
michael@0 | 191 | void pasteNoFormatting(in long aSelectionType); |
michael@0 | 192 | |
michael@0 | 193 | /** |
michael@0 | 194 | * Rebuild the entire document from source HTML |
michael@0 | 195 | * Needed to be able to edit HEAD and other outside-of-BODY content |
michael@0 | 196 | * |
michael@0 | 197 | * @param aSourceString HTML source string of the entire new document |
michael@0 | 198 | */ |
michael@0 | 199 | void rebuildDocumentFromSource(in AString aSourceString); |
michael@0 | 200 | |
michael@0 | 201 | /** |
michael@0 | 202 | * Insert some HTML source, interpreting |
michael@0 | 203 | * the string argument according to the given context. |
michael@0 | 204 | * |
michael@0 | 205 | * @param aInputString the string to be inserted |
michael@0 | 206 | * @param aContextStr Context of insertion |
michael@0 | 207 | * @param aInfoStr Related info to aInputString |
michael@0 | 208 | * @param aFlavor Transferable flavor, can be "" |
michael@0 | 209 | * @param aSourceDoc document where input was dragged from (may be null) |
michael@0 | 210 | * @param aDestinationNode location for insertion (such as when dropped) |
michael@0 | 211 | * @param aDestinationOffset used with aDestNode to determine insert location |
michael@0 | 212 | * @param aDeleteSelection used with aDestNode during drag&drop |
michael@0 | 213 | * @param aCollapseSelection used with aDestNode during drag&drop |
michael@0 | 214 | */ |
michael@0 | 215 | void insertHTMLWithContext(in AString aInputString, |
michael@0 | 216 | in AString aContextStr, |
michael@0 | 217 | in AString aInfoStr, |
michael@0 | 218 | in AString aFlavor, |
michael@0 | 219 | in nsIDOMDocument aSourceDoc, |
michael@0 | 220 | in nsIDOMNode aDestinationNode, |
michael@0 | 221 | in long aDestinationOffset, |
michael@0 | 222 | in boolean aDeleteSelection); |
michael@0 | 223 | |
michael@0 | 224 | |
michael@0 | 225 | /** |
michael@0 | 226 | * Insert an element, which may have child nodes, at the selection |
michael@0 | 227 | * Used primarily to insert a new element for various insert element dialogs, |
michael@0 | 228 | * but it enforces the HTML 4.0 DTD "CanContain" rules, so it should |
michael@0 | 229 | * be useful for other elements. |
michael@0 | 230 | * |
michael@0 | 231 | * @param aElement The element to insert |
michael@0 | 232 | * @param aDeleteSelection Delete the selection before inserting |
michael@0 | 233 | * If aDeleteSelection is PR_FALSE, then the element is inserted |
michael@0 | 234 | * after the end of the selection for all element except |
michael@0 | 235 | * Named Anchors, which insert before the selection |
michael@0 | 236 | */ |
michael@0 | 237 | void insertElementAtSelection(in nsIDOMElement aElement, |
michael@0 | 238 | in boolean aDeleteSelection); |
michael@0 | 239 | |
michael@0 | 240 | /** |
michael@0 | 241 | * Set the documents title. |
michael@0 | 242 | */ |
michael@0 | 243 | void setDocumentTitle(in AString aTitle); |
michael@0 | 244 | |
michael@0 | 245 | /** |
michael@0 | 246 | * Set the BaseURL for the document to the current URL |
michael@0 | 247 | * but only if the page doesn't have a <base> tag |
michael@0 | 248 | * This should be done after the document URL has changed, |
michael@0 | 249 | * such as after saving a file |
michael@0 | 250 | * This is used as base for relativizing link and image urls |
michael@0 | 251 | */ |
michael@0 | 252 | void updateBaseURL(); |
michael@0 | 253 | |
michael@0 | 254 | |
michael@0 | 255 | /* ------------ Selection manipulation -------------- */ |
michael@0 | 256 | /* Should these be moved to nsISelection? */ |
michael@0 | 257 | |
michael@0 | 258 | /** |
michael@0 | 259 | * Set the selection at the suppled element |
michael@0 | 260 | * |
michael@0 | 261 | * @param aElement An element in the document |
michael@0 | 262 | */ |
michael@0 | 263 | void selectElement(in nsIDOMElement aElement); |
michael@0 | 264 | |
michael@0 | 265 | /** |
michael@0 | 266 | * Create a collapsed selection just after aElement |
michael@0 | 267 | * |
michael@0 | 268 | * XXX could we parameterize SelectElement(before/select/after>? |
michael@0 | 269 | * |
michael@0 | 270 | * The selection is set to parent-of-aElement with an |
michael@0 | 271 | * offset 1 greater than aElement's offset |
michael@0 | 272 | * but it enforces the HTML 4.0 DTD "CanContain" rules, so it should |
michael@0 | 273 | * be useful for other elements. |
michael@0 | 274 | * |
michael@0 | 275 | * @param aElement An element in the document |
michael@0 | 276 | */ |
michael@0 | 277 | void setCaretAfterElement(in nsIDOMElement aElement); |
michael@0 | 278 | |
michael@0 | 279 | /** |
michael@0 | 280 | * SetParagraphFormat Insert a block paragraph tag around selection |
michael@0 | 281 | * @param aParagraphFormat "p", "h1" to "h6", "address", "pre", or "blockquote" |
michael@0 | 282 | */ |
michael@0 | 283 | void setParagraphFormat(in AString aParagraphFormat); |
michael@0 | 284 | |
michael@0 | 285 | /** |
michael@0 | 286 | * getParagraphState returns what block tag paragraph format is in |
michael@0 | 287 | * the selection. |
michael@0 | 288 | * @param aMixed True if there is more than one format |
michael@0 | 289 | * @return Name of block tag. "" is returned for none. |
michael@0 | 290 | */ |
michael@0 | 291 | AString getParagraphState(out boolean aMixed); |
michael@0 | 292 | |
michael@0 | 293 | /** |
michael@0 | 294 | * getFontFaceState returns what font face is in the selection. |
michael@0 | 295 | * @param aMixed True if there is more than one font face |
michael@0 | 296 | * @return Name of face. Note: "tt" is returned for |
michael@0 | 297 | * tt tag. "" is returned for none. |
michael@0 | 298 | */ |
michael@0 | 299 | AString getFontFaceState(out boolean aMixed); |
michael@0 | 300 | |
michael@0 | 301 | /** |
michael@0 | 302 | * getFontColorState returns what font face is in the selection. |
michael@0 | 303 | * @param aMixed True if there is more than one font color |
michael@0 | 304 | * @return Color string. "" is returned for none. |
michael@0 | 305 | */ |
michael@0 | 306 | AString getFontColorState(out boolean aMixed); |
michael@0 | 307 | |
michael@0 | 308 | /** |
michael@0 | 309 | * getFontColorState returns what font face is in the selection. |
michael@0 | 310 | * @param aMixed True if there is more than one font color |
michael@0 | 311 | * @return Color string. "" is returned for none. |
michael@0 | 312 | */ |
michael@0 | 313 | AString getBackgroundColorState(out boolean aMixed); |
michael@0 | 314 | |
michael@0 | 315 | /** |
michael@0 | 316 | * getHighlightColorState returns what the highlight color of the selection. |
michael@0 | 317 | * @param aMixed True if there is more than one font color |
michael@0 | 318 | * @return Color string. "" is returned for none. |
michael@0 | 319 | */ |
michael@0 | 320 | AString getHighlightColorState(out boolean aMixed); |
michael@0 | 321 | |
michael@0 | 322 | /** |
michael@0 | 323 | * getListState returns what list type is in the selection. |
michael@0 | 324 | * @param aMixed True if there is more than one type of list, or |
michael@0 | 325 | * if there is some list and non-list |
michael@0 | 326 | * @param aOL The company that employs me. No, really, it's |
michael@0 | 327 | * true if an "ol" list is selected. |
michael@0 | 328 | * @param aUL true if an "ul" list is selected. |
michael@0 | 329 | * @param aDL true if a "dl" list is selected. |
michael@0 | 330 | */ |
michael@0 | 331 | void getListState(out boolean aMixed, out boolean aOL, out boolean aUL, |
michael@0 | 332 | out boolean aDL); |
michael@0 | 333 | |
michael@0 | 334 | /** |
michael@0 | 335 | * getListItemState returns what list item type is in the selection. |
michael@0 | 336 | * @param aMixed True if there is more than one type of list item, or |
michael@0 | 337 | * if there is some list and non-list |
michael@0 | 338 | * @param aLI true if "li" list items are selected. |
michael@0 | 339 | * @param aDT true if "dt" list items are selected. |
michael@0 | 340 | * @param aDD true if "dd" list items are selected. |
michael@0 | 341 | */ |
michael@0 | 342 | void getListItemState(out boolean aMixed, out boolean aLI, |
michael@0 | 343 | out boolean aDT, out boolean aDD); |
michael@0 | 344 | |
michael@0 | 345 | /** |
michael@0 | 346 | * getAlignment returns what alignment is in the selection. |
michael@0 | 347 | * @param aMixed True if there is more than one type of list item, or |
michael@0 | 348 | * if there is some list and non-list |
michael@0 | 349 | * @param aAlign enum value for first encountered alignment |
michael@0 | 350 | * (left/center/right) |
michael@0 | 351 | */ |
michael@0 | 352 | void getAlignment(out boolean aMixed, out short aAlign); |
michael@0 | 353 | |
michael@0 | 354 | /** |
michael@0 | 355 | * Document me! |
michael@0 | 356 | * |
michael@0 | 357 | */ |
michael@0 | 358 | void getIndentState(out boolean aCanIndent, out boolean aCanOutdent); |
michael@0 | 359 | |
michael@0 | 360 | /** |
michael@0 | 361 | * Document me! |
michael@0 | 362 | * |
michael@0 | 363 | */ |
michael@0 | 364 | void makeOrChangeList(in AString aListType, in boolean entireList, |
michael@0 | 365 | in AString aBulletType); |
michael@0 | 366 | |
michael@0 | 367 | /** |
michael@0 | 368 | * Document me! |
michael@0 | 369 | * |
michael@0 | 370 | */ |
michael@0 | 371 | void removeList(in AString aListType); |
michael@0 | 372 | |
michael@0 | 373 | /** |
michael@0 | 374 | * Document me! |
michael@0 | 375 | * |
michael@0 | 376 | */ |
michael@0 | 377 | void indent(in AString aIndent); |
michael@0 | 378 | |
michael@0 | 379 | /** |
michael@0 | 380 | * Document me! |
michael@0 | 381 | * |
michael@0 | 382 | */ |
michael@0 | 383 | void align(in AString aAlign); |
michael@0 | 384 | |
michael@0 | 385 | /** |
michael@0 | 386 | * Return the input node or a parent matching the given aTagName, |
michael@0 | 387 | * starting the search at the supplied node. |
michael@0 | 388 | * An example of use is for testing if a node is in a table cell |
michael@0 | 389 | * given a selection anchor node. |
michael@0 | 390 | * |
michael@0 | 391 | * @param aTagName The HTML tagname |
michael@0 | 392 | * Special input values: |
michael@0 | 393 | * Use "href" to get a link node |
michael@0 | 394 | * (an "A" tag with the "href" attribute set) |
michael@0 | 395 | * Use "anchor" or "namedanchor" to get a named anchor node |
michael@0 | 396 | * (an "A" tag with the "name" attribute set) |
michael@0 | 397 | * Use "list" to get an OL, UL, or DL list node |
michael@0 | 398 | * Use "td" to get either a TD or TH cell node |
michael@0 | 399 | * |
michael@0 | 400 | * @param aNode The node in the document to start the search. |
michael@0 | 401 | * If it is null, the anchor node of the current selection is used. |
michael@0 | 402 | * @return NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found |
michael@0 | 403 | * (passes NS_SUCCEEDED macro) |
michael@0 | 404 | */ |
michael@0 | 405 | nsIDOMElement getElementOrParentByTagName(in AString aTagName, |
michael@0 | 406 | in nsIDOMNode aNode); |
michael@0 | 407 | |
michael@0 | 408 | /** |
michael@0 | 409 | * Return an element only if it is the only node selected, |
michael@0 | 410 | * such as an image, horizontal rule, etc. |
michael@0 | 411 | * The exception is a link, which is more like a text attribute: |
michael@0 | 412 | * The Anchor tag is returned if the selection is within the textnode(s) |
michael@0 | 413 | * that are children of the "A" node. |
michael@0 | 414 | * This could be a collapsed selection, i.e., a caret |
michael@0 | 415 | * within the link text. |
michael@0 | 416 | * |
michael@0 | 417 | * @param aTagName The HTML tagname or and empty string |
michael@0 | 418 | * to get any element (but only if it is the only element selected) |
michael@0 | 419 | * Special input values for Links and Named anchors: |
michael@0 | 420 | * Use "href" to get a link node |
michael@0 | 421 | * (an "A" tag with the "href" attribute set) |
michael@0 | 422 | * Use "anchor" or "namedanchor" to get a named anchor node |
michael@0 | 423 | * (an "A" tag with the "name" attribute set) |
michael@0 | 424 | * @return NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found |
michael@0 | 425 | * (passes NS_SUCCEEDED macro) |
michael@0 | 426 | */ |
michael@0 | 427 | nsIDOMElement getSelectedElement(in AString aTagName); |
michael@0 | 428 | |
michael@0 | 429 | /** |
michael@0 | 430 | * Output the contents of the <HEAD> section as text/HTML format |
michael@0 | 431 | */ |
michael@0 | 432 | AString getHeadContentsAsHTML(); |
michael@0 | 433 | |
michael@0 | 434 | /** |
michael@0 | 435 | * Replace all children of <HEAD> with string of HTML source |
michael@0 | 436 | */ |
michael@0 | 437 | void replaceHeadContentsWithHTML(in AString aSourceToInsert); |
michael@0 | 438 | |
michael@0 | 439 | /** |
michael@0 | 440 | * Return a new element with default attribute values |
michael@0 | 441 | * |
michael@0 | 442 | * This does not rely on the selection, and is not sensitive to context. |
michael@0 | 443 | * |
michael@0 | 444 | * Used primarily to supply new element for various insert element dialogs |
michael@0 | 445 | * (Image, Link, NamedAnchor, Table, and HorizontalRule |
michael@0 | 446 | * are the only returned elements as of 7/25/99) |
michael@0 | 447 | * |
michael@0 | 448 | * @param aTagName The HTML tagname |
michael@0 | 449 | * Special input values for Links and Named anchors: |
michael@0 | 450 | * Use "href" to get a link node |
michael@0 | 451 | * (an "A" tag with the "href" attribute set) |
michael@0 | 452 | * Use "anchor" or "namedanchor" to get a named anchor node |
michael@0 | 453 | * (an "A" tag with the "name" attribute set) |
michael@0 | 454 | * @return The new element created. |
michael@0 | 455 | */ |
michael@0 | 456 | nsIDOMElement createElementWithDefaults(in AString aTagName); |
michael@0 | 457 | |
michael@0 | 458 | /** |
michael@0 | 459 | * Insert an link element as the parent of the current selection |
michael@0 | 460 | * |
michael@0 | 461 | * @param aElement An "A" element with a non-empty "href" attribute |
michael@0 | 462 | */ |
michael@0 | 463 | void insertLinkAroundSelection(in nsIDOMElement aAnchorElement); |
michael@0 | 464 | |
michael@0 | 465 | /** |
michael@0 | 466 | * Set the value of the "bgcolor" attribute on the document's <body> element |
michael@0 | 467 | * |
michael@0 | 468 | * @param aColor The HTML color string, such as "#ffccff" or "yellow" |
michael@0 | 469 | */ |
michael@0 | 470 | void setBackgroundColor(in AString aColor); |
michael@0 | 471 | |
michael@0 | 472 | |
michael@0 | 473 | /** |
michael@0 | 474 | * Set an attribute on the document's <body> element |
michael@0 | 475 | * such as text, link, background colors |
michael@0 | 476 | * |
michael@0 | 477 | * 8/31/00 THIS ISN'T BEING USED? SHOULD WE DROP IT? |
michael@0 | 478 | * |
michael@0 | 479 | * @param aAttr The attribute to be set |
michael@0 | 480 | * @param aValue The value of the attribute |
michael@0 | 481 | */ |
michael@0 | 482 | void setBodyAttribute(in AString aAttr, in AString aValue); |
michael@0 | 483 | |
michael@0 | 484 | /** |
michael@0 | 485 | * Find all the nodes in the document which contain references |
michael@0 | 486 | * to outside URIs (e.g. a href, img src, script src, etc.) |
michael@0 | 487 | * The objects in the array will be type nsIURIRefObject. |
michael@0 | 488 | * |
michael@0 | 489 | * @return aNodeList the linked nodes found |
michael@0 | 490 | */ |
michael@0 | 491 | nsISupportsArray getLinkedObjects(); |
michael@0 | 492 | |
michael@0 | 493 | /** |
michael@0 | 494 | * A boolean which is true is the HTMLEditor has been instantiated |
michael@0 | 495 | * with CSS knowledge and if the CSS pref is currently checked |
michael@0 | 496 | * |
michael@0 | 497 | * @return true if CSS handled and enabled |
michael@0 | 498 | */ |
michael@0 | 499 | attribute boolean isCSSEnabled; |
michael@0 | 500 | |
michael@0 | 501 | /** |
michael@0 | 502 | * Add listener for insertion override |
michael@0 | 503 | * @param inFilter function which callers want called during insertion |
michael@0 | 504 | */ |
michael@0 | 505 | void addInsertionListener(in nsIContentFilter inFilter); |
michael@0 | 506 | |
michael@0 | 507 | /** |
michael@0 | 508 | * Remove listener for insertion override |
michael@0 | 509 | * @param inFilter function which callers do not want called during insertion |
michael@0 | 510 | */ |
michael@0 | 511 | void removeInsertionListener(in nsIContentFilter inFilter); |
michael@0 | 512 | |
michael@0 | 513 | /** |
michael@0 | 514 | * Returns an anonymous nsDOMElement of type aTag, |
michael@0 | 515 | * child of aParentNode. If aIsCreatedHidden is true, the class |
michael@0 | 516 | * "hidden" is added to the created element. If aAnonClass is not |
michael@0 | 517 | * the empty string, it becomes the value of the attribute "_moz_anonclass" |
michael@0 | 518 | * @return a DOM Element |
michael@0 | 519 | * @param aTag [IN] a string representing the desired type of |
michael@0 | 520 | * the element to create |
michael@0 | 521 | * @param aParentNode [IN] the parent node of the created anonymous |
michael@0 | 522 | * element |
michael@0 | 523 | * @param aAnonClass [IN] contents of the _moz_anonclass attribute |
michael@0 | 524 | * @param aIsCreatedHidden [IN] a boolean specifying if the class "hidden" |
michael@0 | 525 | * is to be added to the created anonymous |
michael@0 | 526 | * element |
michael@0 | 527 | */ |
michael@0 | 528 | nsIDOMElement createAnonymousElement(in AString aTag, in nsIDOMNode aParentNode, |
michael@0 | 529 | in AString aAnonClass, in boolean aIsCreatedHidden); |
michael@0 | 530 | |
michael@0 | 531 | /** |
michael@0 | 532 | * returns the deepest container of the selection |
michael@0 | 533 | * @return a DOM Element |
michael@0 | 534 | */ |
michael@0 | 535 | nsIDOMElement getSelectionContainer(); |
michael@0 | 536 | |
michael@0 | 537 | /** |
michael@0 | 538 | * Checks if the anonymous nodes created by the HTML editor have to be |
michael@0 | 539 | * refreshed or hidden depending on a possible new state of the selection |
michael@0 | 540 | * @param aSelection [IN] a selection |
michael@0 | 541 | */ |
michael@0 | 542 | void checkSelectionStateForAnonymousButtons(in nsISelection aSelection); |
michael@0 | 543 | |
michael@0 | 544 | boolean isAnonymousElement(in nsIDOMElement aElement); |
michael@0 | 545 | |
michael@0 | 546 | /** |
michael@0 | 547 | * A boolean indicating if a return key pressed in a paragraph creates |
michael@0 | 548 | * another paragraph or just inserts a <br> at the caret |
michael@0 | 549 | * |
michael@0 | 550 | * @return true if CR in a paragraph creates a new paragraph |
michael@0 | 551 | */ |
michael@0 | 552 | attribute boolean returnInParagraphCreatesNewParagraph; |
michael@0 | 553 | |
michael@0 | 554 | /** |
michael@0 | 555 | * Checks whether a BR node is visible to the user. |
michael@0 | 556 | */ |
michael@0 | 557 | boolean breakIsVisible(in nsIDOMNode aNode); |
michael@0 | 558 | |
michael@0 | 559 | /** |
michael@0 | 560 | * Get an active editor's editing host in DOM window. If this editor isn't |
michael@0 | 561 | * active in the DOM window, this returns NULL. |
michael@0 | 562 | */ |
michael@0 | 563 | [noscript, notxpcom] Element GetActiveEditingHost(); |
michael@0 | 564 | }; |
michael@0 | 565 |