Editor toolbar button that toggles a tag?

259 views
Skip to first unread message

Ittay Dror

unread,
Mar 19, 2020, 4:35:47 AM3/19/20
to TiddlyWiki
How can I toggle a tag on a tiddler using a toolbar button? Alternatively, my real goal is to toggle a css class name on the tiddler (and I saw this can be done by tagging it)

Ittay Dror

unread,
Mar 19, 2020, 4:40:31 AM3/19/20
to TiddlyWiki
And I now realized it needs to toggle the stylesheet for the editor as well (my goal is to have an RTL toggle button)

Mat

unread,
Mar 19, 2020, 1:23:01 PM3/19/20
to TiddlyWiki
Is this what you want: A tiddler toolbar button that toggles the $:/tags/Stylesheet tag on a tiddler.

<:-)

Ittay Dror

unread,
Mar 20, 2020, 1:12:34 AM3/20/20
to TiddlyWiki


On Thursday, 19 March 2020 19:23:01 UTC+2, Mat wrote:
Is this what you want: A tiddler toolbar button that toggles the $:/tags/Stylesheet tag on a tiddler.


My end goal is to toggle the 'direction: rtl;' style for the tiddler and the editor while editing that tiddler (but only for such tiddlers). I saw that for a tiddler this is possible by tagging it with some tag (say 'rtl') and creating a stylesheet tiddler that styles .tc-tagged-<tiddler> (e.g. .tc-tagged-rtl). I don't know what is the approach for the editor itself. 

Jeremy Ruston

unread,
Mar 20, 2020, 6:59:01 AM3/20/20
to tiddl...@googlegroups.com
If you were able to just use the existing tagging mechanism to toggle the “rtl” tag then all you need is the following text in a stylesheet tiddler tagged $:/tags/Stylesheet:

\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline macrocallblock

.tc-tiddler-frame.tc-tagged-rtl textarea.tc-edit-texteditor {
background: red;
direction: rtl;
}

Best wishes

Jeremy

--
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/c33325d4-1e4a-475e-84fe-2ea593d82a83%40googlegroups.com.

Ittay Dror

unread,
Mar 20, 2020, 7:38:10 AM3/20/20
to tiddl...@googlegroups.com
On Fri, 20 Mar 2020 at 12:59, Jeremy Ruston <jeremy...@gmail.com> wrote:
If you were able to just use the existing tagging mechanism to toggle the “rtl” tag then all you need is the following text in a stylesheet tiddler tagged $:/tags/Stylesheet:

\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline macrocallblock

.tc-tiddler-frame.tc-tagged-rtl textarea.tc-edit-texteditor {


The optimal thing for me would be to have a toolbar button (to toggle the tag, or something else)

And wouldn't the styling you suggested change the text editor to always be RTL? I want it to be RTL only when a tiddler is (tagged as) RTL. 

Thanks,
Ittay 

Jeremy Ruston

unread,
Mar 20, 2020, 8:09:47 AM3/20/20
to TiddlyWiki
Hi Ittay

The optimal thing for me would be to have a toolbar button (to toggle the tag, or something else)

Create a tiddler with the following fields:

title: $:/core/ui/EditorToolbar/rtl
tags: $:/tags/EditorToolbar
icon: $:/core/images/right-arrow
caption: RTL
description: Toggle Right To Left
condition: [<targetTiddler>!has[type]] [<targetTiddler>type[text/vnd.tiddlywiki]]

And the following text:

<$list filter="[<targetTiddler>tag[rtl]]" variable="ignore" emptyMessage="""
<$action-listops $tiddler=<<targetTiddler>> $tags="+rtl"/>
""">
<$action-listops $tiddler=<<targetTiddler>> $tags="-rtl"/>
</$list>

And wouldn't the styling you suggested change the text editor to always be RTL? I want it to be RTL only when a tiddler is (tagged as) RTL. 

The selector I’ve used includes .tc-tagged-rtl so that it only applies to tiddlers with the tag “rtl”.

Best wishes

Jeremy.


Thanks,
Ittay 

--
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.

Mohammad

unread,
Mar 20, 2020, 12:13:48 PM3/20/20
to TiddlyWiki
WOW!!
This is absolutely amazing and is very good news for all who uses right-to-left languages like

Persian, Arabic, Hebrew, Azeri, Kurdish, Urdu, Aramaic, ...

I tested this in TW 5.1.22p and it works like a charm.

One more question:

In RTL mode, it would be great if when edit tiddler
  • Have title in RTL
  • possibility to have caption or other fields in RTL
I also added a little css (as below) to show the tiddler body in RTL when view it

.tc-tiddler-frame.tc-tagged-rtl .tc-tiddler-body{
direction
: rtl;
}



--Mohammad


On Friday, March 20, 2020 at 3:39:47 PM UTC+3:30, Jeremy Ruston wrote:
Hi Ittay

The optimal thing for me would be to have a toolbar button (to toggle the tag, or something else)

Create a tiddler with the following fields:

title: $:/core/ui/EditorToolbar/rtl
tags: $:/tags/EditorToolbar
icon: $:/core/images/right-arrow
caption: RTL
description: Toggle Right To Left
condition: [<targetTiddler>!has[type]] [<targetTiddler>type[text/vnd.tiddlywiki]]

And the following text:

<$list filter="[<targetTiddler>tag[rtl]]" variable="ignore" emptyMessage="""
<$action-listops $tiddler=<<targetTiddler>> $tags="+rtl"/>
""">
<$action-listops $tiddler=<<targetTiddler>> $tags="-rtl"/>
</$list>

And wouldn't the styling you suggested change the text editor to always be RTL? I want it to be RTL only when a tiddler is (tagged as) RTL. 

The selector I’ve used includes .tc-tagged-rtl so that it only applies to tiddlers with the tag “rtl”.

Best wishes

Jeremy.


Thanks,
Ittay 

--
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 tiddl...@googlegroups.com.

Mohammad

unread,
Mar 20, 2020, 12:14:09 PM3/20/20
to TiddlyWiki
Added to TW-Scripts.


On Friday, March 20, 2020 at 3:39:47 PM UTC+3:30, Jeremy Ruston wrote:
Hi Ittay

The optimal thing for me would be to have a toolbar button (to toggle the tag, or something else)

Create a tiddler with the following fields:

title: $:/core/ui/EditorToolbar/rtl
tags: $:/tags/EditorToolbar
icon: $:/core/images/right-arrow
caption: RTL
description: Toggle Right To Left
condition: [<targetTiddler>!has[type]] [<targetTiddler>type[text/vnd.tiddlywiki]]

And the following text:

<$list filter="[<targetTiddler>tag[rtl]]" variable="ignore" emptyMessage="""
<$action-listops $tiddler=<<targetTiddler>> $tags="+rtl"/>
""">
<$action-listops $tiddler=<<targetTiddler>> $tags="-rtl"/>
</$list>

And wouldn't the styling you suggested change the text editor to always be RTL? I want it to be RTL only when a tiddler is (tagged as) RTL. 

The selector I’ve used includes .tc-tagged-rtl so that it only applies to tiddlers with the tag “rtl”.

Best wishes

Jeremy.


Thanks,
Ittay 

--
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 tiddl...@googlegroups.com.

Ittay Dror

unread,
Mar 20, 2020, 2:20:46 PM3/20/20
to TiddlyWiki


On Friday, 20 March 2020 14:09:47 UTC+2, Jeremy Ruston wrote:
And wouldn't the styling you suggested change the text editor to always be RTL? I want it to be RTL only when a tiddler is (tagged as) RTL. 

The selector I’ve used includes .tc-tagged-rtl so that it only applies to tiddlers with the tag “rtl”.



dom.PNG

I've tried this and the text editor is still LTR. Here is the dom:  


The button works. Thanks!

Jeremy Ruston

unread,
Mar 20, 2020, 2:35:31 PM3/20/20
to tiddl...@googlegroups.com
Hi Mohammad

Perhaps we should consider adding a mechanism along these lines to the core to allow tiddlers to be selectively written in RTL. It would need some more work; for example, a means of respecting the RTL setting of transcluded text might be useful.

Best wishes

Jeremy

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/1681b6da-4c47-4f39-b1d4-c5c3099b8391%40googlegroups.com.

Mohammad

unread,
Mar 20, 2020, 3:03:23 PM3/20/20
to TiddlyWiki
Hi Jeremy,

On Friday, March 20, 2020 at 10:05:31 PM UTC+3:30, Jeremy Ruston wrote:
Hi Mohammad

Perhaps we should consider adding a mechanism along these lines to the core to allow tiddlers to be selectively written in RTL. It would need some more work; for example, a means of respecting the RTL setting of transcluded text might be useful.

That's true. By the way it will open opportunity to have not only mixed type of tiddlers, RTL and LTR, but also bidirectional text in one tiddler. I am looking forward to have this feature.
As I noted in the above post, there are a lot of people write in RTL and having a bidirectional Tiddlywiki is absolutely very interesting for such people. 

Best wishes
 

Jeremy


Mohammad 

Mohammad

unread,
Mar 20, 2020, 3:04:29 PM3/20/20
to TiddlyWiki
Ittay,
 Could you try this in TW 5.1.22 prerelease?

--Mohammad

Mohammad

unread,
Mar 21, 2020, 2:57:33 PM3/21/20
to TiddlyWiki
Based on Jeremy instruction, a sample Tiddlywiki with RTL button and sample Persian tiddlers is available here:

--Mohammad

On Friday, March 20, 2020 at 3:39:47 PM UTC+3:30, Jeremy Ruston wrote:
Hi Ittay

The optimal thing for me would be to have a toolbar button (to toggle the tag, or something else)

Create a tiddler with the following fields:

title: $:/core/ui/EditorToolbar/rtl
tags: $:/tags/EditorToolbar
icon: $:/core/images/right-arrow
caption: RTL
description: Toggle Right To Left
condition: [<targetTiddler>!has[type]] [<targetTiddler>type[text/vnd.tiddlywiki]]

And the following text:

<$list filter="[<targetTiddler>tag[rtl]]" variable="ignore" emptyMessage="""
<$action-listops $tiddler=<<targetTiddler>> $tags="+rtl"/>
""">
<$action-listops $tiddler=<<targetTiddler>> $tags="-rtl"/>
</$list>

And wouldn't the styling you suggested change the text editor to always be RTL? I want it to be RTL only when a tiddler is (tagged as) RTL. 

The selector I’ve used includes .tc-tagged-rtl so that it only applies to tiddlers with the tag “rtl”.

Best wishes

Jeremy.


Thanks,
Ittay 

--
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 tiddl...@googlegroups.com.

Julio Peña

unread,
Mar 21, 2020, 4:29:40 PM3/21/20
to TiddlyWiki
Wow Mohammad,

Thanks for sharing...I always wanted to do something 
like this but never got around to figuring it out.
Good stuff!

Best regards,
Julio

Mohammad

unread,
Mar 22, 2020, 12:41:35 AM3/22/20
to TiddlyWiki
Julio,
 What I learned is how to add such action to EditorToolbar with that details, for examples I did not know about conditions field.

Mohammad -:)

Ittay Dror

unread,
Mar 22, 2020, 3:32:33 AM3/22/20
to TiddlyWiki
On Saturday, 21 March 2020 20:57:33 UTC+2, Mohammad wrote:
Based on Jeremy instruction, a sample Tiddlywiki with RTL button and sample Persian tiddlers is available here:


Does the styling of the editor text area work for you? Because I can't see there is a tc-tagged-rtl on the tc-editor-frame or anything inside it (there is on the tiddler when not edited) 

Mohammad

unread,
Mar 22, 2020, 4:19:51 AM3/22/20
to TiddlyWiki
If you mean the background:red, NO, it does not work for me!
But if you look at the demo page other settings work. Jeremy may have a better explanation. 

Jeremy Ruston

unread,
Mar 22, 2020, 4:51:59 AM3/22/20
to tiddl...@googlegroups.com
I should have added that the RTL code I gave won't work with the CodeMirror editor, you'll need to be using the plain text editor.

Best wishes

Jeremy


On 22 Mar 2020, at 08:19, Mohammad <mohammad...@gmail.com> wrote:


--
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/f05554ca-415b-41d6-a673-1a334ee0f92f%40googlegroups.com.

Mohammad

unread,
Mar 22, 2020, 4:55:41 AM3/22/20
to TiddlyWiki
Hi Jeremy,
 That is true, but even with plain text editor
background: red;


does not work!


On Sunday, March 22, 2020 at 1:21:59 PM UTC+4:30, Jeremy Ruston wrote:
I should have added that the RTL code I gave won't work with the CodeMirror editor, you'll need to be using the plain text editor.

The codeMirror seems to have its own bidirectional and rtl feature. 

Best wishes


On 22 Mar 2020, at 08:19, Mohammad <mohamma...@gmail.com> wrote:




On Sunday, March 22, 2020 at 12:02:33 PM UTC+4:30, Ittay Dror wrote:
On Saturday, 21 March 2020 20:57:33 UTC+2, Mohammad wrote:
Based on Jeremy instruction, a sample Tiddlywiki with RTL button and sample Persian tiddlers is available here:


Does the styling of the editor text area work for you? Because I can't see there is a tc-tagged-rtl on the tc-editor-frame or anything inside it (there is on the tiddler when not edited) 

If you mean the background:red, NO, it does not work for me!
But if you look at the demo page other settings work. Jeremy may have a better explanation. 

--
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 tiddl...@googlegroups.com.

Ittay Dror

unread,
Mar 22, 2020, 5:11:05 AM3/22/20
to tiddl...@googlegroups.com
How do I choose the plain text editor (other than disabling the plugin)? 

You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/pCbeguJHusQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/7F214B01-13C8-49AA-AF9B-1E5BA6A30D07%40gmail.com.

Ittay Dror

unread,
Mar 22, 2020, 5:12:26 AM3/22/20
to tiddl...@googlegroups.com
I have another tiddlywiki with no plugins (except for the core) and the DOM structure is the same. No tc-tagged-rtl class

Jeremy Ruston

unread,
Mar 22, 2020, 1:05:17 PM3/22/20
to TiddlyWiki
Hi Mohammad

Hi Jeremy,
 That is true, but even with plain text editor
background: red;


Apologies, it was confusing of me to have left that in there. Since v5.1.21 the edit-text widget sets the background colour of the text box to the "tiddler-editor-background” colour from the current palette, overriding anything set via CSS. To avoid this behaviour just leave that palette entry blank.

Best wishes

Jeremy


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/6c9f11a1-9b65-4512-b037-799ce3c4234e%40googlegroups.com.

Mohammad

unread,
Mar 22, 2020, 1:20:56 PM3/22/20
to TiddlyWiki
Many thanks Jeremy!

Cheers
Mohammad
Hi Mohammad

Reply all
Reply to author
Forward
0 new messages