?
?
調整CKEditor的basePath
使用base標簽,或者項目文件結構的原因,我們可能需要調整CKEditor的basePath。
basePath: (
function
() {
//
ATTENTION: fixes to this code must be ported to
//
var basePath in "core/loader.js".
//
Find out the editor directory path, based on its <script> tag.
var
path = window.CKEDITOR_BASEPATH || ''
;
if
( !
path ) {
var
scripts = document.getElementsByTagName( 'script'
);
for
(
var
i = 0; i < scripts.length; i++
) {
var
match = scripts[ i ].src.match( /(^|.*[\\\/])ckeditor(?:_basic)?(?:_source)?.js(?:\?.*)?$/
i );
if
( match ) {
path
= match[ 1
];
break
;
}
}
}
//
In IE (only) the script.src string is the raw value entered in the
//
HTML source. Other browsers return the full resolved URL instead.
if
( path.indexOf( ':/' ) == -1
) {
//
Absolute path.
if
( path.indexOf( '/' ) === 0
)
path
= location.href.match( /^.*?:\/\/[^\/]*/ )[ 0 ] +
path;
//
Relative path.
else
path
= location.href.match( /^[^\?]*\/(?:)/ )[ 0 ] +
path;
}
if
( !
path )
throw
'The CKEditor installation path could not be automatically detected. Please set the global variable "CKEDITOR_BASEPATH" before creating editor instances.'
;
return
path;
})()
可見,我們可以通過設置window.CKEDITOR_BASEPATH來調整CKEditor的basePath。
?
自定義CKEditor的語言
CKEditor可以根據瀏覽器來自動選擇語言,但可能我們需要其和UI統一語言,而不是自動選擇,這時候我們就需要自定義其語言。
我們需要給Config的language屬性定義成相應的語言。
- 在repalce時傳入config
var
idSelector = "editor1"
;
CKEDITOR.replace(idSelector, {language:
'zh-cn'});
//
設置成簡體中文
- 在editor實例生成時自動設置
CKEDITOR.on('instanceCreated',
function
(event){
//
當editor實例創建時
var
editor =
event.editor;
editor.on(
'configLoaded',
function
(){
//
當實例載入config時
editor.config.language = "zh-cn";
//
修改成簡體中文
});
};
?
Advanced Content Filter
CKEditor會自動開啟內容過濾器,其會對節點的屬性進行過濾,可是我們可能不希望其過濾,可以通過設置config.allowedContent為true,來關閉該功能。
這樣CKEditor就僅僅是富文本編輯器了。
?
?
?
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061
微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元

