diff --git a/core/language/en-GB/ControlPanel.multids b/core/language/en-GB/ControlPanel.multids index 07ef1a133..3a9b0397d 100644 --- a/core/language/en-GB/ControlPanel.multids +++ b/core/language/en-GB/ControlPanel.multids @@ -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 diff --git a/core/modules/widgets/link.js b/core/modules/widgets/link.js index c749ff945..716e032c3 100755 --- a/core/modules/widgets/link.js +++ b/core/modules/widgets/link.js @@ -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; } diff --git a/core/ui/ControlPanel/Settings/MissingLinks.tid b/core/ui/ControlPanel/Settings/MissingLinks.tid new file mode 100644 index 000000000..4a7ba5f2e --- /dev/null +++ b/core/ui/ControlPanel/Settings/MissingLinks.tid @@ -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/ +<> + +<$checkbox tiddler="$:/config/MissingLinks" field="text" checked="yes" unchecked="no" default="yes"> <$link to="$:/config/MissingLinks"><> + diff --git a/core/wiki/config/MissingLinks.tid b/core/wiki/config/MissingLinks.tid new file mode 100644 index 000000000..99944224f --- /dev/null +++ b/core/wiki/config/MissingLinks.tid @@ -0,0 +1,2 @@ +title: $:/config/MissingLinks +text: yes