Fixed bugs 6278, 9758, 17014, 17071, 17160. r=sfraser,mjudge

This commit is contained in:
cmanske%netscape.com 1999-10-26 23:13:00 +00:00
Родитель 6f8e40e9a3
Коммит 712a9be961
29 изменённых файлов: 481 добавлений и 266 удалений

Просмотреть файл

@ -1151,10 +1151,11 @@ nsEditorShell::Open()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditorShell::CheckAndSaveDocument(PRBool *_retval) nsEditorShell::CheckAndSaveDocument(const PRUnichar *reasonToSave, PRBool *_retval)
{ {
*_retval = PR_FALSE; *_retval = PR_FALSE;
nsAutoString ReasonToSave(reasonToSave);
nsCOMPtr<nsIDOMDocument> theDoc; nsCOMPtr<nsIDOMDocument> theDoc;
nsresult rv = GetEditorDocument(getter_AddRefs(theDoc)); nsresult rv = GetEditorDocument(getter_AddRefs(theDoc));
if (NS_SUCCEEDED(rv) && theDoc) if (NS_SUCCEEDED(rv) && theDoc)
@ -1175,7 +1176,16 @@ nsEditorShell::CheckAndSaveDocument(PRBool *_retval)
nsAutoString tmp2 = GetString("DontSave"); nsAutoString tmp2 = GetString("DontSave");
nsAutoString title; nsAutoString title;
GetDocumentTitle(title); GetDocumentTitle(title);
nsAutoString saveMsg = GetString("SaveFilePrompt")+" "+"\""+title+"\""+GetString("QuestionMark"); nsAutoString saveMsg = GetString("SaveFilePrompt")+" "+"\""+title+"\"";
if (ReasonToSave.Length() > 0)
{
saveMsg += " ";
saveMsg += ReasonToSave;
saveMsg += GetString("QuestionMark");
} else {
saveMsg += GetString("QuestionMark");
}
EConfirmResult result = ConfirmWithCancel(GetString("SaveDocument"), saveMsg, EConfirmResult result = ConfirmWithCancel(GetString("SaveDocument"), saveMsg,
&tmp1, &tmp2); &tmp1, &tmp2);
if (result == eCancel) if (result == eCancel)
@ -1234,8 +1244,8 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
nsString title; nsString title;
res = HTMLDoc->GetTitle(title); res = HTMLDoc->GetTitle(title);
// Prompt for title ONLY for a new blank doc (no filespec yet) // Prompt for title if it's empty or user selected "Save As"
if (noFileSpec && NS_SUCCEEDED(res) && title.Length() == 0) if (NS_SUCCEEDED(res) && (saveAs || title.Length() == 0))
{ {
// Use a "prompt" common dialog to get title string from user // Use a "prompt" common dialog to get title string from user
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &res); NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &res);
@ -1246,7 +1256,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
nsAutoString msg = GetString("NeedDocTitle"); nsAutoString msg = GetString("NeedDocTitle");
PRBool retVal = PR_FALSE; PRBool retVal = PR_FALSE;
res = dialog->Prompt(mContentWindow, caption.GetUnicode(), msg.GetUnicode(), res = dialog->Prompt(mContentWindow, caption.GetUnicode(), msg.GetUnicode(),
nsnull, &titleUnicode, &retVal); title.GetUnicode(), &titleUnicode, &retVal);
if( retVal == PR_FALSE) if( retVal == PR_FALSE)
{ {
@ -1277,13 +1287,13 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
nsAutoString fileName; nsAutoString fileName;
nsFileSpec parentPath; nsFileSpec parentPath;
titles = new nsString[2]; titles = new nsString[3];
if (!titles) if (!titles)
{ {
res = NS_ERROR_OUT_OF_MEMORY; res = NS_ERROR_OUT_OF_MEMORY;
goto SkipFilters; goto SkipFilters;
} }
filters = new nsString[2]; filters = new nsString[3];
if (!filters) if (!filters)
{ {
res = NS_ERROR_OUT_OF_MEMORY; res = NS_ERROR_OUT_OF_MEMORY;
@ -1301,7 +1311,9 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
*nextFilter++ = "*.htm; *.html; *.shtml"; *nextFilter++ = "*.htm; *.html; *.shtml";
*nextTitle++ = TextFiles; *nextTitle++ = TextFiles;
*nextFilter++ = "*.txt"; *nextFilter++ = "*.txt";
fileWidget->SetFilterList(2, titles, filters); *nextTitle++ = GetString("AllFiles");
*nextFilter++ = "*.*";
fileWidget->SetFilterList(3, titles, filters);
if (noFileSpec) if (noFileSpec)
{ {
@ -1313,14 +1325,14 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
PRUnichar dot = (PRUnichar)'.'; PRUnichar dot = (PRUnichar)'.';
PRUnichar bslash = (PRUnichar)'\\'; PRUnichar bslash = (PRUnichar)'\\';
PRUnichar fslash = (PRUnichar)'/'; PRUnichar fslash = (PRUnichar)'/';
PRUnichar amp = (PRUnichar)'@'; PRUnichar at = (PRUnichar)'@';
PRUnichar colon = (PRUnichar)':'; PRUnichar colon = (PRUnichar)':';
PRUnichar underscore = (PRUnichar)'_'; PRUnichar underscore = (PRUnichar)'_';
title = title.ReplaceChar(space, underscore); title = title.ReplaceChar(space, underscore);
title = title.ReplaceChar(dot, underscore); title = title.ReplaceChar(dot, underscore);
title = title.ReplaceChar(bslash, underscore); title = title.ReplaceChar(bslash, underscore);
title = title.ReplaceChar(fslash, underscore); title = title.ReplaceChar(fslash, underscore);
title = title.ReplaceChar(amp, underscore); title = title.ReplaceChar(at, underscore);
title = title.ReplaceChar(colon, underscore); title = title.ReplaceChar(colon, underscore);
fileName = title + nsString(".html"); fileName = title + nsString(".html");
} }
@ -1405,7 +1417,7 @@ nsEditorShell::CloseWindow()
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
PRBool result; PRBool result;
rv = CheckAndSaveDocument(&result); rv = CheckAndSaveDocument(GetString("BeforeClosing").GetUnicode(),&result);
// Don't close the window if there was an error saving file or // Don't close the window if there was an error saving file or
// user canceled an action along the way // user canceled an action along the way
@ -1436,7 +1448,7 @@ NS_IMETHODIMP
nsEditorShell::Exit() nsEditorShell::Exit()
{ {
PRBool result; PRBool result;
nsresult rv = CheckAndSaveDocument(&result); nsresult rv = CheckAndSaveDocument(GetString("BeforeClosing").GetUnicode(),&result);
// Don't shutdown if there was an error saving file or // Don't shutdown if there was an error saving file or
// user canceled an action along the way // user canceled an action along the way
if (NS_SUCCEEDED(rv) && result) if (NS_SUCCEEDED(rv) && result)
@ -1455,9 +1467,9 @@ nsEditorShell::Exit()
NS_IMETHODIMP NS_IMETHODIMP
nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType, PRUnichar **_retval) nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType, PRUnichar **_retval)
{ {
nsAutoString aFilterType(filterType); nsAutoString FilterType(filterType);
PRBool htmlFilter = aFilterType.EqualsIgnoreCase("html"); PRBool htmlFilter = FilterType.EqualsIgnoreCase("html");
PRBool imgFilter = aFilterType.EqualsIgnoreCase("img"); PRBool imgFilter = FilterType.EqualsIgnoreCase("img");
*_retval = nsnull; *_retval = nsnull;
@ -2475,7 +2487,7 @@ nsEditorShell::GetDocumentLength(PRInt32 *aDocumentLength)
NS_IMETHODIMP NS_IMETHODIMP
nsEditorShell::InsertList(const PRUnichar *listType) nsEditorShell::MakeOrChangeList(const PRUnichar *listType)
{ {
nsresult err = NS_NOINTERFACE; nsresult err = NS_NOINTERFACE;
@ -2484,14 +2496,24 @@ nsEditorShell::InsertList(const PRUnichar *listType)
switch (mEditorType) switch (mEditorType)
{ {
case eHTMLTextEditorType: case eHTMLTextEditorType:
err = mEditor->InsertList(aListType); if (aListType == "")
{
err = mEditor->RemoveList("ol");
if(NS_SUCCEEDED(err))
{
err = mEditor->RemoveList("ul");
if(NS_SUCCEEDED(err))
err = mEditor->RemoveList("dl");
}
}
else
err = mEditor->MakeOrChangeList(aListType);
break; break;
case ePlainTextEditorType: case ePlainTextEditorType:
default: default:
err = NS_ERROR_NOT_IMPLEMENTED; err = NS_ERROR_NOT_IMPLEMENTED;
} }
return err; return err;
} }
@ -2506,6 +2528,17 @@ nsEditorShell::RemoveList(const PRUnichar *listType)
switch (mEditorType) switch (mEditorType)
{ {
case eHTMLTextEditorType: case eHTMLTextEditorType:
if (aListType == "")
{
err = mEditor->RemoveList("ol");
if(NS_SUCCEEDED(err))
{
err = mEditor->RemoveList("ul");
if(NS_SUCCEEDED(err))
err = mEditor->RemoveList("dl");
}
}
else
err = mEditor->RemoveList(aListType); err = mEditor->RemoveList(aListType);
break; break;

Просмотреть файл

@ -1695,9 +1695,12 @@ NS_IMETHODIMP nsHTMLEditor::SetParagraphFormat(const nsString& aParagraphFormat)
{ {
res = InsertBasicBlock("p"); res = InsertBasicBlock("p");
} }
//XXX: TODO: Do we really want to support setting list types here?
// If yes, we need to add "dd", "dt" for <dl> support
else if (tag == "li") else if (tag == "li")
{ {
res = InsertList("ul"); //XXX: Why do we assume "ul" What about "ol"? This will change an OL into a UL list!
res = MakeOrChangeList("ul");
} }
else else
{ {
@ -1949,7 +1952,7 @@ nsHTMLEditor::RemoveParent(const nsString &aParentTag)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::InsertList(const nsString& aListType) nsHTMLEditor::MakeOrChangeList(const nsString& aListType)
{ {
nsresult res; nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }

Просмотреть файл

@ -103,7 +103,7 @@ public:
NS_IMETHOD ReplaceBlockParent(nsString& aParentTag); NS_IMETHOD ReplaceBlockParent(nsString& aParentTag);
NS_IMETHOD RemoveParent(const nsString &aParentTag); NS_IMETHOD RemoveParent(const nsString &aParentTag);
NS_IMETHOD InsertList(const nsString& aListType); NS_IMETHOD MakeOrChangeList(const nsString& aListType);
NS_IMETHOD RemoveList(const nsString& aListType); NS_IMETHOD RemoveList(const nsString& aListType);
NS_IMETHOD InsertBasicBlock(const nsString& aBlockType); NS_IMETHOD InsertBasicBlock(const nsString& aBlockType);
NS_IMETHOD Indent(const nsString& aIndent); NS_IMETHOD Indent(const nsString& aIndent);

Просмотреть файл

@ -488,7 +488,7 @@ nsHTMLEditorLog::SetBodyAttribute(const nsString& aAttr, const nsString& aValue)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::InsertList(const nsString& aListType) nsHTMLEditorLog::MakeOrChangeList(const nsString& aListType)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -496,13 +496,13 @@ nsHTMLEditorLog::InsertList(const nsString& aListType)
{ {
PrintSelection(); PrintSelection();
Write("window.editorShell.InsertList(\""); Write("window.editorShell.MakeOrChangeList(\"");
PrintUnicode(aListType); PrintUnicode(aListType);
Write("\");\n"); Write("\");\n");
Flush(); Flush();
} }
return nsHTMLEditor::InsertList(aListType); return nsHTMLEditor::MakeOrChangeList(aListType);
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -79,7 +79,7 @@ public:
NS_IMETHOD SetBackgroundColor(const nsString& aColor); NS_IMETHOD SetBackgroundColor(const nsString& aColor);
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue); NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);
NS_IMETHOD InsertList(const nsString& aListType); NS_IMETHOD MakeOrChangeList(const nsString& aListType);
NS_IMETHOD Indent(const nsString& aIndent); NS_IMETHOD Indent(const nsString& aIndent);
NS_IMETHOD Align(const nsString& aAlign); NS_IMETHOD Align(const nsString& aAlign);
NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection); NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);

Просмотреть файл

@ -1151,10 +1151,11 @@ nsEditorShell::Open()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsEditorShell::CheckAndSaveDocument(PRBool *_retval) nsEditorShell::CheckAndSaveDocument(const PRUnichar *reasonToSave, PRBool *_retval)
{ {
*_retval = PR_FALSE; *_retval = PR_FALSE;
nsAutoString ReasonToSave(reasonToSave);
nsCOMPtr<nsIDOMDocument> theDoc; nsCOMPtr<nsIDOMDocument> theDoc;
nsresult rv = GetEditorDocument(getter_AddRefs(theDoc)); nsresult rv = GetEditorDocument(getter_AddRefs(theDoc));
if (NS_SUCCEEDED(rv) && theDoc) if (NS_SUCCEEDED(rv) && theDoc)
@ -1175,7 +1176,16 @@ nsEditorShell::CheckAndSaveDocument(PRBool *_retval)
nsAutoString tmp2 = GetString("DontSave"); nsAutoString tmp2 = GetString("DontSave");
nsAutoString title; nsAutoString title;
GetDocumentTitle(title); GetDocumentTitle(title);
nsAutoString saveMsg = GetString("SaveFilePrompt")+" "+"\""+title+"\""+GetString("QuestionMark"); nsAutoString saveMsg = GetString("SaveFilePrompt")+" "+"\""+title+"\"";
if (ReasonToSave.Length() > 0)
{
saveMsg += " ";
saveMsg += ReasonToSave;
saveMsg += GetString("QuestionMark");
} else {
saveMsg += GetString("QuestionMark");
}
EConfirmResult result = ConfirmWithCancel(GetString("SaveDocument"), saveMsg, EConfirmResult result = ConfirmWithCancel(GetString("SaveDocument"), saveMsg,
&tmp1, &tmp2); &tmp1, &tmp2);
if (result == eCancel) if (result == eCancel)
@ -1234,8 +1244,8 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
nsString title; nsString title;
res = HTMLDoc->GetTitle(title); res = HTMLDoc->GetTitle(title);
// Prompt for title ONLY for a new blank doc (no filespec yet) // Prompt for title if it's empty or user selected "Save As"
if (noFileSpec && NS_SUCCEEDED(res) && title.Length() == 0) if (NS_SUCCEEDED(res) && (saveAs || title.Length() == 0))
{ {
// Use a "prompt" common dialog to get title string from user // Use a "prompt" common dialog to get title string from user
NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &res); NS_WITH_SERVICE(nsICommonDialogs, dialog, kCommonDialogsCID, &res);
@ -1246,7 +1256,7 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
nsAutoString msg = GetString("NeedDocTitle"); nsAutoString msg = GetString("NeedDocTitle");
PRBool retVal = PR_FALSE; PRBool retVal = PR_FALSE;
res = dialog->Prompt(mContentWindow, caption.GetUnicode(), msg.GetUnicode(), res = dialog->Prompt(mContentWindow, caption.GetUnicode(), msg.GetUnicode(),
nsnull, &titleUnicode, &retVal); title.GetUnicode(), &titleUnicode, &retVal);
if( retVal == PR_FALSE) if( retVal == PR_FALSE)
{ {
@ -1277,13 +1287,13 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
nsAutoString fileName; nsAutoString fileName;
nsFileSpec parentPath; nsFileSpec parentPath;
titles = new nsString[2]; titles = new nsString[3];
if (!titles) if (!titles)
{ {
res = NS_ERROR_OUT_OF_MEMORY; res = NS_ERROR_OUT_OF_MEMORY;
goto SkipFilters; goto SkipFilters;
} }
filters = new nsString[2]; filters = new nsString[3];
if (!filters) if (!filters)
{ {
res = NS_ERROR_OUT_OF_MEMORY; res = NS_ERROR_OUT_OF_MEMORY;
@ -1301,7 +1311,9 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
*nextFilter++ = "*.htm; *.html; *.shtml"; *nextFilter++ = "*.htm; *.html; *.shtml";
*nextTitle++ = TextFiles; *nextTitle++ = TextFiles;
*nextFilter++ = "*.txt"; *nextFilter++ = "*.txt";
fileWidget->SetFilterList(2, titles, filters); *nextTitle++ = GetString("AllFiles");
*nextFilter++ = "*.*";
fileWidget->SetFilterList(3, titles, filters);
if (noFileSpec) if (noFileSpec)
{ {
@ -1313,14 +1325,14 @@ nsEditorShell::SaveDocument(PRBool saveAs, PRBool saveCopy, PRBool *_retval)
PRUnichar dot = (PRUnichar)'.'; PRUnichar dot = (PRUnichar)'.';
PRUnichar bslash = (PRUnichar)'\\'; PRUnichar bslash = (PRUnichar)'\\';
PRUnichar fslash = (PRUnichar)'/'; PRUnichar fslash = (PRUnichar)'/';
PRUnichar amp = (PRUnichar)'@'; PRUnichar at = (PRUnichar)'@';
PRUnichar colon = (PRUnichar)':'; PRUnichar colon = (PRUnichar)':';
PRUnichar underscore = (PRUnichar)'_'; PRUnichar underscore = (PRUnichar)'_';
title = title.ReplaceChar(space, underscore); title = title.ReplaceChar(space, underscore);
title = title.ReplaceChar(dot, underscore); title = title.ReplaceChar(dot, underscore);
title = title.ReplaceChar(bslash, underscore); title = title.ReplaceChar(bslash, underscore);
title = title.ReplaceChar(fslash, underscore); title = title.ReplaceChar(fslash, underscore);
title = title.ReplaceChar(amp, underscore); title = title.ReplaceChar(at, underscore);
title = title.ReplaceChar(colon, underscore); title = title.ReplaceChar(colon, underscore);
fileName = title + nsString(".html"); fileName = title + nsString(".html");
} }
@ -1405,7 +1417,7 @@ nsEditorShell::CloseWindow()
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
PRBool result; PRBool result;
rv = CheckAndSaveDocument(&result); rv = CheckAndSaveDocument(GetString("BeforeClosing").GetUnicode(),&result);
// Don't close the window if there was an error saving file or // Don't close the window if there was an error saving file or
// user canceled an action along the way // user canceled an action along the way
@ -1436,7 +1448,7 @@ NS_IMETHODIMP
nsEditorShell::Exit() nsEditorShell::Exit()
{ {
PRBool result; PRBool result;
nsresult rv = CheckAndSaveDocument(&result); nsresult rv = CheckAndSaveDocument(GetString("BeforeClosing").GetUnicode(),&result);
// Don't shutdown if there was an error saving file or // Don't shutdown if there was an error saving file or
// user canceled an action along the way // user canceled an action along the way
if (NS_SUCCEEDED(rv) && result) if (NS_SUCCEEDED(rv) && result)
@ -1455,9 +1467,9 @@ nsEditorShell::Exit()
NS_IMETHODIMP NS_IMETHODIMP
nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType, PRUnichar **_retval) nsEditorShell::GetLocalFileURL(nsIDOMWindow *parent, const PRUnichar *filterType, PRUnichar **_retval)
{ {
nsAutoString aFilterType(filterType); nsAutoString FilterType(filterType);
PRBool htmlFilter = aFilterType.EqualsIgnoreCase("html"); PRBool htmlFilter = FilterType.EqualsIgnoreCase("html");
PRBool imgFilter = aFilterType.EqualsIgnoreCase("img"); PRBool imgFilter = FilterType.EqualsIgnoreCase("img");
*_retval = nsnull; *_retval = nsnull;
@ -2475,7 +2487,7 @@ nsEditorShell::GetDocumentLength(PRInt32 *aDocumentLength)
NS_IMETHODIMP NS_IMETHODIMP
nsEditorShell::InsertList(const PRUnichar *listType) nsEditorShell::MakeOrChangeList(const PRUnichar *listType)
{ {
nsresult err = NS_NOINTERFACE; nsresult err = NS_NOINTERFACE;
@ -2484,14 +2496,24 @@ nsEditorShell::InsertList(const PRUnichar *listType)
switch (mEditorType) switch (mEditorType)
{ {
case eHTMLTextEditorType: case eHTMLTextEditorType:
err = mEditor->InsertList(aListType); if (aListType == "")
{
err = mEditor->RemoveList("ol");
if(NS_SUCCEEDED(err))
{
err = mEditor->RemoveList("ul");
if(NS_SUCCEEDED(err))
err = mEditor->RemoveList("dl");
}
}
else
err = mEditor->MakeOrChangeList(aListType);
break; break;
case ePlainTextEditorType: case ePlainTextEditorType:
default: default:
err = NS_ERROR_NOT_IMPLEMENTED; err = NS_ERROR_NOT_IMPLEMENTED;
} }
return err; return err;
} }
@ -2506,6 +2528,17 @@ nsEditorShell::RemoveList(const PRUnichar *listType)
switch (mEditorType) switch (mEditorType)
{ {
case eHTMLTextEditorType: case eHTMLTextEditorType:
if (aListType == "")
{
err = mEditor->RemoveList("ol");
if(NS_SUCCEEDED(err))
{
err = mEditor->RemoveList("ul");
if(NS_SUCCEEDED(err))
err = mEditor->RemoveList("dl");
}
}
else
err = mEditor->RemoveList(aListType); err = mEditor->RemoveList(aListType);
break; break;

Просмотреть файл

@ -114,8 +114,11 @@ interface nsIEditorShell : nsISupports
* return value: * return value:
* false ONLY if user executed "Cancel" in the SaveAs dialog * false ONLY if user executed "Cancel" in the SaveAs dialog
* true if no changes in doc, or file was saved successfully * true if no changes in doc, or file was saved successfully
* @param reasonToSave
* A string to append after "Save changes to <URL>"
* If null, just the question mark will be appended
*/ */
boolean CheckAndSaveDocument(); boolean CheckAndSaveDocument(in wstring reasonToSave);
void CloseWindow(); void CloseWindow();
void Print(); void Print();
@ -158,7 +161,7 @@ interface nsIEditorShell : nsISupports
void InsertSource(in wstring textToInsert); void InsertSource(in wstring textToInsert);
void InsertBreak(); void InsertBreak();
void InsertList(in wstring listType); void MakeOrChangeList(in wstring listType);
void RemoveList(in wstring listType); void RemoveList(in wstring listType);
void Indent(in wstring indent); void Indent(in wstring indent);
void Align(in wstring align); void Align(in wstring align);

Просмотреть файл

@ -1695,9 +1695,12 @@ NS_IMETHODIMP nsHTMLEditor::SetParagraphFormat(const nsString& aParagraphFormat)
{ {
res = InsertBasicBlock("p"); res = InsertBasicBlock("p");
} }
//XXX: TODO: Do we really want to support setting list types here?
// If yes, we need to add "dd", "dt" for <dl> support
else if (tag == "li") else if (tag == "li")
{ {
res = InsertList("ul"); //XXX: Why do we assume "ul" What about "ol"? This will change an OL into a UL list!
res = MakeOrChangeList("ul");
} }
else else
{ {
@ -1949,7 +1952,7 @@ nsHTMLEditor::RemoveParent(const nsString &aParentTag)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditor::InsertList(const nsString& aListType) nsHTMLEditor::MakeOrChangeList(const nsString& aListType)
{ {
nsresult res; nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }

Просмотреть файл

@ -103,7 +103,7 @@ public:
NS_IMETHOD ReplaceBlockParent(nsString& aParentTag); NS_IMETHOD ReplaceBlockParent(nsString& aParentTag);
NS_IMETHOD RemoveParent(const nsString &aParentTag); NS_IMETHOD RemoveParent(const nsString &aParentTag);
NS_IMETHOD InsertList(const nsString& aListType); NS_IMETHOD MakeOrChangeList(const nsString& aListType);
NS_IMETHOD RemoveList(const nsString& aListType); NS_IMETHOD RemoveList(const nsString& aListType);
NS_IMETHOD InsertBasicBlock(const nsString& aBlockType); NS_IMETHOD InsertBasicBlock(const nsString& aBlockType);
NS_IMETHOD Indent(const nsString& aIndent); NS_IMETHOD Indent(const nsString& aIndent);

Просмотреть файл

@ -488,7 +488,7 @@ nsHTMLEditorLog::SetBodyAttribute(const nsString& aAttr, const nsString& aValue)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLEditorLog::InsertList(const nsString& aListType) nsHTMLEditorLog::MakeOrChangeList(const nsString& aListType)
{ {
nsAutoHTMLEditorLogLock logLock(this); nsAutoHTMLEditorLogLock logLock(this);
@ -496,13 +496,13 @@ nsHTMLEditorLog::InsertList(const nsString& aListType)
{ {
PrintSelection(); PrintSelection();
Write("window.editorShell.InsertList(\""); Write("window.editorShell.MakeOrChangeList(\"");
PrintUnicode(aListType); PrintUnicode(aListType);
Write("\");\n"); Write("\");\n");
Flush(); Flush();
} }
return nsHTMLEditor::InsertList(aListType); return nsHTMLEditor::MakeOrChangeList(aListType);
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -79,7 +79,7 @@ public:
NS_IMETHOD SetBackgroundColor(const nsString& aColor); NS_IMETHOD SetBackgroundColor(const nsString& aColor);
NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue); NS_IMETHOD SetBodyAttribute(const nsString& aAttr, const nsString& aValue);
NS_IMETHOD InsertList(const nsString& aListType); NS_IMETHOD MakeOrChangeList(const nsString& aListType);
NS_IMETHOD Indent(const nsString& aIndent); NS_IMETHOD Indent(const nsString& aIndent);
NS_IMETHOD Align(const nsString& aAlign); NS_IMETHOD Align(const nsString& aAlign);
NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection); NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);

Просмотреть файл

@ -283,7 +283,7 @@ public:
* Document me! * Document me!
* *
*/ */
NS_IMETHOD InsertList(const nsString& aListType)=0; NS_IMETHOD MakeOrChangeList(const nsString& aListType)=0;
/** /**
* Document me! * Document me!

Просмотреть файл

@ -243,20 +243,12 @@ function EditorOpen()
function EditorNewPlaintext() function EditorNewPlaintext()
{ {
dump("In EditorNewPlaintext..\n");
window.openDialog( "chrome://editor/content/TextEditorAppShell.xul", window.openDialog( "chrome://editor/content/TextEditorAppShell.xul",
"_blank", "_blank",
"chrome,dialog=no,all", "chrome,dialog=no,all",
"chrome://editor/content/EditorInitPagePlain.html" ); "chrome://editor/content/EditorInitPagePlain.html");
} }
function EditorNewBrowser()
{
dump("In EditorNewBrowser..\n");
window.open( "chrome://navigator/content/", "_blank", "chrome" );
}
function EditorSave() function EditorSave()
{ {
dump("In EditorSave...\n"); dump("In EditorSave...\n");
@ -392,11 +384,6 @@ function EditorListProperties()
contentWindow.focus(); contentWindow.focus();
} }
function EditorSetListStyle(listType)
{
// Write me! Replace EditorInsertList when working?
}
function EditorSetFontSize(size) function EditorSetFontSize(size)
{ {
if( size == "0" || size == "normal" || if( size == "0" || size == "normal" ||
@ -469,7 +456,7 @@ function EditorToggleStyle(styleName)
// which is the appropriate button // which is the appropriate button
// cmanske: I don't think we should depend on button state! // cmanske: I don't think we should depend on button state!
// (this won't work for other list styles, anyway) // (this won't work for other list styles, anyway)
// We need to get list type from document (See EditorSetListStyle) // We need to get list type from document
var theButton = document.getElementById(styleName + "Button"); var theButton = document.getElementById(styleName + "Button");
dump("Toggling style " + styleName + "\n"); dump("Toggling style " + styleName + "\n");
if (theButton) if (theButton)
@ -744,7 +731,7 @@ function EditorDeleteTableCell()
contentWindow.focus(); contentWindow.focus();
} }
function EditorInsertList(listType) function EditorMakeOrChangeList(listType)
{ {
// check the observer node, // check the observer node,
// which is the appropriate button // which is the appropriate button
@ -759,7 +746,7 @@ function EditorInsertList(listType)
editorShell.RemoveList(listType); editorShell.RemoveList(listType);
} }
else else
editorShell.InsertList(listType); editorShell.MakeOrChangeList(listType);
contentWindow.focus(); contentWindow.focus();
} }

Просмотреть файл

@ -28,8 +28,9 @@
*/ */
a[name] { a[name] {
/* TEMPORARY TO COMPENSATE FOR BUG */
padding-left: 20px; padding-left: 20px;
background: url(chrome://editor/skin/images/anchor.gif) 5px 50% no-repeat; background: url(chrome://editor/skin/images/anchor.gif);
} }
table { table {

Просмотреть файл

@ -30,10 +30,12 @@
<!DOCTYPE window SYSTEM "chrome://editor/locale/EditorAppShell.dtd"> <!DOCTYPE window SYSTEM "chrome://editor/locale/EditorAppShell.dtd">
<!-- NOTE: If we don't have "title" set, text editor doesn't work! -->
<window id="main-window" xmlns:html="http://www.w3.org/TR/REC-html40" <window id="main-window" xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="TextEditorOnLoad()" onload="TextEditorOnLoad()"
onunload="EditorShutdown()" onunload="EditorShutdown()"
title="&textEditorWindow.titlemodifier;"
titlemodifier="&textEditorWindow.titlemodifier;" titlemodifier="&textEditorWindow.titlemodifier;"
titlemenuseparator="&editorWindow.titlemodifiermenuseparator;" titlemenuseparator="&editorWindow.titlemodifiermenuseparator;"
align="vertical" align="vertical"

Просмотреть файл

@ -165,6 +165,7 @@
<broadcaster id="Editor:InsertHTML" value="&insertHTMLSourceCmd.label;" disabled="false" oncommand="EditorInsertHTML()"/> <broadcaster id="Editor:InsertHTML" value="&insertHTMLSourceCmd.label;" disabled="false" oncommand="EditorInsertHTML()"/>
<broadcaster id="Editor:InsertBreak" value="&insertLineBreakCmd.label;" disabled="false" oncommand="_EditorNotImplemented()"/> <broadcaster id="Editor:InsertBreak" value="&insertLineBreakCmd.label;" disabled="false" oncommand="_EditorNotImplemented()"/>
<broadcaster id="Editor:InsertBreakAll" value="&insertBreakBelowImagesCmd.label;" disabled="false" oncommand="_EditorNotImplemented()"/> <broadcaster id="Editor:InsertBreakAll" value="&insertBreakBelowImagesCmd.label;" disabled="false" oncommand="_EditorNotImplemented()"/>
<broadcaster id="cmd_preferences"/>
</broadcasterset> </broadcasterset>
<!-- Editor menu items --> <!-- Editor menu items -->
@ -215,6 +216,9 @@
<menuitem accesskey="&editfindnext.accesskey;" key="findnextkb" observes="Editor:FindNext"/> <menuitem accesskey="&editfindnext.accesskey;" key="findnextkb" observes="Editor:FindNext"/>
<menuseparator /> <menuseparator />
<menuitem accesskey="&editcheckspelling.accesskey;" key="checkspellingkb" observes="Editor:CheckSpelling"/> <menuitem accesskey="&editcheckspelling.accesskey;" key="checkspellingkb" observes="Editor:CheckSpelling"/>
<menuseparator />
<!-- TODO: PREF PANELS FOR EDITOR. Replace pref-publish with pref-editor -->
<menuitem id="menu_preferences" oncommand="goPreferences('navigator.xul', 'chrome://pref/content/pref-publish.xul')"/>
</menupopup> </menupopup>
</menu> </menu>
@ -496,17 +500,6 @@
<!-- List Style (opens dialog) --> <!-- List Style (opens dialog) -->
<menuitem id="listProps" value="&listProps.label;" accesskey="&formatlistmenu.accesskey;" oncommand="EditorListProperties()"/> <menuitem id="listProps" value="&listProps.label;" accesskey="&formatlistmenu.accesskey;" oncommand="EditorListProperties()"/>
<!-- We used a menu in 4.x, but we had list stuff in Paragraph Properties
Since we killed that, make list item bring up new List Properties dialog
<menu id="listMenu" value="&listMenu.label;" accesskey="&formatlistmenu.accesskey;">
<menupopup>
<menuitem value="&listNoneCmd.label;" accesskey="&listnone.accesskey;" oncommand="EditorSetListStyle('')"/>
<menuitem value="&listBullettedCmd.label;" accesskey="&listbulletted.accesskey;" oncommand="EditorSetListStyle('ul')"/>
<menuitem value="&listNumberedCmd.label;" accesskey="&listnumbered.accesskey;" oncommand="EditorSetListStyle('ol')"/>
<menuitem value="&listDefinitionCmd.label;" accesskey="&listdefinition.accesskey;" oncommand="EditorSetListStyle('dl')"/>
</menupopup>
</menu>
-->
<!-- Stylesheet submenu --> <!-- Stylesheet submenu -->
<menu id="stylesheetMenu" value="&stylesheetMenu.label;" accesskey="&formatstylesheetmenu.accesskey;"> <menu id="stylesheetMenu" value="&stylesheetMenu.label;" accesskey="&formatstylesheetmenu.accesskey;">
<menupopup> <menupopup>
@ -657,11 +650,11 @@
<observes element="Editor:Underline" attribute="underline" onbroadcast="onStyleChange('underline')"/> <observes element="Editor:Underline" attribute="underline" onbroadcast="onStyleChange('underline')"/>
</titledbutton> </titledbutton>
<titledbutton id="ulButton" src="&bulletListIcon.url;" align="bottom" onclick="EditorInsertList('ul')"> <titledbutton id="ulButton" src="&bulletListIcon.url;" align="bottom" onclick="EditorMakeOrChangeList('ul')">
<observes element="Editor:Paragraph:ListType" attribute="format" onbroadcast="onListFormatChange('ul')"/> <observes element="Editor:Paragraph:ListType" attribute="format" onbroadcast="onListFormatChange('ul')"/>
</titledbutton> </titledbutton>
<titledbutton id="olButton" src="&numberListIcon.url;" align="bottom" onclick="EditorInsertList('ol')"> <titledbutton id="olButton" src="&numberListIcon.url;" align="bottom" onclick="EditorMakeOrChangeList('ol')">
<observes element="Editor:Paragraph:ListType" attribute="format" onbroadcast="onListFormatChange('ol')"/> <observes element="Editor:Paragraph:ListType" attribute="format" onbroadcast="onListFormatChange('ol')"/>
</titledbutton> </titledbutton>
@ -673,7 +666,8 @@
<!-- DEBUG only --> <!-- DEBUG only -->
<menu id="debugMenu" value="&debugMenu.label;"> <menu id="debugMenu" value="&debugMenu.label;">
<menupopup> <menupopup>
<menuitem value="Composer with Test Page" oncommand="window.openDialog('chrome://editor/content','_blank','chrome,all,dialog=no','chrome://editor/content/EditorInitPage.html')"/> <menuitem value="&newEditorTestPage.label;" oncommand="window.openDialog('chrome://editor/content','_blank','chrome,all,dialog=no','chrome://editor/content/EditorInitPage.html')"/>
<menuitem value="&textEditorCmd.label;" oncommand="EditorNewPlaintext();" />
<menuitem value="&outputTextCmd.label;" <menuitem value="&outputTextCmd.label;"
oncommand="EditorGetText()"/> oncommand="EditorGetText()"/>
<menuitem value="&outputHTMLCmd.label;" <menuitem value="&outputHTMLCmd.label;"

Просмотреть файл

@ -1,6 +1,9 @@
# #
# moved from content/ # moved from content/
# #
# Note: embeded "\n" translate into breaks (<br>)
# Don't tranalate!!!
#
Yes=Yes Yes=Yes
No=No No=No
Cancel=Cancel Cancel=Cancel
@ -8,6 +11,7 @@ Save=Save
DontSave=Don't Save DontSave=Don't Save
More=More More=More
Fewer=Fewer Fewer=Fewer
Less=Less
None=None None=None
none=none none=none
OpenHTMLFile=Open HTML File OpenHTMLFile=Open HTML File
@ -26,10 +30,11 @@ IMGFiles=Image Files
TextFiles=Text Files TextFiles=Text Files
AllFiles=All Files AllFiles=All Files
SaveFilePrompt=Save changes to SaveFilePrompt=Save changes to
BeforeClosing=\nbefore closing
QuestionMark=? QuestionMark=?
SaveFileFailed=Saving file failed! SaveFileFailed=Saving file failed!
DocumentTitle=Document Title DocumentTitle=Document Title
NeedDocTitle=Enter a title for the current page./nThe title identifies the page in the window title and bookmarks. NeedDocTitle=Enter a title for the current page.\/nThe title identifies the page in the window title and bookmarks.
AttributesFor=Current attributes for: AttributesFor=Current attributes for:
MissingImageError=Please enter or choose an image<br>of type gif, jpg or png. MissingImageError=Please enter or choose an image<br>of type gif, jpg or png.
EmptyHREFError=You must enter or choose<br>a location (URL) to create a new link. EmptyHREFError=You must enter or choose<br>a location (URL) to create a new link.
@ -44,7 +49,7 @@ DuplicateAnchorNameError=already exists in this page.<br>Please enter a differen
BulletStyle=Bullet Style: BulletStyle=Bullet Style:
SolidCircle=Solid circle SolidCircle=Solid circle
OpenCircle=Open circle OpenCircle=Open circle
OpenSquare=Open square SolidSquare=Solid square
NumberStyle=Number Style: NumberStyle=Number Style:
Automatic=Automatic Automatic=Automatic
Style_1=1,2,3... Style_1=1,2,3...
@ -57,6 +62,5 @@ Percent=percent
PercentOfCell=% of cell PercentOfCell=% of cell
PercentOfWindow=% of window PercentOfWindow=% of window
untitled=untitled untitled=untitled
ComposerCaptionSuffix=- Composer
NoNamedAnchors=(No named anchors in this page) NoNamedAnchors=(No named anchors in this page)
NoHeadings=(No headings in this page) NoHeadings=(No headings without anchors)

Просмотреть файл

@ -323,7 +323,7 @@
<!ENTITY paragraphdesc.accesskey "d"> <!ENTITY paragraphdesc.accesskey "d">
<!-- List menu items --> <!-- List menu items -->
<!ENTITY listProps.label "List"> <!ENTITY listProps.label "List...">
<!ENTITY formatlistmenu.accesskey "l"> <!ENTITY formatlistmenu.accesskey "l">
<!ENTITY listNoneCmd.label "None"> <!ENTITY listNoneCmd.label "None">
<!ENTITY listnone.accesskey "o"> <!ENTITY listnone.accesskey "o">
@ -391,6 +391,8 @@
<!-- debug menu items --> <!-- debug menu items -->
<!ENTITY debugMenu.label "Debug"> <!ENTITY debugMenu.label "Debug">
<!ENTITY newEditorTestPage.label "Composer with Test Page">
<!ENTITY textEditorCmd.label "Plaintext Editor">
<!ENTITY outputTextCmd.label "Output Text"> <!ENTITY outputTextCmd.label "Output Text">
<!ENTITY outputHTMLCmd.label "Output HTML"> <!ENTITY outputHTMLCmd.label "Output HTML">
<!ENTITY outputXIFCmd.label "Output XIF"> <!ENTITY outputXIFCmd.label "Output XIF">

Просмотреть файл

@ -36,23 +36,18 @@
align="vertical" flex="100%"> align="vertical" flex="100%">
<!-- Methods common to all editor dialogs --> <!-- Methods common to all editor dialogs -->
<script language="JavaScript" src="chrome://editor/content/EdDialogCommon.js"> <script language="JavaScript" src="chrome://editor/content/EdDialogCommon.js"/>
</script> <script language="JavaScript" src="chrome://editor/content/EdInsSrc.js"/>
<script language="JavaScript" src="chrome://editor/content/EdInsSrc.js">
</script>
<script language="JavaScript" src="chrome://global/content/dialogOverlay.js" /> <script language="JavaScript" src="chrome://global/content/dialogOverlay.js" />
<xul:broadcaster id="args" value=""/> <xul:broadcaster id="args" value=""/>
<xul:keyset id="keyset"/> <xul:keyset id="keyset"/>
<xul:box> <label id="srcMessage" for="srcInput">&sourceEditField.label;</label>
<label id="srcMessage"/>
</xul:box>
<xul:box>
<textarea rows="6" cols="50" id="srcInput" /> <textarea rows="6" cols="50" id="srcInput" />
</xul:box> <div>&example.label;</div>
<xul:spring class="spacer"/>
<xul:spring flex="100%"/> <div class="separator" align="horizontal"/>
<!-- from global dialogOverlay --> <!-- from global dialogOverlay -->
<xul:box id="okCancelButtons"/> <xul:box id="okCancelButtons"/>
</xul:window> </xul:window>

Просмотреть файл

@ -80,7 +80,7 @@
<label for="border"> &borderEditField.label; </label> <label for="border"> &borderEditField.label; </label>
</td> </td>
<td> <td>
<input type="text" id="borderInput" size="4" onkeyup="forceInteger('border')"/> <input type="text" id="borderInput" size="4" onkeyup="forceInteger('borderInput')"/>
</td> </td>
<!-- THIS IS DUMB Can't figure out how to put "pixels" after the <!-- THIS IS DUMB Can't figure out how to put "pixels" after the
input box and make them center vertically. Used another TD instead --> input box and make them center vertically. Used another TD instead -->

Просмотреть файл

@ -34,6 +34,10 @@ var NamedAnchorList = 0;
var HNodeArray; var HNodeArray;
var haveNamedAnchors = false; var haveNamedAnchors = false;
var haveHeadings = false; var haveHeadings = false;
var MoreSection;
var MoreFewerButton;
var SeeMore = false;
var AdvancedEditSection;
// NOTE: Use "href" instead of "a" to distinguish from Named Anchor // NOTE: Use "href" instead of "a" to distinguish from Named Anchor
// The returned node is has an "a" tagName // The returned node is has an "a" tagName
@ -54,6 +58,9 @@ function Startup()
hrefInput = document.getElementById("hrefInput"); hrefInput = document.getElementById("hrefInput");
NamedAnchorList = document.getElementById("NamedAnchorList"); NamedAnchorList = document.getElementById("NamedAnchorList");
HeadingsList = document.getElementById("HeadingsList"); HeadingsList = document.getElementById("HeadingsList");
MoreSection = document.getElementById("MoreSection");
MoreFewerButton = document.getElementById("MoreFewerButton");
AdvancedEditSection = document.getElementById("AdvancedEditButton");
// Get a single selected anchor element // Get a single selected anchor element
anchorElement = editorShell.GetSelectedElement(tagName); anchorElement = editorShell.GetSelectedElement(tagName);
@ -165,8 +172,10 @@ function Startup()
linkTextInput = null; linkTextInput = null;
} }
} }
//TODO; We should get the current state of the "More" area from a pref
window.sizeToContent(); // Initialize to true, but calling onMoreFewer will toggle to "Fewer"
SeeMore = true;
onMoreFewer();
} }
// Set dialog widgets with attribute data // Set dialog widgets with attribute data
@ -220,9 +229,10 @@ function FillListboxes()
// (this may miss nearby anchors, but at least we don't insert another // (this may miss nearby anchors, but at least we don't insert another
// under the same heading) // under the same heading)
var child = heading.firstChild; var child = heading.firstChild;
dump(child.nodeName+" = Heading's first child nodeName\n"); dump(child.name+" = Child.name. Length="+child.name.length+"\n");
if (child && child.nodeName == "a" && child.name && child.name.length > 0) if (child && child.nodeName == "A" && child.name && (child.name.length>0)) {
continue; continue;
}
var range = editorShell.editorDocument.createRange(); var range = editorShell.editorDocument.createRange();
range.setStart(heading,0); range.setStart(heading,0);
@ -256,8 +266,10 @@ function FillListboxes()
function GetExistingHeadingIndex(text) function GetExistingHeadingIndex(text)
{ {
dump("Heading text: "+text+"\n");
for (i=0; i < HeadingsList.length; i++) { for (i=0; i < HeadingsList.length; i++) {
if (HeadingsList[i].name == name) dump("HeadingListItem"+i+": "+HeadingsList.options[i].value+"\n");
if (HeadingsList.options[i].value == text)
return i; return i;
} }
return -1; return -1;
@ -277,6 +289,33 @@ function SelectHeading()
} }
} }
function onMoreFewer()
{
if (SeeMore)
{
// This doesn't work very well - lots of layout bugs
// MoreSection.setAttribute("style","visibility:collapse");
MoreSection.setAttribute("style","display: none");
MoreFewerButton.setAttribute("value",GetString("More"));
MoreFewerButton.removeAttribute("more");
//AdvancedEditSection.setAttribute("style","display: none");
dump("Set button text\n");
SeeMore = false;
}
else
{
// MoreSection.setAttribute("style","visibility: inherit");
MoreSection.setAttribute("style","display: inherit");
MoreFewerButton.setAttribute("value",GetString("Fewer"));
MoreFewerButton.setAttribute("more","1");
//AdvancedEditSection.setAttribute("style","display: inherit");
SeeMore = true;
}
window.sizeToContent();
}
// Get and validate data from widgets. // Get and validate data from widgets.
// Set attributes on globalElement so they can be accessed by AdvancedEdit() // Set attributes on globalElement so they can be accessed by AdvancedEdit()
function ValidateData() function ValidateData()
@ -290,6 +329,7 @@ function ValidateData()
} else if (insertNew) { } else if (insertNew) {
// We must have a URL to insert a new link // We must have a URL to insert a new link
//NOTE: WE ACCEPT AN EMPTY HREF TO ALLOW REMOVING AN EXISTING LINK, //NOTE: WE ACCEPT AN EMPTY HREF TO ALLOW REMOVING AN EXISTING LINK,
dump("Empty HREF error\n");
ShowInputErrorMessage(GetString("EmptyHREFError")); ShowInputErrorMessage(GetString("EmptyHREFError"));
return false; return false;
} }

Просмотреть файл

@ -29,55 +29,58 @@
<!DOCTYPE window SYSTEM "chrome://editor/locale/EditorLinkProperties.dtd"> <!DOCTYPE window SYSTEM "chrome://editor/locale/EditorLinkProperties.dtd">
<xul:window title="&windowTitle.label;" <window title="&windowTitle.label;"
xmlns:xul ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns="http://www.w3.org/TR/REC-html40" xmlns:html="http://www.w3.org/TR/REC-html40"
onload = "Startup()" onload = "Startup()"
align="vertical"> align="vertical" >
<!-- Methods common to all editor dialogs --> <html:script language="JavaScript" src="chrome://editor/content/EdDialogCommon.js"/>
<script language="JavaScript" src="chrome://editor/content/EdDialogCommon.js"> <html:script language="JavaScript" src="chrome://editor/content/EdLinkProps.js"/>
</script> <html:script language="JavaScript" src="chrome://global/content/dialogOverlay.js" />
<script language="JavaScript" src="chrome://editor/content/EdLinkProps.js">
</script>
<script language="JavaScript" src="chrome://global/content/dialogOverlay.js" />
<xul:broadcaster id="args" value=""/> <broadcaster id="args" value=""/>
<xul:keyset id="keyset"/> <keyset id="keyset"/>
<xul:box align="vertical" style="min-width: 20em"> <box align="vertical" style="min-width: 20em">
<label id="linkTextCaption" for="linkTextMessage"> &LinkText.label; </label> <html:label id="linkTextCaption" for="linkTextMessage"> &LinkText.label; </html:label>
<div id="linkTextMessage" style="margin-left: 3em">[replace this]</div> <html:div id="linkTextMessage" style="margin-left: 3em">[replace this]</html:div>
<input type="text" size="25" length="25" id="linkTextInput"/> <html:input type="text" size="25" length="25" id="linkTextInput"/>
<xul:spring class="spacer"/> <spring class="spacer"/>
<fieldset><legend align="left"> &LinkURLFieldset.label; </legend> <html:fieldset><html:legend align="left"> &LinkURLFieldset.label; </html:legend>
<xul:box align="vertical" style="width: 100%; height: 100%"> <box align="vertical" style="width: 100%; height: 100%">
<xul:box align="horizontal"> <box align="vertical">
<div> &LinkURLEditField.label;</div> <box align="horizontal">
<xul:spring flex="100%"/> <html:div> &LinkURLEditField.label;</html:div>
<div><xul:titledbutton id="RemoveLink" onclick="RemoveLink()" value="&RemoveLinkButton.label;"/> <spring flex="100%"/>
</div> <html:div><titledbutton id="RemoveLink" onclick="RemoveLink()" value="&RemoveLinkButton.label;"/>
</xul:box> </html:div>
<xul:box align="horizontal"> </box>
<input type="text" size="25" length="25" id="hrefInput"></input> <box align="horizontal">
<xul:spring flex="100%"/> <html:input type="text" size="25" length="25" id="hrefInput"></html:input>
<spring flex="100%"/>
<!-- The div prevents button from being the same height as the input field --> <!-- The div prevents button from being the same height as the input field -->
<div><xul:titledbutton id="ChooseFile1" onclick="ChooseFile()" value="&LinkChooseFileButton.label;"/></div> <html:div><titledbutton id="ChooseFile" onclick="ChooseFile()" value="&LinkChooseFileButton.label;"/></html:div>
</xul:box> </box>
</xul:box> </box>
<xul:spring class="spacer"/> <!-- ***** The style: width setting is need to cover a bug in button width resizing when text changes ***** -->
<div>&NamedAnchorMsg.label;</div> <html:div><titledbutton id="MoreFewerButton" align="left" style="width: 6em" onclick="onMoreFewer()"/></html:div>
<select id="NamedAnchorList" style="width: 15em;" size="3" onchange="SelectNamedAnchor()"/> <box id="MoreSection" align="vertical">
<xul:spring class="spacer"/> <spring class="spacer"/>
<div>&HeadingMsg.label;</div> <html:div>&NamedAnchorMsg.label;</html:div>
<select id="HeadingsList" style="width: 15em;" size="3" onchange="SelectHeading()"/> <html:select id="NamedAnchorList" size="3" style="min-width: 1em" onchange="SelectNamedAnchor()"/>
<div>&HeadingMsg2.label;</div> <spring class="spacer"/>
</fieldset> <html:div>&HeadingMsg.label;</html:div>
</xul:box> <html:select id="HeadingsList" size="3" style="min-width: 1em" onchange="SelectHeading()"/>
<html:div>&HeadingMsg2.label;</html:div>
</box>
</box>
</html:fieldset>
</box>
<!-- from EdDialogOverlay --> <!-- from EdDialogOverlay -->
<xul:box id="AdvancedEditButton"/> <box id="AdvancedEditButton"/>
<!-- from global dialogOverlay --> <!-- from global dialogOverlay -->
<xul:box id="okCancelButtons"/> <box id="okCancelButtons"/>
</xul:window> </window>

Просмотреть файл

@ -24,14 +24,16 @@
//Cancel() is in EdDialogCommon.js //Cancel() is in EdDialogCommon.js
var insertNew = true; var insertNew = true;
var tagname = "TAG NAME" var tagname = "TAG NAME"
var ListStyleList; var ListTypeList;
var BulletStyleList; var BulletStyleList;
var BulletStyleLabel; var BulletStyleLabel;
var StartingNumberInput; var StartingNumberInput;
var StartingNumberLabel; var StartingNumberLabel;
var BulletStyleIndex = 0; var BulletStyleIndex = 0;
var NumberStyleIndex = 0; var NumberStyleIndex = 0;
var ListStyle = ""; var ListElement = 0;
var ListType = "";
var AdvancedEditButton;
// dialog initialization code // dialog initialization code
function Startup() function Startup()
@ -41,43 +43,46 @@ function Startup()
doSetOKCancel(onOK, null); doSetOKCancel(onOK, null);
ListStyleList = document.getElementById("ListStyle"); ListTypeList = document.getElementById("ListType");
BulletStyleList = document.getElementById("BulletStyle"); BulletStyleList = document.getElementById("BulletStyle");
BulletStyleLabel = document.getElementById("BulletStyleLabel"); BulletStyleLabel = document.getElementById("BulletStyleLabel");
StartingNumberInput = document.getElementById("StartingNumber"); StartingNumberInput = document.getElementById("StartingNumber");
StartingNumberLabel = document.getElementById("StartingNumberLabel"); StartingNumberLabel = document.getElementById("StartingNumberLabel");
AdvancedEditButton = document.getElementById("AdvancedEditButton");
// Try to get an existing list // Try to get an existing list
// ListElement = editorShell.GetElementOrParentByTagName("list",null);
// The copy to use in AdvancedEdit
if (ListElement)
globalElement = ListElement.cloneNode(false);
dump("List and global elements: "+ListElement+globalElement+"\n");
InitDialog(); InitDialog();
ListStyleList.focus();
ListTypeList.focus();
} }
function InitDialog() function InitDialog()
{ {
//TODO: Get the current list style and set in ListStyle variable if (ListElement)
ListStyle = "ul"; ListType = ListElement.nodeName.toLowerCase();
else
ListType = "";
BuildBulletStyleList(); BuildBulletStyleList();
/*
if(!element)
{
dump("Failed to get selected element or create a new one!\n");
window.close();
}
*/
} }
function BuildBulletStyleList() function BuildBulletStyleList()
{ {
// Put methods on the object if I can figure out its name!
// (SELECT and HTMLSelect don't work!)
//BulletStyleList.clear();
ClearList(BulletStyleList); ClearList(BulletStyleList);
var label = ""; var label = "";
var selectedIndex = -1; var selectedIndex = -1;
if (ListStyle == "ul") dump("List Type: "+ListType+" globalElement: "+globalElement+"\n");
if (ListType == "ul")
{ {
BulletStyleList.removeAttribute("disabled"); BulletStyleList.removeAttribute("disabled");
BulletStyleLabel.removeAttribute("disabled"); BulletStyleLabel.removeAttribute("disabled");
@ -87,11 +92,12 @@ function BuildBulletStyleList()
AppendStringToListByID(BulletStyleList,"SolidCircle"); AppendStringToListByID(BulletStyleList,"SolidCircle");
AppendStringToListByID(BulletStyleList,"OpenCircle"); AppendStringToListByID(BulletStyleList,"OpenCircle");
AppendStringToListByID(BulletStyleList,"OpenSquare"); AppendStringToListByID(BulletStyleList,"SolidSquare");
BulletStyleList.selectedIndex = BulletStyleIndex; BulletStyleList.selectedIndex = BulletStyleIndex;
ListStyleList.selectedIndex = 1; ListTypeList.selectedIndex = 1;
} else if (ListStyle == "ol") }
else if (ListType == "ol")
{ {
BulletStyleList.removeAttribute("disabled"); BulletStyleList.removeAttribute("disabled");
BulletStyleLabel.removeAttribute("disabled"); BulletStyleLabel.removeAttribute("disabled");
@ -106,59 +112,135 @@ function BuildBulletStyleList()
AppendStringToListByID(BulletStyleList,"Style_a"); AppendStringToListByID(BulletStyleList,"Style_a");
BulletStyleList.selectedIndex = NumberStyleIndex; BulletStyleList.selectedIndex = NumberStyleIndex;
ListStyleList.selectedIndex = 2; ListTypeList.selectedIndex = 2;
} else { }
else
{
BulletStyleList.setAttribute("disabled", "true"); BulletStyleList.setAttribute("disabled", "true");
BulletStyleLabel.setAttribute("disabled", "true"); BulletStyleLabel.setAttribute("disabled", "true");
StartingNumberInput.setAttribute("disabled", "true"); StartingNumberInput.setAttribute("disabled", "true");
StartingNumberLabel.setAttribute("disabled", "true"); StartingNumberLabel.setAttribute("disabled", "true");
if (ListStyle == "dl") if (ListType == "dl")
ListStyleList.selectedIndex = 3; ListTypeList.selectedIndex = 3;
else else
ListStyleList.selectedIndex = 0; ListTypeList.selectedIndex = 0;
} }
// Disable advanced edit button if changing to "normal"
if (ListType == "")
AdvancedEditButton.setAttribute("disabled","true");
else
AdvancedEditButton.removeAttribute("disabled");
if (label) if (label)
{ {
BulletStyleLabel.value = label;
if (BulletStyleLabel.hasChildNodes()) if (BulletStyleLabel.hasChildNodes())
{
dump("BulletStyleLabel.firstChild: "+BulletStyleLabel.firstChild+"\n");
BulletStyleLabel.removeChild(BulletStyleLabel.firstChild); BulletStyleLabel.removeChild(BulletStyleLabel.firstChild);
}
var textNode = document.createTextNode(label); var textNode = document.createTextNode(label);
BulletStyleLabel.appendChild(textNode); BulletStyleLabel.appendChild(textNode);
} }
} }
function SelectListStyle() function SelectListType()
{ {
switch (ListStyleList.selectedIndex) switch (ListTypeList.selectedIndex)
{ {
case 1: case 1:
ListStyle = "ul"; NewType = "ul";
break; break;
case 2: case 2:
ListStyle = "ol"; NewType = "ol";
break; break;
case 3: case 3:
ListStyle = "dl"; NewType = "dl";
break; break;
default: default:
ListStyle = ""; NewType = "";
break;
} }
if (ListType != NewType)
{
ListType = NewType;
// Create a newlist object for Advanced Editing
if (ListType != "")
globalElement = editorShell.CreateElementWithDefaults(ListType);
BuildBulletStyleList(); BuildBulletStyleList();
}
} }
// Save the selected index function SelectBulletStyle()
function SelectBulleStyle()
{ {
if (ListStyle == "ul") // Save the selected index so when user changes
// list style, restore index to associated list
if (ListType == "ul")
BulletStyleIndex = BulletStyleList.selectedIndex; BulletStyleIndex = BulletStyleList.selectedIndex;
else if (ListStyle == "ol") else if (ListType == "ol")
NumberStyleIndex = BulletStyleList.selectedIndex; NumberStyleIndex = BulletStyleList.selectedIndex;
} }
function ValidateData() function ValidateData()
{ {
var type = 0;
// globalElement should already be of the correct type
dump("Global List element="+globalElement+" should be type: "+ListType+"\n");
if (globalElement)
{
if (ListType == "ul")
{
switch (BulletStyleList.selectedIndex)
{
// Index 0 = "disc", the default, so we don't set it explicitly
case 1:
type = "circle";
break;
case 2:
type = "square";
break;
}
if (type)
globalElement.setAttribute("type",type);
else
globalElement.removeAttribute("type");
} else if (ListType == "ol")
{
switch (BulletStyleList.selectedIndex)
{
// Index 0 = "1", the default, so we don't set it explicitly
case 1:
type = "I";
break;
case 2:
type = "i";
break;
case 3:
type = "A";
break;
case 4:
type = "a";
break;
}
if (type)
globalElement.setAttribute("type",type);
else
globalElement.removeAttribute("type");
var startingNumber = StartingNumberInput.value.trimString();
if (startingNumber)
globalElement.setAttribute("start",startingNumber);
else
globalElement.removeAttribute("start");
}
}
return true; return true;
} }
@ -166,7 +248,21 @@ function onOK()
{ {
if (ValidateData()) if (ValidateData())
{ {
// Coalesce into one undo transaction
editorShell.BeginBatchChanges();
// Making a list is tricky!
// First, make the list
editorShell.MakeOrChangeList(ListType);
// Now we need to get ALL of the list nodes in the current selection
// For now, let's get just the one at the anchor
listElement = editorShell.GetElementOrParentByTagName("list",null);
// Set the list attributes // Set the list attributes
if (listElement)
editorShell.CloneAttributes(listElement, globalElement);
editorShell.EndBatchChanges();
return true; return true;
} }
return false; return false;

Просмотреть файл

@ -41,8 +41,8 @@
<xul:keyset id="keyset"/> <xul:keyset id="keyset"/>
<label for="ListStyle">&listStyle.label;</label> <label for="ListType">&ListType.label;</label>
<select class="ComboBox" id="ListStyle" onchange="SelectListStyle()"> <select class="ComboBox" id="ListType" onchange="SelectListType()">
<option>&none.value;</option> <option>&none.value;</option>
<option>&bulletList.value;</option> <option>&bulletList.value;</option>
<option>&numberList.value;</option> <option>&numberList.value;</option>
@ -53,13 +53,13 @@
<!-- message text and list items are set in JS <!-- message text and list items are set in JS
bulletStyle.label should be identical to string with id=BulletStyle in editor.properties --> bulletStyle.label should be identical to string with id=BulletStyle in editor.properties -->
<div id="BulletStyleLabel">&bulletStyle.label;</div> <div id="BulletStyleLabel">&bulletStyle.label;</div>
<select class="ComboBox" id="BulletStyle" style="min-width: 10em"/> <select class="ComboBox" id="BulletStyle" style="min-width: 10em" onchange="SelectBulletStyle()"/>
<xul:spring class="spacer"/> <xul:spring class="spacer"/>
<xul:box align="horizontal"> <xul:box align="horizontal">
<label id="StartingNumberLabel" for="StartingNumber">&startingNumber.label;</label> <label id="StartingNumberLabel" for="StartingNumber">&startingNumber.label;</label>
<xul:spring class="spacer"/> <xul:spring class="spacer"/>
<input type="text" id="StartingNumber" size="3"/> <input type="text" id="StartingNumber" size="3" onkeyup="forceInteger('StartingNumber')"/>
<xul:spring/> <xul:spring/>
</xul:box> </xul:box>
<xul:broadcaster id="args" value=""/> <xul:broadcaster id="args" value=""/>

Просмотреть файл

@ -38,9 +38,12 @@
</html:script> </html:script>
<broadcaster id="args" value=""/> <broadcaster id="args" value=""/>
<box align="horizontal" style="margin: 10px">
<html:img src="chrome://global/skin/alert-icon.gif"/>
<!-- text node(s) with message text will be appended as children to this --> <!-- text node(s) with message text will be appended as children to this -->
<html:div id="message" flex="100%" style="width: 20em;"/> <html:div id="message" flex="100%"/>
<spring style="height: 15px"/> </box>
<!-- spring style="height: 15px"/ -->
<box align="horizontal" style="margin: 10px"> <box align="horizontal" style="margin: 10px">
<spring flex="100%"/> <spring flex="100%"/>
<titledbutton class="MsgButton" id="button1" onclick="onButton(1)"/> <titledbutton class="MsgButton" id="button1" onclick="onButton(1)"/>

Просмотреть файл

@ -23,4 +23,4 @@
<!-- Window title --> <!-- Window title -->
<!ENTITY windowTitle.label "Insert HTML"> <!ENTITY windowTitle.label "Insert HTML">
<!ENTITY sourceEditField.label "Enter HTML tags and text:"> <!ENTITY sourceEditField.label "Enter HTML tags and text:">
<!ENTITY example.label "Hello World!"> <!ENTITY example.label "Example: <b>&lt;i&gt;Hello World!&lt;/i&gt;</b>">

Просмотреть файл

@ -24,10 +24,11 @@
<!-- Window title --> <!-- Window title -->
<!ENTITY windowTitle.label "List Properties"> <!ENTITY windowTitle.label "List Properties">
<!ENTITY listStyle.label "List Style"> <!ENTITY ListType.label "List Type:">
<!ENTITY bulletStyle.label "Bullet Style:"> <!ENTITY bulletStyle.label "Bullet Style:">
<!ENTITY startingNumber.label "Starting number:"> <!ENTITY startingNumber.label "Starting number:">
<!ENTITY none.value "None (normal paragraph)"> <!ENTITY none.value "None (normal paragraph)">
<!ENTITY bulletList.value "Bullet (Unnumbered) List"> <!ENTITY bulletList.value "Bullet (Unnumbered) List">
<!ENTITY numberList.value "Numbered List"> <!ENTITY numberList.value "Numbered List">
<!ENTITY definitionList.value "Definition List"> <!ENTITY definitionList.value "Definition List">
<!ENTITY mixedListType.value "(mixed types)">

Просмотреть файл

@ -45,6 +45,12 @@ titledbutton {
padding: 2px 5px; padding: 2px 5px;
} }
*/ */
titledbutton#MoreFewerButton {
list-style-image: url(chrome://global/skin/scroll-down.gif)
}
titledbutton#MoreFewerButton[more="1"] {
list-style-image: url(chrome://global/skin/scroll-up.gif);
}
select.SpellCheckList, select.SpellCheckLanguage, input.SpellCheckWord { select.SpellCheckList, select.SpellCheckLanguage, input.SpellCheckWord {
width: 20em; width: 20em;
@ -60,7 +66,6 @@ td, table { border: 0px;}
vertical-align: middle; vertical-align: middle;
} }
/* Messenger uses this -- IT SHOULD BE IN XUL.CSS */
spring.spacer { spring.spacer {
width: 5px; width: 5px;
height: 5px; height: 5px;
@ -72,26 +77,31 @@ spring.bigspacer {
} }
div.spacer [align~=horizontal] { div.spacer [align~=horizontal] {
border : 1px inset white; border: 1px inset white;
height : 2px; height: 2px;
} }
div#message {
width: 20em;
margin-left: 10px
}
/* Rest are from Ben Goodger for Advanced Edit dialog /* Rest are from Ben Goodger for Advanced Edit dialog
These need reviewing and eliminate all but essential attributes */ These need reviewing and eliminate all but essential attributes */
div.tagname { div.tagname {
font-weight : bold; font-weight: bold;
font-size : 17px; font-size : 17px;
} }
div#tagLabel { div#tagLabel {
font-weight : bold; font-weight: bold;
} }
/* styles for an attribute tree-table */ /* styles for an attribute tree-table */
tree.AttributesTree { tree.AttributesTree {
min-width : 200px; min-width : 200px;
min-height : 200px; min-height: 200px;
border : 1px inset white; border : 1px inset white;
} }
@ -99,13 +109,13 @@ tree.AttributesTree treecell {
color : black; color : black;
padding-left : 10px; padding-left : 10px;
padding-top : 2px; padding-top : 2px;
padding-bottom : 2px; padding-bottom: 2px;
padding-right : 2px; padding-right : 2px;
} }
tree.AttributesTree > treehead > treerow > treecell { tree.AttributesTree > treehead > treerow > treecell {
border : 1px outset white; border : 1px outset white;
background-color : #CCCCDD; background-color: #CCCCDD;
} }
tree.AttributesTree > treehead > treerow > treecell:active { tree.AttributesTree > treehead > treerow > treecell:active {
@ -116,7 +126,7 @@ tree.AttributesTree > treehead > treerow > treecell:active {
padding-left : 11px; padding-left : 11px;
padding-top : 3px; padding-top : 3px;
padding-right : 1px; padding-right : 1px;
padding-bottom : 1px; padding-bottom: 1px;
} }
@ -125,7 +135,7 @@ tree.AttributesTree treechildren > treeitem > treerow > treecell {
border-right : 1px solid #CCCCDD; border-right : 1px solid #CCCCDD;
border-bottom : 1px solid #CCCCDD; border-bottom : 1px solid #CCCCDD;
color : black; color : black;
background-color : #FFFFFF; background-color: #FFFFFF;
padding-left : 10px; padding-left : 10px;
padding-top : 2px; padding-top : 2px;
padding-bottom : 2px; padding-bottom : 2px;
@ -135,7 +145,7 @@ tree.AttributesTree treechildren > treeitem > treerow > treecell {
tree.AttributesTree treechildren > treeitem > treerow > treecell.value { tree.AttributesTree treechildren > treeitem > treerow > treecell.value {
border-bottom : 1px solid #CCCCDD; border-bottom : 1px solid #CCCCDD;
color : black; color : black;
background-color : #FFFFFF; background-color: #FFFFFF;
padding-left : 0px; padding-left : 0px;
padding-top : 0px; padding-top : 0px;
padding-bottom : 0px; padding-bottom : 0px;
@ -146,18 +156,18 @@ tree.AttributesTree treechildren > treeitem > treerow > treecell.value {
tree.AttributesTree treechildren > treeitem > treerow [selected ~= false] { tree.AttributesTree treechildren > treeitem > treerow [selected ~= false] {
color : black; color : black;
background-color : #FFFFFF; background-color: #FFFFFF;
} }
tree.AttributesTree treechildren > treeitem > treerow [selected ~= true] { tree.AttributesTree treechildren > treeitem > treerow [selected ~= true] {
color : white; color : white;
background-color : #666699; background-color: #666699;
} }
input.AttributesCell { input.AttributesCell {
width : 95%; width : 95%;
border : none; border: none;
height : 100%; height: 100%;
} }
/* /*
input.AttributesCell:active { input.AttributesCell:active {
@ -170,7 +180,7 @@ input.AttributesCell:hover {
*/ */
treecell input:hover { treecell input:hover {
background-color : #ECECEC; background-color: #ECECEC;
font-weight : bold; font-weight : bold;
border : 2px solid #666699; border : 2px solid #666699;
} }

Просмотреть файл

@ -30,10 +30,12 @@
<!DOCTYPE window SYSTEM "chrome://editor/locale/EditorAppShell.dtd"> <!DOCTYPE window SYSTEM "chrome://editor/locale/EditorAppShell.dtd">
<!-- NOTE: If we don't have "title" set, text editor doesn't work! -->
<window id="main-window" xmlns:html="http://www.w3.org/TR/REC-html40" <window id="main-window" xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="TextEditorOnLoad()" onload="TextEditorOnLoad()"
onunload="EditorShutdown()" onunload="EditorShutdown()"
title="&textEditorWindow.titlemodifier;"
titlemodifier="&textEditorWindow.titlemodifier;" titlemodifier="&textEditorWindow.titlemodifier;"
titlemenuseparator="&editorWindow.titlemodifiermenuseparator;" titlemenuseparator="&editorWindow.titlemodifiermenuseparator;"
align="vertical" align="vertical"