mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Fix setTextReference()
It wasn’t working for non-existent tiddlers. Also added support for setting indexed properties of a data tiddler.
This commit is contained in:
parent
9bd0174205
commit
8e17c1dfd5
@ -54,20 +54,17 @@ exports.getTextReference = function(textRef,defaultText,currTiddlerTitle) {
|
|||||||
|
|
||||||
exports.setTextReference = function(textRef,value,currTiddlerTitle) {
|
exports.setTextReference = function(textRef,value,currTiddlerTitle) {
|
||||||
var tr = $tw.utils.parseTextReference(textRef),
|
var tr = $tw.utils.parseTextReference(textRef),
|
||||||
title,tiddler,fields;
|
|
||||||
// Check if it is a reference to a tiddler
|
|
||||||
if(tr.title && !tr.field) {
|
|
||||||
tiddler = this.getTiddler(tr.title);
|
|
||||||
this.addTiddler(new $tw.Tiddler(tiddler,{title: tr.title,text: value},this.getModificationFields()));
|
|
||||||
// Else check for a field reference
|
|
||||||
} else if(tr.field) {
|
|
||||||
title = tr.title || currTiddlerTitle;
|
title = tr.title || currTiddlerTitle;
|
||||||
tiddler = this.getTiddler(title);
|
// Check if it is a reference to a tiddler field
|
||||||
if(tiddler) {
|
if(tr.index) {
|
||||||
fields = {};
|
var data = this.getTiddlerData(title,{});
|
||||||
fields[tr.field] = value;
|
data[tr.index] = value;
|
||||||
this.addTiddler(new $tw.Tiddler(tiddler,fields,this.getModificationFields()));
|
this.setTiddlerData(title,data,this.getModificationFields());
|
||||||
}
|
} else {
|
||||||
|
var tiddler = this.getTiddler(title),
|
||||||
|
fields = {title: title};
|
||||||
|
fields[tr.field || "text"] = value;
|
||||||
|
this.addTiddler(new $tw.Tiddler(tiddler,fields,this.getModificationFields()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user