Hi Eric,

Below is a proposed proof-of-concept snippet for EditSectionPlugin, to put 
the edit section button in a separate div outside the heading, so not to be 
covered by the fold heading onclick event:
----
// // EDIT SECTIONS MACRO
//{{{
config.macros.editSections = {
    label: 'edit...',
    tip: 'edit this section',
    command: '~~<<editSection [[##%0]] "%1" "%2">>~~',
    //GJRobert Ciang: insertAfter function from 
http://snipplr.com/view/2107/insertafter-function-for-the-dom/
    insertAfter: function (newElement,targetElement) {
        //target is what you want it to go after. Look for this elements 
parent.
        var parent = targetElement.parentNode;

        //if the parents lastchild is the targetElement...
        if(parent.lastchild == targetElement) {
            //add the newElement after the target element.
            parent.appendChild(newElement);
            } else {
            // else the target has siblings, insert the new element between 
the target and it's next sibling.
            parent.insertBefore(newElement, targetElement.nextSibling);
            }
    },
    handler: function(place,macroName,params,wikifier,paramString,tiddler) {
        if (readOnly) return;
        var elems=place.parentNode.getElementsByTagName("*");
        for (var i=0; i<elems.length; i++) { var e=elems[i]; // for each 
heading element
            if (!['H1','H2','H3','H4','H5'].contains(e.nodeName)) continue;
            var section=e.textContent;
            var label=(params[0]||this.label).format([section]);
            var tip  =(params[1]||this.tip  ).format([section]);
            var btn = document.createElement("div"); //Added by GJRobert 
Ciang
            btn.setAttribute("class","editSectionBtn"); //Added by GJRobert 
Ciang
            this.insertAfter(btn,e); //Added by GJRobert Ciang
//            e.parentNode.insertBefore(btn,e); //Added by GJRobert Ciang
            wikify(this.command.format([section,label,tip]),btn); 
//Modified by GJRobert Ciang, using a separate "btn" as the container 
instead of "e" (the heading element)
        }        
    }
}

//G.J.Robert Ciang
setStylesheet (
".editSectionBtn {float: right;}\n"+
"\n","editSectionButtonStyles");
//}}}
----
Right now I can only insert the button after the heading element, and make 
it float to right. When I wanted to insert them before the headings, TW 
would hang. Perhaps the buttons draw the content of the element right after 
it so there would be indefinite loops (I'm not sure).

The snippet above can make <<editSection>> and <<foldHeadings>> 
announcements both effective in tiddler contents. But one limitation: if we 
put editSection macro in ViewTemplate directly to affect *every* tiddler by 
default, the title of the headings would be appended with the "fold" texts, 
and also the content of sections would be hidden.

Again, this is very immature and ugly so feel free to treat it in any way.

Cheers,
G.J.Robert Ciang

G.J.Robert於 2012年10月22日星期一UTC+8上午11時27分50秒寫道:
>
> Can we change either
>
>    - FoldHeadingsPlugin, to allow configuration whether to make the whole 
>    heading element or just the "show/hide" button clickable/expandable
>
> or
>
>    - EditSectionPlugin, to make the edit button a separate element 
>    outside the heading so to avoid being covered by the FoldHeadings onclick 
>    event?
>
> I found the workarounds not so feasible for me because I may have a lot of 
> headings in a tiddler, and a TOC with edit buttons may be too cumbersome.
>
> Any help? Thanks a lot!
>
> Craig in Calgary於 2012年4月13日星期五UTC+8上午7時17分26秒寫道:
>>
>> Is there any way to implement both plugins simultaneously? Right now the 
>> <<foldHeadings>> clickable region covers the <<editSections>> "edit..." 
>> button. The "edit..." button is visible but selecting it only fires the 
>> <<foldHeadings>> event. As opposed the the "edit..." link being immediately 
>> to the right of the heading text, could it be moved to the right of 
>> "more..." label or to the left of the heading text (with a negative 
>> margin-left)? Maybe a hack involving embedding in a table could be made to 
>> work but that certainly wouldn't be elegant. Suggestions? Thanks.
>>
>

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


Reply via email to