mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Touchbar icon support in notebooks (#4998)
* Touchbar icon support in notebooks - updated shortcut keys to only work if notebook is active - Added icons - Now have 1 "add cell" icon that prompts for code/text. This is useful as there wasn't an icon to differentiate
This commit is contained in:
@@ -14,14 +14,16 @@ import { JupyterController } from './jupyter/jupyterController';
|
||||
import { AppContext } from './common/appContext';
|
||||
import { ApiWrapper } from './common/apiWrapper';
|
||||
import { IExtensionApi } from './types';
|
||||
import { CellType } from './contracts/content';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
const JUPYTER_NOTEBOOK_PROVIDER = 'jupyter';
|
||||
const msgSampleCodeDataFrame = localize('msgSampleCodeDataFrame', 'This sample code loads the file into a data frame and shows the first 10 results.');
|
||||
const noNotebookVisible = localize('noNotebookVisible', 'No notebook editor is active');
|
||||
const msgSampleCodeDataFrame = localize('msgSampleCodeDataFrame', "This sample code loads the file into a data frame and shows the first 10 results.");
|
||||
const noNotebookVisible = localize('noNotebookVisible', "No notebook editor is active");
|
||||
|
||||
let controller: JupyterController;
|
||||
type ChooseCellType = { label: string, id: CellType};
|
||||
|
||||
export async function activate(extensionContext: vscode.ExtensionContext): Promise<IExtensionApi> {
|
||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.new', (context?: azdata.ConnectedContext) => {
|
||||
@@ -37,6 +39,30 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
|
||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.runactivecell', () => {
|
||||
runActiveCell();
|
||||
}));
|
||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.addcell', async () => {
|
||||
let cellType: CellType;
|
||||
try {
|
||||
let cellTypes: ChooseCellType[] = [{
|
||||
label: localize('codeCellName', "Code"),
|
||||
id: 'code'
|
||||
},
|
||||
{
|
||||
label: localize('textCellName', "Text"),
|
||||
id: 'markdown'
|
||||
}];
|
||||
let selection = await vscode.window.showQuickPick(cellTypes, {
|
||||
placeHolder: localize('selectCellType', "What type of cell do you want to add?")
|
||||
});
|
||||
if (selection) {
|
||||
cellType = selection.id;
|
||||
}
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
if (cellType) {
|
||||
addCell(cellType);
|
||||
}
|
||||
}));
|
||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.addcode', () => {
|
||||
addCell('code');
|
||||
}));
|
||||
@@ -97,7 +123,7 @@ async function openNotebook(): Promise<void> {
|
||||
try {
|
||||
let filter = {};
|
||||
// TODO support querying valid notebook file types
|
||||
filter[localize('notebookFiles', 'Notebooks')] = ['ipynb'];
|
||||
filter[localize('notebookFiles', "Notebooks")] = ['ipynb'];
|
||||
let file = await vscode.window.showOpenDialog({
|
||||
filters: filter
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user