mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Notebooks: WYSIWYG Add Redo, Fix Shortcuts (#12752)
* Add redo and out/indent * Check for active cell before doing shortcut * PR feedback * Remove unnecessary parameter
This commit is contained in:
@@ -68,16 +68,20 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('document:keydown', ['$event'])
|
@HostListener('document:keydown', ['$event'])
|
||||||
onkeydown(e) {
|
onkeydown(e: KeyboardEvent) {
|
||||||
// use preventDefault() to avoid invoking the editor's select all
|
if (this.isActive()) {
|
||||||
// select the active .
|
// select the active .
|
||||||
if ((e.ctrlKey || e.metaKey) && e.key === 'a') {
|
if ((e.ctrlKey || e.metaKey) && e.key === 'a') {
|
||||||
e.preventDefault();
|
preventDefaultAndExecCommand(e, 'selectAll');
|
||||||
document.execCommand('selectAll');
|
} else if ((e.metaKey && e.shiftKey && e.key === 'z') || (e.ctrlKey && e.key === 'y')) {
|
||||||
}
|
preventDefaultAndExecCommand(e, 'redo');
|
||||||
if ((e.ctrlKey || e.metaKey) && e.key === 'z') {
|
} else if ((e.ctrlKey || e.metaKey) && e.key === 'z') {
|
||||||
e.preventDefault();
|
preventDefaultAndExecCommand(e, 'undo');
|
||||||
document.execCommand('undo');
|
} else if (e.shiftKey && e.key === 'Tab') {
|
||||||
|
preventDefaultAndExecCommand(e, 'outdent');
|
||||||
|
} else if (e.key === 'Tab') {
|
||||||
|
preventDefaultAndExecCommand(e, 'indent');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,3 +479,9 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
|
|||||||
this._model.updateActiveCell(this.cellModel);
|
this._model.updateActiveCell(this.cellModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function preventDefaultAndExecCommand(e: KeyboardEvent, commandId: string) {
|
||||||
|
// use preventDefault() to avoid invoking the editor's select all
|
||||||
|
e.preventDefault();
|
||||||
|
document.execCommand(commandId);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user