CSS 语法荧光笔 (ace ajax)

发布于 2024-12-17 02:23:26 字数 2952 浏览 4 评论 0原文

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

这是我尝试用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>

I have been working on the ace for a few days but I still cannot get it worked with css properly, been trying to look for solutions online or ace weki/ documentation, etc, but no luck at all.

This is my attempt to highlight css with ace, but it has these error message on 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})

Any ideas what that means and how to fix it?

The entire code,

<!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>

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

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

发布评论

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

评论(1

梦里泪两行 2024-12-24 02:23:26

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

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

So this was a bug in Firefox that appears only on Localhost and that have been fixed a year ago:

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

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