mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fix tabbing through Notebook cells (#9758)
* Fix tabbing through Notebook cells * Fix toggle tab command and re-order DOM
This commit is contained in:
@@ -5,12 +5,14 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
-->
|
-->
|
||||||
<div style="width: 100%; height: 100%; display: flex; flex-flow: row" (mouseover)="hover=true" (mouseleave)="hover=false">
|
<div style="width: 100%; height: 100%; display: flex; flex-flow: row" (mouseover)="hover=true" (mouseleave)="hover=false">
|
||||||
<div #toolbar class="toolbar">
|
|
||||||
</div>
|
|
||||||
<div style="flex: 1 1 auto; flex-flow: column; overflow: hidden;">
|
<div style="flex: 1 1 auto; flex-flow: column; overflow: hidden;">
|
||||||
<div #editor class="editor"></div>
|
<div style="display: flex; flex-flow: row">
|
||||||
|
<div #toolbar class="toolbar"></div>
|
||||||
|
<div style="flex: 1 1 auto; overflow: hidden;">
|
||||||
|
<div #editor class="editor"></div>
|
||||||
|
</div>
|
||||||
|
<div #moreactions class="moreActions" style="flex: 0 0 auto; flex-flow:column;width: 20px; min-height: 20px; max-height: 20px; padding-top: 0px; orientation: portrait"></div>
|
||||||
|
</div>
|
||||||
<collapse-component *ngIf="cellModel.cellType === 'code' && cellModel.source && cellModel.source.length > 1" [cellModel]="cellModel" [activeCellId]="activeCellId"></collapse-component>
|
<collapse-component *ngIf="cellModel.cellType === 'code' && cellModel.source && cellModel.source.length > 1" [cellModel]="cellModel" [activeCellId]="activeCellId"></collapse-component>
|
||||||
</div>
|
</div>
|
||||||
<div #moreactions class="moreActions" style="flex: 0 0 auto; display: flex; flex-flow:column;width: 20px; min-height: 20px; max-height: 20px; padding-top: 0px; orientation: portrait">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -21,12 +21,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div *ngFor="let cell of cells">
|
<div *ngFor="let cell of cells">
|
||||||
<div class="notebook-cell"
|
<div class="notebook-cell" (click)="selectCell(cell, $event)" [class.active]="cell.active">
|
||||||
(click)="selectCell(cell, $event)"
|
|
||||||
(focus)="selectCell(cell, $event)"
|
|
||||||
[class.active]="cell.active"
|
|
||||||
[attr.aria-label]="cell.ariaLabel"
|
|
||||||
tabindex="0">
|
|
||||||
<code-cell-component *ngIf="cell.cellType === 'code'" [cellModel]="cell" [model]="model" [activeCellId]="activeCellId">
|
<code-cell-component *ngIf="cell.cellType === 'code'" [cellModel]="cell" [model]="model" [activeCellId]="activeCellId">
|
||||||
</code-cell-component>
|
</code-cell-component>
|
||||||
<text-cell-component *ngIf="cell.cellType === 'markdown'" [cellModel]="cell" [model]="model" [activeCellId]="activeCellId">
|
<text-cell-component *ngIf="cell.cellType === 'markdown'" [cellModel]="cell" [model]="model" [activeCellId]="activeCellId">
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } fro
|
|||||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
import { IEditorInputFactoryRegistry, Extensions as EditorInputFactoryExtensions } from 'vs/workbench/common/editor';
|
import { IEditorInputFactoryRegistry, Extensions as EditorInputFactoryExtensions, ActiveEditorContext } from 'vs/workbench/common/editor';
|
||||||
|
|
||||||
import { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
import { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/services/languageAssociation/common/languageAssociation';
|
||||||
import { UntitledNotebookInput } from 'sql/workbench/contrib/notebook/browser/models/untitledNotebookInput';
|
import { UntitledNotebookInput } from 'sql/workbench/contrib/notebook/browser/models/untitledNotebookInput';
|
||||||
@@ -45,6 +45,7 @@ import { TextCellComponent } from 'sql/workbench/contrib/notebook/browser/cellVi
|
|||||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||||
import { NotebookThemingContribution } from 'sql/workbench/contrib/notebook/browser/notebookThemingContribution';
|
import { NotebookThemingContribution } from 'sql/workbench/contrib/notebook/browser/notebookThemingContribution';
|
||||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||||
|
import { ToggleTabFocusModeAction } from 'vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode';
|
||||||
|
|
||||||
Registry.as<IEditorInputFactoryRegistry>(EditorInputFactoryExtensions.EditorInputFactories)
|
Registry.as<IEditorInputFactoryRegistry>(EditorInputFactoryExtensions.EditorInputFactories)
|
||||||
.registerEditorInputFactory(FileNotebookInput.ID, FileNoteBookEditorInputFactory);
|
.registerEditorInputFactory(FileNotebookInput.ID, FileNoteBookEditorInputFactory);
|
||||||
@@ -135,6 +136,25 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerWidgetContext, {
|
|||||||
order: 1
|
order: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const TOGGLE_TAB_FOCUS_COMMAND_ID = 'notebook.action.toggleTabFocusMode';
|
||||||
|
const toggleTabFocusAction = new ToggleTabFocusModeAction();
|
||||||
|
|
||||||
|
CommandsRegistry.registerCommand({
|
||||||
|
id: TOGGLE_TAB_FOCUS_COMMAND_ID,
|
||||||
|
handler: (accessor) => {
|
||||||
|
toggleTabFocusAction.run(accessor, undefined);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
||||||
|
command: {
|
||||||
|
id: TOGGLE_TAB_FOCUS_COMMAND_ID,
|
||||||
|
title: toggleTabFocusAction.label,
|
||||||
|
},
|
||||||
|
when: ContextKeyExpr.and(ActiveEditorContext.isEqualTo(NotebookEditor.ID))
|
||||||
|
});
|
||||||
|
|
||||||
registerAction2(class extends Action2 {
|
registerAction2(class extends Action2 {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
|
|||||||
@@ -56,10 +56,6 @@ export class CellModel implements ICellModel {
|
|||||||
private _isCollapsed: boolean;
|
private _isCollapsed: boolean;
|
||||||
private _onCollapseStateChanged = new Emitter<boolean>();
|
private _onCollapseStateChanged = new Emitter<boolean>();
|
||||||
private _modelContentChangedEvent: IModelContentChangedEvent;
|
private _modelContentChangedEvent: IModelContentChangedEvent;
|
||||||
private readonly _ariaLabel: string;
|
|
||||||
|
|
||||||
private readonly codeCellLabel = localize('codeCellLabel', "Code Cell");
|
|
||||||
private readonly textCellLabel = localize('textCellLabel', "Text Cell");
|
|
||||||
|
|
||||||
constructor(cellData: nb.ICellContents,
|
constructor(cellData: nb.ICellContents,
|
||||||
private _options: ICellModelOptions,
|
private _options: ICellModelOptions,
|
||||||
@@ -74,12 +70,6 @@ export class CellModel implements ICellModel {
|
|||||||
this._source = '';
|
this._source = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._cellType === CellTypes.Code) {
|
|
||||||
this._ariaLabel = this.codeCellLabel;
|
|
||||||
} else {
|
|
||||||
this._ariaLabel = this.textCellLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._isEditMode = this._cellType !== CellTypes.Markdown;
|
this._isEditMode = this._cellType !== CellTypes.Markdown;
|
||||||
this._stdInVisible = false;
|
this._stdInVisible = false;
|
||||||
if (_options && _options.isTrusted) {
|
if (_options && _options.isTrusted) {
|
||||||
@@ -96,10 +86,6 @@ export class CellModel implements ICellModel {
|
|||||||
return other !== undefined && other.id === this.id;
|
return other !== undefined && other.id === this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get ariaLabel(): string {
|
|
||||||
return this._ariaLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get onCollapseStateChanged(): Event<boolean> {
|
public get onCollapseStateChanged(): Event<boolean> {
|
||||||
return this._onCollapseStateChanged.event;
|
return this._onCollapseStateChanged.event;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -487,7 +487,6 @@ export interface ICellModel {
|
|||||||
readonly onCellModeChanged: Event<boolean>;
|
readonly onCellModeChanged: Event<boolean>;
|
||||||
modelContentChangedEvent: IModelContentChangedEvent;
|
modelContentChangedEvent: IModelContentChangedEvent;
|
||||||
isEditMode: boolean;
|
isEditMode: boolean;
|
||||||
readonly ariaLabel: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IModelFactory {
|
export interface IModelFactory {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export class ToggleTabFocusModeAction extends EditorAction {
|
|||||||
precondition: undefined,
|
precondition: undefined,
|
||||||
kbOpts: {
|
kbOpts: {
|
||||||
kbExpr: null,
|
kbExpr: null,
|
||||||
primary: KeyMod.CtrlCmd | KeyCode.KEY_M,
|
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_M, // {{SQL CARBON EDIT}} We use Ctrl+M already so move this to an unused binding
|
||||||
mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KEY_M },
|
mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KEY_M },
|
||||||
weight: KeybindingWeight.EditorContrib
|
weight: KeybindingWeight.EditorContrib
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user