mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Don't freelink within links and buttons
This commit is contained in:
parent
1c91f72baa
commit
870c34ab0a
@ -12,7 +12,9 @@ An override of the core text widget that automatically linkifies the text
|
|||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
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,
|
||||||
|
ButtonWidget = require("$:/core/modules/widgets/button.js").button;
|
||||||
|
|
||||||
var TextNodeWidget = function(parseTreeNode,options) {
|
var TextNodeWidget = function(parseTreeNode,options) {
|
||||||
this.initialise(parseTreeNode,options);
|
this.initialise(parseTreeNode,options);
|
||||||
@ -43,8 +45,8 @@ TextNodeWidget.prototype.execute = function() {
|
|||||||
type: "plain-text",
|
type: "plain-text",
|
||||||
text: this.getAttribute("text",this.parseTreeNode.text || "")
|
text: this.getAttribute("text",this.parseTreeNode.text || "")
|
||||||
}];
|
}];
|
||||||
// Only process links if not disabled
|
// Only process links if not disabled and we're not within a button or link widget
|
||||||
if(this.getVariable("tv-wikilinks",{defaultValue:"yes"}).trim() !== "no" && this.getVariable("tv-freelinks",{defaultValue:"no"}).trim() === "yes") {
|
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",function() {
|
this.tiddlerTitleInfo = this.wiki.getGlobalCache("tiddler-title-info",function() {
|
||||||
var titles = [],
|
var titles = [],
|
||||||
@ -122,6 +124,16 @@ TextNodeWidget.prototype.execute = function() {
|
|||||||
this.makeChildWidgets(childParseTree);
|
this.makeChildWidgets(childParseTree);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TextNodeWidget.prototype.isWithinButtonOrLink = function() {
|
||||||
|
var withinButtonOrLink = false,
|
||||||
|
widget = this.parentWidget;
|
||||||
|
while(!withinButtonOrLink && widget) {
|
||||||
|
withinButtonOrLink = widget instanceof ButtonWidget || widget instanceof LinkWidget;
|
||||||
|
widget = widget.parentWidget;
|
||||||
|
}
|
||||||
|
return withinButtonOrLink;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
|
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user