Skip to content

Commit 65dc7c1

Browse files
committed
[container] added open externally to navbar
SQUASHED: AUTO-COMMIT-src-components-tools-lively-container-navbar.js,
1 parent ab5f161 commit 65dc7c1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/components/tools/lively-container-navbar.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ export default class LivelyContainerNavbar extends Morph {
537537
if (prefix.length < 4) {
538538
prefix = ""
539539
}
540-
link.innerHTML = icon + title.replace(new RegExp("^" + prefix), "<span class='prefix'>" +prefix +"</span>")
540+
link.innerHTML = icon + title.replace(new RegExp("^" + RegExp.escape(prefix)), "<span class='prefix'>" +prefix +"</span>")
541541
this.lastTitle = title
542542

543543
var href = ea.href || ea.name;
@@ -699,7 +699,20 @@ export default class LivelyContainerNavbar extends Morph {
699699
["copy path to clipboard", () => copyTextToClipboard(otherUrl), "", '<i class="fa fa-clipboard" aria-hidden="true"></i>'],
700700
["copy file name to clipboard", () => copyTextToClipboard(otherUrl::fileName()), "", '<i class="fa fa-clipboard" aria-hidden="true"></i>'],
701701
])
702+
703+
let serverURL = lively.files.serverURL(otherUrl)
704+
if (serverURL && serverURL.match("localhost")) {
705+
// does only make sense when accessing a localhost server,
706+
// otherwise a pdf viewer would be opened on a remote machine?
707+
menuElements.push(["open externally", async () => {
708+
let buildPath = otherUrl.replace(serverURL,"").replace(/^\//,"")
709+
var openURL = serverURL + "/_open/" + buildPath
710+
fetch(openURL)
711+
}])
712+
}
713+
702714
}
715+
703716
if (isDir) {
704717

705718
if(SearchRoots.isSearchRoot(otherUrl)) {

0 commit comments

Comments
 (0)