简体   繁体   English

UI-codemirror插件

[英]UI-codemirror Addons

I am using UI-codemirror in angularjs application for java code editing with mode set to 'text/x-java'. 我在angularjs应用程序中使用UI-codemirror进行Java代码编辑,并将模式设置为“文本/ x-java”。 Now I want to use addons like autocomplete and lint. 现在,我想使用自动完成和皮棉之类的插件。

for autocomplete I set options as below with keyup and also with onKeyUp, both the events are not triggered. 对于自动完成功能,我使用keyup和onKeyUp设置了以下选项,这两个事件均不会触发。

configure options in controller: 在控制器中配置选项:

_this.editorOptions = {
        lineWrapping: true,
        lineNumbers: true,
        mode: 'text/x-java',
        smartIndent: true,
        tabSize: 4,
        indentWithTabs: true,
        tabindex: 4,
        autofocus: true,
        addModeClass: true,
        keyup: function (e, s) {
            console.log("Event Keyup");

        },
        onKeyUp: function (e, s) {
            console.log("Event Keyup");

        }
    }

Directive in the template: 模板中的指令:

<ui-codemirror ui-codemirror-opts="vm.editorOptions" ng-model="vm.activeQuestion.candidateAnswer"></ui-codemirror>

What are the addon js scripts to include and what configuration options to set for these to workout? 包括哪些addon js脚本,以及为锻炼设置哪些配置选项?

Get access to the editor; 获得对编辑器的访问权限; after that you can register a listener on it : 之后,您可以在其上注册一个侦听器:

var myCodeMirror = CodeMirror.fromTextArea(myTextArea);
myCodeMirror.on('change', function(codemirrorinstance)
{
    console.log(key pressed);
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM