Editing fields as multi-line text

128 views
Skip to first unread message

TW Tones

unread,
Jun 11, 2020, 3:12:36 AM6/11/20
to TiddlyWiki
Folks,

I/We previously found a way to edit additional tiddler fields as text areas. Capable of entering multiple lines.

The only issue was you had to avoid editing them in the edit view fields dialogues or you would loos the line fields.

I can not find anywhere in my notes how we achieved this. 

I have return to this and cloned and hacked the following core tiddlers;

An transclude the new  tiddler like this, rather than  {{||$:/core/ui/EditTemplate/body}} like this {{||$:/PSaT/EditTemplate/body}}

Now the editor appears, has the editorToolBar etc. 

This all works very well but for some reason it only allows one line of text.

I have attached this here but please install on an empty or read only wiki if you want a look.

Create / Edit a tiddler and you will see the edit area below the text editor. The new field is called final-text.

This is a useful tool, that was demonstrated previously but I am unable to track the cause of the problem this time.

Why would such a tool help?

  • It allows a tiddler to have more than one text area field, when only one, the existing text field, is used if the tiddler is transcluded. 
  • Tiddlers can have hidden notes accompanying them
  • For the safety of the editor content I intend to hide it from the field editor, but add it to the edit template.
  • You can build or change view and edit templates do do many things while keeping it in the tiddler.
Thanks in advance
TW Tones aka TonyM




edit-final-text-field.json

Saq Imtiaz

unread,
Jun 11, 2020, 3:18:48 AM6/11/20
to TiddlyWiki
I haven't looked at your code, but the following is all that's needed to have a text area to edit a field:

<$edit-text tiddler=temp field=xyz tag=textarea/>

Pretty sure we have had this capability since we first got custom fields in TWC, though I think at some point there were issues with multiline fields in TW5 on node.js because of the .tid file format. I think to get around that, fields with line breaks trigger saving as .json instead.

Eric Shulman

unread,
Jun 11, 2020, 3:37:54 AM6/11/20
to TiddlyWiki
On Thursday, June 11, 2020 at 12:18:48 AM UTC-7, Saq Imtiaz wrote:
I haven't looked at your code, but the following is all that's needed to have a text area to edit a field:
<$edit-text tiddler=temp field=xyz tag=textarea/>

In addition to the tag="textarea" parameter, I recommend specifying minHeight="1em" and autoHeight="yes"...
and, to make the text area fit the full width of the tiddler editor, include a CSS class (e.g., "width100"), defined as ".width100 { width:100%; }"

For example, if you want to add a multi-line "description" field to the tiddler editor, simply create a tiddler tagged with $:/tags/EditTemplate, containing:
<$edit-text field="description" tag="textarea" minHeight="1em" autoHeight="yes" class="width100" default="" placeholder="enter a description for this tiddler" />

-e



TW Tones

unread,
Jun 11, 2020, 8:24:03 AM6/11/20
to TiddlyWiki
Folks

Thanks for your advice but I am aware of your tips. The problem is getting the edit body template to operate on an additional text field, it is but it refuses to permit multiple lines.

This method would permit use of the tool bar as in saqs streams and other implementations that operate on text fields. In the modified versions I attached I can't identify where I can change the behavior.

Thanks for any other ideas.

Tony

TiddlyTweeter

unread,
Jun 11, 2020, 8:44:03 AM6/11/20
to TiddlyWiki
Didn't Mohammad do this?

As far as I remember he made a tool to edit fields & preserve line breaks. Worked fine but if you edited the field later in the standard editor it reverted to single line?

Something like that. Unfortunately I can't find it.

TT

Saq Imtiaz

unread,
Jun 11, 2020, 8:53:33 AM6/11/20
to TiddlyWiki
@Tony your initial post made it seem like the issue was having and editing multiline text in custom fields. It seems however that your issue is using the framed editor with fields other than text for multiline content.

AFAIK the framed editor will default to using an input element, regardless of the tag specified, for fields other than text unless the field has a definition in fieldModules with an edit tag specified.

Off the top of my head and completely untested, this is would look something like:

$tw.modules.define("$:/boot/tiddlerfields/mycustomfield","tiddlerfield",{
    name: "mycustomfield",
    editTag: "textarea"
});

TW Tones

unread,
Jun 11, 2020, 9:16:30 AM6/11/20
to TiddlyWiki
Saq,

I do think I complicated my initial post. The issue was "having and editing multiline text in custom fields", and sill is but as you say I went onto "using the framed editor with fields other than text". 

You have answered my question in so far as saying it was not just Wiki text macros or widgets that stops the framed editor behaving as I wish.

Perhaps I need to reconsider my approach here.

Thanks
Tony

TW Tones

unread,
Jun 11, 2020, 9:18:52 AM6/11/20
to TiddlyWiki
Tt,

Yes Mohammad did, in fact I think I worked with him on this. The problem is finding it again. But as Saq pointed out I think I complicated it with adding the framed editor.

Which, the truth be known, is a black art to me, placing editors inside frames etc...

Thanks
Tony

Saq Imtiaz

unread,
Jun 11, 2020, 9:25:09 AM6/11/20
to TiddlyWiki
I do think the ability to add definitions for custom fields is a good candidate for something that should be possible via wikitext.
I would encourage you to open an issue Tony.

For the time being you could:
- not use the edit toolbar, which will default the editor to not using the framed editor
- OR if you just need to set up a field or two, we can help you with the JavaScript to do so.

Cheers,
Saq

TW Tones

unread,
Jun 11, 2020, 9:54:58 AM6/11/20
to TiddlyWiki
Saq.

I will go for the first option for now. I can use subtiddlers if I must have the full editor.

Thanks for your kind offer.

If multi text tiddler take off I may raise an issue.

Regards
Tony

Reply all
Reply to author
Forward
0 new messages