mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Vanish selection when a key with data is being pressed
This commit is contained in:
+16
-4
@@ -421,7 +421,6 @@
|
||||
/**
|
||||
* Initialize default behavior
|
||||
*/
|
||||
|
||||
Terminal.prototype.initGlobal = function() {
|
||||
Terminal.bindPaste(this);
|
||||
Terminal.bindKeys(this);
|
||||
@@ -442,10 +441,11 @@
|
||||
});
|
||||
|
||||
/**
|
||||
* Contenteditable hack in order to allow right-click paste
|
||||
* Contenteditable hack in order to allow right-click paste.
|
||||
* Set contentEditable to true when right clicking and then set it back to false on mouse up
|
||||
* in order to hide the contentEditable cursor.
|
||||
*/
|
||||
on(term.element, 'contextmenu', function (ev) {
|
||||
console.log('hey');
|
||||
term.element.contentEditable = true;
|
||||
});
|
||||
|
||||
@@ -514,7 +514,7 @@
|
||||
this.children.push(row);
|
||||
|
||||
return row;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
@@ -2447,6 +2447,18 @@
|
||||
|
||||
key = String.fromCharCode(key);
|
||||
|
||||
/**
|
||||
* When a key is pressed and a character is sent to the terminal, then clear any text
|
||||
* selected in the terminal.
|
||||
*/
|
||||
if (key) {
|
||||
var selectionBaseNode = window.getSelection().baseNode;
|
||||
|
||||
if (selectionBaseNode && (this.element.contains(selectionBaseNode.parentElement))) {
|
||||
window.getSelection().removeAllRanges();
|
||||
}
|
||||
}
|
||||
|
||||
this.emit('keypress', key, ev);
|
||||
this.emit('key', key, ev);
|
||||
this.showCursor();
|
||||
|
||||
Reference in New Issue
Block a user