Closed Bug 170050 Opened 22 years ago Closed 22 years ago

[RFE] Insert Table of Contents

Categories

(SeaMonkey :: Composer, enhancement, P5)

enhancement

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.3alpha

People

(Reporter: imran.geriskovan, Assigned: glazou)

Details

(Whiteboard: fix i n hand, needs r=, needs sr=)

Attachments

(2 files, 2 obsolete files)

"Insert Table of Contents" menu item is needed in composer.

Composer may construct a set of links for headings found in the document.
No dupe found

==> NEW
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Insert Table of Contents → [RFE] Insert Table of Contents
Severity: normal → enhancement
Easy :-) Install the Extensions PlaceHolder XPI for Composer first, and then
TOCMaker 1.0 XPI from , both available from
http://cascades.mozdev.org/installation.html

Enjoy :-)

getting
Assignee: syd → glazman
Status: NEW → ASSIGNED
Priority: -- → P5
Whiteboard: fix i n hand, needs r=, needs sr=
Target Milestone: --- → mozilla1.3alpha
Glazman: I editing www.mozilla.org and had some JS errors when using the dialog.
Charley, I don't see any error on the JS console ; I am using a very recent
build and the latest patch.
Attachment #104753 - Attachment is obsolete: true
Comment on attachment 106900 [details] [diff] [review]
new patch to resolve recent conflicts

Charley, can you re-review please ?
Attachment #106900 - Flags: review?(cmanske)
Comment on attachment 106900 [details] [diff] [review]
new patch to resolve recent conflicts

very cool feature!
Attachment #106900 - Flags: review?(cmanske) → review+
Comment on attachment 106900 [details] [diff] [review]
new patch to resolve recent conflicts

Peterv: do you think you can sr it before monday ? Tree closes next week and
we'd really like this to go in before the closure. Thanks!
Attachment #106900 - Flags: superreview?(peterv)
Comment on attachment 106900 [details] [diff] [review]
new patch to resolve recent conflicts

I'll attach the patch with my comments in them.
Attachment #106900 - Flags: superreview?(peterv) → superreview-
Comment on attachment 107873 [details] [diff] [review]
Comments on the patch

>>+  // we need an array to store all TOC entries we find in the document
>>+  var tocArray = new Array();
>
>Can't you do everything in one pass, instead of filling an array and
>then looping over the items in the array?

I want to avoid that because the TOC can be inserted in the middle
of an element that has to be listed in the TOC. In that case, the
insertion of the TOC splits the element in two but only one TOC
entry should be generated.
The TOC can also count the list items in the document (although it's
an edge case) and since it inserts LI... I could tweak the filter
but is it really worth the case?

>>+  var nodeList = theDocument.documentElement.getElementsByTagName("a");
>>+  for (var j = nodeList.length-1; j >= 0; --j) {
>>+    var anchor = nodeList.item(j);
>>+    if (anchor.nodeName.toLowerCase() == "a"
>>+        && anchor.hasAttribute("name")
>>+        && anchor.hasAttribute("class")
>>+        && anchor.getAttribute("class").substr(0, 6) == "mozToc") {
>>+      anchor.parentNode.removeChild(anchor);
>>+    }
>
>A tree walker would be nice here

Why not. Btw, the test
|anchor.nodeName.toLowerCase() == "a"| is redundant with
the call to |getElementsByTagName()| above...
Attachment #106900 - Attachment is obsolete: true
Comment on attachment 107896 [details] [diff] [review]
In answer to peterv's review.

+function BuildTOC(update)
+{

+      var classArray = node.getAttribute("class").split(" ");
+      for (var j = 0; j < classArray.length; j++) {

++j

+      var commentText = "mozToc ";
+      for (var j = 0; j < 6; j++) {

++j

Index: ui/composer/content/editorOverlay.xul
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/composer/content/editorOverlay.xul,v
retrieving revision 1.220
diff -u -r1.220 editorOverlay.xul
--- ui/composer/content/editorOverlay.xul	12 Nov 2002 22:52:54 -0000     
1.220
+++ ui/composer/content/editorOverlay.xul	2 Dec 2002 13:02:28 -0000
@@ -305,6 +305,9 @@
	   <menuitem id="menu_newBlankPage" label="&newBlankPageCmd.label;" 
		     accesskey="&newBlankPage.accesskey;"
key="key_newBlankPage"
		     command="cmd_newEditor"/>
+	   <menuitem id="XXXXmenu_newEditorTemplate"
+		     label="New from template"
+		     oncommand="NewEditorFromTemplate()"/>

Undo this change.
With the lengths of the consts as const, sr=peterv.
Attachment #107896 - Flags: superreview+
Checked in (trunk). Ô joy, ô happiness.
Thanks to peterv for fast reviews.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: