mirror of
https://github.com/beautifier/js-beautify.git
synced 2024-11-23 20:59:43 +00:00
Add clipboard functionality for plain textarea
This commit is contained in:
parent
f0f866aeff
commit
03713ae1a1
@ -317,19 +317,28 @@ function getSubmitIssueBody(trucate) {
|
||||
}
|
||||
|
||||
function copyText() {
|
||||
var currentText = the.editor.getValue();
|
||||
if (the.editor) {
|
||||
the.editor.execCommand('selectAll');
|
||||
var currentText = the.editor.getValue();
|
||||
var copyArea = $('<textarea />')
|
||||
.text(currentText)
|
||||
.attr('readonly', '')
|
||||
.css({ 'position': 'absolute', 'left': '-9999px' });
|
||||
|
||||
var copyArea = $('<textarea />')
|
||||
.text(currentText)
|
||||
.attr('readonly', '')
|
||||
.css({ 'position': 'absolute', 'left': '-9999px' });
|
||||
$('body').append(copyArea);
|
||||
|
||||
copyArea.select();
|
||||
document.execCommand('copy');
|
||||
copyArea.remove();
|
||||
$('body').append(copyArea);
|
||||
copyArea.select();
|
||||
document.execCommand('copy');
|
||||
copyArea.remove();
|
||||
} else {
|
||||
$('#source').select();
|
||||
document.execCommand('copy');
|
||||
}
|
||||
}
|
||||
|
||||
function selectAll() {
|
||||
the.editor.execCommand('selectAll');
|
||||
if (the.editor) {
|
||||
the.editor.execCommand('selectAll');
|
||||
} else {
|
||||
$('#source').select();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user