CKEditor 插件 - OK 按钮权限错误

发布于 2024-10-06 00:25:18 字数 2017 浏览 0 评论 0原文

您好,我创建了以下 ckeditor 插件来插入 YouTube 视频:

(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'
            });
        }
    });
})();

这工作正常,但我最近将我的 ckeditor 文件移动到 CDN。现在,当我单击“确定”按钮时,我收到权限错误。我正在查看现有插件的来源,以了解它们是如何工作的,但我尝试过的任何方法似乎都不起作用。为了获得一些基本的工作,我尝试将 okOk 事件更改为:

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

但这给了我一个空引用异常。

如果有人能告诉我我做错了什么,我将非常感激。谢谢

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 they 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一杯敬自由 2024-10-13 00:25:18

问题已解决!解决方案是将:更改

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

为:

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

并更改

this._.editor

为:

editor

希望这会有所帮助。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文