mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-27 19:42:50 +00:00
![Jeremy Ruston](/assets/img/avatar_default.png)
Get rid of the separate renderContext stack and instead have a parent pointer on renderer nodes. This lets us walk back up the render tree to resolve context references
45 lines
1019 B
JavaScript
45 lines
1019 B
JavaScript
/*\
|
|
title: $:/core/modules/widgets/view/viewers/link.js
|
|
type: application/javascript
|
|
module-type: fieldviewer
|
|
|
|
A viewer for viewing tiddler fields as a link
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
var LinkViewer = function(viewWidget,tiddler,field,value) {
|
|
this.viewWidget = viewWidget;
|
|
this.tiddler = tiddler;
|
|
this.field = field;
|
|
this.value = value;
|
|
};
|
|
|
|
LinkViewer.prototype.render = function() {
|
|
var text = this.value === undefined ? "" : this.value;
|
|
// Indicate that we're not generating an element
|
|
this.viewWidget.tag = this.viewWidget.renderer.parseTreeNode.isBlock ? "div" : "span";
|
|
this.viewWidget.attributes = {
|
|
"class": "tw-view-link"
|
|
};
|
|
this.viewWidget.children = this.viewWidget.renderer.renderTree.createRenderers(this.viewWidget.renderer,[{
|
|
type: "element",
|
|
tag: "$link",
|
|
attributes: {
|
|
to: {type: "string", value: text}
|
|
},
|
|
children: [{
|
|
type: "text",
|
|
text: text
|
|
}]
|
|
}]);
|
|
};
|
|
|
|
exports.link = LinkViewer;
|
|
|
|
})();
|