Hi TwWizards

> I'd love to see a combination which would allow showing and editing
> tiddler sections - without needing to "hardcode" EditSection
> macrocalls to already existing sections in a tiddler...

In SectionLinksPlugin there's a section for the SectionTOC macro. (Imo
It's the better choice for a TOC, even if it *has* to be embedded into
the tiddler - I've overcome this problem by using MoveablepanelPlugin
and successfully moved the TOC out of the tiddler*)
I copied it (the section) to a tiddler tagged with "systemConfig" and
put in the editSection macrocall:
[[zzSectionTOCoptions]]
//{{{
config.macros.sectionTOC = {
        targetClass: 'sectionTOC',
        handler:
function(place,macroName,params,wikifier,paramString,tiddler) {
                var out=[];
                var targetClass=params[0]||this.targetClass;
                var t=story.findContainingTiddler(place); if (!t) return;
                var elems=t.getElementsByTagName('*');
                var level=5; // topmost heading level
                for (var i=0; i<elems.length; i++) {
                        var txt=getPlainText(elems[i]).trim();
                        var link='[['+txt+'|##'+txt+']] <<editSection 
[[##'+txt+']]
[[✏]]>>';
                        switch(elems[i].nodeName) {
                                case 'H1': out.push('#'+link);          
level=1; break;
                                case 'H2': out.push('##'+link);         
level=level<2?level:2; break;
                                case 'H3': out.push('###'+link);        
level=level<3?level:3; break;
                                case 'H4': out.push('####'+link);       
level=level<4?level:4; break;
                                case 'H5': out.push('#####'+link);      
level=level<5?level:5; break;
                                default: if (hasClass(elems[i],targetClass)) 
var target=elems[i];
                        }
                }
                // trim excess bullet levels
                if (level>1) for (var i=0; i<out.length; i++)
out[i]=out[i].substr(level-1);
                // show numbered list
                if (out.length && target) {
                        if (target.style.display=='none') 
target.style.display='block';
                        wikify(out.join('\n'),target);
                }
        }
}
//}}}

I guess this is the correct/simplest way to alter a plugins behaviour,
without touching the plugin itself...??

*Example: 
http://puppy.tiddlyspace.gir.dk/#%5B%5BHvalpen%20har%20et%20helt%20kuld%5D%5D


Cheers Måns Mårtensson

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.

Reply via email to