copy media URL

This commit is contained in:
Mathium05
2026-07-28 22:17:38 -05:00
parent 971f3ea38e
commit bbd4a20284
2 changed files with 22 additions and 0 deletions
+21
View File
@@ -4,6 +4,7 @@ import {ImagesDisplay} from "./disimg.js";
import {makePlayBox, MediaPlayer} from "./media.js";
import {I18n} from "./i18n.js";
import {createImg} from "./utils/utils.js";
import {Contextmenu} from "./contextmenu.js";
class File {
readonly owner: Message | null;
id: string;
@@ -15,6 +16,22 @@ class File {
url: string;
size: number;
files?: File[];
static menu = this.makeMenu();
static makeMenu() {
const menu = new Contextmenu<File, void>("", true);
I18n.done.then(() => {
menu.addButton(
I18n.copyMedia(),
function () {
navigator.clipboard.writeText(this.url);
},
{
group: "copyLink",
},
);
});
return menu;
}
constructor(fileJSON: filejson, owner: Message | null) {
this.owner = owner;
this.id = fileJSON.id;
@@ -128,6 +145,7 @@ class File {
div.append(makeSpoilerHTML());
}
}
File.menu.bindContextmenu(div, this);
return div;
} else if (this.content_type.startsWith("video/")) {
const video = document.createElement("video");
@@ -150,18 +168,21 @@ class File {
div.append(video, makeSpoilerHTML());
return div;
}
File.menu.bindContextmenu(video, this);
return video;
} else if (this.content_type.startsWith("audio/") || this.content_type === "application/ogg") {
const a = this.getAudioHTML(url);
if (OSpoiler) {
a.append(makeSpoilerHTML());
}
File.menu.bindContextmenu(a, this);
return a;
} else {
const uk = this.createunknown(url);
if (OSpoiler) {
uk.append(makeSpoilerHTML());
}
File.menu.bindContextmenu(uk, this);
return uk;
}
}
+1
View File
@@ -29,6 +29,7 @@
"enable":"Enable onboarding",
"title":"Welcome to $1!"
},
"copyMedia":"Copy media URL",
"DMs": {
"add": "Add someone to this DM",
"close": "Close DM",