javascriptjqueryetherpadmathquill

How to put cursor to the MathQuill (0.10) field so that one can type to edit right away?


I'm developing a simple plugin for Etherpad to edit formulae using MathQuill. When the toolbar is opened, I'd like the cursor to get into the edit field. The field is mathquillified like this:

var MQ = MathQuill.getInterface(2);
var mathQuillEditor = MQ.MathField(mathQuillField, {
    spaceBehavesLikeTab: true,
    handlers: {
        edit: function() {
            latexEditor.value = mathQuillEditor.latex(); // update LaTeX field
            jQuery(latexEditor).change(); // fire updating of CodeCogs
        }
    }
});

To get cursor in the edit field, I've tried:

mathQuillEditor.moveToRightEnd();

which visually puts the cursor there, but the blue margin (that points that the editor is active) does not appear and typing doesn't make any effect; and

mathQuillEditor.el().focus();

which doesn't make any visual difference. I've also tried to combine those, but still no success. Any ideas how to do this?


Solution

  • Ok, this wasn't documented, the answer is simply

    mathQuillEditor.focus();
    

    After I've rised an issue, this was explained and docs now contain this method.