mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-12 18:30:27 +00:00
Merge branch 'master' into zh
This commit is contained in:
commit
d01d8539a6
@ -39,6 +39,7 @@ SetFieldWidget.prototype.execute = function() {
|
||||
this.actionField = this.getAttribute("$field");
|
||||
this.actionIndex = this.getAttribute("$index");
|
||||
this.actionValue = this.getAttribute("$value");
|
||||
this.actionTimestamp = this.getAttribute("$timestamp","yes") === "yes";
|
||||
};
|
||||
|
||||
/*
|
||||
@ -57,13 +58,15 @@ SetFieldWidget.prototype.refresh = function(changedTiddlers) {
|
||||
Invoke the action associated with this widget
|
||||
*/
|
||||
SetFieldWidget.prototype.invokeAction = function(triggeringWidget,event) {
|
||||
var self = this;
|
||||
var self = this,
|
||||
options = {};
|
||||
options.timestamp = this.actionTimestamp;
|
||||
if(typeof this.actionValue === "string") {
|
||||
this.wiki.setText(this.actionTiddler,this.actionField,this.actionIndex,this.actionValue);
|
||||
this.wiki.setText(this.actionTiddler,this.actionField,this.actionIndex,this.actionValue,options);
|
||||
}
|
||||
$tw.utils.each(this.attributes,function(attribute,name) {
|
||||
if(name.charAt(0) !== "$") {
|
||||
self.wiki.setText(self.actionTiddler,name,undefined,attribute);
|
||||
self.wiki.setText(self.actionTiddler,name,undefined,attribute,options);
|
||||
}
|
||||
});
|
||||
return true; // Action was invoked
|
||||
|
@ -220,14 +220,17 @@ NavigatorWidget.prototype.handleEditTiddlerEvent = function(event) {
|
||||
return false;
|
||||
}
|
||||
// Replace the specified tiddler with a draft in edit mode
|
||||
var draftTiddler = this.makeDraftTiddler(title),
|
||||
draftTitle = draftTiddler.fields.title,
|
||||
storyList = this.getStoryList();
|
||||
this.removeTitleFromStory(storyList,draftTitle);
|
||||
this.replaceFirstTitleInStory(storyList,title,draftTitle);
|
||||
this.addToHistory(draftTitle,event.navigateFromClientRect);
|
||||
this.saveStoryList(storyList);
|
||||
return false;
|
||||
var draftTiddler = this.makeDraftTiddler(title);
|
||||
// Update the story and history if required
|
||||
if(!event.paramObject || event.paramObject.suppressNavigation !== "yes") {
|
||||
var draftTitle = draftTiddler.fields.title,
|
||||
storyList = this.getStoryList();
|
||||
this.removeTitleFromStory(storyList,draftTitle);
|
||||
this.replaceFirstTitleInStory(storyList,title,draftTitle);
|
||||
this.addToHistory(draftTitle,event.navigateFromClientRect);
|
||||
this.saveStoryList(storyList);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Delete a tiddler
|
||||
@ -345,11 +348,13 @@ NavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) {
|
||||
if(isRename) {
|
||||
this.wiki.deleteTiddler(draftOf);
|
||||
}
|
||||
// Replace the draft in the story with the original
|
||||
this.replaceFirstTitleInStory(storyList,title,draftTitle);
|
||||
this.addToHistory(draftTitle,event.navigateFromClientRect);
|
||||
if(draftTitle !== this.storyTitle) {
|
||||
this.saveStoryList(storyList);
|
||||
if(!event.paramObject || event.paramObject.suppressNavigation !== "yes") {
|
||||
// Replace the draft in the story with the original
|
||||
this.replaceFirstTitleInStory(storyList,title,draftTitle);
|
||||
this.addToHistory(draftTitle,event.navigateFromClientRect);
|
||||
if(draftTitle !== this.storyTitle) {
|
||||
this.saveStoryList(storyList);
|
||||
}
|
||||
}
|
||||
// Trigger an autosave
|
||||
$tw.rootWidget.dispatchEvent({type: "tm-auto-save-wiki"});
|
||||
@ -381,13 +386,15 @@ NavigatorWidget.prototype.handleCancelTiddlerEvent = function(event) {
|
||||
// Remove the draft tiddler
|
||||
if(isConfirmed) {
|
||||
this.wiki.deleteTiddler(draftTitle);
|
||||
if(originalTiddler) {
|
||||
this.replaceFirstTitleInStory(storyList,draftTitle,originalTitle);
|
||||
this.addToHistory(originalTitle,event.navigateFromClientRect);
|
||||
} else {
|
||||
this.removeTitleFromStory(storyList,draftTitle);
|
||||
if(!event.paramObject || event.paramObject.suppressNavigation !== "yes") {
|
||||
if(originalTiddler) {
|
||||
this.replaceFirstTitleInStory(storyList,draftTitle,originalTitle);
|
||||
this.addToHistory(originalTitle,event.navigateFromClientRect);
|
||||
} else {
|
||||
this.removeTitleFromStory(storyList,draftTitle);
|
||||
}
|
||||
this.saveStoryList(storyList);
|
||||
}
|
||||
this.saveStoryList(storyList);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -58,17 +58,20 @@ exports.setTextReference = function(textRef,value,currTiddlerTitle) {
|
||||
this.setText(title,tr.field,tr.index,value);
|
||||
};
|
||||
|
||||
exports.setText = function(title,field,index,value) {
|
||||
exports.setText = function(title,field,index,value,options) {
|
||||
options = options || {};
|
||||
var creationFields = options.timestamp ? this.getCreationFields() : {},
|
||||
modificationFields = options.timestamp ? this.getModificationFields() : {};
|
||||
// Check if it is a reference to a tiddler field
|
||||
if(index) {
|
||||
var data = this.getTiddlerData(title,Object.create(null));
|
||||
data[index] = value;
|
||||
this.setTiddlerData(title,data,this.getModificationFields());
|
||||
this.setTiddlerData(title,data,modificationFields);
|
||||
} else {
|
||||
var tiddler = this.getTiddler(title),
|
||||
fields = {title: title};
|
||||
fields[field || "text"] = value;
|
||||
this.addTiddler(new $tw.Tiddler(tiddler,fields,this.getModificationFields()));
|
||||
this.addTiddler(new $tw.Tiddler(creationFields,tiddler,fields,modificationFields));
|
||||
}
|
||||
};
|
||||
|
||||
|
3
editions/text-slicer/tiddlers/system/SiteSubtitle.tid
Normal file
3
editions/text-slicer/tiddlers/system/SiteSubtitle.tid
Normal file
@ -0,0 +1,3 @@
|
||||
title: $:/SiteSubtitle
|
||||
|
||||
turning text into tiddlers
|
3
editions/text-slicer/tiddlers/system/SiteTitle.tid
Normal file
3
editions/text-slicer/tiddlers/system/SiteTitle.tid
Normal file
@ -0,0 +1,3 @@
|
||||
title: $:/SiteTitle
|
||||
|
||||
Text-Slicer Edition
|
@ -1,6 +1,6 @@
|
||||
caption: action-setfield
|
||||
created: 20141025120850184
|
||||
modified: 20150220162114000
|
||||
modified: 20150806171403798
|
||||
tags: Widgets ActionWidgets
|
||||
title: ActionSetFieldWidget
|
||||
type: text/vnd.tiddlywiki
|
||||
@ -18,6 +18,7 @@ The ''action-setfield'' widget is invisible. Any content within it is ignored.
|
||||
|$field |Optional name of a field to be assigned the $value attribute |
|
||||
|$index |Optional index of a property in a [[data tiddler|DataTiddlers]] to be assigned the $value attribute|
|
||||
|$value |The value to be assigned to the field or index identified by the $field or $index attribute. If neither is specified then the value is assigned to the text field |
|
||||
|$timestamp |Specifies whether the timestamp(s) of the target tiddler will be updated (''modified'' and ''modifier'', plus ''created'' and ''creator'' for newly created tiddlers). Can be "yes" (the default) or "no" |
|
||||
|//{any attributes not starting with $}// |Each attribute name specifies a field to be modified with the attribute value providing the value to assign to the field |
|
||||
|
||||
! Examples
|
||||
|
@ -240,3 +240,5 @@ Richard Smith, @richardwsmith 2015/05/22
|
||||
Marco Rimoldi, @marcor, 2015/06/26
|
||||
|
||||
Slobodan Vujnovic, @slovuj, 2015/06/30
|
||||
|
||||
Anthon Nilsson, @superdos, 2015/08/06
|
||||
|
@ -1,3 +1,3 @@
|
||||
title: $:/tags/TextSlicerToolbar
|
||||
list: $:/plugins/tiddlywiki/text-slicer/toolbar/title $:/plugins/tiddlywiki/text-slicer/toolbar/rename
|
||||
list: $:/plugins/tiddlywiki/text-slicer/toolbar/title $:/plugins/tiddlywiki/text-slicer/toolbar/rename $:/plugins/tiddlywiki/text-slicer/toolbar/edit $:/plugins/tiddlywiki/text-slicer/toolbar/cancel $:/plugins/tiddlywiki/text-slicer/toolbar/done
|
||||
|
||||
|
@ -3,4 +3,6 @@ title: $:/plugins/tiddlywiki/text-slicer/templates/display-tiddler
|
||||
<$list filter="[<tv-show-toolbar>prefix[yes]]" variable="hasToolbar">
|
||||
{{||$:/plugins/tiddlywiki/text-slicer/templates/tiddler-toolbar}}
|
||||
</$list>
|
||||
<$list filter="[draft.of<currentTiddler>limit[1]]" editTemplate="$:/core/ui/EditTemplate" emptyMessage="""<$transclude mode='block'/>"""/>
|
||||
<$list filter="[draft.of<currentTiddler>limit[1]]" emptyMessage="""<$transclude mode='block'/>""">
|
||||
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/edit-tiddler" mode="block"/>
|
||||
</$list>
|
||||
|
11
plugins/tiddlywiki/text-slicer/template-edit-tiddler.tid
Normal file
11
plugins/tiddlywiki/text-slicer/template-edit-tiddler.tid
Normal file
@ -0,0 +1,11 @@
|
||||
title: $:/plugins/tiddlywiki/text-slicer/templates/edit-tiddler
|
||||
|
||||
<$set name="storyTiddler" value=<<currentTiddler>>>
|
||||
<$keyboard key="escape" message="tm-cancel-tiddler">
|
||||
<$keyboard key="ctrl+enter" message="tm-save-tiddler">
|
||||
<$list filter="[all[shadows+tiddlers]tag[$:/tags/EditTemplate]!has[draft.of]] -[[$:/core/ui/EditTemplate/controls]] -[[$:/core/ui/EditTemplate/title]]" variable="listItem">
|
||||
<$transclude tiddler=<<listItem>>/>
|
||||
</$list>
|
||||
</$keyboard>
|
||||
</$keyboard>
|
||||
</$set>
|
13
plugins/tiddlywiki/text-slicer/toolbar-cancel.tid
Normal file
13
plugins/tiddlywiki/text-slicer/toolbar-cancel.tid
Normal file
@ -0,0 +1,13 @@
|
||||
title: $:/plugins/tiddlywiki/text-slicer/toolbar/cancel
|
||||
tags: $:/tags/TextSlicerToolbar
|
||||
|
||||
\define body()
|
||||
<$button>
|
||||
<$action-sendmessage $message="tm-cancel-tiddler" $param=<<currentTiddler>> suppressNavigation="yes"/>
|
||||
cancel
|
||||
</$button>
|
||||
\end
|
||||
|
||||
<$list filter="[draft.of<currentTiddler>limit[1]]">
|
||||
<<body>>
|
||||
</$list>
|
13
plugins/tiddlywiki/text-slicer/toolbar-done.tid
Normal file
13
plugins/tiddlywiki/text-slicer/toolbar-done.tid
Normal file
@ -0,0 +1,13 @@
|
||||
title: $:/plugins/tiddlywiki/text-slicer/toolbar/done
|
||||
tags: $:/tags/TextSlicerToolbar
|
||||
|
||||
\define body()
|
||||
<$button>
|
||||
<$action-sendmessage $message="tm-save-tiddler" $param=<<currentTiddler>> suppressNavigation="yes"/>
|
||||
done
|
||||
</$button>
|
||||
\end
|
||||
|
||||
<$list filter="[draft.of<currentTiddler>limit[1]]">
|
||||
<<body>>
|
||||
</$list>
|
12
plugins/tiddlywiki/text-slicer/toolbar-edit.tid
Normal file
12
plugins/tiddlywiki/text-slicer/toolbar-edit.tid
Normal file
@ -0,0 +1,12 @@
|
||||
title: $:/plugins/tiddlywiki/text-slicer/toolbar/edit
|
||||
tags: $:/tags/TextSlicerToolbar
|
||||
|
||||
\define body()
|
||||
<$button>
|
||||
<$action-sendmessage $message="tm-edit-tiddler" $param=<<currentTiddler>> suppressNavigation="yes"/>
|
||||
edit
|
||||
</$button>
|
||||
\end
|
||||
|
||||
<$list filter="[draft.of<currentTiddler>limit[1]]" emptyMessage="""<<body>>""">
|
||||
</$list>
|
@ -9,8 +9,10 @@ $:/config/plugins/tiddlywiki/text-slicer/rename-$(currentTiddler)$
|
||||
<$edit-text tag="input" tiddler=<<renameProxyTitle>> placeholder="Rename" default=<<currentTiddler>>/>
|
||||
<$button>
|
||||
<$action-sendmessage $message="tm-rename-tiddler" from=<<currentTiddler>> to={{$(renameProxyTitle)$}}/>
|
||||
<$action-deletetiddler $tiddler=<<renameProxyTitle>>/>
|
||||
rename
|
||||
</$button>
|
||||
\end
|
||||
|
||||
<<body>>
|
||||
<$list filter="[draft.of<currentTiddler>limit[1]]" emptyMessage="""<<body>>""">
|
||||
</$list>
|
||||
|
Loading…
Reference in New Issue
Block a user