mirror of
https://github.com/MathMan05/Fermi.git
synced 2026-08-18 17:00:09 +00:00
copy media URL
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user