删除CKEditor图像插件中的htmlPreview

Kir*_*nov 5 javascript wysiwyg ckeditor

我在CKEditor的图像插件中隐藏预览元素时遇到问题.我需要一个非常简单的图像对话框,其中只有图像源的输入字段和带图像上传按钮的表单.所以我使用这些自定义配置设置删除了不必要的元

CKEDITOR.on( 'dialogDefinition', function( ev )
{
    var dialogName = ev.data.name;
    var dialogDefinition = ev.data.definition;
    if ( dialogName == 'image' ){
        dialogDefinition.removeContents( 'advanced' );
        dialogDefinition.removeContents( 'Link' );
        var infoTab = dialogDefinition.getContents( 'info' );
        infoTab.remove( 'ratioLock' ); 
        infoTab.remove( 'txtHeight' );          
        infoTab.remove( 'txtWidth' );          
        infoTab.remove( 'txtBorder'); 
        infoTab.remove( 'txtHSpace'); 
        infoTab.remove( 'txtVSpace'); 
        infoTab.remove( 'cmbAlign' ); 
        infoTab.remove( 'txtAlt' ); 
    }
}); 
Run Code Online (Sandbox Code Playgroud)

当我尝试隐藏htmlPreview元素时出现问题.如果我只是添加infoTab.remove( 'htmlPreview ' );,将发生错误:Uncaught TypeError: Cannot call method 'setStyle' of null因为删除元素的代码依赖性.我用Google搜索了很多,似乎有解决这个问题的两个方面-手动编辑插件的源代码书面那里(

我想唯一的解决方案是从image/dialogs/image.js中删除所有引用这些html对象的javascript函数.

我试图遵循这个建议,但无法编辑源文件而没有后续错误)或自己编写.当然,我可以简单地添加一些css规则并隐藏元素,但我认为这不是一个好主意.这个问题已经足够老了,我确信有一个很好的解决方案,但我找不到它.希望你能帮助我.先感谢您.

PS我有最新版本的CKEditor - 3.6.4.

Alf*_*oML 7

由于图像对话框的编写方式,您无法轻松删除预览而无需进一步调整文件的其余部分以删除其所有引用.

我建议你使用我的配置插件(或编写类似的代码),如下所述:http://alfonsoml.blogspot.com.es/2012/04/hide-dialog-fields-in-ckeditor.html

config.hideDialogFields="image:info:htmlPreview";
Run Code Online (Sandbox Code Playgroud)

您可以从我的博客下载该插件,或者如果您已切换到CKEditor 4,请将其添加到您的构建中:http://ckeditor.com/addon/confighelper