how to embed a code editor in a page?

前端 未结 3 892
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-01 06:17

Problem

I want to create a page with a code editor embedded in it.I looked up codemirror
but i am having problems using it as i am new to java script.
<         


        
相关标签:
3条回答
  • 2021-01-01 06:46

    There is another embeddable JavaScript code editor: CodeJar

    0 讨论(0)
  • 2021-01-01 07:07

    Try Ace: https://github.com/ajaxorg/ace (source) http://ace.ajax.org/ (Project page), this JavaScript editor is used by Cloud9

    0 讨论(0)
  • 2021-01-01 07:09

    I know this is old post , This is how i did while developing online code-editor you can use ace-editor

    check this sample from ace

    <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="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.5/ace.js" type="text/javascript" charset="utf-8"></script>
    <script>
        var editor = ace.edit("editor");
        editor.setTheme("ace/theme/monokai");
        editor.session.setMode("ace/mode/javascript");
    </script>
    </body>
    </html>

    0 讨论(0)
提交回复
热议问题