@@ -20,6 +20,7 @@ import projects from "lib/projects";
2020import recents from "lib/recents" ;
2121import remoteStorage from "lib/remoteStorage" ;
2222import appSettings from "lib/settings" ;
23+ import mimeTypes from "mime-types" ;
2324import mustache from "mustache" ;
2425import filesSettings from "settings/filesSettings" ;
2526import URLParse from "url-parse" ;
@@ -766,6 +767,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
766767
767768 if ( helpers . isFile ( type ) ) {
768769 options . push ( [ "info" , strings . info , "info" ] ) ;
770+ options . push ( [ "open_with" , strings [ "open with" ] , "open_in_browser" ] ) ;
769771 }
770772
771773 if ( currentDir . url !== "/" && url ) {
@@ -819,6 +821,27 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
819821 navigator . clipboard . writeText ( url ) ;
820822 alert ( strings . success , strings [ "copied to clipboard" ] ) ;
821823 break ;
824+
825+ case "open_with" :
826+ try {
827+ let mimeType = mimeTypes . lookup ( name || "text/plain" ) ;
828+ const fs = fsOperation ( url ) ;
829+ if ( / ^ s ? f t p : / . test ( url ) ) return fs . localName ;
830+
831+ system . fileAction (
832+ ( await fs . stat ( ) ) . url ,
833+ name ,
834+ "VIEW" ,
835+ mimeType ,
836+ ( ) => {
837+ toast ( strings [ "no app found to handle this file" ] ) ;
838+ } ,
839+ ) ;
840+ } catch ( error ) {
841+ console . error ( error ) ;
842+ toast ( strings . error ) ;
843+ }
844+ break ;
822845 }
823846 }
824847
0 commit comments