Open fivecakes opened 3 years ago
@ygj6
官方示例图片没上传到服务器,错误是替换服务器返回的url时出现的,你可以在我这个示例中试一下http://mavoneditor.fivecakes.com
这个大概是因为iRender()
触发了编辑器的重新渲染,光标位置被重置了,再新版本未修复这个问题之前你可以使用如下方式规避这个问题 。
let obj = this.$refs.md.getTextareaDom();
let startPos = obj.selectionStart;
let endPos = obj.selectionEnd;
this.$refs.md.$img2Url(pos, "test.jpg");
setTimeout(function(){
obj.selectionStart = startPos;
obj.selectionEnd = endPos;
},1)
🐛 Bug Report
上传图片到服务器后光标会跑到文章末尾,而不是在刚刚编辑的地方
我看了代码,上传图片后调用$img2Url替换url,在$img2Url函数里调用了iRender(),而d_value被监听也调用了一次iRender()。
我在$img2Url调用结束后,以及iRender()函数的末尾打印光标位置都是正确的,但是在这之后光标位置跑到了文章末尾,应该是后面又做了一些处理,但是我没搞清楚后面又有哪些函数被调用。