Added support for prefs and string bundles for editor, various bug fixes, preliminary Horizontal Line dialog work
git-svn-id: svn://10.0.0.236/trunk@34343 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
9ee8cd5583
commit
5cc87fa56e
@ -67,8 +67,6 @@ CPPSRCS = \
|
||||
|
||||
MODULE = editor
|
||||
|
||||
REQUIRES = xpcom raptor dom base netlib
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@ -102,18 +102,6 @@ CPP_OBJS = \
|
||||
|
||||
MODULE=editor
|
||||
|
||||
REQUIRES=xpcom raptor dom base netlib pref
|
||||
|
||||
LINCS=-I$(PUBLIC)\editor \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\js \
|
||||
-I$(PUBLIC)\pref \
|
||||
-I$(PUBLIC)\txmgr \
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\pref \
|
||||
-I$(PUBLIC)\dom
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = ender
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
@ -129,6 +117,7 @@ LLIBS= \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(DIST)\lib\raptorhtmlpars.lib \
|
||||
$(DIST)\lib\raptorwidget_s.lib \
|
||||
$(DIST)\lib\netlib.lib \
|
||||
$(LIBNSPR)
|
||||
!if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE)
|
||||
LLIBS=$(LLIBS) $(GLOWDIR)\glowcode.lib
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
|
||||
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsILocale.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsIEditProperty.h" // to be removed XXX
|
||||
#include "nsIDOMText.h"
|
||||
@ -46,7 +48,6 @@
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsICaret.h"
|
||||
#include "nsIStyleContext.h"
|
||||
|
||||
#include "nsIEditActionListener.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
@ -111,13 +112,14 @@ static NS_DEFINE_IID(kJoinElementTxnIID, JOIN_ELEMENT_TXN_IID);
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID);
|
||||
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
// factory classes
|
||||
static NS_DEFINE_IID(kIEditFactoryIID, NS_IEDITORFACTORY_IID);
|
||||
static NS_DEFINE_IID(kIHTMLEditFactoryIID, NS_IHTMLEDITORFACTORY_IID);
|
||||
static NS_DEFINE_IID(kITextEditFactoryIID, NS_ITEXTEDITORFACTORY_IID);
|
||||
|
||||
|
||||
#ifdef XP_PC
|
||||
#define TRANSACTION_MANAGER_DLL "txmgr.dll"
|
||||
#else
|
||||
@ -131,6 +133,8 @@ static NS_DEFINE_IID(kITextEditFactoryIID, NS_ITEXTEDITORFACTORY_IID);
|
||||
#define NS_ERROR_EDITOR_NO_SELECTION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,1)
|
||||
#define NS_ERROR_EDITOR_NO_TEXTNODE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,2)
|
||||
|
||||
#define EDITOR_BUNDLE_URL "resource:/res/editor.properties"
|
||||
|
||||
const char* nsEditor::kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE";
|
||||
const char* nsEditor::kMOZEditorBogusNodeValue="TRUE";
|
||||
|
||||
@ -294,7 +298,7 @@ nsEditor::nsEditor()
|
||||
gInstanceCount++;
|
||||
mActionListeners = 0;
|
||||
PR_ExitMonitor(getEditorMonitor());
|
||||
|
||||
mPrefs = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -315,6 +319,10 @@ nsEditor::~nsEditor()
|
||||
delete mActionListeners;
|
||||
mActionListeners = 0;
|
||||
}
|
||||
|
||||
// Release service pointers
|
||||
if (mPrefs)
|
||||
nsServiceManager::ReleaseService(kPrefCID, mPrefs);
|
||||
}
|
||||
|
||||
|
||||
@ -456,6 +464,51 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell)
|
||||
caret->SetCaretVisible(PR_TRUE);
|
||||
caret->SetCaretReadOnly(PR_FALSE);
|
||||
}
|
||||
// NOTE: We don't fail if we can't get prefs or string bundles
|
||||
// since we could still be used as the text edit widget without prefs
|
||||
|
||||
// Get the prefs service (Note: can't use nsCOMPtr for service pointers)
|
||||
nsresult result = nsServiceManager::GetService(kPrefCID,
|
||||
nsIPref::GetIID(),
|
||||
(nsISupports**)&mPrefs);
|
||||
if (NS_FAILED(result) || !mPrefs)
|
||||
{
|
||||
printf("ERROR: Failed to get Prefs Service instance.\n");
|
||||
}
|
||||
// TODO: Cache basic preferences?
|
||||
// Register callbacks for preferences that we need to
|
||||
// respond to while running
|
||||
|
||||
nsIStringBundleService* service;
|
||||
result = nsServiceManager::GetService(kStringBundleServiceCID,
|
||||
nsIStringBundleService::GetIID(),
|
||||
(nsISupports**)&service);
|
||||
|
||||
if (NS_SUCCEEDED(result) && service)
|
||||
{
|
||||
nsCOMPtr<nsIURL> url;
|
||||
result = NS_NewURL(getter_AddRefs(url), nsString(EDITOR_BUNDLE_URL));
|
||||
|
||||
if (NS_SUCCEEDED(result) && url)
|
||||
{
|
||||
nsILocale* locale = nsnull;
|
||||
result = service->CreateBundle(url, locale, getter_AddRefs(mStringBundle));
|
||||
if (NS_FAILED(result))
|
||||
printf("ERROR: Failed to get Create StringBundle\n");
|
||||
|
||||
} else {
|
||||
printf("ERROR: Failed to get create URL for StringBundle\n");
|
||||
}
|
||||
// We don't need to keep service around once we created the bundle
|
||||
nsServiceManager::ReleaseService(kStringBundleServiceCID, service);
|
||||
} else {
|
||||
printf("ERROR: Failed to get StringBundle Service instance.\n");
|
||||
}
|
||||
/*
|
||||
Example of getting a string:
|
||||
nsString value;
|
||||
ret = mStringBundle->GetStringFromName("editor.foo", value);
|
||||
*/
|
||||
|
||||
mPresShell->SetCaretEnabled(PR_TRUE);
|
||||
|
||||
@ -3748,6 +3801,18 @@ nsEditor::JoinNodeDeep(nsIDOMNode *aLeftNode,
|
||||
return res;
|
||||
}
|
||||
|
||||
// Get a string from the localized string resources
|
||||
nsresult nsEditor::GetString(const nsString& name, nsString& value)
|
||||
{
|
||||
nsresult result = NS_ERROR_NOT_INITIALIZED;
|
||||
value = "";
|
||||
if (mStringBundle && (name != ""))
|
||||
{
|
||||
result = mStringBundle->GetStringFromName(name, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* nsAutoSelectionReset
|
||||
*****************************************************************************/
|
||||
@ -3776,6 +3841,3 @@ nsAutoSelectionReset::~nsAutoSelectionReset()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -27,10 +27,10 @@
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "TransactionFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsIEditActionListener;
|
||||
class nsIDOMCharacterData;
|
||||
@ -48,6 +48,10 @@ class JoinElementTxn;
|
||||
class EditAggregateTxn;
|
||||
class nsVoidArray;
|
||||
class nsISupportsArray;
|
||||
class nsIPref;
|
||||
class nsIStringBundleService;
|
||||
class nsIStringBundle;
|
||||
class nsILocale;
|
||||
|
||||
//This is the monitor for the editor.
|
||||
PRMonitor *getEditorMonitor();
|
||||
@ -72,9 +76,12 @@ private:
|
||||
static PRInt32 gInstanceCount;
|
||||
|
||||
nsVoidArray *mActionListeners;
|
||||
nsCOMPtr<nsIStringBundle> mStringBundle;
|
||||
|
||||
protected:
|
||||
nsIDOMDocument * mDoc;
|
||||
// Services are not nsCOMPtr friendly
|
||||
nsIPref* mPrefs;
|
||||
|
||||
public:
|
||||
|
||||
@ -494,7 +501,7 @@ public:
|
||||
static nsCOMPtr<nsIDOMNode> NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir);
|
||||
static nsresult GetStartNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr<nsIDOMNode> *outStartNode, PRInt32 *outStartOffset);
|
||||
static nsresult GetEndNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr<nsIDOMNode> *outEndNode, PRInt32 *outEndOffset);
|
||||
|
||||
|
||||
nsresult IsPreformatted(nsIDOMNode *aNode, PRBool *aResult);
|
||||
nsresult IsNextCharWhitespace(nsIDOMNode *aParentNode, PRInt32 aOffset, PRBool *aResult);
|
||||
nsresult IsPrevCharWhitespace(nsIDOMNode *aParentNode, PRInt32 aOffset, PRBool *aResult);
|
||||
@ -502,6 +509,7 @@ public:
|
||||
nsresult SplitNodeDeep(nsIDOMNode *aNode, nsIDOMNode *aSplitPointParent, PRInt32 aSplitPointOffset);
|
||||
nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMSelection *aSelection);
|
||||
|
||||
nsresult GetString(const nsString& name, nsString& value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1809,13 +1809,13 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
|
||||
|
||||
if (aTagName == "" || !aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
|
||||
nsAutoString TagName = aTagName;
|
||||
TagName.ToLowerCase();
|
||||
nsAutoString realTagName;
|
||||
|
||||
PRBool isHREF = (TagName == "href");
|
||||
PRBool isAnchor = (TagName == "anchor");
|
||||
PRBool isHREF = (TagName.Equals("href"));
|
||||
PRBool isAnchor = (TagName.Equals("anchor"));
|
||||
if (isHREF || isAnchor)
|
||||
{
|
||||
realTagName = "a";
|
||||
@ -1836,16 +1836,20 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
|
||||
// ATTRIBUTES SAVED IN PREFS?
|
||||
if (isAnchor)
|
||||
{
|
||||
|
||||
// TODO: Get the text of the selection and build a suggested Name
|
||||
// Replace spaces with "_"
|
||||
} else if (TagName.Equals("hr"))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// ADD OTHER DEFAULT ATTRIBUTES HERE
|
||||
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
*aReturn = newElement;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -1876,15 +1880,12 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection, ns
|
||||
}
|
||||
}
|
||||
|
||||
DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode);
|
||||
res = DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode);
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> newNode = do_QueryInterface(aElement);
|
||||
|
||||
res = InsertNode(aElement, parentSelectedNode, offsetOfNewNode);
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -2164,8 +2165,19 @@ NS_IMETHODIMP nsHTMLEditor::GetLocalFileURL(nsIDOMWindow* aParent, const nsStrin
|
||||
|
||||
|
||||
nsCOMPtr<nsIFileWidget> fileWidget;
|
||||
// TODO: WHERE TO WE PUT GLOBAL STRINGS TO BE LOCALIZED?
|
||||
nsString title(htmlFilter ? "Open HTML file" : "Select Image File");
|
||||
nsAutoString title("");
|
||||
|
||||
// Get strings from editor resource bundle
|
||||
nsString name;
|
||||
if (htmlFilter)
|
||||
{
|
||||
name = "OpenHTMLFile";
|
||||
} else if (imgFilter)
|
||||
{
|
||||
name = "SelectImageFile";
|
||||
}
|
||||
GetString(name, title);
|
||||
|
||||
nsFileSpec fileSpec;
|
||||
// TODO: GET THE DEFAULT DIRECTORY FOR DIFFERENT TYPES FROM PREFERENCES
|
||||
nsFileSpec aDisplayDirectory;
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
|
||||
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsILocale.h"
|
||||
#include "nsEditor.h"
|
||||
#include "nsIEditProperty.h" // to be removed XXX
|
||||
#include "nsIDOMText.h"
|
||||
@ -46,7 +48,6 @@
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsICaret.h"
|
||||
#include "nsIStyleContext.h"
|
||||
|
||||
#include "nsIEditActionListener.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
@ -111,13 +112,14 @@ static NS_DEFINE_IID(kJoinElementTxnIID, JOIN_ELEMENT_TXN_IID);
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID);
|
||||
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
// factory classes
|
||||
static NS_DEFINE_IID(kIEditFactoryIID, NS_IEDITORFACTORY_IID);
|
||||
static NS_DEFINE_IID(kIHTMLEditFactoryIID, NS_IHTMLEDITORFACTORY_IID);
|
||||
static NS_DEFINE_IID(kITextEditFactoryIID, NS_ITEXTEDITORFACTORY_IID);
|
||||
|
||||
|
||||
#ifdef XP_PC
|
||||
#define TRANSACTION_MANAGER_DLL "txmgr.dll"
|
||||
#else
|
||||
@ -131,6 +133,8 @@ static NS_DEFINE_IID(kITextEditFactoryIID, NS_ITEXTEDITORFACTORY_IID);
|
||||
#define NS_ERROR_EDITOR_NO_SELECTION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,1)
|
||||
#define NS_ERROR_EDITOR_NO_TEXTNODE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,2)
|
||||
|
||||
#define EDITOR_BUNDLE_URL "resource:/res/editor.properties"
|
||||
|
||||
const char* nsEditor::kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE";
|
||||
const char* nsEditor::kMOZEditorBogusNodeValue="TRUE";
|
||||
|
||||
@ -294,7 +298,7 @@ nsEditor::nsEditor()
|
||||
gInstanceCount++;
|
||||
mActionListeners = 0;
|
||||
PR_ExitMonitor(getEditorMonitor());
|
||||
|
||||
mPrefs = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -315,6 +319,10 @@ nsEditor::~nsEditor()
|
||||
delete mActionListeners;
|
||||
mActionListeners = 0;
|
||||
}
|
||||
|
||||
// Release service pointers
|
||||
if (mPrefs)
|
||||
nsServiceManager::ReleaseService(kPrefCID, mPrefs);
|
||||
}
|
||||
|
||||
|
||||
@ -456,6 +464,51 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell)
|
||||
caret->SetCaretVisible(PR_TRUE);
|
||||
caret->SetCaretReadOnly(PR_FALSE);
|
||||
}
|
||||
// NOTE: We don't fail if we can't get prefs or string bundles
|
||||
// since we could still be used as the text edit widget without prefs
|
||||
|
||||
// Get the prefs service (Note: can't use nsCOMPtr for service pointers)
|
||||
nsresult result = nsServiceManager::GetService(kPrefCID,
|
||||
nsIPref::GetIID(),
|
||||
(nsISupports**)&mPrefs);
|
||||
if (NS_FAILED(result) || !mPrefs)
|
||||
{
|
||||
printf("ERROR: Failed to get Prefs Service instance.\n");
|
||||
}
|
||||
// TODO: Cache basic preferences?
|
||||
// Register callbacks for preferences that we need to
|
||||
// respond to while running
|
||||
|
||||
nsIStringBundleService* service;
|
||||
result = nsServiceManager::GetService(kStringBundleServiceCID,
|
||||
nsIStringBundleService::GetIID(),
|
||||
(nsISupports**)&service);
|
||||
|
||||
if (NS_SUCCEEDED(result) && service)
|
||||
{
|
||||
nsCOMPtr<nsIURL> url;
|
||||
result = NS_NewURL(getter_AddRefs(url), nsString(EDITOR_BUNDLE_URL));
|
||||
|
||||
if (NS_SUCCEEDED(result) && url)
|
||||
{
|
||||
nsILocale* locale = nsnull;
|
||||
result = service->CreateBundle(url, locale, getter_AddRefs(mStringBundle));
|
||||
if (NS_FAILED(result))
|
||||
printf("ERROR: Failed to get Create StringBundle\n");
|
||||
|
||||
} else {
|
||||
printf("ERROR: Failed to get create URL for StringBundle\n");
|
||||
}
|
||||
// We don't need to keep service around once we created the bundle
|
||||
nsServiceManager::ReleaseService(kStringBundleServiceCID, service);
|
||||
} else {
|
||||
printf("ERROR: Failed to get StringBundle Service instance.\n");
|
||||
}
|
||||
/*
|
||||
Example of getting a string:
|
||||
nsString value;
|
||||
ret = mStringBundle->GetStringFromName("editor.foo", value);
|
||||
*/
|
||||
|
||||
mPresShell->SetCaretEnabled(PR_TRUE);
|
||||
|
||||
@ -3748,6 +3801,18 @@ nsEditor::JoinNodeDeep(nsIDOMNode *aLeftNode,
|
||||
return res;
|
||||
}
|
||||
|
||||
// Get a string from the localized string resources
|
||||
nsresult nsEditor::GetString(const nsString& name, nsString& value)
|
||||
{
|
||||
nsresult result = NS_ERROR_NOT_INITIALIZED;
|
||||
value = "";
|
||||
if (mStringBundle && (name != ""))
|
||||
{
|
||||
result = mStringBundle->GetStringFromName(name, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* nsAutoSelectionReset
|
||||
*****************************************************************************/
|
||||
@ -3776,6 +3841,3 @@ nsAutoSelectionReset::~nsAutoSelectionReset()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -27,10 +27,10 @@
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "TransactionFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsIEditActionListener;
|
||||
class nsIDOMCharacterData;
|
||||
@ -48,6 +48,10 @@ class JoinElementTxn;
|
||||
class EditAggregateTxn;
|
||||
class nsVoidArray;
|
||||
class nsISupportsArray;
|
||||
class nsIPref;
|
||||
class nsIStringBundleService;
|
||||
class nsIStringBundle;
|
||||
class nsILocale;
|
||||
|
||||
//This is the monitor for the editor.
|
||||
PRMonitor *getEditorMonitor();
|
||||
@ -72,9 +76,12 @@ private:
|
||||
static PRInt32 gInstanceCount;
|
||||
|
||||
nsVoidArray *mActionListeners;
|
||||
nsCOMPtr<nsIStringBundle> mStringBundle;
|
||||
|
||||
protected:
|
||||
nsIDOMDocument * mDoc;
|
||||
// Services are not nsCOMPtr friendly
|
||||
nsIPref* mPrefs;
|
||||
|
||||
public:
|
||||
|
||||
@ -494,7 +501,7 @@ public:
|
||||
static nsCOMPtr<nsIDOMNode> NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir);
|
||||
static nsresult GetStartNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr<nsIDOMNode> *outStartNode, PRInt32 *outStartOffset);
|
||||
static nsresult GetEndNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr<nsIDOMNode> *outEndNode, PRInt32 *outEndOffset);
|
||||
|
||||
|
||||
nsresult IsPreformatted(nsIDOMNode *aNode, PRBool *aResult);
|
||||
nsresult IsNextCharWhitespace(nsIDOMNode *aParentNode, PRInt32 aOffset, PRBool *aResult);
|
||||
nsresult IsPrevCharWhitespace(nsIDOMNode *aParentNode, PRInt32 aOffset, PRBool *aResult);
|
||||
@ -502,6 +509,7 @@ public:
|
||||
nsresult SplitNodeDeep(nsIDOMNode *aNode, nsIDOMNode *aSplitPointParent, PRInt32 aSplitPointOffset);
|
||||
nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMSelection *aSelection);
|
||||
|
||||
nsresult GetString(const nsString& name, nsString& value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1809,13 +1809,13 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
|
||||
|
||||
if (aTagName == "" || !aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
|
||||
nsAutoString TagName = aTagName;
|
||||
TagName.ToLowerCase();
|
||||
nsAutoString realTagName;
|
||||
|
||||
PRBool isHREF = (TagName == "href");
|
||||
PRBool isAnchor = (TagName == "anchor");
|
||||
PRBool isHREF = (TagName.Equals("href"));
|
||||
PRBool isAnchor = (TagName.Equals("anchor"));
|
||||
if (isHREF || isAnchor)
|
||||
{
|
||||
realTagName = "a";
|
||||
@ -1836,16 +1836,20 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
|
||||
// ATTRIBUTES SAVED IN PREFS?
|
||||
if (isAnchor)
|
||||
{
|
||||
|
||||
// TODO: Get the text of the selection and build a suggested Name
|
||||
// Replace spaces with "_"
|
||||
} else if (TagName.Equals("hr"))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// ADD OTHER DEFAULT ATTRIBUTES HERE
|
||||
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
*aReturn = newElement;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -1876,15 +1880,12 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection, ns
|
||||
}
|
||||
}
|
||||
|
||||
DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode);
|
||||
res = DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode);
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> newNode = do_QueryInterface(aElement);
|
||||
|
||||
res = InsertNode(aElement, parentSelectedNode, offsetOfNewNode);
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -2164,8 +2165,19 @@ NS_IMETHODIMP nsHTMLEditor::GetLocalFileURL(nsIDOMWindow* aParent, const nsStrin
|
||||
|
||||
|
||||
nsCOMPtr<nsIFileWidget> fileWidget;
|
||||
// TODO: WHERE TO WE PUT GLOBAL STRINGS TO BE LOCALIZED?
|
||||
nsString title(htmlFilter ? "Open HTML file" : "Select Image File");
|
||||
nsAutoString title("");
|
||||
|
||||
// Get strings from editor resource bundle
|
||||
nsString name;
|
||||
if (htmlFilter)
|
||||
{
|
||||
name = "OpenHTMLFile";
|
||||
} else if (imgFilter)
|
||||
{
|
||||
name = "SelectImageFile";
|
||||
}
|
||||
GetString(name, title);
|
||||
|
||||
nsFileSpec fileSpec;
|
||||
// TODO: GET THE DEFAULT DIRECTORY FOR DIFFERENT TYPES FROM PREFERENCES
|
||||
nsFileSpec aDisplayDirectory;
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
<menuitem name="Link..." onclick="EditorInsertLink()"/>
|
||||
<menuitem name=".Target..." onclick=""/>
|
||||
<menuitem name="Image..." onclick="EditorInsertImage()"/>
|
||||
<menuitem name=".Horizontal Line" onclick=""/>
|
||||
<menuitem name="Horizontal Line" onclick="EditorInsertHLine()"/>
|
||||
<menuitem name=".Table" onclick=""/>
|
||||
<menuitem name=".HTML Tag..." onclick=""/>
|
||||
<separator />
|
||||
@ -90,10 +90,12 @@
|
||||
<menuitem name="Courier" onclick="EditorSetFontFace('Courier New, Courier, mono')"/>
|
||||
</menu>
|
||||
<menu name="Size">
|
||||
<menuitem name="-4" onclick="EditorSetFontSize('-4')"/>
|
||||
<menuitem name="-3" onclick="EditorSetFontSize('-3')"/>
|
||||
<menuitem name="-2" onclick="EditorSetFontSize('-2')"/>
|
||||
<menuitem name="-1" onclick="EditorSetFontSize('-1')"/>
|
||||
<menuitem name=" 0" onclick="EditorSetFontSize(' 0')"/>
|
||||
<menuitem name="+1" onclick="EditorSetFontSize('+1')"/>
|
||||
<menuitem name="-1 (smaller)" onclick="EditorSetFontSize('-1')"/>
|
||||
<menuitem name="Normal" onclick="EditorSetFontSize('0')"/>
|
||||
<menuitem name="+1 (bigger)" onclick="EditorSetFontSize('+1')"/>
|
||||
<menuitem name="+2" onclick="EditorSetFontSize('+2')"/>
|
||||
<menuitem name="+3" onclick="EditorSetFontSize('+3')"/>
|
||||
<menuitem name="+4" onclick="EditorSetFontSize('+4')"/>
|
||||
@ -108,10 +110,34 @@
|
||||
<menuitem name="Blink" onclick="EditorApplyStyle('blink')"/>
|
||||
<menuitem name="Nonbreaking" onclick="EditorApplyStyle('nobr')"/>
|
||||
</menu>
|
||||
<menuitem name=".Color..." onclick=""/>
|
||||
<menu name="Text Color">
|
||||
<menuitem name="Black" onclick="EditorSetFontColor('black')"/>
|
||||
<menuitem name="Gray" onclick="EditorSetFontColor('gray')"/>
|
||||
<menuitem name="Silver" onclick="EditorSetFontColor('silver')"/>
|
||||
<menuitem name="White" onclick="EditorSetFontColor('white')"/>
|
||||
<menuitem name="Red" onclick="EditorSetFontColor('red')"/>
|
||||
<menuitem name="Blue" onclick="EditorSetFontColor('blue')"/>
|
||||
<menuitem name="Green" onclick="EditorSetFontColor('green')"/>
|
||||
<menuitem name="Cyan" onclick="EditorSetFontColor('cyan')"/>
|
||||
<menuitem name="Yellow" onclick="EditorSetFontColor('yellow')"/>
|
||||
<menuitem name="Magenta" onclick="EditorSetFontColor('magenta')"/>
|
||||
</menu>
|
||||
<menu name="Background Color">
|
||||
<menuitem name="Black" onclick="EditorSetBackgroundColor('black')"/>
|
||||
<menuitem name="Gray" onclick="EditorSetBackgroundColor('gray')"/>
|
||||
<menuitem name="Silver" onclick="EditorSetBackgroundColor('silver')"/>
|
||||
<menuitem name="White" onclick="EditorSetBackgroundColor('white')"/>
|
||||
<menuitem name="Red" onclick="EditorSetBackgroundColor('red')"/>
|
||||
<menuitem name="Blue" onclick="EditorSetBackgroundColor('blue')"/>
|
||||
<menuitem name="Green" onclick="EditorSetBackgroundColor('green')"/>
|
||||
<menuitem name="Cyan" onclick="EditorSetBackgroundColor('cyan')"/>
|
||||
<menuitem name="Yellow" onclick="EditorSetBackgroundColor('yellow')"/>
|
||||
<menuitem name="Magenta" onclick="EditorSetBackgroundColor('magenta')"/>
|
||||
</menu>
|
||||
<menuitem name="Remove All Style(s)" onclick="EditorRemoveStyle('all')"/>
|
||||
<menuitem name="Remove Link(s)" onclick="EditorRemoveLinks()"/>
|
||||
<separator />
|
||||
<menu name="Paragraph / Heading">
|
||||
<menu name="Heading">
|
||||
<menuitem name="Normal" onclick="EditorSetParagraphFormat('normal')"/>
|
||||
<menuitem name="Heading 1" onclick="EditorSetParagraphFormat('h1')"/>
|
||||
<menuitem name="Heading 2" onclick="EditorSetParagraphFormat('h2')"/>
|
||||
@ -119,10 +145,14 @@
|
||||
<menuitem name="Heading 4" onclick="EditorSetParagraphFormat('h4')"/>
|
||||
<menuitem name="Heading 5" onclick="EditorSetParagraphFormat('h5')"/>
|
||||
<menuitem name="Heading 6" onclick="EditorSetParagraphFormat('h6')"/>
|
||||
<menuitem name="Address" onclick="EditorSetParagraphFormat('address')"/>
|
||||
<menuitem name="Preformat" onclick="EditorSetParagraphFormat('pre')"/>
|
||||
<menuitem name="List item" onclick="EditorSetParagraphFormat('li')"/>
|
||||
<menuitem name="Definition term" onclick="EditorSetParagraphFormat('dt')"/>
|
||||
</menu>
|
||||
<menu name="Paragraph">
|
||||
<menuitem name="Normal" onclick="EditorSetParagraphFormat('normal')"/>
|
||||
<menuitem name="Blockquote" onclick="EditorSetParagraphFormat('blockquote')"/>
|
||||
<menuitem name="Address" onclick="EditorSetParagraphFormat('address')"/>
|
||||
<menuitem name="Preformat" onclick="EditorSetParagraphFormat('pre')"/>
|
||||
<menuitem name="List item" onclick="EditorSetParagraphFormat('li')"/>
|
||||
<menuitem name="Definition term" onclick="EditorSetParagraphFormat('dt')"/>
|
||||
<menuitem name="Definition description" onclick="EditorSetParagraphFormat('dd')"/>
|
||||
</menu>
|
||||
</menu>
|
||||
@ -168,11 +198,12 @@
|
||||
<titledbutton src="chrome://editor/skin/images/ED_ClearStyle.gif" align="bottom" onclick="EditorRemoveStyle('all')"/>
|
||||
<titledbutton src="chrome://editor/skin/images/ED_Bullets.gif" align="bottom" onclick="EditorInsertList('ul')"/>
|
||||
<titledbutton src="chrome://editor/skin/images/ED_Numbers.gif" align="bottom" onclick="EditorInsertList('ol')"/>
|
||||
<titledbutton src="chrome://editor/skin/images/ED_Indent.gif" align="bottom" onclick="EditorIndent('indent')"/>
|
||||
<titledbutton src="chrome://editor/skin/images/ED_Outdent.gif" align="bottom" onclick="EditorIndent('outdent')"/>
|
||||
<titledbutton src="chrome://editor/skin/images/ED_Indent.gif" align="bottom" onclick="EditorIndent('indent')"/>
|
||||
<titledbutton src="chrome://editor/skin/images/ED_Align.gif" align="bottom" class="popup" popup="AlignmentMenu"/>
|
||||
<titledbutton src="chrome://editor/skin/images/ED_Link.gif" align="bottom" onclick="EditorInsertLink()"/>
|
||||
<titledbutton src="chrome://editor/skin/images/ED_Image.gif" align="bottom" onclick= "EditorInsertImage()"/>
|
||||
<titledbutton src="chrome://editor/skin/images/ED_HLine.gif" align="bottom" onclick= "EditorInsertHLine()"/>
|
||||
<titledbutton src="chrome://editor/skin/images/ED_Spell.gif" align="bottom" class="popup" onclick="CheckSpelling()"/>
|
||||
</toolbar>
|
||||
</toolbox>
|
||||
@ -224,13 +255,15 @@
|
||||
|
||||
<popup id="FontSizeMenu">
|
||||
<menu>
|
||||
<menuitem name="-2" onclick="EditorSetFontSize('-2')"/>
|
||||
<menuitem name="-1" onclick="EditorSetFontSize('-1')"/>
|
||||
<menuitem name=" 0 (normal)" onclick="EditorSetFontSize(' 0')"/>
|
||||
<menuitem name="+1" onclick="EditorSetFontSize('+1')"/>
|
||||
<menuitem name="+2" onclick="EditorSetFontSize('+2')"/>
|
||||
<menuitem name="+3" onclick="EditorSetFontSize('+3')"/>
|
||||
<menuitem name="+4" onclick="EditorSetFontSize('+4')"/>
|
||||
<menuitem name="-4" onclick="EditorSetFontSize('-4')"/>
|
||||
<menuitem name="-3" onclick="EditorSetFontSize('-3')"/>
|
||||
<menuitem name="-2" onclick="EditorSetFontSize('-2')"/>
|
||||
<menuitem name="-1 (smaller)" onclick="EditorSetFontSize('-1')"/>
|
||||
<menuitem name="Normal" onclick="EditorSetFontSize('0')"/>
|
||||
<menuitem name="+1 (bigger)" onclick="EditorSetFontSize('+1')"/>
|
||||
<menuitem name="+2" onclick="EditorSetFontSize('+2')"/>
|
||||
<menuitem name="+3" onclick="EditorSetFontSize('+3')"/>
|
||||
<menuitem name="+4" onclick="EditorSetFontSize('+4')"/>
|
||||
</menu>
|
||||
</popup>
|
||||
|
||||
|
||||
@ -5,11 +5,12 @@
|
||||
var editorName = "EditorAppCore" + ( new Date() ).getTime().toString();
|
||||
var appCore = null;
|
||||
var toolbar;
|
||||
var contentWindow;
|
||||
|
||||
function EditorStartup(editorType)
|
||||
{
|
||||
dump("Doing Startup...\n");
|
||||
|
||||
contentWindow = window.frames[0];
|
||||
/* Get the global Editor AppCore and the XPFE toolkit core into globals here */
|
||||
appCore = XPAppCoresManager.Find(editorName);
|
||||
dump("Looking up EditorAppCore...\n");
|
||||
@ -25,7 +26,7 @@ function EditorStartup(editorType)
|
||||
appCore.setToolbarWindow(window)
|
||||
|
||||
appCore.setEditorType(editorType);
|
||||
appCore.setContentWindow( window.frames[0] );
|
||||
appCore.setContentWindow(contentWindow);
|
||||
|
||||
// Get url for editor content
|
||||
var url = document.getElementById("args").getAttribute("value");
|
||||
@ -39,8 +40,9 @@ function EditorStartup(editorType)
|
||||
}
|
||||
EditorSetup(editorName, appCore);
|
||||
|
||||
// Set focus to the edit window
|
||||
window.focus();
|
||||
// Set focus to the editor content window
|
||||
dump("Setting focus to content window\n");
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorSetup(p_editorName, p_appCore)
|
||||
@ -87,6 +89,7 @@ function EditorOpen()
|
||||
{
|
||||
appCore.open();
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorNewPlaintext()
|
||||
@ -134,6 +137,7 @@ function EditorSave()
|
||||
{
|
||||
appCore.save();
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorSaveAs()
|
||||
@ -145,6 +149,7 @@ function EditorSaveAs()
|
||||
{
|
||||
appCore.saveAs();
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
|
||||
@ -157,6 +162,7 @@ function EditorPrint()
|
||||
{
|
||||
appCore.print();
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorClose()
|
||||
@ -236,6 +242,7 @@ function EditorFind()
|
||||
if (appCore) {
|
||||
appCore.find();
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorFindNext()
|
||||
@ -243,6 +250,7 @@ function EditorFindNext()
|
||||
if (appCore) {
|
||||
appCore.findNext();
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorShowClipboard()
|
||||
@ -262,9 +270,8 @@ function EditorSetTextProperty(property, attribute, value)
|
||||
{
|
||||
if (appCore) {
|
||||
appCore.setTextProperty(property, attribute, value);
|
||||
}
|
||||
dump("Set text property -- calling focus()\n");
|
||||
window.focus();
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorSetParagraphFormat(paraFormat)
|
||||
@ -272,15 +279,22 @@ function EditorSetParagraphFormat(paraFormat)
|
||||
if (appCore) {
|
||||
appCore.setParagraphFormat(paraFormat);
|
||||
}
|
||||
window.focus();
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorSetFontSize(size)
|
||||
{
|
||||
if (appCore) {
|
||||
appCore.setTextProperty("font", "size", size);
|
||||
if( size == "0" || size == "normal" ||
|
||||
size === "+0" )
|
||||
{
|
||||
appCore.removeTextProperty("font", size);
|
||||
dump("Removing font size\n");
|
||||
} else {
|
||||
dump("Setting font size\n");
|
||||
appCore.setTextProperty("font", "size", size);
|
||||
}
|
||||
}
|
||||
window.focus();
|
||||
}
|
||||
|
||||
function EditorSetFontFace(fontFace)
|
||||
@ -294,7 +308,7 @@ function EditorSetFontFace(fontFace)
|
||||
}
|
||||
appCore.setTextProperty("font", "face", fontFace);
|
||||
}
|
||||
window.focus();
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorSetFontColor(color)
|
||||
@ -302,13 +316,13 @@ function EditorSetFontColor(color)
|
||||
if (appCore) {
|
||||
appCore.setTextProperty("font", "color", color);
|
||||
}
|
||||
window.focus();
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorSetBackgroundColor(color)
|
||||
{
|
||||
appCore.setBackgroundColor(color);
|
||||
window.focus();
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorApplyStyle(styleName)
|
||||
@ -316,8 +330,9 @@ function EditorApplyStyle(styleName)
|
||||
if (appCore) {
|
||||
dump("Applying Style\n");
|
||||
appCore.setTextProperty(styleName, null, null);
|
||||
dump("Restore focus to editor window: "+window.frames[0]+"\n");
|
||||
}
|
||||
window.focus();
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorRemoveStyle(styleName)
|
||||
@ -326,7 +341,11 @@ function EditorRemoveStyle(styleName)
|
||||
dump("Removing Style\n");
|
||||
appCore.removeTextProperty(styleName, null);
|
||||
}
|
||||
window.focus();
|
||||
contentWindow.focus();
|
||||
}
|
||||
function EditorRemoveLinks()
|
||||
{
|
||||
dump("NOT IMPLEMENTED YET\n");
|
||||
}
|
||||
|
||||
// --------------------------- Output ---------------------------
|
||||
@ -359,11 +378,43 @@ function EditorInsertText()
|
||||
|
||||
function EditorInsertLink()
|
||||
{
|
||||
dump("Starting Insert Link...\n");
|
||||
if (appCore) {
|
||||
dump("Link Properties Dialog starting...\n");
|
||||
window.openDialog("chrome://editordlgs/content/EdLinkProps.xul", "LinkDlg", "chrome", editorName);
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorInsertImage()
|
||||
{
|
||||
if (appCore) {
|
||||
window.openDialog("chrome://editordlgs/content/EdImageProps.xul", "dlg", "chrome", editorName);
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorInsertHLine()
|
||||
{
|
||||
if (appCore) {
|
||||
window.openDialog("chrome://editordlgs/content/EdHLineProps.xul", "dlg", "chrome", editorName);
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorInsertNamedAnchor()
|
||||
{
|
||||
if (appCore) {
|
||||
window.openDialog("chrome://editordlgs/content/EdNamedAnchorProps.xul", "dlg", "chrome", editorName);
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorIndent(indent)
|
||||
{
|
||||
dump("indenting\n");
|
||||
if (appCore) {
|
||||
appCore.indent(indent);
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
|
||||
@ -374,22 +425,7 @@ function EditorInsertList(listType)
|
||||
appCore.insertList(listType);
|
||||
dump("\n");
|
||||
}
|
||||
}
|
||||
|
||||
function EditorInsertImage()
|
||||
{
|
||||
if (appCore) {
|
||||
dump("Image Properties Dialog starting. Editor Name="+editorName+"\n");
|
||||
window.openDialog("chrome://editordlgs/content/EdImageProps.xul", "dlg", "chrome", editorName);
|
||||
}
|
||||
}
|
||||
|
||||
function EditorIndent(indent)
|
||||
{
|
||||
dump("indenting\n");
|
||||
if (appCore) {
|
||||
appCore.indent(indent);
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorAlign(align)
|
||||
@ -398,6 +434,7 @@ function EditorAlign(align)
|
||||
if (appCore) {
|
||||
appCore.align(align);
|
||||
}
|
||||
contentWindow.focus();
|
||||
}
|
||||
|
||||
|
||||
@ -506,7 +543,6 @@ function OpenFile(url)
|
||||
} else {
|
||||
dump("Error; can't create toolkitCore\n");
|
||||
}
|
||||
window.focus();
|
||||
}
|
||||
|
||||
// --------------------------- Status calls ---------------------------
|
||||
|
||||
@ -34,6 +34,10 @@ EXPORT_RESOURCE_CONTENT = \
|
||||
$(srcdir)/EditorInitPagePlain.html \
|
||||
$(NULL)
|
||||
|
||||
EXPORT_STRING_CONTENT = \
|
||||
$(srcdir)/editor.properties \
|
||||
$(NULL)
|
||||
|
||||
install::
|
||||
$(INSTALL) $(EXPORT_RESOURCE_CONTENT) $(DIST)/bin/chrome/editor/composer/content/default
|
||||
|
||||
$(INSTALL) $(EXPORT_STRING_CONTENT) $(DIST)/bin/res
|
||||
|
||||
@ -24,9 +24,11 @@ install::
|
||||
$(MAKE_INSTALL) EditorCommands.js $(DIST)\bin\chrome\editor\composer\content\default
|
||||
$(MAKE_INSTALL) EditorInitPage.html $(DIST)\bin\chrome\editor\composer\content\default
|
||||
$(MAKE_INSTALL) EditorInitPagePlain.html $(DIST)\bin\chrome\editor\composer\content\default
|
||||
$(MAKE_INSTALL) editor.properties $(DIST)\bin\res
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorAppShell.xul
|
||||
rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorCommands.js
|
||||
rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorInitPage.html
|
||||
rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorInitPagePlain.html
|
||||
rm -f $(DIST)\bin\res\editor.properties
|
||||
|
||||
@ -1,9 +1,3 @@
|
||||
/* These are critical - should be in xul.css */
|
||||
window#main-window {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
box#outer-box {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@ -28,31 +22,10 @@ select.combobox {
|
||||
//background: silver;
|
||||
}
|
||||
|
||||
select[pseudoclass~="hover"] {
|
||||
/* NOT WORKING */
|
||||
background: red;
|
||||
}
|
||||
|
||||
/* Make the buttons butt up against each other
|
||||
Bug: When hover over, width decreases by 1 pixel,
|
||||
causing horizontal jump for rest of controls in toolbar
|
||||
*/
|
||||
titledbutton#TextColorPopup {
|
||||
margin-right: -2px;
|
||||
border-right: 0px;
|
||||
}
|
||||
|
||||
titledbutton#BackColorPopup {
|
||||
margin-left: -2px;
|
||||
border-left: 0px;
|
||||
}
|
||||
|
||||
/* trying to fix hover width problem, but hover detection not working */
|
||||
titledbutton#TextColorPopup[pseudoclass~="hover"] {
|
||||
margin-right: -1px;
|
||||
border-right: 0px;
|
||||
}
|
||||
|
||||
titledbutton#BackColorPopup[pseudoclass~="hover"] {
|
||||
margin-left: -1px;
|
||||
border-left: 0px;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 143 B |
Binary file not shown.
|
Before Width: | Height: | Size: 908 B After Width: | Height: | Size: 138 B |
@ -21,3 +21,9 @@ function AppendStringToList(list, string)
|
||||
dump("Failed to create OPTION node. String content="+string+"\n");
|
||||
}
|
||||
}
|
||||
|
||||
// All dialogs share this simple method
|
||||
function onCancel()
|
||||
{
|
||||
window.close();
|
||||
}
|
||||
|
||||
38
mozilla/editor/ui/dialogs/content/EdHLineProps.js
Normal file
38
mozilla/editor/ui/dialogs/content/EdHLineProps.js
Normal file
@ -0,0 +1,38 @@
|
||||
var appCore;
|
||||
var toolkitCore;
|
||||
var insertNew = true;
|
||||
|
||||
// dialog initialization code
|
||||
function Startup()
|
||||
{
|
||||
dump("Doing Startup...\n");
|
||||
// New method: parameters passed via window.openDialog, which puts
|
||||
// arguments in the array "arguments"
|
||||
var editorName = window.arguments[0];
|
||||
dump("Got editorAppCore called " + editorName + "\n");
|
||||
|
||||
// NEVER create an appcore here - we must find parent editor's
|
||||
appCore = XPAppCoresManager.Find(editorName);
|
||||
if(!appCore) {
|
||||
dump("EditorAppCore not found!!!\n");
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
dump("EditorAppCore found for HRule Properties dialog\n");
|
||||
|
||||
// Create dialog object to store controls for easy access
|
||||
dialog = new Object;
|
||||
// GET EACH CONTROL -- E.G.:
|
||||
//dialog.editBox = document.getElementById("editBox");
|
||||
// Can we get at just the edit field?
|
||||
dialog.AltText = document.getElementById("image.AltText");
|
||||
|
||||
//initDialog();
|
||||
|
||||
// SET FOCUS TO FIRST CONTROL
|
||||
//dialog.editBox.focus();
|
||||
}
|
||||
|
||||
function OnOK()
|
||||
{
|
||||
}
|
||||
68
mozilla/editor/ui/dialogs/content/EdHLineProps.xul
Normal file
68
mozilla/editor/ui/dialogs/content/EdHLineProps.xul
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/xul.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://editordlgs/skin/EditorDialog.css" type="text/css"?>
|
||||
<!DOCTYPE window>
|
||||
<!-- dialog containing a control requiring initial setup -->
|
||||
<xul:window width="280" height="305" title="Horizontal Line Properties"
|
||||
xmlns:xul ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns="http://www.w3.org/TR/REC-html40"
|
||||
onload = "Startup()">
|
||||
|
||||
<!-- Methods common to all editor dialogs -->
|
||||
<script language="JavaScript" src="chrome://editordlgs/content/EdDialogCommon.js">
|
||||
</script>
|
||||
<script language="JavaScript" src="chrome://editordlgs/content/EdHLineProps.js">
|
||||
</script>
|
||||
<table width="95%">
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<fieldset><legend align="left">Dimensions</legend>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="right">
|
||||
Height:
|
||||
</td>
|
||||
<td colspan="2">
|
||||
<input type="text" id="width" size="4" maxlength="4"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Width:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="width" size="4" maxlength="4"/>
|
||||
</td>
|
||||
<td>
|
||||
<xul:titledbutton class="push popup" id="PixelOrPercent" value="pixels" align="left" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<fieldset><legend align="left">Alignment</legend>
|
||||
<label><input type="radio" name="HRuleAlign" id="leftAlign"/>Left</label>
|
||||
<label><input type="radio" name="HRuleAlign" id="centerAlign"/>Center</label>
|
||||
<label><input type="radio" name="HRuleAlign" id="rightAlign"/>Right</label>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label><input type="checkbox" id="3dShading"/>3-D Shading</label>
|
||||
</td>
|
||||
<td align="right">
|
||||
<button id="SaveDefault">Save settings as default</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="right">
|
||||
<button class="spaced" id="OK" onclick="onOK()">OK</button>
|
||||
<button class="spaced" id="Cancel" onclick="onCancel()" width="50">Cancel</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</xul:window>
|
||||
@ -1,20 +1,16 @@
|
||||
// OnOK(), Undo(), and Cancel() are in EdDialogCommon.js
|
||||
// applyChanges() must be implemented here
|
||||
|
||||
var appCore;
|
||||
var insertNew = true;
|
||||
var imageWasInserted = false;
|
||||
var undoCount = 0;
|
||||
var imageElement;
|
||||
var tagName = "img"
|
||||
var advanced = false;
|
||||
var advanced = true;
|
||||
|
||||
// dialog initialization code
|
||||
function Startup()
|
||||
{
|
||||
dump("Doing Startup...\n");
|
||||
|
||||
// New metho: parameters passed via window.openDialog, which puts
|
||||
// New method: parameters passed via window.openDialog, which puts
|
||||
// arguments in the array "arguments"
|
||||
var editorName = window.arguments[0];
|
||||
dump("Got editorAppCore called " + editorName + "\n");
|
||||
@ -37,9 +33,14 @@ function Startup()
|
||||
dialog.AdvancedButton = document.getElementById("AdvancedButton");
|
||||
dialog.AdvancedRow = document.getElementById("AdvancedRow");
|
||||
|
||||
// Start in "basic" mode
|
||||
dialog.AdvancedRow.style.display = "none";
|
||||
|
||||
// Start in the mode initialized in the "advanced" var above
|
||||
// THIS IS NOT WORKING NOW - After switching to "basic" mode,
|
||||
// then back to
|
||||
if (advanced) {
|
||||
dialog.AdvancedRow.style.visibility = "visible";
|
||||
} else {
|
||||
dialog.AdvancedRow.style.visibility = "collapse";
|
||||
}
|
||||
|
||||
if (null == dialog.srcInput ||
|
||||
null == dialog.altTextInput )
|
||||
@ -91,48 +92,38 @@ function chooseFile()
|
||||
|
||||
function onAdvanced()
|
||||
{
|
||||
if (dialog.AdvancedRow) {
|
||||
dump("AdvancedRow still exists ****\n");
|
||||
}
|
||||
|
||||
if (advanced) {
|
||||
dump("Changing to BASIC mode\n");
|
||||
advanced = false;
|
||||
// BUG: This works to hide the row, but
|
||||
// setting visibility to "show" doesn't bring it back
|
||||
//dialog.AdvancedRow.style.visibility = "collapse";
|
||||
dialog.AdvancedRow.style.display = "none";
|
||||
dialog.AdvancedRow.style.visibility = "collapse";
|
||||
//dialog.AdvancedRow.style.display = "none";
|
||||
} else {
|
||||
dump("Changing to ADVANCED mode\n");
|
||||
advanced = true;
|
||||
dialog.AdvancedRow.style.display = "table-row";
|
||||
//dialog.AdvancedRow.style.display = "table-row";
|
||||
dialog.AdvancedRow.style.visibility = "visible";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onOK() {
|
||||
if (applyChanges()) {
|
||||
if (imageWasInserted) {
|
||||
// We selected the object, undo it by
|
||||
// setting caret to just after the inserted element
|
||||
appCore.setCaretAfterElement(imageElement);
|
||||
}
|
||||
window.close();
|
||||
}
|
||||
function SelectWidthUnits()
|
||||
{
|
||||
list = document.getElementByID("WidthUnits");
|
||||
value = list.options[list.selectedIndex].value;
|
||||
dump("Selected item: "+value+"\n");
|
||||
}
|
||||
|
||||
function onCancel() {
|
||||
// Undo all actions performed within the dialog
|
||||
// TODO: We need to suppress reflow/redraw untill all levels are undone
|
||||
while (undoCount > 0) {
|
||||
onUndo();
|
||||
}
|
||||
window.close();
|
||||
function OnChangeSrc()
|
||||
{
|
||||
dump("*** Changed SRC field\n");
|
||||
}
|
||||
|
||||
function applyChanges()
|
||||
function onOK()
|
||||
{
|
||||
// TODO: BE SURE Src AND AltText are completed!
|
||||
|
||||
imageElement.setAttribute("src",dialog.srcInput.value);
|
||||
// We must convert to "file:///" format else image doesn't load!
|
||||
imageElement.setAttribute("alt",dialog.altTextInput.value);
|
||||
@ -145,9 +136,10 @@ function applyChanges()
|
||||
// when dialog closes
|
||||
imageWasInserted = true;
|
||||
}
|
||||
// Reinitialize dialog data
|
||||
initDialog();
|
||||
|
||||
// TODO: Return false if any data validation tests fail
|
||||
return true;
|
||||
}
|
||||
if (imageWasInserted) {
|
||||
// We selected the object, undo it by
|
||||
// setting caret to just after the inserted element
|
||||
appCore.setCaretAfterElement(imageElement);
|
||||
}
|
||||
window.close();
|
||||
}
|
||||
|
||||
@ -22,11 +22,11 @@
|
||||
<td colspan="2">
|
||||
<fieldset><legend align="left">Image Information </legend>
|
||||
<p class="smallmargin">Enter a remote URL or local file: </p>
|
||||
<input type="text" size="20" length="20" id="image.srcInput" />
|
||||
<input type="text" size="20" length="20" id="image.srcInput" onchange="OnChangeSrc()"/>
|
||||
<button class="ChooseFile" id="ChooseFile" onclick="chooseFile()">Choose File...</button>
|
||||
<br/>
|
||||
<p class="smallmargin">Alternative Text</p>
|
||||
<input type="text" size="30" length="30" id="image.altTextInput" />
|
||||
<input type="text" size="30" id="image.altTextInput" />
|
||||
</fieldset>
|
||||
</td>
|
||||
<td/>
|
||||
@ -40,19 +40,24 @@
|
||||
<tr id="AdvancedRow">
|
||||
<td height="60">
|
||||
<fieldset><legend align="left">Dimensions </legend>
|
||||
Put size controls here
|
||||
<select id="WidthUnits" size="1" onchange="SelectWidthUnits()">
|
||||
<option>pixels</option>
|
||||
<option>percent</option>
|
||||
</select>
|
||||
</fieldset>
|
||||
</td>
|
||||
<td height="60">
|
||||
<fieldset><legend align="left">Spacing </legend>
|
||||
Put spacing controls here
|
||||
Put spacing controls here<br/>
|
||||
<button>Button</button>
|
||||
<input type="radio">Radio button</input>
|
||||
<input type="Checkbox">Checkbox</input>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align = "right">
|
||||
<button class="spaced" id="OK" onclick="onOK()" width="50">OK</button>
|
||||
<button class="spaced" id="Preview" onclick="applyChanges()" width="50">Preview</button>
|
||||
<button class="spaced" id="Cancel" onclick="onCancel()" width="50">Cancel</button>
|
||||
</td>
|
||||
<td/>
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
// OnOK(), Undo(), and Cancel() are in EdDialogCommon.js
|
||||
// applyChanges() must be implemented here
|
||||
|
||||
var appCore;
|
||||
var anchorElement = null;
|
||||
var insertNew = true;
|
||||
var needLinkText = false;
|
||||
var selection;
|
||||
var undoCount = 0;
|
||||
var insertLinkAroundSelection = false;
|
||||
|
||||
// NOTE: Use "HREF" instead of "A" to distinguish from Named Anchor
|
||||
@ -127,23 +123,10 @@ function chooseFile()
|
||||
dialog.hrefInput.focus();
|
||||
}
|
||||
|
||||
function onOK() {
|
||||
if (applyChanges()) {
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
function onCancel() {
|
||||
// Undo all actions performed within the dialog
|
||||
// TODO: We need to suppress reflow/redraw untill all levels are undone
|
||||
while (undoCount > 0) {
|
||||
onUndo();
|
||||
}
|
||||
window.close();
|
||||
}
|
||||
|
||||
function applyChanges()
|
||||
function onOK()
|
||||
{
|
||||
// TODO: VALIDATE FIELDS BEFORE COMMITING CHANGES
|
||||
|
||||
// Coalesce into one undo transaction
|
||||
appCore.beginBatchChanges();
|
||||
|
||||
@ -167,12 +150,8 @@ function applyChanges()
|
||||
dump("Setting link around selected text\n");
|
||||
appCore.insertLinkAroundSelection(anchorElement);
|
||||
}
|
||||
undoCount = undoCount + 1;
|
||||
appCore.endBatchChanges();
|
||||
|
||||
// Reinitialize dialog data
|
||||
initDialog();
|
||||
|
||||
// TODO: Return false if any data validation tests fail
|
||||
return true;
|
||||
window.close();
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,6 @@
|
||||
<tr>
|
||||
<td align = "right">
|
||||
<button class="spaced" id="OK" onclick="onOK()" width="50">OK</button>
|
||||
<button class="spaced" id="Preview" onclick="applyChanges()" width="50">Preview</button>
|
||||
<button class="spaced" id="Cancel" onclick="onCancel()" width="50">Cancel</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -152,11 +152,6 @@ function Close()
|
||||
window.close();
|
||||
}
|
||||
|
||||
function Help()
|
||||
{
|
||||
dump("SpellCheck: Help me Rhonda, help, help me Rhonda\n");
|
||||
}
|
||||
|
||||
function FillSuggestedList(firstWord)
|
||||
{
|
||||
list = dialog.suggestedList;
|
||||
|
||||
@ -83,7 +83,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<td colspan="2">
|
||||
<select class="SpellCheckLanguage" id="LanguageList" size="1" onchange="SelectLanguage()">
|
||||
<option>English
|
||||
</option>
|
||||
@ -92,9 +92,6 @@
|
||||
<td>
|
||||
<button id="Close" onclick="Close()">Close</button>
|
||||
</td>
|
||||
<td>
|
||||
<button id="Help" onclick="Help()">Help</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</xul:window>
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
#dialogs:content directory
|
||||
|
||||
EdDialogCommon.js
|
||||
EdCharacterProps.xul
|
||||
EdCharacterProps.js
|
||||
EdHLineProps.xul
|
||||
EdHLineProps.js
|
||||
EdImageProps.xul
|
||||
EdImageProps.js
|
||||
EdLinkProps.js
|
||||
|
||||
@ -29,11 +29,11 @@ include $(topsrcdir)/config/rules.mk
|
||||
EXPORT_RESOURCE_CONTENT = \
|
||||
$(srcdir)/EdDialogCommon.js \
|
||||
$(srcdir)/EdLinkProps.xul \
|
||||
$(srcdir)/EdImageProps.xul \
|
||||
$(srcdir)/EdCharacterProps.xul \
|
||||
$(srcdir)/EdLinkProps.js \
|
||||
$(srcdir)/EdImageProps.xul \
|
||||
$(srcdir)/EdImageProps.js \
|
||||
$(srcdir)/EdCharacterProps.js \
|
||||
$(srcdir)/EdHLineProps.xul \
|
||||
$(srcdir)/EdHLineProps.js \
|
||||
$(srcdir)/EdSpellCheck.xul \
|
||||
$(srcdir)/EdSpellCheck.js \
|
||||
$(NULL)
|
||||
|
||||
@ -25,10 +25,10 @@ install::
|
||||
$(MAKE_INSTALL) EdLinkProps.js $(DIST)\bin\chrome\editor\dialogs\content\default
|
||||
$(MAKE_INSTALL) EdImageProps.xul $(DIST)\bin\chrome\editor\dialogs\content\default
|
||||
$(MAKE_INSTALL) EdImageProps.js $(DIST)\bin\chrome\editor\dialogs\content\default
|
||||
$(MAKE_INSTALL) EdCharacterProps.xul $(DIST)\bin\chrome\editor\dialogs\content\default
|
||||
$(MAKE_INSTALL) EdCharacterProps.js $(DIST)\bin\chrome\editor\dialogs\content\default
|
||||
$(MAKE_INSTALL) EdSpellCheck.xul $(DIST)\bin\chrome\editor\dialogs\content\default
|
||||
$(MAKE_INSTALL) EdSpellCheck.js $(DIST)\bin\chrome\editor\dialogs\content\default
|
||||
$(MAKE_INSTALL) EdHLineProps.xul $(DIST)\bin\chrome\editor\dialogs\content\default
|
||||
$(MAKE_INSTALL) EdHLineProps.js $(DIST)\bin\chrome\editor\dialogs\content\default
|
||||
$(MAKE_INSTALL) EdSpellCheck.xul $(DIST)\bin\chrome\editor\dialogs\content\default
|
||||
$(MAKE_INSTALL) EdSpellCheck.js $(DIST)\bin\chrome\editor\dialogs\content\default
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdDialogCommon.js
|
||||
@ -36,7 +36,7 @@ clobber::
|
||||
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdLinkProps.js
|
||||
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdImageProps.xul
|
||||
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdImageProps.js
|
||||
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdCharacterProps.xul
|
||||
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdCharacterProps.js
|
||||
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdHLineProps.xul
|
||||
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdHLineProps.js
|
||||
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdSpellCheck.xul
|
||||
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdSpellCheck.js
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user