nsIEditor 编辑
editor/nsIEditor.idl
Scriptable Provides methods and attributes used when editing page content. 66 Introduced Gecko 1.0 Inherits from: nsISupports
Last changed in Gecko 18.0 (Firefox 18.0 / Thunderbird 18.0 / SeaMonkey 2.15)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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论