kopia lustrzana https://github.com/c9/core
allow expand_abbreviation emmet command for all modes
rodzic
c4f5eb2eec
commit
5d2bb09104
|
@ -343,11 +343,9 @@ var keymap = {
|
|||
|
||||
var editorProxy = new AceEmmetEditor();
|
||||
exports.commands = new HashHandler();
|
||||
exports.runEmmetCommand = function(editor) {
|
||||
exports.runEmmetCommand = function runEmmetCommand(editor) {
|
||||
try {
|
||||
editorProxy.setupContext(editor);
|
||||
if (editorProxy.getSyntax() == "php")
|
||||
return false;
|
||||
var actions = emmet.require("actions");
|
||||
|
||||
if (this.action == "expand_abbreviation_with_tab") {
|
||||
|
@ -369,6 +367,10 @@ exports.runEmmetCommand = function(editor) {
|
|||
|
||||
var result = actions.run(this.action, editorProxy);
|
||||
} catch(e) {
|
||||
if (!emmet) {
|
||||
load(runEmmetCommand.bind(this, editor));
|
||||
return true;
|
||||
}
|
||||
editor._signal("changeStatus", typeof e == "string" ? e : e.message);
|
||||
console.log(e);
|
||||
result = false;
|
||||
|
@ -401,6 +403,22 @@ exports.isSupportedMode = function(mode) {
|
|||
return /css|less|scss|sass|stylus|html|php|twig|ejs|handlebars/.test(id);
|
||||
};
|
||||
|
||||
exports.isAvailable = function(editor, command) {
|
||||
if (/(evaluate_math_expression|expand_abbreviation)$/.test(command))
|
||||
return true;
|
||||
var mode = editor.session.$mode;
|
||||
var isSupported = exports.isSupportedMode(mode);
|
||||
if (isSupported && mode.$modes) {
|
||||
// TODO refactor mode delegates to make this simpler
|
||||
try {
|
||||
editorProxy.setupContext(editor);
|
||||
if (/js|php/.test(editorProxy.getSyntax()))
|
||||
isSupported = false;
|
||||
} catch(e) {}
|
||||
}
|
||||
return isSupported;
|
||||
}
|
||||
|
||||
var onChangeMode = function(e, target) {
|
||||
var editor = target;
|
||||
if (!editor)
|
||||
|
@ -408,16 +426,20 @@ var onChangeMode = function(e, target) {
|
|||
var enabled = exports.isSupportedMode(editor.session.$mode);
|
||||
if (e.enableEmmet === false)
|
||||
enabled = false;
|
||||
if (enabled) {
|
||||
if (typeof emmetPath == "string") {
|
||||
require("ace/config").loadModule(emmetPath, function() {
|
||||
emmetPath = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
if (enabled)
|
||||
load();
|
||||
exports.updateCommands(editor, enabled);
|
||||
};
|
||||
|
||||
var load = function(cb) {
|
||||
if (typeof emmetPath == "string") {
|
||||
require("ace/config").loadModule(emmetPath, function() {
|
||||
emmetPath = null;
|
||||
cb && cb();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.AceEmmetEditor = AceEmmetEditor;
|
||||
require("ace/config").defineOptions(Editor.prototype, "editor", {
|
||||
enableEmmet: {
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
"c9.ide.find.replace": "#44772dd796",
|
||||
"c9.ide.run.debug": "#c7f1ed5d5d",
|
||||
"c9.automate": "#47e2c429c9",
|
||||
"c9.ide.ace.emmet": "#0ab4c6cd68",
|
||||
"c9.ide.ace.emmet": "#6dc4585e02",
|
||||
"c9.ide.ace.gotoline": "#a8ff07c8f4",
|
||||
"c9.ide.ace.keymaps": "#43445d6306",
|
||||
"c9.ide.ace.repl": "#f3a62c1f2a",
|
||||
|
|
Ładowanie…
Reference in New Issue