Editing fields in the current Tiddler in view mode

293 views
Skip to first unread message

TonyM

unread,
Jul 22, 2019, 8:24:17 PM7/22/19
to TiddlyWiki
Editing fields in the current Tiddler in view mode is tricky at the beginning because the field you are editing keeps loosing focus.

Here is a quick solution to this issue.

The simplest approach is to place the following in a tiddler tagged $:/tags/ViewTemplate
<$edit-text field="description"/>

Then wrap the above in a list widget to have it appear selectively such as only on tiddlers that already have the description field.

Alternatively place he above in a template tiddler and transclude that In the view template tiddler

in a tiddler tagged $:/tags/ViewTemplate
{{||yourtemplate}}
However if you use the above directly (typed in the body) in a random tiddler you will experience the same lost of focus issue. 

Using it through the view template works because what you are looking at is the rendering of the view template not your current tiddler. 
You may want to fold the tiddler so you do not see the content twice.

Templates have the advantage of being able to have edits for multiple fields without making the view template tiddlers any more complex. eg
Using template:<br>
Description: <$edit-text field="description"/><br>
Caption: <$edit-text field="caption"/><br>


One way to make it possible to decide in any given tiddler if you want to edit a field in the current tiddler, when in view mode, is to create a field in any given tiddler called viewtemplate and name your view template eg viewtemplate: testTemplate

Then to activate this add to a tiddler tagged $:/tags/ViewTemplate

<$list filter="[all[current]has[viewtemplate]get[viewtemplate]]" variable="view-template">
  <$transclude tiddler=<
<view-template>>/>
</$list>
So if the template is named in any tiddler the view template will transclude that template. You may want to add a list-before field with the value 

$:/core/ui/ViewTemplate/body in the tiddler tagged 

$:/tags/ViewTemplate

What is nice is if the fields do not exist they are silently created.

If you create your own new tiddler button you can set the viewtemplate field at creation or use a template to create your tiddlers with the view template already set. Or just clone an existing tiddler.

Regards
Tony

TonyM

unread,
Jul 22, 2019, 9:14:04 PM7/22/19
to TiddlyWiki
Also try this for a quick way to edit in the view mode a field on the current tiddler

QuickFieldEdit - edit-field-list

Place this in a tiddler tagged $:/tags/ViewTemplate
<$list filter="[all[current]has[edit-field-list]]" variable=nul>
   <$list filter={{!!edit-field-list}} variable=named-field>
      <
<named-field>> <$edit-text field=<<named-field>>/><br>
   </$list>
</$list>

Now in any tiddler place a list of field names (space separated) in a field called edit-field-list eg
caption description

And you can edit these as text fields in the view mode.

Regards
Tony

TonyM

unread,
Jul 22, 2019, 9:45:13 PM7/22/19
to TiddlyWiki
Editing the text field in the current Tiddler in view mode


in a tiddler tagged $:/tags/ViewTemplate
<$list filter="[is[current]edit-inline[yes]]" variable=null>
  {{||$:/core/ui/EditTemplate/body/editor}}
</$list>

Now set the field edit-inline on any tiddler to yes and you can edit the text directly.

Some editor toolbar buttons do not work with this method.

Regards
Tony

Mat

unread,
Jul 22, 2019, 10:01:59 PM7/22/19
to TiddlyWiki
Some editor toolbar buttons do not work with this method.

My head is a bit mushy at this hour so forgive me if I misunderstand you or say exactly what you already meant, this how about an "edit-this-button" that *toggles* to activate the viewtemplate or some of the solutions you've described so it is activated when you need it.

<:-)

Mohammad

unread,
Jul 22, 2019, 11:02:45 PM7/22/19
to TiddlyWiki
Added to TW-Scripts.

TonyM

unread,
Jul 23, 2019, 12:37:53 AM7/23/19
to TiddlyWiki
Mat,

To clarify your mushy mind
  • Editing the text field in the current Tiddler in view mode works if you set the field edit-inline on any tiddler to yes and you can edit the text directly.
  • The editor is displayed with all the editor toolbar buttons, some of these will not work in this mode, such as the preview button.
However a designer may wish to provide their own button or checkbox to toggle the field edit-inline to yes or no.

Regards
Tony

PMario

unread,
Jul 23, 2019, 7:27:49 AM7/23/19
to TiddlyWiki
Hi Tony,

Nice stuff. ...

Please also vote for this PR at github: https://github.com/Jermolene/TiddlyWiki5/pull/4113  ... If this PR would be merged, we wouldn't need to add workarounds, because the core would be able to do it.

-m
Reply all
Reply to author
Forward
0 new messages