diff --git a/editor/public/MANIFEST b/editor/public/MANIFEST
index 6447b0f9762..a191c3de575 100644
--- a/editor/public/MANIFEST
+++ b/editor/public/MANIFEST
@@ -17,5 +17,6 @@
#
nsIEditor.h
+nsITextEditor.h
nsEditorCID.h
nsIContextLoader.h
diff --git a/editor/public/Makefile.in b/editor/public/Makefile.in
index 8172f95a0dd..bed1d37f5fe 100644
--- a/editor/public/Makefile.in
+++ b/editor/public/Makefile.in
@@ -25,6 +25,7 @@ include $(DEPTH)/config/autoconf.mk
EXPORTS = \
nsIContextLoader.h \
nsIEditor.h \
+ nsITextEditor.h \
nsEditorCID.h \
$(NULL)
diff --git a/editor/public/makefile.win b/editor/public/makefile.win
index 80acca2095d..43e8ce0fd30 100644
--- a/editor/public/makefile.win
+++ b/editor/public/makefile.win
@@ -20,6 +20,7 @@ IGNORE_MANIFEST=1
EXPORTS = \
nsIEditor.h \
+ nsITextEditor.h \
nsEditorCID.h \
nsIContextLoader.h \
$(NULL)
diff --git a/editor/public/nsEditorCID.h b/editor/public/nsEditorCID.h
index 911a4055d39..5cc73bf77bd 100644
--- a/editor/public/nsEditorCID.h
+++ b/editor/public/nsEditorCID.h
@@ -5,5 +5,17 @@
0xd3de3431, 0x8a75, 0x11d2, \
{ 0x91, 0x8c, 0x0, 0x80, 0xc8, 0xe4, 0x4d, 0xb5 } }
+#define NS_TEXTEDITOR_CID \
+{/* {bc37c640-c144-11d2-8f4c-006008159b0c}*/ \
+0xbc37c640, 0xc144, 0x11d2, \
+{ 0x8f, 0x4c, 0x0, 0x60, 0x08, 0x15, 0x9b, 0x0c } }
+
+#define NS_HTMLEDITOR_CID \
+{/* {ed0244e0-c144-11d2-8f4c-006008159b0c}*/ \
+0xed0244e0, 0xc144, 0x11d2, \
+{ 0x8f, 0x4c, 0x0, 0x60, 0x08, 0x15, 0x9b, 0x0c } }
+
#endif //NSEDITORCID_H___
+
+
diff --git a/editor/public/nsIEditor.h b/editor/public/nsIEditor.h
index dff4bf9be77..174eac2fd2b 100644
--- a/editor/public/nsIEditor.h
+++ b/editor/public/nsIEditor.h
@@ -38,6 +38,10 @@ Editor interface to outside world
0xe2f4c7f1, 0x864a, 0x11d2, \
{ 0x8f, 0x38, 0x0, 0x60, 0x8, 0x31, 0x1, 0x94 } }
+#define NS_ITEXTEDITORFACTORY_IID \
+{ /* {4a1f5ce0-c1f9-11d2-8f4c-006008159b0c}*/ \
+0x4a1f5ce0, 0xc1f9, 0x11d2, \
+{ 0x8f, 0x4c, 0x0, 0x60, 0x8, 0x15, 0x9b, 0xc } }
class nsIDOMDocument;
class nsIPresShell;
@@ -53,8 +57,6 @@ class nsString;
class nsIEditor : public nsISupports{
public:
- typedef enum {NONE = 0,BOLD = 1,NUMPROPERTIES} Properties;
-
typedef enum {eLTR=0, eRTL=1} Direction;
static const nsIID& IID() { static nsIID iid = NS_IEDITOR_IID; return iid; }
@@ -77,29 +79,6 @@ public:
*/
virtual nsresult GetDocument(nsIDOMDocument **aDoc)=0;
- /**
- * SetProperties() sets the aggregate properties on the current selection
- *
- * @param aProperty An enum that lists the various properties that can be applied, bold, ect.
- * @see Properties
- * NOTE: this is an experimental interface. Since it's really just a shortcut for
- * the caller setting a set of attributes on a set of nodes, this method may be removed.
- * If it's more than just a convenience method (ie, it has logic about what objects in a selection get
- * which attributes) that's a whole other story.
- */
- virtual nsresult SetProperties(Properties aProperties)=0;
-
- /**
- * GetProperties() gets the aggregate properties of the current selection.
- * All object in the current selection are scanned and their attributes are
- * represented in a list of Property object.
- *
- * @param aProperty An enum that will recieve the various properties that can be applied from the current selection.
- * @see nsIEditor::Properties
- * NOTE: this method is experimental, expect it to change.
- */
- virtual nsresult GetProperties(Properties **aProperties)=0;
-
/**
* SetAttribute() sets the attribute of aElement.
* No checking is done to see if aAttribute is a legal attribute of the node,
@@ -137,23 +116,47 @@ public:
const nsString& aAttribute)=0;
/**
- * CreateElement instantiates a new element of type aTag and inserts it into aParent at aPosition.
+ * CreateNode instantiates a new element of type aTag and inserts it into aParent at aPosition.
* @param aTag The type of object to create
* @param aParent The node to insert the new object into
* @param aPosition The place in aParent to insert the new node
*/
- virtual nsresult CreateElement(const nsString& aTag,
- nsIDOMNode * aParent,
- PRInt32 aPosition)=0;
+ virtual nsresult CreateNode(const nsString& aTag,
+ nsIDOMNode * aParent,
+ PRInt32 aPosition)=0;
/**
- * DeleteElement removes aChild from aParent.
+ * InsertNode inserts aNode into aParent at aPosition.
+ * No checking is done to verify the legality of the insertion. That is the
+ * responsibility of the caller.
+ * @param aNode The DOM Node to insert.
+ * @param aParent The node to insert the new object into
+ * @param aPosition The place in aParent to insert the new node
+ */
+ virtual nsresult InsertNode(nsIDOMNode * aNode,
+ nsIDOMNode * aParent,
+ PRInt32 aPosition)=0;
+
+
+ /**
+ * InsertText() Inserts a string at the current location, given by the selection.
+ * If the selection is not collapsed, the selection is deleted and the insertion
+ * takes place at the resulting collapsed selection.
+ *
+ * NOTE: what happens if the string contains a CR?
+ *
+ * @param aString the string to be inserted
+ */
+ virtual nsresult InsertText(const nsString& aStringToInsert)=0;
+
+ /**
+ * DeleteNode removes aChild from aParent.
* If aChild is not a child of aParent, nothing is done and an error is returned.
* @param aChild The node to delete
* @param aParent The parent of aChild
*/
- virtual nsresult DeleteElement(nsIDOMNode * aParent,
- nsIDOMNode * aChild)=0;
+ virtual nsresult DeleteNode(nsIDOMNode * aParent,
+ nsIDOMNode * aChild)=0;
/**
* DeleteSelection removes all nodes in the current selection.
@@ -188,25 +191,12 @@ public:
nsIDOMNode *aParent,
PRBool aNodeToKeepIsFirst)=0;
-
/**
- * InsertText() Inserts a string at the current location, given by the selection.
- * If the selection is not collapsed, the selection is deleted and the insertion
- * takes place at the resulting collapsed selection.
- *
- * NOTE: what happens if the string contains a CR?
- *
- * @param aString the string to be inserted
- */
- virtual nsresult InsertText(const nsString& aStringToInsert)=0;
-
- /**
- * Commit(PRBool aCtrlKey) is a catch all method. It may be depricated later.
- *
It is to respond to RETURN keys and CTRL return keys. Its action depends
- * on the selection at the time. It may insert a
or a
or activate the properties of the element
+ * The handler for RETURN keys and CTRL-RETURN keys.
+ * It may enter a character, split a node in the tree, etc.
* @param aCtrlKey was the CtrlKey down?
*/
- virtual nsresult Commit(PRBool aCtrlKey)=0;
+ virtual nsresult InsertBreak(PRBool aCtrlKey)=0;
/** turn the undo system on or off
* @param aEnable if PR_TRUE, the undo system is turned on if it is available
@@ -255,20 +245,21 @@ public:
*/
virtual nsresult CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo)=0;
- /** BeginUpdate is a signal from the caller to the editor that the caller will execute multiple updates
- * to the content tree that should be treated in the most efficient way possible.
- * All transactions executed between a call to BeginUpdate and EndUpdate will be undoable as
- * an atomic action.
- * EndUpdate must be called after BeginUpdate.
- * Calls to BeginUpdate can be nested, as long as EndUpdate is called once per BeginUpdate.
+ /** 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.
*/
- virtual nsresult BeginUpdate()=0;
+ virtual nsresult BeginTransaction()=0;
- /** EndUpdate is a signal to the editor that the caller is finished updating the content model.
- * BeginUpdate must be called before EndUpdate is called.
- * Calls to BeginUpdate can be nested, as long as EndUpdate is called once per BeginUpdate.
+ /** 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.
*/
- virtual nsresult EndUpdate()=0;
+ virtual nsresult EndTransaction()=0;
};
diff --git a/editor/public/nsITextEditor.h b/editor/public/nsITextEditor.h
new file mode 100644
index 00000000000..df35be7b428
--- /dev/null
+++ b/editor/public/nsITextEditor.h
@@ -0,0 +1,256 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL")=0; you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+
+#ifndef nsITextEditor_h__
+#define nsITextEditor_h__
+
+#define NS_ITEXTEDITOR_IID \
+{/* afe65c90-bb82-11d2-86d8-000064657374*/ \
+0xafe65c90, 0xbb82, 0x11d2, \
+{0x8f, 0xd8, 0x0, 0x00, 0x64, 0x65, 0x73, 0x74} }
+
+#include "nsIEditor.h"
+#include "nscore.h"
+
+class nsIEditorCallback;
+class nsVoidArray;
+class nsIAtom;
+class nsIInputStream;
+class nsIOutputStream;
+
+/**
+ * The general text editor interface.
+ *
+ * Use to edit text represented as a DOM tree.
+ * This interface is used for both plain text and rich text (attributed text).
+ * Different types of text fields are instantiated as a result of installing the
+ * proper GUI Manager and Edit Rules. For example,
+ * a single line plain text editor is instantiated by using the SingleLinePlainTextGUIManager
+ * to limit UI and the SingleLinePlainTextEditRules to filter input and output.
+ */
+class nsITextEditor : public nsISupports{
+public:
+ typedef enum {ePlainText=0, eRichText=1} TextType;
+ typedef enum {eSingleLine=0, eMultipleLines=1, ePassword=2} EditorType;
+
+ static const nsIID& IID() { static nsIID iid = NS_ITEXTEDITOR_IID; return iid; }
+
+ /** Initialize the text editor
+ *
+ */
+ virtual nsresult InitTextEditor(nsIDOMDocument *aDoc,
+ nsIPresShell *aPresShell,
+ nsIEditorCallback *aCallback=nsnull)=0;
+
+ /**
+ * SetTextProperties() sets the aggregate properties on the current selection
+ *
+ * @param aProperty
+ */
+ virtual nsresult SetTextProperties(nsVoidArray *aPropList)=0;
+
+ /**
+ * GetTextProperties() gets the aggregate properties of the current selection.
+ * All object in the current selection are scanned and their attributes are
+ * represented in a list of Property object.
+ *
+ * @param aProperty An enum that will recieve the various properties that can be applied from the current selection.
+ * @see nsIEditor::Properties
+ * NOTE: this method is experimental, expect it to change.
+ */
+ virtual nsresult GetTextProperties(nsVoidArray *aPropList)=0;
+
+ /**
+ * RemoveTextProperties() deletes the properties from all text in the current selection.
+ * If aProperty is not set on the selection, nothing is done.
+ *
+ * @param aElement the content element to operate on
+ * @param aAttribute the string representation of the attribute to get
+ */
+ virtual nsresult RemoveTextProperties(nsVoidArray *aPropList)=0;
+
+ /**
+ * DeleteSelection removes all nodes in the current selection.
+ * @param aDir if eLTR, delete to the right (for example, the DEL key)
+ * if eRTL, delete to the left (for example, the BACKSPACE key)
+ */
+ virtual nsresult DeleteSelection(nsIEditor::Direction aDir)=0;
+
+ /**
+ * InsertText() Inserts a string at the current location, given by the selection.
+ * If the selection is not collapsed, the selection is deleted and the insertion
+ * takes place at the resulting collapsed selection.
+ * It is expected that this would be used for Paste.
+ *
+ * NOTE: what happens if the string contains a CR?
+ *
+ * @param aString the string to be inserted
+ */
+ virtual nsresult InsertText(const nsString& aStringToInsert)=0;
+
+ /**
+ * The handler for the ENTER key.
+ * Its action depends on the selection at the time.
+ * It may insert a
or a
or activate the properties of the element
+ * @param aCtrlKey was the CtrlKey down?
+ */
+ virtual nsresult InsertBreak(PRBool aCtrlKey)=0;
+
+ /** turn the undo system on or off
+ * @param aEnable if PR_TRUE, the undo system is turned on if it is available
+ * if PR_FALSE the undo system is turned off if it was previously on
+ * @return if aEnable is PR_TRUE, returns NS_OK if the undo system could be initialized properly
+ * if aEnable is PR_FALSE, returns NS_OK.
+ */
+ virtual nsresult EnableUndo(PRBool aEnable)=0;
+
+ /** 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.
+ *
+ */
+ virtual nsresult Undo(PRUint32 aCount)=0;
+
+ /** returns state information about the undo system.
+ * @param aIsEnabled [OUT] PR_TRUE if undo is enabled
+ * @param aCanUndo [OUT] PR_TRUE if at least one transaction is currently ready to be undone.
+ */
+ virtual nsresult CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo)=0;
+
+ /** 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.
+ *
+ */
+ virtual nsresult Redo(PRUint32 aCount)=0;
+
+ /** returns state information about the redo system.
+ * @param aIsEnabled [OUT] PR_TRUE if redo is enabled
+ * @param aCanRedo [OUT] PR_TRUE if at least one transaction is currently ready to be redone.
+ */
+ virtual nsresult CanRedo(PRBool &aIsEnabled, PRBool &aCanRedo)=0;
+
+ /** BeginTransaction is a signal to the editor that the caller will execute multiple updates
+ * to the content tree that should be treated as a single 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 BeginTransaction.
+ */
+ virtual nsresult BeginTransaction()=0;
+
+ /** EndTransaction is a signal to the editor that the caller is finished updating the content model.
+ * BeginTransaction must be called before EndTransaction is called.
+ * Calls to BeginTransaction can be nested, as long as EndTransaction is called once per BeginTransaction.
+ */
+ virtual nsresult EndTransaction()=0;
+
+/* the following methods are the convenience methods to make text editing easy for the embedding App
+ * all simple getter and setter methods use Get/Set/RemoveProperties
+ * we're looking for a balance between convenience and API bloat, since many of these actions can be
+ * achieved in other ways.
+ */
+
+// Selection and navigation -- exposed here for convenience
+
+ /** move the selection up (towards the beginning of the document.)
+ * @param aIncrement the amount to move the Selection
+ * legal values are nsIEditor::Line, nsIEditor::Page
+ */
+ virtual nsresult MoveSelectionUp(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
+
+ /** move the selection down (towards the end of the document.)
+ * @param aIncrement the amount to move the Selection
+ * legal values are nsIEditor::Line, nsIEditor::Page
+ */
+ virtual nsresult MoveSelectionDown(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
+
+ /** move the selection by some increment.
+ * The dir attribute for the document is used to decide if "next" is LTR or RTL
+ * @param aIncrement the amount to move the Selection
+ * legal values are nsIEditor::Word, nsIEditor::Sentence, nsIEditor::Paragraph
+ * @param aExtendSelection
+ */
+ virtual nsresult MoveSelectionNext(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
+
+ virtual nsresult MoveSelectionPrevious(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
+
+ /** select the next portion of the document
+ * The dir attribute for the document is used to decide if "next" is LTR or RTL
+ * @param aType the kind of selection to create.
+ * legal values are nsIEditor::Word, nsIEditor::Sentence, nsIEditor::Paragraph
+ * nsIEditor::Document
+ * @param aExtendSelection
+ */
+ virtual nsresult SelectNext(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
+
+ /** select the previous portion of the document
+ * The dir attribute for the document is used to decide if "next" is LTR or RTL
+ * @param aType the kind of selection to create.
+ * legal values are nsIEditor::Word, nsIEditor::Sentence, nsIEditor::Paragraph
+ * nsIEditor::Document
+ * @param aExtendSelection
+ */
+ virtual nsresult SelectPrevious(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
+
+ /** scroll the viewport up (towards the beginning of the document.)
+ * @param aIncrement the amount to scroll
+ * legal values are nsIEditor::Line, nsIEditor::Page
+ */
+ virtual nsresult ScrollUp(nsIAtom *aIncrement)=0;
+
+ /** scroll the viewport down (towards the end of the document.)
+ * @param aIncrement the amount to scroll
+ * legal values are nsIEditor::Line, nsIEditor::Page
+ */
+ virtual nsresult ScrollDown(nsIAtom *aIncrement)=0;
+
+ /** scroll the viewport so the selection is in view.
+ * @param aScrollToBegin PR_TRUE if the beginning of the selection is to be scrolled into view.
+ * PR_FALSE if the end of the selection is to be scrolled into view
+ */
+ virtual nsresult ScrollIntoView(PRBool aScrollToBegin)=0;
+
+// Input/Output
+ // nsString will be a stream, as soon as I can figure out what kind of stream we should be using
+ virtual nsresult Insert(nsIInputStream *aInputStream)=0;
+ virtual nsresult OutputText(nsIOutputStream *aOutputStream)=0;
+ virtual nsresult OutputHTML(nsIOutputStream *aOutputStream)=0;
+
+// Miscellaneous Methods
+ /*
+ virtual nsresult CheckSpelling()=0;
+ virtual nsresult SpellingLanguage(nsIAtom *aLanguage)=0;
+ */
+ /* The editor doesn't know anything about specific services like SpellChecking.
+ * Services can be invoked on the content, and these services can use the editor if they choose
+ * to get transactioning/undo/redo.
+ * For things like auto-spellcheck, the App should implement nsIDocumentObserver and
+ * trigger off of ContentChanged notifications.
+ */
+
+};
+
+#endif //nsIEditor_h__
+