documentation; not part of a build
This commit is contained in:
Родитель
a8044fd3a0
Коммит
53257c3f39
|
@ -0,0 +1,635 @@
|
|||
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=iso-8859-1">
|
||||
|
||||
<meta name="Author" content="mike judge">
|
||||
|
||||
<meta name="GENERATOR"
|
||||
content="Mozilla/4.7 [en-gb]C-NSCP (WinNT; U) [Netscape]">
|
||||
<title>embeddocs</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><b> A Guide to Embedding The Gecko Editor</b></h1>
|
||||
11/5/02<br>
|
||||
<br>
|
||||
|
||||
<h2>In the Beginning there is MakeEditable</h2>
|
||||
|
||||
<p>Given an nsIWebBrowser instance, get a nsIDOMWindow from the GetContentDOMWindow
|
||||
call. Then simply call nsIWebBrowser->do_GetInterface on the nsIWebBrowser
|
||||
to retrieve the nsIEditingSession from it. From there you call editingSession->MakeWindowEditable(domWindow,
|
||||
PR_TRUE); The first parameter is the nsIDOMWindow you just
|
||||
retrieved and the second is whether you want the window editable or not.
|
||||
In calling this method the editor is created underneath and the event listeners
|
||||
etc. are all prepared.<br>
|
||||
</p>
|
||||
<p><i> nsCOMPtr<nsIDOMWindow> domWindow;<br>
|
||||
nsIWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));</i></p>
|
||||
<p><i> nsCOMPtr<nsIEditingSession> editingSession;<br>
|
||||
nsIWebBrowser->do_GetInterface(getter_AddRefs(editingSession));</i></p>
|
||||
<p><i> editingSession->MakeWindowEditable(domWindow,
|
||||
PR_TRUE);<br>
|
||||
</i> </p>
|
||||
|
||||
<h2>Editor Commands</h2>
|
||||
|
||||
<p>To do anything meaningful you of course need to call commands and<br>
|
||||
recieve updates. First get the nsICommandManager from the nsIWebBrowser<br>
|
||||
using do_GetInterface.</p>
|
||||
|
||||
<p><i> nsCOMPtr<nsICommandManager> commandManager;<br>
|
||||
nsIWebBrowser->do_GetInterface(getter_AddRefs(commandMgr));</i><br>
|
||||
</p>
|
||||
<p>To call a command use DoCommand:</p>
|
||||
|
||||
<p><i> </i><i>commandManager</i><i>->DoCommand(aCommand,
|
||||
aCommandParams);</i> </p>
|
||||
|
||||
<p> <i>aCommand</i> is a const char * to a supported command
|
||||
name (see list below).<br>
|
||||
<i>aCommandParams</i> could possibly be a null pointer
|
||||
or a pointer to a valid structure filled with relative parameters to aCommand.
|
||||
(see list below for legal params)</p>
|
||||
|
||||
<p>To see if a command is enabled use IsCommandEnabled</p>
|
||||
|
||||
<p><i> </i><i>commandManager</i><i>->IsCommandEnabled(aCommand,
|
||||
retval)</i> </p>
|
||||
|
||||
<p>To get the current command state of a given command use GetCommandState:
|
||||
</p>
|
||||
|
||||
<p><i> </i><i>commandManager</i><i>->GetCommandState(aCommand,aCommandParams)</i>
|
||||
<br>
|
||||
</p>
|
||||
|
||||
<h3>Index of Commands and Parameters</h3>
|
||||
|
||||
<table cellpadding="2" cellspacing="2" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">Command<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">cmd_bold, cmd_italics, cmd_underline<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Description<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">acts upon the current selection to apply
|
||||
style<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">GetCommandState<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_all"(boolean), "state_begin"(boolean),<br>
|
||||
"state_end"(boolean), "state_mixed"(boolean) </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">DoCommand<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">no parameters<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
<td valign="top" width="75%"><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><br>
|
||||
</p>
|
||||
|
||||
<table cellpadding="2" cellspacing="2" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">Command<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">cmd_indent, cmd_outdent<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Description<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">indents the line(s) of the current selection<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">GetCommandState<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_enabled"(boolean) </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">DoCommand<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">no parameters<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
<td valign="top" width="75%"><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><br>
|
||||
</p>
|
||||
|
||||
<table cellpadding="2" cellspacing="2" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">Command<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">cmd_increaseFont, cmd_decreaseFont<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Description<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">acts upon the current selection to adjust
|
||||
font size.<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">GetCommandState<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_enabled" </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">DoCommand<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">no parameters<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
<td valign="top" width="75%"><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><br>
|
||||
</p>
|
||||
|
||||
<table cellpadding="2" cellspacing="2" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">Command<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">cmd_undo, cmd_redo<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Description<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">undoes/redoes last executed command.
|
||||
(only availabe if txmgr.dll is present)<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">GetCommandState<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_enabled" </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">DoCommand<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">no parameters<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
<td valign="top" width="75%"><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><br>
|
||||
</p>
|
||||
|
||||
<table cellpadding="2" cellspacing="2" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">Command<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">cmd_fontColor<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Description<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">acts upon the current selection to set
|
||||
the font color<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">GetCommandState<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_attribute" (cstring)<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">DoCommand<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_attribute" (cstring) **<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
<td valign="top" width="75%"><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><br>
|
||||
</p>
|
||||
|
||||
<table cellpadding="2" cellspacing="2" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">Command<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">cmd_backgroundColor<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Description<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">sets the background color of the
|
||||
document<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">GetCommandState<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_attribute" (cstring) </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">DoCommand<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_attribute" (cstring) ** </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
<td valign="top" width="75%"><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><br>
|
||||
</p>
|
||||
|
||||
<table cellpadding="2" cellspacing="2" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">Command<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">cmd_fontFace<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Description<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">sets the font face for the current selection<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">GetCommandState<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_attribute" (cstring) </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">DoCommand<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_attribute" (cstring) *** "Helvetica,
|
||||
Arial, sans-serif", "Times New Roman, Times, serif", "Courier New, Courier,
|
||||
monospace" </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
<td valign="top" width="75%"><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><br>
|
||||
</p>
|
||||
|
||||
<table cellpadding="2" cellspacing="2" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">Command<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">cmd_align<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Description<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">sets the alignment for the lines contained
|
||||
in the current selection<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">GetCommandState<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_attribute" (cstring) </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">DoCommand<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_attribute" (cstring) "left","right","center"
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
<td valign="top" width="75%"><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><br>
|
||||
</p>
|
||||
|
||||
<table cellpadding="2" cellspacing="2" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">Command<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"cmd_charSet" </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Description<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">sets the charset for the document. there
|
||||
must be a clear undo stack or this will not work<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">GetCommandState<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_attribute" (cstring) </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">DoCommand<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"state_attribute" (cstring)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
<td valign="top" width="75%"><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><br>
|
||||
</p>
|
||||
|
||||
<table cellpadding="2" cellspacing="2" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">Command<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"cmd_copy", "cmd_delete", "cmd_cut",
|
||||
"cmd_paste", "cmd_cutOrDelete"</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Description<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">operates on the current selection to
|
||||
copy, delete, cut and paste respectively<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">GetCommandState<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">*"state_enabled" (boolean) </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">DoCommand<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">no parameter </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
<td valign="top" width="75%"><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p></p>
|
||||
|
||||
<p><br>
|
||||
</p>
|
||||
|
||||
<table cellpadding="2" cellspacing="2" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">Command<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"cmd_deleteCharBackward", "cmd_deleteCharForward",
|
||||
"cmd_deleteWordForward",<br>
|
||||
"cmd_deleteWordBackward", "cmd_deleteToBeginningOfLine", "cmd_deleteToEndOfLine",<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Description<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">deletes relative to the current selection
|
||||
end point.<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">GetCommandState<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">*"state_enabled" (boolean) </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">DoCommand<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">no parameter </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
<td valign="top" width="75%"><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><br>
|
||||
</p>
|
||||
|
||||
<table cellpadding="2" cellspacing="2" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">Command<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"cmd_scrollTop", "cmd_scrollBottom", "cmd_scrollPageUp", "cmd_scrollPageDown",<br>
|
||||
"cmd_selectTop", "cmd_selectBottom", "cmd_selectLineNext", "cmd_selectLinePrevious",<br>
|
||||
"cmd_selectCharPrevious", "cmd_selectCharNext", "cmd_selectBeginLine", "cmd_selectEndLine",<br>
|
||||
"cmd_selectWordPrevious", "cmd_selectWordNext", </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Description<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">scrolls relative to the current selection
|
||||
end point.<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">GetCommandState<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">*"state_enabled" (boolean) </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">DoCommand<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">no parameter </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
<td valign="top" width="75%"><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><br>
|
||||
</p>
|
||||
|
||||
<table cellpadding="2" cellspacing="2" border="1" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top">Command<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">"cmd_movePageUp", "cmd_movePageDown", "cmd_moveTop", "cmd_moveBottom",<br>
|
||||
"cmd_lineNext", "cmd_linePrevious", "cmd_charPrevious", "cmd_charNext", "cmd_beginLine",<br>
|
||||
"cmd_endLine", "cmd_wordPrevious", "cmd_wordNext"</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Description<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">scrolls relative to the current selection
|
||||
end point.<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">GetCommandState<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">*"state_enabled" (boolean) </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">DoCommand<br>
|
||||
</td>
|
||||
<td valign="top" width="75%">no parameter </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
<td valign="top" width="75%"><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>*Note: GetCommandState in these cases will return whether or not it is
|
||||
<br>
|
||||
possible to call DoCommand. This will not really give you any concrete
|
||||
<br>
|
||||
information on the state of the current indent and outdent .<br>
|
||||
**Note: for color values, use the cstring representation of RRGGBB. i.e.<br>
|
||||
RED="#FF0000" and BLACK="#000000"<br>
|
||||
***Font Face is a cstring of the following values : "Helvetica, Arial,<br>
|
||||
sans-serif", "Times New Roman, Times, serif", "Courier New, Courier,<br>
|
||||
monospace" </p>
|
||||
|
||||
<h2>nsICommandParams </h2>
|
||||
<h3>Creating:</h3>
|
||||
<i>- how do you create an nsICommandParams? -saari</i><br>
|
||||
<br>
|
||||
<h3>Writing:</h3>
|
||||
Once you have created an nsICommandParams you call the "Set" methods.
|
||||
<p>SetBooleanValue<br>
|
||||
SetLongValue<br>
|
||||
SetDoubleValue<br>
|
||||
SetStringValue<br>
|
||||
SetCStringValue<br>
|
||||
SetISupportsValue<br>
|
||||
RemoveValue</p>
|
||||
|
||||
<p>Each will take a name value pair. In the case of SetBooleanValue
|
||||
for<br>
|
||||
example you use a boolean as the second parameter.</p>
|
||||
|
||||
<p> <i> commandParam->SetCStringValue("state_attribute","left");</i><br>
|
||||
</p>
|
||||
|
||||
<h3>Reading:</h3>
|
||||
For reading you may go after individual name/value pairs you know are<br>
|
||||
there or you may iterate through all the name/value pairs and<br>
|
||||
programatically pull off data.
|
||||
<p>First<br>
|
||||
GetNext (returns the next name in the name/value pair list)<br>
|
||||
HasMoreElements<br>
|
||||
GetValueType (numeric enum type see nsICommandParams for values)</p>
|
||||
|
||||
<p>If the name/value pair is known or it was obtained using the methods<br>
|
||||
described above, it is possible to call the following methods.</p>
|
||||
|
||||
<p>GetBooleanValue<br>
|
||||
GetLongValue<br>
|
||||
GetDoubleValue<br>
|
||||
GetStringValue<br>
|
||||
GetCStringValue<br>
|
||||
GetISupportsValue</p>
|
||||
|
||||
<p>All of these take pointers to values except for GetStringValue which<br>
|
||||
demands a reference to an nsAString.</p>
|
||||
|
||||
<p>commandParam->GetBooleanValue("state_enabled",&boolval);<br>
|
||||
</p>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,439 @@
|
|||
<!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: November 15, 2002<br>
|
||||
<br>
|
||||
Midas is rich text editing controls for a document.<br>
|
||||
<br>
|
||||
|
||||
<h1> Enabling Midas:</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 Midas enabled,
|
||||
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>xxx<br>
|
||||
</blockquote>
|
||||
<br>
|
||||
<h2>queryCommandValue</h2>
|
||||
<blockquote> xxx<br>
|
||||
</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 is untested right now.<br>
|
||||
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: the shortcut key will automatically trigger this command (typically
|
||||
accel-C)<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: the shortcut key will automatically trigger this command (typically
|
||||
accel-X)<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 is untested right now.<br>
|
||||
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">????<br>
|
||||
</td>
|
||||
<td valign="top"><br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">heading<br>
|
||||
</td>
|
||||
<td valign="top">????<br>
|
||||
</td>
|
||||
<td valign="top"><br>
|
||||
</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 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;">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 is disabled for the
|
||||
time being to prevent security exploits.<br>
|
||||
<br>
|
||||
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: the shortcut key will automatically trigger this command (typically
|
||||
accel-V)</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>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
</div>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче