fix adding of pasted text into convex and fix double paste problem
Build and Push Docker Container / build-and-push (push) Successful in 1m40s
Build and Push Docker Container / build-and-push (push) Successful in 1m40s
This commit is contained in:
@@ -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")
|
||||||
|
|
||||||
|
|||||||
@@ -176,20 +176,30 @@ fileInput.addEventListener('change',e=>{
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* ====== Clipboard handling ====== */
|
/* ====== Clipboard handling ====== */
|
||||||
window.addEventListener('paste',e=>{
|
window.addEventListener('paste', e => {
|
||||||
if(file || (text && text.trim())) return;
|
if (e.target === pasteEl) return; // 👈 let browser handle it
|
||||||
const items=e.clipboardData?.items||[];
|
|
||||||
const fItem=[...items].find(it=>it.kind==='file');
|
if (file || (text && text.trim())) return;
|
||||||
if(fItem){
|
|
||||||
|
const items = e.clipboardData?.items || [];
|
||||||
|
const fItem = [...items].find(it => it.kind === 'file');
|
||||||
|
|
||||||
|
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')||'';
|
|
||||||
if(pasted){ pasteEl.value=pasted; text=pasted; updateUI(); }
|
const pasted = e.clipboardData?.getData('text') || '';
|
||||||
|
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 ====== */
|
||||||
expiresMode.addEventListener('change',()=>{
|
expiresMode.addEventListener('change',()=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user