What are some good starting points for learning how to write “safe” or “sanitary” JS in TW? I’ve scoured https://tiddlywiki.com/dev/ - all good stuff about its internals and startup process - but it didn’t really list common (“approved”?) use cases with examples, available hooks, etc.
It depends, what you try to achieve. Can you be a bit more specific, using plain text, what you want to do.
There are some detailed examples, how to create a TW widget, but there is no more info about libraries or other stuff.
Some ideas I’ve had:
- Custom wiki rule (see TW5- Checklist)
- Edit toolbar buttons (I tried cloning the excise button; failed at a custom message handler)
- Popups with custom dialogs (haven’t gotten the action-popup widget working yet)
But your question makes me think the community recommends a different approach to learning how to do this. What’s the recommended path to learning for JS-literate users?
tiddlywiki-starter-kit/plugins/oeyoews at main · oeyoews/tiddlywiki-starter-kit · GitHub The plugins I wrote here are basically js plugins, which may not be suitable for you, but it is definitely worth a look
Basically I copy and modify code from tiddlywiki.
Tiddlywiki uses module-type
for include a set of modules in many places. For the edit operations there is the module-type texteditoroperation
for the tm-edit-text-operation
messages.
I believe all these things can be done with the wikitext TW provides.
There are times when nothing will do but reaching for JS, but the platform is quite capable. I would look to this first.
But if you do want to know, the various widgets, modules, macros, etc. available in Sidebar > More > Shadows
can give you a pretty good idea of how the JS tools work.