mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-04-30 10:41:30 +00:00
Compare commits
2 Commits
edit-text-
...
fix-tc-sto
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7836018b20 | ||
|
|
aefe87de7f |
@@ -177,11 +177,9 @@ FramedEngine.prototype.fixHeight = function() {
|
||||
Focus the engine node
|
||||
*/
|
||||
FramedEngine.prototype.focus = function() {
|
||||
if(this.domNode.focus) {
|
||||
if(this.domNode.focus && this.domNode.select) {
|
||||
this.domNode.focus();
|
||||
}
|
||||
if(this.domNode.select) {
|
||||
$tw.utils.setSelectionByPosition(this.domNode,this.widget.editFocusSelectFromStart,this.widget.editFocusSelectFromEnd);
|
||||
this.domNode.select();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -119,12 +119,10 @@ SimpleEngine.prototype.fixHeight = function() {
|
||||
/*
|
||||
Focus the engine node
|
||||
*/
|
||||
SimpleEngine.prototype.focus = function() {
|
||||
if(this.domNode.focus) {
|
||||
SimpleEngine.prototype.focus = function() {
|
||||
if(this.domNode.focus && this.domNode.select) {
|
||||
this.domNode.focus();
|
||||
}
|
||||
if(this.domNode.select) {
|
||||
$tw.utils.setSelectionByPosition(this.domNode,this.widget.editFocusSelectFromStart,this.widget.editFocusSelectFromEnd);
|
||||
this.domNode.select();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -180,8 +180,6 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
||||
this.editMinHeight = this.getAttribute("minHeight",DEFAULT_MIN_TEXT_AREA_HEIGHT);
|
||||
this.editFocusPopup = this.getAttribute("focusPopup");
|
||||
this.editFocus = this.getAttribute("focus");
|
||||
this.editFocusSelectFromStart = $tw.utils.parseNumber(this.getAttribute("focusSelectFromStart","0"));
|
||||
this.editFocusSelectFromEnd = $tw.utils.parseNumber(this.getAttribute("focusSelectFromEnd","0"));
|
||||
this.editTabIndex = this.getAttribute("tabindex");
|
||||
this.editCancelPopups = this.getAttribute("cancelPopups","") === "yes";
|
||||
this.editInputActions = this.getAttribute("inputActions");
|
||||
@@ -220,7 +218,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
||||
EditTextWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
// Completely rerender if any of our attributes have changed
|
||||
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE] || changedTiddlers["$:/palette"] || changedAttributes.disabled || changedAttributes.fileDrop) {
|
||||
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE] || changedAttributes.disabled || changedAttributes.fileDrop) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
} else if (changedTiddlers[this.editRefreshTitle]) {
|
||||
|
||||
@@ -28,24 +28,6 @@ exports.domMatchesSelector = function(node,selector) {
|
||||
return node.matches ? node.matches(selector) : node.msMatchesSelector(selector);
|
||||
};
|
||||
|
||||
/*
|
||||
Select text in a an input or textarea (setSelectionRange crashes on certain input types)
|
||||
*/
|
||||
exports.setSelectionRangeSafe = function(node,start,end,direction) {
|
||||
try {
|
||||
node.setSelectionRange(start,end,direction);
|
||||
} catch(e) {
|
||||
node.select();
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Select the text in an input or textarea by position
|
||||
*/
|
||||
exports.setSelectionByPosition = function(node,selectFromStart,selectFromEnd) {
|
||||
$tw.utils.setSelectionRangeSafe(node,selectFromStart,node.value.length - selectFromEnd);
|
||||
};
|
||||
|
||||
exports.removeChildren = function(node) {
|
||||
while(node.hasChildNodes()) {
|
||||
node.removeChild(node.firstChild);
|
||||
|
||||
@@ -238,7 +238,7 @@ exports.generateTiddlerFileInfo = function(tiddler,options) {
|
||||
} else {
|
||||
// Save as a .tid or a text/binary file plus a .meta file
|
||||
var tiddlerType = tiddler.fields.type || "text/vnd.tiddlywiki";
|
||||
if(tiddlerType === "text/vnd.tiddlywiki" || tiddler.hasField("_canonical_uri")) {
|
||||
if(tiddlerType === "text/vnd.tiddlywiki") {
|
||||
// Save as a .tid file
|
||||
fileInfo.type = "application/x-tiddler";
|
||||
fileInfo.hasMetaFile = false;
|
||||
|
||||
@@ -46,7 +46,6 @@ GenesisWidget.prototype.execute = function() {
|
||||
this.genesisRemappable = this.getAttribute("$remappable","yes") === "yes";
|
||||
this.genesisNames = this.getAttribute("$names","");
|
||||
this.genesisValues = this.getAttribute("$values","");
|
||||
this.genesisIsBlock = this.getAttribute("$mode",this.parseTreeNode.isBlock && "block") === "block";
|
||||
// Do not create a child widget if the $type attribute is missing or blank
|
||||
if(!this.genesisType) {
|
||||
this.makeChildWidgets(this.parseTreeNode.children);
|
||||
@@ -61,7 +60,6 @@ GenesisWidget.prototype.execute = function() {
|
||||
tag: nodeTag,
|
||||
attributes: {},
|
||||
orderedAttributes: [],
|
||||
isBlock: this.genesisIsBlock,
|
||||
children: this.parseTreeNode.children || [],
|
||||
isNotRemappable: !this.genesisRemappable
|
||||
}];
|
||||
|
||||
@@ -74,9 +74,7 @@ LetWidget.prototype.getVariableInfo = function(name,options) {
|
||||
text: this.currentValueFor[name]
|
||||
};
|
||||
}
|
||||
return Widget.prototype.getVariableInfo.call(this,name,$tw.utils.extend(Object.create(null),options,{
|
||||
defaultValue: ""
|
||||
}));
|
||||
return Widget.prototype.getVariableInfo.call(this,name,options);
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -499,8 +499,7 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
|
||||
// Get the tiddlers
|
||||
var tiddlers = $tw.utils.parseJSONSafe(event.param,[]);
|
||||
// Get the current $:/Import tiddler
|
||||
var paramObject = event.paramObject || {},
|
||||
importTitle = event.importTitle || paramObject.importTitle || IMPORT_TITLE,
|
||||
var importTitle = event.importTitle ? event.importTitle : IMPORT_TITLE,
|
||||
importTiddler = this.wiki.getTiddler(importTitle),
|
||||
importData = this.wiki.getTiddlerData(importTitle,{}),
|
||||
newFields = new Object({
|
||||
@@ -541,7 +540,7 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
|
||||
newFields.text = JSON.stringify(importData,null,$tw.config.preferences.jsonSpaces);
|
||||
this.wiki.addTiddler(new $tw.Tiddler(importTiddler,newFields));
|
||||
// Update the story and history details
|
||||
var autoOpenOnImport = event.autoOpenOnImport || paramObject.autoOpenOnImport || this.getVariable("tv-auto-open-on-import");
|
||||
var autoOpenOnImport = event.autoOpenOnImport ? event.autoOpenOnImport : this.getVariable("tv-auto-open-on-import");
|
||||
if(autoOpenOnImport !== "no") {
|
||||
var storyList = this.getStoryList(),
|
||||
history = [];
|
||||
|
||||
@@ -14,7 +14,6 @@ extension: .html
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="generator" content="TiddlyWiki" />
|
||||
<meta name="tiddlywiki-version" content="{{$:/core/templates/version}}" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="format-detection" content="telephone=no">
|
||||
<link id="faviconLink" rel="shortcut icon" href="favicon.ico">
|
||||
<title>{{$:/core/wiki/title}}</title>
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
title: Genesis/Block
|
||||
description: genesis widget distinguishes between block and inline
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
<$genesis $type="$reveal" type=nomatch>
|
||||
|
||||
Block
|
||||
</$genesis>
|
||||
|
||||
<$genesis $type="$reveal" type=nomatch $mode=block>
|
||||
|
||||
Block forced block
|
||||
</$genesis>
|
||||
|
||||
<$genesis $type="$reveal" type=nomatch $mode=inline>
|
||||
|
||||
Block forced inline
|
||||
</$genesis>
|
||||
|
||||
<$genesis $type=$reveal type=nomatch>Inline</$genesis>
|
||||
<$genesis $type=$reveal type=nomatch $mode=block>Inline forced block</$genesis>
|
||||
<$genesis $type=$reveal type=nomatch $mode=inline>Inline forced inline</$genesis>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<div class=" tc-reveal"><p>Block</p></div><div class=" tc-reveal"><p>Block forced block</p></div><span class=" tc-reveal"><p>Block forced inline</p></span><p><span class=" tc-reveal">Inline</span><div class=" tc-reveal">Inline forced block</div><span class=" tc-reveal">Inline forced inline</span></p>
|
||||
@@ -1,35 +0,0 @@
|
||||
title: Message/tm-import-tiddlers/CustomTitle
|
||||
description: tm-import-tiddlers message can import to a tiddler with a custom title
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
text: <$text text={{MyCustomTitle}}/>
|
||||
plugin-type: <$text text={{MyCustomTitle!!plugin-type}}/>
|
||||
~$:/StoryList: <$text text={{$:/StoryList!!list}}/>
|
||||
+
|
||||
title: Actions
|
||||
|
||||
<$navigator story="$:/StoryList">
|
||||
<$action-sendmessage
|
||||
$message="tm-import-tiddlers"
|
||||
$param='[{"title": "Elephants"}, {"title": "Eagles"}]'
|
||||
importTitle=MyCustomTitle/>
|
||||
</$navigator>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>text: {
|
||||
"tiddlers": {
|
||||
"Elephants": {
|
||||
"title": "Elephants"
|
||||
},
|
||||
"Eagles": {
|
||||
"title": "Eagles"
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin-type: import
|
||||
$:/StoryList: MyCustomTitle</p>
|
||||
@@ -1,35 +0,0 @@
|
||||
title: Message/tm-import-tiddlers/NoAutoOpen
|
||||
description: tm-import-tiddlers can import without automatically opening the import tiddler
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
text: <$text text={{$:/Import}}/>
|
||||
plugin-type: <$text text={{$:/Import!!plugin-type}}/>
|
||||
~$:/StoryList: <$text text={{$:/StoryList!!list}}/>
|
||||
+
|
||||
title: Actions
|
||||
|
||||
<$navigator story="$:/StoryList">
|
||||
<$action-sendmessage
|
||||
$message="tm-import-tiddlers"
|
||||
$param='[{"title": "Elephants"}, {"title": "Eagles"}]'
|
||||
autoOpenOnImport=no/>
|
||||
</$navigator>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>text: {
|
||||
"tiddlers": {
|
||||
"Elephants": {
|
||||
"title": "Elephants"
|
||||
},
|
||||
"Eagles": {
|
||||
"title": "Eagles"
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin-type: import
|
||||
$:/StoryList: </p>
|
||||
@@ -1,36 +0,0 @@
|
||||
title: Message/tm-import-tiddlers/NoAutoOpenViaVar
|
||||
description: tm-import-tiddlers can import and open based on tv-auto-open-on-import
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
text: <$text text={{$:/Import}}/>
|
||||
plugin-type: <$text text={{$:/Import!!plugin-type}}/>
|
||||
~$:/StoryList: <$text text={{$:/StoryList!!list}}/>
|
||||
+
|
||||
title: Actions
|
||||
|
||||
<$let tv-auto-open-on-import="no">
|
||||
<$navigator story="$:/StoryList">
|
||||
<$action-sendmessage
|
||||
$message="tm-import-tiddlers"
|
||||
$param='[{"title": "Elephants"}, {"title": "Eagles"}]'/>
|
||||
</$navigator>
|
||||
</$let>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>text: {
|
||||
"tiddlers": {
|
||||
"Elephants": {
|
||||
"title": "Elephants"
|
||||
},
|
||||
"Eagles": {
|
||||
"title": "Eagles"
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin-type: import
|
||||
$:/StoryList: </p>
|
||||
@@ -1,34 +0,0 @@
|
||||
title: Message/tm-import-tiddlers/default
|
||||
description: tm-import-tiddlers message by default should import to $:/Import and open the tiddler
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
text: <$text text={{$:/Import}}/>
|
||||
plugin-type: <$text text={{$:/Import!!plugin-type}}/>
|
||||
~$:/StoryList: <$text text={{$:/StoryList!!list}}/>
|
||||
+
|
||||
title: Actions
|
||||
|
||||
<$navigator story="$:/StoryList">
|
||||
<$action-sendmessage
|
||||
$message="tm-import-tiddlers"
|
||||
$param='[{"title": "Elephants"}, {"title": "Eagles"}]'/>
|
||||
</$navigator>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>text: {
|
||||
"tiddlers": {
|
||||
"Elephants": {
|
||||
"title": "Elephants"
|
||||
},
|
||||
"Eagles": {
|
||||
"title": "Eagles"
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin-type: import
|
||||
$:/StoryList: $:/Import</p>
|
||||
@@ -1,6 +1,6 @@
|
||||
caption: edit-text
|
||||
created: 20131024141900000
|
||||
modified: 20230122210049893
|
||||
modified: 20211104200554064
|
||||
tags: Widgets
|
||||
title: EditTextWidget
|
||||
type: text/vnd.tiddlywiki
|
||||
@@ -24,8 +24,6 @@ The content of the `<$edit-text>` widget is ignored.
|
||||
|placeholder |Placeholder text to be displayed when the edit field is empty |
|
||||
|focusPopup |Title of a state tiddler for a popup that is displayed when the editing element has focus |
|
||||
|focus |Set to "yes" or "true" to automatically focus the editor after creation |
|
||||
|focusSelectFromStart |<<.from-version 5.2.6>> If the `focus` attribute is enabled, determines the position of the start of the selection: `0` (default) places the start of the selection at the beginning of the text, `1` places the start of the selection after the first character, etc. |
|
||||
|focusSelectFromEnd |<<.from-version 5.2.6>> If the `focus` attribute is enabled, determines the position of the end of the selection: `0` (default) places the end of the selection at the end of the text, `1` places the start of the selection before the final character, etc. |
|
||||
|tabindex |Sets the `tabindex` attribute of the input or textarea to the given value |
|
||||
|autocomplete |<<.from-version 5.1.23>> An optional string to provide a hint to the browser how to handle autocomplete for this input |
|
||||
|tag |Overrides the generated HTML editing element tag. For a multi-line editor use `tag=textarea`. For a single-line editor use `tag=input` |
|
||||
@@ -40,7 +38,8 @@ The content of the `<$edit-text>` widget is ignored.
|
||||
|disabled|<<.from-version "5.1.23">> Optional, disables the text input if set to "yes". Defaults to "no"|
|
||||
|fileDrop|<<.from-version "5.2.0">> Optional. When set to "yes" allows dropping or pasting images into the editor to import them. Defaults to "no"|
|
||||
|
||||
! Examples
|
||||
|
||||
! Example
|
||||
|
||||
If you wanted to change the field //myconfig// of the tiddler //AppSettings//, you could use an EditTextWidget to edit the field, and then show the result anywhere else by using `{{AppSettings!!myconfig}}`. Note that this will create tiddler AppSettings if it doesn't already exist.
|
||||
|
||||
@@ -49,20 +48,3 @@ eg="""<$edit-text tiddler="AppSettings" field="myconfig"/><p/>
|
||||
Value of ''myconfig'' : {{AppSettings!!myconfig}}
|
||||
"""/>
|
||||
|
||||
!! Text Selection
|
||||
|
||||
If the edit field already contains text or a default value is provided, you can use the `focusSelectFromStart` and `focusSelectFromEnd` attributes to only select part of the text when using `focus="yes"`.
|
||||
|
||||
Partial selection when editing this tiddler's //caption// field:
|
||||
|
||||
<$macrocall $name=".example" n="2"
|
||||
eg="""<$edit-text tiddler=<<currentTiddler>> field="caption" focus="yes" focusSelectFromStart="5" />
|
||||
"""/>
|
||||
|
||||
!!! {{!!heading}}
|
||||
|
||||
Provide a dated heading for this example where only the placeholder (but not the date) is selected for easier text input:
|
||||
|
||||
<$macrocall $name=".example" n="3"
|
||||
eg="""<$edit-text tiddler=<<currentTiddler>> field="heading" size="25" focus="yes" focusSelectFromEnd="13" default={{{ [[Heading Text (]] [<now YYYY-0MM-0DD>] [[)]] +[join[]] }}} />
|
||||
"""/>
|
||||
|
||||
@@ -17,7 +17,6 @@ The content of the <<.wid genesis>> widget is used as the content of the dynamic
|
||||
|$type |The type of widget or element to create (an initial `$` indicates a widget, otherwise an HTML element will be created) |
|
||||
|$names |An optional filter evaluating to the names of a list of attributes to be applied to the widget |
|
||||
|$values |An optional filter evaluating to the values corresponding to the list of names specified in <<.attr $names>> |
|
||||
|$mode |An optional override of the parsing mode. May be "inline" or "block" |
|
||||
|//{other attributes starting with $}// |Other attributes starting with a single dollar sign are reserved for future use |
|
||||
|//{attributes starting with $$}// |Attributes starting with two dollar signs are applied as attributes to the output widget, but with the attribute name changed to use a single dollar sign |
|
||||
|//{attributes not starting with $}// |Any other attributes that do not start with a dollar are applied as attributes to the output widget |
|
||||
|
||||
@@ -38,28 +38,23 @@ DynannotateWidget.prototype.render = function(parent,nextSibling) {
|
||||
// Create our DOM nodes
|
||||
var isSnippetMode = this.isSnippetMode();
|
||||
this.domContent = $tw.utils.domMaker("div",{
|
||||
"class": "tc-dynannotation-selection-container",
|
||||
document: this.document
|
||||
"class": "tc-dynannotation-selection-container"
|
||||
});
|
||||
if(isSnippetMode) {
|
||||
this.domContent.setAttribute("hidden","hidden");
|
||||
this.domContent.setAttribute("hidden","hidden");
|
||||
}
|
||||
this.domAnnotations = $tw.utils.domMaker("div",{
|
||||
"class": "tc-dynannotation-annotation-wrapper",
|
||||
document: this.document
|
||||
"class": "tc-dynannotation-annotation-wrapper"
|
||||
});
|
||||
this.domSnippets = $tw.utils.domMaker("div",{
|
||||
"class": "tc-dynannotation-snippet-wrapper",
|
||||
document: this.document
|
||||
"class": "tc-dynannotation-snippet-wrapper"
|
||||
});
|
||||
this.domSearches = $tw.utils.domMaker("div",{
|
||||
"class": "tc-dynannotation-search-wrapper",
|
||||
document: this.document
|
||||
"class": "tc-dynannotation-search-wrapper"
|
||||
});
|
||||
this.domWrapper = $tw.utils.domMaker("div",{
|
||||
"class": "tc-dynannotation-wrapper",
|
||||
children: [this.domContent,this.domAnnotations,this.domSnippets,this.domSearches],
|
||||
document: this.document
|
||||
children: [this.domContent,this.domAnnotations,this.domSnippets,this.domSearches]
|
||||
})
|
||||
parent.insertBefore(this.domWrapper,nextSibling);
|
||||
this.domNodes.push(this.domWrapper);
|
||||
@@ -69,18 +64,16 @@ DynannotateWidget.prototype.render = function(parent,nextSibling) {
|
||||
}
|
||||
// Render our child widgets
|
||||
this.renderChildren(this.domContent,null);
|
||||
if(!this.document.isTiddlyWikiFakeDom) {
|
||||
if(isSnippetMode) {
|
||||
// Apply search snippets
|
||||
this.applySnippets();
|
||||
} else {
|
||||
// Get the list of annotation tiddlers
|
||||
this.getAnnotationTiddlers();
|
||||
// Apply annotations
|
||||
this.applyAnnotations();
|
||||
// Apply search overlays
|
||||
this.applySearch();
|
||||
}
|
||||
if(isSnippetMode) {
|
||||
// Apply search snippets
|
||||
this.applySnippets();
|
||||
} else {
|
||||
// Get the list of annotation tiddlers
|
||||
this.getAnnotationTiddlers();
|
||||
// Apply annotations
|
||||
this.applyAnnotations();
|
||||
// Apply search overlays
|
||||
this.applySearch();
|
||||
}
|
||||
// Save the width of the wrapper so that we can tell when it changes
|
||||
this.wrapperWidth = this.domWrapper.offsetWidth;
|
||||
|
||||
@@ -7,5 +7,5 @@ markdown/breaks: false
|
||||
markdown/linkify: false
|
||||
markdown/quotes: “”‘’
|
||||
markdown/renderWikiText: true
|
||||
markdown/renderWikiTextPragma: \rules only html entity syslink prettylink image prettyextlink wikilink commentblock commentinline macrocallblock macrocallinline transcludeblock transcludeinline filteredtranscludeblock filteredtranscludeinline
|
||||
markdown/renderWikiTextPragma: \rules only html entity syslink wikilink commentblock commentinline macrocallblock macrocallinline transcludeblock transcludeinline filteredtranscludeblock filteredtranscludeinline
|
||||
markdown/typographer: false
|
||||
@@ -103,9 +103,8 @@ function render_tw_expr(tokens,idx) {
|
||||
return tokens[idx].content;
|
||||
}
|
||||
|
||||
// Overwrite default: attribute values can be either a string or {type;, value:}.
|
||||
// 1) string attr val: render in e"..." format so HTML entities can be decoded.
|
||||
// 2) object attr val: render value as is.
|
||||
// Overwrite default: render attribute strings in e"..." format instead,
|
||||
// so HTML entities can be decoded. See parseStringLiteralExt() below.
|
||||
function render_token_attrs(token) {
|
||||
var i, l, result;
|
||||
|
||||
@@ -114,11 +113,7 @@ function render_token_attrs(token) {
|
||||
result = '';
|
||||
|
||||
for(i=0, l=token.attrs.length; i<l; i++) {
|
||||
if(typeof token.attrs[i][1] === "object" && token.attrs[i][1] !== null) {
|
||||
result += ' ' + md.utils.escapeHtml(token.attrs[i][0]) + '=' + token.attrs[i][1].value;
|
||||
} else {
|
||||
result += ' ' + md.utils.escapeHtml(token.attrs[i][0]) + '=e"' + md.utils.escapeHtml(token.attrs[i][1]) + '"';
|
||||
}
|
||||
result += ' ' + md.utils.escapeHtml(token.attrs[i][0]) + '=e"' + md.utils.escapeHtml(token.attrs[i][1]) + '"';
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -269,19 +264,7 @@ function tw_image(state,silent) {
|
||||
var twNode = ruleinfo.rule.parse()[0];
|
||||
var token = state.push('$image','$image',0);
|
||||
$tw.utils.each(twNode.attributes,function(attr,id) {
|
||||
switch(attr.type) {
|
||||
case "filtered":
|
||||
token.attrSet(id,{ type: "filtered", value: "{{{" + attr.filter + "}}}" });
|
||||
break;
|
||||
case "indirect":
|
||||
token.attrSet(id,{ type: "indirect", value: "{{" + attr.textReference + "}}" });
|
||||
break;
|
||||
case "macro":
|
||||
token.attrSet(id,{ type: "macro", value: ruleinfo.rule.parser.source.substring(attr.value.start,attr.value.end) });
|
||||
break;
|
||||
default:
|
||||
token.attrSet(id,attr.value);
|
||||
}
|
||||
token.attrSet(id,attr.value);
|
||||
});
|
||||
token.markup = 'tw_image';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user