~ubuntu-branches/ubuntu/utopic/codemirror-js/utopic

« back to all changes in this revision

Viewing changes to doc/upgrade_v2.2.html

  • Committer: Package Import Robot
  • Author(s): David Paleino
  • Date: 2012-04-12 12:25:28 UTC
  • Revision ID: package-import@ubuntu.com-20120412122528-8xp5a8frj4h1d3ee
Tags: upstream-2.23
ImportĀ upstreamĀ versionĀ 2.23

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!doctype html>
 
2
<html>
 
3
  <head>
 
4
    <title>CodeMirror: Upgrading to v2.2</title>
 
5
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/>
 
6
    <link rel="stylesheet" type="text/css" href="docs.css"/>
 
7
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 
8
  </head>
 
9
  <body>
 
10
 
 
11
<h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMirror</a></h1>
 
12
 
 
13
<pre class="grey">
 
14
<img src="baboon.png" class="logo" alt="logo"/>/* Upgrading to v2.2
 
15
 */
 
16
</pre>
 
17
 
 
18
<div class="left">
 
19
 
 
20
<p>There are a few things in the 2.2 release that require some care
 
21
when upgrading.</p>
 
22
 
 
23
<h2>No more default.css</h2>
 
24
 
 
25
<p>The default theme is now included
 
26
in <a href="../lib/codemirror.css"><code>codemirror.css</code></a>, so
 
27
you do not have to included it separately anymore. (It was tiny, so
 
28
even if you're not using it, the extra data overhead is negligible.)
 
29
 
 
30
<h2>Different key customization</h2>
 
31
 
 
32
<p>CodeMirror has moved to a system
 
33
where <a href="manual.html#option_keyMap">keymaps</a> are used to
 
34
bind behavior to keys. This means <a href="../demo/emacs.html">custom
 
35
bindings</a> are now possible.</p>
 
36
 
 
37
<p>Three options that influenced key
 
38
behavior, <code>tabMode</code>, <code>enterMode</code>,
 
39
and <code>smartHome</code>, are no longer supported. Instead, you can
 
40
provide custom bindings to influence the way these keys act. This is
 
41
done through the
 
42
new <a href="manual.html#option_extraKeys"><code>extraKeys</code></a>
 
43
option, which can hold an object mapping key names to functionality. A
 
44
simple example would be:</p>
 
45
 
 
46
<pre>  extraKeys: {
 
47
    "Ctrl-S": function(instance) { saveText(instance.getValue()); },
 
48
    "Ctrl-/": "undo"
 
49
  }</pre>
 
50
 
 
51
<p>Keys can be mapped either to functions, which will be given the
 
52
editor instance as argument, or to strings, which are mapped through
 
53
functions through the <code>CodeMirror.commands</code> table, which
 
54
contains all the built-in editing commands, and can be inspected and
 
55
extended by external code.</p>
 
56
 
 
57
<p>By default, the <code>Home</code> key is bound to
 
58
the <code>"goLineStartSmart"</code> command, which moves the cursor to
 
59
the first non-whitespace character on the line. You can set do this to
 
60
make it always go to the very start instead:</p>
 
61
 
 
62
<pre>  extraKeys: {"Home": "goLineStart"}</pre>
 
63
 
 
64
<p>Similarly, <code>Enter</code> is bound
 
65
to <code>"newlineAndIndent"</code> by default. You can bind it to
 
66
something else to get different behavior. To disable special handling
 
67
completely and only get a newline character inserted, you can bind it
 
68
to <code>false</code>:</p>
 
69
 
 
70
<pre>  extraKeys: {"Enter": false}</pre>
 
71
 
 
72
<p>The same works for <code>Tab</code>. If you don't want CodeMirror
 
73
to handle it, bind it to <code>false</code>. The default behaviour is
 
74
to indent the current line more (<code>"indentMore"</code> command),
 
75
and indent it less when shift is held (<code>"indentLess"</code>).
 
76
There are also <code>"indentAuto"</code> (smart indent)
 
77
and <code>"insertTab"</code> commands provided for alternate
 
78
behaviors. Or you can write your own handler function to do something
 
79
different altogether.</p>
 
80
 
 
81
<h2>Tabs</h2>
 
82
 
 
83
<p>Handling of tabs changed completely. The display width of tabs can
 
84
now be set with the <code>tabSize</code> option, and tabs can
 
85
be <a href="../demo/visibletabs.html">styled</a> by setting CSS rules
 
86
for the <code>cm-tab</code> class.</p>
 
87
 
 
88
<p>The default width for tabs is now 4, as opposed to the 8 that is
 
89
hard-wired into browsers. If you are relying on 8-space tabs, make
 
90
sure you explicitly set <code>tabSize: 8</code> in your options.</p>
 
91
 
 
92
</div>
 
93
 
 
94
  </body>
 
95
</html>