百度富文本编辑器图片调节框超出编辑器内容区展示,在ueditor.all.js的7946行加入下面个方法:
getScrollTop: function () {
return Math.max(this.document.documentElement.scrollTop, this.document.body.scrollTop);
},
getScrollLeft: function () {
return Math.max(this.document.documentElement.scrollLeft, this.document.body.scrollLeft);
},
然后在17108行设置样式处调整left和top值:
domUtils.setStyles(resizer, {
'width': target.width + 'px',
'height': target.height + 'px',
'left': iframePos.x + imgPos.x - me.editor.getScrollLeft() - editorPos.x - parseInt(resizer.style.borderLeftWidth) + 'px',
'top': iframePos.y + imgPos.y - me.editor.getScrollTop() - editorPos.y - parseInt(resizer.style.borderTopWidth) + 'px'
});
还有一个问题就是在编辑器框内文字选中状态,然后点击字体大小设置(也就是弹出Popup)时,高亮选区丢失了。在26589行加入this.editor.selection.getRange().select()
这一行代码。
showPopup: function (){
this.editor.selection.getRange().select() // 高亮选区
var rect = uiUtils.getClientRect(this.getDom());
rect.top += 1;
rect.bottom -= 1;
rect.height -= 2;
this.popup.showAnchorRect(rect);
},
最后使用uglify@2.6.2重新编译editor.all.js
# 编译输出压缩混淆
uglifyjs editor.all.js -o editor.all.min.js -c -m
参考
- ueditor-plus的api文档
- 选区集合API