mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-28 20:12:41 +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
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
/*\
|
|
title: $:/core/modules/widgets/view/viewers/wikified.js
|
|
type: application/javascript
|
|
module-type: fieldviewer
|
|
|
|
A viewer for viewing tiddler fields as wikified text
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
var WikifiedViewer = function(viewWidget,tiddler,field,value) {
|
|
this.viewWidget = viewWidget;
|
|
this.tiddler = tiddler;
|
|
this.field = field;
|
|
this.value = value;
|
|
};
|
|
|
|
WikifiedViewer.prototype.render = function() {
|
|
// Set the element details
|
|
this.viewWidget.tag = this.viewWidget.renderer.parseTreeNode.isBlock ? "div" : "span";
|
|
this.viewWidget.attributes = {};
|
|
var node = {
|
|
type: "element",
|
|
tag: "$transclude",
|
|
attributes: {
|
|
"class": "tw-view-wikified",
|
|
field: {type: "string", value: this.field}
|
|
},
|
|
isBlock: this.viewWidget.renderer.parseTreeNode.isBlock
|
|
};
|
|
if(this.tiddler && this.tiddler.fields.title) {
|
|
node.attributes.target = {type: "string", value: this.tiddler.fields.title}
|
|
}
|
|
this.viewWidget.children = this.viewWidget.renderer.renderTree.createRenderers(this.viewWidget.renderer,[node]);
|
|
};
|
|
|
|
exports.wikified = WikifiedViewer;
|
|
|
|
})();
|