mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-09 19:39:57 +00:00
73 lines
2.1 KiB
Plaintext
73 lines
2.1 KiB
Plaintext
title: LinkWidget
|
|
tags: docs widget
|
|
|
|
The `link` widget generates links to tiddlers and external URIs. Optionally, hovering over a link can trigger the display of another tiddler as a popup.
|
|
|
|
! Attributes
|
|
|
|
* `to` - link target can be a URL
|
|
* `hover` - the title of a tiddler containing the popup state to set when hovering over the link
|
|
* `qualifyHoverTitles` - if this attribute is present then the title of the hover state tiddler is qualified as described in the PopupMechanism
|
|
|
|
The `to` attribute is interpreted as an external link if it matches this regular expression:
|
|
|
|
```
|
|
/(?:file|http|https|mailto|ftp|irc|news|data):[^\s'"]+(?:\/|\b)/i
|
|
```
|
|
|
|
! Examples
|
|
|
|
The `hover` attribute is part of the PopupMechanism.
|
|
|
|
For example:
|
|
|
|
```
|
|
`$:/MyHover` is {{$:/MyHover}}
|
|
|
|
<$link to="HelloThere" hover="$:/MyHover">Hover me to see ~HelloThere!</$link>
|
|
<$reveal state="$:/MyHover" type="popup">
|
|
<div class="tw-drop-down">
|
|
{{HelloThere}}
|
|
</div>
|
|
</$reveal>
|
|
```
|
|
|
|
Renders as:
|
|
|
|
`$:/MyHover` is {{$:/MyHover}}
|
|
|
|
<$link to="HelloThere" hover="$:/MyHover">Hover me to see ~HelloThere!</$link>
|
|
<$reveal state="$:/MyHover" type="popup">
|
|
<div class="tw-drop-down">
|
|
{{HelloThere}}
|
|
</div>
|
|
</$reveal>
|
|
|
|
! CSS Classes
|
|
|
|
* `tw-tiddlylink` - applied to all links
|
|
* `tw-tiddlylink-external` - applied to external, non-tiddler links
|
|
* `tw-tiddlylink-internal` - applied to tiddler links
|
|
* `tw-tiddlylink-missing` - applied to tiddler links where the target tiddler doesn't exist
|
|
* `tw-tiddlylink-resolves` - applied to tiddler links when the target tiddler does exist
|
|
|
|
! Configuration macros
|
|
|
|
Configuration macros can be used to modify the behaviour of the link widget.
|
|
|
|
!! tw-wikilinks
|
|
|
|
Links are suppressed if the macro `tw-wikilinks` evaluates to the string `no`. For example:
|
|
|
|
```
|
|
\define tw-wikilinks() no
|
|
```
|
|
|
|
!! tw-wikilink-template
|
|
|
|
Link targets default to the URL encoded title of the tiddler. The `href` can be templated by defining the configuration macro `tw-wikilink-template`, and including within it the token `$uri_encoded$`. For example:
|
|
|
|
```
|
|
\define tw-wikilink-template() http://tiddlywiki.com/#$uri_encoded$
|
|
```
|