Skip to content

Commit

Permalink
feat: new option to open file in external app from file browser (#1163)
Browse files Browse the repository at this point in the history
* feat: new option to open file in external app

* fix: formatting
  • Loading branch information
bajrangCoder authored Jan 23, 2025
1 parent 40d9832 commit 170da7e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/pages/fileBrowser/fileBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import projects from "lib/projects";
import recents from "lib/recents";
import remoteStorage from "lib/remoteStorage";
import appSettings from "lib/settings";
import mimeTypes from "mime-types";
import mustache from "mustache";
import filesSettings from "settings/filesSettings";
import URLParse from "url-parse";
Expand Down Expand Up @@ -766,6 +767,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {

if (helpers.isFile(type)) {
options.push(["info", strings.info, "info"]);
options.push(["open_with", strings["open with"], "open_in_browser"]);
}

if (currentDir.url !== "/" && url) {
Expand Down Expand Up @@ -819,6 +821,27 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
navigator.clipboard.writeText(url);
alert(strings.success, strings["copied to clipboard"]);
break;

case "open_with":
try {
let mimeType = mimeTypes.lookup(name || "text/plain");
const fs = fsOperation(url);
if (/^s?ftp:/.test(url)) return fs.localName;

system.fileAction(
(await fs.stat()).url,
name,
"VIEW",
mimeType,
() => {
toast(strings["no app found to handle this file"]);
},
);
} catch (error) {
console.error(error);
toast(strings.error);
}
break;
}
}

Expand Down

0 comments on commit 170da7e

Please sign in to comment.