mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-28 20:12:41 +00:00
![Jeremy Ruston](/assets/img/avatar_default.png)
This arrangement takes better advantage of the similarities between the now deleted widget renderer and the element renderer. It also obviates the need for wrapper elements around every widget.
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.renderContext,[node]);
|
|
};
|
|
|
|
exports.wikified = WikifiedViewer;
|
|
|
|
})();
|