Index: jar.mn
===================================================================
RCS file: /cvsroot/mozilla/editor/jar.mn,v
retrieving revision 1.14
diff -u -r1.14 jar.mn
--- jar.mn 2001/06/13 01:04:30 1.14
+++ jar.mn 2001/10/23 10:14:21
@@ -160,6 +160,14 @@
content/editor/EdInsertTable.js (ui/dialogs/content/EdInsertTable.js)
content/editor/EdTableProps.xul (ui/dialogs/content/EdTableProps.xul)
content/editor/EdTableProps.js (ui/dialogs/content/EdTableProps.js)
+ content/editor/EdFormProps.xul (ui/dialogs/content/EdFormProps.xul)
+ content/editor/EdFormProps.js (ui/dialogs/content/EdFormProps.js)
+ content/editor/EdInputProps.xul (ui/dialogs/content/EdInputProps.xul)
+ content/editor/EdInputProps.js (ui/dialogs/content/EdInputProps.js)
+ content/editor/EdTextAreaProps.xul (ui/dialogs/content/EdTextAreaProps.xul)
+ content/editor/EdTextAreaProps.js (ui/dialogs/content/EdTextAreaProps.js)
+ content/editor/EdSelectProps.xul (ui/dialogs/content/EdSelectProps.xul)
+ content/editor/EdSelectProps.js (ui/dialogs/content/EdSelectProps.js)
content/editor/EdInsSrc.xul (ui/dialogs/content/EdInsSrc.xul)
content/editor/EdInsSrc.js (ui/dialogs/content/EdInsSrc.js)
content/editor/EdInsertChars.xul (ui/dialogs/content/EdInsertChars.xul)
@@ -216,6 +224,10 @@
locale/en-US/editor/EditorPersonalDictionary.dtd (ui/dialogs/locale/en-US/EditorPersonalDictionary.dtd)
locale/en-US/editor/EditorSpellCheck.dtd (ui/dialogs/locale/en-US/EditorSpellCheck.dtd)
locale/en-US/editor/EditorTableProperties.dtd (ui/dialogs/locale/en-US/EditorTableProperties.dtd)
+ locale/en-US/editor/EditorFormProperties.dtd (ui/dialogs/locale/en-US/EditorFormProperties.dtd)
+ locale/en-US/editor/EditorInputProperties.dtd (ui/dialogs/locale/en-US/EditorInputProperties.dtd)
+ locale/en-US/editor/EditorTextAreaProperties.dtd (ui/dialogs/locale/en-US/EditorTextAreaProperties.dtd)
+ locale/en-US/editor/EditorSelectProperties.dtd (ui/dialogs/locale/en-US/EditorSelectProperties.dtd)
locale/en-US/editor/EdNamedAnchorProperties.dtd (ui/dialogs/locale/en-US/EdNamedAnchorProperties.dtd)
locale/en-US/editor/EdDialogOverlay.dtd (ui/dialogs/locale/en-US/EdDialogOverlay.dtd)
locale/en-US/editor/EdAdvancedEdit.dtd (ui/dialogs/locale/en-US/EdAdvancedEdit.dtd)
Index: ui/dialogs/content/makefile.win
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/dialogs/content/makefile.win,v
retrieving revision 1.31
diff -u -r1.31 makefile.win
--- ui/dialogs/content/makefile.win 2001/06/13 01:04:37 1.31
+++ ui/dialogs/content/makefile.win 2001/10/23 10:14:21
@@ -42,6 +42,14 @@
.\EdInsertTable.js \
.\EdTableProps.xul \
.\EdTableProps.js \
+ .\EdFormProps.xul \
+ .\EdFormProps.js \
+ .\EdInputProps.xul \
+ .\EdInputProps.js \
+ .\EdTextAreaProps.xul \
+ .\EdTextAreaProps.js \
+ .\EdSelectProps.xul \
+ .\EdSelectProps.js \
.\EdInsSrc.xul \
.\EdInsSrc.js \
.\EdInsertChars.xul \
Index: ui/dialogs/content/MANIFEST
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/dialogs/content/MANIFEST,v
retrieving revision 1.26
diff -u -r1.26 MANIFEST
--- ui/dialogs/content/MANIFEST 2001/06/13 01:04:36 1.26
+++ ui/dialogs/content/MANIFEST 2001/10/23 10:14:21
@@ -41,6 +41,14 @@
EdInsertTable.js
EdTableProps.js
EdTableProps.xul
+EdFormProps.js
+EdFormProps.xul
+EdInputProps.js
+EdInputProps.xul
+EdTextAreaProps.js
+EdTextAreaProps.xul
+EdSelectProps.js
+EdSelectProps.xul
EdInsSrc.xul
EdInsSrc.js
EdDialogOverlay.xul
Index: ui/dialogs/content/EdDialogCommon.js
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/dialogs/content/EdDialogCommon.js,v
retrieving revision 1.107
diff -u -r1.107 EdDialogCommon.js
--- ui/dialogs/content/EdDialogCommon.js 2001/10/10 20:07:00 1.107
+++ ui/dialogs/content/EdDialogCommon.js 2001/10/23 10:14:25
@@ -1556,3 +1556,128 @@
return gOS;
}
+
+var blockIsValidParent = {
+ ADDRESS: false,
+ APPLET: true,
+ BLOCKQUOTE: true,
+ BODY: true,
+ CENTER: true,
+ DL: false,
+ DD: true,
+ DIR: false,
+ DIV: true,
+ FIELDSET: false,
+ FORM: true,
+ H1: false,
+ H2: false,
+ H3: false,
+ H4: false,
+ H5: false,
+ H6: false,
+ HR: false,
+ ISINDEX: false,
+ LI: true,
+ MENU: false,
+ OBJECT: true,
+ OL: false,
+ P: false,
+ PRE: false,
+ TABLE: false,
+ TD: true,
+ TH: true,
+ UL: false
+};
+
+function nodeDepth(node)
+{
+ for (var depth = 0; node != null; depth++)
+ node = node.parentNode;
+ return depth;
+}
+
+function nthParent(node, n)
+{
+ for (; n > 0; n--)
+ node = node.parentNode;
+ return node;
+}
+
+function InsertBlockElementAroundSelection(block)
+{
+ // We need to find a suitable container for the block.
+ // First find the common ancestor
+ var anchor = editorShell.editorSelection.anchorNode;
+ var anchorDepth = nodeDepth(anchor);
+ var focus = editorShell.editorSelection.focusNode;
+ var focusDepth = nodeDepth(focus);
+ anchor = nthParent(anchor, anchorDepth - focusDepth);
+ focus = nthParent(focus, focusDepth - anchorDepth);
+ var ordered = false;
+ var parent;
+ if (anchor == focus) {
+ parent = anchor;
+ anchor = parent.firstChild;
+ focus = parent.lastChild;
+ ordered = true;
+ } else {
+ while (anchor.parentNode != focus.parentNode) {
+ anchor = anchor.parentNode;
+ focus = focus.parentNode;
+ }
+ parent = anchor.parentNode;
+ }
+ // The common ancestor may not be suitable, so find a suitable one.
+ while (!(parent.localName in blockIsValidParent) || !blockIsValidParent[parent.localName]) {
+ anchor = parent;
+ focus = parent;
+ parent = parent.parentNode;
+ ordered = true;
+ }
+ // We now have an ancestor to hold the block
+ // and a range of child nodes to move into the block
+ if (!ordered) {
+ // Ensure anchor <= focus
+ for (var element = parent.firstChild; element != anchor; element = element.nextSibling) {
+ if (element == focus) {
+ focus = anchor;
+ anchor = element;
+ break;
+ }
+ }
+ }
+ // The range may be contained by body text, which should all be selected.
+ if (anchor && !(anchor.localName in blockIsValidParent))
+ while (anchor.previousSibling && !(anchor.previousSibling.localName in blockIsValidParent))
+ anchor = anchor.previousSibling;
+ if (focus && !(focus.localName in blockIsValidParent))
+ while (focus.nextSibling && !(focus.nextSibling.localName in blockIsValidParent))
+ focus = focus.nextSibling;
+
+ editorShell.BeginBatchChanges();
+ try {
+ var anchorOffset = 0;
+ if (anchor) {
+ element = parent.firstChild;
+ // Calculate the insertion point for the undoable InsertNode method
+ while (element != anchor) {
+ anchorOffset++;
+ element = element.nextSibling;
+ }
+ // Copy all the old child nodes to the block element
+ block.appendChild(element.cloneNode(true));
+ while (element != focus) {
+ element = element.nextSibling;
+ editorShell.editor.DeleteNode(element.previousSibling);
+ block.appendChild(element.cloneNode(true));
+ }
+ // Finish undoably deleting the old child nodes
+ editorShell.editor.DeleteNode(focus);
+ }
+ editorShell.editor.InsertNode(block, parent, anchorOffset);
+ }
+ catch (e) {
+ dump(e + "\n");
+ }
+ editorShell.EndBatchChanges();
+}
Index: ui/dialogs/content/EdImageProps.js
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/dialogs/content/EdImageProps.js,v
retrieving revision 1.85
diff -u -r1.85 EdImageProps.js
--- ui/dialogs/content/EdImageProps.js 2001/10/22 23:55:57 1.85
+++ ui/dialogs/content/EdImageProps.js 2001/10/23 10:14:26
@@ -90,15 +90,25 @@
gDialog.PreviewImage = null;
// Get a single selected image element
- var tagName = "img"
- imageElement = editorShell.GetSelectedElement(tagName);
+ var tagName = "img";
+ if ("arguments" in window && window.arguments[0]) {
+ imageElement = window.arguments[0];
+ } else {
+ // First check for
+ imageElement = editorShell.GetSelectedElement("input");
+ if (!imageElement || imageElement.getAttribute("type") != "image")
+ // Get a single selected image element
+ imageElement = editorShell.GetSelectedElement(tagName);
+ }
if (imageElement)
{
// We found an element and don't need to insert one
- gInsertNewImage = false;
- actualWidth = imageElement.naturalWidth;
- actualHeight = imageElement.naturalHeight;
+ if (imageElement.hasAttribute("src")) {
+ gInsertNewImage = false;
+ actualWidth = imageElement.naturalWidth;
+ actualHeight = imageElement.naturalHeight;
+ }
}
else
{
Index: ui/dialogs/locale/en-US/makefile.win
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/dialogs/locale/en-US/makefile.win,v
retrieving revision 1.22
diff -u -r1.22 makefile.win
--- ui/dialogs/locale/en-US/makefile.win 2001/10/02 23:58:21 1.22
+++ ui/dialogs/locale/en-US/makefile.win 2001/10/23 10:14:27
@@ -37,6 +37,10 @@
.\EditorPersonalDictionary.dtd \
.\EditorSpellCheck.dtd \
.\EditorTableProperties.dtd \
+ .\EditorFormProperties.dtd \
+ .\EditorInputProperties.dtd \
+ .\EditorTextAreaProperties.dtd \
+ .\EditorSelectProperties.dtd \
.\EdNamedAnchorProperties.dtd \
.\EdDialogOverlay.dtd \
.\EdAdvancedEdit.dtd \
Index: ui/dialogs/locale/en-US/MANIFEST
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/dialogs/locale/en-US/MANIFEST,v
retrieving revision 1.16
diff -u -r1.16 MANIFEST
--- ui/dialogs/locale/en-US/MANIFEST 2001/05/09 05:23:37 1.16
+++ ui/dialogs/locale/en-US/MANIFEST 2001/10/23 10:14:27
@@ -35,6 +35,10 @@
EditorPersonalDictionary.dtd
EditorSpellCheck.dtd
EditorTableProperties.dtd
+EditorFormProperties.dtd
+EditorInputProperties.dtd
+EditorTextAreaProperties.dtd
+EditorSelectProperties.dtd
EdNamedAnchorProperties.dtd
EdDialogOverlay.dtd
EdAdvancedEdit.dtd
Index: ui/composer/content/ComposerCommands.js
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/composer/content/ComposerCommands.js,v
retrieving revision 1.75
diff -u -r1.75 ComposerCommands.js
--- ui/composer/content/ComposerCommands.js 2001/10/13 02:27:25 1.75
+++ ui/composer/content/ComposerCommands.js 2001/10/23 10:14:31
@@ -63,6 +63,14 @@
controller.registerCommand("cmd_objectProperties", nsObjectPropertiesCommand);
controller.registerCommand("cmd_removeLinks", nsRemoveLinksCommand);
+ controller.registerCommand("cmd_form", nsFormCommand);
+ controller.registerCommand("cmd_inputtag", nsInputTagCommand);
+ controller.registerCommand("cmd_textarea", nsTextAreaCommand);
+ controller.registerCommand("cmd_select", nsSelectCommand);
+ controller.registerCommand("cmd_button", nsButtonCommand);
+ controller.registerCommand("cmd_label", nsLabelCommand);
+ controller.registerCommand("cmd_fieldset", nsFieldSetCommand);
+ controller.registerCommand("cmd_isindex", nsIsIndexCommand);
controller.registerCommand("cmd_image", nsImageCommand);
controller.registerCommand("cmd_hline", nsHLineCommand);
controller.registerCommand("cmd_link", nsLinkCommand);
@@ -845,6 +853,128 @@
};
//-----------------------------------------------------------------------------------
+var nsFormCommand =
+{
+ isCommandEnabled: function(aCommand, dummy)
+ {
+ return (window.editorShell && window.editorShell.documentEditable && IsEditingRenderedHTML());
+ },
+ doCommand: function(aCommand)
+ {
+ window.openDialog("chrome://editor/content/EdFormProps.xul", "_blank", "chrome,close,titlebar,modal", "");
+ window._content.focus();
+ }
+};
+
+//-----------------------------------------------------------------------------------
+var nsInputTagCommand =
+{
+ isCommandEnabled: function(aCommand, dummy)
+ {
+ return (window.editorShell && window.editorShell.documentEditable && IsEditingRenderedHTML());
+ },
+ doCommand: function(aCommand)
+ {
+ window.openDialog("chrome://editor/content/EdInputProps.xul", "_blank", "chrome,close,titlebar,modal", "");
+ window._content.focus();
+ }
+};
+
+//-----------------------------------------------------------------------------------
+var nsTextAreaCommand =
+{
+ isCommandEnabled: function(aCommand, dummy)
+ {
+ return (window.editorShell && window.editorShell.documentEditable && IsEditingRenderedHTML());
+ },
+ doCommand: function(aCommand)
+ {
+ window.openDialog("chrome://editor/content/EdTextAreaProps.xul", "_blank", "chrome,close,titlebar,modal", "");
+ window._content.focus();
+ }
+};
+
+//-----------------------------------------------------------------------------------
+var nsSelectCommand =
+{
+ isCommandEnabled: function(aCommand, dummy)
+ {
+ return (window.editorShell && window.editorShell.documentEditable && IsEditingRenderedHTML());
+ },
+ doCommand: function(aCommand)
+ {
+ window.openDialog("chrome://editor/content/EdSelectProps.xul", "_blank", "chrome,close,titlebar,modal", "");
+ window._content.focus();
+ }
+};
+
+//-----------------------------------------------------------------------------------
+var nsButtonCommand =
+{
+ isCommandEnabled: function(aCommand, dummy)
+ {
+ return (window.editorShell && window.editorShell.documentEditable && IsEditingRenderedHTML());
+ },
+ doCommand: function(aCommand)
+ {
+ dump('Doing button command\n');
+ try {
+ var buttonElement = editorShell.CreateElementWithDefaults("button");
+ buttonElement.innerHTML = editorShell.GetContentsAs("text/html", gOutputSelectionOnly);
+ editorShell.InsertElementAtSelection(buttonElement, true);
+ } catch (e) {
+ dump(e);
+ }
+ dump('Done button command\n');
+ }
+};
+
+//-----------------------------------------------------------------------------------
+var nsLabelCommand =
+{
+ isCommandEnabled: function(aCommand, dummy)
+ {
+ return (window.editorShell && window.editorShell.documentEditable && IsEditingRenderedHTML());
+ },
+ doCommand: function(aCommand)
+ {
+ var labelElement = editorShell.CreateElementWithDefaults("label");
+ labelElement.innerHTML = editorShell.GetContentsAs("text/html", gOutputSelectionOnly);
+ editorShell.InsertElementAtSelection(labelElement, true);
+ }
+};
+
+//-----------------------------------------------------------------------------------
+var nsFieldSetCommand =
+{
+ isCommandEnabled: function(aCommand, dummy)
+ {
+ return (window.editorShell && window.editorShell.documentEditable && IsEditingRenderedHTML());
+ },
+ doCommand: function(aCommand)
+ {
+ var fieldsetElement = editorShell.CreateElementWithDefaults("fieldset");
+ fieldsetElement.innerHTML = editorShell.GetContentsAs("text/html", gOutputSelectionOnly);
+ editorShell.InsertElementAtSelection(fieldsetElement, true);
+ }
+};
+
+//-----------------------------------------------------------------------------------
+var nsIsIndexCommand =
+{
+ isCommandEnabled: function(aCommand, dummy)
+ {
+ return (window.editorShell && window.editorShell.documentEditable && IsEditingRenderedHTML());
+ },
+ doCommand: function(aCommand)
+ {
+ var isindexElement = editorShell.CreateElementWithDefaults("isindex");
+ isindexElement.setAttribute("prompt", editorShell.GetContentsAs("text/plain", gOutputSelectionOnly));
+ editorShell.InsertElementAtSelection(isindexElement, true);
+ }
+};
+
+//-----------------------------------------------------------------------------------
var nsImageCommand =
{
isCommandEnabled: function(aCommand, dummy)
@@ -1063,6 +1193,15 @@
break;
case 'hr':
goDoCommand("cmd_hline");
+ break;
+ case 'input':
+ goDoCommand("cmd_inputtag");
+ break;
+ case 'textarea':
+ goDoCommand("cmd_textarea");
+ break;
+ case 'select':
+ goDoCommand("cmd_select");
break;
case 'table':
EditorInsertOrEditTable(false);
Index: ui/composer/content/editor.js
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/composer/content/editor.js,v
retrieving revision 1.122
diff -u -r1.122 editor.js
--- ui/composer/content/editor.js 2001/10/21 03:59:15 1.122
+++ ui/composer/content/editor.js 2001/10/23 10:14:39
@@ -1648,6 +1648,15 @@
case "li":
objStr = GetString("ListItem");
break;
+ case "input":
+ objStr = GetString("Input");
+ break;
+ case "textarea":
+ objStr = GetString("TextArea");
+ break;
+ case "select":
+ objStr = GetString("Select");
+ break;
case "a":
if (element.name)
{
@@ -2128,6 +2137,7 @@
HideItem("insertHline");
HideItem("insertTable");
HideItem("insertHTML");
+ HideItem("insertFormMenu");
HideItem("fileExportToText");
HideItem("viewFormatToolbar");
HideItem("viewEditModeToolbar");
Index: ui/composer/content/editorOverlay.xul
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/composer/content/editorOverlay.xul,v
retrieving revision 1.188
diff -u -r1.188 editorOverlay.xul
--- ui/composer/content/editorOverlay.xul 2001/10/19 14:12:48 1.188
+++ ui/composer/content/editorOverlay.xul 2001/10/23 10:14:46
@@ -104,6 +104,14 @@