How to embed ace editor in my website

11,146

Embedding to your website is clearly shown on the website: http://ace.c9.io/#nav=embedding

Example:

<!DOCTYPE html>
<html lang="en">
<head>
<title>ACE in Action</title>
<style type="text/css" media="screen">
    #editor { 
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
    }
</style>
</head>
<body>

<div id="editor">function foo(items) {
    var x = "All this is syntax highlighted";
    return x;
}</div>

<script src="/ace-builds/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
    var editor = ace.edit("editor");
    editor.setTheme("ace/theme/monokai");
    editor.getSession().setMode("ace/mode/javascript");
</script>
</body>
</html>

Cloud9 IDE

If your using the cloud9 IDE, you can download the editor via..

  • Github: git clone git://github.com/ajaxorg/ace.git
  • Bower: bower install --save git clone git://github.com/ajaxorg/ace.git

NOTE: you will need to build the project.

If you want to use the pre built ones use this instead: https://github.com/ajaxorg/ace-builds.git

Example Here's my setup for the ace-editor: https://ide.c9.io/anik786/cloud-9-sandbox

Share:
11,146
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin about 2 years

    Guys lately i have been using the cloud9 ide and i wanted to add the ace editor to me website. To view the ace editor, here is the link: http://ace.c9.io/#nav=about

    Can someone please tell me how to embed it in my website. I cant understand the tutorial given on the homepage of the ace editor

    All help is appreciated.

  • Admin
    Admin almost 9 years
    Thanks a ton bro it worked
  • JohnnyBizzle
    JohnnyBizzle over 7 years
    Unfortunately this wipes out everything else you might want to show.
  • Stefan Steiger
    Stefan Steiger over 7 years
    @JohnnyBizzle: LoL, just change the css and remove the absolute.
  • Kraang Prime
    Kraang Prime over 5 years
    I would hardly call ace-builds as built. Each feature is a separate file (such as autocomplete, etc). For language files, this is fine, but for every feature ?? Would be nice if there was a true "pre-built" version somewhere or a builder, or even instructions on how to "build" the pre-built stuff into a single js. Their builder is rather lazy with lots of **/*.js so the output is directed to the same messy structure as the input.
  • Nic Scozzaro
    Nic Scozzaro about 5 years
    Here's where the snippet above comes from: github.com/ajaxorg/ace-builds/blob/master/editor.html