Widget Attribute is Not Wikified

42 views
Skip to first unread message

Thomas Elmiger

unread,
Oct 3, 2018, 3:54:35 PM10/3/18
to TiddlyWikiDev
Hello TW Developers,

My first attempt to develop a widget led me to a problem I am not able to solve myself. The Details widget should produce a standard HTML5 disclosure element:

    <details>
       
<summary>This sums it up</summary>
        All the details follow here.
   
</details>

In TW the suggested syntax is

<$details summary="Open here!">

!! This is the revealed content
And this is some text

</$details>

So far this works great – but: The attribute summary is always rendered as text only, even if the input contains wikitext or tags like
summary="<em>This</em> sums it up"

In the widget's JS code the summary is evaluated from different input possibilities and appended to the parent DOM node detailsDomNode like this:

    if(this.detailsSummary !== "") {
       
this.summaryDomNode = this.document.createElement("summary");
       
this.detailsDomNode.appendChild(this.summaryDomNode);
       
this.summaryDomNode.appendChild(this.document.createTextNode(this.detailsSummary));
   
}

Finally everything should be rendered, I had hoped including the summary which is a child of details:

    // Insert the details into the DOM and render any children
   
this.parentDomNode.insertBefore(this.detailsDomNode,nextSibling);
   
this.renderChildren(this.detailsDomNode,null);
   
this.domNodes.push(this.detailsDomNode);

The only difference I can spot between details and summary is: details content can/must be surrounded by newlines to trigger wikitext rendering (wikification).

Is there a trick I can use to force TW to render the summary attribute as wikitext (wikify*)?

The whole plugin is at https://tid.li/tw5/plugins.html#DetailsWidget a summary that should result in HTML tags is included in one of the last examples on fhttps://tid.li/tw5/plugins.html#Details%20Advanced%20Examples
''Local'' summary <b>wins</b>

I would be greatful for any hints.

Cheers,
Thomas

* In macros I have successfully used my own wikify function to transform parameter input – but it seems not to work in the widget:

/*
Wikify
*/

function wikifyText(t) {
   
var Parser = $tw.wiki.parseText("text/vnd.tiddlywiki",t,{
            parseAsInline
: true
       
});
   
var WidgetNode = $tw.wiki.makeWidget(Parser,{
            document
: $tw.fakeDocument
       
});
   
var Container = $tw.fakeDocument.createElement("div");
   
WidgetNode.render(Container,null);
   
return Container.textContent;
}


Reply all
Reply to author
Forward
0 new messages