From fdce67399d175a9911df908981b83ac3edfb1142 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 5 Aug 2015 15:07:19 +0100 Subject: [PATCH 1/5] Provide option to suppress navigation for edit/cancel/save --- core/modules/widgets/navigator.js | 45 ++++++++++++++++++------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/core/modules/widgets/navigator.js b/core/modules/widgets/navigator.js index df2724ec1..de57d9dff 100755 --- a/core/modules/widgets/navigator.js +++ b/core/modules/widgets/navigator.js @@ -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; From cbbe90313b6696188c083ad0e2bba56bc23b3cf0 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 5 Aug 2015 15:08:03 +0100 Subject: [PATCH 2/5] Add in-place editing for text-slicer plugin @pmario \o/ --- .../text-slicer/tag-TextSlicerToolbar.tid | 2 +- .../text-slicer/template-display-tiddler.tid | 4 +++- .../text-slicer/template-edit-tiddler.tid | 11 +++++++++++ plugins/tiddlywiki/text-slicer/toolbar-cancel.tid | 13 +++++++++++++ plugins/tiddlywiki/text-slicer/toolbar-done.tid | 13 +++++++++++++ plugins/tiddlywiki/text-slicer/toolbar-edit.tid | 12 ++++++++++++ plugins/tiddlywiki/text-slicer/toolbar-rename.tid | 3 ++- 7 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 plugins/tiddlywiki/text-slicer/template-edit-tiddler.tid create mode 100644 plugins/tiddlywiki/text-slicer/toolbar-cancel.tid create mode 100644 plugins/tiddlywiki/text-slicer/toolbar-done.tid create mode 100644 plugins/tiddlywiki/text-slicer/toolbar-edit.tid diff --git a/plugins/tiddlywiki/text-slicer/tag-TextSlicerToolbar.tid b/plugins/tiddlywiki/text-slicer/tag-TextSlicerToolbar.tid index ef2f27cd4..d00060b74 100644 --- a/plugins/tiddlywiki/text-slicer/tag-TextSlicerToolbar.tid +++ b/plugins/tiddlywiki/text-slicer/tag-TextSlicerToolbar.tid @@ -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 diff --git a/plugins/tiddlywiki/text-slicer/template-display-tiddler.tid b/plugins/tiddlywiki/text-slicer/template-display-tiddler.tid index 0a4023560..1bf427c5a 100644 --- a/plugins/tiddlywiki/text-slicer/template-display-tiddler.tid +++ b/plugins/tiddlywiki/text-slicer/template-display-tiddler.tid @@ -3,4 +3,6 @@ title: $:/plugins/tiddlywiki/text-slicer/templates/display-tiddler <$list filter="[prefix[yes]]" variable="hasToolbar"> {{||$:/plugins/tiddlywiki/text-slicer/templates/tiddler-toolbar}} -<$list filter="[draft.oflimit[1]]" editTemplate="$:/core/ui/EditTemplate" emptyMessage="""<$transclude mode='block'/>"""/> +<$list filter="[draft.oflimit[1]]" emptyMessage="""<$transclude mode='block'/>"""> +<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/edit-tiddler" mode="block"/> + diff --git a/plugins/tiddlywiki/text-slicer/template-edit-tiddler.tid b/plugins/tiddlywiki/text-slicer/template-edit-tiddler.tid new file mode 100644 index 000000000..1b4080a84 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/template-edit-tiddler.tid @@ -0,0 +1,11 @@ +title: $:/plugins/tiddlywiki/text-slicer/templates/edit-tiddler + +<$set name="storyTiddler" value=<>> +<$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=<>/> + + + + diff --git a/plugins/tiddlywiki/text-slicer/toolbar-cancel.tid b/plugins/tiddlywiki/text-slicer/toolbar-cancel.tid new file mode 100644 index 000000000..935cd77bf --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/toolbar-cancel.tid @@ -0,0 +1,13 @@ +title: $:/plugins/tiddlywiki/text-slicer/toolbar/cancel +tags: $:/tags/TextSlicerToolbar + +\define body() +<$button> +<$action-sendmessage $message="tm-cancel-tiddler" $param=<> suppressNavigation="yes"/> +cancel + +\end + +<$list filter="[draft.oflimit[1]]"> +<> + diff --git a/plugins/tiddlywiki/text-slicer/toolbar-done.tid b/plugins/tiddlywiki/text-slicer/toolbar-done.tid new file mode 100644 index 000000000..cbffcba69 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/toolbar-done.tid @@ -0,0 +1,13 @@ +title: $:/plugins/tiddlywiki/text-slicer/toolbar/done +tags: $:/tags/TextSlicerToolbar + +\define body() +<$button> +<$action-sendmessage $message="tm-save-tiddler" $param=<> suppressNavigation="yes"/> +done + +\end + +<$list filter="[draft.oflimit[1]]"> +<> + diff --git a/plugins/tiddlywiki/text-slicer/toolbar-edit.tid b/plugins/tiddlywiki/text-slicer/toolbar-edit.tid new file mode 100644 index 000000000..be074aab2 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/toolbar-edit.tid @@ -0,0 +1,12 @@ +title: $:/plugins/tiddlywiki/text-slicer/toolbar/edit +tags: $:/tags/TextSlicerToolbar + +\define body() +<$button> +<$action-sendmessage $message="tm-edit-tiddler" $param=<> suppressNavigation="yes"/> +edit + +\end + +<$list filter="[draft.oflimit[1]]" emptyMessage="""<>"""> + diff --git a/plugins/tiddlywiki/text-slicer/toolbar-rename.tid b/plugins/tiddlywiki/text-slicer/toolbar-rename.tid index a11f10bbd..12538744e 100644 --- a/plugins/tiddlywiki/text-slicer/toolbar-rename.tid +++ b/plugins/tiddlywiki/text-slicer/toolbar-rename.tid @@ -13,4 +13,5 @@ rename \end -<> \ No newline at end of file +<$list filter="[draft.oflimit[1]]" emptyMessage="""<>"""> + From b1cf0fdd68ce1966714168304ba94d4f2dee2921 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 5 Aug 2015 19:21:48 +0100 Subject: [PATCH 3/5] Text-slicer tweaks * Add site title/subtitle * Remove proxy title tiddler used for renames when no longer used --- editions/text-slicer/tiddlers/system/SiteSubtitle.tid | 3 +++ editions/text-slicer/tiddlers/system/SiteTitle.tid | 3 +++ plugins/tiddlywiki/text-slicer/toolbar-rename.tid | 1 + 3 files changed, 7 insertions(+) create mode 100644 editions/text-slicer/tiddlers/system/SiteSubtitle.tid create mode 100644 editions/text-slicer/tiddlers/system/SiteTitle.tid diff --git a/editions/text-slicer/tiddlers/system/SiteSubtitle.tid b/editions/text-slicer/tiddlers/system/SiteSubtitle.tid new file mode 100644 index 000000000..d3922b358 --- /dev/null +++ b/editions/text-slicer/tiddlers/system/SiteSubtitle.tid @@ -0,0 +1,3 @@ +title: $:/SiteSubtitle + +turning text into tiddlers \ No newline at end of file diff --git a/editions/text-slicer/tiddlers/system/SiteTitle.tid b/editions/text-slicer/tiddlers/system/SiteTitle.tid new file mode 100644 index 000000000..669384ce6 --- /dev/null +++ b/editions/text-slicer/tiddlers/system/SiteTitle.tid @@ -0,0 +1,3 @@ +title: $:/SiteTitle + +Text-Slicer Edition \ No newline at end of file diff --git a/plugins/tiddlywiki/text-slicer/toolbar-rename.tid b/plugins/tiddlywiki/text-slicer/toolbar-rename.tid index 12538744e..baea5b52d 100644 --- a/plugins/tiddlywiki/text-slicer/toolbar-rename.tid +++ b/plugins/tiddlywiki/text-slicer/toolbar-rename.tid @@ -9,6 +9,7 @@ $:/config/plugins/tiddlywiki/text-slicer/rename-$(currentTiddler)$ <$edit-text tag="input" tiddler=<> placeholder="Rename" default=<>/> <$button> <$action-sendmessage $message="tm-rename-tiddler" from=<> to={{$(renameProxyTitle)$}}/> +<$action-deletetiddler $tiddler=<>/> rename \end From 22563792c49a792c6dbe29a77681d83af5369c9b Mon Sep 17 00:00:00 2001 From: SuperDOS Date: Thu, 6 Aug 2015 15:16:19 +0200 Subject: [PATCH 4/5] Update cla-individual.md --- licenses/cla-individual.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/licenses/cla-individual.md b/licenses/cla-individual.md index 3f4370f5c..63dfac34b 100644 --- a/licenses/cla-individual.md +++ b/licenses/cla-individual.md @@ -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 From e5cd8313a0d1a4a3dea17457a8a883675243b9c7 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 6 Aug 2015 18:17:06 +0100 Subject: [PATCH 5/5] Update actionsetfield widget to allow timestamp to be preserved --- core/modules/widgets/action-setfield.js | 9 ++++++--- core/modules/wiki.js | 9 ++++++--- .../tw5.com/tiddlers/widgets/ActionSetFieldWidget.tid | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/core/modules/widgets/action-setfield.js b/core/modules/widgets/action-setfield.js index 89de61824..7d6681752 100644 --- a/core/modules/widgets/action-setfield.js +++ b/core/modules/widgets/action-setfield.js @@ -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 diff --git a/core/modules/wiki.js b/core/modules/wiki.js index c2c0e22a2..bf53e34c6 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -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)); } }; diff --git a/editions/tw5.com/tiddlers/widgets/ActionSetFieldWidget.tid b/editions/tw5.com/tiddlers/widgets/ActionSetFieldWidget.tid index 91b267fcc..3656accfc 100644 --- a/editions/tw5.com/tiddlers/widgets/ActionSetFieldWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/ActionSetFieldWidget.tid @@ -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