Код: Выделить всё
document.execCommand
Код: Выделить всё
$('#word_count').summernote({
height:350,
callbacks: {
onPaste: function (e) {
var bufferText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text');
e.preventDefault();
document.execCommand('copy', false, bufferText);
// Firefox fix
setTimeout(function () {
document.execCommand('insertText', false, bufferText);
}, 10);
}
}
});
< /code>
Для Google Chrome я использую ниже код, но не работаю должным образом: < /p>
chrome.extension.onMessage.addListener(handlePaste);
function getClipboard() {
var pasteTarget = document.createElement("div");
pasteTarget.contentEditable = true;
var actElem = document.activeElement.appendChild(pasteTarget).parentNode;
pasteTarget.focus();
document.execCommand("Paste", null, null);
var paste = pasteTarget.innerText;
actElem.removeChild(pasteTarget);
return paste;
};
function onClipboardMessage(request, sender, sendResponse) {
if (request.action === "paste") { //$NON-NLS-0$
sendResponse({
paste: getClipboard()
});
}
}
chrome.extension.onMessage.addListener(onClipboardMessage);
Вывод функции приводит к следующему представлению:
Подробнее здесь: https://stackoverflow.com/questions/796 ... gle-chrome