簡體   English   中英

CKEditor在Drupal 7中缺少/不正確的basePath

[英]CKEditor missing/incorrect basePath in Drupal 7

在自定義模塊中,我包含了CKEditor

drupal_add_js( 'sites/all/libraries/ckeditor/ckeditor.js',array('weight'=>JS_LIBRARY+1));
drupal_add_js( 'sites/all/libraries/ckeditor/adapters/jquery.js',array('weight'=>JS_LIBRARY+2));

在我的JS中,我正在使用以下方法在textarea上創建一個實例

jQuery('#myTextArea').ckeditor();

這是可行的,但現在不可行。 在Firebug中,我看到ckeditor試圖訪問config.js ,並且它正在頁面的URL中尋找它。 應該查看http://example.com/sites/all/libraries/ckeditor/

我認為最近發生的變化可能會破壞它!

我嘗試將config { basePath: '/sites/all/libraries/ckeditor/' } ckeditor()ckeditor()調用中,但這被忽略,可能無法在運行時設置嗎?

任何人都知道我在做什么錯,或者如果這是一個錯誤,有沒有解決的辦法?

正如我評論的那樣,這似乎與通過Drupal的JS聚合加載編輯器有關

這是一個對我有用的丑陋的技巧。

編輯sites / all / libraries / ckeditor / ckeditor.js文件,並在壓縮的js代碼添加之前:

window.CKEDITOR_BASEPATH = 'http://example.com/sites/all/libraries/ckeditor/';

然后,請記住每次升級時都要這樣做。

PS。 歸功於基本路徑提示

當您更改默認的ckeditor.js文件名時,CKEditor(已測試4.4.4)在確定正確的基本路徑時遇到問題。 例如,當您添加用於實時部署的cachebreaker或使用聚合名稱時。

您可以使用屬性輸出CKEDITOR.basePath輕松重現該行為。

您使用原始ckeditor文件名/ext/ckeditor/ckeditor.js在網站(假設http://example.de )上使用路徑/ a / b / c / d:

Website: http://example.de/a/b/c/d
CKeditor: http://example.de/ext/ckeditor/ckeditor.js

console.log(CKEDITOR.basePath); //output: http://example.de/ext/ckeditor/ 

您在同一網站上,相同的路徑和ckeditor.js已更改:

Website: http://example.de/a/b/c/d
CKeditor: http://example.de/ext/ckeditor/ckeditor-whatever.js

console.log(CKEDITOR.basePath); //output: http://example.de/a/b/c/ 

通常,JavaScript控制台顯示如下錯誤:

Line 1: Uncaught SyntaxError: Unexpected token <
Uncaught TypeError: Cannot set property 'dir' of undefined

因此,如果更改默認文件名ckeditor.js,則始終有必要設置基本路徑。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM