CodeMirror 与 elFinder!无法在任何地方找到示例,因此必须弄清楚。最终结果很简单,但花了一点时间才弄清楚,所以我发布这个是因为那里的某个人最终一定会需要它。
$().ready(function() {
var elf = $('#elfinder').elfinder({
url : 'elfinder-2.0-rc1/php/connector.php',
commandsOptions: {
edit : {
// list of allowed mimetypes to edit
// if empty - any text files can be edited
mimes : ['text/plain', 'text/html', 'text/javascript', 'text/css'],
// you can have a different editor for different mimes
editors : [{
mimes : ['text/plain', 'text/html', 'text/javascript', 'text/css'],
load : function(textarea) {
this.myCodeMirror = CodeMirror.fromTextArea(textarea, {
lineNumbers: true,
theme: "xq-dark"
})
},
close : function(textarea, instance) {
this.myCodeMirror = null;
},
save : function(textarea, editor) {
textarea.value = this.myCodeMirror.getValue();
this.myCodeMirror = null;
}
} ] //editors
} //edit
} //commandsoptions
}).elfinder('instance');
});