add wrap_with_abbreviation emmet command
This commit is contained in:
parent
e97d7609b9
commit
8530e3837a
1 changed files with 17 additions and 7 deletions
|
|
@ -51,6 +51,8 @@ AceEmmetEditor.prototype = {
|
|||
setupContext: function(editor) {
|
||||
this.ace = editor;
|
||||
this.indentation = editor.session.getTabString();
|
||||
if (!emmet)
|
||||
emmet = window.emmet;
|
||||
emmet.require("resources").setVariable("indentation", this.indentation);
|
||||
this.$syntax = null;
|
||||
this.$syntax = this.getSyntax();
|
||||
|
|
@ -161,7 +163,7 @@ AceEmmetEditor.prototype = {
|
|||
*/
|
||||
replaceContent: function(value, start, end, noIndent) {
|
||||
if (end == null)
|
||||
end = start == null ? content.length : start;
|
||||
end = start == null ? this.getContent().length : start;
|
||||
if (start == null)
|
||||
start = 0;
|
||||
var utils = emmet.require("utils");
|
||||
|
|
@ -228,7 +230,7 @@ AceEmmetEditor.prototype = {
|
|||
if (state.length > 1)
|
||||
syntax = state[0];
|
||||
else if (syntax == "php")
|
||||
syntax = "html"
|
||||
syntax = "html";
|
||||
}
|
||||
}
|
||||
return syntax;
|
||||
|
|
@ -309,12 +311,13 @@ var keymap = {
|
|||
// update_image_size: {"mac": "shift+ctrl+i", "win": "ctrl+u"},
|
||||
// expand_as_you_type: "ctrl+alt+enter",
|
||||
// wrap_as_you_type: {"mac": "shift+ctrl+g", "win": "shift+ctrl+g"},
|
||||
expand_abbreviation_with_tab: "Tab"
|
||||
expand_abbreviation_with_tab: "Tab",
|
||||
wrap_with_abbreviation: {"mac": "shift+ctrl+a", "win": "shift+ctrl+a"}
|
||||
};
|
||||
|
||||
var editorProxy = new AceEmmetEditor();
|
||||
exports.commands = new HashHandler();
|
||||
function runEmmetCommand(editor) {
|
||||
exports.runEmmetCommand = function(editor) {
|
||||
editorProxy.setupContext(editor);
|
||||
if (editorProxy.getSyntax() == "php")
|
||||
return false;
|
||||
|
|
@ -325,6 +328,13 @@ function runEmmetCommand(editor) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (this.action == "wrap_with_abbreviation") {
|
||||
// without setTimeout prompt doesn't work on firefox
|
||||
return setTimeout(function() {
|
||||
actions.run("wrap_with_abbreviation", editorProxy);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
try {
|
||||
var result = actions.run(this.action, editorProxy);
|
||||
} catch(e) {
|
||||
|
|
@ -332,14 +342,14 @@ function runEmmetCommand(editor) {
|
|||
console.log(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
for (var command in keymap) {
|
||||
exports.commands.addCommand({
|
||||
name: "emmet:" + command,
|
||||
action: command,
|
||||
bindKey: keymap[command],
|
||||
exec: runEmmetCommand,
|
||||
exec: exports.runEmmetCommand,
|
||||
multiSelectAction: "forEach"
|
||||
});
|
||||
}
|
||||
|
|
@ -359,7 +369,7 @@ var onChangeMode = function(e, target) {
|
|||
};
|
||||
|
||||
|
||||
exports.AceEmmetEditor = AceEmmetEditor
|
||||
exports.AceEmmetEditor = AceEmmetEditor;
|
||||
require("ace/config").defineOptions(Editor.prototype, "editor", {
|
||||
enableEmmet: {
|
||||
set: function(val) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue