0

我在 angularjs 应用程序中使用 UI-codemirror 进行 java 代码编辑,模式设置为“text/x-java”。现在我想使用自动完成和 lint 之类的插件。

对于自动完成,我使用 keyup 和 onKeyUp 设置了如下选项,这两个事件都不会被触发。

在控制器中配置选项:

_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");

        }
    }

模板中的指令:

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

要包含哪些插件 js 脚本以及为这些脚本设置哪些配置选项以进行锻炼?

4

1 回答 1

0

访问编辑器;之后,您可以在其上注册一个侦听器:

var myCodeMirror = CodeMirror.fromTextArea(myTextArea);
myCodeMirror.on('change', function(codemirrorinstance)
{
    console.log(key pressed);
})
于 2017-11-14T11:04:18.333 回答