Hide Controls for System and Shadow Tiddlers

A normal end user should not be able to accidentally edit or delete shadow, system tiddlers. For this reason, I used the below CSS rule:

[data-tiddler-title^="$:/"] .tc-tiddler-controls button:not(
 [aria-label*="close"]
 ){
  display:none;
}

(Note: Create a tiddler, tag it with $:/tags/Stylesheet, set the type to text/css

My question is how to limit this to shadow tiddlers, or specific system tiddlers? Is there any CSS solution or I have to go to use Wikitext and check the tiddler is a shadow tiddler?

Revision 1
This solution is not language specific

[data-tiddler-title^="$:/"] .tc-tiddler-controls button:not(.tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fclose){
  display:none;
}

One drawback here is I used [aria-label*="close"]. What if the TW language set to French or Spanish? So, this is not a good general solution.

1 Like

I think this is a better solution:

[data-tiddler-title^="$:/"] .tc-tiddler-controls button:not(.tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fclose){
  display:none;
}

Tiddler DIVs that are shadows have a class that includes tc-tiddler-shadow.

Try replacing [data-tiddler-title^="$:/"] with .tc-tiddler-shadow, like this:

.tc-tiddler-shadow .tc-tiddler-controls button:not(.tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fclose){
  display:none;
}

-e

2 Likes

Perfect! Thank you, Eric.
I assume if a shadow tiddler is edited, then it is a normal tiddler or a system tiddler (depend to the name prefix), am I right?

This is because if we allow to edit a shadow tiddler, the above rule won’t be applied to such tiddler.

Do these solutions only work from some specific TW version onward? None of them work in my wiki in TW version 5.3.5.

Did you remember to add the $:/tags/Stylesheet tag to the tiddler containing the CSS?

-e

Yes, I did. I also tried adding the lines to a stylesheet tiddler that already worked, without success. I will check everything again, probably made a silly mistake.

The solution works on all recent TW versions including 5.3.5.
Check your tiddler for tag ($:/tags/Stylesheet), and type (text/css)
Also look at the new TW-Utility which uses this solution.

After some fiddling, including refreshing the wiki, it now partly works.

The code in the ‘edit blocker’ tiddler is now (Mohammad’s solution):

[data-tiddler-title^="$:/"] .tc-tiddler-controls button:not(.tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fclose)
{
  display:none;
}

So editing should be blocked for ALL system tiddlers, including shadow tiddlers. BUT: only editing of shadow tiddlers is blocked now. Other system tiddlers can still be edited.

BTW, using the last code by Eric (with the .tc-tiddler-shadow class) has the same result, but this is as it should be of course.

Still confused…

can you share a minimal demo wiki on tiddlyhost?

Could you test this on empty.html (no plugin)?

  1. I took an empty TW from the site (5.3.6) and copied the edit blocker tiddler to it (the version that blocks editing any tiddler starting with ‘$:/’). It worked on system tiddlers! The same tiddler did not work in my wiki where it came from (5.3.5).

  2. Then I disabled all plugins in the original wiki, then saved and refreshed. These are:

  • context-menu-plugin
  • simplecalendar
  • mob (JD Mobile layout)
  • Menu Bar
  • Search in Fields
  • Shiraz
  • Tiddler Commander
  • TiddlyFormula

This caused a little mystery in itself, because at least some of the plugins still worked even after the refresh (I looked at simplecalendar and Menu Bar). Turned out the wiki tab was ‘pinned’ in Firefox. Only after unpinning, saving, closing and reopening the wiki, the plugins were really disabled.

All this had no effect on the ‘edit bug’. With all plugins disbled, I could still edit normal system files, but not shadow files. I created a system tiddler in the empty wiki (empty apart from the edit blocker tiddler). I could not edit it after leaving the editor, but the same tiddler copied into my original wiki was editable there.

  1. I tested the edit blocker on another of my wiki’s (also 5.3.5). It worked perfectly. So the problem lies within at least one specific wiki.

@Mohammad, I will now try to make a minimal demo wiki to put on Tiddlyhost.

Greetings,
Sjaak

For myself, the problem is solved. I decided to experiment a bit with the part of the code after the selection, i.e. after the part between brackets.

Exp. 1. just change color background: worked in all cases
Exp. 2. show no buttons at all (removing ‘:not(…)’ part): worked OK
Exp. 3. show only one other button, so changed ‘close’ into ‘edit’ or ‘info’: worked OK!
Exp. 4. changed ‘info’ back into ‘close’. Hey presto! The code suddenly worked as advertised.

This solves the problem, but not the riddle: the original edit blocker tiddler worked flawlessly from the beginning in another wiki.

I then deleted ALL non-system tiddlers and images from the original wiki, apart from the edit blocker and a few small test-tiddlers. This also solved the problem. So somewhere in those 869 tiddlers the snag must be. I will try to make a few smart guesses and pinpoint the source of the problem, if possible.

Meanwhile, have a good New Year’s Eve and a Happy Healthy 2025!

Greetings,
Sjaak