ace README

The project's README from github.com/ajaxorg/ace. As one markdown file: README.md.

Ace (Ajax.org Cloud9 Editor)

Build Status npm

Note: The new site at http://ace.c9.io contains all the info below along with an embedding guide and all the other resources you need to get started with Ace.

Ace is a standalone code editor written in JavaScript. Our goal is to create a browser based editor that matches and extends the features, usability and performance of existing native editors such as TextMate, Vim or Eclipse. It can be easily embedded in any web page or JavaScript application. Ace is developed as the primary editor for Cloud9 IDE and the successor of the Mozilla Skywriter (Bespin) Project.

Features

Take Ace for a spin!

Check out the Ace live demo or get a Cloud9 IDE account to experience Ace while editing one of your own GitHub projects.

If you want, you can use Ace as a textarea replacement thanks to the Ace Bookmarklet.

Embedding Ace

Ace can be easily embedded into any existing web page. You can either use one of pre-packaged versions of ace (just copy one of src* subdirectories somewhere into your project), or use requireJS to load contents of lib/ace as ace

The easiest version is simply:

<div id="editor">some text</div>
<script src="src/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
    var editor = ace.edit("editor");
</script>

Exploring configuration options Configuring-Ace

With "editor" being the id of the DOM element, which should be converted to an editor. Note that this element must be explicitly sized and positioned absolute or relative for Ace to work. e.g.

#editor {
    position: absolute;
    width: 500px;
    height: 400px;
}

To change the theme simply include the Theme's JavaScript file

<script src="src/theme-twilight.js" type="text/javascript" charset="utf-8"></script>

and configure the editor to use the theme:

editor.setTheme("ace/theme/twilight");

By default the editor only supports plain text mode; many other languages are available as separate modules. After including the mode's JavaScript file:

<script src="src/mode-javascript.js" type="text/javascript" charset="utf-8"></script>

The mode can then be used like this:

var JavaScriptMode = ace.require("ace/mode/javascript").Mode;
editor.session.setMode(new JavaScriptMode());

to destroy editor use

editor.destroy();
editor.container.remove();

Documentation

Additional usage information, including events to listen to and extending syntax highlighters, can be found on the main Ace website.

You can also find API documentation at https://ajaxorg.github.io/ace-api-docs/.

Also check out the sample code for the kitchen sink demo app.

If you still need help, feel free to ask a question on our discussions page.

Running Ace

After the checkout Ace works out of the box. No build step is required. To try it out, simply start the bundled mini HTTP server using Node.JS

node ./static.js

The editor can then be opened at http://localhost:8888/kitchen-sink.html.

To open the editor with a file:/// URL see the wiki.

Building Ace

You do not generally need to build ACE. The ace-builds repository endeavours to maintain the latest build, and you can just copy one of src* subdirectories somewhere into your project.

However, all you need is Node.js and npm installed to package ACE. Just run npm install in the ace folder to install dependencies:

npm install
node ./Makefile.dryice.js

To package Ace, we use the dryice build tool developed by the Mozilla Skywriter team. Call node Makefile.dryice.js on the command-line to start the packing. This build script accepts the following options

-m                 minify build files with uglify-js          
-nc                namespace require and define calls with "ace"
-bm                builds the bookmarklet version
--target ./path    specify relative path for output folder (default value is "./build")

To generate all the files in the ace-builds repository, run node Makefile.dryice.js full --target ../ace-builds

Running the Unit Tests

The Ace unit tests can run on node.js. Assuming you have already done npm install, just call:

npm run test

You can also run the tests in your browser by serving:

http://localhost:8888/src/test/tests.html

This makes debugging failing tests much easier.

Contributing

Ace is a community project and wouldn't be what it is without contributions! We actively encourage and support contributions. The Ace source code is released under the BSD License. This license is very simple, and is friendly to all kinds of projects, whether open source or not. Take charge of your editor and add your favorite language highlighting and keybindings!

Feel free to fork and improve/enhance Ace any way you want. If you feel that the editor or the Ace community will benefit from your changes, please open a pull request. For more information on our contributing guidelines, see CONTRIBUTING.md.

ace (ajaxorg/ace)

Searching Database…

27.1K ·GitHub
这是什么?Ace 是一个独立的开源代码编辑器,用 JavaScript 编写,目标是在功能、易用性和性能上与 TextMate、Vim、Eclipse 等原生编辑器相当,并且可以嵌入到任何网页或 JS 应用中。
这是一个独立应用,还是我可以嵌入自己页面里的库?它是一个 JavaScript 库/组件,而不是独立应用。你只需将它指向自己网页中一个已设定尺寸、采用绝对或相对定位的 DOM 元素,即可把该元素变成编辑器。
我该如何把 Ace 添加到我的项目中?将预打包的 'src' 子目录之一复制到你的项目中,或通过 requireJS 加载 lib/ace 的内容,然后对你的 DOM 元素的 id 调用 ace.edit。
只是使用这个编辑器,也需要安装 Node.js 吗?不需要,嵌入 Ace 只需要预打包的 JS 文件;只有当你想从源码构建 Ace 或运行其测试套件时,才需要 Node.js 和 npm。
Ace 能处理的文档大小有上限吗?Ace 的设计目标是处理超大文档,但据最近一次确认,它能应对的上限约为 400 万行。
Ace 开箱即用支持多少种语言和主题?Ace 内置了 120 多种语言的语法高亮和 20 多款内置主题,并且可以导入 TextMate/Sublime 的 .tmlanguage 和 .tmtheme 文件。
有哪些键位绑定模式可用?Ace 提供完全可自定义的键位绑定,并内置 Vim 和 Emacs 模拟模式。
Ace 与 Cloud9 IDE 是什么关系?Ace 最初是为 Cloud9 IDE 打造的主要编辑器,它也是 Mozilla Skywriter(Bespin)项目的后继者。
Ace 支持多光标或实时错误检查吗?支持。它既支持多光标和多选区,也内置了针对 JavaScript、CoffeeScript、CSS 和 XQuery 的实时语法检查器;更广泛的语言检查可通过独立的 ace-linters 项目实现。
Creator
ajaxorg
Size
43.8 MB
Stars
27.1K
Age
15y
Commits · 90 Days