nsIEditor
| IID: | 2f76d0bb-d90d-4454-905e-9b0cc39a701c |
| Inherits From: | nsISupports |
This interface is implemented by the following components:
Constants
| PRInt16 | eNone | = 0 |
| PRInt16 | eNext | = 1 |
| PRInt16 | ePrevious | = 2 |
| PRInt16 | eNextWord | = 3 |
| PRInt16 | ePreviousWord | = 4 |
| PRInt16 | eToBeginningOfLine | = 5 |
| PRInt16 | eToEndOfLine | = 6 |
Properties
char* contentsMIMEType
The MimeType of the document
readonly nsIDOMDocument document
The DOM Document this editor is associated with, refcounted.
ACString documentCharacterSet
readonly PRBool documentIsEmpty
readonly PRBool documentModified
PRUint32 flags
readonly PRBool isDocumentEditable
readonly nsIDOMElement rootElement
The body element, i.e. the root of the editable document.
readonly nsISelection selection
readonly nsISelectionController selectionController
The selection controller for the current presentation, refcounted.
nsITransactionManager transactionManager
TransactionManager Get the transaction manager the editor is using.
Methods
void addDocumentStateListener ( nsIDocumentStateListener listener )
void addEditActionListener ( nsIEditActionListener listener )
void addEditorObserver ( nsIEditorObserver observer )
void beginningOfDocument ( )
void beginPlaceHolderTransaction ( nsIAtom name )
void beginTransaction ( )
PRBool canCopy ( )
PRBool canCut ( )
PRBool canDrag ( nsIDOMEvent event )
PRBool canPaste ( PRInt32 selectionType )
void canRedo ( out PRBool isEnabled , out PRBool canRedo )
void canUndo ( out PRBool isEnabled , out PRBool canUndo )
void cloneAttribute ( AString attribute , nsIDOMNode destNode , nsIDOMNode sourceNode )
void cloneAttributes ( nsIDOMNode destNode , nsIDOMNode sourceNode )
void copy ( )
nsIDOMNode createNode ( AString tag , nsIDOMNode parent , PRInt32 position )
void cut ( )
void debugDumpContent ( )
void debugUnitTests ( out PRInt32 outNumTests , out PRInt32 outNumTestsFailed )
void deleteNode ( nsIDOMNode child )
void deleteSelection ( PRInt16 action )
void doDrag ( nsIDOMEvent event )
void doTransaction ( nsITransaction txn )
void dumpContentTree ( )
void enableUndo ( PRBool enable )
void endOfDocument ( )
void endPlaceHolderTransaction ( )
void endTransaction ( )
PRBool getAttributeValue ( nsIDOMElement element , AString attributestr , out AString resultValue )
nsIInlineSpellChecker getInlineSpellChecker ( PRBool autoCreate )
PRInt32 getModificationCount ( )
void incrementModificationCount ( PRInt32 modCount )
[noscript] void init ( nsIDOMDocument doc , nsIPresShellPtr shell , nsIContent root , nsISelectionController selCon , PRUint32 flags )
void insertFromDrop ( nsIDOMEvent event )
void insertNode ( nsIDOMNode node , nsIDOMNode parent , PRInt32 position )
[notxpcom] PRBool isModifiableNode ( nsIDOMNode node )
void joinNodes ( nsIDOMNode leftNode , nsIDOMNode rightNode , nsIDOMNode parent )
void markNodeDirty ( nsIDOMNode node )
void outputToStream ( nsIOutputStream stream , AString formatType , ACString charsetOverride , PRUint32 flags )
AString outputToString ( AString formatType , PRUint32 flags )
void paste ( PRInt32 selectionType )
void postCreate ( )
void preDestroy ( )
void redo ( PRUint32 count )
void removeAttribute ( nsIDOMElement element , AString attribute )
void removeAttributeOrEquivalent ( nsIDOMElement element , DOMString sourceAttrName , PRBool suppressTransaction )
void removeDocumentStateListener ( nsIDocumentStateListener listener )
void removeEditActionListener ( nsIEditActionListener listener )
void removeEditorObserver ( nsIEditorObserver observer )
void resetModificationCount ( )
void selectAll ( )
void setAttribute ( nsIDOMElement element , AString attributestr , AString attvalue )
void setAttributeOrEquivalent ( nsIDOMElement element , AString sourceAttrName , AString sourceAttrValue , PRBool suppressTransaction )
void setShouldTxnSetSelection ( PRBool should )
void setSpellcheckUserOverride ( PRBool enable )
PRBool shouldTxnSetSelection ( )
void splitNode ( nsIDOMNode existingRightNode , PRInt32 offset , out nsIDOMNode newLeftNode )
void switchTextDirection ( )
void syncRealTimeSpell ( )
void undo ( PRUint32 count )
void addDocumentStateListener ( nsIDocumentStateListener listener )
- Arguments:
- listener
void addEditActionListener ( nsIEditActionListener listener )
- Arguments:
- listener
void addEditorObserver ( nsIEditorObserver observer )
- Arguments:
- observer
void beginPlaceHolderTransaction ( nsIAtom name )
- Arguments:
- name
BeginTransaction is a signal from the caller to the editor that
the caller will execute multiple updates to the content tree
that should be treated as a single logical operation,
in the most efficient way possible.
All transactions executed between a call to beginTransaction and
endTransaction will be undoable as an atomic action.
endTransaction must be called after beginTransaction.
Calls to beginTransaction can be nested, as long as endTransaction
is called once per beginUpdate.
Can we cut? True if the doc is modifiable, and we have a non- collapsed selection.
PRBool canDrag ( nsIDOMEvent event )
CanDrag decides if a drag should be started (for example, based on the current selection and mousepoint).
- Arguments:
- event
PRBool canPaste ( PRInt32 selectionType )
Can we paste? True if the doc is modifiable, and we have pasteable data in the clipboard.
- Arguments:
- selectionType
void canRedo ( out PRBool isEnabled , out PRBool canRedo )
Returns state information about the redo system.
- Arguments:
- isEnabled: [OUT] PR_TRUE if redo is enabled
- canRedo: [OUT] PR_TRUE if at least one transaction is currently ready to be redone.
void canUndo ( out PRBool isEnabled , out PRBool canUndo )
Returns state information about the undo system.
- Arguments:
- isEnabled: [OUT] PR_TRUE if undo is enabled
- canUndo: [OUT] PR_TRUE if at least one transaction is currently ready to be undone.
void cloneAttribute ( AString attribute , nsIDOMNode destNode , nsIDOMNode sourceNode )
CloneAttribute() copies the attribute from the source node to the destination node and delete those not in the source.
The supplied nodes MUST BE ELEMENTS (most callers are working with nodes)
- Arguments:
- attribute: the name of the attribute to copy
- destNode: the destination element to operate on
- sourceNode: the source element to copy attributes from
void cloneAttributes ( nsIDOMNode destNode , nsIDOMNode sourceNode )
CloneAttributes() is similar to nsIDOMNode::cloneNode(), it assures the attribute nodes of the destination are identical with the source node by copying all existing attributes from the source and deleting those not in the source. This is used when the destination node (element) already exists
The supplied nodes MUST BE ELEMENTS (most callers are working with nodes)
- Arguments:
- destNode: the destination element to operate on
- sourceNode: the source element to copy attributes from
Copy the currently selected text, putting it into the OS clipboard What if no text is selected? What about mixed selections? What are the clipboard formats?
nsIDOMNode createNode ( AString tag , nsIDOMNode parent , PRInt32 position )
CreateNode instantiates a new element of type tag and inserts it into parent at position.
- Arguments:
- tag: The type of object to create
- parent: The node to insert the new object into
- position: The place in parent to insert the new node
- Returns:
- The node created. Caller must release aNewNode.
Cut the currently selected text, putting it into the OS clipboard What if no text is selected? What about mixed selections? What are the clipboard formats?
void debugUnitTests ( out PRInt32 outNumTests , out PRInt32 outNumTestsFailed )
- Arguments:
- outNumTests
- outNumTestsFailed
void deleteNode ( nsIDOMNode child )
DeleteNode removes child from parent.
- Arguments:
- child: The node to delete
void deleteSelection ( PRInt16 action )
DeleteSelection removes all nodes in the current selection.
- Arguments:
- action
void doDrag ( nsIDOMEvent event )
DoDrag transfers the relevant data (as appropriate) to a transferable so it can later be dropped.
- Arguments:
- event
void doTransaction ( nsITransaction txn )
DoTransaction() fires a transaction. It is provided here so clients can create their own transactions. If a transaction manager is present, it is used. Otherwise, the transaction is just executed directly.
- Arguments:
- txn: the transaction to execute
void enableUndo ( PRBool enable )
Turn the undo system on or off
- Arguments:
- enable: if PR_TRUE, the undo system is turned on if available if PR_FALSE the undo system is turned off if it was previously on
- Returns:
- if aEnable is PR_TRUE, returns NS_OK if the undo system could be initialized properly if aEnable is PR_FALSE, returns NS_OK.
EndTransaction is a signal to the editor that the caller is
finished updating the content model.
beginUpdate must be called before endTransaction is called.
Calls to beginTransaction can be nested, as long as endTransaction
is called once per beginTransaction.
PRBool getAttributeValue ( nsIDOMElement element , AString attributestr , out AString resultValue )
GetAttributeValue() retrieves the attribute's value for element.
- Arguments:
- element: the content element to operate on
- attributestr
- resultValue: [OUT] the value of attribute. Only valid if resultIsSet is PR_TRUE
- Returns:
- PR_TRUE if aAttribute is set on the current node, PR_FALSE if it is not.
nsIInlineSpellChecker getInlineSpellChecker ( PRBool autoCreate )
Returns the inline spell checker associated with this object. The spell checker is lazily created, so this function may create the object for you during this call.
- Arguments:
- autoCreate: If true, this will create a spell checker object if one does not exist yet for this editor. If false and the object has not been created, this function WILL RETURN NULL.
PRInt32 getModificationCount ( )
Gets the modification count of the document we are editing.
- Returns:
- the modification count of the document being edited. Zero means unchanged.
void incrementModificationCount ( PRInt32 modCount )
Called each time we modify the document. Increments the modification count of the document.
- Arguments:
- modCount: the number of modifications by which to increase or decrease the count
void init ( nsIDOMDocument doc , nsIPresShellPtr shell , nsIContent root , nsISelectionController selCon , PRUint32 flags )
Init is to tell the implementation of nsIEditor to begin its services
- Arguments:
- doc: The dom document interface being observed
- shell
- root: This is the root of the editable section of this document. If it is null then we get root from document body.
- selCon: this should be used to get the selection location
- flags: A bitmask of flags for specifying the behavior of the editor.
void insertFromDrop ( nsIDOMEvent event )
InsertFromDrop looks for a dragsession and inserts the relevant data in response to a drop.
- Arguments:
- event
void insertNode ( nsIDOMNode node , nsIDOMNode parent , PRInt32 position )
InsertNode inserts node into parent at position. No checking is done to verify the legality of the insertion. That is the responsibility of the caller.
- Arguments:
- node: The DOM Node to insert.
- parent: The node to insert the new object into
- position: The place in parent to insert the new node 0=first child, 1=second child, etc. any number > number of current children = last child
[notxpcom] PRBool isModifiableNode ( nsIDOMNode node )
- Arguments:
- node
void joinNodes ( nsIDOMNode leftNode , nsIDOMNode rightNode , nsIDOMNode parent )
JoinNodes() takes 2 nodes and merge their contentchildren.
There is no requirement that the two nodes be of the same type. However, a text node can be merged only with another text node.
- Arguments:
- leftNode: The left node. It will be deleted.
- rightNode: The right node. It will remain after the join.
- parent: The parent of existingRightNode
void markNodeDirty ( nsIDOMNode node )
MarkNodeDirty() sets a special dirty attribute on the node. Usually this will be called immediately after creating a new node.
- Arguments:
- node: The node for which to insert formatting.
void outputToStream ( nsIOutputStream stream , AString formatType , ACString charsetOverride , PRUint32 flags )
- Arguments:
- stream
- formatType
- charsetOverride
- flags
AString outputToString ( AString formatType , PRUint32 flags )
Output methods: formatType is a mime type, like text/plain.
- Arguments:
- formatType
- flags
void paste ( PRInt32 selectionType )
Paste the text in the OS clipboard at the cursor position, replacing the selected text (if any)
- Arguments:
- selectionType
PostCreate should be called after Init, and is the time that the editor tells its documentStateObservers that the document has been created.
PreDestroy is called before the editor goes away, and gives the editor a chance to tell its documentStateObservers that the document is going away.
Redo reverses the effects of the last Undo operation It is provided here so clients need no knowledge of whether the editor has a transaction manager or not. If a transaction manager is present, it is told to redo and the result of the previously undone transaction is reapplied to the document. If no transaction is available for Redo, or if the document has no transaction manager, the Redo request is ignored and an error NS_ERROR_NOT_AVAILABLE is returned.
- Arguments:
- count
void removeAttribute ( nsIDOMElement element , AString attribute )
RemoveAttribute() deletes attribute from the attribute list of element. If attribute is not an attribute of element, nothing is done.
- Arguments:
- element: the content element to operate on
- attribute: the string representation of the attribute to get
void removeAttributeOrEquivalent ( nsIDOMElement element , DOMString sourceAttrName , PRBool suppressTransaction )
- Arguments:
- element
- sourceAttrName
- suppressTransaction
void removeDocumentStateListener ( nsIDocumentStateListener listener )
- Arguments:
- listener
void removeEditActionListener ( nsIEditActionListener listener )
- Arguments:
- listener
void removeEditorObserver ( nsIEditorObserver observer )
- Arguments:
- observer
void resetModificationCount ( )
To be used ONLY when we need to override the doc's modification state (such as when it's saved).
void setAttribute ( nsIDOMElement element , AString attributestr , AString attvalue )
SetAttribute() sets the attribute of element. No checking is done to see if attribute is a legal attribute of the node, or if value is a legal value of attribute.
- Arguments:
- element: the content element to operate on
- attributestr
- attvalue
void setAttributeOrEquivalent ( nsIDOMElement element , AString sourceAttrName , AString sourceAttrValue , PRBool suppressTransaction )
- Arguments:
- element
- sourceAttrName
- sourceAttrValue
- suppressTransaction
void setShouldTxnSetSelection ( PRBool should )
Set the flag that prevents insertElementTxn from changing the selection
- Arguments:
- should: Set false to suppress changing the selection; i.e., before using InsertElement() to insert under element WARNING: You must be very careful to reset back to PR_TRUE after setting PR_FALSE, else selection/caret is trashed for further editing.
void setSpellcheckUserOverride ( PRBool enable )
Called when the user manually overrides the spellchecking state for this editor.
- Arguments:
- enable: The new state of spellchecking in this editor, as requested by the user.
void splitNode ( nsIDOMNode existingRightNode , PRInt32 offset , out nsIDOMNode newLeftNode )
SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes
- Arguments:
- existingRightNode: the node to split. It will become the new node's next sibling.
- offset: the offset of existingRightNode's content|children to do the split at
- newLeftNode: [OUT] the new node resulting from the split, becomes existingRightNode's previous sibling.
Switches the editor element direction; from "Left-to-Right" to "Right-to-Left", and vice versa.
Resyncs spellchecking state (enabled/disabled). This should be called when anything that affects spellchecking state changes, such as the spellcheck attribute value.
Undo reverses the effects of the last Do operation, if Undo is enabled in the editor. It is provided here so clients need no knowledge of whether the editor has a transaction manager or not. If a transaction manager is present, it is told to undo, and the result of that undo is returned. Otherwise, the Undo request is ignored and an error NS_ERROR_NOT_AVAILABLE is returned.
- Arguments:
- count
References
This interface is the type of the following properties:
nsIDOMNSEditableElement.editor, nsIEditorDocShell.editor, nsIMsgCompose.editor
This interface is passed as an argument to the following methods:
nsIEditingSession.setEditorOnControllers, nsIEditorSpellCheck.InitSpellChecker, nsIInlineSpellChecker.init, nsIMsgCompose.initEditor, nsIMsgSend.createAndSendMessage
This interface is returned from the following methods:
nsIEditingSession.getEditorForWindow
Reference documentation is generated from Mozilla's source.
