From 715d035355c57909cd6ee99868d7b80d1fcbac65 Mon Sep 17 00:00:00 2001 From: yanglbme Date: Wed, 25 Dec 2019 11:39:00 +0800 Subject: [PATCH] fix: add select status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加文本选中状态 --- assets/scripts/editor.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/assets/scripts/editor.js b/assets/scripts/editor.js index 66aaa39..6f44445 100644 --- a/assets/scripts/editor.js +++ b/assets/scripts/editor.js @@ -266,11 +266,19 @@ let app = new Vue({ e.preventDefault(); e.clipboardData.setData('text/html', text); e.clipboardData.setData('text/plain', text); - console.log(e.clipboardData) document.removeEventListener('copy', copyCall); }); 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({ showClose: true, message: '已复制渲染后的文章到剪贴板,可直接到公众号后台粘贴',