Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions extension/pages/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ <h2>Add-ons</h2>
<li>
<strong>"clickableUrls"</strong> - <span class="hint">Make URLs clickable (boolean). Default true</span>
</li>
<li>
<strong>"wrapLinkWithAnchorTag"</strong> - <span class="hint">Add URLs as anchor tag (boolean). Default false</span>
</li>
<li>
<strong>"openLinksInNewWindow"</strong> - <span class="hint">Open URLs in the same window/tab (boolean). Default true</span>
</li>
Expand Down
12 changes: 12 additions & 0 deletions extension/src/json-viewer/highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ Highlighter.prototype = {
elements.forEach(function(node) {
node.classList.add("cm-string-link");
node.setAttribute("data-url", decodedText);
if (self.wrapLinkWithAnchorTag()) {
var linkTag = document.createElement("a");
linkTag.href = decodedText;
linkTag.setAttribute('target', '_blank')
linkTag.innerHTML = decodedText;
node.innerHTML = "";
node.appendChild(linkTag);
}
});
}
});
Expand Down Expand Up @@ -200,6 +208,10 @@ Highlighter.prototype = {
return this.options.addons.clickableUrls;
},

wrapLinkWithAnchorTag: function() {
return this.options.addons.wrapLinkWithAnchorTag;
},

openLinksInNewWindow: function() {
return this.options.addons.openLinksInNewWindow;
},
Expand Down
1 change: 1 addition & 0 deletions extension/src/json-viewer/options/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
alwaysRenderAllContent: false,
sortKeys: false,
clickableUrls: true,
wrapLinkWithAnchorTag: false,
openLinksInNewWindow: true,
autoHighlight: true
},
Expand Down