mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-09 19:39:57 +00:00
ca6e32bd5a
Instead of the special case handling for <a> tags
36 lines
710 B
JavaScript
36 lines
710 B
JavaScript
/*\
|
|
title: js/macros/link.js
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true */
|
|
"use strict";
|
|
|
|
var utils = require("../Utils.js");
|
|
|
|
exports.macro = {
|
|
name: "link",
|
|
wrapperTag: "span",
|
|
types: ["text/html","text/plain"],
|
|
params: {
|
|
target: {byName: "default", type: "tiddler", optional: false},
|
|
text: {byName: true, type: "text", optional: true}
|
|
},
|
|
handler: function(type,tiddler,store,params) {
|
|
var text = params.text || params.target;
|
|
if(type === "text/html") {
|
|
return utils.stitchElement("a",{
|
|
href: params.target
|
|
},{
|
|
content: utils.htmlEncode(text),
|
|
classNames: store.adjustClassesForLink([],params.target)
|
|
});
|
|
} else if (type === "text/plain") {
|
|
return text;
|
|
}
|
|
}
|
|
};
|
|
|
|
})();
|