Skip to content

Commit

Permalink
Adding missed files
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitesh Kumar committed Mar 5, 2020
1 parent 5171c85 commit 0420ac1
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 0 deletions.
70 changes: 70 additions & 0 deletions src/extensions/default/OpenWithExternalEditor/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2013 - present Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/

define(function (require, exports, module) {
"use strict";


var AppInit = brackets.getModule("utils/AppInit"),
PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
Strings = brackets.getModule("strings"),
FileViewController = brackets.getModule("project/FileViewController"),
ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
NodeDomain = brackets.getModule("utils/NodeDomain"),
FileUtils = brackets.getModule("file/FileUtils");

/**
* @private
* @type {string} fullPath of the OpenWithExternalEditor Domain implementation
*/
var _domainPath = ExtensionUtils.getModulePath(module, "node/OpenWithExternalEditorDomain");

/**
* @private
* @type {NodeDomain}
*/
var _nodeDomain = new NodeDomain("OpenWithExternalEditor", _domainPath);

var extensionToExternalEditorMap = {};

function _openInExternalEdior(event, path) {
_nodeDomain.exec("open", {
path: path,
app: extensionToExternalEditorMap[FileUtils.getFileExtension(path).toLowerCase()]
});
}

PreferencesManager.definePreference("externalEditor", "object", {}, {
description: Strings.DESCRIPTION_EXTERNAL_EDITOR
});

PreferencesManager.on("change", "externalEditor", function () {
extensionToExternalEditorMap = PreferencesManager.get("externalEditor");
});

FileViewController.on("openInExternalEditor", _openInExternalEdior);

AppInit.appReady(function () {
FileUtils.addExtensionToExternalAppList(Object.keys(extensionToExternalEditorMap));
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2012 - present Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/

/*eslint-env node */
/*jslint node: true */
"use strict";

var open = require("open");

var _domainManager;

/**
* @private
*
* @param {Object} params Object to use
*/
function _OpenWithExternalEditor(params) {
var application = "default" === params.app ? "": params.app;
open(params.path, application);
}


/**
* Initializes the OpenWithExternalEditor domain with its commands.
* @param {DomainManager} domainManager The DomainManager for the server
*/
function init(domainManager) {
_domainManager = domainManager;

if (!domainManager.hasDomain("OpenWithExternalEditor")) {
domainManager.registerDomain("OpenWithExternalEditor", {major: 0, minor: 1});
}
_domainManager.registerCommand(
"OpenWithExternalEditor",
"open",
_OpenWithExternalEditor,
true,
"open document with External Editor.",
[{
name: "params",
type: "object",
description: "Params Object having document and App Path."
}],
[]
);
}

exports.init = init;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "brackets-open-external_editor",
"dependencies": {
"open": "0.0.5"
}
}

0 comments on commit 0420ac1

Please sign in to comment.