Skip to content

Instantly share code, notes, and snippets.

@alexbaumgertner
Last active November 3, 2015 15:00
Show Gist options
  • Select an option

  • Save alexbaumgertner/9a252f45c5f9151674ca to your computer and use it in GitHub Desktop.

Select an option

Save alexbaumgertner/9a252f45c5f9151674ca to your computer and use it in GitHub Desktop.
// api: fromTextArea
// https://github.com/codemirror/CodeMirror/blob/a11ccbefa281a0e728b7431ba52f550854831ea6/lib/codemirror.js#L5888
var editor = targetIsTextarea ? CodeMirror.fromTextArea(target, editorOptions) : target;
// api: setCursor
// https://github.com/codemirror/CodeMirror/blob/a11ccbefa281a0e728b7431ba52f550854831ea6/lib/codemirror.js#L7438
// api: posFromIndex
// https://github.com/codemirror/CodeMirror/blob/a11ccbefa281a0e728b7431ba52f550854831ea6/lib/codemirror.js#L7624
editor.setCursor(editor.posFromIndex(initialPos));
// api: getWrapperElement
// https://github.com/codemirror/CodeMirror/blob/master/lib/codemirror.js#L5318
var wrapper = editor.getWrapperElement();
// api: https://github.com/codemirror/CodeMirror/blob/master/lib/codemirror.js#L5138
editor.execCommand('revert');
// api: https://github.com/codemirror/CodeMirror/blob/master/lib/codemirror.js#L1372
editor.focus();
// api: https://github.com/codemirror/CodeMirror/blob/master/lib/codemirror.js#L2184
editor.setSelection(curPos, curPos);
// api: https://github.com/codemirror/CodeMirror/blob/master/lib/codemirror.js#L7624
return posObj(editor.posFromIndex(pos));
// api: https://github.com/codemirror/CodeMirror/blob/master/lib/codemirror.js#L2817
return sanitizeCaretPos(editor.cursorCoords(true));
// api: https://github.com/codemirror/CodeMirror/blob/master/lib/codemirror.js#L2809
return sanitizeCaretPos(editor.charCoords(pos));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment