主机模式文件与Ace Editor分开 [英] Host mode files separately from Ace Editor

查看:89
本文介绍了主机模式文件与Ace Editor分开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将ACE Editor与桌面应用程序捆绑在一起,并在WebView中呈现它。 Ace是从 file:/// 协议运行的。有什么方法可以与 ace.js 分开托管模式文件吗?例如, ace.js 将位于应用程序捆绑包 /Application/MyApp.app /...中,但是模式文件位于〜/ Library / Application Support / MyApp / ace / modes

I want to bundle ACE Editor with the desktop application and render it inside WebView. Ace is running from file:/// protocol. Is there any way to host Mode files separately from ace.js? For example ace.js will be located inside the application bundle /Application/MyApp.app/..., but mode files at ~/Library/Application Support/MyApp/ace/modes.

我从测试项目开始,具有以下代码

I started with test project and have the following code

<script type="text/javascript">
    var require = {
        baseUrl: window.location.protocol + "//" + window.location.host
                + window.location.pathname.split("/").slice(0, -1).join("/"),
        paths: {
            "ace/mode": "/Users/user/ace-build",
        }
    };
</script>
<script type="text/javascript" src="require.js"></script>
<script type="text/javascript" src="ace/ace.js"></script>
<script type="text/javascript">
    require(["ace/ace"], function(ace){
        var editor = ace.edit("editor-container");
        editor.getSession().setUseWorker(false);
        editor.setTheme("ace/theme/xcode");
        editor.getSession().setMode("ace/mode/javascript");
    });
</script>

我希望该模块 ace / mode / javascript 将从 / Users / user / ace-build / javascript 加载,但将从 ace / mode-javascript.js 。如何使模式从不同位置加载?

I expect that module ace/mode/javascript will be loaded from /Users/user/ace-build/javascript but it loads from ace/mode-javascript.js. How to make modes loading from different location?

推荐答案

使用

require("ace/config").set("modePath", require.toUrl("ace/mode"))

如果 ext-* 和其他文件位于同一文件夹中,则可以执行 .set ( basePath,..)代替

if ext-* and other files are in the same folder you can do .set("basePath", ..) instead

这篇关于主机模式文件与Ace Editor分开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆