mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Fixed copy event in IE11
This commit is contained in:
@@ -35,11 +35,16 @@ function prepareTextForClipboard(text) {
|
||||
* Binds copy functionality to the given terminal.
|
||||
* @param {ClipboardEvent} ev The original copy event to be handled
|
||||
*/
|
||||
function copyHandler (ev) {
|
||||
function copyHandler(ev, term) {
|
||||
var copiedText = window.getSelection().toString(),
|
||||
text = prepareTextForClipboard(copiedText);
|
||||
|
||||
ev.clipboardData.setData('text/plain', text);
|
||||
if (term.browser.isMSIE) {
|
||||
window.clipboardData.setData('Text', text);
|
||||
} else {
|
||||
ev.clipboardData.setData('text/plain', text);
|
||||
}
|
||||
|
||||
ev.preventDefault(); // Prevent or the original text will be copied.
|
||||
}
|
||||
|
||||
@@ -57,8 +62,7 @@ function pasteHandler(ev, term) {
|
||||
return term.cancel(ev);
|
||||
};
|
||||
|
||||
var userAgent = window.navigator.userAgent.toLowerCase();
|
||||
if (userAgent.match(/msie|MSIE/) || userAgent.match(/(T|t)rident/)) {
|
||||
if (term.browser.isMSIE) {
|
||||
if (window.clipboardData) {
|
||||
var text = window.clipboardData.getData('Text');
|
||||
dispatchPaste(text);
|
||||
|
||||
@@ -16,7 +16,7 @@ let userAgent = (isNode) ? 'node' : navigator.userAgent;
|
||||
let platform = (isNode) ? 'node' : navigator.platform;
|
||||
|
||||
export let isFirefox = !!~userAgent.indexOf('Firefox');
|
||||
export let isMSIE = !!~userAgent.indexOf('MSIE');
|
||||
export let isMSIE = !!~userAgent.indexOf('MSIE') || !!~userAgent.indexOf('Trident');
|
||||
|
||||
// Find the users platform. We use this to interpret the meta key
|
||||
// and ISO third level shifts.
|
||||
|
||||
+3
-2
@@ -447,12 +447,13 @@ Terminal.prototype.initGlobal = function() {
|
||||
Terminal.bindBlur(this);
|
||||
|
||||
// Bind clipboard functionality
|
||||
on(this.element, 'copy', copyHandler);
|
||||
on(this.element, 'copy', function (ev) {
|
||||
copyHandler.call(this, ev, term);
|
||||
});
|
||||
on(this.textarea, 'paste', function (ev) {
|
||||
pasteHandler.call(this, ev, term);
|
||||
});
|
||||
|
||||
|
||||
function rightClickHandlerWrapper (ev) {
|
||||
rightClickHandler.call(this, ev, term);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user