javascript 你如何定义 CKEditor 用来搜索配置/语言文件的路径?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8807029/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you define the path which CKEditor uses to search for config / language files?
提问by David Smith
CKEditor seems to look for its configuration files relative to the location it was loaded from, not the location of ckeditor.js. So loading CKEditor on the page http://www.example.com/articles/1causes it to look for the language files in http://www.example.com/articles/1/lang/
CKEditor 似乎寻找与它加载的位置相关的配置文件,而不是 ckeditor.js 的位置。因此,在页面http://www.example.com/articles/1上加载 CKEditor会导致它在http://www.example.com/articles/1/lang/ 中查找语言文件
The config file contains an attribute for baseHref, but it doesn't affect the editor resources themselves.
配置文件包含 baseHref 的属性,但它不会影响编辑器资源本身。
How do I set the path which CKEditor uses for its own resources?
如何设置 CKEditor 用于其自身资源的路径?
回答by AlfonsoML
That behavior that you describe isn't normal, for some reason CKEditor isn't identifying properly its own folder so you should set a CKEDITOR_BASEPATH
variable before loading CKEditor.
您描述的这种行为是不正常的,由于某种原因,CKEditor 没有正确识别自己的文件夹,因此您应该CKEDITOR_BASEPATH
在加载 CKEditor 之前设置一个变量。
It's briefly commented here: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.html#.basePathbut there might be other places where it's explained better.
它在这里简要评论:http: //docs.cksource.com/ckeditor_api/symbols/CKEDITOR.html#.basePath但可能还有其他地方可以更好地解释它。
A successful implementation is therefore:
因此,成功的实施是:
<script>
window.CKEDITOR_BASEPATH = 'http://example.com/path/to/libs/ckeditor/';
</script>
Thenload the main ckeditor.js
script. Note you can use root-relative paths e.g. /path/to/libs/ckeditor/
but relative paths do not work.
然后加载主ckeditor.js
脚本。请注意,您可以使用根相对路径,例如/path/to/libs/ckeditor/
但相对路径不起作用。