diff --git a/mozilla/editor/ui/composer/content/ComposerCommands.js b/mozilla/editor/ui/composer/content/ComposerCommands.js index eb5e00f9a5c..562c52e3a13 100644 --- a/mozilla/editor/ui/composer/content/ComposerCommands.js +++ b/mozilla/editor/ui/composer/content/ComposerCommands.js @@ -87,6 +87,7 @@ function SetupHTMLEditorCommands() gHTMLEditorCommandManager.registerCommand("cmd_FinishHTMLSource", nsFinishHTMLSource); gHTMLEditorCommandManager.registerCommand("cmd_CancelHTMLSource", nsCancelHTMLSource); gHTMLEditorCommandManager.registerCommand("cmd_smiley", nsSetSmiley); + gHTMLEditorCommandManager.registerCommand("cmd_buildRecentPagesMenu", nsBuildRecentPagesMenu); } function SetupComposerWindowCommands() @@ -135,27 +136,30 @@ function SetupComposerWindowCommands() } // File-related commands - commandManager.registerCommand("cmd_newEditor", nsNewEditorCommand); - commandManager.registerCommand("cmd_open", nsOpenCommand); - commandManager.registerCommand("cmd_save", nsSaveCommand); - commandManager.registerCommand("cmd_saveAs", nsSaveAsCommand); - commandManager.registerCommand("cmd_saveAsCharset", nsSaveAsCharsetCommand); - commandManager.registerCommand("cmd_revert", nsRevertCommand); - commandManager.registerCommand("cmd_openRemote", nsOpenRemoteCommand); - commandManager.registerCommand("cmd_preview", nsPreviewCommand); - commandManager.registerCommand("cmd_editSendPage", nsSendPageCommand); - commandManager.registerCommand("cmd_quit", nsQuitCommand); - commandManager.registerCommand("cmd_close", nsCloseCommand); - commandManager.registerCommand("cmd_preferences", nsPreferencesCommand); + commandManager.registerCommand("cmd_newEditor", nsNewEditorCommand); + commandManager.registerCommand("cmd_open", nsOpenCommand); + commandManager.registerCommand("cmd_save", nsSaveCommand); + commandManager.registerCommand("cmd_saveAs", nsSaveAsCommand); + commandManager.registerCommand("cmd_exportToText", nsExportToTextCommand); + commandManager.registerCommand("cmd_saveAsCharset", nsSaveAsCharsetCommand); + commandManager.registerCommand("cmd_revert", nsRevertCommand); + commandManager.registerCommand("cmd_openRemote", nsOpenRemoteCommand); + commandManager.registerCommand("cmd_preview", nsPreviewCommand); + commandManager.registerCommand("cmd_editSendPage", nsSendPageCommand); + commandManager.registerCommand("cmd_quit", nsQuitCommand); + commandManager.registerCommand("cmd_close", nsCloseCommand); + commandManager.registerCommand("cmd_preferences", nsPreferencesCommand); // Edit Mode commands - commandManager.registerCommand("cmd_NormalMode", nsNormalModeCommand); - commandManager.registerCommand("cmd_AllTagsMode", nsAllTagsModeCommand); - commandManager.registerCommand("cmd_HTMLSourceMode", nsHTMLSourceModeCommand); - commandManager.registerCommand("cmd_PreviewMode", nsPreviewModeCommand); - commandManager.registerCommand("cmd_FinishHTMLSource", nsFinishHTMLSource); - commandManager.registerCommand("cmd_CancelHTMLSource", nsCancelHTMLSource); - + if (window.editorShell.editorType == "html") + { + commandManager.registerCommand("cmd_NormalMode", nsNormalModeCommand); + commandManager.registerCommand("cmd_AllTagsMode", nsAllTagsModeCommand); + commandManager.registerCommand("cmd_HTMLSourceMode", nsHTMLSourceModeCommand); + commandManager.registerCommand("cmd_PreviewMode", nsPreviewModeCommand); + commandManager.registerCommand("cmd_FinishHTMLSource", nsFinishHTMLSource); + commandManager.registerCommand("cmd_CancelHTMLSource", nsCancelHTMLSource); + } gComposerWindowCommandManager.insertControllerAt(0, editorController); } @@ -282,7 +286,7 @@ var nsSaveCommand = { FinishHTMLSource(); // In editor.js var doSaveAs = window.editorShell.editorDocument.location == "about:blank"; - return window.editorShell.saveDocument(doSaveAs, false); + return window.editorShell.saveDocument(doSaveAs, false, "text/html"); } return false; } @@ -300,7 +304,25 @@ var nsSaveAsCommand = if (window.editorShell) { FinishHTMLSource(); - return window.editorShell.saveDocument(true, false); + return window.editorShell.saveDocument(true, false, "text/html"); + } + return false; + } +} + +var nsExportToTextCommand = +{ + isCommandEnabled: function(aCommand, dummy) + { + return (window.editorShell && window.editorShell.documentEditable); + }, + + doCommand: function(aCommand) + { + if (window.editorShell) + { + FinishHTMLSource(); + return window.editorShell.saveDocument(true, true, "text/plain"); } return false; } @@ -319,7 +341,7 @@ var nsSaveAsCharsetCommand = window.openDialog("chrome://editor/content/EditorSaveAsCharset.xul","_blank", "chrome,close,titlebar,modal") if (window.ok) { - window.ok = window.editorShell.saveDocument(true, false); + window.ok = window.editorShell.saveDocument(true, false, "text/html"); } window._content.focus(); return window.ok; @@ -884,7 +906,6 @@ var nsSetSmiley = { var commandNode = document.getElementById(aCommand); - var smileyCode = commandNode.getAttribute("state"); var strSml; @@ -906,7 +927,6 @@ var nsSetSmiley = break; default: strSml=""; break; - } try @@ -1451,3 +1471,16 @@ var nsCancelHTMLSource = CancelHTMLSource(); } }; + +var nsBuildRecentPagesMenu = +{ + isCommandEnabled: function(aCommand, dummy) + { + return true; + }, + doCommand: function(aCommand) + { + // In editor.js. True means save menu to prefs + BuildRecentMenu(true); + } +}; diff --git a/mozilla/editor/ui/composer/content/EditorContextMenu.js b/mozilla/editor/ui/composer/content/EditorContextMenu.js index 8966658dbff..d3c2fc19bbf 100644 --- a/mozilla/editor/ui/composer/content/EditorContextMenu.js +++ b/mozilla/editor/ui/composer/content/EditorContextMenu.js @@ -100,10 +100,10 @@ function EditorFillContextMenu(event, contextMenuNode) } // Note: Item "menu_selectAll_cm" and - // folowing separator are ALWAYS enabled, + // following separator are ALWAYS enabled, // so there will always be 1 separator here -dump("haveStyle = "+haveStyle+", "+haveProps+", inCell"+inCell+"\n"); +//dump("haveStyle = "+haveStyle+", "+haveProps+", inCell"+inCell+"\n"); ShowMenuItem("styles-separator", haveStyle && (haveProps || inCell)); ShowMenuItem("property-separator", (haveProps && inCell) || !haveStyle); @@ -132,8 +132,8 @@ function HideDisabledItem( item ) { if (!item) return false; - var enabled = (item.getAttribute('disabled') !="true"); +//dump("HideDisabledItem: "+item.getAttribute("id")+", enabled="+enabled+"\n"); item.setAttribute("collapsed", enabled ? "" : "true"); item.setAttribute('contexthidden', enabled ? "" : "true"); return enabled; diff --git a/mozilla/editor/ui/composer/content/editor.js b/mozilla/editor/ui/composer/content/editor.js index b14c03baf27..0d7c4ff1130 100644 --- a/mozilla/editor/ui/composer/content/editor.js +++ b/mozilla/editor/ui/composer/content/editor.js @@ -337,23 +337,6 @@ function FindAndSelectEditorWindowWithURL(urlToMatch) return false; } -function editorSendPage() -{ - var docModified = window.editorShell.documentModified; - var pageUrl = window.editorShell.editorDocument.location; - if (pageUrl != "about:blank" && !docModified) - { - var pageTitle = window.editorShell.editorDocument.title; - window.openDialog("chrome://messenger/content/messengercompose/messengercompose.xul", "_blank", - "chrome,all,dialog=no", "attachment='" + pageUrl.replace(/\,/g, "%2C") + "',body='" + pageUrl + - "',subject='" + pageTitle + "',bodyislink=true"); - } - else if (CheckAndSaveDocument(GetString("SendPageReason")), DocumentHasBeenSaved()) - editorSendPage(); - - window._content.focus(); -} - function DocumentHasBeenSaved() { var fileurl = ""; @@ -410,7 +393,7 @@ function CheckAndSaveDocument(reasonToSave, allowDontSave) if (result.value == 0) { // Save - var success = window.editorShell.saveDocument(false, false); + var success = window.editorShell.saveDocument(false, false, "text/html"); return success; } @@ -671,11 +654,11 @@ function initFontFaceMenu(menuPopup) var fontWasFound = anyHas.value; // Skip over default, TT, and separator - for (var i = 3; i < menuPopup.childNodes.length; i++) + for (var i = 3; i < children.length; i++) { var menuItem = children[i]; var faceType = menuItem.getAttribute("data"); - + if (faceType) { editorShell.GetTextProperty("font", "face", faceType, firstHas, anyHas, allHas); @@ -1030,6 +1013,31 @@ function SetEditMode(mode) if (mode == DisplayModeSource) { + // Display the DOCTYPE as a non-editable string above edit area + var domdoc; + try { domdoc = window.editorShell.editorDocument; } catch (e) { dump( e + "\n");} + if (domdoc) + { + var doctypeNode = document.getElementById("doctype-text"); + var dt = domdoc.doctype; + if (doctypeNode) + { + if (dt) + { + doctypeNode.removeAttribute("collapsed"); + var doctypeText = "" + doctypeNode.setAttribute("value", doctypeText); + } + else + doctypeNode.setAttribute("collapsed", "true"); + } + } + // We can't monitor changes while in HTML Source, // so the nsSaveCommand::isCommandEnabled() will always return true // when in HTML Source mode @@ -1328,6 +1336,7 @@ function BuildRecentMenu(savePrefs) var menuIndex = 1; var arrayIndex = 0; var i; + var disableMenu = true; if(!newDoc) { @@ -1350,6 +1359,7 @@ function BuildRecentMenu(savePrefs) // Build the menu AppendRecentMenuitem(popup, title, url, menuIndex); menuIndex++; + disableMenu = false; // Save in array for prefs if (savePrefs && arrayIndex < historyCount) @@ -1377,6 +1387,9 @@ function BuildRecentMenu(savePrefs) // Force saving to file so next file opened finds these values if (savePrefs) gPrefs.SavePrefFile(); + + // Disable menu item if no entries + DisableItem("menu_RecentFiles", disableMenu); } function AppendRecentMenuitem(menupopup, title, url, menuIndex) @@ -1395,10 +1408,16 @@ function AppendRecentMenuitem(menupopup, title, url, menuIndex) accessKey = " "; var itemString = accessKey+" "; + + // Show "title [url]" or just the URL if (title) - itemString += title; - else - itemString += url; + { + itemString += title; + itemString += " ["; + } + itemString += url; + if (title) + itemString += "]"; menuItem.setAttribute("value", itemString); menuItem.setAttribute("data", url); @@ -2178,6 +2197,7 @@ function IsSelectionInOneCell() function EditorInsertOrEditTable(insertAllowed) { if (IsInTable()) { + // Edit properties of existing table window.openDialog("chrome://editor/content/EdTableProps.xul", "_blank", "chrome,close,titlebar,modal", "","TablePanel"); window._content.focus(); } else if(insertAllowed) { diff --git a/mozilla/editor/ui/composer/content/editor.xul b/mozilla/editor/ui/composer/content/editor.xul index 4dbcad7d9a7..7696d0af4e1 100644 --- a/mozilla/editor/ui/composer/content/editor.xul +++ b/mozilla/editor/ui/composer/content/editor.xul @@ -226,8 +226,11 @@ - + + + +