mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-16 06:44:50 +00:00
Always default to a href='#title' format for tiddler links
The link format will be overridden when we're creating links within static HTML representations
This commit is contained in:
parent
8063770dae
commit
d93e6b1229
@ -78,7 +78,7 @@ LinkWidget.prototype.generate = function() {
|
||||
this.attributes.href = this.to;
|
||||
} else {
|
||||
var wikiLinkTemplateMacro = this.renderer.renderTree.findMacroDefinition(this.renderer.parentRenderer,"tw-wikilink-template"),
|
||||
wikiLinkTemplate = wikiLinkTemplateMacro ? wikiLinkTemplateMacro.text.trim() : "$uri_encoded$";
|
||||
wikiLinkTemplate = wikiLinkTemplateMacro ? wikiLinkTemplateMacro.text.trim() : "#$uri_encoded$";
|
||||
this.wikiLinkText = wikiLinkTemplate.replace("$uri_encoded$",encodeURIComponent(this.to));
|
||||
this.wikiLinkText = this.wikiLinkText.replace("$uri_doubleencoded$",encodeURIComponent(encodeURIComponent(this.to)));
|
||||
this.attributes.href = this.wikiLinkText;
|
||||
@ -154,10 +154,6 @@ LinkWidget.prototype.postRenderInDom = function() {
|
||||
if(this.renderer.domNode.tagName === "A") {
|
||||
this.renderer.domNode.setAttribute("draggable",true);
|
||||
}
|
||||
// Hack the href of internal links to include a #, again omitted from the static representation. This helps the browser see it as an internal link (eg it prevents Mobile Safari on iPhone from sliding the address bar into view)
|
||||
if(!this.isExternal) {
|
||||
this.renderer.domNode.setAttribute("href","#" + this.wikiLinkText);
|
||||
}
|
||||
};
|
||||
|
||||
LinkWidget.prototype.refreshInDom = function(changedAttributes,changedTiddlers) {
|
||||
|
@ -43,7 +43,7 @@ describe("WikiText tests", function() {
|
||||
expect(wiki.renderTiddler("text/html","TiddlerThree")).toBe("<p>\nThe speed of sound</p><p>\nThe light of speed</p>");
|
||||
});
|
||||
it("should support attributes specified as macro invocations", function() {
|
||||
expect(wiki.renderTiddler("text/html","TiddlerFour")).toBe("<p>\n<a class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-missing' href='This%20is%20my%20amazingly%20groovy%20macro!'>\nThis is a link</a></p>");
|
||||
expect(wiki.renderTiddler("text/html","TiddlerFour")).toBe("<p>\n<a class='tw-tiddlylink tw-tiddlylink-internal tw-tiddlylink-missing' href='#This%20is%20my%20amazingly%20groovy%20macro!'>\nThis is a link</a></p>");
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user