12360 Notebook UI - Mac/Win fix for Select all. (#12383) (#12397)

* 12360 Notebook UI - Mac/Win fix for Select all.

* Fix for ctrl key selecting all in windows

* Fix undo as well

* preventDefault to prevent confusing behavior

Co-authored-by: chlafreniere <hichise@gmail.com>

Co-authored-by: chlafreniere <hichise@gmail.com>
This commit is contained in:
Hale Rankin
2020-09-17 12:18:47 -07:00
committed by GitHub
parent 0bc81e1078
commit 3e22fcfd2d

View File

@@ -67,18 +67,19 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
this.enableActiveCellEditOnDoubleClick(); this.enableActiveCellEditOnDoubleClick();
} }
@HostListener('document:keydown.meta.a', ['$event']) @HostListener('document:keydown', ['$event'])
onkeydown(e) { onkeydown(e) {
// use preventDefault() to avoid invoking the editor's select all // use preventDefault() to avoid invoking the editor's select all
// select the active . // select the active .
if ((e.ctrlKey || e.metaKey) && e.key === 'a') {
e.preventDefault(); e.preventDefault();
document.execCommand('selectAll'); document.execCommand('selectAll');
} }
if ((e.ctrlKey || e.metaKey) && e.key === 'z') {
@HostListener('document:keydown.meta.z', ['$event']) e.preventDefault();
onUndo(e) {
document.execCommand('undo'); document.execCommand('undo');
} }
}
private _content: string | string[]; private _content: string | string[];
private _lastTrustedMode: boolean; private _lastTrustedMode: boolean;