import kscreenshot from "kscreenshot";
data() {
return {
index: 0,
modules: {
toolbar: {
container: [
[shot]
]
},
handlers: {
'shot': () => {
// 记录截图之前光标位置
this.index = this.quill.getSelection().index
// 截图函数
this.screenShot()
}
}
}
}
},
methods: {
screenShot() {
new kscreenshot({
endCB: (base64) => {
console.log(base64)
// 设置光标
this.quill.setSelection(this.index)
this.quill.insertEmbed(this.index, 'image', base64);
// 调整光标到图片后面
this.quill.setSelection(length + 1);
}
})
}
}
你必须非常努力,才能看起来毫不费力