开发者

CKEditor Plugin - OK Button Permission Error

开发者 https://www.devze.com 2023-01-28 12:35 出处:网络
Hi i have created the following ckeditor plugin to insert a youtube video: (function() { CKEDITOR.plugins.add(\'youtube\', {

Hi i have created the following ckeditor plugin to insert a youtube video:

(function() {
    CKEDITOR.plugins.add('youtube', {
        requires : ['iframedialog'],
        init : function(editor) {
            var iframeWindow = null;
            CKEDITOR.dialog.add('youtube_dialog', function() {
                return {
                    title : 'YouTube Movie Properties',
                    minWidth : 550,
                    minHeight : 200,
                    contents : [{
                        id : 'iframe',
                        label : 'Insert YouTube Movie',
                        expand : true,
                        elements : [{
                            type : 'iframe',
                            src : me.path + 'dialogs/youtube.html',
                            width : '100%',
                            height : '100%',
                            onContentLoad : function() {
                                iframeWindow = document.getElementById(this._.frameId).contentWindow;
                            }
                        }]
                    }],
                    onOk : function() {
                        this._.editor.insertHtml('<cke:youtube url="' + iframeWindow.document.getElementById('url').value + '">YouTube Video Place Marker</cke:youtube>');
                    }
                };
            });
            editor.addCommand('youtube', new CKEDITOR.dialogCommand('youtube_dialog'));
            editor.ui.addButton('YouTube', {
                label : 'Insert YouTube Movie',
                command : 'youtube',
                icon : this.path + 'images/icon.gif'
            });
        }
    });
})();

This was working fine but i recently moved my ckeditor files to a CDN. Now when i click the "OK" button i get a permission error. I was looking at the source of the existing plugins to get an idea of how th开发者_如何学Goey work but whatever i have tried doesn't seem to work. To get something basic working I tried changing my okOk event to:

onOk : function() {
    var hr = new CKEDITOR.dom.element('hr', editor.document );
    editor.insertElement(hr);
}

But this gave me a null reference exception.

I'd really appreciate it if someone could show me what i am doing wrong. Thanks


Problem fixed! The solution is to change:

CKEDITOR.dialog.add('youtube_dialog', function()

to:

CKEDITOR.dialog.add('youtube_dialog', function(editor)

and change:

this._.editor

to:

editor

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消