1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-28 11:00:27 +00:00

Use default link text when link widget has no content

Fixes #3974
This commit is contained in:
Jeremy Ruston 2019-06-10 21:04:21 +01:00
parent cd412d8ccb
commit f02352f6a1
2 changed files with 14 additions and 3 deletions

View File

@ -183,7 +183,14 @@ LinkWidget.prototype.execute = function() {
this.isShadow = this.wiki.isShadowTiddler(this.to);
this.hideMissingLinks = (this.getVariable("tv-show-missing-links") || "yes") === "no";
// Make the child widgets
this.makeChildWidgets();
var templateTree;
if(this.parseTreeNode.children && this.parseTreeNode.children.length > 0) {
templateTree = this.parseTreeNode.children;
} else {
// Default template is a link to the title
templateTree = [{type: "text", text: this.to}];
}
this.makeChildWidgets(templateTree);
};
/*

View File

@ -1,6 +1,6 @@
caption: link
created: 20131024141900000
modified: 20171212063130159
modified: 20190610195105615
tags: Widgets
title: LinkWidget
type: text/vnd.tiddlywiki
@ -9,6 +9,10 @@ The `link` widget generates links to tiddlers. (Use the HTML `<a>` element to ge
! Content and Attributes
The content of the link widget is rendered within the `<a>` tag representing the link. If the content is empty then the title of the target tiddler is rendered as the default.
For example, `<$link to="HelloThere"/>` is equivalent to `<$link to="HelloThere">HelloThere</$link>` and `<$link/>` is equivalent to `<$link to=<<currentTiddler>>><$view field="title"/></$link>`.
|!Attribute |!Description |
|to |The title of the target tiddler for the link (defaults to the [[current tiddler|Current Tiddler]]) |
|aria-label |Optional accessibility label |
@ -19,7 +23,7 @@ The `link` widget generates links to tiddlers. (Use the HTML `<a>` element to ge
|class|Optional CSS classes //in addition to// the default classes (see below)|
|overrideClass|<<.from-version "5.1.16">> Optional CSS classes //instead of// the default classes |
The content of the link widget is rendered within the `<a>` tag. The draggable functionality is equivalent to using the DraggableWidget with the ''tiddler'' attribute set to the link target.
The draggable functionality is equivalent to using the DraggableWidget with the ''tiddler'' attribute set to the link target.
The default value of the tooltip attribute is supplied by the <<.vlink tv-wikilink-tooltip>> variable.