mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-16 07:17:21 +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:
66
core/modules/widgets/qualify.js
Normal file
66
core/modules/widgets/qualify.js
Normal 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;
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user