【发布时间】:2018-01-19 04:58:13
【问题描述】:
我正在尝试将上传的图片嵌入到编辑器中。我的filebrowserUploadUrl 是/api/m/image,它似乎工作正常。我点击Send it to the Server按钮后,出现脚本错误如下:
image.js?t=H4PG:19 Uncaught TypeError: Cannot read property 'setCustomData'
of undefined
at textInput.onChange (image.js?t=H4PG:19)
at textInput.n (ckeditor.js:10)
at textInput.CKEDITOR.event.CKEDITOR.event.fire (ckeditor.js:12)
at textInput.setValue (ckeditor.js:619)
at textInput.setValue (ckeditor.js:545)
at a.q (ckeditor.js:841)
at ckeditor.js:31
at Object.callFunction (ckeditor.js:31)
at image?CKEditor=editor&CKEditorFuncNum=1&langCode=en:1
上面的最后一行是对filebrowserUploadUrl的调用,它的响应是:
window.parent.CKEDITOR.tools.callFunction(1, '/images/bulletins.jpg', '上传成功');
Uploaded successfully 消息显示在警报中。 Image Info 选项卡下的预览框未更新。但是如果我点击确定关闭对话框,图像(bulletins.jpg)就嵌入到编辑器中了。
什么可能导致错误,我该如何解决?
我找到了导致它的原因。当插入图像对话框启动到上传选项卡时,我想设置默认选项卡。我使用以下代码:
CKEDITOR.on("dialogDefinition", function(ev) {
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
if (dialogName === "image") {
dialogDefinition.onShow = function() {
this.selectPage("Upload");
}
}
});
使用上述代码时,上传文件时会出现该错误。
【问题讨论】:
-
我在使用 onShow 事件处理程序后面临同样的问题。 dialogDefinition.onShow = function() { console.log('onShow called'); } 有人可以帮助我吗?
标签: ckeditor ckeditor4.x