mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Handle key_up in callout dialog (#15472)
This commit is contained in:
@@ -22,6 +22,7 @@ import { InputBox } from 'sql/base/browser/ui/inputBox/inputBox';
|
|||||||
import { attachCalloutDialogStyler } from 'sql/workbench/common/styler';
|
import { attachCalloutDialogStyler } from 'sql/workbench/common/styler';
|
||||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||||
import { escapeLabel, escapeUrl } from 'sql/workbench/contrib/notebook/browser/calloutDialog/common/utils';
|
import { escapeLabel, escapeUrl } from 'sql/workbench/contrib/notebook/browser/calloutDialog/common/utils';
|
||||||
|
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||||
|
|
||||||
export interface ILinkCalloutDialogOptions {
|
export interface ILinkCalloutDialogOptions {
|
||||||
insertTitle?: string,
|
insertTitle?: string,
|
||||||
@@ -100,6 +101,13 @@ export class LinkCalloutDialog extends Modal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected renderBody(container: HTMLElement) {
|
protected renderBody(container: HTMLElement) {
|
||||||
|
this._register(DOM.addDisposableListener(document, DOM.EventType.KEY_UP, (e: KeyboardEvent) => {
|
||||||
|
let event = new StandardKeyboardEvent(e);
|
||||||
|
if (event.equals(KeyCode.Enter)) {
|
||||||
|
DOM.EventHelper.stop(e, true);
|
||||||
|
this.hide('ok');
|
||||||
|
}
|
||||||
|
}));
|
||||||
let linkContentColumn = DOM.$('.column.insert-link');
|
let linkContentColumn = DOM.$('.column.insert-link');
|
||||||
DOM.append(container, linkContentColumn);
|
DOM.append(container, linkContentColumn);
|
||||||
|
|
||||||
@@ -147,7 +155,8 @@ export class LinkCalloutDialog extends Modal {
|
|||||||
protected onAccept(e?: StandardKeyboardEvent) {
|
protected onAccept(e?: StandardKeyboardEvent) {
|
||||||
// EventHelper.stop() will call preventDefault. Without it, text cell will insert an extra newline when pressing enter on dialog
|
// EventHelper.stop() will call preventDefault. Without it, text cell will insert an extra newline when pressing enter on dialog
|
||||||
DOM.EventHelper.stop(e, true);
|
DOM.EventHelper.stop(e, true);
|
||||||
this.insert();
|
const keyboardEventExists = !!e;
|
||||||
|
this.insert(keyboardEventExists);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected onClose(e?: StandardKeyboardEvent) {
|
protected onClose(e?: StandardKeyboardEvent) {
|
||||||
@@ -155,8 +164,10 @@ export class LinkCalloutDialog extends Modal {
|
|||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public insert(): void {
|
public insert(willHideByKeyboardEvent = false): void {
|
||||||
this.hide('ok');
|
if (!willHideByKeyboardEvent) {
|
||||||
|
this.hide('ok');
|
||||||
|
}
|
||||||
let escapedLabel = escapeLabel(this._linkTextInputBox.value);
|
let escapedLabel = escapeLabel(this._linkTextInputBox.value);
|
||||||
let escapedUrl = escapeUrl(this._linkUrlInputBox.value);
|
let escapedUrl = escapeUrl(this._linkUrlInputBox.value);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user