mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-29 04:26:44 +00:00
Some new viewers we'll need for cooking TiddlyWiki files
This is all part of getting the new parser able to cook TiddlyWiki files
This commit is contained in:
39
core/modules/widgets/view/viewers/htmlwikified.js
Normal file
39
core/modules/widgets/view/viewers/htmlwikified.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/*\
|
||||
title: $:/core/modules/widgets/view/viewers/htmlwikified.js
|
||||
type: application/javascript
|
||||
module-type: newfieldviewer
|
||||
|
||||
A viewer for viewing tiddler fields as a textual HTML representation of the wikified text
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
var HtmlWikifiedViewer = function(viewWidget,tiddler,field,value) {
|
||||
this.viewWidget = viewWidget;
|
||||
this.tiddler = tiddler;
|
||||
this.field = field;
|
||||
this.value = value;
|
||||
};
|
||||
|
||||
HtmlWikifiedViewer.prototype.render = function() {
|
||||
// Parse the field text
|
||||
var text = this.viewWidget.renderer.renderTree.wiki.new_renderText("text/html","text/vnd.tiddlywiki",this.value);
|
||||
// Create a node containing the HTML representation of the field
|
||||
var node = {
|
||||
type: "element",
|
||||
tag: "pre",
|
||||
children: [{
|
||||
type: "text",
|
||||
text: text
|
||||
}]
|
||||
};
|
||||
return this.viewWidget.renderer.renderTree.createRenderers(this.viewWidget.renderer.renderContext,[node]);
|
||||
};
|
||||
|
||||
exports.htmlwikified = HtmlWikifiedViewer;
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user