Extensible Edit Template definitions

77 views
Skip to first unread message

Matthew Lauber

unread,
Feb 6, 2019, 9:31:23 AM2/6/19
to TiddlyWikiDev
All, 
   Right now, we've got two types of Edit Templates, one for text and one for images.  In one of my recent plugins (https://github.com/mklauber/tw-CreatureManager) I ended up overwriting a bit of the core in order to implement a third type (for editing tiddlers with type "Creature").  In doing so, I realized it would be possible to implement an extensible EditTemplate system, where users could create edit templates for new types of tiddlers.  If you look at https://github.com/mklauber/tw-CreatureManager/blob/master/%24__core_ui_EditTemplate.tid#L17 I check for a tiddler titled $:/core/uiEditTemplate/$type$, before defaulting to $:/core/ui/EditTemplate/default where I put the original contents of $:/core/ui/EditTemplate.  Is this a good use of the type field, and what do people think of this as functionality?  Is it something you'd like to see in the core?

Matt Lauber

TonyM

unread,
Feb 6, 2019, 6:11:03 PM2/6/19
to TiddlyWikiDev
Matt,

Others can comment if this is the best approach. However the desire for an "extensible EditTemplate system" is there, however this also exists for an "extensible ViewTemplate system". Personally I have proposed previously the concept of an intermediate "Update Template", a view of the tiddler that has selected update or edit fields displayed. But of course we may use more templates. The idea of an update template is you can switch it on or off, depending on the user and wiki update rights. It would make TiddlyWiki more capable of Internet 2.0+ CMS by not forcing edits to take place in the default editor, but in a customised presentation.

I have in fact built a custom update template that is displayed from the view template when selected. What appears is dependant on an update-list field containing the fields and their order in which to appear on the update view. To assist I have also defined each field used and provided  "field edit code" for example using the image picker on the field icon, colour selector on color field, edit-text fields on others and time stamps date pickers on others etc....

I have taken this field definition concept further an include a definition for each field that is used when listing tiddlers, that is that field in a table, it includes definition of the column header, display method in table cells and more.

I also want to create a template that appears on the "Viewer", for all tiddlers (currentTiddler aware), and another for each tiddler in a toc internal nav outliner. See this as an example
<$macrocall
        $name="toc-tabbed-internal-nav"
        tag="TableOfContents"
        selectedTiddler="$:/temp/toc/selectedTiddler"
        unselectedText="
<p>Select a topic in the table of contents. Click the arrow to expand a topic.</p>"
        missingText="
<p>Missing tiddler.</p>"
/>

My point being that what you suggest is called for, how it is done should support other requirments and methods with serious merit.

Regards
Tony

TonyM

unread,
Feb 6, 2019, 7:36:41 PM2/6/19
to TiddlyWikiDev
Co-indecently this Request would benifit from easy use of alternate view, update and edit templates within a tabbed internal toc

Jeremy Ruston

unread,
Feb 7, 2019, 6:42:43 AM2/7/19
to TiddlyWikiDev
Hi Matt

The current implementation in the core does not exactly have two separate edit templates for text and images. Instead the ability to edit multiple content types is implemented by the <$edit> widget deferring to type-specific variants for images, text, etc. Thus, if one wanted to add a new type of editor for a new content type called "jack" using the MIME type "foo/bar", one would add a new <$edit-jack> widget, and then create a tiddler $:/config/EditorTypeMappings/foo/bar with the content "jack" that points the content type "foo/bar" to the <$edit-jack> widget.

Best wishes

Jeremy.

Matthew Lauber

unread,
Feb 7, 2019, 4:00:49 PM2/7/19
to TiddlyWikiDev
Hey Jeremy, 

 Thanks for that information.  That actually pointed me in the right direction, to learning that you've already implemented $:/tags/EditTemplate, which does what I was trying to do.  

Matt LAuber
Reply all
Reply to author
Forward
0 new messages