如何将ckeditor图片上传简化到只有上传功能


ckeditor 图片上传默认有很多功能,如何将其简化成只有图片上传功能,上传完成自动关闭对话框并将图片显示在 textarea 中
参考这里 http://ckeditor.com/forums/CKEditor-3.x/Automatically-close-image-dialog-after-uploading-image 会报错 a.preview is undefined


 CKEDITOR.on('dialogDefinition', function(ev) {
    var dd = ev.data.definition;

    if(ev.data.name == 'image') {
    dd.onShow = function () {
        var dialog = CKEDITOR.dialog.getCurrent(); 
        // make upload default tab
        this.selectPage('Upload');
        // hide unwanted tab
        dialog.hidePage( 'Link' ); 
        dialog.hidePage( 'advanced' ); 
        dialog.hidePage('info');

        var uploadTab = dd.getContents('Upload');
        var uploadButton = uploadTab.get('uploadButton');
        uploadButton['filebrowser']['onSelect'] = function( fileUrl, errorMessage ) {
        dialog.getContentElement('info', 'txtUrl').setValue(fileUrl);
        $(".cke_dialog_ui_button_ok span").click();
        }
    };
    }
}

富文本编辑器 ckeditor

Eysia 10 years, 4 months ago

OK,原来需要将 onShow 改成 onLoad

四夕奈奈子 answered 10 years, 4 months ago

Your Answer