?
?
調(diào)整CKEditor的basePath
使用base標(biāo)簽,或者項(xiàng)目文件結(jié)構(gòu)的原因,我們可能需要調(diào)整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; })()
可見(jiàn),我們可以通過(guò)設(shè)置window.CKEDITOR_BASEPATH來(lái)調(diào)整CKEditor的basePath。
?
自定義CKEditor的語(yǔ)言
CKEditor可以根據(jù)瀏覽器來(lái)自動(dòng)選擇語(yǔ)言,但可能我們需要其和UI統(tǒng)一語(yǔ)言,而不是自動(dòng)選擇,這時(shí)候我們就需要自定義其語(yǔ)言。
我們需要給Config的language屬性定義成相應(yīng)的語(yǔ)言。
- 在repalce時(shí)傳入config
var idSelector = "editor1" ; CKEDITOR.replace(idSelector, {language: 'zh-cn'}); // 設(shè)置成簡(jiǎn)體中文
- 在editor實(shí)例生成時(shí)自動(dòng)設(shè)置
CKEDITOR.on('instanceCreated', function (event){ // 當(dāng)editor實(shí)例創(chuàng)建時(shí) var editor = event.editor; editor.on( 'configLoaded', function (){ // 當(dāng)實(shí)例載入config時(shí) editor.config.language = "zh-cn"; // 修改成簡(jiǎn)體中文 }); };
?
Advanced Content Filter
CKEditor會(huì)自動(dòng)開(kāi)啟內(nèi)容過(guò)濾器,其會(huì)對(duì)節(jié)點(diǎn)的屬性進(jìn)行過(guò)濾,可是我們可能不希望其過(guò)濾,可以通過(guò)設(shè)置config.allowedContent為true,來(lái)關(guān)閉該功能。
這樣CKEditor就僅僅是富文本編輯器了。
?
?
?
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
