fix: add select status

添加文本选中状态
This commit is contained in:
yanglbme 2019-12-25 11:39:00 +08:00
parent b9f90433f2
commit 715d035355

View File

@ -266,11 +266,19 @@ let app = new Vue({
e.preventDefault(); e.preventDefault();
e.clipboardData.setData('text/html', text); e.clipboardData.setData('text/html', text);
e.clipboardData.setData('text/plain', text); e.clipboardData.setData('text/plain', text);
console.log(e.clipboardData)
document.removeEventListener('copy', copyCall); document.removeEventListener('copy', copyCall);
}); });
if (document.execCommand('copy')) { if (document.execCommand('copy')) {
// 模拟一个选中的状态
let clipboardDiv = document.getElementById('output');
clipboardDiv.focus();
window.getSelection().removeAllRanges();
let range = document.createRange();
range.setStartBefore(clipboardDiv.firstChild);
range.setEndAfter(clipboardDiv.lastChild);
window.getSelection().addRange(range);
this.refresh()
this.$notify({ this.$notify({
showClose: true, showClose: true,
message: '已复制渲染后的文章到剪贴板,可直接到公众号后台粘贴', message: '已复制渲染后的文章到剪贴板,可直接到公众号后台粘贴',