具有自动完成的基于Web的代码编辑器

发布于 2025-01-20 19:53:24 字数 506 浏览 4 评论 0原文

我正在为我的

个人项目构建基于 Web 的代码编辑器。我想让它像 VS code 一样工作,但面临一些问题。

我正在使用 ACE 编辑器。

这是我在尝试自动完成时得到的结果。

输入图片这里的描述

我在尝试编写“os.(something)”时获得了所有可用的建议,而不是仅仅获得了语言和包的具体建议。

我想要的是这个。

输入图片此处描述

在这张图片中,如您所见,我仅收到与操作系统包相关的建议。

guys

I'm building the web based code editor for my personal project.I want to make it work like VS code but facing some issues.

I'm using ACE editor.

This is what I get while trying with autocompletion.

enter image description here

I'm getting all the available suggestions while trying to write "os.(something)", rather then just getting the language and package specific suggestions.

What I want is this.

enter image description here

In this pic as you can see I'm getting suggetion related to os package only.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无人问我粥可暖 2025-01-27 19:53:24

根据您使用Reirect-JS的设置,您可能还需要在页面的HTML中包含一个额外的JavaScript文件。您需要编写此简单的脚本来使用自动完成功能。

ace.require("ace/ext/language_tools");
var editor = ace.edit("editor");
editor.setOptions({
    enableBasicAutocompletion: true
});

演示: httpps://githbithub.com/ajaxorg/ajaxorg/ajaxorg/ace/blob/ master/demo/autocompletion.html

参考: https://github.com/ajaxorg/ace/wiki/how-to-to-now-to-enable-autocomplete-inocomplete-in-the-ace-editor

Depending on your setup with require-js, you may also need to include an additional javascript file in the html for your page. You need to write this simple script to working with the auto completion feature.

ace.require("ace/ext/language_tools");
var editor = ace.edit("editor");
editor.setOptions({
    enableBasicAutocompletion: true
});

Demo: https://github.com/ajaxorg/ace/blob/master/demo/autocompletion.html

Reference: https://github.com/ajaxorg/ace/wiki/How-to-enable-Autocomplete-in-the-Ace-editor

じ违心 2025-01-27 19:53:24

基于 HTML、JS、CSS

  1. 创建
  2. 创建<代码><脚本>
  3. 构建自动完成
  4. 脚本: functioncompile() { document.GetElementById('code').value = document.GetElementById('code').value.replaceAll('snippet1', 'Snippet1Value').replaceAll('snippet2', 'SnippetValue'). ...

例如:当您输入 _text_ (并将 snippet1 设置为 )时,您的textarea 将写入 。要创建选择器,请使用 json.contextmenu-library。

我知道,这只是一个计划,怎么做才是。

HTML, JS, CSS Based

  1. Create <textarea onkeyup=compile() id=code>. It should be big enaugt for code.
  2. Create <script> </script>
  3. Build the autocomplete
  4. Script: function compile() { document.GetElementById('code').value = document.GetElementById('code').value.replaceAll('snippet1', 'Snippet1Value').replaceAll('snippet2', 'SnippetValue'). ...

E.g.: When you enter _text_ (and you set snippet1 to <input type=text>) then your textarea will write <input type=text>. To create an picker, use a contextmenu-library at json.

I know, this is only an plan how to do is.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文