ueditor富文本编辑器使用图片问题

此编辑器的图片使用最近遇上两个问题

一、图片上传后选中图片,下滑滚动条后再次点击图片,图片错位

找到fiximgclick.js文件的attachTo函数  修改domUtils.setStyles里面的top值

//修改前
'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'

此解决方法参考原文:http://t.zoukankan.com/douyage-p-10948748.html 

二、图片选中后无法脱离选中状态,需要多次点击才能使光标出现

还是找到fiximgclick.js文件中,对hide传入参数true,在接收时做判断

 Scale.prototype = {
            init: function (editor) {
                var me = this;
                me.editor = editor;
                me.startPos = this.prePos = { x: 0, y: 0 };
                me.dragId = -1;

                var hands = [],
                    cover = me.cover = document.createElement('div'),
                    resizer = me.resizer = document.createElement('div');

                cover.id = me.editor.ui.id + '_imagescale_cover';
                cover.style.cssText = 'position:absolute;display:none;z-index:' + (me.editor.options.zIndex) + ';filter:alpha(opacity=0); opacity:0;background:#CCC;';
                domUtils.on(cover, 'mousedown click', function () {
                    //传人参数 true
                    me.hide(true);
                });
hide: function (reset) {
                var me = this;
                me.hideCover();
                me.resizer.style.display = 'none';

                domUtils.un(me.resizer, 'mousedown', me.proxy(me._eventHandler, me));
                domUtils.un(me.doc, 'mouseup', me.proxy(me._eventHandler, me));
                me.editor.fireEvent('afterscalehide', me);
                //做判断
                reset && me.editor.setContent(me.editor.getContent())
            },

 参考作者的回复评论:

 但是这个办法只是让多次点击图片之外空白的地方减少,点击两次取消选中状态出现光标,没有彻底解决这个问题。

如果同志们有更好的解决办法,多多指教,携手前行。

猜你喜欢

转载自blog.csdn.net/a_grain_of_wheat/article/details/126388613