Skip to content

Commit fd1de57

Browse files
committed
[frontend] right click menu for links
1 parent 542df13 commit fd1de57

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

frontend/src/Tab.tsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ function copyImageToClipboard(img: HTMLImageElement) {
541541
}
542542

543543
function pageContextItems(client: ScramjetClient, tab: Tab, e: MouseEvent) {
544-
console.log(e.target);
545544
const selection = client.global.getSelection();
546545
if (selection && selection.toString().length > 0) {
547546
return [
@@ -602,6 +601,39 @@ function pageContextItems(client: ScramjetClient, tab: Tab, e: MouseEvent) {
602601
},
603602
},
604603
];
604+
} else if (target && target instanceof view.HTMLAnchorElement) {
605+
return [
606+
{
607+
label: "Open Link",
608+
action: () => {
609+
const url = scramjet.decodeUrl(target.href);
610+
if (url) {
611+
browser.activetab.pushNavigate(new URL(url));
612+
}
613+
},
614+
},
615+
{
616+
label: "Open Link in New Tab",
617+
action: () => {
618+
const url = scramjet.decodeUrl(target.href);
619+
if (url) {
620+
browser.newTab(new URL(url));
621+
}
622+
},
623+
},
624+
{
625+
label: "Copy Link Address",
626+
action: () => {
627+
navigator.clipboard.writeText(scramjet.decodeUrl(target.href));
628+
},
629+
},
630+
{
631+
label: "Save Link As...",
632+
action: () => {
633+
// TODO
634+
},
635+
},
636+
];
605637
}
606638

607639
return [

0 commit comments

Comments
 (0)