【问题标题】:syntax highlighter for CSS (ace ajax)CSS 的语法高亮器(ace ajax)
【发布时间】:2011-11-21 19:23:27
【问题描述】:

我已经在ace 上工作了几天,但我仍然无法正确使用 css,一直在尝试在线寻找解决方案或 ace weki/ 文档等,但一点运气都没有。

这是我的attempt 用ace高亮css,但它在firefox上有这些错误信息,

Could not load worker ace.js (line 1)
Error: Could not get domain! [Break On This Error] define("ace/mode/css",["require","expo...).call(f.prototype),b.WorkerClient=f})

任何想法这意味着什么以及如何解决它?

整个代码,

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Ace editor</title>
    <style>
    #ace-editor {
        position: absolute;
        width: 500px;
        height: 400px;
    }
    </style>

    <script src="jquery-1.7.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="src/ace.js" type="text/javascript" charset="utf-8"></script>
    <script src="src/theme-eclipse.js" type="text/javascript" charset="utf-8"></script>
    <script src="src/mode-css.js" type="text/javascript" charset="utf-8"></script>

    <script>
    $(document).ready(function(){

        var editor = ace.edit("ace-editor");
        editor.setTheme("ace/theme/eclipse");

        var CssMode = require("ace/mode/css").Mode;
        editor.getSession().setMode(new CssMode());

        //var textarea = $('.code').hide();
        var textarea = $('.code');

        // Get the value from the editor and place it into the texrarea.
        var text = editor.getSession().getValue();
        textarea.val(text);

        // Update the textarea on change.
        editor.getSession().on('change', function(){

            // Get the value from the editor and place it into the texrarea.
            var text = editor.getSession().getValue();
            textarea.val(text);
            //alert(text);
        });

        $('#form_data').submit(function(e){
            //alert($(this).serialize());

            var object = $(this);
            var path = object.attr('action');

            alert(object.serialize());

            $.post(path, object.serialize(),function(xml){

            });
            return false;
        });
    });
    </script>
</head>
<body>

<form action="data.php" method="post" enctype="multipart/form-data" id="form_data" class="set-form">

    <textarea rows="5" cols="10" class="code" name="ace-editor"></textarea>

    <div style="height:450px; border:1px solid #000;">
        <div id="ace-editor"><style>.text-layer {
    font-family: Monaco, "Courier New", monospace;
    font-size: 12px;
    cursor: text;
}</style></div>
    </div>

<input type="submit" name="submit" value="submit"/>

</form>

</body>
</html>

【问题讨论】:

    标签: jquery css syntax-highlighting


    【解决方案1】:

    所以这是 Firefox 中的一个错误,仅出现在 Localhost 上,并且在一年前已修复:

    https://github.com/ajaxorg/ace/issues/526#issuecomment-2876359

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-05
      • 1970-01-01
      • 2011-07-25
      • 2020-04-19
      • 1970-01-01
      相关资源
      最近更新 更多