1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Avoid wikify widget in TOC macro

Fixing the most egregious problem from #3517

@pmario can you kindly retest?
This commit is contained in:
Jermolene 2018-11-06 15:29:13 +00:00
parent b584295831
commit 698224556e
2 changed files with 74 additions and 16 deletions

View File

@ -0,0 +1,66 @@
/*\
title: $:/core/modules/widgets/qualify.js
type: application/javascript
module-type: widget
Qualify text to a variable
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Widget = require("$:/core/modules/widgets/widget.js").widget;
var QualifyWidget = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options);
};
/*
Inherit from the base widget class
*/
QualifyWidget.prototype = new Widget();
/*
Render this widget into the DOM
*/
QualifyWidget.prototype.render = function(parent,nextSibling) {
this.parentDomNode = parent;
this.computeAttributes();
this.execute();
this.renderChildren(parent,nextSibling);
};
/*
Compute the internal state of the widget
*/
QualifyWidget.prototype.execute = function() {
// Get our parameters
this.qualifyName = this.getAttribute("name");
this.qualifyText = this.getAttribute("text");
// Set context variable
if(this.qualifyName) {
this.setVariable(this.qualifyName,this.qualifyText + "-" + this.getStateQualifier());
}
// Construct the child widgets
this.makeChildWidgets();
};
/*
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
*/
QualifyWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes.name || changedAttributes.text) {
this.refreshSelf();
return true;
} else {
return this.refreshChildren(changedTiddlers);
}
};
exports.qualify = QualifyWidget;
})();

View File

@ -32,9 +32,7 @@ tags: $:/tags/Macro
\define toc-linked-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
<!-- helper function -->
<$wikify name="toc-state" text="""
<$macrocall $name="qualify" title={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}} />
""">
<$qualify name="toc-state" text={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}}>
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item" value="toc-item-selected">
<li class=<<toc-item-class>>>
<$link>
@ -55,14 +53,12 @@ tags: $:/tags/Macro
</$reveal>
</li>
</$set>
</$wikify>
</$qualify>
\end
\define toc-unlinked-expandable-body(tag,sort:"",itemClassFilter:" ",exclude,path)
<!-- helper function -->
<$wikify name="toc-state" text="""
<$macrocall $name="qualify" title={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}} />
""">
<$qualify name="toc-state" text={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}}>
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item" value="toc-item-selected">
<li class=<<toc-item-class>>>
<$reveal type="nomatch" state=<<toc-state>> text="open">
@ -82,7 +78,7 @@ tags: $:/tags/Macro
</$reveal>
</li>
</$set>
</$wikify>
</$qualify>
\end
\define toc-expandable-empty-message()
@ -102,9 +98,7 @@ tags: $:/tags/Macro
\end
\define toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter:" ",exclude,path)
<$wikify name="toc-state" text="""
<$macrocall $name="qualify" title={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}} />
""">
<$qualify name="toc-state" text={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}}>
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item" value="toc-item-selected" >
<li class=<<toc-item-class>>>
<$link>
@ -127,13 +121,11 @@ tags: $:/tags/Macro
</$reveal>
</li>
</$set>
</$wikify>
</$qualify>
\end
\define toc-unlinked-selective-expandable-body(tag,sort:"",itemClassFilter:" ",exclude,path)
<$wikify name="toc-state" text="""
<$macrocall $name="qualify" title={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}} />
""">
<$qualify name="toc-state" text={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}}>
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item" value="toc-item-selected">
<li class=<<toc-item-class>>>
<$list filter="[all[current]tagging[]limit[1]]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button> <$view field='caption'><$view field='title'/></$view>">
@ -155,7 +147,7 @@ tags: $:/tags/Macro
</$reveal>
</li>
</$set>
</$wikify>
</$qualify>
\end
\define toc-selective-expandable-empty-message()