1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-27 02:20:28 +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) { "tw-SaveTiddler": function(event) {
var template = this.hasParameter("defaultViewTemplate") ? this.params.defaultEditTemplate : "SimpleTemplate", var template = this.hasParameter("defaultViewTemplate") ? this.params.defaultEditTemplate : "SimpleTemplate",
storyTiddler = this.store.getTiddler(this.params.story), storyTiddler = this.store.getTiddler(this.params.story),
story = {tiddlers: []}; story = {tiddlers: []},
storyTiddlerModified = false;
if(storyTiddler && storyTiddler.hasOwnProperty("text")) { if(storyTiddler && storyTiddler.hasOwnProperty("text")) {
story = JSON.parse(storyTiddler.text); story = JSON.parse(storyTiddler.text);
} }
@ -74,10 +75,16 @@ exports.macro = {
// Make the story record point to the newly saved tiddler // Make the story record point to the newly saved tiddler
storyRecord.title = tiddler["draft.title"]; storyRecord.title = tiddler["draft.title"];
storyRecord.template = template; storyRecord.template = template;
// Check if we're modifying the story tiddler itself
if(tiddler["draft.title"] === this.params.story) {
storyTiddlerModified = true;
} }
} }
} }
}
if(!storyTiddlerModified) {
this.store.addTiddler(new Tiddler(storyTiddler,{text: JSON.stringify(story)})); this.store.addTiddler(new Tiddler(storyTiddler,{text: JSON.stringify(story)}));
}
event.stopPropagation(); event.stopPropagation();
return false; return false;
} }