首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用CodeMirror作为elFinder编辑器

使用CodeMirror作为elFinder编辑器
EN

Stack Overflow用户
提问于 2013-12-03 19:02:27
回答 1查看 1.3K关注 0票数 2

CodeMirror和elFinder!在任何地方都找不到例子,所以必须弄清楚。最终结果是很简单的,但是我花了一点时间才弄清楚,所以我发了这个帖子,因为最终肯定会有人需要它。

代码语言:javascript
复制
$().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');

});
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-05-23 09:59:03

答案在上面!我真应该把这个问题当作一个问题来问,然后再回答。抱歉的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20359471

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档