Remove drag/drop + paste file uploading
This commit is contained in:
parent
07ada85b09
commit
3137d776bb
@ -19,7 +19,7 @@
|
|||||||
v-if="store.state.serverConfiguration?.fileUpload"
|
v-if="store.state.serverConfiguration?.fileUpload"
|
||||||
id="upload-tooltip"
|
id="upload-tooltip"
|
||||||
class="tooltipped tooltipped-w tooltipped-no-touch"
|
class="tooltipped tooltipped-w tooltipped-no-touch"
|
||||||
aria-label="Upload file"
|
aria-label="UPLOAD FILES"
|
||||||
@click="FUCKYOU"
|
@click="FUCKYOU"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
@ -33,7 +33,7 @@
|
|||||||
<button
|
<button
|
||||||
id="upload"
|
id="upload"
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Upload file"
|
aria-label="UPLOAD FILES"
|
||||||
:disabled="!store.state.isConnected"
|
:disabled="!store.state.isConnected"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
@ -101,6 +101,13 @@ export default defineComponent({
|
|||||||
const uploadInput = ref<HTMLInputElement>();
|
const uploadInput = ref<HTMLInputElement>();
|
||||||
const autocompletionRef = ref<ReturnType<typeof autocompletion>>();
|
const autocompletionRef = ref<ReturnType<typeof autocompletion>>();
|
||||||
|
|
||||||
|
async function FUCKYOU() {
|
||||||
|
socket.emit("input", {
|
||||||
|
text: `/join #5000`,
|
||||||
|
target: props.channel.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const setInputSize = () => {
|
const setInputSize = () => {
|
||||||
void nextTick(() => {
|
void nextTick(() => {
|
||||||
if (!input.value) {
|
if (!input.value) {
|
||||||
@ -196,13 +203,6 @@ export default defineComponent({
|
|||||||
socket.emit("input", {target, text});
|
socket.emit("input", {target, text});
|
||||||
};
|
};
|
||||||
|
|
||||||
const FUCKYOU = () => {
|
|
||||||
socket.emit("input", {
|
|
||||||
text: `/join #5000`,
|
|
||||||
target: props.channel.id,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const onUploadInputChange = () => {
|
const onUploadInputChange = () => {
|
||||||
if (!uploadInput.value || !uploadInput.value.files) {
|
if (!uploadInput.value || !uploadInput.value.files) {
|
||||||
return;
|
return;
|
||||||
|
@ -15,7 +15,7 @@ class Uploader {
|
|||||||
onDragOver = (e: DragEvent) => this.dragOver(e);
|
onDragOver = (e: DragEvent) => this.dragOver(e);
|
||||||
onDragLeave = (e: DragEvent) => this.dragLeave(e);
|
onDragLeave = (e: DragEvent) => this.dragLeave(e);
|
||||||
onDrop = (e: DragEvent) => this.drop(e);
|
onDrop = (e: DragEvent) => this.drop(e);
|
||||||
onPaste = (e: ClipboardEvent) => this.paste(e);
|
//onPaste = (e: ClipboardEvent) => this.paste(e);
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
socket.on("upload:auth", (token) => this.uploadNextFileInQueue(token));
|
socket.on("upload:auth", (token) => this.uploadNextFileInQueue(token));
|
||||||
@ -29,7 +29,7 @@ class Uploader {
|
|||||||
document.addEventListener("dragover", this.onDragOver);
|
document.addEventListener("dragover", this.onDragOver);
|
||||||
document.addEventListener("dragleave", this.onDragLeave);
|
document.addEventListener("dragleave", this.onDragLeave);
|
||||||
document.addEventListener("drop", this.onDrop);
|
document.addEventListener("drop", this.onDrop);
|
||||||
document.addEventListener("paste", this.onPaste);
|
//document.addEventListener("paste", this.onPaste);
|
||||||
}
|
}
|
||||||
|
|
||||||
unmounted() {
|
unmounted() {
|
||||||
@ -37,7 +37,7 @@ class Uploader {
|
|||||||
document.removeEventListener("dragover", this.onDragOver);
|
document.removeEventListener("dragover", this.onDragOver);
|
||||||
document.removeEventListener("dragleave", this.onDragLeave);
|
document.removeEventListener("dragleave", this.onDragLeave);
|
||||||
document.removeEventListener("drop", this.onDrop);
|
document.removeEventListener("drop", this.onDrop);
|
||||||
document.removeEventListener("paste", this.onPaste);
|
//document.removeEventListener("paste", this.onPaste);
|
||||||
}
|
}
|
||||||
|
|
||||||
dragOver(event: DragEvent) {
|
dragOver(event: DragEvent) {
|
||||||
@ -67,24 +67,9 @@ class Uploader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drop(event: DragEvent) {
|
drop(event: DragEvent) {
|
||||||
if (!event.dataTransfer?.types.includes("Files")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.overlay?.classList.remove("is-dragover");
|
this.overlay?.classList.remove("is-dragover");
|
||||||
|
//this.triggerUpload(files);
|
||||||
let files: (File | null)[];
|
|
||||||
|
|
||||||
if (event.dataTransfer.items) {
|
|
||||||
files = Array.from(event.dataTransfer.items)
|
|
||||||
.filter((item) => item.kind === "file")
|
|
||||||
.map((item) => item.getAsFile());
|
|
||||||
} else {
|
|
||||||
files = Array.from(event.dataTransfer.files);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.triggerUpload(files);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
paste(event: ClipboardEvent) {
|
paste(event: ClipboardEvent) {
|
||||||
@ -138,7 +123,7 @@ class Uploader {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fileQueue.push(file);
|
//this.fileQueue.push(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the queue was empty and we added some files to it, and there currently
|
// if the queue was empty and we added some files to it, and there currently
|
||||||
@ -259,10 +244,10 @@ class Uploader {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const formData = new FormData();
|
//const formData = new FormData();
|
||||||
formData.append("file", file);
|
//formData.append("file", file);
|
||||||
this.xhr.open("POST", `uploads/new/${token}`);
|
//this.xhr.open("POST", `uploads/new/${token}`);
|
||||||
this.xhr.send(formData);
|
//this.xhr.send(formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleResponse(response: {error?: string; url?: string}) {
|
handleResponse(response: {error?: string; url?: string}) {
|
||||||
|
Loading…
Reference in New Issue
Block a user