better example code for modelist demo
This commit is contained in:
parent
e306b09232
commit
3d222a773a
1 changed files with 14 additions and 10 deletions
|
|
@ -21,16 +21,20 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<pre id="editor">Editor.prototype.showKeyboardShortcuts = function () {
|
<pre id="editor">var editor = ace.edit("editor");
|
||||||
showKeyboardShortcuts(this);
|
editor.setTheme("ace/theme/twilight");
|
||||||
};
|
(function () {
|
||||||
editor.commands.addCommands([{
|
var modelist = ace.require('ace/ext/modelist');
|
||||||
name: "showKeyboardShortcuts",
|
// the file path could come from an xmlhttp request, a drop event,
|
||||||
bindKey: {win: "Ctrl-Alt-h", mac: "Command-Alt-h"},
|
// or any other scriptable file loading process.
|
||||||
exec: function(editor, line) {
|
// Extensions could consume the modelist and use it to dynamically
|
||||||
editor.showKeyboardShortcuts();
|
// set the editor mode. Webmasters could use it in their scripts
|
||||||
}
|
// for site specific purposes as well.
|
||||||
}]);
|
var filePath = 'blahblah/weee/some.js';
|
||||||
|
var mode = modelist.getModeFromPath(filePath).mode;
|
||||||
|
console.log(mode);
|
||||||
|
editor.getSession().setMode(mode);
|
||||||
|
}());
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<script src="../build/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
|
<script src="../build/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue