Inline Editor Template?

78 views
Skip to first unread message

Lisa Wasserman

unread,
Apr 22, 2020, 3:44:29 PM4/22/20
to TiddlyWiki
I am using TW to sort notes by creation date and project tag.  When I select a project, I open a tiddler containing all of the entries for that project, sorted by date, descending.  I would like this tiddler to contain an editor that allows me to create/update a project entry for today's date.  So far, I've split my entries into two lists, one with today's entry, and one with the older entries, then displayed them using difference view templates.

<$list filter="[!has[draft.of]tag[journal]field:project{!!project}days:created[-1]]">
<p><h2>Today</h2></p>
{{||$:/core/ui/EditTemplate/body}}
</$list>
<$list filter="[!has[draft.of]tag[journal]field:project{!!project}!days:created[-1]sort[created]]">
<p><h2><$view field="modified" format="date" template="DD-MMM-YYYY"/></h2></p>
<p><$transclude mode="block" /></p>
<p>Tasks</p>
<
<list-tagged-draggable tag:"task" subFilter:"!has[draft.of]project{!!project}sameday:created{!!created}" itemTemplate:"TaskManagementExampleDraggableTemplate" emptyMessage:"None">>
<br />
</$list>


Using $:/core/ui/EditTemplate/body, I got something that looks like the following:


tw_example.PNG


The buttons produce markup in the textbox.  That said, if I actually want to edit and save my current day's entry, I assume that it's a little more complicated than what I currently have.  


I had thought to add Edit, Accept, and Cancel buttons next to the word "Today"', and use them to trigger the edit and save tiddler messages, however,  thought that that would just create a new copy of the tiddler in the river.  Also, I was wondering if I had to edit a draft version of my tiddler.  


Does anyone know how to make a functional, inline editor for a tiddler?


--L. Wasserman



Mat

unread,
Apr 22, 2020, 4:21:53 PM4/22/20
to TiddlyWiki
Hi Linda

Sure, there's the edittext widget made for this. I don't understand exactly how you want it presented but one could imagine you have the list of tiddler titles and next to each tiddler there's a button that opens the editor "mid list" so that you can edit it. The button would be a revealwidget, set up as an "accordion". That could be made something like so:

\define state() $:/state/$(currentTiddler)$

<$list filter="[tag[HelloThere]]">
<$set name=state value=<<state>>>
   
<$reveal type="nomatch" state=<<state>> text="show">
     
<$button set=<<state>> setTo="show">edit</$button>
   </
$reveal>
   
<$reveal type="match" state=<<state>> text="show">
     
<$button set=<<state>> setTo="hide">close</$button>
      <$edit-text class="myclass"/
>
   
</$reveal>
</
$set>
<$link/>
<br>
</$list>

<style>
.myclass {width:100%}
</
style>

<:-)

Saq Imtiaz

unread,
Apr 22, 2020, 4:58:21 PM4/22/20
to TiddlyWiki
Are the contents of the editor displayed correctly, and correspond to the correct tiddler? If so, that editor already works and will save each keystroke as you type it.  Which means, you can't discard your changes and go back to the previous saved version. If that's OK then your editor is already up and running. The normal editor goes through a draft mechanism to allow you to discard your changes without saving them and revert to the last saved version.

The template you transcluded contains the EditText widget, so if you don't want the toolbar buttons for the editor, you can also just add an EditText widget directly.

However, I think your code as it is will only show today's project entry if it already exists. The quick solution to that might be to add a button at the top to create a project entry for today, look at documentation for the Button and ActionCreateTiddler widgets on how to create a tiddler invisibly in the background.

Alternatively, depending on the naming conventions of your journal tiddlers, you should be able to set it up so that it displays an empty editor if there is no journal for today, and typing creates one. (Hint: use SetWidget and filters to create a variable with the title that today's journal should have, and use that instead of the first List)
Reply all
Reply to author
Forward
0 new messages