Skip to content

Instantly share code, notes, and snippets.

@RaymondLim
Created May 17, 2014 20:45
Show Gist options
  • Save RaymondLim/d9161c7206ede4566fd5 to your computer and use it in GitHub Desktop.
Save RaymondLim/d9161c7206ede4566fd5 to your computer and use it in GitHub Desktop.
Test file for CM right click issue
<!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