1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv=
"content-type" content=
"text/html; charset=ISO-8859-1">
5 <title>Midas Specification
</title>
6 <meta name=
"author" content=
"Kathleen Brade">
7 <style type=
"text/css">
8 td
{ vertical-align: top
; }
12 Last revised:
August
23,
2005<br>
14 This document describes the rich text editing controls for web pages
15 available in recent mozilla browsers.
<br>
17 <h1> Enabling Rich Text Editing in your web page:
</h1>
18 <div style=
"margin-left: 40px;">Given a document, you can add the
19 attribute
"designMode" and set it to
"on" to get an editable document.
20 For example, in JavaScript, if you have an iframe with an id of 'edit', you
21 can get its contentDocument and set designMode to
"on" like this:
<br>
22 <div style=
"margin-left: 40px;"><code>document.getElementById(
"edit").contentDocument.
designMode=
"on";
</code></div>
24 Right now, you can't completely turn off editing by setting designMode
25 to
"off." Setting designMode to
"off" will prevent certain operations
26 from being handled but typing and other actions are still possible.
<br>
29 <h1>Invoking Commands:
</h1>
31 <div style=
"margin-left: 40px;">Given a document that has rich text
32 editing enabled (see above), you can invoke specific commands on the
33 document by calling execCommand with
3 parameters.
For example,
34 in JavaScript, if you have an editable document,
35 you can invoke the bold command by calling this:
<br>
36 <div style=
"margin-left: 40px;"><code>editableDocument.execCommand(
"Bold",
37 false, null);
</code></div><br>
38 Notes:
If you haven't set designMode to
"On", you will get an
39 error.
This could also happen if you call execCommand with the wrong
42 There are
3 required parameters for execCommand:
<br>
44 <li>command string
</li>
45 <li>boolean flag for showing UI
</li>
48 The first parameter is a string which contains the command.
The
49 second parameter is a boolean flag.
If it is set to true, you will
50 get an error (NS_ERROR_NOT_IMPLEMENTED).
The third parameter is a
51 string which is the value.
Some commands will require details such
52 as the particular size you want to set when setting a font size.
<br>
54 The section on Supported Commands will document each command and any
55 corresponding values needed.
<br>
57 <div style=
"margin-left: 40px;"> </div>
59 <h2>queryCommandEnabled
</h2>
60 <blockquote>This command operates on the editable document.
There
61 is one required parameter (the command string).
The result is a
62 boolean which is true if the command is can be done given the current
63 selection and/or caret position.
The result is false if the command
64 should not be invoked (execCommand) given the current selection and/or
68 <h2>queryCommandState
</h2>
69 <blockquote>This section needs to be written.
It can be called
70 similarly to IE implementation.
<br>
73 <h2>queryCommandValue
</h2>
74 <blockquote> This section needs to be written.
It can be called
75 similarly to IE implementation.
78 <h1>Supported Commands:
</h1>
79 <div style=
"margin-left: 40px;">The following list of commands is
80 presented in alphabetical order.
The commands may be mixed case
81 or whatever makes your code more readable.
<br>
83 <table cellpadding=
"4" cellspacing=
"0" border=
"1"
84 style=
"text-align: left; width: 100%;">
89 <td>explanation / behavior
</td>
94 <td>This command will set the background color of the document.
</td>
99 <td>If there is no selection, the insertion
100 point will set bold for subsequently typed characters.
<br>
102 If there is a selection and all of the characters are already bold, the
103 bold will be removed.
Otherwise, all selected characters will become
107 <td>contentReadOnly
</td>
108 <td>true
<br>false
</td>
109 <td>This command will make the editor readonly (true) or editable
110 (false).
Anticipated usage is for temporarily disabling input while
111 something else is occurring elsewhere in the web page.
</td>
116 <td>If there is a selection, this command will copy the selection
117 to the clipboard.
If there isn't a selection, nothing will happen.
<br>
119 note: this command won't work without setting a pref or using signed
120 JS.
See: http://www.mozilla.org/editor/midasdemo/securityprefs.html
<br>
122 note:
the shortcut key will automatically trigger this command
123 (typically accel-C) with or without the signed JS or any code on the page to
129 <td>This command will not do anything if no selection
130 is made.
If there is a selection, a link will be inserted around
131 the selection with the url parameter as the href of the link.
</td>
136 <td>If there is a selection, this command will copy the selection
137 to the clipboard and remove the selection from the edit control.
138 If there isn't a selection, nothing will happen.
<br>
140 note: this command won't work without setting a pref or using signed
141 JS.
See: http://www.mozilla.org/editor/midasdemo/securityprefs.html
<br>
143 note:
the shortcut key will automatically trigger this command
144 (typically accel-X) with or without the signed JS or any code on the page to
148 <td>decreasefontsize
</td>
150 <td>This command will add a
<small
> tag around selection or
151 at insertion point.
</td>
156 <td>This command will delete all text and objects that
162 <td>This command will set the fontface for a selection
163 or at the insertion point if there is no selection.
</td>
168 <td>This command will set the fontsize for a selection
169 or at the insertion point if there is no selection.
</td>
174 <td>This command will set the text color of the
175 selection or at the insertion point.
</td>
189 [this list may not be complete]
</td>
205 <td>This command will set the hilite color of the selection or at
206 the insertion point.
It only works with usecss enabled.
</td>
209 <td>increasefontsize
</td>
211 <td>This command will add a
212 <big
> tag around selection or at insertion point.
</td>
217 <td>Indent the block where the caret is located.
</td>
220 <td>inserthorizontalrule
</td>
222 <td>This command will insert a horizontal rule
223 (line) at the insertion point.
<br>
225 Does it delete the selection?
</td>
229 <td>valid html string
</td>
230 <td>This command will insert the given html into the
<body
>
231 in place of the current selection or at the caret location.
</td>
236 <td>This command will insert an image (referenced by
237 url) at the insertion point.
<br>
239 Does it delete the selection?
</td>
242 <td>insertorderedlist
</td>
247 <td>insertunorderedlist
</td>
252 <td>insertparagraph
</td>
259 <td>If there is no selection, the insertion
260 point will set italic for subsequently typed characters.
<br>
262 If there is a selection and all of the characters are already italic,
263 the italic will be removed.
Otherwise, all selected characters will
267 <td>justifycenter
</td>
282 <td>justifyright
</td>
289 <td>Outdent the block where the caret is located.
If the
290 block is not indented prior to calling outdent, nothing will happen.
<br>
292 note:
is an error thrown if no outdenting is done?
</td>
297 <td>This command will paste the contents of the clipboard at the
298 location of the caret.
If there is a selection, it will be deleted
299 prior to the insertion of the clipboard's contents.
<br>
301 note: this command won't work without setting a pref or using signed
303 <tt>user_pref(
"capability.policy.policynames",
"allowclipboard");
</tt><tt>
304 user_pref(
"capability.policy.allowclipboard.Clipboard.paste",
305 "allAccess");
</tt><br>
306 See: http://www.mozilla.org/editor/midasdemo/securityprefs.html
<br>
308 note:
the shortcut key will automatically trigger this command
309 (typically accel-V) with or without the signed JS or any code on the page to
315 <td>This command will redo the previous undo action.
If undo
316 was not the most recent action, this command will have no effect.
<br>
318 note:
the shortcut key will automatically trigger this command
319 (typically accel-shift-Z)
</td>
322 <td>removeformat
</td>
329 <td>This command will select all of the contents within the
332 note:
the shortcut key will automatically trigger this command
333 (typically accel-A)
</td>
336 <td>strikethrough
</td>
338 <td>If there is no selection, the insertion point
339 will set strikethrough for subsequently typed characters.
<br>
341 If there is a selection and all of the characters are already striked,
342 the strikethrough will be removed. Otherwise, all selected characters
343 will have a line drawn through them.
</td>
346 <td>styleWithCSS
</td>
347 <td>true
<br>false
</td>
348 <td>This command is used for
349 toggling the format of generated content.
By default (at least
350 today), this is true.
An example of the differences is that the
351 "bold" command will generate
<b
> if the styleWithCSS command is false
352 and generate css style attribute if the styleWithCSS command is true.
</td>
357 <td>If there is no selection, the insertion point
358 will set subscript for subsequently typed characters.
<br>
360 If there is a selection and all of the characters are already
361 subscripted, the subscript will be removed.
Otherwise, all
362 selected characters will be drawn slightly lower than normal text.
</td>
367 <td>If there is no selection, the insertion point
368 will set superscript for subsequently typed characters.
<br>
370 If there is a selection and all of the characters are already
371 superscripted, the superscript will be removed.
Otherwise, all
372 selected characters will be drawn slightly higher than normal text.
</td>
377 <td>If there is no selection, the insertion
378 point will set underline for subsequently typed characters.
<br>
380 If there is a selection and all of the characters are already
381 underlined, the underline will be removed.
Otherwise, all
382 selected characters will become underlined.
</td>
387 <td>This command will undo the previous action.
If no action
388 has occurred in the document, then this command will have no effect.
<br>
390 note:
the shortcut key will automatically trigger this command
391 (typically accel-Z)
</td>
401 <table cellpadding=
"4" cellspacing=
"0" border=
"1"
402 style=
"text-align: left; width: 100%;">
405 <td colspan=
"3">DEPRECATED COMMANDS
</td>
409 <td>true
<br>false
</td>
410 <td>This command has been replaced with contentReadOnly.
It
411 takes the same values as contentReadOnly, but the meaning of true and
412 false are inversed.
</td>
417 <td>This command has been replaced with styleWithCSS.
It takes
418 the same values as styleWithCSS, but the meaning of true and false are