Fixed getSelectionAsText breakage, added loading an editor-specific CSS file and switching between it and browser (ua.css) at runtime, removed Publish button.

This commit is contained in:
cmanske%netscape.com 1999-07-16 18:04:03 +00:00
Родитель c091a95174
Коммит 01eed0d246
11 изменённых файлов: 110 добавлений и 51 удалений

Просмотреть файл

@ -207,6 +207,7 @@
<!ENTITY saveToolbarCmd.label "Save">
<!ENTITY publishToolbarCmd.label "Publish">
<!ENTITY previewToolbarCmd.label "Preview">
<!ENTITY editmodeToolbarCmd.label "Edit Mode">
<!ENTITY printToolbarCmd.label "Print">
<!ENTITY findToolbarCmd.label "Find">
<!ENTITY linkToolbarCmd.label "Link">
@ -451,6 +452,9 @@
</menu>
<separator />
<menu name="&stylesheetMenu.label;">
<menuitem name="EditorContent Sheet" onclick="EditorApplyStyleSheet('chrome://editor/content/EditorContent.css')"/>
<menuitem name="EditorContent Sheet" onclick="EditorApplyStyleSheet('resource:/res/ua.css')"/>
<separator />
<menuitem name="&stylesheetEditorOneCmd.label;" onclick="EditorApplyStyleSheet('chrome://editor/content/EditorStyles1.css')"/>
<separator />
<menuitem name="&stylesheetOldstyleCmd.label;" onclick="EditorApplyStyleSheet('http://www.w3.org/StyleSheets/Core/Oldstyle')"/>
@ -499,8 +503,8 @@
<titledbutton src="&newEditorIcon.url;" align="bottom" value="&newToolbarCmd.label;" class="popup" onclick="EditorNew()"/>
<titledbutton src="&openEditorIcon.url;" align="bottom" value="&openToolbarCmd.label;" class="popup" onclick="EditorOpen()"/>
<titledbutton id="saveButton" src="&saveIcon.url;" align="bottom" value="&saveCmd.label;" class="popup" onclick="EditorSave()"/>
<titledbutton src="&publishIcon.url;" align="bottom" value="&publishToolbarCmd.label;" class="popup"/>
<titledbutton src="&previewIcon.url;" align="bottom" value="&previewToolbarCmd.label;" class="popup"/>
<!-- Not supporting publishing (yet?) -->
<!-- <titledbutton src="&publishIcon.url;" align="bottom" value="&publishToolbarCmd.label;" class="popup"/> -->
<titledbutton src="&printIcon.url;" align="bottom" value="&printToolbarCmd.label;" class="popup"/>
<titledbutton src="&findIcon.url;" align="bottom" value="&findToolbarCmd.label;" onclick="EditorFind()"/>
<titledbutton src="&linkIcon.url;" align="bottom" value="&linkToolbarCmd.label;" onclick="EditorInsertLink()"/>
@ -509,7 +513,8 @@
<titledbutton src="&hlineIcon.url;" align="bottom" value="&hruleToolbarCmd.label;" onclick="EditorInsertHLine()"/>
<titledbutton src="&tableIcon.url;" align="bottom" value="&tableToolbarCmd.label;" onclick="EditorInsertTable()"/>
<titledbutton src="&spellingIcon.url;" align="bottom" value="&spellToolbarCmd.label;" onclick="CheckSpelling()"/>
<spring flex="100%"/>
<spring flex="100%"/>
<titledbutton id="DisplayStyleButton" src="&previewIcon.url;" align="bottom" value="&previewToolbarCmd.label;" class="popup" onclick="EditorToggleDisplayStyle()"/>
</toolbar>
<toolbar id="FormatToolbar">
<titledbutton id="ParagraphPopup" value="&paragraphToolbarMenu.label;" class="popup" align="left" popup="ParagraphMenu" popupanchor="bottomleft"/>

Просмотреть файл

@ -20,6 +20,7 @@
var toolbar;
var documentModified;
var EditorDisplayStyle = true;
function EditorStartup(editorType)
{
@ -445,6 +446,26 @@ function EditorAlign(align)
contentWindow.focus();
}
function EditorToggleDisplayStyle()
{
if (EditorDisplayStyle) {
EditorDisplayStyle = false;
styleSheet = "resource:/res/ua.css";
//TODO: Where do we store localizable JS strings?
buttonText = "Preview";
}
else {
EditorDisplayStyle = true;
styleSheet = "chrome://editor/content/EditorContent.css"
buttonText = "Edit Mode";
}
EditorApplyStyleSheet(styleSheet);
button = document.getElementById("DisplayStyleButton");
if (button)
button.setAttribute("value",buttonText);
}
function EditorPrintPreview()
{
window.openDialog("resource:/res/samples/printsetup.html", "PrintPreview", "chrome", "");

Просмотреть файл

@ -0,0 +1,23 @@
/* Styles to alter look of things in the Editor content window */
a[name] {
display: inline; /*-block;*/ /* the new feature */
min-width: 10px;
width: 10px;
height: 10px;
background-image: url(chrome://editor/skin/images/ED_Left.gif);
border: 1px solid blue;
}
table {
empty-cells: show;
}
table[empty-cells=show] {
border: 1px dotted red;
}
td, tr {
min-height: 10px;
min-line-height: 10px;
}

Просмотреть файл

@ -8,3 +8,4 @@ EditorInitPage.html
EditorInitPagePlain.html
editor.properties
EditorStyles1.css
EditorContent.css

Просмотреть файл

@ -34,6 +34,7 @@ EXPORT_RESOURCE_CONTENT = \
$(srcdir)/EditorInitPagePlain.html \
$(srcdir)/editor.properties \
$(srcdir)/EditorStyles1.css \
$(srcdir)/EditorContent.css \
$(NULL)
install::

Просмотреть файл

@ -27,6 +27,7 @@ install::
$(MAKE_INSTALL) EditorInitPagePlain.html $(DIST)\bin\chrome\editor\composer\content\default
$(MAKE_INSTALL) editor.properties $(DIST)\bin\chrome\editor\composer\content\default
$(MAKE_INSTALL) EditorStyles1.css $(DIST)\bin\chrome\editor\composer\content\default
$(MAKE_INSTALL) EditorContent.css $(DIST)\bin\chrome\editor\composer\content\default
clobber::
rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorAppShell.xul
@ -36,3 +37,4 @@ clobber::
rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorInitPagePlain.html
rm -f $(DIST)\bin\chrome\editor\composer\content\default\editor.properties
rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorStyles1.css
rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorContent.css

Просмотреть файл

@ -1,6 +1,9 @@
// Each editor window must include this file
// Variables shared by all dialogs:
var editorShell;
var SelectionOnly=1;
var FormatedWithDoctype=2;
var FormatedWithoutDoctype=6;
function InitEditorShell()
{
@ -329,3 +332,7 @@ function onCancel()
window.close();
}
function GetSelectionAsText()
{
return editorShell.GetContentsAs("text/plain", SelectionOnly);
}

Просмотреть файл

@ -105,7 +105,7 @@ function initDialog()
} else if (!insertNew && !imageElement) {
// Replace the link message with the link source string
selectedText = editorShell.selectionAsText;
selectedText = GetSelectionAsText();
if (selectedText.length > 0) {
// Use just the first 50 characters and add "..."
selectedText = TruncateStringAtWordEnd(selectedText, 50, true);
@ -143,29 +143,36 @@ function onOK()
{
// TODO: VALIDATE FIELDS BEFORE COMMITING CHANGES
// Coalesce into one undo transaction
editorShell.BeginBatchChanges();
href = TrimString(dialog.hrefInput.value);
if (href.length > 0) {
// Coalesce into one undo transaction
editorShell.BeginBatchChanges();
// Set the HREF directly on the editor document's anchor node
// or on the newly-created node if insertNew is true
anchorElement.setAttribute("href",dialog.hrefInput.value);
// Set the HREF directly on the editor document's anchor node
// or on the newly-created node if insertNew is true
anchorElement.setAttribute("href",href);
// Get text to use for a new link
if (insertNew) {
// Append the link text as the last child node
// of the anchor node
dump("Creating text node\n");
textNode = editorShell.editorDocument.createTextNode(dialog.linkTextInput.value);
if (textNode) {
anchorElement.appendChild(textNode);
// Get text to use for a new link
if (insertNew) {
// Append the link text as the last child node
// of the anchor node
dump("Creating text node\n");
textNode = editorShell.editorDocument.createTextNode(dialog.linkTextInput.value);
if (textNode) {
anchorElement.appendChild(textNode);
}
dump("Inserting\n");
editorShell.InsertElement(anchorElement, false);
} else if (insertLinkAroundSelection) {
dump("Setting link around selected text\n");
editorShell.InsertLinkAroundSelection(anchorElement);
}
dump("Inserting\n");
editorShell.InsertElement(anchorElement, false);
} else if (insertLinkAroundSelection) {
dump("Setting link around selected text\n");
editorShell.InsertLinkAroundSelection(anchorElement);
editorShell.EndBatchChanges();
} else if (!insertNew) {
// We already had a link, but empty HREF means remove it
// TODO: IMPLEMENT REMOVE LINK
}
editorShell.EndBatchChanges();
window.close();
}

Просмотреть файл

@ -48,10 +48,10 @@ function Startup()
// We must have a message
window.close();
}
title = window.arguments[2];
if (title.length > 0) {
// BUG 9722: Not implemented yet.
//document.title = title;
titleText = window.arguments[2];
if (titleText.length > 0) {
dump(titleText+" is the message dialog title\n");
window.title = titleText;
}
button1 = document.getElementById("button1");

Просмотреть файл

@ -1,18 +1,17 @@
var insertNew = true;
var tagName = "anchor"
var anchorElement = null;
var nameInput;
// dialog initialization code
function Startup()
{
if (!InitEditorShell())
return;
dump("EditoreditorShell found for NamedAnchor Properties dialog\n");
// Create dialog object to store controls for easy access
dialog = new Object;
// GET EACH CONTROL -- E.G.:
dialog.nameInput = document.getElementById("name");
dump("EditorShell found for NamedAnchor Properties dialog\n");
dump(document+"\n");
nameInput = document.getElementById("nameInput");
dump(nameInput+"\n");
// Get a single selected element of the desired type
anchorElement = editorShell.GetSelectedElement(tagName);
@ -21,7 +20,7 @@ function Startup()
// We found an element and don't need to insert one
insertNew = false;
dump("Found existing anchor\n");
dialog.nameInput.value = anchorElement.getAttribute("name");
nameInput.value = anchorElement.getAttribute("name");
} else {
insertNew = true;
// We don't have an element selected,
@ -29,12 +28,13 @@ function Startup()
dump("Element not selected - calling createElementWithDefaults\n");
anchorElement = editorShell.CreateElementWithDefaults(tagName);
// Use the current selection as suggested name
name = editorShell.selectionAsText;
name = GetSelectionAsText();
// Get 40 characters of the selected text and don't add "..."
name = TruncateStringAtWordEnd(name, 40, false);
// Replace whitespace with "_"
name = ReplaceWhitespace(name, "_");
dialog.nameInput.value = name;
dump("Selection text for name: "+name+"\n");
nameInput.value = name;
}
if(!anchorElement)
@ -43,12 +43,12 @@ function Startup()
window.close();
}
dialog.nameInput.focus();
nameInput.focus();
}
function onOK()
{
name = dialog.nameInput.value;
name = nameInput.value;
name = TrimString(name);
if (name.length == 0) {
dump("EMPTY ANCHOR STRING\n");

Просмотреть файл

@ -6,10 +6,10 @@
<!-- These entity declarations will go into a separate, locale file at some point -->
<!ENTITY windowTitle.label "Named Anchor Properties">
<!ENTITY anchorNameEditField.label "Anchor Name">
<!ENTITY anchorNameEditField.label "Anchor Name:">
<!ENTITY OKButton.label "OK">
<!ENTITY CancelButton.label "Cancel">
<!ENTITY advancedEditingButton.label "More Attributes...">
<!ENTITY moreButton.label "More Attributes...">
]>
@ -29,22 +29,14 @@
<table>
<tr>
<td>
<label class="spacedtext" for="name"> &anchorNameEditField.label; </label>
<input type="text" id="name" size="30" maxlength="255" />
<label class="spacedtext" for="nameInput"> &anchorNameEditField.label; </label><br/>
<input type="text" id="nameInput" size="30" maxlength="255" />
</td>
</tr>
</table>
<!-- A classic case of box layout fighting what I want to do!
<xul:box>
<div class="spacedtext">
Enter a name for this target:
</div>
<input type="text" id="name" size="30"/>
</xul:box>
-->
<hr width="100%"/>
<xul:box>
<xul:titledbutton class="spaced" id="Advanced" onclick="onAdvanced()" value="&advancedEditingButton.label;"/>
<xul:titledbutton class="spaced" id="MoreAttributes" onclick="onMoreAttributes()" value="&moreButton.label;"/>
<xul:spring flex="100%"/>
<xul:titledbutton class="spaced" id="OK" onclick="onOK()" value="&OKButton.label;"/>
<xul:titledbutton class="spaced" id="Cancel" onclick="onCancel()" value="&CancelButton.label;"/>