mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(edit) mv options to file
This commit is contained in:
parent
8b0ae4fca7
commit
457cf9f5fd
2 changed files with 65 additions and 30 deletions
13
json/edit.json
Normal file
13
json/edit.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"options": {
|
||||
"enableBasicAutocompletion": true,
|
||||
"enableSnippets": false,
|
||||
"showPrintMargin": false,
|
||||
"showInvisibles": true,
|
||||
"useSoftTabs": true
|
||||
},
|
||||
|
||||
"extensions": {
|
||||
"emmet": false
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
|
|||
Events = DOM.Events,
|
||||
Dialog = DOM.Dialog,
|
||||
Images = DOM.Images,
|
||||
Element, JSHintConfig;
|
||||
Element, JSHintConfig, EditConfig;
|
||||
|
||||
function init() {
|
||||
Loading = true;
|
||||
|
|
@ -83,28 +83,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
|
|||
Session.setMode(mode);
|
||||
setUseOfWorker(mode);
|
||||
|
||||
Util.ifExec(Emmet, function() {
|
||||
if (Emmet)
|
||||
Ace.setOption('enableEmmet', isHTML);
|
||||
}, function(callback) {
|
||||
var url;
|
||||
|
||||
if (!isHTML)
|
||||
Util.exec(callback);
|
||||
else {
|
||||
url = CloudFunc.getJoinURL([
|
||||
DIR + 'emmet.js',
|
||||
DIR + 'ext-emmet.js'
|
||||
]);
|
||||
|
||||
DOM.jsload(url, function() {
|
||||
Emmet = ace.require('ace/ext/emmet');
|
||||
Emmet.setCore(window.emmet);
|
||||
Util.exec(callback);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
setEmmet(isHTML);
|
||||
|
||||
Util.ifExec(isStr, function() {
|
||||
var UndoManager = ace.require('ace/undomanager').UndoManager;
|
||||
|
|
@ -142,6 +121,36 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
|
|||
Ace.gotoLine(number);
|
||||
};
|
||||
|
||||
function setEmmet(isHTML) {
|
||||
getEditConfig(function(config) {
|
||||
var extensions = config.extensions,
|
||||
isEmmet = extensions.emmet;
|
||||
|
||||
if (isEmmet)
|
||||
Util.ifExec(Emmet, function() {
|
||||
if (Emmet)
|
||||
Ace.setOption('enableEmmet', isHTML);
|
||||
}, function(callback) {
|
||||
var url;
|
||||
|
||||
if (!isHTML)
|
||||
Util.exec(callback);
|
||||
else {
|
||||
url = CloudFunc.getJoinURL([
|
||||
DIR + 'emmet.js',
|
||||
DIR + 'ext-emmet.js'
|
||||
]);
|
||||
|
||||
DOM.jsload(url, function() {
|
||||
Emmet = ace.require('ace/ext/emmet');
|
||||
Emmet.setCore(window.emmet);
|
||||
Util.exec(callback);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function setUseOfWorker(mode) {
|
||||
var isMatch,
|
||||
isStr = Util.isString(mode),
|
||||
|
|
@ -160,10 +169,6 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
|
|||
|
||||
Ace.setTheme('ace/theme/tomorrow_night_blue');
|
||||
|
||||
Ace.setShowPrintMargin(false);
|
||||
Ace.setShowInvisibles(true);
|
||||
Session.setUseSoftTabs(true);
|
||||
|
||||
Ace.commands.addCommand({
|
||||
name : 'hide',
|
||||
bindKey : { win: 'Esc', mac: 'Esc' },
|
||||
|
|
@ -195,9 +200,10 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
|
|||
ace.require('ace/ext/language_tools');
|
||||
Modelist = ace.require('ace/ext/modelist');
|
||||
|
||||
Ace.setOptions({
|
||||
enableBasicAutocompletion : true,
|
||||
enableSnippets : true
|
||||
getEditConfig(function(config) {
|
||||
var options = config.options;
|
||||
|
||||
Ace.setOptions(options);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -326,6 +332,22 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
|
|||
});
|
||||
}
|
||||
|
||||
function getEditConfig(callback) {
|
||||
var CONFIG_PATH = '/json/edit.json',
|
||||
func = Util.retExec(callback);
|
||||
|
||||
Util.ifExec(EditConfig, function() {
|
||||
func(EditConfig);
|
||||
}, function() {
|
||||
DOM.ajax({
|
||||
url : CONFIG_PATH,
|
||||
success : function(data) {
|
||||
EditConfig = data;
|
||||
func(EditConfig);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function load(callback) {
|
||||
var files = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue