mirror of
https://github.com/doocs/md.git
synced 2024-11-28 13:36:32 +08:00
fix: add select status
添加文本选中状态
This commit is contained in:
parent
b9f90433f2
commit
715d035355
@ -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: '已复制渲染后的文章到剪贴板,可直接到公众号后台粘贴',
|
||||||
|
Loading…
Reference in New Issue
Block a user