Created
December 18, 2015 02:11
-
-
Save craftzdog/269ad0c6fc897d3e3f70 to your computer and use it in GitHub Desktop.
brackets/atomのエクステンションの仕組み ref: http://qiita.com/noradaiko/items/a35d2b8191765a4e84e5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read optional requirejs-config.json | |
var promise = _mergeConfig(extensionConfig).then(function (mergedConfig) { | |
// Create new RequireJS context and load extension entry point | |
var extensionRequire = brackets.libRequire.config(mergedConfig), | |
extensionRequireDeferred = new $.Deferred(); | |
contexts[name] = extensionRequire; | |
extensionRequire([entryPoint], extensionRequireDeferred.resolve, extensionRequireDeferred.reject); | |
return extensionRequireDeferred.promise(); | |
}).then(function (module) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */ | |
/*global define, $, brackets, window */ | |
/** Simple extension that adds a "File > Hello World" menu item */ | |
define(function (require, exports, module) { | |
"use strict"; | |
var CommandManager = brackets.getModule("command/CommandManager"), | |
Menus = brackets.getModule("command/Menus"); | |
// Function to run when the menu item is clicked | |
function handleHelloWorld() { | |
window.alert("Hello, world!"); | |
} | |
// First, register a command - a UI-less object associating an id to a handler | |
var MY_COMMAND_ID = "helloworld.sayhello"; // package-style naming to avoid collisions | |
CommandManager.register("Hello World", MY_COMMAND_ID, handleHelloWorld); | |
// Then create a menu item bound to the command | |
// The label of the menu item is the name we gave the command (see above) | |
var menu = Menus.getMenu(Menus.AppMenuBar.FILE_MENU); | |
menu.addMenuItem(MY_COMMAND_ID); | |
// We could also add a key binding at the same time: | |
//menu.addMenuItem(MY_COMMAND_ID, "Ctrl-Alt-W"); | |
// (Note: "Ctrl" is automatically mapped to "Cmd" on Mac) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "fezvrasta.gist-manager", | |
"title": "Gist Manager", | |
"description": "Create and view Github Gists within Brackets. (View > Show Gists Manager)", | |
"keywords": ["gist", "GitHub", "snippets"], | |
"homepage": "https://github.com/FezVrasta/gist-manager", | |
"version": "0.1.1", | |
"author": "Fez Vrasta <[email protected]> (http://www.mywebexpression.com)", | |
"license": "MIT", | |
"engines": { | |
"brackets": ">=0.24.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global.loadModule = function (name) { | |
return require(name); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loadModule("util"); // -> Object {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Loading extensions requires creating new require.js contexts, which | |
// requires access to the global 'require' object that always gets hidden | |
// by the 'require' in the AMD wrapper. We store this in the brackets | |
// object here so that the ExtensionLoader doesn't have to have access to | |
// the global object. | |
global.brackets.libRequire = global.require; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment