I have created a file input in my Angular application that can detect image pasting using CTRL-V. Is there a way to enable the paste option when I right click on the input?
Any assistance would be greatly appreciated!
Here's the code snippet:
@HostListener("paste", ["$event"])
onPaste(e: ClipboardEvent) {
let clipboardData = e.clipboardData || (window as any).clipboardData;
let pastedData = clipboardData.getData("text");
if (pastedData.includes("data:image")) {
var binary = atob(pastedData.split(",")[1]);
var array = [];
for (var i = 0; i < binary.length; i++) {
array.push(binary.charCodeAt(i));
}
var pasteImages = new Blob([new Uint8Array(array)], {
type: "image/jpeg"
});
} else {
alert("Select an image in the correct format");
}
}