CKFinder产生:" TypeError:f.config未定义"

时间:2015-04-24 19:11:10

标签: javascript ckeditor ckfinder ckeditor4.x

我试图将CKFinder与CKEDitor 4.4.7集成,并在页面加载时出现以下错误:

TypeError: f.config is undefined  
ckfinder.js (line 6, col 12104)
...;var p=o.indexOf('?')!== -1?'&':'?';f.config.filebrowserBrowseUrl=o;f.config...
                                           ^^^^^^^^

这是示例页面:

    <script type='text/JavaScript' src='/includes/static/js/ckeditor/ckeditor.js'></script>
    <script type='text/JavaScript' src='/includes/static/js/ckfinder/ckfinder.js'></script>
    <p>entry box

    <form action='test.php' method='post'>
        <p>

            <textarea class='ckeditor' id='citation' name='citation'>citation</textarea>
            <script>
                CKEDITOR.replace( 'citation', {
                    uiColor: '#FFF6DA',
                    allowedContent: true,
                    filebrowserBrowseUrl: '/includes/static/js/ckfinder/ckfinder.html',
                    filebrowserImageBrowseUrl: '/includes/static/js/ckfinder/ckfinder.html?type=Images',
                    filebrowserFlashBrowseUrl: '/includes/static/js/ckfinder/ckfinder.html?type=Flash',
                    filebrowserUploadUrl: '/includes/static/js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
                    filebrowserImageUploadUrl: '/includes/static/js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
                    filebrowserFlashUploadUrl: '/includes/static/js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash',                          

                     height:100 
                });

                CKEDITOR.instances['citation'].on('instanceReady', function() {
                    // Output self-closing tags the HTML4 way, like <br>.
                    this.dataProcessor.writer.selfClosingEnd = '>';


                });                 

                CKFinder.setupCKEditor( 'citation', '/includes/static/js/ckfinder/' );

            </script>
        <input type='submit'>
    </form>

上传按钮未被创建,可能是因为上面的f.config错误: enter image description here

这是ckeditor / config.js:

CKEDITOR.editorConfig = function( config ) {

    // The default plugins included in the basic setup define some buttons that
    // are not needed in a basic editor. They are removed here.
    config.removeButtons = 'Cut,Copy,Paste,Undo,Redo,Anchor,Underline,Strike,Subscript,Superscript';

    config.extraPlugins = 'justify,onchange';

    // Dialog windows are also simplified.
    config.removeDialogTabs = 'link:advanced';

    config.disableNativeSpellChecker = false;

};

和未修改的ckfinder / config.js:

CKFinder.customConfig = function( config )
{
        // Define changes to default configuration here. For example:
        // config.skin = 'v1';
        // config.language = 'fr';
};

可能导致f.config错误的原因是什么?

1 个答案:

答案 0 :(得分:1)

CKFinder.setupCKEditor需要一个实例,而不是编辑器的id。

使用:

CKFinder.setupCKEditor( CKEDITOR.instances['citation'], '/includes/static/js/ckfinder/' );

或简单地将null作为第一个参数传递。有关详情,请查看http://docs.cksource.com/CKFinder_2.x/Developers_Guide/PHP/CKEditor_Integration