kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Merge branch 'master' into zh
commit
d01d8539a6
|
@ -39,6 +39,7 @@ SetFieldWidget.prototype.execute = function() {
|
||||||
this.actionField = this.getAttribute("$field");
|
this.actionField = this.getAttribute("$field");
|
||||||
this.actionIndex = this.getAttribute("$index");
|
this.actionIndex = this.getAttribute("$index");
|
||||||
this.actionValue = this.getAttribute("$value");
|
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
|
Invoke the action associated with this widget
|
||||||
*/
|
*/
|
||||||
SetFieldWidget.prototype.invokeAction = function(triggeringWidget,event) {
|
SetFieldWidget.prototype.invokeAction = function(triggeringWidget,event) {
|
||||||
var self = this;
|
var self = this,
|
||||||
|
options = {};
|
||||||
|
options.timestamp = this.actionTimestamp;
|
||||||
if(typeof this.actionValue === "string") {
|
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) {
|
$tw.utils.each(this.attributes,function(attribute,name) {
|
||||||
if(name.charAt(0) !== "$") {
|
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
|
return true; // Action was invoked
|
||||||
|
|
|
@ -220,14 +220,17 @@ NavigatorWidget.prototype.handleEditTiddlerEvent = function(event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Replace the specified tiddler with a draft in edit mode
|
// Replace the specified tiddler with a draft in edit mode
|
||||||
var draftTiddler = this.makeDraftTiddler(title),
|
var draftTiddler = this.makeDraftTiddler(title);
|
||||||
draftTitle = draftTiddler.fields.title,
|
// Update the story and history if required
|
||||||
storyList = this.getStoryList();
|
if(!event.paramObject || event.paramObject.suppressNavigation !== "yes") {
|
||||||
this.removeTitleFromStory(storyList,draftTitle);
|
var draftTitle = draftTiddler.fields.title,
|
||||||
this.replaceFirstTitleInStory(storyList,title,draftTitle);
|
storyList = this.getStoryList();
|
||||||
this.addToHistory(draftTitle,event.navigateFromClientRect);
|
this.removeTitleFromStory(storyList,draftTitle);
|
||||||
this.saveStoryList(storyList);
|
this.replaceFirstTitleInStory(storyList,title,draftTitle);
|
||||||
return false;
|
this.addToHistory(draftTitle,event.navigateFromClientRect);
|
||||||
|
this.saveStoryList(storyList);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Delete a tiddler
|
// Delete a tiddler
|
||||||
|
@ -345,11 +348,13 @@ NavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) {
|
||||||
if(isRename) {
|
if(isRename) {
|
||||||
this.wiki.deleteTiddler(draftOf);
|
this.wiki.deleteTiddler(draftOf);
|
||||||
}
|
}
|
||||||
// Replace the draft in the story with the original
|
if(!event.paramObject || event.paramObject.suppressNavigation !== "yes") {
|
||||||
this.replaceFirstTitleInStory(storyList,title,draftTitle);
|
// Replace the draft in the story with the original
|
||||||
this.addToHistory(draftTitle,event.navigateFromClientRect);
|
this.replaceFirstTitleInStory(storyList,title,draftTitle);
|
||||||
if(draftTitle !== this.storyTitle) {
|
this.addToHistory(draftTitle,event.navigateFromClientRect);
|
||||||
this.saveStoryList(storyList);
|
if(draftTitle !== this.storyTitle) {
|
||||||
|
this.saveStoryList(storyList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Trigger an autosave
|
// Trigger an autosave
|
||||||
$tw.rootWidget.dispatchEvent({type: "tm-auto-save-wiki"});
|
$tw.rootWidget.dispatchEvent({type: "tm-auto-save-wiki"});
|
||||||
|
@ -381,13 +386,15 @@ NavigatorWidget.prototype.handleCancelTiddlerEvent = function(event) {
|
||||||
// Remove the draft tiddler
|
// Remove the draft tiddler
|
||||||
if(isConfirmed) {
|
if(isConfirmed) {
|
||||||
this.wiki.deleteTiddler(draftTitle);
|
this.wiki.deleteTiddler(draftTitle);
|
||||||
if(originalTiddler) {
|
if(!event.paramObject || event.paramObject.suppressNavigation !== "yes") {
|
||||||
this.replaceFirstTitleInStory(storyList,draftTitle,originalTitle);
|
if(originalTiddler) {
|
||||||
this.addToHistory(originalTitle,event.navigateFromClientRect);
|
this.replaceFirstTitleInStory(storyList,draftTitle,originalTitle);
|
||||||
} else {
|
this.addToHistory(originalTitle,event.navigateFromClientRect);
|
||||||
this.removeTitleFromStory(storyList,draftTitle);
|
} else {
|
||||||
|
this.removeTitleFromStory(storyList,draftTitle);
|
||||||
|
}
|
||||||
|
this.saveStoryList(storyList);
|
||||||
}
|
}
|
||||||
this.saveStoryList(storyList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -58,17 +58,20 @@ exports.setTextReference = function(textRef,value,currTiddlerTitle) {
|
||||||
this.setText(title,tr.field,tr.index,value);
|
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
|
// Check if it is a reference to a tiddler field
|
||||||
if(index) {
|
if(index) {
|
||||||
var data = this.getTiddlerData(title,Object.create(null));
|
var data = this.getTiddlerData(title,Object.create(null));
|
||||||
data[index] = value;
|
data[index] = value;
|
||||||
this.setTiddlerData(title,data,this.getModificationFields());
|
this.setTiddlerData(title,data,modificationFields);
|
||||||
} else {
|
} else {
|
||||||
var tiddler = this.getTiddler(title),
|
var tiddler = this.getTiddler(title),
|
||||||
fields = {title: title};
|
fields = {title: title};
|
||||||
fields[field || "text"] = value;
|
fields[field || "text"] = value;
|
||||||
this.addTiddler(new $tw.Tiddler(tiddler,fields,this.getModificationFields()));
|
this.addTiddler(new $tw.Tiddler(creationFields,tiddler,fields,modificationFields));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
title: $:/SiteSubtitle
|
||||||
|
|
||||||
|
turning text into tiddlers
|
|
@ -0,0 +1,3 @@
|
||||||
|
title: $:/SiteTitle
|
||||||
|
|
||||||
|
Text-Slicer Edition
|
|
@ -1,6 +1,6 @@
|
||||||
caption: action-setfield
|
caption: action-setfield
|
||||||
created: 20141025120850184
|
created: 20141025120850184
|
||||||
modified: 20150220162114000
|
modified: 20150806171403798
|
||||||
tags: Widgets ActionWidgets
|
tags: Widgets ActionWidgets
|
||||||
title: ActionSetFieldWidget
|
title: ActionSetFieldWidget
|
||||||
type: text/vnd.tiddlywiki
|
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 |
|
|$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|
|
|$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 |
|
|$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 |
|
|//{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
|
! Examples
|
||||||
|
|
|
@ -240,3 +240,5 @@ Richard Smith, @richardwsmith 2015/05/22
|
||||||
Marco Rimoldi, @marcor, 2015/06/26
|
Marco Rimoldi, @marcor, 2015/06/26
|
||||||
|
|
||||||
Slobodan Vujnovic, @slovuj, 2015/06/30
|
Slobodan Vujnovic, @slovuj, 2015/06/30
|
||||||
|
|
||||||
|
Anthon Nilsson, @superdos, 2015/08/06
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
title: $:/tags/TextSlicerToolbar
|
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">
|
<$list filter="[<tv-show-toolbar>prefix[yes]]" variable="hasToolbar">
|
||||||
{{||$:/plugins/tiddlywiki/text-slicer/templates/tiddler-toolbar}}
|
{{||$:/plugins/tiddlywiki/text-slicer/templates/tiddler-toolbar}}
|
||||||
</$list>
|
</$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>
|
||||||
|
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>>/>
|
<$edit-text tag="input" tiddler=<<renameProxyTitle>> placeholder="Rename" default=<<currentTiddler>>/>
|
||||||
<$button>
|
<$button>
|
||||||
<$action-sendmessage $message="tm-rename-tiddler" from=<<currentTiddler>> to={{$(renameProxyTitle)$}}/>
|
<$action-sendmessage $message="tm-rename-tiddler" from=<<currentTiddler>> to={{$(renameProxyTitle)$}}/>
|
||||||
|
<$action-deletetiddler $tiddler=<<renameProxyTitle>>/>
|
||||||
rename
|
rename
|
||||||
</$button>
|
</$button>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
<<body>>
|
<$list filter="[draft.of<currentTiddler>limit[1]]" emptyMessage="""<<body>>""">
|
||||||
|
</$list>
|
||||||
|
|
Ładowanie…
Reference in New Issue