CKEditor:双击 url 或在任何其他事件中停止弹出链接对话框

use*_*809 5 ckeditor

我正在使用 CK 编辑器并使用 jQuery 实现。我在 ckeditor config.js 中隐藏了链接选项,这样工具栏中就不会出现链接选项。当我输入 URL 或链接时,在单击事件中,它将链接(网页)加载到我的页面/div 中。我还通过删除 href 来限制它。现在,在 URL 上双击,它会显示一个链接对话框,其中包含“链接类型”、“协议”、“URL”和“确定取消”按钮等选项。现在我想限制对话框。即:我不想弹出对话框。双击应该像在普通文本中一样工作。有人可以帮助我吗?我也尝试过“config.removeDialogTabs = 'image:advanced;link';” “config.removeDialogTabs = '链接:上传;图像:上传';”

CKEDITOR.on('dialogDefinition', 函数 (ev) {

            var dialogName = ev.data.name;
            var dialogDefinition = ev.data.definition;

            switch (dialogName) {
                case 'image': //Image Properties dialog      
                    dialogDefinition.removeContents('advanced');
                    break;
                case 'link': //image Properties dialog          
                    dialogDefinition.removeContents('advanced');
                    break;
            }
        });
Run Code Online (Sandbox Code Playgroud)

它不起作用。

小智 2

关键是编写自己的“双击”处理程序,其优先级高于“链接”插件的默认处理程序,并阻止事件传播。

    myEditor.on('doubleclick', function (evt) {
        var element = evt.data.element;

        if (element.is('a')){
            evt.stop(); // don't do the other listeners
            // optionally put your code 
        }

    }, null, null, 1); // 10 is default, so put something lower for higher priority
Run Code Online (Sandbox Code Playgroud)