使用其对话框添加链接时出现 EmebrJS + CKEDITOR 错误

报告类型

在 chrome 78.0.3904.97 中使用 CKEditor 添加的链接会出现以下错误,我也检查了最新的 firefox,我可以重现这个


link.js?t=J8Q8:27 Uncaught TypeError: Cannot read property 'length' of undefined

    at CKEDITOR.dialog.onOk (link.js?t=J8Q8:27)

    at CKEDITOR.dialog.<anonymous> (ckeditor.js:613)

    at CKEDITOR.dialog.l (ckeditor.js:10)

    at CKEDITOR.dialog.fire (ckeditor.js:12)

    at button.onClick (ckeditor.js:637)

    at button.<anonymous> (ckeditor.js:575)

    at button.l (ckeditor.js:10)

    at button.fire (ckeditor.js:12)

    at button.click (ckeditor.js:574)

    at CKEDITOR.dom.element.<anonymous> (ckeditor.js:566)

繁殖步骤

  1. 启用 CKeditor 的链接

  2. 单击ckeditor工具栏中的链接图标

  3. 它会打开一个对话框以添加显示名称和链接

  4. 添加链接和显示名称

  5. 点击确定

预期结果

关闭对话框并将链接添加到 ckeditor 文本区域

实际结果

对话框没有关闭,控制台给出

link.js?t=J8Q8:27 Uncaught TypeError: Cannot read property 'length' of undefined

    at CKEDITOR.dialog.onOk (link.js?t=J8Q8:27)

    at CKEDITOR.dialog.<anonymous> (ckeditor.js:613)

    at CKEDITOR.dialog.l (ckeditor.js:10)

    at CKEDITOR.dialog.fire (ckeditor.js:12)

    at button.onClick (ckeditor.js:637)

    at button.<anonymous> (ckeditor.js:575)

    at button.l (ckeditor.js:10)

    at button.fire (ckeditor.js:12)

    at button.click (ckeditor.js:574)

    at CKEDITOR.dom.element.<anonymous> (ckeditor.js:566)

其他详情

  • 浏览器:chrome 78.0.3904.97 / firefox

  • 操作系统:Mac

  • CKEditor 版本:4.13.0

  • 安装的 CKEditor 插件:

使用 CKEditor 作为 Emberjs 组件

有人知道我该如何解决吗?我也检查了他们的 github 问题,但不幸的是我找不到任何东西


至尊宝的传说
浏览 171回答 1
1回答

湖上湖

错误在这里CKEDITOR.on( 'dialogDefinition', function(e) {&nbsp; &nbsp; &nbsp; var dialogName&nbsp; &nbsp; &nbsp; &nbsp;= e.data.name,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dialogDefinition = e.data.definition;&nbsp; &nbsp; &nbsp; if ( dialogName === 'link' ) {&nbsp; &nbsp; &nbsp; &nbsp; dialogDefinition.onShow = function () {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var dialog&nbsp; &nbsp; &nbsp; &nbsp; = CKEDITOR.dialog.getCurrent(),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; linkType&nbsp; &nbsp; &nbsp; = dialog.getContentElement( 'info' , 'linkType' ),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchorOptions = dialog.getContentElement( 'info' , 'anchorOptions' ),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; emailOptions&nbsp; = dialog.getContentElement( 'info' , 'emailOptions' ),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protocol&nbsp; &nbsp; &nbsp; = dialog.getContentElement( 'info' , 'protocol' );&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; linkType.getElement().hide();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anchorOptions.getElement().hide();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; emailOptions.getElement().hide();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; protocol.disable();&nbsp; &nbsp; &nbsp; &nbsp; };&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; } );我已经用下面的代码更新了这个CKEDITOR.on( 'dialogDefinition', function(e) {&nbsp; &nbsp; &nbsp; var dialogName&nbsp; &nbsp; &nbsp; &nbsp;= e.data.name,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dialogDefinition = e.data.definition;&nbsp; &nbsp; &nbsp; if ( dialogName === 'link' ) {&nbsp; &nbsp; &nbsp; &nbsp; dialogDefinition.getContents('info').get('protocol')['items'].splice(2, 6);&nbsp; &nbsp; &nbsp; &nbsp; dialogDefinition.getContents('info').get('linkType')['items'].splice(1, 4);&nbsp; &nbsp; &nbsp; &nbsp; var target = e.data.definition.getContents('target');&nbsp; &nbsp; &nbsp; &nbsp; var options = target.get('linkTargetType').items;&nbsp; &nbsp; &nbsp; &nbsp; for (var i = options.length-1; i >= 0; i--) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var label = options[i][0];&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!label.match(/new window/i)) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; options.splice(i, 1);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; var targetField = target.get( 'linkTargetType' );&nbsp; &nbsp; &nbsp; &nbsp; targetField['default'] = '_blank';&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; } );
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript