|
12 | 12 | .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;} |
13 | 13 | .CodeMirror-selected { background-color: blue !important; } |
14 | 14 | .CodeMirror-selectedtext { color: white; } |
| 15 | + .styled-background { background-color: #ff7; } |
15 | 16 | </style> |
16 | 17 | <div id=nav> |
17 | 18 | <a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a> |
|
28 | 29 |
|
29 | 30 | <article> |
30 | 31 | <h2>Selection Marking Demo</h2> |
31 | | -<form><textarea id="code" name="code">Select something from here. |
32 | | -You'll see that the selection's foreground color changes to white! |
33 | | -Since, by default, CodeMirror only puts an independent "marker" layer |
34 | | -behind the text, you'll need something like this to change its colour.</textarea></form> |
| 32 | +<form><textarea id="code" name="code"> |
| 33 | +Select something from here. You'll see that the selection's foreground |
| 34 | +color changes to white! Since, by default, CodeMirror only puts an |
| 35 | +independent "marker" layer behind the text, you'll need something like |
| 36 | +this to change its colour. |
| 37 | + |
| 38 | +Also notice that turning this addon on (with the default style) allows |
| 39 | +you to safely give text a background color without screwing up the |
| 40 | +visibility of the selection.</textarea></form> |
35 | 41 |
|
36 | 42 | <script> |
37 | 43 | var editor = CodeMirror.fromTextArea(document.getElementById("code"), { |
38 | 44 | lineNumbers: true, |
39 | 45 | styleSelectedText: true |
40 | 46 | }); |
| 47 | +editor.markText({line: 6, ch: 26}, {line: 6, ch: 42}, {className: "styled-background"}); |
41 | 48 | </script> |
42 | 49 |
|
43 | 50 | <p>Simple addon to easily mark (and style) selected text.</p> |
|
0 commit comments