简体   繁体   English

如何禁用 ACE 编辑器中的语法检查器?

[英]how can I disable the syntax checker in ACE editor?

Hello I'm using the ACE editor and I would like to disable the syntax checker, I've found that removing the worker-javascript.js file seems to do the trick but I hope there's a cleaner way as I'm not sure what else I'm disabling or even breaking by removing that file.您好,我正在使用ACE 编辑器,我想禁用语法检查器,我发现删除worker-javascript.js文件似乎可以解决问题,但我希望有一种更简洁的方法,因为我不确定是什么否则我通过删除该文件来禁用甚至破坏。

Thanks.谢谢。

I also didn't find this in documentation, so I've looked at ACE source code.我也没有在文档中找到这个,所以我查看了 ACE 源代码。 You can disable worker with the following lines of code:您可以使用以下代码行禁用 worker:

var editor = ace.edit(document.getElementById('test'));
editor.getSession().setUseWorker(false);

There's a more efficient way of achieving this.有一种更有效的方法来实现这一点。 Instead of spawning a worker for stopping it immediately after, is better to directly tell the editor to not spawn a worker, like this:最好直接告诉编辑器不要产生一个工人,而不是立即产生一个工人来停止它,像这样:

ace.edit(document.getElementById('test'), {
    useWorker: false
});

If you are using React with the react-ace wrapper you must use the setOptions prop to disable the ACE syntax checker:如果您将Reactreact-ace包装器一起使用,则必须使用setOptions属性来禁用 ACE 语法检查器:

  <AceEditor
    mode="css"
    theme="github"
    onChange={onChange}
    name="UNIQUE_ID_OF_DIV"
    editorProps={{ $blockScrolling: true }}
    setOptions={{
      useWorker: false // <<----- USE THIS OPTION TO DISABLE THE SYNTAX CHECKER
    }}
  />,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM