mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
Improved drag & drop file path search
This commit is contained in:
@@ -35,5 +35,6 @@
|
|||||||
<button class="submit-btn" id="submitButton">Submit Video</button>
|
<button class="submit-btn" id="submitButton">Submit Video</button>
|
||||||
|
|
||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
|
<script src="./renderer.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
const { contextBridge, ipcRenderer } = require('electron');
|
|
||||||
contextBridge.exposeInMainWorld('electronAPI', {
|
|
||||||
sendDropPath: (path) => ipcRenderer.send('file-dropped', path)
|
const { contextBridge, ipcRenderer, webUtils } = require('electron')
|
||||||
});
|
|
||||||
|
contextBridge.exposeInMainWorld("explorer", {
|
||||||
|
onFileDrop: (file) => webUtils.getPathForFile(file)
|
||||||
|
})
|
||||||
|
|||||||
@@ -1 +1,22 @@
|
|||||||
|
|
||||||
|
const dropzone = document.getElementById("uploadContainer");
|
||||||
|
|
||||||
|
dropzone.addEventListener("dragover", (e) =>{
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
dropzone.addEventListener("drop", (e) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
const files = e.dataTransfer.files
|
||||||
|
const filePath = window.explorer.onFileDrop(files[0])
|
||||||
|
var holdy = filePath + "";
|
||||||
|
if(holdy.endsWith(".mp4")){
|
||||||
|
console.log(filePath)
|
||||||
|
|
||||||
|
const files1 = e.dataTransfer.files;
|
||||||
|
handleFiles(files1);
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
@@ -5,28 +5,8 @@ const manualBtn = document.getElementById('manualUploadBtn');
|
|||||||
const videoPreview = document.getElementById('videoPreview');
|
const videoPreview = document.getElementById('videoPreview');
|
||||||
|
|
||||||
|
|
||||||
// Drag & Drop Events
|
|
||||||
uploadContainer.addEventListener('dragover', (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
uploadContainer.classList.add('dragover');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
uploadContainer.addEventListener('dragleave', () => {
|
|
||||||
uploadContainer.classList.remove('dragover');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
uploadContainer.addEventListener('drop', (e) => { e.preventDefault();
|
|
||||||
const file = e.dataTransfer.files[0]; // Pfad der Datei
|
|
||||||
const filePath = file.path;
|
|
||||||
console.log('Pfad:', filePath); // ggf. an den Hauptprozess senden, wenn nötig
|
|
||||||
window.electronAPI?.sendDropPath?.(filePath);
|
|
||||||
|
|
||||||
const files = e.dataTransfer.files;
|
|
||||||
handleFiles(files);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
manualBtn.addEventListener('click', () => {
|
manualBtn.addEventListener('click', () => {
|
||||||
fileInput.click();
|
fileInput.click();
|
||||||
|
|||||||
Reference in New Issue
Block a user