Changeset 5190152 in Klonkt for src/assets/js
- Timestamp:
- 07/19/2026 05:38:25 PM (7 weeks ago)
- Branches:
- main
- Children:
- e9c9ae1
- Parents:
- feced2c
- git-author:
- Robin <roboburr@…> (07/19/2026 05:38:00 PM)
- git-committer:
- Robin <roboburr@…> (07/19/2026 05:38:25 PM)
- File:
-
- 1 edited
-
src/assets/js/reply-editor.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/assets/js/reply-editor.js
rfeced2c r5190152 36 36 var attField = form.querySelector('input[name="attachments"]'); 37 37 var fileInput = form.querySelector('.re-file'); 38 var canAttach = !!(attWrap && attField && fileInput); // edit mode renders without media 38 39 var attachments = []; 39 40 40 41 function syncAtt() { 42 if (!canAttach) return; 41 43 attField.value = attachments.length ? JSON.stringify(attachments) : ''; 42 44 attWrap.hidden = attachments.length === 0; … … 62 64 } 63 65 function uploadFiles(files) { 66 if (!canAttach) return; 64 67 Array.prototype.forEach.call(files, function (file) { 65 68 if (!/^(image|audio|video)\//.test(file.type) || attachments.length >= 4) return; … … 93 96 e.preventDefault(); 94 97 var cmd = btn.getAttribute('data-cmd'); 95 if (cmd === 'attach') { fileInput.click(); return; } // no editor focus: keeps the picker usable on mobile98 if (cmd === 'attach') { if (fileInput) fileInput.click(); return; } // no editor focus: keeps the picker usable on mobile 96 99 ed.focus(); 97 100 if (cmd === 'bold') document.execCommand('bold'); … … 104 107 } 105 108 }); 106 fileInput.addEventListener('change', function () {109 if (fileInput) fileInput.addEventListener('change', function () { 107 110 uploadFiles(fileInput.files); 108 111 fileInput.value = ''; … … 114 117 var cd = e.clipboardData || window.clipboardData; 115 118 if (cd.files && cd.files.length) { 116 e.preventDefault(); 117 uploadFiles(cd.files); 119 e.preventDefault(); // never let the browser inline-paste a file as base64 120 uploadFiles(cd.files); // no-op without the attach UI (edit mode) 118 121 return; 119 122 } … … 125 128 126 129 // Drag/drop media onto the editor. 130 if (canAttach) { 127 131 ed.addEventListener('dragover', function (e) { 128 132 if (e.dataTransfer && Array.prototype.some.call(e.dataTransfer.types || [], function (t) { return t === 'Files'; })) { … … 139 143 } 140 144 }); 145 } 141 146 142 147 // Full-screen compose on mobile: enter on focus, leave via ×.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)