Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new option to open file in external app from file browser #1163

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading