@@ -1948,6 +1948,50 @@ function initOnlineTool() {
19481948 wv . addEventListener ( 'did-navigate' , ( ) => setUrlLabel ( wv . getURL ( ) ) ) ;
19491949 wv . addEventListener ( 'did-navigate-in-page' , ( ) => setUrlLabel ( wv . getURL ( ) ) ) ;
19501950
1951+ // Enable drag-drop onto webview for file uploads
1952+ const onlineFrame = wv . closest ( '.online-frame' ) ;
1953+ if ( onlineFrame ) {
1954+ onlineFrame . addEventListener ( 'dragover' , ( e ) => {
1955+ e . preventDefault ( ) ;
1956+ e . stopPropagation ( ) ;
1957+ e . dataTransfer . dropEffect = 'copy' ;
1958+ } ) ;
1959+
1960+ onlineFrame . addEventListener ( 'drop' , ( e ) => {
1961+ e . preventDefault ( ) ;
1962+ e . stopPropagation ( ) ;
1963+
1964+ // Handle in-app drag from explorer
1965+ const itemsJson = e . dataTransfer ?. getData ( 'application/x-fileshot-items' ) ;
1966+ if ( itemsJson ) {
1967+ let items ;
1968+ try { items = JSON . parse ( itemsJson ) ; } catch ( _ ) { items = null ; }
1969+ const list = Array . isArray ( items ) ? items : [ ] ;
1970+ const paths = list . map ( it => String ( it ?. path || '' ) ) . filter ( Boolean ) ;
1971+ if ( paths . length ) {
1972+ triggerWebviewFileUpload ( wv , paths ) ;
1973+ }
1974+ return ;
1975+ }
1976+
1977+ // Handle OS-level file drop
1978+ const files = e . dataTransfer ?. files ;
1979+ if ( files && files . length > 0 ) {
1980+ const paths = Array . from ( files ) . map ( f => f . path ) . filter ( Boolean ) ;
1981+ if ( paths . length ) {
1982+ triggerWebviewFileUpload ( wv , paths ) ;
1983+ }
1984+ }
1985+ } ) ;
1986+ }
1987+
1988+ // Handle online upload trigger from main process
1989+ window . electronAPI ?. onTriggerOnlineUpload ?. ( ( paths ) => {
1990+ if ( paths && paths . length ) {
1991+ triggerWebviewFileUpload ( wv , paths ) ;
1992+ }
1993+ } ) ;
1994+
19511995 const backBtn = DOM . onlineBackBtn ( ) ;
19521996 const fwdBtn = DOM . onlineForwardBtn ( ) ;
19531997 const reloadBtn = DOM . onlineReloadBtn ( ) ;
@@ -2024,4 +2068,51 @@ function explorerRefresh() {
20242068 }
20252069}
20262070
2071+ // ============================================================================
2072+ // WEBVIEW FILE UPLOAD TRIGGER
2073+ // ============================================================================
2074+
2075+ /**
2076+ * Trigger file upload in the online webview by injecting a script
2077+ * that simulates a file drop on the dropzone.
2078+ */
2079+ function triggerWebviewFileUpload ( wv , paths ) {
2080+ if ( ! wv || ! paths || ! paths . length ) return ;
2081+
2082+ // We need to use executeJavaScript to trigger the file input in the webview
2083+ // The webview has a dropzone that accepts files
2084+ const script = `
2085+ (function() {
2086+ // Look for file input or dropzone
2087+ const dropzone = document.querySelector('.upload-dropzone, .dropzone, [class*="drop"]');
2088+ const fileInput = document.querySelector('input[type="file"]');
2089+
2090+ if (fileInput) {
2091+ // Click the file input to trigger native file dialog
2092+ // Note: We can't programmatically set files due to security
2093+ fileInput.click();
2094+ console.log('[FileShot Desktop] Triggered file input click for upload');
2095+ } else if (dropzone) {
2096+ // Visual indicator that drop was received
2097+ dropzone.style.outline = '3px solid #f97316';
2098+ setTimeout(() => { dropzone.style.outline = ''; }, 1500);
2099+ console.log('[FileShot Desktop] Files received - use Choose Files button');
2100+ }
2101+
2102+ // Show a notification
2103+ const msg = document.createElement('div');
2104+ msg.style.cssText = 'position:fixed;top:20px;left:50%;transform:translateX(-50%);background:#f97316;color:#fff;padding:12px 24px;border-radius:8px;z-index:99999;font-weight:600;box-shadow:0 4px 20px rgba(0,0,0,0.3);';
2105+ msg.textContent = 'Files received! Click "Choose Files" to select them.';
2106+ document.body.appendChild(msg);
2107+ setTimeout(() => msg.remove(), 3000);
2108+ })();
2109+ ` ;
2110+
2111+ try {
2112+ wv . executeJavaScript ( script ) ;
2113+ } catch ( e ) {
2114+ console . error ( '[FileShot Desktop] Failed to trigger webview upload:' , e ) ;
2115+ }
2116+ }
2117+
20272118// Legacy hook removed: online is now embedded inside the local shell.
0 commit comments