mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-21 05:20:01 +00:00
Freelinks: Add a filter for which tiddlers can be the targets of freelinks
This commit is contained in:
parent
50d0b6ee50
commit
0ed32fded9
@ -1,5 +1,7 @@
|
|||||||
title: $:/plugins/tiddlywiki/freelinks/settings
|
title: $:/plugins/tiddlywiki/freelinks/settings
|
||||||
|
|
||||||
|
Filter defining tiddlers to which freelinks are made: <$edit-text tiddler="$:/config/Freelinks/TargetFilter" tag="input" placeholder="Filter expression..." default=""/>
|
||||||
|
|
||||||
<$checkbox tiddler="$:/config/Freelinks/Enable" field="text" checked="yes" unchecked="no" default="no"> <$link to="$:/config/Freelinks/Enable">Enable freelinking within tiddler view templates</$link> </$checkbox>
|
<$checkbox tiddler="$:/config/Freelinks/Enable" field="text" checked="yes" unchecked="no" default="no"> <$link to="$:/config/Freelinks/Enable">Enable freelinking within tiddler view templates</$link> </$checkbox>
|
||||||
|
|
||||||
<$checkbox tiddler="$:/config/Freelinks/IgnoreCase" field="text" checked="yes" unchecked="no" default="no"> <$link to="$:/config/Freelinks/IgnoreCase">Ignore case</$link> </$checkbox>
|
<$checkbox tiddler="$:/config/Freelinks/IgnoreCase" field="text" checked="yes" unchecked="no" default="no"> <$link to="$:/config/Freelinks/IgnoreCase">Ignore case</$link> </$checkbox>
|
||||||
|
@ -12,6 +12,8 @@ An override of the core text widget that automatically linkifies the text
|
|||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var TITLE_TARGET_FILTER = "$:/config/Freelinks/TargetFilter";
|
||||||
|
|
||||||
var Widget = require("$:/core/modules/widgets/widget.js").widget,
|
var Widget = require("$:/core/modules/widgets/widget.js").widget,
|
||||||
LinkWidget = require("$:/core/modules/widgets/link.js").link,
|
LinkWidget = require("$:/core/modules/widgets/link.js").link,
|
||||||
ButtonWidget = require("$:/core/modules/widgets/button.js").button,
|
ButtonWidget = require("$:/core/modules/widgets/button.js").button,
|
||||||
@ -51,7 +53,9 @@ TextNodeWidget.prototype.execute = function() {
|
|||||||
if(this.getVariable("tv-wikilinks",{defaultValue:"yes"}).trim() !== "no" && this.getVariable("tv-freelinks",{defaultValue:"no"}).trim() === "yes" && !this.isWithinButtonOrLink()) {
|
if(this.getVariable("tv-wikilinks",{defaultValue:"yes"}).trim() !== "no" && this.getVariable("tv-freelinks",{defaultValue:"no"}).trim() === "yes" && !this.isWithinButtonOrLink()) {
|
||||||
// Get the information about the current tiddler titles, and construct a regexp
|
// Get the information about the current tiddler titles, and construct a regexp
|
||||||
this.tiddlerTitleInfo = this.wiki.getGlobalCache("tiddler-title-info-" + (ignoreCase ? "insensitive" : "sensitive"),function() {
|
this.tiddlerTitleInfo = this.wiki.getGlobalCache("tiddler-title-info-" + (ignoreCase ? "insensitive" : "sensitive"),function() {
|
||||||
var sortedTitles = self.wiki.allTitles().sort(function(a,b) {
|
var targetFilterText = self.wiki.getTiddlerText(TITLE_TARGET_FILTER),
|
||||||
|
titles = !!targetFilterText ? self.wiki.filterTiddlers(targetFilterText,$tw.rootWidget) : self.wiki.allTitles(),
|
||||||
|
sortedTitles = titles.sort(function(a,b) {
|
||||||
var lenA = a.length,
|
var lenA = a.length,
|
||||||
lenB = b.length;
|
lenB = b.length;
|
||||||
// First sort by length, so longer titles are first
|
// First sort by length, so longer titles are first
|
||||||
|
Loading…
x
Reference in New Issue
Block a user