mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 00:50:28 +00:00
Add option to disable linking to missing tiddlers
* Add LinkWidget option to ignore missing tiddlers * Add missing link option to settings
This commit is contained in:
parent
37823f64e9
commit
7908e10488
@ -121,6 +121,9 @@ Settings/TitleLinks/Caption: Tiddler Titles
|
||||
Settings/TitleLinks/Hint: Optionally display tiddler titles as links
|
||||
Settings/TitleLinks/No/Description: Do not display tiddler titles as links
|
||||
Settings/TitleLinks/Yes/Description: Display tiddler titles as links
|
||||
Settings/MissingLinks/Caption: Wiki Links
|
||||
Settings/MissingLinks/Hint: Choose whether to link to tiddlers that do not exist yet
|
||||
Settings/MissingLinks/Description: Enable links to missing tiddlers
|
||||
StoryView/Caption: Story View
|
||||
StoryView/Prompt: Current view:
|
||||
Theme/Caption: Theme
|
||||
|
@ -13,6 +13,7 @@ Link widget
|
||||
"use strict";
|
||||
|
||||
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
||||
var MISSING_LINK_CONFIG_TITLE = "$:/config/MissingLinks";
|
||||
|
||||
var LinkWidget = function(parseTreeNode,options) {
|
||||
this.initialise(parseTreeNode,options);
|
||||
@ -35,9 +36,10 @@ LinkWidget.prototype.render = function(parent,nextSibling) {
|
||||
this.execute();
|
||||
// Get the value of the tv-wikilinks configuration macro
|
||||
var wikiLinksMacro = this.getVariable("tv-wikilinks"),
|
||||
useWikiLinks = wikiLinksMacro ? (wikiLinksMacro.trim() !== "no") : true;
|
||||
useWikiLinks = wikiLinksMacro ? (wikiLinksMacro.trim() !== "no") : true,
|
||||
missingLinksEnabled = !(this.hideMissingLinks && this.isMissing);
|
||||
// Render the link if required
|
||||
if(useWikiLinks) {
|
||||
if(useWikiLinks && missingLinksEnabled) {
|
||||
this.renderLink(parent,nextSibling);
|
||||
} else {
|
||||
// Just insert the link text
|
||||
@ -216,6 +218,7 @@ LinkWidget.prototype.execute = function() {
|
||||
// Determine the link characteristics
|
||||
this.isMissing = !this.wiki.tiddlerExists(this.to);
|
||||
this.isShadow = this.wiki.isShadowTiddler(this.to);
|
||||
this.hideMissingLinks = ($tw.wiki.getTiddlerText(MISSING_LINK_CONFIG_TITLE,"yes") === "no");
|
||||
// Make the child widgets
|
||||
this.makeChildWidgets();
|
||||
};
|
||||
@ -225,7 +228,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
|
||||
*/
|
||||
LinkWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
if(changedAttributes.to || changedTiddlers[this.to] || changedAttributes["aria-label"] || changedAttributes.tooltip) {
|
||||
if(changedAttributes.to || changedTiddlers[this.to] || changedAttributes["aria-label"] || changedAttributes.tooltip || changedTiddlers[MISSING_LINK_CONFIG_TITLE]) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
}
|
||||
|
9
core/ui/ControlPanel/Settings/MissingLinks.tid
Normal file
9
core/ui/ControlPanel/Settings/MissingLinks.tid
Normal file
@ -0,0 +1,9 @@
|
||||
title: $:/core/ui/ControlPanel/Settings/MissingLinks
|
||||
tags: $:/tags/ControlPanel/Settings
|
||||
caption: {{$:/language/ControlPanel/Settings/MissingLinks/Caption}}
|
||||
|
||||
\define lingo-base() $:/language/ControlPanel/Settings/MissingLinks/
|
||||
<<lingo Hint>>
|
||||
|
||||
<$checkbox tiddler="$:/config/MissingLinks" field="text" checked="yes" unchecked="no" default="yes"> <$link to="$:/config/MissingLinks"><<lingo Description>></$link> </$checkbox>
|
||||
|
2
core/wiki/config/MissingLinks.tid
Normal file
2
core/wiki/config/MissingLinks.tid
Normal file
@ -0,0 +1,2 @@
|
||||
title: $:/config/MissingLinks
|
||||
text: yes
|
Loading…
Reference in New Issue
Block a user