diff --git a/core/modules/widgets/view.js b/core/modules/widgets/view.js index bbe9106be..30da34147 100755 --- a/core/modules/widgets/view.js +++ b/core/modules/widgets/view.js @@ -51,15 +51,16 @@ ViewWidget.prototype.execute = function() { this.viewIndex = this.getAttribute("index"); this.viewFormat = this.getAttribute("format","text"); this.viewTemplate = this.getAttribute("template",""); + this.viewMode = this.getAttribute("mode","block"); switch(this.viewFormat) { case "htmlwikified": - this.text = this.getValueAsHtmlWikified(); + this.text = this.getValueAsHtmlWikified(this.viewMode); break; case "plainwikified": - this.text = this.getValueAsPlainWikified(); + this.text = this.getValueAsPlainWikified(this.viewMode); break; case "htmlencodedplainwikified": - this.text = this.getValueAsHtmlEncodedPlainWikified(); + this.text = this.getValueAsHtmlEncodedPlainWikified(this.viewMode); break; case "htmlencoded": this.text = this.getValueAsHtmlEncoded(); @@ -134,16 +135,25 @@ ViewWidget.prototype.getValueAsText = function() { return this.getValue({asString: true}); }; -ViewWidget.prototype.getValueAsHtmlWikified = function() { - return this.wiki.renderText("text/html","text/vnd.tiddlywiki",this.getValueAsText(),{parentWidget: this}); +ViewWidget.prototype.getValueAsHtmlWikified = function(mode) { + return this.wiki.renderText("text/html","text/vnd.tiddlywiki",this.getValueAsText(),{ + parseAsInline: mode !== "block", + parentWidget: this + }); }; -ViewWidget.prototype.getValueAsPlainWikified = function() { - return this.wiki.renderText("text/plain","text/vnd.tiddlywiki",this.getValueAsText(),{parentWidget: this}); +ViewWidget.prototype.getValueAsPlainWikified = function(mode) { + return this.wiki.renderText("text/plain","text/vnd.tiddlywiki",this.getValueAsText(),{ + parseAsInline: mode !== "block", + parentWidget: this + }); }; -ViewWidget.prototype.getValueAsHtmlEncodedPlainWikified = function() { - return $tw.utils.htmlEncode(this.wiki.renderText("text/plain","text/vnd.tiddlywiki",this.getValueAsText(),{parentWidget: this})); +ViewWidget.prototype.getValueAsHtmlEncodedPlainWikified = function(mode) { + return $tw.utils.htmlEncode(this.wiki.renderText("text/plain","text/vnd.tiddlywiki",this.getValueAsText(),{ + parseAsInline: mode !== "block", + parentWidget: this + })); }; ViewWidget.prototype.getValueAsHtmlEncoded = function() { diff --git a/editions/tw5.com/tiddlers/widgets/ViewWidget.tid b/editions/tw5.com/tiddlers/widgets/ViewWidget.tid index 66d415795..0967352af 100644 --- a/editions/tw5.com/tiddlers/widgets/ViewWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/ViewWidget.tid @@ -1,6 +1,6 @@ caption: view created: 20131024141900000 -modified: 20160623152830060 +modified: 20170824195528248 tags: Widgets title: ViewWidget type: text/vnd.tiddlywiki @@ -20,6 +20,7 @@ The content of the `<$view>` widget is displayed if the field or property is mis |format |The format for displaying the field (see below) | |template |Optional template string used with certain formats such as dates | |subtiddler |Optional SubTiddler title when the target tiddler is a [[plugin|Plugins]] (see below) | +|mode |<<.from-version "5.1.15">> Optional transclusion parsing mode for wikified formats. May be "inline" or "block" (the default) | !! Formats @@ -30,9 +31,9 @@ The following formats can be specified in the `format` attribute: |''htmlencoded'' |The field is displayed with HTML encoding | |''urlencoded'' |The field is displayed with URL encoding | |''doubleurlencoded'' |The field is displayed with double URL encoding | -|''htmlwikified'' |The field is wikified and the resulting HTML returned as plain text (ie HTML elements will appear in plain text) | -|''plainwikified'' |The field is wikified and the text content of the resulting HTML returned as plain text (ie HTML elements will be removed) | -|''htmlencodedplainwikified'' |The field is wikified and the text content of the resulting HTML returned as HTML encoded plain text (ie HTML elements will be removed) | +|''htmlwikified'' |The field is wikified according to the mode attribute and the resulting HTML returned as plain text (ie HTML elements will appear in plain text) | +|''plainwikified'' |The field is wikified according to the mode attribute and the text content of the resulting HTML returned as plain text (ie HTML elements will be removed) | +|''htmlencodedplainwikified'' |The field is wikified according to the mode attribute and the text content of the resulting HTML returned as HTML encoded plain text (ie HTML elements will be removed) | |''date'' |The field is interpreted as a UTC date and displayed according to the DateFormat specified in the `template` attribute | |''relativedate'' |The field is interpreted as a UTC date and displayed as the interval from the present instant | |''stripcomments'' |The field is interpreted as JavaScript source code and any lines beginning `\\#` are stripped |