diff --git a/editor/composer/src/res/EditorOverride.css b/editor/composer/src/res/EditorOverride.css index 3c461bbc7396..d3c7e4d379c4 100644 --- a/editor/composer/src/res/EditorOverride.css +++ b/editor/composer/src/res/EditorOverride.css @@ -32,7 +32,13 @@ a:link, a:visited, a:active, a:out-of-date { cursor: text; } +/* We want the default arrow when hover over the + various objects, such as the image that + represents the named anchor +*/ a:link img, a:visited img, a:active img, -a:out-of-date img, img[usemap], object[usemap] { +a:out-of-date img, img[usemap], +object[usemap], +a[name] { cursor: default; } diff --git a/editor/ui/composer/content/ComposerCommands.js b/editor/ui/composer/content/ComposerCommands.js index a2378922d056..80d83894205f 100644 --- a/editor/ui/composer/content/ComposerCommands.js +++ b/editor/ui/composer/content/ComposerCommands.js @@ -58,7 +58,8 @@ function SetupControllerCommands() gComposerCommandManager.registerCommand("cmd_pageProperties", nsPagePropertiesCommand); gComposerCommandManager.registerCommand("cmd_colorProperties", nsColorPropertiesCommand); gComposerCommandManager.registerCommand("cmd_advancedProperties", nsAdvancedPropertiesCommand); - + gComposerCommandManager.registerCommand("cmd_objectProperties", nsObjectPropertiesCommand); + gComposerCommandManager.registerCommand("cmd_image", nsImageCommand); gComposerCommandManager.registerCommand("cmd_hline", nsHLineCommand); gComposerCommandManager.registerCommand("cmd_link", nsLinkCommand); @@ -535,45 +536,6 @@ var nsHLineCommand = } }; -//----------------------------------------------------------------------------------- -// Launch Object properties for appropriate selected element - -function EditorObjectProperties() -{ - var element = GetSelectedElementOrParentCell(); - // dump("EditorObjectProperties: element="+element+"\n"); - if (element) - { - // dump("TagName="+element.nodeName+"\n"); - switch (element.nodeName) - { - case 'IMG': - goDoCommand("cmd_image"); - break; - case 'HR': - goDoCommand("cmd_hline"); - break; - case 'TABLE': - EditorInsertOrEditTable(false); - break; - case 'TD': - EditorTableCellProperties(); - break; - case 'A': - if(element.href) - goDoCommand("cmd_link"); - else if (element.name) - goDoCommand("cmd_anchor"); - break; - } - } else { - // We get a partially-selected link if asked for specifically - element = editorShell.GetSelectedElement("href"); - if (element) - goDoCommand("cmd_link"); - } -} - //----------------------------------------------------------------------------------- var nsLinkCommand = { @@ -680,7 +642,67 @@ var nsPagePropertiesCommand = }; //----------------------------------------------------------------------------------- +var nsObjectPropertiesCommand = +{ + isCommandEnabled: function(aCommand, dummy) + { + if (window.editorShell && window.editorShell.documentEditable) + { + // Launch Object properties for appropriate selected element + var element = GetSelectedElementOrParentCell(); + //dump("nsObjectProperties, isCommandEnabled: element="+element+",TagName="+element.nodeName+"\n"); + return (element && + (element.nodeName == "img" || + element.nodeName == "hr" || + element.nodeName == "table" || + element.nodeName == "td" || + element.nodeName == "a" || + editorShell.GetSelectedElement("href"))); + } + return false; + }, + doCommand: function(aCommand) + { + // Launch Object properties for appropriate selected element + var element = GetSelectedElementOrParentCell(); + if (element) + { + switch (element.nodeName) + { + case 'img': + goDoCommand("cmd_image"); + break; + case 'hr': + goDoCommand("cmd_hline"); + break; + case 'table': + EditorInsertOrEditTable(false); + break; + case 'td': + EditorTableCellProperties(); + break; + case 'a': + if (element.name) + { + goDoCommand("cmd_anchor"); + } + else if(element.href) + { + goDoCommand("cmd_link"); + } + break; + } + } else { + // We get a partially-selected link if asked for specifically + element = editorShell.GetSelectedElement("href"); + if (element) + goDoCommand("cmd_link"); + } + window.content.focus(); + } +}; +//----------------------------------------------------------------------------------- var nsAdvancedPropertiesCommand = { isCommandEnabled: function(aCommand, dummy) @@ -721,173 +743,15 @@ var nsEditHTMLCommand = { if (gEditorDisplayMode === DisplayModeSource) { -dump(" *** Switch back to HTML Source mode\n"); SetEditMode(DisplayModeNormal); } else { -dump(" *** Switch back to NORMAL\n"); SetEditMode(DisplayModeSource); } } }; -//----------------------------------------------------------------------------------- -// TABLE EDITING COMMANDS -// Command Updating Strategy: -// Don't update on on selection change, only when menu is displayed, -// with this "oncreate" hander: -function EditorInitTableMenu() -{ - // Change text on the "Join..." item depending if we - // are joining selected cells or just cell to right - // TODO: What to do about normal selection that crosses - // table border? Try to figure out all cells - // included in the selection? - var menuText; - - // Use "Join selected cells if there's more than 1 cell selected - var tagNameObj = new Object; - var countObj = new Object; - if (window.editorShell.GetSelectedOrParentTableElement(tagNameObj, countObj) && countObj.value > 1) - menuText = GetString("JoinSelectedCells"); - else - menuText = GetString("JoinCellToRight"); - - document.getElementById("menu_tableJoinCells").setAttribute("value",menuText); - - // Set platform-specific hints for how to select cells - if (gIsWin) osKey = "XulKeyWin"; - if (gIsMac) osKey = "XulKeyMac"; - if (gIsUNIX) osKey = "XulKeyUnix"; - - var DragStr = GetString(osKey)+GetString("Drag"); - var ClickStr = GetString(osKey)+GetString("Click"); - var DelStr = GetString(gIsMac ? "Clear" : "Del"); - - document.getElementById("menu_DeleteCell").setAttribute("acceltext",ClickStr); - document.getElementById("menu_SelectRow").setAttribute("acceltext",DragStr); - document.getElementById("menu_SelectColumn").setAttribute("acceltext",DragStr); - document.getElementById("menu_SelectAllCells").setAttribute("acceltext",DragStr); - // And add "Del" or "Clear" - document.getElementById("menu_DeleteCellContents").setAttribute("acceltext",DelStr); - - // Set enable states for all table commands - goUpdateTableMenuItems(document.getElementById("composerTableMenuItems")); -} - -function goUpdateTableMenuItems(commandset) -{ - var enabled = false; - - var enabledIfTable = false; - if (window.editorShell && window.editorShell.documentEditable) - { - var selectedCountObj = new Object(); - var tagNameObj = new Object(); - var element = editorShell.GetSelectedOrParentTableElement(tagNameObj, selectedCountObj); - if (element) - { - // Value when we need to have a selected table or inside a table - enabledIfTable = true; - - // All others require being inside a cell or selected cell - enabled = (tagNameObj.value == "td"); - } - } - - // Loop through command nodes - for (var i = 0; i < commandset.childNodes.length; i++) - { - var commandID = commandset.childNodes[i].getAttribute("id"); - if (commandID) - { - if (commandID == "cmd_InsertTable" || - commandID == "cmd_tableJoinCells" || - commandID == "cmd_tableSplitCell") - { - // Call the update method in the command class - goUpdateCommand(commandID); - } - // Directly set with the values calculated here - else if (commandID == "cmd_DeleteTable" || - commandID == "cmd_NormalizeTable") - { - goSetCommandEnabled(commandID, enabledIfTable); - } else { - goSetCommandEnabled(commandID, enabled); - } - } - } -} - -//----------------------------------------------------------------------------------- -// Helpers for inserting and editing tables: - -function IsInTable() -{ - return (window.editorShell && window.editorShell.documentEditable && - null != window.editorShell.GetElementOrParentByTagName("table", null)); -} - -function IsInTableCell() -{ - return (window.editorShell && window.editorShell.documentEditable && - null != window.editorShell.GetElementOrParentByTagName("td", null)); -} - -function IsSelectionInOneCell() -{ - var selection = window.editorShell.editorSelection; - - if (selection && selection.rangeCount == 1) - { - // We have a "normal" single-range selection - if (!selection.isCollapsed && - selection.anchorNode != selection.focusNode) - { - // Check if both nodes are within the same cell - var anchorCell = window.editorShell.GetElementOrParentByTagName("td", selection.anchorNode); - var focusCell = window.editorShell.GetElementOrParentByTagName("td", selection.focusNode); - return (focusCell != null && anchorCell != null && (focusCell == anchorCell)); - } - // Collapsed selection or anchor == focus (thus must be in 1 cell) - return true; - } - return false; -} - -// Call this with insertAllowed = true to allow inserting if not in existing table, -// else use false to do nothing if not in a table -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) { - EditorInsertTable(); - } -} - -function EditorInsertTable() -{ -dump("EditorInsertTable\n"); - // Insert a new table - window.openDialog("chrome://editor/content/EdInsertTable.xul", "_blank", "chrome,close,titlebar,modal", ""); - window.content.focus(); -} - -function EditorTableCellProperties() -{ - var cell = editorShell.GetElementOrParentByTagName("td", null); - if (cell) { - // Start Table Properties dialog on the "Cell" panel - window.openDialog("chrome://editor/content/EdTableProps.xul", "_blank", "chrome,close,titlebar,modal", "", "CellPanel"); - window.content.focus(); - } -} - //----------------------------------------------------------------------------------- var nsInsertOrEditTableCommand = { diff --git a/editor/ui/composer/content/EditorCommandsOverlay.xul b/editor/ui/composer/content/EditorCommandsOverlay.xul index 2c275f3f74e4..d8dd9b148c24 100644 --- a/editor/ui/composer/content/EditorCommandsOverlay.xul +++ b/editor/ui/composer/content/EditorCommandsOverlay.xul @@ -62,7 +62,7 @@ + observes="cmd_objectProperties"/> diff --git a/editor/ui/composer/content/EditorContent.css b/editor/ui/composer/content/EditorContent.css index c1535a0b476b..b3b7ab9ed73c 100644 --- a/editor/ui/composer/content/EditorContent.css +++ b/editor/ui/composer/content/EditorContent.css @@ -53,11 +53,3 @@ table[border="0"] * td, table[border="0"] * th { border: 1px dotted red; } -/* For ease in caret placement, - have a minimum cell width - BUG - DOESN'T WORK! - Note: Setting "width" works -*/ -td, th { - min-width: 10px; -} diff --git a/editor/ui/composer/content/EditorContextMenuOverlay.xul b/editor/ui/composer/content/EditorContextMenuOverlay.xul index 849ab8546307..4364bd360a4a 100644 --- a/editor/ui/composer/content/EditorContextMenuOverlay.xul +++ b/editor/ui/composer/content/EditorContextMenuOverlay.xul @@ -64,8 +64,7 @@ - + diff --git a/editor/ui/composer/content/EditorOverride.css b/editor/ui/composer/content/EditorOverride.css index 3c461bbc7396..d3c7e4d379c4 100644 --- a/editor/ui/composer/content/EditorOverride.css +++ b/editor/ui/composer/content/EditorOverride.css @@ -32,7 +32,13 @@ a:link, a:visited, a:active, a:out-of-date { cursor: text; } +/* We want the default arrow when hover over the + various objects, such as the image that + represents the named anchor +*/ a:link img, a:visited img, a:active img, -a:out-of-date img, img[usemap], object[usemap] { +a:out-of-date img, img[usemap], +object[usemap], +a[name] { cursor: default; } diff --git a/editor/ui/composer/content/editor.js b/editor/ui/composer/content/editor.js index 4d0e7fee2b5c..bfa3dec5b9f1 100644 --- a/editor/ui/composer/content/editor.js +++ b/editor/ui/composer/content/editor.js @@ -439,6 +439,8 @@ function onParagraphFormatChange(paraMenuList, commandID) { var commandNode = document.getElementById(commandID); var state = commandNode.getAttribute("state"); + var menuList = document.getElementById("ParagraphSelect"); + if (!menuList) return; dump("Updating font face with " + state + "\n"); @@ -450,7 +452,7 @@ function onParagraphFormatChange(paraMenuList, commandID) { //Selection is the "mixed" ( > 1 style) state paraMenuList.selectedItem = null; - paraMenuList.setAttribute("value",GetString('MixedFormats')); + paraMenuList.setAttribute("value",GetString('Mixed')); } else { @@ -488,7 +490,7 @@ function onFontFaceChange(fontFaceMenuList, commandID) { //Selection is the "mixed" ( > 1 style) state fontFaceMenuList.selectedItem = null; - fontFaceMenuList.setAttribute("value",GetString('MixedFormats')); + fontFaceMenuList.setAttribute("value",GetString('Mixed')); } else { @@ -915,32 +917,6 @@ function EditorToggleParagraphMarks() } } -function SetBackColorString(xulElementID) -{ - var xulElement = document.getElementById(xulElementID); - if (xulElement) - { - var textVal; - var selectedCountObj = new Object(); - var tagNameObj = new Object(); - var element = editorShell.GetSelectedOrParentTableElement(tagNameObj, selectedCountObj); - - if (tagNameObj.value == "table") - textVal = GetString("TableBackColor"); - else if (tagNameObj.value == "td") - textVal = GetString("CellBackColor"); - else - textVal = GetString("PageBackColor"); - - xulElement.setAttribute("value",textVal); - } -} - -function InitBackColorPopup() -{ - SetBackColorString("BackColorCaption"); -} - function EditorInitEditMenu() { var DelStr = GetString(gIsMac ? "Clear" : "Delete"); @@ -981,6 +957,9 @@ function EditorInitFormatMenu() // Set the string for the background color menu item SetBackColorString("backgroundColorMenu"); + // Set strings and enable for the [Object] Properties item + // Note that we directly do the enabling instead of + // using goSetCommandEnabled since we already have the menuitem var menuItem = document.getElementById("objectProperties"); if (menuItem) { @@ -992,23 +971,23 @@ function EditorInitFormatMenu() menuItem.removeAttribute("disabled"); switch (element.nodeName) { - case 'IMG': + case 'img': objStr = GetString("Image"); break; - case 'HR': + case 'hr': objStr = GetString("HLine"); break; - case 'TABLE': + case 'table': objStr = GetString("Table"); break; - case 'TD': + case 'td': objStr = GetString("TableCell"); break; - case 'A': - if(element.href) - objStr = GetString("Link"); - else if (element.name) + case 'a': + if (element.name) objStr = GetString("NamedAnchor"); + else if(element.href) + objStr = GetString("Link"); break; } menuStr = menuStr.replace(/%obj%/,objStr); @@ -1025,6 +1004,32 @@ function EditorInitFormatMenu() } } +function SetBackColorString(xulElementID) +{ + var xulElement = document.getElementById(xulElementID); + if (xulElement) + { + var textVal; + var selectedCountObj = new Object(); + var tagNameObj = new Object(); + var element = editorShell.GetSelectedOrParentTableElement(tagNameObj, selectedCountObj); + + if (tagNameObj.value == "table") + textVal = GetString("TableBackColor"); + else if (tagNameObj.value == "td") + textVal = GetString("CellBackColor"); + else + textVal = GetString("PageBackColor"); + + xulElement.setAttribute("value",textVal); + } +} + +function InitBackColorPopup() +{ + SetBackColorString("BackColorCaption"); +} + function EditorInitToolbars() { // Nothing to do now, but we might want some state updating here @@ -1452,3 +1457,158 @@ function GetPrefsService() dump("failed to get prefs service!\n"); } } + +// Command Updating Strategy: +// Don't update on on selection change, only when menu is displayed, +// with this "oncreate" hander: +function EditorInitTableMenu() +{ + // Change text on the "Join..." item depending if we + // are joining selected cells or just cell to right + // TODO: What to do about normal selection that crosses + // table border? Try to figure out all cells + // included in the selection? + var menuText; + + // Use "Join selected cells if there's more than 1 cell selected + var tagNameObj = new Object; + var countObj = new Object; + if (window.editorShell.GetSelectedOrParentTableElement(tagNameObj, countObj) && countObj.value > 1) + menuText = GetString("JoinSelectedCells"); + else + menuText = GetString("JoinCellToRight"); + + document.getElementById("menu_tableJoinCells").setAttribute("value",menuText); + + // Set platform-specific hints for how to select cells + if (gIsWin) osKey = "XulKeyWin"; + if (gIsMac) osKey = "XulKeyMac"; + if (gIsUNIX) osKey = "XulKeyUnix"; + + var DragStr = GetString(osKey)+GetString("Drag"); + var ClickStr = GetString(osKey)+GetString("Click"); + var DelStr = GetString(gIsMac ? "Clear" : "Del"); + + document.getElementById("menu_DeleteCell").setAttribute("acceltext",ClickStr); + document.getElementById("menu_SelectRow").setAttribute("acceltext",DragStr); + document.getElementById("menu_SelectColumn").setAttribute("acceltext",DragStr); + document.getElementById("menu_SelectAllCells").setAttribute("acceltext",DragStr); + // And add "Del" or "Clear" + document.getElementById("menu_DeleteCellContents").setAttribute("acceltext",DelStr); + + // Set enable states for all table commands + goUpdateTableMenuItems(document.getElementById("composerTableMenuItems")); +} + +function goUpdateTableMenuItems(commandset) +{ + var enabled = false; + + var enabledIfTable = false; + if (window.editorShell && window.editorShell.documentEditable) + { + var selectedCountObj = new Object(); + var tagNameObj = new Object(); + var element = editorShell.GetSelectedOrParentTableElement(tagNameObj, selectedCountObj); + if (element) + { + // Value when we need to have a selected table or inside a table + enabledIfTable = true; + + // All others require being inside a cell or selected cell + enabled = (tagNameObj.value == "td"); + } + } + + // Loop through command nodes + for (var i = 0; i < commandset.childNodes.length; i++) + { + var commandID = commandset.childNodes[i].getAttribute("id"); + if (commandID) + { + if (commandID == "cmd_InsertTable" || + commandID == "cmd_tableJoinCells" || + commandID == "cmd_tableSplitCell") + { + // Call the update method in the command class + goUpdateCommand(commandID); + } + // Directly set with the values calculated here + else if (commandID == "cmd_DeleteTable" || + commandID == "cmd_NormalizeTable") + { + goSetCommandEnabled(commandID, enabledIfTable); + } else { + goSetCommandEnabled(commandID, enabled); + } + } + } +} + +//----------------------------------------------------------------------------------- +// Helpers for inserting and editing tables: + +function IsInTable() +{ + return (window.editorShell && window.editorShell.documentEditable && + null != window.editorShell.GetElementOrParentByTagName("table", null)); +} + +function IsInTableCell() +{ + return (window.editorShell && window.editorShell.documentEditable && + null != window.editorShell.GetElementOrParentByTagName("td", null)); +} + +function IsSelectionInOneCell() +{ + var selection = window.editorShell.editorSelection; + + if (selection && selection.rangeCount == 1) + { + // We have a "normal" single-range selection + if (!selection.isCollapsed && + selection.anchorNode != selection.focusNode) + { + // Check if both nodes are within the same cell + var anchorCell = window.editorShell.GetElementOrParentByTagName("td", selection.anchorNode); + var focusCell = window.editorShell.GetElementOrParentByTagName("td", selection.focusNode); + return (focusCell != null && anchorCell != null && (focusCell == anchorCell)); + } + // Collapsed selection or anchor == focus (thus must be in 1 cell) + return true; + } + return false; +} + +// Call this with insertAllowed = true to allow inserting if not in existing table, +// else use false to do nothing if not in a table +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) { + EditorInsertTable(); + } +} + +function EditorInsertTable() +{ +dump("EditorInsertTable\n"); + // Insert a new table + window.openDialog("chrome://editor/content/EdInsertTable.xul", "_blank", "chrome,close,titlebar,modal", ""); + window.content.focus(); +} + +function EditorTableCellProperties() +{ + var cell = editorShell.GetElementOrParentByTagName("td", null); + if (cell) { + // Start Table Properties dialog on the "Cell" panel + window.openDialog("chrome://editor/content/EdTableProps.xul", "_blank", "chrome,close,titlebar,modal", "", "CellPanel"); + window.content.focus(); + } +} + diff --git a/editor/ui/composer/content/editorOverlay.xul b/editor/ui/composer/content/editorOverlay.xul index e3e8191de0e5..e657e87ee057 100644 --- a/editor/ui/composer/content/editorOverlay.xul +++ b/editor/ui/composer/content/editorOverlay.xul @@ -100,17 +100,18 @@ - - - - - - + + + + + + + - - - - + + + + - + diff --git a/editor/ui/composer/content/images/tag-ol.gif b/editor/ui/composer/content/images/tag-ol.gif index 875d998e6763..fd8dca3505db 100644 Binary files a/editor/ui/composer/content/images/tag-ol.gif and b/editor/ui/composer/content/images/tag-ol.gif differ diff --git a/editor/ui/composer/content/images/tag-ul.gif b/editor/ui/composer/content/images/tag-ul.gif index 71ce8c1ede02..3b6717a83b8e 100644 Binary files a/editor/ui/composer/content/images/tag-ul.gif and b/editor/ui/composer/content/images/tag-ul.gif differ diff --git a/editor/ui/composer/locale/en-US/editor.properties b/editor/ui/composer/locale/en-US/editor.properties index 60a007fc3fd4..8d7c0cf04f8b 100644 --- a/editor/ui/composer/locale/en-US/editor.properties +++ b/editor/ui/composer/locale/en-US/editor.properties @@ -60,8 +60,7 @@ EmptyHREFError=You must enter or choose a location (URL) to create a new link. LinkText=Link text: LinkImage=Link image: MixedSelection=[Mixed selection] -MixedFormats=(mixed) -MixedFonts=(mixed) +Mixed=(mixed) EnterLinkText=Enter text to display for the link: EmptyLinkTextError=You must enter some text for this link. #Don't translate: %n% %min% %max%