mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -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:
@@ -57,7 +57,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "notebook.command.runactivecell",
|
"command": "notebook.command.runactivecell",
|
||||||
"title": "%notebook.command.runactivecell%"
|
"title": "%notebook.command.runactivecell%",
|
||||||
|
"icon": "resources/dark/touchbar_run_cell.png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "notebook.command.addcode",
|
"command": "notebook.command.addcode",
|
||||||
@@ -67,6 +68,11 @@
|
|||||||
"command": "notebook.command.addtext",
|
"command": "notebook.command.addtext",
|
||||||
"title": "%notebook.command.addtext%"
|
"title": "%notebook.command.addtext%"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "notebook.command.addcell",
|
||||||
|
"title": "%notebook.command.addcell%",
|
||||||
|
"icon": "resources/dark/touchbar_add_cell.png"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "jupyter.cmd.analyzeNotebook",
|
"command": "jupyter.cmd.analyzeNotebook",
|
||||||
"title": "%title.analyzeJupyterNotebook%"
|
"title": "%title.analyzeJupyterNotebook%"
|
||||||
@@ -147,6 +153,10 @@
|
|||||||
"command": "notebook.command.addtext",
|
"command": "notebook.command.addtext",
|
||||||
"when": "notebookEditorVisible"
|
"when": "notebookEditorVisible"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "notebook.command.addcell",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "jupyter.task.newNotebook",
|
"command": "jupyter.task.newNotebook",
|
||||||
"when": "false"
|
"when": "false"
|
||||||
@@ -172,17 +182,12 @@
|
|||||||
{
|
{
|
||||||
"command": "notebook.command.runactivecell",
|
"command": "notebook.command.runactivecell",
|
||||||
"when": "activeEditor == workbench.editor.notebookEditor",
|
"when": "activeEditor == workbench.editor.notebookEditor",
|
||||||
"group": "1_notebook"
|
"group": "1_notebook@1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "notebook.command.addcode",
|
"command": "notebook.command.addcell",
|
||||||
"when": "activeEditor == workbench.editor.notebookEditor",
|
"when": "activeEditor == workbench.editor.notebookEditor",
|
||||||
"group": "2_notebook"
|
"group": "1_notebook@2"
|
||||||
},
|
|
||||||
{
|
|
||||||
"command": "notebook.command.addtext",
|
|
||||||
"when": "activeEditor == workbench.editor.notebookEditor",
|
|
||||||
"group": "2_notebook"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"objectExplorer/item/context": [
|
"objectExplorer/item/context": [
|
||||||
@@ -222,17 +227,17 @@
|
|||||||
{
|
{
|
||||||
"command": "notebook.command.runactivecell",
|
"command": "notebook.command.runactivecell",
|
||||||
"key": "F5",
|
"key": "F5",
|
||||||
"when": "notebookEditorVisible"
|
"when": "activeEditor == workbench.editor.notebookEditor"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "notebook.command.addcode",
|
"command": "notebook.command.addcode",
|
||||||
"key": "Ctrl+Shift+C",
|
"key": "Ctrl+Shift+C",
|
||||||
"when": "notebookEditorVisible"
|
"when": "activeEditor == workbench.editor.notebookEditor"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "notebook.command.addtext",
|
"command": "notebook.command.addtext",
|
||||||
"key": "Ctrl+Shift+T",
|
"key": "Ctrl+Shift+T",
|
||||||
"when": "notebookEditorVisible"
|
"when": "activeEditor == workbench.editor.notebookEditor"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"notebook.languagemagics": [
|
"notebook.languagemagics": [
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"notebook.command.runactivecell": "Run Cell",
|
"notebook.command.runactivecell": "Run Cell",
|
||||||
"notebook.command.addcode": "Add Code Cell",
|
"notebook.command.addcode": "Add Code Cell",
|
||||||
"notebook.command.addtext": "Add Text Cell",
|
"notebook.command.addtext": "Add Text Cell",
|
||||||
|
"notebook.command.addcell": "Add Cell",
|
||||||
"title.analyzeJupyterNotebook": "Analyze in Notebook",
|
"title.analyzeJupyterNotebook": "Analyze in Notebook",
|
||||||
"title.newJupyterNotebook": "New Notebook",
|
"title.newJupyterNotebook": "New Notebook",
|
||||||
"title.openJupyterNotebook": "Open Notebook",
|
"title.openJupyterNotebook": "Open Notebook",
|
||||||
|
|||||||
BIN
extensions/notebook/resources/dark/touchbar_add_cell.png
Normal file
BIN
extensions/notebook/resources/dark/touchbar_add_cell.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 766 B |
BIN
extensions/notebook/resources/dark/touchbar_run_cell.png
Normal file
BIN
extensions/notebook/resources/dark/touchbar_run_cell.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 826 B |
@@ -14,14 +14,16 @@ import { JupyterController } from './jupyter/jupyterController';
|
|||||||
import { AppContext } from './common/appContext';
|
import { AppContext } from './common/appContext';
|
||||||
import { ApiWrapper } from './common/apiWrapper';
|
import { ApiWrapper } from './common/apiWrapper';
|
||||||
import { IExtensionApi } from './types';
|
import { IExtensionApi } from './types';
|
||||||
|
import { CellType } from './contracts/content';
|
||||||
|
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
const JUPYTER_NOTEBOOK_PROVIDER = 'jupyter';
|
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 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 noNotebookVisible = localize('noNotebookVisible', "No notebook editor is active");
|
||||||
|
|
||||||
let controller: JupyterController;
|
let controller: JupyterController;
|
||||||
|
type ChooseCellType = { label: string, id: CellType};
|
||||||
|
|
||||||
export async function activate(extensionContext: vscode.ExtensionContext): Promise<IExtensionApi> {
|
export async function activate(extensionContext: vscode.ExtensionContext): Promise<IExtensionApi> {
|
||||||
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.new', (context?: azdata.ConnectedContext) => {
|
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', () => {
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.runactivecell', () => {
|
||||||
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', () => {
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.addcode', () => {
|
||||||
addCell('code');
|
addCell('code');
|
||||||
}));
|
}));
|
||||||
@@ -97,7 +123,7 @@ async function openNotebook(): Promise<void> {
|
|||||||
try {
|
try {
|
||||||
let filter = {};
|
let filter = {};
|
||||||
// TODO support querying valid notebook file types
|
// TODO support querying valid notebook file types
|
||||||
filter[localize('notebookFiles', 'Notebooks')] = ['ipynb'];
|
filter[localize('notebookFiles', "Notebooks")] = ['ipynb'];
|
||||||
let file = await vscode.window.showOpenDialog({
|
let file = await vscode.window.showOpenDialog({
|
||||||
filters: filter
|
filters: filter
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user