UI changes for export to text file (51798) and adding read-only DOCTYPE display in HTML Source (58650), and new command to update Recent Files menu (part of 60129). r=brade, sr=sfraser

git-svn-id: svn://10.0.0.236/trunk@88016 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
cmanske%netscape.com 2001-02-26 22:02:07 +00:00
parent 2a78d1e0c8
commit 5dfd9bae88
7 changed files with 123 additions and 62 deletions

View File

@ -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);
}
};

View File

@ -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;

View File

@ -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 = "<!DOCTYPE " + domdoc.doctype.name;
if (dt.publicId)
doctypeText += " PUBLIC \"" + domdoc.doctype.publicId;
if (dt.systemId)
doctypeText += " "+"\"" + dt.systemId;
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) {

View File

@ -226,8 +226,11 @@
<stack>
<editor type="content-primary" id="content-frame" src="about:blank" context="editorContentContext" flex="1"/>
</stack>
<textfield class="source-editor plain" id="content-source" multiline="true" rows="1"
flex="1" style="width:1em; height:1em;"/>
<box align="vertical">
<text class="label" id="doctype-text" style="width:1em" crop="right"/>
<textfield class="source-editor plain" id="content-source" multiline="true" rows="1"
flex="1" style="width:1em; height:1em;"/>
</box>
</deck>
<box id="EditModeToolbar" hidden="true" autostretch="never" valign="middle" persist="hidden collapsed">

View File

@ -133,7 +133,6 @@
<command id="cmd_smiley" state="" oncommand="goDoCommand('cmd_smiley')"/>
<command id="cmd_insertBreak" oncommand="goDoCommand('cmd_insertBreak')"/>
<command id="cmd_insertBreakAll" oncommand="goDoCommand('cmd_insertBreakAll')"/>
<command id="cmd_NormalMode" oncommand="goDoCommand('cmd_NormalMode')" value="&NormalMode.label;"/>
<command id="cmd_AllTagsMode" oncommand="goDoCommand('cmd_AllTagsMode')" value="&AllTagsMode.label;"/>
<command id="cmd_HTMLSourceMode" oncommand="goDoCommand('cmd_HTMLSourceMode')"/>
@ -145,11 +144,12 @@
events="create, save"
oncommandupdate="goUpdateComposerMenuItems(this)"
>
<command id="cmd_save" value="&saveCmd.label;" oncommand="goDoCommand('cmd_save')"/>
<command id="cmd_saveAs" value="&saveAsCmd.label;" oncommand="goDoCommand('cmd_saveAs')"/>
<command id="cmd_saveAsCharset" value="&saveAsCharsetCmd.label;" oncommand="goDoCommand('cmd_saveAsCharset')"/>
<command id="cmd_revert" value="&fileRevert.label;" oncommand="goDoCommand('cmd_revert')"/>
<command id="cmd_preview" oncommand="goDoCommand('cmd_preview')"/>
<command id="cmd_save" value="&saveCmd.label;" oncommand="goDoCommand('cmd_save')"/>
<command id="cmd_saveAs" value="&saveAsCmd.label;" oncommand="goDoCommand('cmd_saveAs')"/>
<command id="cmd_exportToText" value="&exportToTextCmd.label;" oncommand="goDoCommand('cmd_exportToText')"/>
<command id="cmd_saveAsCharset" value="&saveAsCharsetCmd.label;" oncommand="goDoCommand('cmd_saveAsCharset')"/>
<command id="cmd_revert" value="&fileRevert.label;" oncommand="goDoCommand('cmd_revert')"/>
<command id="cmd_preview" oncommand="goDoCommand('cmd_preview')"/>
<command id="cmd_editSendPage" value="&sendPageCmd.label;" accesskey="&sendPage.accesskey;" oncommand="goDoCommand('cmd_editSendPage')"/>
</commandset>
@ -294,20 +294,22 @@
</menu>
<menuitem accesskey="&fileopenremote.accesskey;" key="openremoteeditorkb" observes="cmd_openRemote"/>
<menuitem accesskey="&fileopen.accesskey;" key="openeditorkb" observes="cmd_open" value="&openFileCmd.label;"/>
<menu accesskey="&filerecentmenu.accesskey;" value="&fileRecentMenu.label;" oncreate="BuildRecentMenu(false)">
<menu id="menu_RecentFiles" accesskey="&filerecentmenu.accesskey;" value="&fileRecentMenu.label;" oncreate="BuildRecentMenu(false)">
<menupopup id="menupopup_RecentFiles"/>
<!-- menuitems appended at runtime -->
</menu>
<menuseparator/>
<menuitem accesskey="&fileclose.accesskey;" key="closekb" observes="cmd_close"/>
<menuitem accesskey="&filesave.accesskey;" key="savekb" observes="cmd_save"/>
<menuitem accesskey="&filesaveas.accesskey;" observes="cmd_saveAs"/>
<menuitem accesskey="&filesaveascharset.accesskey;" observes="cmd_saveAsCharset"/>
<menuitem accesskey="&fileexporttotext.accesskey;" observes="cmd_exportToText"/>
<menuitem accesskey="&filerevert.accesskey;" observes="cmd_revert"/>
<menuseparator/>
<menuitem value="&previewCmd.label;" accesskey="&filepreview.accesskey;" observes="cmd_preview"/>
<!-- menuitem id="menu_SendPage" is merged here from mailEditorOverlay.xul,
where "position" is assumed to be 13. Change that value if menu position changes. -->
where "position" is assumed to be 14. Change that value if menu position changes. -->
<menuitem accesskey="&fileprintsetup.accesskey;" observes="cmd_printSetup" />
<menuitem accesskey="&fileprint.accesskey;" observes="cmd_print" value="&printCmd.label;"/>
<menuseparator/>
@ -697,7 +699,6 @@
</menupopup>
</menulist>
<!-- TODO: Use actual "face" value when combobox can display arbitrary HTML -->
<!-- "data" are HTML tagnames, don't translate -->
<menulist class="toolbar-focustarget" id="FontFaceSelect" tooltip="aTooltip" tooltiptext="&FontFaceSelect.tooltip;" crop="right">
<observes element="cmd_fontFace" attribute="state" onbroadcast="onFontFaceChange(this.parentNode, 'cmd_fontFace')"/>

View File

@ -25,6 +25,7 @@ OpenHTMLFile=Open HTML File
SelectImageFile=Select Image File
SaveDocument=Save Page
SaveDocumentAs=Save Page As
ExportToText=Export to Text
EditMode=Edit Mode
Preview=Preview
CorrectSpelling=(correct spelling)
@ -158,3 +159,4 @@ StopLinks=Discontinue Link
NoAltText=You should always supply alternative text for an image,\nbut you may use a space if you really don't want it.
NoAlignChar=No alignment character supplied.\nEnter a single character or\nselect a different alignment style.
SaveImageAs=Save Image (%NAME%)...

View File

@ -47,6 +47,8 @@
<!ENTITY filesave.keybinding "s">
<!ENTITY saveAsCmd.label "Save As...">
<!ENTITY filesaveas.accesskey "a">
<!ENTITY exportToTextCmd.label "Export to Text...">
<!ENTITY fileexporttotext.accesskey "x">
<!ENTITY saveAsCharsetCmd.label "Save As Charset...">
<!ENTITY filesaveascharset.accesskey "h">
<!ENTITY previewCmd.label "Browse Page">
@ -248,7 +250,7 @@
<!ENTITY insertchars.accesskey "c">
<!ENTITY insertBreakCmd.label "Line Break">
<!ENTITY insertbreak.accesskey "b">
<!ENTITY insertBreakAllCmd.label "Break below Image(s)">
<!ENTITY insertBreakAllCmd.label "Break Below Image(s)">
<!ENTITY insertbreakall.accesskey "k">
<!-- Used just in context popup. -->