此問題出現在本地測試的時候:
1. 定製化config.js應該放的位置
放到gwt/server 端的src/main/webapp/ckeditor_local/config.js下,這樣會被打包到apache-tomee/webapps/ROOT下, 然後
$wnd.CKEDITOR
.replace(id, {
customConfig : '/ckeditor_local/config.js'
});
就可以使定製化生效了。
2. 使用獨立服務器(CDN)放置ckeditor的包時, 需要在index.html中配置如下:
<script type="text/javascript">
var CKEDITOR_BASEPATH = '//www-static.***.com/libs/ckeditor-4.4.5/';
</script>
<script src="//www-static.***.com/libs/ckeditor-4.4.5/ckeditor.js"></script>
但是customConfig : '/ckeditor/config.js'就不work了。這個是誤解。 這個是因爲www-static上的ckeditor package plugins裏沒有autosave, 而我的ckeditor_local/config.js裏有autosave的配置,所以導致出錯,實際上可以在firebug中看到這個錯誤的原因。 而且和CKEDITOR_BASEPATH也沒有關係。 我發現CKEDITOR_BASEPATH根本沒必要配置。
3. 一直想把定製的ckeditor/config.js放到gwt/client一側,但是一直不生效。【這個是錯誤做法,肯定不行。 只能放到gwt server, webapp下,也就是web server的root path下】
無論放到src/main/resources還是src/main/resources/com/.../client/ckeditor/config.js 都不行。
4. 添加ckeditor autogrow插件
editor.config.extraPlugins = 'autogrow';
editor.config.autoGrow_minHeight = 100;
editor.config.autoGrow_maxHeight = 1000;
editor.config.removePlugins = 'resize';
5. ckeditor 在使用CDN情況下的配置
refer to: https://cdn.ckeditor.com/
6. 從server本地添加autosave插件的方法:
$wnd.CKEDITOR.plugins.addExternal('autosave',
'/ckeditor_local/plugins/autosave/', 'plugin.js');
$wnd.CKEDITOR
.replace(id, {
customConfig : '/ckeditor_local/config.js'
});
7. 如果Toolbar 上沒有出現想要的button, 比如TextColor, BGColor, 可能是因爲缺少插件(那些插件不是默認添加的)
可以這樣一次添加多個插件,主要如果寫多次 config.extraPlugins =xxx, 後面的會覆蓋前面的。
config.extraPlugins = 'autosave,colorbutton,showblocks';
8. 獲取CKEditor Toolbar命令Button的狀態
public native int getCommandState(String command) /*-{
return [email protected]::editor
.getCommand(command).state;
}-*/;