felixhayashi / TW5-TiddlyMap

Map drawing and topic visualization for your wiki
http://tiddlymap.org
BSD 2-Clause "Simplified" License
863 stars 132 forks source link

Open a view/map from a link inside a tiddler #367

Closed agichim closed 2 years ago

agichim commented 4 years ago

Hi,

The title is descriptive enough I believe. It's the same concept to how you open a tiddler from within another tiddler by using double brackets [[like so]].

If this exists already, I wasn't able to find it.

It would be a good implementation.

felixhayashi commented 4 years ago

Hi @agichim,

in a way, this feature exists, but only for the "live view"

  1. create a new view with name my view
  2. create a new tiddler "my tiddler" and add the field tmap.open-view with value my view.
  3. in the sidebar open the "live tab" to see the live view
  4. Now everytime the tiddler "my tiddler" is scrolled into view in the "story river" (e.g. by clicking a link that leads to the tiddler), the live view renders the map "my view"

You can check this effect out at http://tiddlymap.org – when scrolling to the "Getting started" tiddler, the live view will display the "overview map".

Apart from this, intercepting a click on a tiddlywiki-link (e.g. a click on [[like so]]) is unfortunately not possible and thus cannot be implemented.

agichim commented 4 years ago

Hi. Ah, alright. Thanks for the reply.

flibbles commented 2 years ago

Actually this feature is completely possible. You just need to use invisible buttons, which is a pretty common TiddlyWiki core practice. Here's a macro for you

\define set-view(view, caption)
\whitespace trim
<$button class="tc-btn-invisible tc-tiddlylink">
<!--
Uncomment this and add a "tiddler" argument if you also want
this button/link to open a specific tiddler at the same time.
<$action-navigate $to=<<__tiddler__>>/>
-->
<$action-setfield $tiddler="$:/plugins/felixhayashi/tiddlymap/misc/defaultViewHolder" text=<<__view__>>/>
<$text text={{{ [<__caption__>!match[]else<__view__>] }}} />
</$button>
\end

<<set-view MyView "Switch to my view">>

Hope this isn't too late. I'm working through the backlog, and I wasn't around when this issue opened.