Last Comment Bug 170050 - [RFE] Insert Table of Contents
: [RFE] Insert Table of Contents
Status: RESOLVED FIXED
fix i n hand, needs r=, needs sr=
:
Product: SeaMonkey
Classification: Client Software
Component: Composer (show other bugs)
: Trunk
: All All
P5 enhancement (vote)
: mozilla1.3alpha
Assigned To: Daniel Glazman (:glazou)
: sujay
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2002-09-21 03:29 PDT by imran.geriskovan
Modified: 2004-11-22 17:25 PST (History)
4 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
patch #1 (38.09 KB, patch)
2002-10-31 07:17 PST, Daniel Glazman (:glazou)
no flags Details | Diff | Splinter Review
new patch to resolve recent conflicts (38.12 KB, patch)
2002-11-20 00:44 PST, Daniel Glazman (:glazou)
cmanske: review+
peterv: superreview-
Details | Diff | Splinter Review
Comments on the patch (40.25 KB, patch)
2002-12-01 15:21 PST, Peter Van der Beken [:peterv]
no flags Details | Diff | Splinter Review
In answer to peterv's review. (39.25 KB, patch)
2002-12-02 05:03 PST, Daniel Glazman (:glazou)
peterv: superreview+
Details | Diff | Splinter Review

Description User image imran.geriskovan 2002-09-21 03:29:09 PDT
"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 User image Wesha 2002-09-21 13:20:10 PDT
No dupe found

==> NEW
Comment 2 User image Daniel Glazman (:glazou) 2002-10-08 13:40:28 PDT
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 :-)

Comment 3 User image Daniel Glazman (:glazou) 2002-10-31 07:12:54 PST
getting
Comment 4 User image Daniel Glazman (:glazou) 2002-10-31 07:17:33 PST
Created attachment 104753 [details] [diff] [review]
patch #1
Comment 5 User image Charles Manske 2002-11-18 15:42:51 PST
Glazman: I editing www.mozilla.org and had some JS errors when using the dialog.
Comment 6 User image Daniel Glazman (:glazou) 2002-11-20 00:44:29 PST
Created attachment 106900 [details] [diff] [review]
new patch to resolve recent conflicts

Charley, I don't see any error on the JS console ; I am using a very recent
build and the latest patch.
Comment 7 User image Daniel Glazman (:glazou) 2002-11-20 02:24:01 PST
Comment on attachment 106900 [details] [diff] [review]
new patch to resolve recent conflicts

Charley, can you re-review please ?
Comment 8 User image Charles Manske 2002-11-27 11:07:06 PST
Comment on attachment 106900 [details] [diff] [review]
new patch to resolve recent conflicts

very cool feature!
Comment 9 User image Daniel Glazman (:glazou) 2002-11-27 12:06:57 PST
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!
Comment 10 User image Peter Van der Beken [:peterv] 2002-12-01 15:19:14 PST
Comment on attachment 106900 [details] [diff] [review]
new patch to resolve recent conflicts

I'll attach the patch with my comments in them.
Comment 11 User image Peter Van der Beken [:peterv] 2002-12-01 15:21:48 PST
Created attachment 107873 [details] [diff] [review]
Comments on the patch
Comment 12 User image Daniel Glazman (:glazou) 2002-12-02 03:04:02 PST
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...
Comment 13 User image Daniel Glazman (:glazou) 2002-12-02 05:03:13 PST
Created attachment 107896 [details] [diff] [review]
In answer to peterv's review.
Comment 14 User image Peter Van der Beken [:peterv] 2002-12-02 05:25:45 PST
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.
Comment 15 User image Daniel Glazman (:glazou) 2002-12-02 05:55:33 PST
Checked in (trunk). Ô joy, ô happiness.
Thanks to peterv for fast reviews.

Note You need to log in before you can comment on or make changes to this bug.