ueditor编辑器,图片大小、错位问题修复

问题:在ueditor编辑器中上传照片,当鼠标点击图片时,图片上的编辑框错位跑到编辑器外面。

打开 ueditor.all.min.js 或者 ueditor.all.js(看你使用的是哪个js,修改下即可),输入attachTo进行搜索查询,找到对应位置,注释掉原来的。

找到这个方法:attachTo: function(a) {}

'top': iframePos.y + imgPos.y - me.editor.document.body.scrollTop - editorPos.y - parseInt(resizer.style.borderTopWidth) + 'px'

修改后完整代码:

attachTo: function (targetObj) {
    var me = this,
        target = me.target = targetObj,
        resizer = this.resizer,
        imgPos = domUtils.getXY(target),
        iframePos = domUtils.getXY(me.editor.iframe),
        editorPos = domUtils.getXY(resizer.parentNode);
    domUtils.setStyles(resizer, {
        'width': target.width + 'px',
        'height': target.height + 'px',
        'left': iframePos.x + imgPos.x - me.editor.document.body.scrollLeft - editorPos.x - parseInt(resizer.style.borderLeftWidth) + 'px',
        // 'top': iframePos.y + imgPos.y - me.editor.document.body.scrollTop - editorPos.y - parseInt(resizer.style.borderTopWidth) + 'px'
        'top': iframePos.y + imgPos.y - me.editor.document.documentElement.scrollTop - editorPos.y - parseInt(resizer.style.borderTopWidth) + 'px'
    });}

当然,如果你不需要让用户添加图片大小可以直接在css文件里设置添加下面这段代码

位于:UEditor/themes/css/ueditor.css

/* 取消图片点击边框 */#edui1_imagescale {
  display: none !important;}


© 版权声明
THE END