Skip to content

Commit 4f39b3a

Browse files
authored
Support clipboard paste image uploads with UI cleanup (closes #40)
1 parent 40cecc1 commit 4f39b3a

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# Changelog
22

3-
## Changes 5/27/2025
3+
## Changes 5/27/2025 v1.3.9
44

55
- Support for mounting CIFS (SMB) network shares via Docker volumes
66
- New `scripts/scan_uploads.php` script to generate metadata for imported files and folders
77
- `SCAN_ON_START` environment variable to trigger automatic scanning on container startup
88
- Documentation for configuring CIFS share mounting and scanning
99

10+
- Clipboard Paste Upload Support (single image):
11+
- Users can now paste images directly into the FileRise web interface.
12+
- Pasted images are renamed to `image<TIMESTAMP>.png` and added to the upload queue using the existing drag-and-drop logic.
13+
- Implemented using a `.isClipboard` flag and a delayed UI cleanup inside `xhr.addEventListener("load", ...)`.
14+
1015
---
1116

1217
## Changes 5/26/2025

public/js/adminPanel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { loadAdminConfigFunc } from './auth.js';
33
import { showToast, toggleVisibility, attachEnterKeyListener } from './domUtils.js';
44
import { sendRequest } from './networkUtils.js';
55

6-
const version = "v1.3.8";
6+
const version = "v1.3.9";
77
const adminTitle = `${t("admin_panel")} <small style="font-size:12px;color:gray;">${version}</small>`;
88

99
// ————— Inject updated styles —————

public/js/upload.js

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,18 @@ function submitFiles(allFiles) {
669669
}
670670
allSucceeded = false;
671671
}
672+
if (file.isClipboard) {
673+
setTimeout(() => {
674+
window.selectedFiles = [];
675+
updateFileInfoCount();
676+
const progressContainer = document.getElementById("uploadProgressContainer");
677+
if (progressContainer) progressContainer.innerHTML = "";
678+
const fileInfoContainer = document.getElementById("fileInfoContainer");
679+
if (fileInfoContainer) {
680+
fileInfoContainer.innerHTML = `<span id="fileInfoDefault">No files selected</span>`;
681+
}
682+
}, 5000);
683+
}
672684

673685
// ─── Only now count this chunk as finished ───────────────────
674686
finishedCount++;
@@ -847,4 +859,39 @@ function initUpload() {
847859
}
848860
}
849861

850-
export { initUpload };
862+
export { initUpload };
863+
864+
// -------------------------
865+
// Clipboard Paste Handler (Mimics Drag-and-Drop)
866+
// -------------------------
867+
document.addEventListener('paste', function handlePasteUpload(e) {
868+
const items = e.clipboardData?.items;
869+
if (!items) return;
870+
871+
const files = [];
872+
873+
for (let i = 0; i < items.length; i++) {
874+
const item = items[i];
875+
if (item.kind === 'file') {
876+
const file = item.getAsFile();
877+
if (file) {
878+
const ext = file.name.split('.').pop() || 'png';
879+
const renamedFile = new File([file], `image${Date.now()}.${ext}`, { type: file.type });
880+
renamedFile.isClipboard = true;
881+
882+
Object.defineProperty(renamedFile, 'customRelativePath', {
883+
value: renamedFile.name,
884+
writable: true,
885+
configurable: true
886+
});
887+
888+
files.push(renamedFile);
889+
}
890+
}
891+
}
892+
893+
if (files.length > 0) {
894+
processFiles(files);
895+
showToast('Pasted file added to upload list.', 'success');
896+
}
897+
});

0 commit comments

Comments
 (0)