Skip to content

Commit e306b09

Browse files
matthewkastornightwing
authored andcommitted
adds modelist demo
1 parent a37b9ac commit e306b09

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

demo/mode_list.html

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6+
<title>Editor</title>
7+
<style type="text/css" media="screen">
8+
body {
9+
overflow: hidden;
10+
}
11+
12+
#editor {
13+
margin: 0;
14+
position: absolute;
15+
top: 0;
16+
bottom: 0;
17+
left: 0;
18+
right: 0;
19+
}
20+
</style>
21+
</head>
22+
<body>
23+
24+
<pre id="editor">Editor.prototype.showKeyboardShortcuts = function () {
25+
showKeyboardShortcuts(this);
26+
};
27+
editor.commands.addCommands([{
28+
name: "showKeyboardShortcuts",
29+
bindKey: {win: "Ctrl-Alt-h", mac: "Command-Alt-h"},
30+
exec: function(editor, line) {
31+
editor.showKeyboardShortcuts();
32+
}
33+
}]);
34+
</pre>
35+
36+
<script src="../build/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
37+
<script src="../build/src-noconflict/ext-modelist.js" type="text/javascript" charset="utf-8"></script>
38+
<script>
39+
var editor = ace.edit("editor");
40+
editor.setTheme("ace/theme/twilight");
41+
(function () {
42+
var modelist = ace.require('ace/ext/modelist');
43+
// the file path could come from an xmlhttp request, a drop event,
44+
// or any other scriptable file loading process.
45+
// Extensions could consume the modelist and use it to dynamically
46+
// set the editor mode. Webmasters could use it in their scripts
47+
// for site specific purposes as well.
48+
var filePath = 'blahblah/weee/some.js';
49+
var mode = modelist.getModeFromPath(filePath).mode;
50+
console.log(mode);
51+
editor.getSession().setMode(mode);
52+
}());
53+
54+
</script>
55+
56+
</body>
57+
</html>

0 commit comments

Comments
 (0)