mirror of
https://github.com/adobe/brackets.git
synced 2024-11-20 09:53:00 +01:00
Associate an file tpye to external Application
This commit is contained in:
parent
3ae5417b43
commit
5171c85c20
@ -59,6 +59,11 @@ define(function (require, exports, module) {
|
||||
*/
|
||||
var MAX_FILE_SIZE = MAX_FILE_SIZE_MB * 1024 * 1024;
|
||||
|
||||
/**
|
||||
* @const {List} list of File Extensions which will be opened in external Application
|
||||
*/
|
||||
var extListToBeOpenedInExtApp = [];
|
||||
|
||||
|
||||
/**
|
||||
* Asynchronously reads a file as UTF-8 encoded text.
|
||||
@ -526,6 +531,28 @@ define(function (require, exports, module) {
|
||||
return pathArray.join("/");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} ext extension string a file
|
||||
* @return {string} returns true If file to be opened in External Application.
|
||||
*
|
||||
*/
|
||||
function shouldOpenInExternalApplication(ext) {
|
||||
return !extListToBeOpenedInExtApp.includes(ext);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} ext File Extensions to be added in External App List
|
||||
*
|
||||
*/
|
||||
function addExtensionToExternalAppList(ext) {
|
||||
|
||||
if(typeof ext !== 'string') {
|
||||
extListToBeOpenedInExtApp.concat(ext);
|
||||
} else {
|
||||
extListToBeOpenedInExtApp.push(ext);
|
||||
}
|
||||
}
|
||||
|
||||
// Asynchronously load DocumentCommandHandlers
|
||||
// This avoids a temporary circular dependency created
|
||||
// by relocating showFileOpenError() until deprecation is over
|
||||
@ -568,4 +595,6 @@ define(function (require, exports, module) {
|
||||
exports.comparePaths = comparePaths;
|
||||
exports.MAX_FILE_SIZE = MAX_FILE_SIZE;
|
||||
exports.encodeFilePath = encodeFilePath;
|
||||
exports.shouldOpenInExternalApplication = shouldOpenInExternalApplication;
|
||||
exports.addExtensionToExternalAppList = addExtensionToExternalAppList;
|
||||
});
|
||||
|
@ -903,5 +903,8 @@ define({
|
||||
"REMOTE_DEBUGGING_ENABLED" : "Remote debugging enabled on localhost:",
|
||||
|
||||
// Remote debugging port argument is invalid
|
||||
"REMOTE_DEBUGGING_PORT_INVALID" : "Cannot enable remote debugging on port {0}. Port numbers should be between {1} and {2}."
|
||||
"REMOTE_DEBUGGING_PORT_INVALID" : "Cannot enable remote debugging on port {0}. Port numbers should be between {1} and {2}.",
|
||||
|
||||
//Associate File Type to External App
|
||||
"DESCRIPTION_EXTERNAL_EDITOR" : "Add File type association to external App here"
|
||||
});
|
||||
|
@ -39,7 +39,8 @@ define(function (require, exports, module) {
|
||||
LanguageManager = require("language/LanguageManager"),
|
||||
FileTreeViewModel = require("project/FileTreeViewModel"),
|
||||
ViewUtils = require("utils/ViewUtils"),
|
||||
KeyEvent = require("utils/KeyEvent");
|
||||
KeyEvent = require("utils/KeyEvent"),
|
||||
PreferencesManager = require("preferences/PreferencesManager");
|
||||
|
||||
var DOM = Preact.DOM;
|
||||
|
||||
@ -554,7 +555,10 @@ define(function (require, exports, module) {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.props.actions.setSelected(this.myPath());
|
||||
this.props.actions.setSelected(this.myPath(),
|
||||
FileUtils.shouldOpenInExternalApplication(
|
||||
FileUtils.getFileExtension(this.myPath()).toLowerCase()
|
||||
));
|
||||
}
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
@ -569,6 +573,12 @@ define(function (require, exports, module) {
|
||||
if (this.state.clickTimer !== null) {
|
||||
this.clearTimer();
|
||||
}
|
||||
if (FileUtils.shouldOpenInExternalApplication(
|
||||
FileUtils.getFileExtension(this.myPath()).toLowerCase()
|
||||
)) {
|
||||
this.props.actions.openInExternalEditor(this.myPath());
|
||||
return;
|
||||
}
|
||||
this.props.actions.selectInWorkingSet(this.myPath());
|
||||
}
|
||||
},
|
||||
|
@ -226,6 +226,13 @@ define(function (require, exports, module) {
|
||||
return result.promise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the specified document with its associated external editor,
|
||||
*/
|
||||
function openInExternalEditor(fullPath) {
|
||||
exports.trigger("openInExternalEditor", fullPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the specified document if it's not already open, adds it to the working set,
|
||||
* and selects it in the WorkingSetView
|
||||
@ -275,4 +282,5 @@ define(function (require, exports, module) {
|
||||
exports.setFileViewFocus = setFileViewFocus;
|
||||
exports.WORKING_SET_VIEW = WORKING_SET_VIEW;
|
||||
exports.PROJECT_MANAGER = PROJECT_MANAGER;
|
||||
exports.openInExternalEditor = openInExternalEditor;
|
||||
});
|
||||
|
@ -280,6 +280,14 @@ define(function (require, exports, module) {
|
||||
this.model.selectInWorkingSet(path);
|
||||
};
|
||||
|
||||
/**
|
||||
* See `FileViewController.openInExternalEditor`
|
||||
*/
|
||||
ActionCreator.prototype.openInExternalEditor = function (path) {
|
||||
FileViewController.openInExternalEditor(path);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* See `ProjectModel.setContext`
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user