Source code

Revision control

Other Tools

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/. */
5
6
#include "nsISupports.idl"
7
#include "domstubs.idl"
8
9
interface nsIContent;
10
interface nsIArray;
11
12
webidl Document;
13
webidl Element;
14
webidl Node;
15
webidl Selection;
16
17
[scriptable, builtinclass, uuid(87ee993e-985f-4a43-a974-0d9512da2fb0)]
18
interface nsIHTMLEditor : nsISupports
19
{
20
%{C++
21
typedef short EAlignment;
22
%}
23
24
// used by GetAlignment()
25
const short eLeft = 0;
26
const short eCenter = 1;
27
const short eRight = 2;
28
const short eJustify = 3;
29
30
31
/* ------------ Inline property methods -------------- */
32
33
/**
34
* SetInlineProperty() sets the aggregate properties on the current selection
35
*
36
* @param aProperty the property to set on the selection
37
* @param aAttribute the attribute of the property, if applicable.
38
* May be null.
39
* Example: aProperty="font", aAttribute="color"
40
* @param aValue if aAttribute is not null, the value of the attribute.
41
* May be null.
42
* Example: aProperty="font", aAttribute="color",
43
* aValue="0x00FFFF"
44
*/
45
[can_run_script]
46
void setInlineProperty(in AString aProperty,
47
in AString aAttribute,
48
in AString aValue);
49
50
/**
51
* getInlineProperty() gets aggregate properties of the current selection.
52
* All object in the current selection are scanned and their attributes are
53
* represented in a list of Property object.
54
*
55
* @param aProperty the property to get on the selection
56
* @param aAttribute the attribute of the property, if applicable.
57
* May be null.
58
* Example: aProperty="font", aAttribute="color"
59
* @param aValue if aAttribute is not null, the value of the attribute.
60
* May be null.
61
* Example: aProperty="font", aAttribute="color",
62
* aValue="0x00FFFF"
63
* @param aFirst [OUT] PR_TRUE if the first text node in the
64
* selection has the property
65
* @param aAny [OUT] PR_TRUE if any of the text nodes in the
66
* selection have the property
67
* @param aAll [OUT] PR_TRUE if all of the text nodes in the
68
* selection have the property
69
*/
70
void getInlineProperty(in AString aProperty,
71
in AString aAttribute,
72
in AString aValue,
73
out boolean aFirst,
74
out boolean aAny,
75
out boolean aAll);
76
77
AString getInlinePropertyWithAttrValue(in AString aProperty,
78
in AString aAttribute,
79
in AString aValue,
80
out boolean aFirst,
81
out boolean aAny,
82
out boolean aAll);
83
84
/**
85
* removeAllInlineProperties() deletes all the inline properties from all
86
* text in the current selection.
87
*/
88
[can_run_script]
89
void removeAllInlineProperties();
90
91
92
/**
93
* removeInlineProperty() removes a property which changes inline style of
94
* text. E.g., bold, italic, super and sub.
95
*
96
* @param aProperty Tag name whcih represents the inline style you want to
97
* remove. E.g., "strong", "b", etc.
98
* If "href", <a> element which has href attribute will be
99
* removed.
100
* If "name", <a> element which has non-empty name
101
* attribute will be removed.
102
* @param aAttribute If aProperty is "font", aAttribute should be "face",
103
* "size", "color" or "bgcolor".
104
*/
105
[can_run_script]
106
void removeInlineProperty(in AString aProperty, in AString aAttribute);
107
108
/**
109
* Increase font size for text in selection by 1 HTML unit
110
* All existing text is scanned for existing <FONT SIZE> attributes
111
* so they will be incremented instead of inserting new <FONT> tag
112
*/
113
[can_run_script]
114
void increaseFontSize();
115
116
/**
117
* Decrease font size for text in selection by 1 HTML unit
118
* All existing text is scanned for existing <FONT SIZE> attributes
119
* so they will be decreased instead of inserting new <FONT> tag
120
*/
121
[can_run_script]
122
void decreaseFontSize();
123
124
/* ------------ HTML content methods -------------- */
125
126
/**
127
* Tests if a node is a BLOCK element according the the HTML 4.0 DTD.
128
* This does NOT consider CSS effect on display type
129
*
130
* @param aNode the node to test
131
*/
132
boolean nodeIsBlock(in Node node);
133
134
/**
135
* Insert some HTML source at the current location
136
*
137
* @param aInputString the string to be inserted
138
*/
139
[can_run_script]
140
void insertHTML(in AString aInputString);
141
142
143
/**
144
* Paste the text in the OS clipboard at the cursor position, replacing
145
* the selected text (if any), but strip out any HTML styles and formatting
146
*/
147
[can_run_script]
148
void pasteNoFormatting(in long aSelectionType);
149
150
/**
151
* Rebuild the entire document from source HTML
152
* Needed to be able to edit HEAD and other outside-of-BODY content
153
*
154
* @param aSourceString HTML source string of the entire new document
155
*/
156
[can_run_script]
157
void rebuildDocumentFromSource(in AString aSourceString);
158
159
/**
160
* Insert an element, which may have child nodes, at the selection
161
* Used primarily to insert a new element for various insert element dialogs,
162
* but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
163
* be useful for other elements.
164
*
165
* @param aElement The element to insert
166
* @param aDeleteSelection Delete the selection before inserting
167
* If aDeleteSelection is PR_FALSE, then the element is inserted
168
* after the end of the selection for all element except
169
* Named Anchors, which insert before the selection
170
*/
171
[can_run_script]
172
void insertElementAtSelection(in Element aElement,
173
in boolean aDeleteSelection);
174
175
/**
176
* Set the BaseURL for the document to the current URL
177
* but only if the page doesn't have a <base> tag
178
* This should be done after the document URL has changed,
179
* such as after saving a file
180
* This is used as base for relativizing link and image urls
181
*/
182
void updateBaseURL();
183
184
185
/* ------------ Selection manipulation -------------- */
186
/* Should these be moved to Selection? */
187
188
/**
189
* Set the selection at the suppled element
190
*
191
* @param aElement An element in the document
192
*/
193
[can_run_script]
194
void selectElement(in Element aElement);
195
196
/**
197
* Create a collapsed selection just after aElement
198
*
199
* XXX could we parameterize SelectElement(before/select/after>?
200
*
201
* The selection is set to parent-of-aElement with an
202
* offset 1 greater than aElement's offset
203
* but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
204
* be useful for other elements.
205
*
206
* @param aElement An element in the document
207
*/
208
void setCaretAfterElement(in Element aElement);
209
210
/**
211
* SetParagraphFormat Insert a block paragraph tag around selection
212
* @param aParagraphFormat "p", "h1" to "h6", "address", "pre", or "blockquote"
213
*/
214
[can_run_script]
215
void setParagraphFormat(in AString aParagraphFormat);
216
217
/**
218
* getParagraphState returns what block tag paragraph format is in
219
* the selection.
220
* @param aMixed True if there is more than one format
221
* @return Name of block tag. "" is returned for none.
222
*/
223
[can_run_script]
224
AString getParagraphState(out boolean aMixed);
225
226
/**
227
* getFontFaceState returns what font face is in the selection.
228
* @param aMixed True if there is more than one font face
229
* @return Name of face. Note: "tt" is returned for
230
* tt tag. "" is returned for none.
231
*/
232
AString getFontFaceState(out boolean aMixed);
233
234
/**
235
* getBackgroundColorState returns what the background color of the selection.
236
* @param aMixed True if there is more than one font color
237
* @return Color string. "" is returned for none.
238
*/
239
AString getBackgroundColorState(out boolean aMixed);
240
241
/**
242
* getHighlightColorState returns what the highlight color of the selection.
243
* @param aMixed True if there is more than one font color
244
* @return Color string. "" is returned for none.
245
*/
246
AString getHighlightColorState(out boolean aMixed);
247
248
/**
249
* getListState returns what list type is in the selection.
250
* @param aMixed True if there is more than one type of list, or
251
* if there is some list and non-list
252
* @param aOL The company that employs me. No, really, it's
253
* true if an "ol" list is selected.
254
* @param aUL true if an "ul" list is selected.
255
* @param aDL true if a "dl" list is selected.
256
*/
257
[can_run_script]
258
void getListState(out boolean aMixed, out boolean aOL, out boolean aUL,
259
out boolean aDL);
260
261
/**
262
* getListItemState returns what list item type is in the selection.
263
* @param aMixed True if there is more than one type of list item, or
264
* if there is some list and non-list
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.
268
*/
269
[can_run_script]
270
void getListItemState(out boolean aMixed, out boolean aLI,
271
out boolean aDT, out boolean aDD);
272
273
/**
274
* getAlignment returns what alignment is in the selection.
275
* @param aMixed True if there is more than one type of list item, or
276
* if there is some list and non-list
277
* @param aAlign enum value for first encountered alignment
278
* (left/center/right)
279
*/
280
[can_run_script]
281
void getAlignment(out boolean aMixed, out short aAlign);
282
283
/**
284
* Document me!
285
*
286
*/
287
[can_run_script]
288
void makeOrChangeList(in AString aListType, in boolean entireList,
289
in AString aBulletType);
290
291
/**
292
* removeList removes list items (<li>, <dd>, and <dt>) and list structures
293
* (<ul>, <ol>, and <dl>).
294
*
295
* @param aListType Unused.
296
*/
297
void removeList(in AString aListType);
298
299
/**
300
* Document me!
301
*
302
*/
303
[can_run_script]
304
void indent(in AString aIndent);
305
306
/**
307
* Document me!
308
*
309
*/
310
void align(in AString aAlign);
311
312
/**
313
* GetElementOrParentByTagName() looks for an element node whose name matches
314
* aTagName from aNode or anchor node of Selection to <body> element.
315
*
316
* @param aTagName The tag name which you want to look for.
317
* Must not be empty string.
318
* If "list", the result may be <ul>, <ol> or <dl>
319
* element.
320
* If "td", the result may be <td> or <th>.
321
* If "href", the result may be <a> element
322
* which has "href" attribute with non-empty value.
323
* If "anchor", the result may be <a> which has
324
* "name" attribute with non-empty value.
325
* @param aNode If non-null, this starts to look for the result
326
* from it. Otherwise, i.e., null, starts from
327
* anchor node of Selection.
328
* @return If an element which matches aTagName, returns
329
* an Element. Otherwise, nullptr.
330
*/
331
Element getElementOrParentByTagName(in AString aTagName,
332
in Node aNode);
333
334
/**
335
* getSelectedElement() returns a "selected" element node. "selected" means:
336
* - there is only one selection range
337
* - the range starts from an element node or in an element
338
* - the range ends at immediately after same element
339
* - and the range does not include any other element nodes.
340
* Additionally, only when aTagName is "href", this thinks that an <a>
341
* element which has non-empty "href" attribute includes the range, the
342
* <a> element is selected.
343
*
344
* @param aTagName Case-insensitive element name.
345
* If empty string, this returns any element node or null.
346
* If "href", this returns an <a> element which has
347
* non-empty "href" attribute or null.
348
* If "anchor", this returns an <a> element which has
349
* non-empty "name" attribute or null.
350
* Otherwise, returns an element node whose name is
351
* same as aTagName or null.
352
* @return A "selected" element.
353
*/
354
nsISupports getSelectedElement(in AString aTagName);
355
356
/**
357
* Return a new element with default attribute values
358
*
359
* This does not rely on the selection, and is not sensitive to context.
360
*
361
* Used primarily to supply new element for various insert element dialogs
362
* (Image, Link, NamedAnchor, Table, and HorizontalRule
363
* are the only returned elements as of 7/25/99)
364
*
365
* @param aTagName The HTML tagname
366
* Special input values for Links and Named anchors:
367
* Use "href" to get a link node
368
* (an "A" tag with the "href" attribute set)
369
* Use "anchor" or "namedanchor" to get a named anchor node
370
* (an "A" tag with the "name" attribute set)
371
* @return The new element created.
372
*/
373
[can_run_script]
374
Element createElementWithDefaults(in AString aTagName);
375
376
/**
377
* Insert an link element as the parent of the current selection
378
*
379
* @param aElement An "A" element with a non-empty "href" attribute
380
*/
381
[can_run_script]
382
void insertLinkAroundSelection(in Element aAnchorElement);
383
384
/**
385
* Set the value of the "bgcolor" attribute on the document's <body> element
386
*
387
* @param aColor The HTML color string, such as "#ffccff" or "yellow"
388
*/
389
[can_run_script]
390
void setBackgroundColor(in AString aColor);
391
392
/**
393
* Find all the nodes in the document which contain references
394
* to outside URIs (e.g. a href, img src, script src, etc.)
395
* The objects in the array will be type nsIURIRefObject.
396
*
397
* @return aNodeList the linked nodes found
398
*/
399
nsIArray getLinkedObjects();
400
401
/**
402
* A boolean which is true is the HTMLEditor has been instantiated
403
* with CSS knowledge and if the CSS pref is currently checked
404
*
405
* @return true if CSS handled and enabled
406
*/
407
attribute boolean isCSSEnabled;
408
409
/**
410
* checkSelectionStateForAnonymousButtons() may refresh editing UI such as
411
* resizers, inline-table-editing UI, absolute positioning UI for current
412
* Selection and focus state. When this method shows or hides UI, the
413
* editor (and/or its document/window) could be broken by mutation observers.
414
* FYI: Current user in script is only BlueGriffon.
415
*/
416
[can_run_script]
417
void checkSelectionStateForAnonymousButtons();
418
419
boolean isAnonymousElement(in Element aElement);
420
421
/**
422
* A boolean indicating if a return key pressed in a paragraph creates
423
* another paragraph or just inserts a <br> at the caret
424
*
425
* @return true if CR in a paragraph creates a new paragraph
426
*/
427
attribute boolean returnInParagraphCreatesNewParagraph;
428
};
429