1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-10-03 01:10:45 +00:00

Fixed problem with manually editting the story tiddler

Now you can manually edit StoryTiddler, which is quite fun
This commit is contained in:
Jeremy Ruston 2012-03-30 18:12:45 +01:00
parent 75279c2b13
commit c57d1efefe

View File

@ -58,7 +58,8 @@ exports.macro = {
"tw-SaveTiddler": function(event) {
var template = this.hasParameter("defaultViewTemplate") ? this.params.defaultEditTemplate : "SimpleTemplate",
storyTiddler = this.store.getTiddler(this.params.story),
story = {tiddlers: []};
story = {tiddlers: []},
storyTiddlerModified = false;
if(storyTiddler && storyTiddler.hasOwnProperty("text")) {
story = JSON.parse(storyTiddler.text);
}
@ -74,10 +75,16 @@ exports.macro = {
// Make the story record point to the newly saved tiddler
storyRecord.title = tiddler["draft.title"];
storyRecord.template = template;
// Check if we're modifying the story tiddler itself
if(tiddler["draft.title"] === this.params.story) {
storyTiddlerModified = true;
}
}
}
}
this.store.addTiddler(new Tiddler(storyTiddler,{text: JSON.stringify(story)}));
if(!storyTiddlerModified) {
this.store.addTiddler(new Tiddler(storyTiddler,{text: JSON.stringify(story)}));
}
event.stopPropagation();
return false;
}