From 69e027394d3782fc90f1e42f575bef8b509a3a7e Mon Sep 17 00:00:00 2001 From: Paris Kasidiaris Date: Wed, 14 Dec 2016 01:43:32 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=98=B1=20=20Fix=20wrong=20event=20typ?= =?UTF-8?q?e=20and=20remove=20useless=20interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/Clipboard.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/handlers/Clipboard.ts b/src/handlers/Clipboard.ts index db528f9..e496759 100644 --- a/src/handlers/Clipboard.ts +++ b/src/handlers/Clipboard.ts @@ -7,13 +7,6 @@ import { ITerminal } from '../Interfaces'; -// We are extending the ClipboardEvent interface, since TypeScript has not declared the -// clientX and clientY properties that we use. -interface IClipboardEvent extends ClipboardEvent { - clientX: number; - clientY: number; -} - interface IWindow extends Window { clipboardData?: { getData(format: string): string; @@ -49,7 +42,7 @@ export function prepareTextForClipboard(text: string): string { * Binds copy functionality to the given terminal. * @param {ClipboardEvent} ev The original copy event to be handled */ -export function copyHandler(ev: IClipboardEvent, term: ITerminal) { +export function copyHandler(ev: ClipboardEvent, term: ITerminal) { // We cast `window` to `any` type, because TypeScript has not declared the `clipboardData` // property that we use below for Internet Explorer. let copiedText = window.getSelection().toString(), @@ -69,7 +62,7 @@ export function copyHandler(ev: IClipboardEvent, term: ITerminal) { * @param {ClipboardEvent} ev The original paste event to be handled * @param {Terminal} term The terminal on which to apply the handled paste event */ -export function pasteHandler(ev: IClipboardEvent, term: ITerminal) { +export function pasteHandler(ev: ClipboardEvent, term: ITerminal) { ev.stopPropagation(); let text: string; @@ -103,10 +96,10 @@ export function pasteHandler(ev: IClipboardEvent, term: ITerminal) { * area, then bring the terminal's input below the cursor, in order to * trigger the event on the textarea and allow-right click paste, without * caring about disappearing selection. - * @param {ClipboardEvent} ev The original paste event to be handled + * @param {MouseEvent} ev The original right click event to be handled * @param {Terminal} term The terminal on which to apply the handled paste event */ -export function rightClickHandler(ev: IClipboardEvent, term: ITerminal) { +export function rightClickHandler(ev: MouseEvent, term: ITerminal) { let s = document.getSelection(), selectedText = prepareTextForClipboard(s.toString()), clickIsOnSelection = false, From ab87dece0bae023cd7bab5cf650479e9018093a0 Mon Sep 17 00:00:00 2001 From: Paris Kasidiaris Date: Wed, 14 Dec 2016 01:45:53 +0200 Subject: [PATCH 2/2] Fix weird paste issue: #405 Fix #405 --- src/xterm.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/xterm.js b/src/xterm.js index dc1c733..12c236f 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -433,6 +433,9 @@ Terminal.prototype.initGlobal = function() { on(this.textarea, 'paste', function (ev) { pasteHandler.call(this, ev, term); }); + on(this.element, 'paste', function (ev) { + pasteHandler.call(this, ev, term); + }); function rightClickHandlerWrapper (ev) { rightClickHandler.call(this, ev, term);