mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-18 18:33:42 +00:00
Drop document.execCommand
This commit is contained in:
parent
8b0b387ed0
commit
5b17f60f6f
@ -52,21 +52,7 @@ NexT.utils = {
|
||||
button.querySelector('i').className = 'fa fa-times-circle fa-fw';
|
||||
});
|
||||
} else {
|
||||
const ta = document.createElement('textarea');
|
||||
ta.style.top = window.scrollY + 'px'; // Prevent page scrolling
|
||||
ta.style.position = 'absolute';
|
||||
ta.style.opacity = '0';
|
||||
ta.readOnly = true;
|
||||
ta.value = code;
|
||||
document.body.append(ta);
|
||||
ta.select();
|
||||
ta.setSelectionRange(0, code.length);
|
||||
ta.readOnly = false;
|
||||
const result = document.execCommand('copy');
|
||||
button.querySelector('i').className = result ? 'fa fa-check-circle fa-fw' : 'fa fa-times-circle fa-fw';
|
||||
ta.blur(); // For iOS
|
||||
button.blur();
|
||||
document.body.removeChild(ta);
|
||||
button.querySelector('i').className = 'fa fa-times-circle fa-fw';
|
||||
}
|
||||
});
|
||||
// If copycode.style is not mac, element is larger than target
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user