|
@@ -131,12 +131,29 @@ export default {
|
|
|
const newImgUrl = await this.uploadImg(src[1])
|
|
|
newStr = newStr.replace(src[1], newImgUrl)
|
|
|
console.log('newStr', newStr)
|
|
|
+ this.inputValue = newStr
|
|
|
+ // 光标最后
|
|
|
+ this.$nextTick(() => {
|
|
|
+ var ifra = document.getElementById(`tinymce_${id}`);
|
|
|
+ this.keepLastIndex(ifra.contentWindow.document.getElementById(`tinymce`), ifra.contentWindow)
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
- console.log('newStr', newStr)
|
|
|
- this.inputValue = newStr
|
|
|
// return newStr
|
|
|
},
|
|
|
+ keepLastIndex (obj, window) {
|
|
|
+ if (window.getSelection) { //ie11 10 9 ff safari
|
|
|
+ obj.focus(); //解决ff不获取焦点无法定位问题
|
|
|
+ var range = window.getSelection(); //创建range
|
|
|
+ range.selectAllChildren(obj); //range 选择obj下所有子内容
|
|
|
+ range.collapseToEnd(); //光标移至最后
|
|
|
+ } else if (document.selection) { //ie10 9 8 7 6 5
|
|
|
+ var range = document.selection.createRange(); //创建选择对象
|
|
|
+ range.moveToElementText(obj); //range定位到obj
|
|
|
+ range.collapse(false); //光标移至最后
|
|
|
+ range.select();
|
|
|
+ }
|
|
|
+ },
|
|
|
uploadImg(imgData) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
const HTTP = axios.create({
|