有没有办法为每个编辑器实例覆盖CKEditor的配置文件?

我有全局尺寸和高度设置

CKEDITOR.editorConfig = function( config ) { config.height = '400px'; config.width = '600px'; ... 

我想在单独的页面上仅为编辑器的一个实例更改此高度和宽度。 有没有其他人完成这个?

是。 在页面上创建编辑器时,您可以覆盖

 CKEDITOR.replace(editorName, { height: 448, width: 448, customConfig: '/path/to/yourconfig.js' }); 

实际上,作为性能建议,您可以在此处放置所有配置选项,并单独保存配置文件的加载。 您可以在自己的共享JavaScript文件中执行此操作,参数化以覆盖页面的特定值。

更新以回应评论

可以像使用任何其他设置一样使用单独的配置文件(请参阅上面的customConfig。如果您不希望任何自定义配置加载使用

 customConfig: '' 

您可以在instanceReady事件上调整编辑器的大小:

 CKEDITOR.on 'instanceReady', (evt) -> setCustomHeight(evt.editor) setCustomHeight = (editor) -> height = $(editor.element.$).attr('height') return unless height editor.resize('100%', height) 

现在,您必须在要为其具有自定义高度的textarea上指定height属性: