Bug 154521 In "Composer", all source I inputed will be removed by switching display mode between "<html>Source" and "Preview";

r=cmanske, sr=sfraser, a=asa
Harry Lu(harry.lu@sun.com)'s fix (part 1)
This commit is contained in:
kyle.yuan%sun.com 2002-07-23 05:30:16 +00:00
Родитель b39f5ffad9
Коммит 9a5b258a6b
4 изменённых файлов: 44 добавлений и 8 удалений

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

@ -1823,7 +1823,7 @@ var nsRevertCommand =
// Reload page if first button (Revert) was pressed
if(result == 0)
{
FinishHTMLSource();
SetEditMode(PreviousNonSourceDisplayMode);
window.editorShell.LoadUrl(GetDocumentUrl());
}
}
@ -2002,12 +2002,14 @@ var nsQuitCommand =
return true; // we can always do this
},
/* The doCommand is not used, since cmd_quit's oncommand="goQuitApplication()" in platformCommunicatorOverlay.xul
doCommand: function(aCommand)
{
// In editor.js
FinishHTMLSource();
goQuitApplication();
}
*/
};
//-----------------------------------------------------------------------------------
@ -2763,6 +2765,7 @@ var nsNormalModeCommand =
},
doCommand: function(aCommand)
{
FinishHTMLSource();
if (gEditorDisplayMode != DisplayModeNormal)
SetEditMode(DisplayModeNormal);
}
@ -2776,6 +2779,7 @@ var nsAllTagsModeCommand =
},
doCommand: function(aCommand)
{
FinishHTMLSource();
if (gEditorDisplayMode != DisplayModeAllTags)
SetEditMode(DisplayModeAllTags);
}

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

@ -606,8 +606,11 @@ function CheckAndSaveDocument(command, allowDontSave)
if (result == 0)
{
// Save, but first finish HTML source mode
if (gHTMLSourceChanged)
FinishHTMLSource();
if (gHTMLSourceChanged) {
try {
FinishHTMLSource();
} catch (e) { return false;}
}
if (doPublish)
{
@ -1634,6 +1637,35 @@ function CancelHTMLSource()
function FinishHTMLSource()
{
//Here we need to check whether the HTML source contains <head> and <body> tags
//Or RebuildDocumentFromSource() will fail.
if (IsInHTMLSourceMode())
{
var htmlSource = gSourceContentWindow.value;
if (htmlSource.length > 0)
{
var beginHead = htmlSource.indexOf("<head");
if (beginHead == -1)
{
AlertWithTitle(GetString("Alert"), GetString("NoHeadTag"));
//cheat to force back to Source Mode
gEditorDisplayMode = DisplayModePreview;
SetDisplayMode(DisplayModeSource);
throw Components.results.NS_ERROR_FAILURE;
}
var beginBody = htmlSource.indexOf("<body");
if (beginBody == -1)
{
AlertWithTitle(GetString("Alert"), GetString("NoBodyTag"));
//cheat to force back to Source Mode
gEditorDisplayMode = DisplayModePreview;
SetDisplayMode(DisplayModeSource);
throw Components.results.NS_ERROR_FAILURE;
}
}
}
// Switch edit modes -- converts source back into DOM document
SetEditMode(PreviousNonSourceDisplayMode);
}

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

@ -147,7 +147,7 @@ function editPage(url, launchWindow, delay)
{
// we have an empty window we can use
if (emptyWindow.IsInHTMLSourceMode())
emptyWindow.FinishHTMLSource();
emptyWindow.SetEditMode(emptyWindow.PreviousNonSourceDisplayMode);
emptyWindow.editorShell.LoadUrl(url);
emptyWindow.focus();
emptyWindow.SetSaveAndPublishUI(url);

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

@ -833,13 +833,13 @@
</toolbarbutton>
<!-- Edit Mode toolbar -->
<tab id="NormalModeButton" class="tab-bottom edit-mode _plain" type="text" selected="1" label="&NormalModeTab.label;" oncommand="SetEditMode(1);"
<tab id="NormalModeButton" class="tab-bottom edit-mode _plain" type="text" selected="1" label="&NormalModeTab.label;" oncommand="goDoCommand('cmd_NormalMode');"
tooltiptext="&NormalMode.tooltip;"/>
<tab id="TagModeButton" class="tab-bottom edit-mode _plain" type="text" selected="0" label="&AllTagsMode.label;" oncommand="SetEditMode(2);"
<tab id="TagModeButton" class="tab-bottom edit-mode _plain" type="text" selected="0" label="&AllTagsMode.label;" oncommand="goDoCommand('cmd_AllTagsMode');"
tooltiptext="&AllTagsMode.tooltip;"/>
<tab id="SourceModeButton" class="tab-bottom edit-mode _plain" type="text" selected="0" label="&SourceMode.label;" oncommand="SetEditMode(3);"
<tab id="SourceModeButton" class="tab-bottom edit-mode _plain" type="text" selected="0" label="&SourceMode.label;" oncommand="goDoCommand('cmd_HTMLSourceMode');"
tooltiptext="&HTMLSourceMode.tooltip;" dir="&SourceTabDirection;"/>
<tab id="PreviewModeButton" class="tab-bottom edit-mode _plain" type="text" selected="0" label="&PreviewMode.label;" oncommand="SetEditMode(0);"
<tab id="PreviewModeButton" class="tab-bottom edit-mode _plain" type="text" selected="0" label="&PreviewMode.label;" oncommand="goDoCommand('cmd_PreviewMode');"
tooltiptext="&PreviewMode.tooltip;"/>
<!-- Paste as quotation is used by mail compose,