mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-17 15:21:22 +00:00
Improve action-createtiddler to return a draft title too
This commit is contained in:
@@ -37,6 +37,7 @@ Compute the internal state of the widget
|
||||
CreateTiddlerWidget.prototype.execute = function() {
|
||||
this.actionBaseTitle = this.getAttribute("$basetitle");
|
||||
this.actionSaveTitle = this.getAttribute("$savetitle");
|
||||
this.actionSaveDraftTitle = this.getAttribute("$savedrafttitle");
|
||||
this.actionTimestamp = this.getAttribute("$timestamp","yes") === "yes";
|
||||
};
|
||||
|
||||
@@ -73,6 +74,9 @@ CreateTiddlerWidget.prototype.invokeAction = function(triggeringWidget,event) {
|
||||
if(this.actionSaveTitle) {
|
||||
this.wiki.setTextReference(this.actionSaveTitle,title,this.getVariable("currentTiddler"));
|
||||
}
|
||||
if(this.actionSaveDraftTitle) {
|
||||
this.wiki.setTextReference(this.actionSaveDraftTitle,this.wiki.generateDraftTitle(title),this.getVariable("currentTiddler"));
|
||||
}
|
||||
return true; // Action was invoked
|
||||
};
|
||||
|
||||
|
||||
@@ -279,15 +279,7 @@ NavigatorWidget.prototype.makeDraftTiddler = function(targetTitle) {
|
||||
Generate a title for the draft of a given tiddler
|
||||
*/
|
||||
NavigatorWidget.prototype.generateDraftTitle = function(title) {
|
||||
var c = 0,
|
||||
draftTitle,
|
||||
username = this.wiki.getTiddlerText("$:/status/UserName"),
|
||||
attribution = username ? " by " + username : "";
|
||||
do {
|
||||
draftTitle = "Draft " + (c ? (c + 1) + " " : "") + "of '" + title + "'" + attribution;
|
||||
c++;
|
||||
} while(this.wiki.tiddlerExists(draftTitle));
|
||||
return draftTitle;
|
||||
return this.wiki.generateDraftTitle(title);
|
||||
};
|
||||
|
||||
// Take a tiddler out of edit mode, saving the changes
|
||||
|
||||
Reference in New Issue
Block a user