mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-01 05:49:55 +00:00
68 lines
2.2 KiB
Plaintext
68 lines
2.2 KiB
Plaintext
title: LinkWidget
|
|
created: 201310241419
|
|
modified: 20150228144334000
|
|
tags: Widgets
|
|
caption: link
|
|
|
|
The `link` widget generates links to tiddlers. (Use the HTML `<a>` element to generate external links).
|
|
|
|
! Content and Attributes
|
|
|
|
|!Attribute |!Description |
|
|
|to |The title of the target tiddler for the link (defaults to the [[current tiddler|Current Tiddler]]) |
|
|
|aria-label |Optional [[Accessibility]] label |
|
|
|tooltip |Optional tooltip WikiText |
|
|
|tabindex |Optional numeric [[tabindex|https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex]] |
|
|
|draggable |"yes" to enable the link to be draggable (defaults to "yes") |
|
|
|tag |Optional tag to override the default "a" element |
|
|
|
|
The content of the link widget is rendered within the `<a>` tag.
|
|
|
|
The default value of the tooltip attribute is supplied by the <<.vlink tv-wikilink-tooltip>> variable.
|
|
|
|
This means that you can control the text of a link tooltip in several ways:
|
|
|
|
```
|
|
<$link to="HelloThere" tooltip="Custom tooltip">Link 1</$link>
|
|
|
|
<$set name="tv-wikilink-tooltip" value="I'm a link to {{!!title}}">
|
|
<$link to="HelloThere">Link 2</$link>
|
|
</$set>
|
|
|
|
```
|
|
|
|
Renders as:
|
|
|
|
<$link to="HelloThere" tooltip="Custom tooltip">Link 1</$link>
|
|
|
|
<$set name="tv-wikilink-tooltip" value="I'm a link to {{!!title}}">
|
|
<$link to="HelloThere">Link 2</$link>
|
|
</$set>
|
|
|
|
Note that the tooltip is rendered with the current tiddler set to the target of the link.
|
|
|
|
A useful convention is to set the tooltip like this:
|
|
|
|
```
|
|
\define tv-wikilink-tooltip()
|
|
<$transclude field="tooltip"><$transclude field="title"/></$transclude>
|
|
\end
|
|
```
|
|
|
|
This causes the tooltip to be the ''tooltip'' field of the target tiddler. If the field isn't present, then the title is used instead.
|
|
|
|
! CSS Classes
|
|
|
|
* `tc-tiddlylink` - applied to all links
|
|
* `tc-tiddlylink-external` - applied to external, non-tiddler links
|
|
* `tc-tiddlylink-internal` - applied to tiddler links
|
|
* `tc-tiddlylink-missing` - applied to tiddler links where the target tiddler doesn't exist
|
|
* `tc-tiddlylink-resolves` - applied to tiddler links when the target tiddler does exist
|
|
|
|
! Configuration variables
|
|
|
|
* <<.vlink tv-wikilinks>>
|
|
* <<.vlink tv-wikilink-template>>
|
|
* <<.vlink tv-wikilink-tooltip>>
|
|
* <<.vlink tv-get-export-link>>
|