mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 21:35:39 +00:00
Added focus reset to table editcommands, added a couple of missing commands, changed name for some global variables in editor.js, added some 'dump's to debug flaky command firing
This commit is contained in:
parent
f9fe8d6f06
commit
78271287f8
@ -37,14 +37,14 @@ function SetupControllerCommands()
|
||||
|
||||
dump("Registering commands\n");
|
||||
|
||||
gComposerCommandManager.registerCommand("cmd_newEditor", nsNewEditorCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_newEditor", nsNewEditorCommand);
|
||||
|
||||
gComposerCommandManager.registerCommand("cmd_open", nsOpenCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_saveAsCharset", nsSaveAsCharsetCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_revert", nsRevertCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_openRemote", nsOpenRemoteCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_preview", nsPreviewCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_quit", nsQuitCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_open", nsOpenCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_saveAsCharset", nsSaveAsCharsetCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_revert", nsRevertCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_openRemote", nsOpenRemoteCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_preview", nsPreviewCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_quit", nsQuitCommand);
|
||||
|
||||
gComposerCommandManager.registerCommand("cmd_find", nsFindCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_findNext", nsFindNextCommand);
|
||||
@ -61,14 +61,14 @@ function SetupControllerCommands()
|
||||
|
||||
gComposerCommandManager.registerCommand("cmd_image", nsImageCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_hline", nsHLineCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_table", nsInsertOrEditTableCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_editTable", nsEditTableCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_link", nsLinkCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_anchor", nsAnchorCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_insertHTML", nsInsertHTMLCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_insertBreak", nsInsertBreakCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_insertBreakAll",nsInsertBreakAllCommand);
|
||||
|
||||
gComposerCommandManager.registerCommand("cmd_table", nsInsertOrEditTableCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_editTable", nsEditTableCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_SelectTable", nsSelectTableCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_SelectRow", nsSelectTableRowCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_SelectColumn", nsSelectTableColumnCommand);
|
||||
@ -86,7 +86,8 @@ function SetupControllerCommands()
|
||||
gComposerCommandManager.registerCommand("cmd_DeleteColumn", nsDeleteTableColumnCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_DeleteCell", nsDeleteTableCellCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_DeleteCellContents", nsDeleteTableCellContentsCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_NormalizeTable", nsNormalizeTableCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_tableJoinCells", nsJoinTableCellsCommand);
|
||||
gComposerCommandManager.registerCommand("cmd_tableSplitCell", nsSplitTableCellCommand);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
@ -444,7 +445,7 @@ var nsSpellingCommand =
|
||||
}
|
||||
}
|
||||
}
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
};
|
||||
|
||||
@ -807,13 +808,14 @@ function goUpdateTableMenuItems(commandset)
|
||||
|
||||
function IsInTable()
|
||||
{
|
||||
dump("IsInTable?\n");
|
||||
return (window.editorShell && window.editorShell.documentEditable &&
|
||||
null != window.editorShell.GetElementOrParentByTagName("table", null));
|
||||
}
|
||||
|
||||
function IsInTableCell()
|
||||
{
|
||||
dump("IsInTableCell???\n");
|
||||
dump("IsInTableCell?\n");
|
||||
return (window.editorShell && window.editorShell.documentEditable &&
|
||||
null != window.editorShell.GetElementOrParentByTagName("td", null));
|
||||
}
|
||||
@ -825,7 +827,7 @@ function EditorInsertOrEditTable(insertAllowed)
|
||||
if (IsInTable()) {
|
||||
// Edit properties of existing table
|
||||
window.openDialog("chrome://editor/content/EdTableProps.xul", "_blank", "chrome,close,titlebar,modal", "","TablePanel");
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
} else if(insertAllowed) {
|
||||
EditorInsertTable();
|
||||
}
|
||||
@ -833,9 +835,10 @@ function EditorInsertOrEditTable(insertAllowed)
|
||||
|
||||
function EditorInsertTable()
|
||||
{
|
||||
dump("EditorInsertTable\n");
|
||||
// Insert a new table
|
||||
window.openDialog("chrome://editor/content/EdInsertTable.xul", "_blank", "chrome,close,titlebar,modal", "");
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
|
||||
function EditorTableCellProperties()
|
||||
@ -844,7 +847,7 @@ function EditorTableCellProperties()
|
||||
if (cell) {
|
||||
// Start Table Properties dialog on the "Cell" panel
|
||||
window.openDialog("chrome://editor/content/EdTableProps.xul", "_blank", "chrome,close,titlebar,modal", "", "CellPanel");
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
|
||||
@ -857,6 +860,7 @@ var nsInsertOrEditTableCommand =
|
||||
},
|
||||
doCommand: function(aCommand)
|
||||
{
|
||||
dump("nsInsertOrEditTableCommand\n");
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
EditorInsertOrEditTable(true);
|
||||
}
|
||||
@ -871,6 +875,7 @@ var nsEditTableCommand =
|
||||
},
|
||||
doCommand: function(aCommand)
|
||||
{
|
||||
dump("nsEditTableCommand\n");
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
EditorInsertOrEditTable(false);
|
||||
}
|
||||
@ -885,10 +890,11 @@ var nsSelectTableCommand =
|
||||
},
|
||||
doCommand: function(aCommand)
|
||||
{
|
||||
dump("nsSelectTableCommand\n");
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.SelectTable();
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -901,10 +907,11 @@ var nsSelectTableRowCommand =
|
||||
},
|
||||
doCommand: function(aCommand)
|
||||
{
|
||||
dump("nsSelectTableRowCommand\n");
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.SelectTableRow();
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -917,10 +924,11 @@ var nsSelectTableColumnCommand =
|
||||
},
|
||||
doCommand: function(aCommand)
|
||||
{
|
||||
dump("nsSelectTableColumnCommand\n");
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.SelectTableColumn();
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -933,10 +941,11 @@ var nsSelectTableCellCommand =
|
||||
},
|
||||
doCommand: function(aCommand)
|
||||
{
|
||||
dump("nsSelectTableCellCommand\n");
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.SelectTableCell();
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -945,14 +954,15 @@ var nsSelectAllTableCellsCommand =
|
||||
{
|
||||
isCommandEnabled: function(aCommand, dummy)
|
||||
{
|
||||
return IsInTableCell();
|
||||
return IsInTable();
|
||||
},
|
||||
doCommand: function(aCommand)
|
||||
{
|
||||
dump("nsSelectAllTableCellsCommand\n");
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.SelectAllTableCells();
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -982,7 +992,7 @@ var nsInsertTableRowAboveCommand =
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.InsertTableRow(false);
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -998,7 +1008,7 @@ var nsInsertTableRowBelowCommand =
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.InsertTableRow(true);
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1014,7 +1024,7 @@ var nsInsertTableColumnBeforeCommand =
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.InsertTableColumn(false);
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1030,7 +1040,7 @@ var nsInsertTableColumnAfterCommand =
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.InsertTableColumn(true);
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1059,7 +1069,7 @@ var nsInsertTableCellAfterCommand =
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.InsertTableCell(true);
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1076,7 +1086,7 @@ var nsDeleteTableCommand =
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.DeleteTable();
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1092,7 +1102,7 @@ var nsDeleteTableRowCommand =
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.DeleteTableRow(1);
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1108,7 +1118,7 @@ var nsDeleteTableColumnCommand =
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.DeleteTableColumn(1);
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1124,7 +1134,7 @@ var nsDeleteTableCellCommand =
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.DeleteTableCell(1);
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1140,7 +1150,7 @@ var nsDeleteTableCellContentsCommand =
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.DeleteTableCellContents();
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1157,7 +1167,7 @@ var nsNormalizeTableCommand =
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.NormalizeTable();
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1175,7 +1185,7 @@ var nsJoinTableCellsCommand =
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.JoinTableCells();
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1193,7 +1203,7 @@ var nsSplitTableCellCommand =
|
||||
if (this.isCommandEnabled(aCommand))
|
||||
{
|
||||
window.editorShell.SplitTableCell();
|
||||
contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -41,10 +41,10 @@ var EditorDisplayMode = 1; // Normal Editor mode
|
||||
var EditModeType = "";
|
||||
var WebCompose = false; // Set true for Web Composer, leave false for Messenger Composer
|
||||
var docWasModified = false; // Check if clean document, if clean then unload when user "Opens"
|
||||
var contentWindow = 0;
|
||||
var sourceContentWindow = 0;
|
||||
var ContentWindowDeck;
|
||||
var FormatToolbar;
|
||||
var gContentWindow = 0;
|
||||
var gSourceContentWindow = 0;
|
||||
var gContentWindowDeck;
|
||||
var gFormatToolbar;
|
||||
// Bummer! Can't get at enums from nsIDocumentEncoder.h
|
||||
var gOutputSelectionOnly = 1;
|
||||
var gOutputFormatted = 2;
|
||||
@ -138,8 +138,8 @@ var DocumentStateListener =
|
||||
|
||||
function EditorStartup(editorType, editorElement)
|
||||
{
|
||||
contentWindow = window.content;
|
||||
sourceContentWindow = document.getElementById("content-source");
|
||||
gContentWindow = window.content;
|
||||
gSourceContentWindow = document.getElementById("content-source");
|
||||
gIsHTMLEditor = (editorType == "html");
|
||||
|
||||
if (gIsHTMLEditor)
|
||||
@ -156,8 +156,8 @@ dump("Edit Mode: "+gNormalModeButton.getAttribute('type')+"\n");
|
||||
ToggleEditModeType(gNormalModeButton.getAttribute("type"));
|
||||
|
||||
// XUL elements we use when switching from normal editor to edit source
|
||||
ContentWindowDeck = document.getElementById("ContentWindowDeck");
|
||||
FormatToolbar = document.getElementById("FormatToolbar");
|
||||
gContentWindowDeck = document.getElementById("ContentWindowDeck");
|
||||
gFormatToolbar = document.getElementById("FormatToolbar");
|
||||
}
|
||||
|
||||
gIsWin = navigator.appVersion.indexOf("Win") != -1;
|
||||
@ -173,7 +173,7 @@ dump("Edit Mode: "+gNormalModeButton.getAttribute('type')+"\n");
|
||||
editorShell.SetEditorType(editorType);
|
||||
|
||||
editorShell.webShellWindow = window;
|
||||
editorShell.contentWindow = contentWindow;
|
||||
editorShell.contentWindow = gContentWindow;
|
||||
|
||||
// hide UI that we don't have components for
|
||||
HideInapplicableUIElements();
|
||||
@ -412,7 +412,7 @@ function EditorSetDocumentCharacterSet(aCharset)
|
||||
function EditorSetTextProperty(property, attribute, value)
|
||||
{
|
||||
editorShell.SetTextProperty(property, attribute, value);
|
||||
contentWindow.focus();
|
||||
gContentWindow.focus();
|
||||
}
|
||||
|
||||
function onParagraphFormatChange(commandID)
|
||||
@ -484,7 +484,7 @@ function EditorSetFontFace(fontFace)
|
||||
}
|
||||
}
|
||||
//dump("Setting focus to content window...\n");
|
||||
contentWindow.focus();
|
||||
gContentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorSelectFontSize()
|
||||
@ -573,7 +573,7 @@ function EditorSetFontSize(size)
|
||||
editorShell.SetTextProperty("span", "style", "font-size:"+size);
|
||||
}
|
||||
*/
|
||||
contentWindow.focus();
|
||||
gContentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorSelectTextColor(ColorPickerID, ColorWellID)
|
||||
@ -591,7 +591,7 @@ function EditorSelectTextColor(ColorPickerID, ColorWellID)
|
||||
if (menupopup) menupopup.closePopup();
|
||||
|
||||
EditorSetFontColor(color);
|
||||
contentWindow.focus();
|
||||
gContentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorRemoveTextColor(ColorWellID)
|
||||
@ -604,7 +604,7 @@ function EditorRemoveTextColor(ColorWellID)
|
||||
|
||||
//TODO: Set colorwell to browser's default color
|
||||
editorShell.SetTextProperty("font", "color", "");
|
||||
contentWindow.focus();
|
||||
gContentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorSelectBackColor(ColorPickerID, ColorWellID)
|
||||
@ -622,7 +622,7 @@ dump("EditorSelectBackColor: "+color+"\n");
|
||||
if (menupopup) menupopup.closePopup();
|
||||
|
||||
EditorSetBackgroundColor(color);
|
||||
contentWindow.focus();
|
||||
gContentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorRemoveBackColor(ColorWellID)
|
||||
@ -634,7 +634,7 @@ function EditorRemoveBackColor(ColorWellID)
|
||||
}
|
||||
//TODO: Set colorwell to browser's default color
|
||||
editorShell.SetBackgroundColor("");
|
||||
contentWindow.focus();
|
||||
gContentWindow.focus();
|
||||
}
|
||||
|
||||
|
||||
@ -649,26 +649,26 @@ function SetManualTextColor()
|
||||
function EditorSetFontColor(color)
|
||||
{
|
||||
editorShell.SetTextProperty("font", "color", color);
|
||||
contentWindow.focus();
|
||||
gContentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorSetBackgroundColor(color)
|
||||
{
|
||||
editorShell.SetBackgroundColor(color);
|
||||
contentWindow.focus();
|
||||
gContentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorApplyStyle(tagName)
|
||||
{
|
||||
dump("applying style\n");
|
||||
editorShell.SetTextProperty(tagName, "", "");
|
||||
contentWindow.focus();
|
||||
gContentWindow.focus();
|
||||
}
|
||||
|
||||
function EditorRemoveLinks()
|
||||
{
|
||||
editorShell.RemoveTextProperty("href", "");
|
||||
contentWindow.focus();
|
||||
gContentWindow.focus();
|
||||
}
|
||||
|
||||
/*TODO: We need an oncreate hook to do enabling/disabling for the
|
||||
@ -723,10 +723,10 @@ function SetEditMode(mode)
|
||||
{
|
||||
// KLUDGE until we have an output flag that strips out <body> and </body> for us
|
||||
//var sourceContent = editorShell.GetContentsAs("text/html", gOutputBodyOnly);
|
||||
//sourceContentWindow.value = sourceContent.replace(/<body>/,"").replace(/<\/body>/,"");
|
||||
sourceContentWindow.value = editorShell.GetContentsAs("text/html", gOutputBodyOnly);
|
||||
sourceContentWindow.focus();
|
||||
setTimeout("sourceContentWindow.focus()", 10);
|
||||
//gSourceContentWindow.value = sourceContent.replace(/<body>/,"").replace(/<\/body>/,"");
|
||||
gSourceContentWindow.value = editorShell.GetContentsAs("text/html", gOutputBodyOnly);
|
||||
gSourceContentWindow.focus();
|
||||
setTimeout("gSourceContentWindow.focus()", 10);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -738,15 +738,15 @@ function SetEditMode(mode)
|
||||
// We are comming from edit source mode,
|
||||
// so transfer that back into the document
|
||||
editorShell.SelectAll();
|
||||
editorShell.InsertSource(sourceContentWindow.value);
|
||||
editorShell.InsertSource(gSourceContentWindow.value);
|
||||
// Clear out the source editor buffer
|
||||
sourceContentWindow.value = "";
|
||||
gSourceContentWindow.value = "";
|
||||
// reset selection to top of doc (wish we could preserve it!)
|
||||
if (bodyNode)
|
||||
editorShell.editorSelection.collapse(bodyNode, 0);
|
||||
|
||||
contentWindow.focus();
|
||||
setTimeout("contentWindow.focus()", 10);
|
||||
gContentWindow.focus();
|
||||
setTimeout("gContentWindow.focus()", 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -754,7 +754,7 @@ function SetEditMode(mode)
|
||||
function CancelSourceEditing()
|
||||
{
|
||||
// Empty the source window
|
||||
sourceContentWindow.value="";
|
||||
gSourceContentWindow.value="";
|
||||
SetDisplayMode(PreviousNonSourceDisplayMode);
|
||||
}
|
||||
|
||||
@ -786,21 +786,21 @@ function SetDisplayMode(mode)
|
||||
if (mode == DisplayModeSource)
|
||||
{
|
||||
// Switch to the sourceWindow (second in the deck)
|
||||
ContentWindowDeck.setAttribute("index","1");
|
||||
gContentWindowDeck.setAttribute("index","1");
|
||||
|
||||
// TODO: WE MUST DISABLE ALL KEYBOARD COMMANDS!
|
||||
|
||||
// THIS DOESN'T WORK!
|
||||
sourceContentWindow.focus();
|
||||
gSourceContentWindow.focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Switch to the normal editor (first in the deck)
|
||||
ContentWindowDeck.setAttribute("index","0");
|
||||
gContentWindowDeck.setAttribute("index","0");
|
||||
|
||||
// TODO: WE MUST ENABLE ALL KEYBOARD COMMANDS!
|
||||
|
||||
contentWindow.focus();
|
||||
gContentWindow.focus();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user