这篇文章需要技术复核。如何帮忙。
我们的志愿者还没有将这篇文章翻译为 中文 (简体)。加入我们帮助完成翻译!
Provides methods and attributes used when editing page content.
28
Introduced
Gecko 1.0
Inherits from:
nsISupports
Last changed in Gecko 18.0 (Firefox 18.0 / Thunderbird 18.0 / SeaMonkey 2.15 / Firefox OS 1.0.1)Method overview
[noscript] void init(in |
void setAttributeOrEquivalent(in |
void removeAttributeOrEquivalent(in |
void postCreate(); |
void preDestroy(in boolean aDestroyingFrames); |
Selected Content Removal |
void deleteSelection(in short action, in short stripWrappers); |
Document Info and File Methods |
void resetModificationCount(); |
long getModificationCount(); |
void incrementModificationCount(in long aModCount); |
void incrementModificationCount(in long aModCount); |
Transaction Methods |
void doTransaction(in |
void enableUndo(in boolean enable); |
void undo(in unsigned long count); |
void canUndo(out boolean isEnabled, out boolean canUndo); |
void redo(in unsigned long count); |
void canRedo(out boolean isEnabled, out boolean canRedo); |
void beginTransaction(); |
void endTransaction(); |
void beginPlaceHolderTransaction(in |
void endPlaceHolderTransaction(); |
boolean shouldTxnSetSelection(); |
void setShouldTxnSetSelection(in boolean should); |
Inline Spellchecking Methods |
|
void syncRealTimeSpell(); |
void setSpellcheckUserOverride(in boolean enable); |
Clipboard Methods |
void cut(); |
boolean canCut(); |
void copy(); |
boolean canCopy(); |
void paste(in long aSelectionType); |
boolean canPaste(in long aSelectionType); |
Selection Methods |
void selectAll(); |
void beginningOfDocument(); |
void endOfDocument(); |
Drag/Drop Methods |
boolean canDrag(in |
void doDrag(in |
void insertFromDrop(in |
Node Manipulation Methods |
void setAttribute(in |
boolean getAttributeValue(in |
void removeAttribute(in |
void cloneAttribute(in AString aAttribute, in |
void cloneAttributes(in |
|
void insertNode(in |
void splitNode(in |
void joinNodes(in |
void deleteNode(in |
void markNodeDirty(in |
Direction Controller |
void switchTextDirection(); |
Output Methods |
Example: // flags are declared in base/public/nsIDocumentEncoder.idl // OutputSelectionOnly = 1, OutputFormatted = 2, // OutputRaw = 4, OutputBodyOnly = 8, // OutputPreformatted = 16, OutputWrap = 32, // OutputFormatFlowed = 64, OutputAbsoluteLinks = 258, // OutputEncodeW3CEntities = 256, OutputCRLineBreak = 512, // OutputLFLineBreak = 1024, OutputNoScriptContent = 2048, // OutputNoFramesContent = 4096, OutputNoFormattingInPre = 8192, // OutputEncodeBasicEntities=16384, OutputEncodeLatin1Entities=32768, // OutputEncodeHTMLEntities=65536, OutputPersistNBSP=131072 editorAPI.outputToString('text/html', 2); editorAPI.outputToString('text/plain', 4); // output the body tag, body children and the html end tag (</html>). // tag name are in lower case with <br>. editorAPI.outputToString('text/html', 8); // XML: all in xml with _moz_dirty="" in new tags, HTML tags are in upper case // application/xhtml+xml format do the same editorAPI.outputToString('text/xml', 2); // the body is not recognized, everything is printed |
void outputToStream(in |
Listener Methods |
void addEditorObserver(in Obsolete since Gecko 18 |
void setEditorObserver(in EditActionListener observer); |
void removeEditorObserver(in |
void addEditActionListener(in |
void removeEditActionListener(in |
void addDocumentStateListener(in |
void removeDocumentStateListener(in |
Debug Methods |
void dumpContentTree(); |
void debugDumpContent() ; |
void debugUnitTests(out long outNumTests, out long outNumTestsFailed); |
[notxpcom] boolean isModifiableNode(in |
Constants
Load Flags
Constant | Value | Description |
eNone |
0 | |
eNext |
1 | |
ePrevious |
2 | |
eNextWord |
3 | |
ePreviousWord |
4 | |
eToBeginningOfLine |
5 | |
eToEndOfLine |
6 |
Attributes
Attribute | Type | Description |
contentsMIMEType |
string |
The MIME type of the document. |
document |
Document |
Read only. The DOM Document this editor is associated with. |
documentCharacterSet |
ACString |
Sets the current 'Save' document character set. |
documentIsEmpty |
boolean |
Read only. Returns true if the document has no *meaningful* content. |
documentModified |
boolean |
Read only. Returns true if the document is modifed and needs saving. |
flags |
unsigned long |
Edit flags for this editor. May be set at any time. |
isDocumentEditable |
PRBool |
Read only. Returns true if we have a document that is not marked read-only. |
isSelectionEditable |
boolean |
Read only. true if the current selection anchor is editable; otherwise false . This helps to support cases where only parts of the document are editable, by letting you see if the current selection is in an editable section. |
rootElement |
|
Read only. The root editable element, which for a document is its body. |
selection |
|
Read only. The selection/caret for this editor. In the case of a design mode document, this is the same as the window's selection. |
selectionController |
|
Read only. The selection controller for the current presentation. |
Methods
Native code only!
init
Initializes the editor's services.
[noscript] void init(
in nsIDOMDocument
doc,
in nsIPresShellPtr shell, Obsolete since Gecko 5
in nsIContent
aRoot,
in nsISelectionController
aSelCon,
in unsigned long aFlags
);
Parameters
-
doc
- The document to observe.
-
shell
Obsolete since Gecko 5.0 -
The
nsIPresShellPtr
representing the presentation shell displaying the document. This parameter was removed in Gecko 5.0 (Firefox 5.0 / Thunderbird 5.0 / SeaMonkey 2.2). -
aRoot
-
The root of the editable section of this document; if it's
null
, the editor gets its root fromdocument.body
. -
aSelCon
-
The
nsISelectionController
object used to get selection location information. This should benull
for HTML editors. -
aFlags
- A bit mask of flags controlling the editor's behavior. Need to document what the possible values are.