diff --git a/mozilla/editor/ui/composer/content/EditorAppShell.xul b/mozilla/editor/ui/composer/content/EditorAppShell.xul index ff4e590a6ca..aa11197b398 100644 --- a/mozilla/editor/ui/composer/content/EditorAppShell.xul +++ b/mozilla/editor/ui/composer/content/EditorAppShell.xul @@ -1,5 +1,6 @@ + + onload="EditorStartup()" onunload="EditorShutdown()" title="Editor"> + - - + + @@ -37,7 +39,7 @@ - + @@ -178,9 +180,24 @@ - - + + + + + + + + + + + + + + + + + diff --git a/mozilla/editor/ui/composer/content/EditorCommands.js b/mozilla/editor/ui/composer/content/EditorCommands.js index 700da9505c3..1ce3ce750bd 100644 --- a/mozilla/editor/ui/composer/content/EditorCommands.js +++ b/mozilla/editor/ui/composer/content/EditorCommands.js @@ -1,344 +1,430 @@ /* Main Composer window UI control */ - /*the editor type, i.e. "text" or "html" */ - /* the name of the editor. Must be unique to this window clique */ - var editorName = "EditorAppCoreHTML"; - var appCore = null; - var toolkitCore = null; +/*the editor type, i.e. "text" or "html" */ +/* the name of the editor. Must be unique globally, hence the timestamp */ +var editorName = "EditorAppCore." + ( new Date() ).getTime().toString(); +var appCore = null; +var toolkitCore = null; - function Startup() +function EditorStartup() +{ + dump("Doing Startup...\n"); + + /* Get the global Editor AppCore and the XPFE toolkit core into globals here */ + appCore = XPAppCoresManager.Find(editorName); + dump("Looking up EditorAppCore...\n"); + if (appCore == null) { - dump("Doing Startup...\n"); + dump("Creating EditorAppCore...\n"); + appCore = new EditorAppCore(); + if (appCore) { + dump(editorName + " has been created.\n"); + appCore.Init(editorName); - /* Get the global Editor AppCore and the XPFE toolkit core into globals here */ - appCore = XPAppCoresManager.Find(editorName); - dump("Looking up EditorAppCore...\n"); - if (appCore == null) { - dump("Creating EditorAppCore...\n"); - appCore = new EditorAppCore(); - if (appCore) { - dump("EditorAppCore has been created.\n"); - appCore.Init(editorName); - appCore.setEditorType("html"); - appCore.setContentWindow( window.frames[0] ); - appCore.setWebShellWindow(window); - appCore.setToolbarWindow(window); - dump("EditorAppCore windows have been set.\n"); - } - } else { - dump("EditorAppCore has already been created! Why?\n"); - } - toolkitCore = XPAppCoresManager.Find("ToolkitCore"); - if (!toolkitCore) { - toolkitCore = new ToolkitCore(); - if (toolkitCore) { - toolkitCore.Init("ToolkitCore"); - dump("ToolkitCore initialized for Editor\n"); - } - } else { - dump("ToolkitCore found\n"); + appCore.setWebShellWindow(window); + appCore.setToolbarWindow(window) + + appCore.setEditorType("html"); + appCore.setContentWindow( window.frames[0] ); + + // Get url for editor content + var url = document.getElementById("args").getAttribute("value"); + // Load the source (the app core will magically know what to do). + appCore.loadUrl(url); + // the editor gets instantiated by the appcore when the URL has finished loading. + dump("EditorAppCore windows have been set.\n"); } + } else { + dump("EditorAppCore has already been created! Why?\n"); } - - - function EditorSave() + toolkitCore = XPAppCoresManager.Find("ToolkitCore"); + if (!toolkitCore) { - dump("In EditorSave...\n"); - - appCore = XPAppCoresManager.Find(editorName); - if (appCore) - { - appCore.save(); + toolkitCore = new ToolkitCore(); + if (toolkitCore) { + toolkitCore.Init("ToolkitCore"); + dump("ToolkitCore initialized for Editor\n"); } + } else { + dump("ToolkitCore found\n"); } +} - function EditorSaveAs() + +function EditorShutdown() +{ + dump("In EditorShutdown..\n"); + + appCore = XPAppCoresManager.Remove(editorName); +} + + +// --------------------------- File menu --------------------------- + +function EditorNew() +{ + dump("In EditorNew..\n"); + + appCore = XPAppCoresManager.Find(editorName); + if (appCore) { - dump("In EditorSave...\n"); - - appCore = XPAppCoresManager.Find(editorName); - if (appCore) - { - appCore.saveAs(); - } - } - - function EditorClose() + appCore.newWindow(); + } +} + +function EditorOpen() +{ + dump("In EditorOpen..\n"); + + appCore = XPAppCoresManager.Find(editorName); + if (appCore) { - dump("In EditorClose...\n"); - - appCore = XPAppCoresManager.Find(editorName); - if (appCore) - { - - - - } + appCore.open(); + } +} + +function EditorSave() +{ + dump("In EditorSave...\n"); + + appCore = XPAppCoresManager.Find(editorName); + if (appCore) + { + appCore.save(); + } +} + +function EditorSaveAs() +{ + dump("In EditorSave...\n"); + + appCore = XPAppCoresManager.Find(editorName); + if (appCore) + { + appCore.saveAs(); + } +} + + +function EditorPrint() +{ + dump("In EditorPrint..\n"); + + appCore = XPAppCoresManager.Find(editorName); + if (appCore) + { + appCore.print(); + } +} + +function EditorClose() +{ + dump("In EditorClose...\n"); + + appCore = XPAppCoresManager.Find(editorName); + if (appCore) + { + appCore.closeWindow(); + } +} + +// --------------------------- Edit menu --------------------------- + +function EditorUndo() +{ + if (appCore) { + dump("Undoing\n"); + appCore.undo(); + } +} + +function EditorRedo() +{ + if (appCore) { + dump("Redoing\n"); + appCore.redo(); + } +} + +function EditorCut() +{ + if (appCore) { + dump("Cutting\n"); + appCore.cut(); + } +} + +function EditorCopy() +{ + if (appCore) { + dump("Copying\n"); + appCore.copy(); + } +} + +function EditorPaste() +{ + if (appCore) { + dump("Pasting\n"); + appCore.paste(); + } +} + +function EditorSelectAll() +{ + if (appCore) { + dump("Selecting all\n"); + appCore.selectAll(); + } +} + +function EditorFind(firstTime) +{ + if (toolkitCore && firstTime) { + toolkitCore.ShowWindow("resource:/res/samples/find.xul", window); } - function EditorFind(firstTime) - { - if (toolkitCore && firstTime) { - toolkitCore.ShowWindow("resource:/res/samples/find.xul", window); + if (appCore) { + appCore.find("test", true, true); + } +} + +function EditorShowClipboard() +{ + dump("In EditorShowClipboard...\n"); + + if (appCore) { + dump("Doing EditorShowClipboard...\n"); + appCore.showClipboard(); + } +} + +// --------------------------- Text style --------------------------- + +function SetTextProperty(property, attribute, value) +{ + if (appCore) { + appCore.setTextProperty(property, attribute, value); + } +} + +function SetParagraphFormat(paraFormat) +{ + if (appCore) { + appCore.setParagraphFormat(paraFormat); + } +} + +function SetFontSize(size) +{ + if (appCore) { + appCore.setTextProperty("font", "size", size); + } +} + +function SetFontFace(fontFace) +{ + if (appCore) { + if( fontFace == "tt") { + // The old "teletype" attribute + appCore.setTextProperty("tt", "", ""); + // Clear existing font face + fontFace = ""; } - - if (appCore) { - appCore.find("test", true, true); - } - } + appCore.setTextProperty("font", "face", fontFace); + } +} - function SetTextProperty(property, attribute, value) - { - if (appCore) { - appCore.setTextProperty(property, attribute, value); - } - } - - function SetParagraphFormat(paraFormat) - { - if (appCore) { - appCore.setParagraphFormat(paraFormat); - } - } - - function SetFontSize(size) - { - if (appCore) { - appCore.setTextProperty("font", "size", size); - } - } - - function SetFontFace(fontFace) - { - if (appCore) { - if( fontFace == "tt") { - // The old "teletype" attribute - appCore.setTextProperty("tt", "", ""); - // Clear existing font face - fontFace = ""; - } - appCore.setTextProperty("font", "face", fontFace); - } - } - - function SetFontColor(color) - { - if (appCore) { - appCore.setTextProperty("font", "color", color); - } - } +function SetFontColor(color) +{ + if (appCore) { + appCore.setTextProperty("font", "color", color); + } +} // Debug methods to test the SELECT element used in a toolbar: - function OnChangeParaFormat() - { - dump(" *** Change Paragraph Format combobox setting\n"); - } +function OnChangeParaFormat() +{ + dump(" *** Change Paragraph Format combobox setting\n"); +} - function OnFocusParaFormat() - { - dump(" *** OnFocus -- Paragraph Format\n"); - } +function OnFocusParaFormat() +{ + dump(" *** OnFocus -- Paragraph Format\n"); +} - function OnBlurParaFormat() - { - dump(" *** OnBlur -- Paragraph Format\n"); - } +function OnBlurParaFormat() +{ + dump(" *** OnBlur -- Paragraph Format\n"); +} - function EditorApplyStyle(styleName) - { - if (appCore) { - dump("Applying Style\n"); - appCore.setTextProperty(styleName, null, null); - } +function EditorApplyStyle(styleName) +{ + if (appCore) { + dump("Applying Style\n"); + appCore.setTextProperty(styleName, null, null); } +} - function EditorRemoveStyle(styleName) - { - if (appCore) { - dump("Removing Style\n"); - appCore.removeTextProperty(styleName, null); - } +function EditorRemoveStyle(styleName) +{ + if (appCore) { + dump("Removing Style\n"); + appCore.removeTextProperty(styleName, null); } +} - function EditorGetText() - { - if (appCore) { - dump("Getting text\n"); - var outputText = appCore.contentsAsText; - dump(outputText + "\n"); - } - } +// --------------------------- Output --------------------------- - function EditorGetHTML() - { - if (appCore) { - dump("Getting HTML\n"); - var outputText = appCore.contentsAsHTML; - dump(outputText + "\n"); - } +function EditorGetText() +{ + if (appCore) { + dump("Getting text\n"); + var outputText = appCore.contentsAsText; + dump(outputText + "\n"); } +} - function EditorUndo() - { - if (appCore) { - dump("Undoing\n"); - appCore.undo(); - } +function EditorGetHTML() +{ + if (appCore) { + dump("Getting HTML\n"); + var outputText = appCore.contentsAsHTML; + dump(outputText + "\n"); } +} - function EditorRedo() - { - if (appCore) { - dump("Redoing\n"); - appCore.redo(); - } - } - - function EditorCut() - { - if (appCore) { - dump("Cutting\n"); - appCore.cut(); - } - } - - function EditorCopy() - { - if (appCore) { - dump("Copying\n"); - appCore.copy(); - } - } - - function EditorPaste() - { - if (appCore) { - dump("Pasting\n"); - appCore.paste(); - } - } - - function EditorSelectAll() - { - if (appCore) { - dump("Selecting all\n"); - appCore.selectAll(); - } - } - - function EditorInsertText() - { - if (appCore) { - dump("Inserting text\n"); - appCore.insertText("Once more into the breach, dear friends.\n"); - } +function EditorInsertText() +{ + if (appCore) { + dump("Inserting text\n"); + appCore.insertText("Once more into the breach, dear friends.\n"); } +} function EditorInsertLink() - { - dump("Starting Insert Link... appCore, toolkitCore: "+(appCore==null)+(toolkitCore==null)+"\n"); - if (appCore && toolkitCore) { - dump("Link Properties Dialog starting...\n"); - toolkitCore.ShowModalDialog("chrome://editordlgs/content/EdLinkProps.xul", - window); - } +{ + dump("Starting Insert Link... appCore, toolkitCore: "+(appCore==null)+(toolkitCore==null)+"\n"); + if (appCore && toolkitCore) { + dump("Link Properties Dialog starting...\n"); + // go back to using this when window.opener works. + //toolkitCore.ShowModalDialog("chrome://editordlgs/content/EdLinkProps.xul", window); + toolkitCore.ShowWindowWithArgs("chrome://editordlgs/content/EdLinkProps.xul", window, editorName); } +} - function EditorInsertList(listType) - { - if (appCore) { - dump("Inserting link\n"); - appCore.insertList(listType); - } +function EditorInsertList(listType) +{ + if (appCore) { + dump("Inserting link\n"); + appCore.insertList(listType); } +} - function EditorInsertImage() +function EditorInsertImage() +{ + dump("Starting Insert Image...\n"); + if (appCore && toolkitCore) { + dump("Link Properties Dialog starting...\n"); + //toolkitCore.ShowModalDialog("chrome://editordlgs/content/EdImageProps.xul", window); + toolkitCore.ShowWindowWithArgs("chrome://editordlgs/content/EdImageProps.xul", window, editorName); + } +} + +function EditorExit() +{ + if (appCore) { + dump("Exiting\n"); + appCore.exit(); + } +} + +function EditorPrintPreview() { + if (toolkitCore) { + toolkitCore.ShowWindow("resource:/res/samples/printsetup.html", window); + } +} + +// --------------------------- Debug stuff --------------------------- + +function EditorTestSelection() +{ + if (appCore) { - dump("Starting Insert Image...\n"); - if (appCore && toolkitCore) { - dump("Link Properties Dialog starting...\n"); - toolkitCore.ShowModalDialog("chrome://editordlgs/content/EdImageProps.xul", - window); + dump("Testing selection\n"); + var selection = appCore.editorSelection; + if (selection) + { + dump("Got selection\n"); + var firstRange = selection.getRangeAt(0); + if (firstRange) + { + dump("Range contains \""); + dump(firstRange.toString() + "\"\n"); } } - function EditorExit() + } +} + +function EditorTestDocument() +{ + if (appCore) { - if (appCore) { - dump("Exiting\n"); - appCore.exit(); + dump("Getting document\n"); + var theDoc = appCore.editorDocument; + if (theDoc) + { + dump("Got the doc\n"); + dump("Document name:" + theDoc.nodeName + "\n"); + dump("Document type:" + theDoc.doctype + "\n"); + } + else + { + dump("Failed to get the doc\n"); } } +} - function EditorPrintPreview() { - if (toolkitCore) { - toolkitCore.ShowWindow("resource:/res/samples/printsetup.html", window); - } + +// --------------------------- Callbacks --------------------------- +function OpenFile(url) +{ + // This is invoked from the browser app core. + core = XPAppCoresManager.Find("toolkitCore"); + if ( !core ) { + core = new ToolkitCore(); + if ( core ) { + core.Init("toolkitCore"); + } } + if ( core ) { + core.ShowWindowWithArgs( "chrome://editor/content/", window, url ); + } else { + dump("Error; can't create toolkitCore\n"); + } +} - function EditorTestSelection() - { - if (appCore) - { - dump("Testing selection\n"); - var selection = appCore.editorSelection; - if (selection) - { - dump("Got selection\n"); - var firstRange = selection.getRangeAt(0); - if (firstRange) - { - dump("Range contains \""); - dump(firstRange.toString() + "\"\n"); - } - } - - } - } - - function EditorTestDocument() - { - if (appCore) - { - dump("Getting document\n"); - var theDoc = appCore.editorDocument; - if (theDoc) - { - dump("Got the doc\n"); - dump("Document name:" + theDoc.nodeName + "\n"); - dump("Document type:" + theDoc.doctype + "\n"); - } - else - { - dump("Failed to get the doc\n"); - } - } - } - - /* Status calls */ - function onBoldChange() - { - var button = document.getElementById("Editor:Style:IsBold"); - if (button) - { - var bold = button.getAttribute("bold"); - - if ( bold == "true" ) { - button.setAttribute( "disabled", false ); - } - else { - button.setAttribute( "disabled", true ); - } - - } - else - { - dump("Can't find bold broadcaster!\n"); - } - } - - function Shutdown() +// --------------------------- Status calls --------------------------- +function onBoldChange() +{ + var button = document.getElementById("Editor:Style:IsBold"); + if (button) { - } \ No newline at end of file + var bold = button.getAttribute("bold"); + + if ( bold == "true" ) { + button.setAttribute( "disabled", false ); + } + else { + button.setAttribute( "disabled", true ); + } + + } + else + { + dump("Can't find bold broadcaster!\n"); + } +} diff --git a/mozilla/editor/ui/dialogs/content/EdCharacterProps.js b/mozilla/editor/ui/dialogs/content/EdCharacterProps.js index cd25ce56106..570864695f7 100644 --- a/mozilla/editor/ui/dialogs/content/EdCharacterProps.js +++ b/mozilla/editor/ui/dialogs/content/EdCharacterProps.js @@ -21,8 +21,13 @@ function Startup() dump("toolkitCore not found!!! And we can't close the dialog!\n"); } + // temporary while this window is opend with ShowWindowWithArgs + dump("Getting parent appcore\n"); + var editorName = document.getElementById("args").getAttribute("value"); + dump("Got editorAppCore called " + editorName + "\n"); + // NEVER create an appcore here - we must find parent editor's - appCore = XPAppCoresManager.Find("EditorAppCoreHTML"); + appCore = XPAppCoresManager.Find(editorName); if(!appCore || !toolkitCore) { dump("EditorAppCore not found!!!\n"); toolkitCore.CloseWindow(window); diff --git a/mozilla/editor/ui/dialogs/content/EdCharacterProps.xul b/mozilla/editor/ui/dialogs/content/EdCharacterProps.xul index 09c4ff54978..346a843bfb6 100644 --- a/mozilla/editor/ui/dialogs/content/EdCharacterProps.xul +++ b/mozilla/editor/ui/dialogs/content/EdCharacterProps.xul @@ -13,5 +13,6 @@ + diff --git a/mozilla/editor/ui/dialogs/content/EdImageProps.js b/mozilla/editor/ui/dialogs/content/EdImageProps.js index 1e4fd5e0138..d107c5a0e44 100644 --- a/mozilla/editor/ui/dialogs/content/EdImageProps.js +++ b/mozilla/editor/ui/dialogs/content/EdImageProps.js @@ -22,11 +22,17 @@ function Startup() dump("toolkitCore not found!!! And we can't close the dialog!\n"); } + // temporary while this window is opend with ShowWindowWithArgs + dump("Getting parent appcore\n"); + var editorName = document.getElementById("args").getAttribute("value"); + dump("Got editorAppCore called " + editorName + "\n"); + // NEVER create an appcore here - we must find parent editor's - appCore = XPAppCoresManager.Find("EditorAppCoreHTML"); + appCore = XPAppCoresManager.Find(editorName); if(!appCore || !toolkitCore) { dump("EditorAppCore not found!!!\n"); toolkitCore.CloseWindow(window); + return; } dump("EditorAppCore found for Image Properties dialog\n"); diff --git a/mozilla/editor/ui/dialogs/content/EdImageProps.xul b/mozilla/editor/ui/dialogs/content/EdImageProps.xul index a7b1aa00d8a..75f9f027a3a 100644 --- a/mozilla/editor/ui/dialogs/content/EdImageProps.xul +++ b/mozilla/editor/ui/dialogs/content/EdImageProps.xul @@ -2,6 +2,7 @@ + + + +
diff --git a/mozilla/editor/ui/dialogs/content/EdLinkProps.js b/mozilla/editor/ui/dialogs/content/EdLinkProps.js index 898d35dedcd..b905c838cce 100644 --- a/mozilla/editor/ui/dialogs/content/EdLinkProps.js +++ b/mozilla/editor/ui/dialogs/content/EdLinkProps.js @@ -28,11 +28,17 @@ function Startup() { dump("toolkitCore not found!!! And we can't close the dialog!\n"); } + // temporary while this window is opend with ShowWindowWithArgs + dump("Getting parent appcore\n"); + var editorName = document.getElementById("args").getAttribute("value"); + dump("Got editorAppCore called " + editorName + "\n"); + // NEVER create an appcore here - we must find parent editor's - appCore = XPAppCoresManager.Find("EditorAppCoreHTML"); + appCore = XPAppCoresManager.Find(editorName); if(!appCore || !toolkitCore) { dump("EditorAppCore not found!!!\n"); toolkitCore.CloseWindow(window); + return; } dump("EditorAppCore found for Link Properties dialog\n"); diff --git a/mozilla/editor/ui/dialogs/content/EdLinkProps.xul b/mozilla/editor/ui/dialogs/content/EdLinkProps.xul index 860524296ab..304a89ab80d 100644 --- a/mozilla/editor/ui/dialogs/content/EdLinkProps.xul +++ b/mozilla/editor/ui/dialogs/content/EdLinkProps.xul @@ -2,6 +2,7 @@ + + + +