fix adding of pasted text into convex and fix double paste problem
Build and Push Docker Container / build-and-push (push) Successful in 1m40s

This commit is contained in:
2026-01-19 18:52:27 +01:00
parent e541000347
commit d82ed3d43a
2 changed files with 20 additions and 14 deletions
-4
View File
@@ -136,10 +136,6 @@ async def api_upload(user):
elif text.strip(): elif text.strip():
data = text.encode("utf-8") data = text.encode("utf-8")
fname = iso_stamp_filename("pasted", "txt") fname = iso_stamp_filename("pasted", "txt")
path = current_app.upload_folder / fname
async with aiofiles.open(path, "wb") as f:
await f.write(data)
storage_id = await current_app.convex.send_to_storage(data=data, content_type="text/plain") storage_id = await current_app.convex.send_to_storage(data=data, content_type="text/plain")
+11 -1
View File
@@ -177,18 +177,28 @@ fileInput.addEventListener('change',e=>{
/* ====== Clipboard handling ====== */ /* ====== Clipboard handling ====== */
window.addEventListener('paste', e => { window.addEventListener('paste', e => {
if (e.target === pasteEl) return; // 👈 let browser handle it
if (file || (text && text.trim())) return; if (file || (text && text.trim())) return;
const items = e.clipboardData?.items || []; const items = e.clipboardData?.items || [];
const fItem = [...items].find(it => it.kind === 'file'); const fItem = [...items].find(it => it.kind === 'file');
if (fItem) { if (fItem) {
e.preventDefault(); e.preventDefault();
const blob = fItem.getAsFile(); const blob = fItem.getAsFile();
if (blob) setFileFromBlob(blob); if (blob) setFileFromBlob(blob);
return; return;
} }
const pasted = e.clipboardData?.getData('text') || ''; const pasted = e.clipboardData?.getData('text') || '';
if(pasted){ pasteEl.value=pasted; text=pasted; updateUI(); } if (pasted) {
pasteEl.value = pasted;
text = pasted;
updateUI();
}
}); });
pasteEl.addEventListener('input',e => { text = e.target.value; updateUI(); }); pasteEl.addEventListener('input',e => { text = e.target.value; updateUI(); });
/* ====== Expiration handling ====== */ /* ====== Expiration handling ====== */