Does the "text" field store data differently to other fields?

166 views
Skip to first unread message

si

unread,
May 14, 2021, 3:09:28 PM5/14/21
to TiddlyWiki
I've create a button that will move the contents of the "text" field of one tiddler into a different field ("text-history") of another tiddler.

I anticipate in the future doing this with text fields that contain a lot of content, including new lines, html tables, macro definitions etc. Since fields appear on only one line I'm wondering if any formatting information could be lost during this process?

I've done a test that involves new lines, and it seems that this data is retained, but I'm just wondering if there is something that I might not be anticipating, or will I always be able to transfer text back and forth without losing anything?

Mohammad Rahmani

unread,
May 14, 2021, 3:10:00 PM5/14/21
to tiddl...@googlegroups.com
I would recommend using a JSON tiddler!
If you store text of tidA then you can have tidA-History to keep these!

Best wishes
Mohammad


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/96c27860-b58b-4bb6-a828-730880ed5cc6n%40googlegroups.com.

si

unread,
May 14, 2021, 3:26:51 PM5/14/21
to TiddlyWiki
Yep this is what I had initially decided, however I have a slightly idiosyncratic use case which means that it will be easier for me to use fields.

Hence why I just wanted to know if I will potentially lose any data by going down this route.

si

unread,
May 15, 2021, 11:11:39 AM5/15/21
to TiddlyWiki
Sorry to bump this but I did a little test and looked at the source to see how the data was stored.

I create a tiddler like this:

tiddler.png

Then I used action-setfield to move the text to a field called "test". When I looked at the source I saw this:

source-div.png

So it looks to my non-technical eyes that "text" is stored in the <pre> element, and other fields within the <div> tag. However it also seems that all the information was retained.

Can anyone with knowledge of TiddlyWiki internals confirm that this safe to do, or are there instances where I could lose data?

JWHoneycutt

unread,
May 15, 2021, 7:35:53 PM5/15/21
to TiddlyWiki
"Does the "text" field store data differently to other fields?"

I am not an expert, but think I know the answer to your question, and would love to be corrected.

Text fields are handled the "same" as any other field. That said, the tiddlywiki core or your overriding viewtemplate tiddlers can change the display behavior.
I would use this to find these tiddlers:

<$list filter="[tag[$:/tags/ViewTemplate]]" >

</$list>

JWHoneycutt

si

unread,
May 16, 2021, 8:07:17 AM5/16/21
to TiddlyWiki
@JWHoneycutt Although it behaves the same as other fields within TiddlyWiki, it does seem the the contents of the "text" field is stored differently to other fields (see my previous post).

My question is more about whether this matters when copying content from the text of a tiddler into a different field. I realize now that I have made the title of this thread is too general, so at some point I will probably make another post that gets more to the point.

PMario

unread,
May 16, 2021, 10:12:19 AM5/16/21
to TiddlyWiki
On Sunday, May 16, 2021 at 2:07:17 PM UTC+2 si wrote:
My question is more about whether this matters when copying content from the text of a tiddler into a different field.

The HTML spec says this:  https://html.spec.whatwg.org/#attributes ... There is no restriction on the text, that can be put into a attribute value. .. BUT it has to be HTML escaped. ... As your screenshot shows.
 
BUT .. The problem is the TW UI.

If you copy text from the text-field with javascript into a field, you can add whitespace to the field. If you use a text area, you can also add whitespace eg: newLines. ... BUT if you edit a field in tiddler-edit-mode, with the single-line editor, all the NewLines and other whitespace will be removed.

So that's the real problem here.

-mario

Saq Imtiaz

unread,
May 16, 2021, 10:21:03 AM5/16/21
to TiddlyWiki
As @pmario states, you will need a custom editing UI for multiline fields.

Also worth noting is that on node.js, tiddlers with multiline fields are saved as JSON and not in the .tid format.

si

unread,
May 16, 2021, 4:44:51 PM5/16/21
to TiddlyWiki
Thanks a lot Mario and Saq, that's exactly what I needed to know. I don't intent to edit any of these fields, so I should be OK, but I'll have a think about whether it will be more sensible to use JSON. Thanks again.

TW Tones

unread,
May 17, 2021, 12:12:54 AM5/17/21
to TiddlyWiki
Si,

Just to back this up it is possible, there may be some issues saving on node (untested). 

However All you have to do is hide the additional text field and not edit it in the Edit View fields.

If you place hide in a tiddler named  $:/config/EditTemplateFields/Visibility/fieldname it will not appear as a row in the edit fields.

Attached is a macro I am quite proud off, it allows the addition of a local-viewtemplate field on any tiddler, However its not yet being polished for publishing. just add the fieldname local-viewtemplate to any tiddler and an additional edit area is available in edit view, the content is applied to this tiddler only when in the view tiddler mode.

This makes it easy to test prototype changes to the view template without actually changing the shared global one and much more.

Tones
local-viewtemplate.json

si

unread,
May 17, 2021, 12:54:28 PM5/17/21
to TiddlyWiki
Hi Tones

>>> If you place hide in a tiddler named  $:/config/EditTemplateFields/Visibility/fieldname it will not appear as a row in the edit fields.

I was going to look up how to do this but you got there ahead of me - thanks!

>>> Attached is a macro I am quite proud off, it allows the addition of a local-viewtemplate field on any tiddler

Thanks for sharing. This concept will be very useful when I add a "summary" or "description" field to some of my tiddlers.

TW Tones

unread,
May 17, 2021, 7:13:50 PM5/17/21
to TiddlyWiki
Si,

Good, I hoped it would be helpful.

Tones

Reply all
Reply to author
Forward
0 new messages