Make notebook cells selectable for tab navigation. (#8946)

This commit is contained in:
Cory Rivera
2020-01-23 15:39:27 -08:00
committed by GitHub
parent 5ccc0fd97b
commit 2eebcab74a
4 changed files with 22 additions and 2 deletions

View File

@@ -54,6 +54,10 @@ export class CellModel implements ICellModel {
private _isCollapsed: boolean;
private _onCollapseStateChanged = new Emitter<boolean>();
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,
private _options: ICellModelOptions,
@@ -67,6 +71,13 @@ export class CellModel implements ICellModel {
this._cellType = CellTypes.Code;
this._source = '';
}
if (this._cellType === CellTypes.Code) {
this._ariaLabel = this.codeCellLabel;
} else {
this._ariaLabel = this.textCellLabel;
}
this._isEditMode = this._cellType !== CellTypes.Markdown;
this._stdInVisible = false;
if (_options && _options.isTrusted) {
@@ -83,6 +94,10 @@ export class CellModel implements ICellModel {
return other !== undefined && other.id === this.id;
}
public get ariaLabel(): string {
return this._ariaLabel;
}
public get onCollapseStateChanged(): Event<boolean> {
return this._onCollapseStateChanged.event;
}

View File

@@ -543,6 +543,7 @@ export interface ICellModel {
readonly onCollapseStateChanged: Event<boolean>;
modelContentChangedEvent: IModelContentChangedEvent;
isEditMode: boolean;
readonly ariaLabel: string;
}
export interface FutureInternal extends nb.IFuture {

View File

@@ -21,7 +21,12 @@
</button>
</div>
<div *ngFor="let cell of cells">
<div class="notebook-cell" (click)="selectCell(cell, $event)" [class.active]="cell.active">
<div class="notebook-cell"
(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>
<text-cell-component *ngIf="cell.cellType === 'markdown'" [cellModel]="cell" [model]="model" [activeCellId]="activeCellId">

View File

@@ -9,7 +9,6 @@ export type CellType = 'code' | 'markdown' | 'raw';
export class CellTypes {
public static readonly Code = 'code';
public static readonly Markdown = 'markdown';
public static readonly Raw = 'raw';
}
// to do: add all mime types