mozilla

Revision 137696 of Editor Embedding Guide

  • Revision slug: Editor_Embedding_Guide
  • Revision title: Editor Embedding Guide
  • Revision id: 137696
  • Created:
  • Creator: Cheba
  • Is current revision? No
  • Comment some new formating

Revision Content

{{template.Draft()}}

In the Beginning there is MakeEditable

Given an nsIWebBrowser instance, get a nsIDOMWindow from the GetContentDOMWindow call. Then simply call nsIWebBrowser->do_GetInterface on the nsIWebBrowser to retrieve the </code>nsIEditingSession</code> from it. From there you call editingSession->MakeWindowEditable(domWindow, editortype, PR_TRUE); The first parameter is the nsIDOMWindow you just retrieved, the second is the editor type you want to create and the third is whether you want the window editable immediately or when the document is done loading. In calling this method the editor is created underneath and the event listeners etc. are all prepared.

nsCOMPtr<nsIDOMWindow> domWindow;
nsresult rv = nsIWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
if (NS_FAILED(rv)) return NS_ERROR_FAILURE; // we are not setup??!!

nsCOMPtr<nsIEditingSession> editingSession;
nsIWebBrowser->do_GetInterface(getter_AddRefs(editingSession));
if (editingSession)
  editingSession->MakeWindowEditable(domWindow, "html", PR_TRUE);

The valid editor types are:

  • "text" (similar to NotePad or a textarea; does not allow for html)
  • "textmail" (similar to "text" but html can be inserted; intended for plaintext mail usage and handling of citations)
  • "html" (this is the default type if no type is specified; it allows for all html tags to be inserted)
  • "htmlmail" (this is much like "html" except there are a few editing rules / behaviors that differ such as splitting of mail quotes)

Editor Commands

To do anything meaningful you of course need to call commands and receive updates. First get the nsICommandManager from the nsIWebBrowser using do_GetInterface.

nsCOMPtr<nsICommandManager> commandManager;
nsIWebBrowser->do_GetInterface(getter_AddRefs(commandMgr));

To call a command use DoCommand:

commandManager->DoCommand(aCommand, aCommandParams);

aCommand is a const char * to a supported command name (see list below).
aCommandParams 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)

To see if a command is enabled use IsCommandEnabled

commandManager->IsCommandEnabled(aCommand, retval)

To get the current command state of a given command use GetCommandState:

commandManager->GetCommandState(aCommand,aCommandParams)

Index of Commands and Parameters

cmd_bold

Applies or cacels bold style on selection.

GetCommandState
"state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
DoCommand
no parameters
Example
bold

cmd_italics

Applies or cacels italics style on selection.

GetCommandState
"state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
DoCommand
no parameters
Example
italics

cmd_underline

Applies or cacels underline on selection.

GetCommandState
"state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
DoCommand
no parameters
Example
underline

cmd_tt

Applies or cacels teletype style (monosace font) on selection.

GetCommandState
"state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
DoCommand
no parameters
Example
<tt>teletype</tt>

=== cmd_strikethrough === I've fixed this one. It was cmd_strikethru Toggles strikethrough style on selection.

GetCommandState
"state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
DoCommand
no parameters
Example
strikethrough

cmd_superscript

Toggles superscript style on selection.

GetCommandState
"state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
DoCommand
no parameters
Example
superscript style

cmd_subscript

Toggles subscript style on selection.

GetCommandState
"state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
DoCommand
no parameters
Example
subscript style

cmd_nobreak

Toggles superscript style on selection.

GetCommandState
"state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
DoCommand
no parameters
Example
superscript style
Command cmd_bold, cmd_italics, cmd_underline, cmd_tt, , cmd_superscript, cmd_subscript, cmd_nobreak, cmd_em, cmd_strong, cmd_cite, cmd_abbr, cmd_acronym, cmd_code, cmd_samp, cmd_var
Description acts upon the current selection to apply style

(cmd_tt is fixed width or "teletype" style)

GetCommandState
"state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
DoCommand no parameters
see also cmd_removeStyles


Command
cmd_removeLinks
Description
removes the existing link from the

selection (if any)

GetCommandState
"state_enabled"(boolean)

???

DoCommand
no parameters



</tbody>
Command
cmd_ol, cmd_ul, cmd_dt, cmd_dd
Description
converts selection to appropriate

list or list item; inserts new list if no selection (cmd_ol, cmd_ul)

GetCommandState
"state_enabled"(boolean)

???

DoCommand
no parameters

see also cmd_removeList


Command
cmd_indent, cmd_outdent
Description
indents/outdents the line(s) of the

current selection

GetCommandState
"state_enabled"(boolean)

???

DoCommand
no parameters




Command
cmd_increaseFont, cmd_decreaseFont
Description
acts upon the current selection to

adjust font size (uses <big> and <small> tags).

GetCommandState
"state_enabled"
DoCommand
no parameters



</tbody>
Command
cmd_undo, cmd_redo
Description
undoes/redoes last executed command.

 (only available if txmgr.dll is present)

GetCommandState
"state_enabled"
DoCommand
no parameters



Command
cmd_fontColor
Description
acts upon the current selection to

set the font color

GetCommandState
"state_attribute" (cstring)
DoCommand
"state_attribute" (cstring) **



Command
cmd_backgroundColor
Description
sets the background color of

 the document

GetCommandState
"state_attribute" (cstring)
DoCommand
"state_attribute" (cstring) **



Command
cmd_fontFace
Description
sets the font face for the current

selection

GetCommandState
"state_attribute" (string)
DoCommand
"state_attribute" (cstring or

string)
   "Helvetica, Arial, sans-serif"
   "Times New Roman, Times, serif"
   "Courier New, Courier, monospace"
{{mediawiki.external('any string is acceptable; the above strings should be considered\nexamples or base functionality and in no way imply that this command\nwon\'t handle other fonts')}}




Command
cmd_align
Description
sets the alignment for the lines

contained in the current selection

GetCommandState
"state_attribute" (cstring)
DoCommand
"state_attribute"

(cstring) "left","right","center", "full"???  XXXX




cmd_insertHTML
cmd_insertLinkNoUI
cmd_insertImageNoUI
cmd_insertHR



Command
"cmd_charSet" XXXXX
Description
sets the charset for the document.

there must be a clear undo stack or this will not work

GetCommandState
"state_attribute" (cstring)
DoCommand
"state_attribute" (cstring)  



Command
"cmd_copy", "cmd_delete", "cmd_cut", "cmd_paste", "cmd_cutOrDelete"
Description
operates on the current selection to

copy, delete, cut and paste  respectively

GetCommandState
*"state_enabled" (boolean)
DoCommand
no parameter 



</tbody>
Command
"cmd_deleteCharBackward", "cmd_deleteCharForward",

"cmd_deleteWordForward",
"cmd_deleteWordBackward", "cmd_deleteToBeginningOfLine", "cmd_deleteToEndOfLine",

Description
deletes relative to the current

selection end point.

GetCommandState
*"state_enabled" (boolean)
DoCommand
no parameter 



Command
"cmd_scrollTop", "cmd_scrollBottom", "cmd_scrollPageUp", "cmd_scrollPageDown",

"cmd_selectTop", "cmd_selectBottom", "cmd_selectLineNext", "cmd_selectLinePrevious",
"cmd_selectCharPrevious", "cmd_selectCharNext", "cmd_selectBeginLine", "cmd_selectEndLine",

"cmd_selectWordPrevious", "cmd_selectWordNext", 
Description
scrolls relative to the current

selection end point.

GetCommandState
*"state_enabled" (boolean)
DoCommand
no parameter 



Command
"cmd_movePageUp", "cmd_movePageDown", "cmd_moveTop", "cmd_moveBottom",

"cmd_lineNext", "cmd_linePrevious", "cmd_charPrevious", "cmd_charNext", "cmd_beginLine",

"cmd_endLine", "cmd_wordPrevious", "cmd_wordNext"
Description
scrolls relative to the current

selection end point.

GetCommandState
*"state_enabled" (boolean)
DoCommand
no parameter 


  • Note: GetCommandState in these cases will return whether or not it is possible to call DoCommand. This will not really give you any concrete information on the state of the current indent and outdent .
    • Note: for color values, use the cstring representation of RRGGBB. i.e. RED="#FF0000" and BLACK="#000000"

nsICommandParams

Creating

how do you create an nsICommandParams? -saari

Writing

Once you have created an nsICommandParams you call the "Set" methods.

SetBooleanValue SetLongValue SetDoubleValue SetStringValue SetCStringValue SetISupportsValue RemoveValue

Each will take a name value pair. In the case of SetBooleanValue for example you use a boolean as the second parameter.

   commandParam->SetCStringValue("state_attribute","left");

Reading

For reading you may go after individual name/value pairs you know are there or you may iterate through all the name/value pairs and programatically pull off data.

First GetNext (returns the next name in the name/value pair list) HasMoreElements GetValueType (numeric enum type see nsICommandParams for values)

If the name/value pair is known or it was obtained using the methods described above, it is possible to call the following methods.

GetBooleanValue GetLongValue GetDoubleValue GetStringValue GetCStringValue GetISupportsValue

All of these take pointers to values except for GetStringValue which demands a reference to an nsAString.

commandParam->GetBooleanValue("state_enabled",&boolval);


Original Document Information

Revision Source

<p>{{template.Draft()}}

</p>
<h2 name="In_the_Beginning_there_is_MakeEditable"> In the Beginning there is MakeEditable </h2>
<p>Given an <code>nsIWebBrowser</code> instance, get a <code>nsIDOMWindow</code> from the <code>GetContentDOMWindow</code> call. Then simply call <code>nsIWebBrowser-&gt;do_GetInterface</code> on the <code>nsIWebBrowser</code> to retrieve the &lt;/code&gt;nsIEditingSession&lt;/code&gt; from it. From there you call <code>editingSession-&gt;MakeWindowEditable(domWindow, editortype, PR_TRUE);</code>
The first parameter is the <code>nsIDOMWindow</code> you just retrieved, the second is the editor type you want to create and the third is whether you want the window editable immediately or when the document is done loading. In calling this method the editor is created underneath and the event listeners etc. are all prepared.
</p>
<pre class="eval">nsCOMPtr&lt;nsIDOMWindow&gt; domWindow;
nsresult rv = nsIWebBrowser-&gt;GetContentDOMWindow(getter_AddRefs(domWindow));
if (NS_FAILED(rv)) return NS_ERROR_FAILURE; // we are not setup??!!

nsCOMPtr&lt;nsIEditingSession&gt; editingSession;
nsIWebBrowser-&gt;do_GetInterface(getter_AddRefs(editingSession));
if (editingSession)
  editingSession-&gt;MakeWindowEditable(domWindow, "html", PR_TRUE);
</pre>
<p>The valid editor types are:
</p>
<ul><li> "text" (similar to NotePad or a textarea; does not allow for html)
</li><li> "textmail" (similar to "text" but html can be inserted; intended for plaintext mail usage and handling of citations)
</li><li> "html" (this is the default type if no type is specified; it allows for all html tags to be inserted)
</li><li> "htmlmail" (this is much like "html" except there are a few editing rules / behaviors that differ such as splitting of mail quotes)
</li></ul>
<h2 name="Editor_Commands"> Editor Commands </h2>
<p>To do anything meaningful you of course need to call commands and receive updates. First get the <code>nsICommandManager</code> from the <code>nsIWebBrowser</code> using <code>do_GetInterface</code>.
</p>
<pre class="eval">nsCOMPtr&lt;nsICommandManager&gt; commandManager;
nsIWebBrowser-&gt;do_GetInterface(getter_AddRefs(commandMgr));
</pre>
<p>To call a command use <code>DoCommand</code>:
</p>
<pre class="eval">commandManager-&gt;DoCommand(aCommand, aCommandParams);
</pre>
<p><code>aCommand</code> is a const char * to a supported command name (see list below).<br>
<code>aCommandParams</code> 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 <code>IsCommandEnabled</code>
</p>
<pre class="eval">commandManager-&gt;IsCommandEnabled(aCommand, retval)
</pre>
<p>To get the current command state of a given command use <code>GetCommandState</code>:
</p>
<pre class="eval">commandManager-&gt;GetCommandState(aCommand,aCommandParams)
</pre>
<h3 name="Index_of_Commands_and_Parameters"> Index of Commands and Parameters </h3>
<h4 name="cmd_bold"> cmd_bold </h4>
<p>Applies or cacels bold style on selection.
</p>
<dl><dt> GetCommandState</dt><dd> "state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
</dd><dt> DoCommand</dt><dd> no parameters
</dd><dt> Example</dt><dd> <b>bold</b>
</dd></dl>
<h4 name="cmd_italics"> cmd_italics </h4>
<p>Applies or cacels italics style on selection.
</p>
<dl><dt> GetCommandState</dt><dd> "state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
</dd><dt> DoCommand</dt><dd> no parameters
</dd><dt> Example</dt><dd> <i>italics</i>
</dd></dl>
<h4 name="cmd_underline"> cmd_underline </h4>
<p>Applies or cacels underline on selection.
</p>
<dl><dt> GetCommandState</dt><dd> "state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
</dd><dt> DoCommand</dt><dd> no parameters
</dd><dt> Example</dt><dd> <u>underline</u>
</dd></dl>
<h4 name="cmd_tt"> cmd_tt </h4>
<p>Applies or cacels teletype style (monosace font) on selection.
</p>
<dl><dt> GetCommandState</dt><dd> "state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
</dd><dt> DoCommand</dt><dd> no parameters
</dd><dt> Example</dt><dd> <tt>teletype</tt>
</dd></dl>
<p>=== cmd_strikethrough === <span class="comment">I've fixed this one. It was cmd_strikethru</span>
Toggles strikethrough style on selection.
</p>
<dl><dt> GetCommandState</dt><dd> "state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
</dd><dt> DoCommand</dt><dd> no parameters
</dd><dt> Example</dt><dd> <strike>strikethrough</strike>
</dd></dl>
<h4 name="cmd_superscript"> cmd_superscript </h4>
<p>Toggles superscript style on selection.
</p>
<dl><dt> GetCommandState</dt><dd> "state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
</dd><dt> DoCommand</dt><dd> no parameters
</dd><dt> Example</dt><dd> <sup>superscript</sup> style
</dd></dl>
<h4 name="cmd_subscript"> cmd_subscript </h4>
<p>Toggles subscript style on selection.
</p>
<dl><dt> GetCommandState</dt><dd> "state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
</dd><dt> DoCommand</dt><dd> no parameters
</dd><dt> Example</dt><dd> <sub>subscript</sub> style
</dd></dl>
<h4 name="cmd_nobreak"> cmd_nobreak </h4>
<p>Toggles superscript style on selection.
</p>
<dl><dt> GetCommandState</dt><dd> "state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
</dd><dt> DoCommand</dt><dd> no parameters
</dd><dt> Example</dt><dd> <sup>superscript</sup> style
</dd></dl>
<table border="1" cellpadding="2" cellspacing="2" width="100%">
<tbody><tr>
<td valign="top">Command
      </td>
      <td valign="top" width="75%">cmd_bold, cmd_italics, cmd_underline, cmd_tt, , cmd_superscript, cmd_subscript, cmd_nobreak, cmd_em, cmd_strong, cmd_cite, cmd_abbr, cmd_acronym, cmd_code, cmd_samp, cmd_var
      </td>
    </tr>
    <tr>
      <td valign="top">Description</td>
      <td valign="top" width="75%">acts upon the current selection to apply style<br>
<p>(cmd_tt is fixed width or "teletype" style)
</p>
      </td>
    </tr>
    <tr>
      <td valign="top">GetCommandState<br>
      </td>
      <td valign="top" width="75%">"state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean)
      </td>
    </tr>
    <tr>
      <td valign="top">DoCommand
      </td>
      <td valign="top" width="75%">no parameters
      </td>
    </tr>
    <tr>
      <td valign="top"></td>
      <td valign="top" width="75%">see also cmd_removeStyles
      </td>
    </tr>
</tbody></table>
<p><br>
</p>
<table border="1" cellpadding="2" cellspacing="2" width="100%">
    <tbody><tr>
      <td valign="top">Command<br>
      </td>
      <td valign="top" width="75%">cmd_removeLinks<br>
      </td>

    </tr>
    <tr>
      <td valign="top">Description<br>
      </td>
      <td valign="top" width="75%">removes the existing link from the
<p>selection (if any)<br>
</p>
      </td>
    </tr>
    <tr>

      <td valign="top">GetCommandState<br>
      </td>
      <td valign="top" width="75%">"state_enabled"(boolean)<br>
<p>???<br>
</p>
      </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>

  &lt;/tbody&gt;
<table border="1" cellpadding="2" cellspacing="2" width="100%">
    <tbody><tr>
      <td valign="top">Command<br>
      </td>
      <td valign="top" width="75%">cmd_ol, cmd_ul, cmd_dt, cmd_dd<br>
      </td>
    </tr>
    <tr>
      <td valign="top">Description<br>
      </td>
      <td valign="top" width="75%">converts selection to appropriate
<p>list or list item; inserts new list if no selection (cmd_ol, cmd_ul)<br>
</p>
      </td>
    </tr>
    <tr>
      <td valign="top">GetCommandState<br>
      </td>
      <td valign="top" width="75%">"state_enabled"(boolean)<br>
<p>???<br>
</p>
      </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%">see also cmd_removeList<br>
      </td>
    </tr></tbody></table>
<p><br>
</p>
<table border="1" cellpadding="2" cellspacing="2" 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/outdents the line(s) of the
<p>current selection<br>
</p>
      </td>
    </tr>
    <tr>
      <td valign="top">GetCommandState<br>
      </td>
      <td valign="top" width="75%">"state_enabled"(boolean)<br>
<p>???<br>
</p>
      </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><p><br>
</p>
<table border="1" cellpadding="2" cellspacing="2" 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
<p>adjust font size (uses &lt;big&gt; and &lt;small&gt; tags).<br>
</p>
      </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>

  &lt;/tbody&gt;
<table border="1" cellpadding="2" cellspacing="2" 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.
<p> (only available if txmgr.dll is present)<br>
</p>
      </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 border="1" cellpadding="2" cellspacing="2" 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
<p>set the font color<br>
</p>
      </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 border="1" cellpadding="2" cellspacing="2" 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
<p> the document<br>
</p>
      </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 border="1" cellpadding="2" cellspacing="2" 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
<p>selection<br>
</p>
      </td>
    </tr>

    <tr>
      <td valign="top">GetCommandState<br>
      </td>
      <td valign="top" width="75%">"state_attribute" (string) </td>
    </tr>
    <tr>
      <td valign="top">DoCommand<br>
      </td>
      <td valign="top" width="75%">"state_attribute" (cstring or
<p>string) <br>
   "Helvetica, Arial, sans-serif"<br>
   "Times New Roman, Times, serif"<br>
   "Courier New, Courier, monospace" <br>
{{mediawiki.external('any string is acceptable; the above strings should be considered\nexamples or base functionality and in no way imply that this command\nwon\'t handle other fonts')}}<br>
</p>
      </td>

    </tr>
    <tr>
      <td valign="top"><br>
      </td>
      <td valign="top" width="75%"><br>
      </td>
    </tr>
</tbody></table>
<p><br>
</p>
<table border="1" cellpadding="2" cellspacing="2" 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
<p>contained in the current selection<br>
</p>
      </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"
<p>(cstring) "left","right","center", "full"???  XXXX<br>
</p>
      </td>
    </tr>
    <tr>
      <td valign="top"><br>
      </td>
      <td valign="top" width="75%"><br>
      </td>
    </tr>
</tbody></table>
<p><br>
cmd_insertHTML<br>
cmd_insertLinkNoUI<br>
cmd_insertImageNoUI<br>
cmd_insertHR<br>
</p><p><br>
<br>
</p>
<table border="1" cellpadding="2" cellspacing="2" width="100%">
    <tbody><tr>
      <td valign="top">Command<br>
      </td>
      <td valign="top" width="75%">"cmd_charSet" XXXXX </td>
    </tr>

    <tr>
      <td valign="top">Description<br>
      </td>
      <td valign="top" width="75%">sets the charset for the document.
<p>there must be a clear undo stack or this will not work<br>
</p>
      </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)   </td>

    </tr>
    <tr>
      <td valign="top"><br>
      </td>
      <td valign="top" width="75%"><br>
      </td>
    </tr>
</tbody></table>
<p><br>
</p>
<table border="1" cellpadding="2" cellspacing="2" 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
<p>copy, delete, cut and paste  respectively<br>
</p>
      </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>

  &lt;/tbody&gt;
<table border="1" cellpadding="2" cellspacing="2" width="100%">
    <tbody><tr>
      <td valign="top">Command<br>
      </td>

      <td valign="top" width="75%">"cmd_deleteCharBackward", "cmd_deleteCharForward",
<p>"cmd_deleteWordForward",<br>
"cmd_deleteWordBackward",
"cmd_deleteToBeginningOfLine", "cmd_deleteToEndOfLine",<br>
</p>
      </td>
    </tr>
    <tr>
      <td valign="top">Description<br>
      </td>

      <td valign="top" width="75%">deletes relative to the current
<p>selection end point.<br>
</p>
      </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 border="1" cellpadding="2" cellspacing="2" width="100%">
    <tbody><tr>

      <td valign="top">Command<br>
      </td>
      <td valign="top" width="75%">"cmd_scrollTop", "cmd_scrollBottom", "cmd_scrollPageUp", "cmd_scrollPageDown",<br>
<p>"cmd_selectTop",
"cmd_selectBottom", "cmd_selectLineNext", "cmd_selectLinePrevious",<br>
"cmd_selectCharPrevious",
"cmd_selectCharNext", "cmd_selectBeginLine", "cmd_selectEndLine",<br>
</p>
"cmd_selectWordPrevious", "cmd_selectWordNext", </td>
    </tr>
    <tr>
      <td valign="top">Description<br>
      </td>
      <td valign="top" width="75%">scrolls relative to the current
<p>selection end point.<br>
</p>
      </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 border="1" cellpadding="2" cellspacing="2" width="100%">
    <tbody><tr>
      <td valign="top">Command<br>
      </td>

      <td valign="top" width="75%">"cmd_movePageUp", "cmd_movePageDown", "cmd_moveTop", "cmd_moveBottom",<br>
<p>"cmd_lineNext",
"cmd_linePrevious", "cmd_charPrevious", "cmd_charNext", "cmd_beginLine",<br>
</p>
"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
<p>selection end point.<br>
</p>
      </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>
<ul><li>Note: GetCommandState in these cases will return whether or not it is possible to call DoCommand.  This will not really give you any concrete information on the state of the current indent and outdent .
</li></ul>
<ul><li><ul><li>Note: for color values, use the cstring representation of RRGGBB. i.e. RED="#FF0000" and BLACK="#000000"
</li></ul>
</li></ul>
<h2 name="nsICommandParams"> nsICommandParams </h2>
<h3 name="Creating"> Creating </h3>
<p><i>how do you create an nsICommandParams? -saari</i>
</p>
<h3 name="Writing"> Writing </h3>
<p>Once you have created an nsICommandParams you call the "Set" methods.
</p><p>SetBooleanValue
SetLongValue
SetDoubleValue
SetStringValue
SetCStringValue
SetISupportsValue
RemoveValue
</p><p>Each will take a name value pair.  In the case of SetBooleanValue for example you use a boolean as the second parameter.
</p>
<pre class="eval">   commandParam-&gt;SetCStringValue("state_attribute","left");
</pre>
<h3 name="Reading"> Reading </h3>
<p>For reading you may go after individual name/value pairs you know are
there or you may iterate through all the name/value pairs and
programatically pull off data.
</p><p>First
GetNext (returns the next name in the name/value pair list)
HasMoreElements
GetValueType (numeric enum type see nsICommandParams for values)
</p><p>If the name/value pair is known or it was obtained using the methods
described above, it is possible to call the following methods.
</p><p>GetBooleanValue
GetLongValue
GetDoubleValue
GetStringValue
GetCStringValue
GetISupportsValue
</p><p>All of these take pointers to values except for GetStringValue which
demands a reference to an nsAString.
</p><p>commandParam-&gt;GetBooleanValue("state_enabled",&amp;boolval);
</p><p><br>
</p>
<div class="originaldocinfo">
<h2 name="Original_Document_Information"> Original Document Information </h2>
<ul><li> Authors: Michael Judge (<a class="external" href="mailto:mjudge@netscape.com">mjudge@netscape.com</a>)
</li><li> Contributor: Kathleen Brade (<a class="external" href="mailto:brade@netscape.com">brade@netscape.com</a>)
</li><li> Last Updated Date: March 27, 2003
</li><li> Original Document: <a class="external" href="http://lxr.mozilla.org/mozilla1.8/source/editor/docs/Editor_Embedding_Guide.html">A Guide to Embedding The Gecko Editor</a>
</li></ul>
</div>
Revert to this revision