added nsIEditRules.h. Experimental, don't count on this.

This commit is contained in:
buster%netscape.com 1999-03-10 19:46:24 +00:00
parent 9baeaa0952
commit 4d7a29dc92
7 changed files with 106 additions and 12 deletions

View File

@ -21,3 +21,4 @@ nsITextEditor.h
nsEditorCID.h
nsIContextLoader.h
nsIHTMLEditor.h
nsIEditRules.h

View File

@ -27,6 +27,7 @@ EXPORTS = \
nsIEditor.h \
nsIHTMLEditor.h \
nsITextEditor.h \
nsIEditRules.h \
nsEditorCID.h \
$(NULL)

View File

@ -18,11 +18,12 @@
DEPTH=..\..
IGNORE_MANIFEST=1
EXPORTS = \
nsIEditor.h \
EXPORTS = \
nsIEditor.h \
nsITextEditor.h \
nsIHTMLEditor.h \
nsEditorCID.h \
nsIEditRules.h \
nsEditorCID.h \
nsIContextLoader.h \
$(NULL)

View File

@ -0,0 +1,85 @@
/* -*- 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"); 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 nsIEditRules_h__
#define nsIEditRules_h__
#include "nsISupports.h"
#include "nscore.h"
class nsIAtom;
class nsIDOMNode;
class nsIEditor;
class nsIDOMSelection;
#define NS_IEDITRULES_IID \
{/* d64999a0-d255-11d2-86dc-000064657374*/ \
0xd64999a0, 0xd255, 0x11d2, \
{0x86, 0xdc, 0x0, 0x00, 0x64, 0x65, 0x73, 0x74} }
#define NS_IEDITRULESFACTORY_IID \
{ /* f6ab69d0-d255-11d2-86dc-000064657374*/ \
0xf6ab69d0, 0xd255, 0x11d2, \
{ 0x86, 0xdc, 0x0, 0x00, 0x64, 0x65, 0x73, 0x74} }
/** Object that encapsulates content-specific editing rules.
*
* To be a good citizen, edit rules must live by these restrictions:
* 1. All data manipulation is through the editor.
* Content nodes in the document tree must <B>not</B> be manipulated directly.
* Content nodes in document fragments that are not part of the document itself
* may be manipulated at will. Operations on document fragments must <B>not</B>
* go through the editor.
* 2. Selection must not be explicitly set by the rule method.
* Any manipulation of Selection must be done by the editor.
*/
class nsIEditRules : public nsISupports
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IEDITRULES_IID; return iid; }
/** General Initialization of the rules for a content type
* @param aEditor The editor for the document
* @param aNextRule The next rule in the rules chain.
* Should be called if this rules object doesn't handle the request.
*/
NS_IMETHOD Init(nsIEditor *aEditor, nsIEditRules *aNextRule)=0;
/** notification that InsertBreak is about to start.
* @param aSelection The selection where insertion will take place
* @param aCancel [OUT] PR_FALSE if the insert break should continue.
* PR_TRUE if the insert break should be aborted.
*/
NS_IMETHOD WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel)=0;
/** notification that InsertBreak is completed.
* @param aSelection The selection immediately following the insertion of the break.
*/
NS_IMETHOD DidInsertBreak(nsIDOMSelection *aSelection, nsresult aResult)=0;
/** return the tag for the content to be created for the break.
* @param aTag [OUT] the tag used to create the content that represents a break.
*/
NS_IMETHOD GetInsertBreakTag(nsIAtom **aTag)=0;
};
#endif //nsIEditRules_h__

View File

@ -68,6 +68,8 @@ public:
typedef enum {eLTR=0, eRTL=1} Direction;
static nsString& GetTextNodeTag();
static const nsIID& GetIID() { static nsIID iid = NS_IEDITOR_IID; return iid; }
/**
@ -220,11 +222,11 @@ public:
PRBool aNodeToKeepIsFirst)=0;
/**
* The handler for RETURN keys and CTRL-RETURN keys.<br>
* It may enter a character, split a node in the tree, etc.
* @param aCtrlKey was the CtrlKey down?
* Insert a break into the content model.<br>
* The interpretation of a break is up to the rule system:
* it may enter a character, split a node in the tree, etc.
*/
NS_IMETHOD InsertBreak(PRBool aCtrlKey)=0;
NS_IMETHOD InsertBreak()=0;
/** turn the undo system on or off
* @param aEnable if PR_TRUE, the undo system is turned on if it is available
@ -302,6 +304,9 @@ public:
*/
NS_IMETHOD ScrollIntoView(PRBool aScrollToBegin)=0;
/** sets the document selection to the entire contents of the document */
NS_IMETHOD SelectAll()=0;
};
#endif //nsIEditor_h__

View File

@ -54,7 +54,7 @@ public:
NS_IMETHOD RemoveTextProperty(nsIAtom *aProperty)=0;
NS_IMETHOD DeleteSelection(nsIEditor::Direction aDir)=0;
NS_IMETHOD InsertText(const nsString& aStringToInsert)=0;
NS_IMETHOD InsertBreak(PRBool aCtrlKey)=0;
NS_IMETHOD InsertBreak()=0;
NS_IMETHOD EnableUndo(PRBool aEnable)=0;
NS_IMETHOD Undo(PRUint32 aCount)=0;
NS_IMETHOD CanUndo(PRBool &aIsEnabled, PRBool &aCanUndo)=0;

View File

@ -105,11 +105,9 @@ public:
/**
* The handler for the ENTER key.
* Its action depends on the selection at the time.
* It may insert a <BR> or a <P> or activate the properties of the element
* @param aCtrlKey was the CtrlKey down?
* @see nsIEditor::InsertBreak
*/
NS_IMETHOD InsertBreak(PRBool aCtrlKey)=0;
NS_IMETHOD InsertBreak()=0;
/** turn the undo system on or off
* @param aEnable if PR_TRUE, the undo system is turned on if it is available
@ -214,6 +212,9 @@ public:
*/
NS_IMETHOD SelectPrevious(nsIAtom *aIncrement, PRBool aExtendSelection)=0;
/** select the entire contents of the document */
NS_IMETHOD SelectAll()=0;
/** scroll the viewport up (towards the beginning of the document.)
* @param aIncrement the amount to scroll
* legal values are nsIEditor::Line, nsIEditor::Page