Skip to content

Commit 5b55680

Browse files
committed
add CodeMirror.listModes/listMIMEs()
1 parent 4eac2a5 commit 5b55680

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/codemirror.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,18 @@ var CodeMirror = (function() {
13581358
}
13591359
return mfactory(options, config);
13601360
}
1361+
CodeMirror.listModes = function() {
1362+
var list = [];
1363+
for (var m in modes)
1364+
if (modes.propertyIsEnumerable(m)) list.push(m);
1365+
return list;
1366+
};
1367+
CodeMirror.listMIMEs = function() {
1368+
var list = [];
1369+
for (var m in mimeModes)
1370+
if (mimeModes.propertyIsEnumerable(m)) list.push(m);
1371+
return list;
1372+
};
13611373

13621374
CodeMirror.fromTextArea = function(textarea, options) {
13631375
if (!options) options = {};

manual.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ <h2 id="config">Configuration</h2>
117117
a <code>name</code> property that names the mode (for
118118
example <code>{name: "javascript", json: true}</code>). The demo
119119
pages for each mode contain information about what configuration
120-
parameters the mode supports.</dd>
120+
parameters the mode supports. You can ask CodeMirror which modes
121+
and MIME types are loaded with
122+
the <code>CodeMirror.listModes</code>
123+
and <code>CodeMirror.listMIMEs</code> functions.</dd>
121124

122125
<dt id="option_indentUnit"><code>indentUnit (integer)</code></dt>
123126
<dd>How many spaces a block (whatever that means in the edited

0 commit comments

Comments
 (0)