diff --git a/editor/ui/composer/content/ComposerCommands.js b/editor/ui/composer/content/ComposerCommands.js index 9014e5188021..a0f2d1838d84 100644 --- a/editor/ui/composer/content/ComposerCommands.js +++ b/editor/ui/composer/content/ComposerCommands.js @@ -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); } diff --git a/editor/ui/composer/content/editor.js b/editor/ui/composer/content/editor.js index 38c08f5314c8..2f00f5da93cd 100644 --- a/editor/ui/composer/content/editor.js +++ b/editor/ui/composer/content/editor.js @@ -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 and tags + //Or RebuildDocumentFromSource() will fail. + if (IsInHTMLSourceMode()) + { + var htmlSource = gSourceContentWindow.value; + if (htmlSource.length > 0) + { + var beginHead = htmlSource.indexOf(" - - - -