12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>ACE Autocompletion demo</title>
- <style type="text/css" media="screen">
- body { overflow: hidden; }
- #editor {
- margin: 0; position: absolute;
- top: 0; bottom: 0; left: 0; right: 0;
- }
- </style>
- </head>
- <body>
- <pre id="editor"></pre>
- <!-- load ace -->
- <script src="../src/ace.js"></script>
- <!-- load ace language_tools extension -->
- <script src="../src/ext-language_tools.js"></script>
- <script>
- var langagueTools = require("ace/ext/language_tools");
- var editor = ace.edit("editor");
- editor.session.setMode("ace/mode/html");
- editor.setTheme("ace/theme/tomorrow");
- // enable autocompletion and snippets
- editor.setOptions({
- enableBasicAutocompletion: true,
- enableSnippets: true,
- enableLiveAutocompletion: false
- });
- //editor.completers.length = 0
- editor.completers.push({
- getCompletions: function(editor, session, pos, prefix, callback) {
- setTimeout(function() {
- callback(null, [{
- // string used for filtering
- value: "customCompletion",
- // optional, allows to display a caption different from value
- caption: "!!customCompletion!!",
- // optional, snippet that can be inseted instead of value
- snippet: "${2}insert${1:This}${2}Instead$0",
- // short description
- meta: "foo"
- }, {
- value: "customCompletion2"
- }]);
- }, 500);
- }
- });
- </script>
- <script src="./show_own_source.js"></script>
- </body>
- </html>
|