kindeditor 4.1.11 在进行复制粘贴、图片等操作时滚动条直接跑到编辑器首行问题的解决方法。
完善时间:2018-10-26 01:43:42会员:bekda目录:电脑网络 - 编程开发浏览:3404 次
KindEditor 是一套轻量级开源的在线HTML编辑器,主要用于让用户在网站上获得所见即所得编辑效果,KindEditor 使用 JavaScript 编写,可以无缝地与 Java、.NET、PHP、ASP 等程序集成,但由于各种原因,此编辑器最后一次更新已经是2年前了,原有程序存在的部份BUG也停止维护,其中在进行复制粘贴、图片等操作时滚动条直接跑到编辑器首行问题十分令人烦恼,经过研究,通过修改以下代码后,在本机测试成功,修改方法如下:
1、使用编辑器打开KindEditor的JS库:kindeditor.js,搜索以下代码:
pos : function() { var self = this, node = self.[0], x = 0, y = 0; if (node) { if (node.getBoundingClientRect) { var box = node.getBoundingClientRect(), pos = _getScrollPos(self.doc); x = box.left + pos.x; y = box.top + pos.y; } else { while (node) { x += node.offsetLeft; y += node.offsetTop; node = node.offsetParent; } } } return {x : _round(x), y : _round(y)}; },2、将其中的变量node赋值从原始的:node = self.[0] 修改为:self.parent()[0],完成后的代码如下:
pos : function() { var self = this, node = self.parent()[0], x = 0, y = 0; //修正复制粘贴时卷轴定位问题,修改:node = self.[0] 为:node = self.parent()[0] if (node) { if (node.getBoundingClientRect) { var box = node.getBoundingClientRect(), pos = _getScrollPos(self.doc); x = box.left + pos.x; y = box.top + pos.y; } else { while (node) { x += node.offsetLeft; y += node.offsetTop; node = node.offsetParent; } } } return {x : _round(x), y : _round(y)}; },
3、修改完成后清除网站的历史记录,重新加载编辑器试试。
* 此问题针对 newlineTag 回车换行标签设置 ”p” 测试有效,如果问题依然存在,请尝试将:newlineTag : "br" 修改为:newlineTag : "p",或直接删除 newlineTag : "br" 设置,KindEditor默认回车换行标签为 "p" 。
发布日期:2020/01/15
发布日期:2019/07/22
发布日期:2019/03/17
苏公网安备 32011102010041号
320111201705278429
苏ICP备12027725号