Search code examples
javascriptcursorfocuspreviewepiceditor

EpicEditor: editor.preview() remove cursor from another form element


I have a input field when I placed focus and then trying to load epiceditor on a textarea and try to set preview mode. So preview mode working prefect, but the problem is it removed the cursor from the text field.

Is there a way to load epiceditor and set preview mode and cursor stay on the input field?


Solution

  • editor.on('preview', function () {
      $(editor.getElement('previewer')).find('input').focus();
    });
    

    The previous code runs each time preview is opened. It then gets the preview iframes body then lastly finds the first input and focuses