ueditor公式插件kity formula在chrome运行报错的解决办法
公司项目中的文本编辑器需要用到富文本编辑器,于是就用了百度的ueditor,毕竟是大公司,没想到也坑人,在chrome上公司插件用不了,于是立即百度谷歌了一番。终于找到了解决方法,特发此文记录解决之法,以供以后参阅。这里还是要感谢谷歌大神,百度搜索真垃圾,不过因为一些你懂得的原因用不了谷歌,程序猿的苦啊!
ueditor 错误提示
Uncaught TypeError: target.node.getTransformToElement is not a function
ueditor 错误原因
这是因为Chrome V.48版本后移除了SVGElement.getTransformToElement函数,而导致在Chrome V.48及以上版本使用该插件会报错。
原文如下:SVGGraphicsElement.getTransformToElement has been removed to match the SVG spec.
意思是移除了 SVGGraphicsElement.getTransformToElement,以符合 SVG 规范。
解决方法
在插件根目录下的kityFormulaDialog.html
文件中引入以下代码即可
SVGElement.prototype.getTransformToElement = SVGElement.prototype.getTransformToElement || function(toElement) {
return toElement.getScreenCTM().inverse().multiply(this.getScreenCTM());
};