mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-04-21 10:13:18 +00:00
feat: allow static site jumping
This commit is contained in:
parent
b34221aadf
commit
d2a18b4668
core/modules/widgets
@ -3,12 +3,11 @@ title: $:/core/modules/widgets/block-mark.js
|
||||
type: application/javascript
|
||||
module-type: widget
|
||||
|
||||
An invisible element with block-mark id metadata.
|
||||
An invisible element with block mark id metadata. Marking a block level element, so that it can be jumped to.
|
||||
\*/
|
||||
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
||||
var BlockMarkWidget = function(parseTreeNode,options) {
|
||||
this.initialise(parseTreeNode,options);
|
||||
// only this widget knows target info (if the block is before this node or not), so we need to hook the focus event, and process it here, instead of in the root widget.
|
||||
};
|
||||
BlockMarkWidget.prototype = new Widget();
|
||||
|
||||
@ -23,6 +22,8 @@ BlockMarkWidget.prototype.render = function(parent,nextSibling) {
|
||||
this.idNode = this.document.createElement("span");
|
||||
this.idNode.setAttribute("data-block-mark-id",this.blockMarkId);
|
||||
this.idNode.setAttribute("data-block-mark-title",this.tiddlerTitle);
|
||||
// id for anchor jumping in static site
|
||||
this.idNode.setAttribute("id",this.tiddlerTitle + "-" + this.blockMarkId);
|
||||
// if the actual block is before this node, we need to add a flag to the node
|
||||
if(this.previousSibling) {
|
||||
this.idNode.setAttribute("data-block-mark-previous-sibling","true");
|
||||
|
@ -92,6 +92,7 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) {
|
||||
}
|
||||
// Set an href
|
||||
var wikilinkTransformFilter = this.getVariable("tv-filter-export-link"),
|
||||
to = this.toBlockMark ? this.to + "-" + this.toBlockMark : this.to,
|
||||
wikiLinkText;
|
||||
if(wikilinkTransformFilter) {
|
||||
// Use the filter to construct the href
|
||||
@ -102,8 +103,8 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) {
|
||||
// Expand the tv-wikilink-template variable to construct the href
|
||||
var wikiLinkTemplateMacro = this.getVariable("tv-wikilink-template"),
|
||||
wikiLinkTemplate = wikiLinkTemplateMacro ? wikiLinkTemplateMacro.trim() : "#$uri_encoded$";
|
||||
wikiLinkText = $tw.utils.replaceString(wikiLinkTemplate,"$uri_encoded$",$tw.utils.encodeURIComponentExtended(this.to));
|
||||
wikiLinkText = $tw.utils.replaceString(wikiLinkText,"$uri_doubleencoded$",$tw.utils.encodeURIComponentExtended($tw.utils.encodeURIComponentExtended(this.to)));
|
||||
wikiLinkText = $tw.utils.replaceString(wikiLinkTemplate,"$uri_encoded$",$tw.utils.encodeURIComponentExtended(to));
|
||||
wikiLinkText = $tw.utils.replaceString(wikiLinkText,"$uri_doubleencoded$",$tw.utils.encodeURIComponentExtended($tw.utils.encodeURIComponentExtended(to)));
|
||||
}
|
||||
// Override with the value of tv-get-export-link if defined
|
||||
wikiLinkText = this.getVariable("tv-get-export-link",{params: [{name: "to",value: this.to}],defaultValue: wikiLinkText});
|
||||
|
Loading…
x
Reference in New Issue
Block a user