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