Created
May 17, 2014 20:45
-
-
Save RaymondLim/d9161c7206ede4566fd5 to your computer and use it in GitHub Desktop.
Test file for CM right click issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>CodeMirror Context Menu Issue</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
<script src="http://codemirror.net/lib/codemirror.js"></script> | |
<link rel="stylesheet" href="http://codemirror.net/lib/codemirror.css"> | |
</head> | |
<body> | |
<div id="code"></div> | |
<script> | |
// Set up the outer CodeMirror instance | |
var content = "Here's some content\nRight click on any word and you will get a selection from the beginning of the line.\nThen type any text you will see a red dot before the typed letter."; | |
var hostEditor = CodeMirror(document.getElementById("code"), { | |
lineNumbers: true, | |
lineWrapping: true, | |
mode: "html", | |
value: content | |
}); | |
$(window).contextmenu(function (e) { | |
e.preventDefault(); | |
var cursor = hostEditor.getCursor(); | |
hostEditor.setSelection({line: cursor.line, ch: 0}, {line: cursor.line, ch:cursor.ch}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment