Ckeditor Link with basepath

自闭症网瘾萝莉.ら 提交于 2019-12-05 05:37:48

I know this isn't ideal as it's a hack, but you can go to ckeditor/plugins/link/dialogs/link.js find this in the code:

label:i.protocol,"default":"http://",items:[["http://‎","http://"],["https://‎","https://"],["ftp://‎","ftp://"],["news://‎","news://"],[b.other,""]]

Then just add another option in the items array like ["Base URL","/"].

I did find this solution that may also suit your needs: http://ckeditor.com/forums/CKEditor-3.x/internal-pages-dropdown-link-dialog

Hope that helps.

Lelio Faieta

Have a look at this page of the ckeditor documentation.

Here they say that you can set the basepath using this syntax:

<script>
    var CKEDITOR_BASEPATH = '/ckeditor/';
</script>    
<script src="all_my_scripts.js"></script>

I don't really understand what your issue really is. If you just set the basepath as a relative path like this you will never need to change it changing the environment. Just replicate the folder structure between development and production!

Set the 'baseHref' of the ckeditor configuration to the current url of the environment you are currently on , 'http://staging.google.com' for instance . You can start using links relative to such path in your editor. If for instance you have url pointing to an image 'http://staging.google/images/example.jpg' you just insert '/images/example.jpg' in the editor and this should display the actual image. Hope this helps.

I believe Mario Wakeel has the nearest answer so far (note that you need to be looking at baseHref and not basePath):

http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-baseHref

If you need to set this variable programmatically, I'm guessing you'd need to use some simple server-side code to check which domain the editor is being accessed from (before the config is loaded).

If you take a look at the ckeditor.js you will see this line:

Please set the global variable "CKEDITOR_BASEPATH" before creating editor instances.

So if you want to set the base path so that all upload file and link have the correct path, just prepend this line into ckeditor.js file

CKEDITOR_BASEPATH=your_relative_path

or you can set global variable like this

var CKEDITOR_BASEPATH = your_relative_path;

before you include ckeditor.js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!