Madhura KM
Madhura KM

Reputation: 140

UI-codemirror Addons

I am using UI-codemirror in angularjs application for java code editing with mode set to 'text/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.

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?

Upvotes: 0

Views: 656

Answers (1)

Albert
Albert

Reputation: 21

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);
})

Upvotes: 0

Related Questions