diff --git a/editor/base/nsHTMLEditor.cpp b/editor/base/nsHTMLEditor.cpp
index c3663e0cd8f..25b2ad384a6 100644
--- a/editor/base/nsHTMLEditor.cpp
+++ b/editor/base/nsHTMLEditor.cpp
@@ -1439,8 +1439,10 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
iter->Next();
}
- if (!bNodeFound)
- printf("No nodes of tag name = %s were found in selection\n", aTagName);
+ if (!bNodeFound) {
+ char TagBuf[50] = "";
+ printf("No nodes of tag name = %s were found in selection\n", aTagName.ToCString(TagBuf, 50));
+ }
}
} else {
// Should never get here?
@@ -1525,7 +1527,20 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection, ns
nsCOMPtr parentSelectedNode;
PRInt32 offsetOfNewNode;
+ // Clear current selection.
+ // Should put caret at anchor point?
+ if (!aDeleteSelection)
+ {
+ nsCOMPtrselection;
+ nsresult res = nsEditor::GetSelection(getter_AddRefs(selection));
+ if (NS_SUCCEEDED(res) && selection)
+ {
+ selection->ClearSelection();
+ }
+ }
+
DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode);
+
if (NS_SUCCEEDED(result))
{
nsCOMPtr newNode = do_QueryInterface(aElement);
diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp
index c3663e0cd8f..25b2ad384a6 100644
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -1439,8 +1439,10 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
iter->Next();
}
- if (!bNodeFound)
- printf("No nodes of tag name = %s were found in selection\n", aTagName);
+ if (!bNodeFound) {
+ char TagBuf[50] = "";
+ printf("No nodes of tag name = %s were found in selection\n", aTagName.ToCString(TagBuf, 50));
+ }
}
} else {
// Should never get here?
@@ -1525,7 +1527,20 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection, ns
nsCOMPtr parentSelectedNode;
PRInt32 offsetOfNewNode;
+ // Clear current selection.
+ // Should put caret at anchor point?
+ if (!aDeleteSelection)
+ {
+ nsCOMPtrselection;
+ nsresult res = nsEditor::GetSelection(getter_AddRefs(selection));
+ if (NS_SUCCEEDED(res) && selection)
+ {
+ selection->ClearSelection();
+ }
+ }
+
DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode);
+
if (NS_SUCCEEDED(result))
{
nsCOMPtr newNode = do_QueryInterface(aElement);
diff --git a/editor/ui/dialogs/content/EdCharacterProps.js b/editor/ui/dialogs/content/EdCharacterProps.js
index 4e3ba603cac..cd25ce56106 100644
--- a/editor/ui/dialogs/content/EdCharacterProps.js
+++ b/editor/ui/dialogs/content/EdCharacterProps.js
@@ -1,11 +1,14 @@
- // dialog initialization code
+// OnOK(), Undo(), and Cancel() are in EdDialogCommon.js
+// applyChanges() must be implemented here
+
+// dialog initialization code
var appCore;
var toolkitCore;
var insertNew = true;
var selectionIsCollapsed = false;
var undoCount = 0;
-function Statup()
+function Startup()
{
dump("Doing Character Props Startup...\n");
toolkitCore = XPAppCoresManager.Find("ToolkitCore");
@@ -24,4 +27,8 @@ function Statup()
dump("EditorAppCore not found!!!\n");
toolkitCore.CloseWindow(window);
}
-}
\ No newline at end of file
+}
+
+function applyChanges()
+{
+}
diff --git a/editor/ui/dialogs/content/EdCharacterProps.xul b/editor/ui/dialogs/content/EdCharacterProps.xul
index 5736afc6833..09c4ff54978 100644
--- a/editor/ui/dialogs/content/EdCharacterProps.xul
+++ b/editor/ui/dialogs/content/EdCharacterProps.xul
@@ -7,6 +7,11 @@
xmlns:xul ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload = "Startup()">
+
+
+
+
diff --git a/editor/ui/dialogs/content/EdDialogCommon.js b/editor/ui/dialogs/content/EdDialogCommon.js
new file mode 100644
index 00000000000..1a988bd8f1d
--- /dev/null
+++ b/editor/ui/dialogs/content/EdDialogCommon.js
@@ -0,0 +1,23 @@
+function onUndo() {
+ if (undoCount > 0)
+ {
+ dump("Undo count = "+undoCount+"\n");
+ undoCount = undoCount - 1;
+ appCore.undo();
+ }
+}
+
+function onOK() {
+ applyChanges();
+ //toolkitCore.CloseWindow(window);
+}
+
+function onCancel() {
+ // Undo all actions performed within the dialog
+ // TODO: We need to suppress reflow/redraw untill all levels are undone
+ while (undoCount > 0) {
+ appCore.undo();
+ }
+ //toolkitCore.CloseWindow(window);
+}
+
diff --git a/editor/ui/dialogs/content/EdImageProps.js b/editor/ui/dialogs/content/EdImageProps.js
index 1f10fa90803..1e4fd5e0138 100644
--- a/editor/ui/dialogs/content/EdImageProps.js
+++ b/editor/ui/dialogs/content/EdImageProps.js
@@ -1,28 +1,94 @@
+// OnOK(), Undo(), and Cancel() are in EdDialogCommon.js
+// applyChanges() must be implemented here
+
var appCore;
var toolkitCore;
var insertNew = true;
-var selectionIsCollapsed = false;
var undoCount = 0;
+var imageElement;
+var tagName = "img"
// dialog initialization code
function Startup()
{
- dump("Doing Startup...\n");
- toolkitCore = XPAppCoresManager.Find("ToolkitCore");
- if (!toolkitCore) {
- toolkitCore = new ToolkitCore();
- if (toolkitCore)
- toolkitCore.Init("ToolkitCore");
- }
- if(!toolkitCore) {
- dump("toolkitCore not found!!! And we can't close the dialog!\n");
- }
+ dump("Doing Startup...\n");
+ toolkitCore = XPAppCoresManager.Find("ToolkitCore");
+ if (!toolkitCore) {
+ toolkitCore = new ToolkitCore();
+ if (toolkitCore)
+ toolkitCore.Init("ToolkitCore");
+ }
+ if(!toolkitCore) {
+ dump("toolkitCore not found!!! And we can't close the dialog!\n");
+ }
- // NEVER create an appcore here - we must find parent editor's
- appCore = XPAppCoresManager.Find("EditorAppCoreHTML");
- if(!appCore || !toolkitCore) {
- dump("EditorAppCore not found!!!\n");
- toolkitCore.CloseWindow(window);
- }
- dump("EditorAppCore found for Image Properties dialog\n");
+ // NEVER create an appcore here - we must find parent editor's
+ appCore = XPAppCoresManager.Find("EditorAppCoreHTML");
+ if(!appCore || !toolkitCore) {
+ dump("EditorAppCore not found!!!\n");
+ toolkitCore.CloseWindow(window);
+ }
+ dump("EditorAppCore found for Image Properties dialog\n");
+
+ // Create dialog object to store controls for easy access
+ dialog = new Object;
+ // This is the "combined" widget:
+ dialog.Src = document.getElementById("image.Src");
+ // Can we get at just the edit field?
+ fileChild = dialog.Src.firstChild;
+ if (fileChild)
+ {
+ dump("*** fileInput control has a child\n");
+ } else {
+ dump("*** fileInput control has NO child\n");
+ }
+
+ dialog.AltText = document.getElementById("image.AltText");
+ if (null == dialog.Src ||
+ null == dialog.AltText )
+ {
+ dump("Not all dialog controls were found!!!\n");
+ }
+
+ initDialog();
+
+ dialog.Src.focus();
+ if (fileChild)
+ fileChild.focus();
}
+
+function initDialog() {
+ // Get a single selected anchor element
+ imageElement = appCore.getSelectedElement(tagName);
+
+ if (imageElement) {
+ // We found an element and don't need to insert one
+ insertNew = false;
+ dump("Found existing image\n");
+ } else {
+ insertNew = true;
+ // We don't have an element selected,
+ // so create one with default attributes
+ dump("Element not selected - calling createElementWithDefaults\n");
+ imageElement = appCore.createElementWithDefaults(tagName);
+ }
+
+ if(!imageElement)
+ {
+ dump("Failed to get selected element or create a new one!\n");
+ //toolkitCore.CloseWindow(window);
+ }
+}
+
+function applyChanges()
+{
+ // TODO: BE SURE Src AND AltText are completed!
+ imageElement.setAttribute("src",dialog.Src.value);
+ // We must convert to "file:///" format else image doesn't load!
+ imageElement.setAttribute("alt",dialog.AltText.value);
+ if (insertNew) {
+ dump("Src="+imageElement.getAttribute("src")+" Alt="+imageElement.getAttribute("alt")+"\n");
+ appCore.insertElement(imageElement, true)
+
+ }
+}
\ No newline at end of file
diff --git a/editor/ui/dialogs/content/EdImageProps.xul b/editor/ui/dialogs/content/EdImageProps.xul
index cc3837bca18..df968b5daf9 100644
--- a/editor/ui/dialogs/content/EdImageProps.xul
+++ b/editor/ui/dialogs/content/EdImageProps.xul
@@ -3,18 +3,22 @@
-
+
+