1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
<title>Midas Specification</title>
<meta name="author" content="Kathleen Brade">
</head>
<body>
Last revised: May 30, 2003<br>
<br>
This document describes the rich text editing controls for web pages
available in recent mozilla browsers.<br>
<br>
<h1> Enabling Rich Text Editing in your web page:</h1>
<div style="margin-left: 40px;">Given a document, you can add the
attribute
"designMode" and set it to "on" to get an editable document. For
example,
in JavaScript, if you have an iframe with an id of 'edit', you can get
its
contentDocument and set designMode to "on" like this:<br>
<div style="margin-left: 40px;"><code>document.getElementById("edit").contentDocument.designMode="on";</code>
</div>
<br>
Right now, you can't completely turn off editing by setting designMode
to
"off." Setting designMode to "off" will prevent certain
operations
from being handled but typing and other actions are still possible.<br>
</div>
<br>
<h1>Invoking Commands:</h1>
<h2>execCommand<br>
</h2>
<div style="margin-left: 40px;">Given a document that has rich text
editing
enabled (see above),
you can invoke specific commands on the document by calling execCommand
with
3 parameters. For example, in JavaScript, if you have an editable
document,
you can invoke the bold command by calling this:<br>
<div style="margin-left: 40px;"><code>editableDocument.execCommand("Bold",
false, null); </code></div>
Notes: If you haven't set designMode to "On", you will get an
error.
This could also happen if you call execCommand with the wrong
document.<br>
<br>
There are 3 required parameters for execCommand:<br>
<ol>
<li>command string</li>
<li>boolean flag for showing UI</li>
<li>value string</li>
</ol>
The first parameter is a string which contains the command. The
second
parameter is a boolean flag. If it is set to true, you will get
an
error (NS_ERROR_NOT_IMPLEMENTED). The third parameter is a string
which
is the value. Some commands will require details such as the
particular
size you want to set when setting a font size.<br>
<br>
The section on Supported Commands will document each command and any
corresponding values needed.<br>
</div>
<div style="margin-left: 40px;"> </div>
<br>
<h2>queryCommandEnabled</h2>
<blockquote>This command operates on the editable document. There
is
one required parameter (the command string). The result is a
boolean
which is true if the command is can be done given the current selection
and/or
caret position. The result is false if the command should not be
invoked
(execCommand) given the current selection and/or caret position. <br>
</blockquote>
<br>
<h2>queryCommandState</h2>
<blockquote>This section needs to be written. It can be called
similarly to IE implementation.<br>
</blockquote>
<br>
<h2>queryCommandValue</h2>
<blockquote> This section needs to be written. It can be called
similarly to IE implementation.
</blockquote>
<br>
<h1>Supported Commands:</h1>
<div style="margin-left: 40px;">The following list of commands is
presented
in alphabetical order. The commands may be mixed case or whatever
makes
your code more readable.<br>
<br>
<table cellpadding="2" cellspacing="2" border="1"
style="text-align: left; width: 100%;">
<tbody>
<tr>
<td style="vertical-align: top;">command<br>
</td>
<td style="vertical-align: top;">value<br>
</td>
<td style="vertical-align: top;">explanation / behavior<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">backcolor<br>
</td>
<td style="vertical-align: top;">????<br>
</td>
<td style="vertical-align: top;">This command will set the
background color of the document.</td>
</tr>
<tr>
<td style="vertical-align: top;">bold<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;">If there is no selection, the
insertion
point will set bold for subsequently typed characters. <br>
<br>
If there is a selection and all of the characters are already bold, the
bold
will be removed. Otherwise, all selected characters will become
bold.<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">copy<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;">If there is a selection, this
command
will copy the selection to the clipboard. If there isn't a
selection,
nothing will happen.<br>
<br>
note: this command won't work without setting a pref or using signed
JS. See:
http://www.mozilla.org/editor/midasdemo/securityprefs.html<br>
<br>
note: the shortcut key will automatically trigger this command
(typically
accel-C) with or without the signed JS or any code on the page to
handle it.<br>
</td>
</tr>
<tr>
<td valign="top">createlink<br>
</td>
<td valign="top">url (href)<br>
</td>
<td valign="top">This command will not do anything if no
selection
is made. If there is a selection, a link will be inserted around
the
selection with the url parameter as the href of the link.<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">cut<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;">If there is a selection, this
command
will copy the selection to the clipboard and remove the selection from
the
edit control. If there isn't a selection, nothing will happen.<br>
<br>
note: this command won't work without setting a pref or using signed
JS. See:
http://www.mozilla.org/editor/midasdemo/securityprefs.html<br>
<br>
note: the shortcut key will automatically trigger this command
(typically
accel-X) with or without the signed JS or any code on the page to
handle it.<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">decreasefontsize<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;">This command will add a
<small> tag around selection or at insertion point.<br>
</td>
</tr>
<tr>
<td valign="top">delete<br>
</td>
<td valign="top">none<br>
</td>
<td valign="top">This command will delete all text and objects
that
are selected.<br>
</td>
</tr>
<tr>
<td valign="top">fontname<br>
</td>
<td valign="top">????<br>
</td>
<td valign="top">This command will set the fontface for a
selection
or at the insertion point if there is no selection.<br>
</td>
</tr>
<tr>
<td valign="top">fontsize<br>
</td>
<td valign="top">????<br>
</td>
<td valign="top">This command will set the fontsize for a
selection
or at the insertion point if there is no selection.<br>
</td>
</tr>
<tr>
<td valign="top">forecolor<br>
</td>
<td valign="top">????<br>
</td>
<td valign="top">This command will set the text color of the
selection or at the insertion
point.<br>
</td>
</tr>
<tr>
<td valign="top">formatblock<br>
</td>
<td valign="top"><h1><br>
<h2><br>
<h3><br>
<h4><br>
<h5><br>
<h6><br>
<pre><br>
<address><br>
<p><br>
p<br>
[this list may not be completely]<br>
</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td valign="top">heading<br>
</td>
<td valign="top"><h1><br>
<h2><br>
<h3><br>
<h4><br>
<h5><br>
<h6><br>
</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">hilitecolor<br>
</td>
<td style="vertical-align: top;">????<br>
</td>
<td style="vertical-align: top;">This command will set the hilite
color of the selection or at the insertion point. It only works
with usecss enabled.<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">increasefontsize<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;">This command will add a
<big> tag around selection or at insertion point.</td>
</tr>
<tr>
<td style="vertical-align: top;">indent<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;">Indent the block where the caret
is
located.<br>
</td>
</tr>
<tr>
<td valign="top">inserthorizontalrule<br>
</td>
<td valign="top">none<br>
</td>
<td valign="top">This command will insert a horizontal rule
(line)
at the insertion point.<br>
<br>
Does it delete the selection?<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">inserthtml<br>
</td>
<td style="vertical-align: top;">valid html string<br>
</td>
<td style="vertical-align: top;">This command will insert the
given html into the <body> in place of the current selection or
at the caret location.<br>
</td>
</tr>
<tr>
<td valign="top">insertimage<br>
</td>
<td valign="top">url (src)<br>
</td>
<td valign="top">This command will insert an image (referenced by
url)
at the insertion point.<br>
<br>
Does it delete the selection?<br>
</td>
</tr>
<tr>
<td valign="top">insertorderedlist<br>
</td>
<td valign="top">none<br>
</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td valign="top">insertunorderedlist<br>
</td>
<td valign="top">none<br>
</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">insertparagraph<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;"><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">italic<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;">If there is no selection, the
insertion
point will set italic for subsequently typed characters. <br>
<br>
If there is a selection and all of the characters are already italic,
the
italic will be removed. Otherwise, all selected characters will
become
italic.</td>
</tr>
<tr>
<td valign="top">justifycenter<br>
</td>
<td valign="top">none<br>
</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td valign="top">justifyfull<br>
</td>
<td valign="top">none<br>
</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td valign="top">justifyleft<br>
</td>
<td valign="top">none<br>
</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td valign="top">justifyright<br>
</td>
<td valign="top">none<br>
</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">outdent<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;">Outdent the block where the
caret
is located. If the block is not indented prior to calling
outdent,
nothing will happen.<br>
<br>
note: is an error thrown if no outdenting is done?<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">paste<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;">This command will paste the
contents of the clipboard at the location of
the caret. If there is a selection, it will be deleted prior to
the
insertion of the clipboard's contents.<br>
<br>
note: this command won't work without setting a pref or using signed
JS. <br>
<tt>user_pref("capability.policy.policynames", "allowclipboard");</tt><tt>
user_pref("capability.policy.allowclipboard.Clipboard.paste",
"allAccess");<br>
</tt>See:
http://www.mozilla.org/editor/midasdemo/securityprefs.html<br>
<br>
note: the shortcut key will automatically trigger this command
(typically
accel-V) with or without the signed JS or any code on the page to
handle it.</td>
</tr>
<tr>
<td style="vertical-align: top;">readonly<br>
</td>
<td style="vertical-align: top;">true<br>
false<br>
</td>
<td style="vertical-align: top;">This command will make the
editor readonly (true) or editable (false). Anticipated usage is
for temporarily disabling input while something else is occurring
elsewhere in the web page.<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">redo<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;">This command will redo the
previous
undo action. If undo was not the most recent action, this command
will
have no effect.<br>
<br>
note: the shortcut key will automatically trigger this command
(typically
accel-shift-Z)</td>
</tr>
<tr>
<td valign="top">removeformat<br>
</td>
<td valign="top">none<br>
</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">selectall<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;">This command will select all of
the
contents within the editable area.<br>
<br>
note: the shortcut key will automatically trigger this command
(typically
accel-A)<br>
</td>
</tr>
<tr>
<td valign="top">strikethrough<br>
</td>
<td valign="top">none<br>
</td>
<td valign="top">If there is no selection, the insertion point
will
set strikethrough for subsequently typed characters. <br>
<br>
If there is a selection and all of the characters are already striked,
the
strikethrough will be removed. Otherwise, all selected characters will
have
a line drawn through them.<br>
</td>
</tr>
<tr>
<td valign="top">subscript<br>
</td>
<td valign="top">none<br>
</td>
<td valign="top">If there is no selection, the insertion point
will
set subscript for subsequently typed characters. <br>
<br>
If there is a selection and all of the characters are already
subscripted,
the subscript will be removed. Otherwise, all selected characters will
be
drawn slightly lower than normal text.<br>
</td>
</tr>
<tr>
<td valign="top">superscript<br>
</td>
<td valign="top">none<br>
</td>
<td valign="top">If there is no selection, the insertion point
will
set superscript for subsequently typed characters. <br>
<br>
If there is a selection and all of the characters are already
superscripted,
the superscript will be removed. Otherwise, all selected characters
will
be drawn slightly higher than normal text<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">underline<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;">If there is no selection, the
insertion
point will set underline for subsequently typed characters. <br>
<br>
If there is a selection and all of the characters are already
underlined,
the underline will be removed. Otherwise, all selected characters will
become
underlined.</td>
</tr>
<tr>
<td style="vertical-align: top;">undo<br>
</td>
<td style="vertical-align: top;">none<br>
</td>
<td style="vertical-align: top;">This command will undo the
previous
action. If no action has occurred in the document, then this
command
will have no effect.<br>
<br>
note: the shortcut key will automatically trigger this command
(typically
accel-Z)<br>
</td>
</tr>
<tr>
<td valign="top">unlink<br>
</td>
<td valign="top">none<br>
</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;">useCSS<br>
</td>
<td style="vertical-align: top;">true<br>
false<br>
</td>
<td style="vertical-align: top;">This command is used for
toggling the format of generated content. By default (at least
today), this is true. An example of the differences is that the
"bold" command will generate <b> if the useCSS command is false
and generate css style attribute if the useCSS command is true.<br>
</td>
</tr>
</tbody>
</table>
<br>
</div>
<br>
</body>
</html>
|