mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-31 07:32:59 +00:00 
			
		
		
		
	Add "mode" attribute to View widget
Useful for controlling how the content is parsed
This commit is contained in:
		| @@ -51,15 +51,16 @@ ViewWidget.prototype.execute = function() { | |||||||
| 	this.viewIndex = this.getAttribute("index"); | 	this.viewIndex = this.getAttribute("index"); | ||||||
| 	this.viewFormat = this.getAttribute("format","text"); | 	this.viewFormat = this.getAttribute("format","text"); | ||||||
| 	this.viewTemplate = this.getAttribute("template",""); | 	this.viewTemplate = this.getAttribute("template",""); | ||||||
|  | 	this.viewMode = this.getAttribute("mode","block"); | ||||||
| 	switch(this.viewFormat) { | 	switch(this.viewFormat) { | ||||||
| 		case "htmlwikified": | 		case "htmlwikified": | ||||||
| 			this.text = this.getValueAsHtmlWikified(); | 			this.text = this.getValueAsHtmlWikified(this.viewMode); | ||||||
| 			break; | 			break; | ||||||
| 		case "plainwikified": | 		case "plainwikified": | ||||||
| 			this.text = this.getValueAsPlainWikified(); | 			this.text = this.getValueAsPlainWikified(this.viewMode); | ||||||
| 			break; | 			break; | ||||||
| 		case "htmlencodedplainwikified": | 		case "htmlencodedplainwikified": | ||||||
| 			this.text = this.getValueAsHtmlEncodedPlainWikified(); | 			this.text = this.getValueAsHtmlEncodedPlainWikified(this.viewMode); | ||||||
| 			break; | 			break; | ||||||
| 		case "htmlencoded": | 		case "htmlencoded": | ||||||
| 			this.text = this.getValueAsHtmlEncoded(); | 			this.text = this.getValueAsHtmlEncoded(); | ||||||
| @@ -134,16 +135,25 @@ ViewWidget.prototype.getValueAsText = function() { | |||||||
| 	return this.getValue({asString: true}); | 	return this.getValue({asString: true}); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| ViewWidget.prototype.getValueAsHtmlWikified = function() { | ViewWidget.prototype.getValueAsHtmlWikified = function(mode) { | ||||||
| 	return this.wiki.renderText("text/html","text/vnd.tiddlywiki",this.getValueAsText(),{parentWidget: this}); | 	return this.wiki.renderText("text/html","text/vnd.tiddlywiki",this.getValueAsText(),{ | ||||||
|  | 		parseAsInline: mode !== "block", | ||||||
|  | 		parentWidget: this | ||||||
|  | 	}); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| ViewWidget.prototype.getValueAsPlainWikified = function() { | ViewWidget.prototype.getValueAsPlainWikified = function(mode) { | ||||||
| 	return this.wiki.renderText("text/plain","text/vnd.tiddlywiki",this.getValueAsText(),{parentWidget: this}); | 	return this.wiki.renderText("text/plain","text/vnd.tiddlywiki",this.getValueAsText(),{ | ||||||
|  | 		parseAsInline: mode !== "block", | ||||||
|  | 		parentWidget: this | ||||||
|  | 	}); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| ViewWidget.prototype.getValueAsHtmlEncodedPlainWikified = function() { | ViewWidget.prototype.getValueAsHtmlEncodedPlainWikified = function(mode) { | ||||||
| 	return $tw.utils.htmlEncode(this.wiki.renderText("text/plain","text/vnd.tiddlywiki",this.getValueAsText(),{parentWidget: this})); | 	return $tw.utils.htmlEncode(this.wiki.renderText("text/plain","text/vnd.tiddlywiki",this.getValueAsText(),{ | ||||||
|  | 		parseAsInline: mode !== "block", | ||||||
|  | 		parentWidget: this | ||||||
|  | 	})); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| ViewWidget.prototype.getValueAsHtmlEncoded = function() { | ViewWidget.prototype.getValueAsHtmlEncoded = function() { | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| caption: view | caption: view | ||||||
| created: 20131024141900000 | created: 20131024141900000 | ||||||
| modified: 20160623152830060 | modified: 20170824195528248 | ||||||
| tags: Widgets | tags: Widgets | ||||||
| title: ViewWidget | title: ViewWidget | ||||||
| type: text/vnd.tiddlywiki | 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) | | |format |The format for displaying the field (see below) | | ||||||
| |template |Optional template string used with certain formats such as dates | | |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) | | |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 | !! Formats | ||||||
|  |  | ||||||
| @@ -30,9 +31,9 @@ The following formats can be specified in the `format` attribute: | |||||||
| |''htmlencoded'' |The field is displayed with HTML encoding | | |''htmlencoded'' |The field is displayed with HTML encoding | | ||||||
| |''urlencoded'' |The field is displayed with URL encoding | | |''urlencoded'' |The field is displayed with URL encoding | | ||||||
| |''doubleurlencoded'' |The field is displayed with double 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) | | |''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 and the text content of the resulting HTML returned as plain text (ie HTML elements will be removed) | | |''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 and the text content of the resulting HTML returned as HTML encoded 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 | | |''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 | | |''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 | | |''stripcomments'' |The field is interpreted as JavaScript source code and any lines beginning `\\#` are stripped | | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jermolene
					Jermolene