зеркало из https://github.com/mozilla/pjs.git
636 строки
16 KiB
HTML
636 строки
16 KiB
HTML
<!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>
|