[RFE] Insert Table of Contents

RESOLVED FIXED in mozilla1.3alpha


17 years ago
15 years ago


(Reporter: imran.geriskovan, Assigned: glazou)



Firefox Tracking Flags

(Not tracked)


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


(2 attachments, 2 obsolete attachments)



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

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

Comment 1

17 years ago
No dupe found

==> NEW
Ever confirmed: true
Summary: Insert Table of Contents → [RFE] Insert Table of Contents
Severity: normal → enhancement

Comment 2

17 years ago
Easy :-) Install the Extensions PlaceHolder XPI for Composer first, and then
TOCMaker 1.0 XPI from , both available from

Enjoy :-)


Comment 3

17 years ago
Assignee: syd → glazman

Comment 4

17 years ago
Posted patch patch #1 (obsolete) — Splinter Review


17 years ago
Priority: -- → P5
Whiteboard: fix i n hand, needs r=, needs sr=
Target Milestone: --- → mozilla1.3alpha

Comment 5

17 years ago
Glazman: I editing www.mozilla.org and had some JS errors when using the dialog.

Comment 6

17 years ago
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 7

17 years ago
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 8

17 years ago
Comment on attachment 106900 [details] [diff] [review]
new patch to resolve recent conflicts

very cool feature!
Attachment #106900 - Flags: review?(cmanske) → review+

Comment 9

17 years ago
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 12

17 years ago
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...


17 years ago
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++) {


+      var commentText = "mozToc ";
+      for (var j = 0; j < 6; 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     
+++ ui/composer/content/editorOverlay.xul	2 Dec 2002 13:02:28 -0000
@@ -305,6 +305,9 @@
	   <menuitem id="menu_newBlankPage" label="&newBlankPageCmd.label;" 
+	   <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+

Comment 15

17 years ago
Checked in (trunk). Ô joy, ô happiness.
Thanks to peterv for fast reviews.
Last Resolved: 17 years ago
Resolution: --- → FIXED
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.