markselection.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>CodeMirror: Match Highlighter Demo</title>
  6. <link rel="stylesheet" href="../lib/codemirror.css">
  7. <script src="../lib/codemirror.js"></script>
  8. <script src="../addon/search/searchcursor.js"></script>
  9. <script src="../addon/selection/mark-selection.js"></script>
  10. <link rel="stylesheet" href="../doc/docs.css">
  11. <style type="text/css">
  12. .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
  13. .CodeMirror-selected { background-color: blue !important; }
  14. .CodeMirror-selectedtext { color: white; }
  15. </style>
  16. </head>
  17. <body>
  18. <h1>CodeMirror: Mark Selection Demo</h1>
  19. <form><textarea id="code" name="code">Select something from here.
  20. You'll see that the selection's foreground color changes to white!
  21. Since, by default, CodeMirror only puts an independent "marker" layer
  22. behind the text, you'll need something like this to change its colour.</textarea></form>
  23. <script>
  24. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  25. lineNumbers: true,
  26. styleSelectedText: true
  27. });
  28. </script>
  29. <p>Simple addon to easily mark (and style) selected text.</p>
  30. </body>
  31. </html>