mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 00:50:28 +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 */
|
||||
"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) {
|
||||
this.initialise(parseTreeNode,options);
|
||||
@ -43,8 +45,8 @@ TextNodeWidget.prototype.execute = function() {
|
||||
type: "plain-text",
|
||||
text: this.getAttribute("text",this.parseTreeNode.text || "")
|
||||
}];
|
||||
// Only process links if not disabled
|
||||
if(this.getVariable("tv-wikilinks",{defaultValue:"yes"}).trim() !== "no" && this.getVariable("tv-freelinks",{defaultValue:"no"}).trim() === "yes") {
|
||||
// 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" && !this.isWithinButtonOrLink()) {
|
||||
// Get the information about the current tiddler titles, and construct a regexp
|
||||
this.tiddlerTitleInfo = this.wiki.getGlobalCache("tiddler-title-info",function() {
|
||||
var titles = [],
|
||||
@ -122,6 +124,16 @@ TextNodeWidget.prototype.execute = function() {
|
||||
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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user