I'm working on a DSL and try to customize the webEditor.
(我正在使用DSL,并尝试自定义webEditor。)
Using the editor works fine as well as the autocompletion when called manually with "Ctrl + Space". (当使用“ Ctrl +空格”手动调用时,使用编辑器和自动补全功能一样好。)
Now it would be handy if hinting would be called after any keyup. (现在,如果在任何键入之后都调用提示,将很方便。)
I found several possible solutions here. (我在这里找到了几种可能的解决方案。)
Unfortunately, the pop-up window is not shown (but log messages are shown). (不幸的是,没有显示弹出窗口(但显示了日志消息)。)
Here is my code:
(这是我的代码:)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="en-us">
<title>Example Web Editor</title>
<link rel="stylesheet" type="text/css" href="webjars/codemirror/5.41.0/lib/codemirror.css" />
<link rel="stylesheet" type="text/css" href="xtext/2.17.0/xtext-codemirror.css" />
<link rel="stylesheet" type="text/css" href="webjars/codemirror/5.41.0/addon/hint/show-hint.css" />
<script type="text/javascript" src="webjars/codemirror/5.41.0/lib/codemirror.js"></script>
<script type="text/javascript" src="webjars/codemirror/5.41.0/addon/hint/show-hint.js"></script>
<script src="webjars/requirejs/2.3.6/require.min.js"></script>
<script type="text/javascript">
var baseUrl = window.location.pathname;
var fileIndex = baseUrl.indexOf("index.html");
if (fileIndex > 0)
baseUrl = baseUrl.slice(0, fileIndex)
require.config({
baseUrl : baseUrl,
paths : {
"jquery" : "webjars/jquery/3.3.1-1/jquery.min",
"xtext/xtext-codemirror" : "xtext/2.17.0/xtext-codemirror"
},
packages : [ {
name : "codemirror",
location : "webjars/codemirror/5.41.0",
main : "lib/codemirror"
} ]
});
require([ "xtext/xtext-codemirror" ], function(xtext) {
var editor = xtext.createEditor();
editor.on('inputRead', function onChange(editor, input) {
console.log("hey");
CodeMirror.commands.autocomplete(editor);
});
});
</script>
</head>
<body>
<div class="content">
<div id="xtext-editor" data-editor-xtext-lang="adv"></div>
</div>
</body>
</html>
Nothing fancy happens here, I just try to get the autocompletion after any keyup to work.
(这里没有任何幻想,我只是尝试在进行任何键盘输入后获得自动完成功能。)
ask by orangeblend translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…